Commit Graph

76 Commits

Author SHA1 Message Date
Florian Müllner
a1dd1b25d8 js: Use templates for non-translatable strings
This reverts commit 9d941f8202 and replaces all additional
instances of .format() that have been added since.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2160>
2022-02-12 12:29:52 +00:00
Florian Müllner
5442266f28 js: Simplify promisify() calls
If the finish function isn't specified, promisify will now try
to use the async name without '_async'/'_begin' suffix (if any)
and '_finish' appended.

Everything except IBus uses a variation of that pattern, so there's
quite a bit of boilerplate we get to remove…

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2174>
2022-02-11 16:24:01 +00:00
Florian Müllner
ef70364e81 cleanup: Replace non-standard ByteArray module
gjs landed support for TextDecoder/TextEncoder. Use those instead
of gjs' own ByteArray module.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1946>
2021-09-01 14:49:30 +00:00
Florian Müllner
ae90b50dc7 extensionDownloader: Port to Soup3
After 13 years, Soup will release a new, API-incompatible
version[0]. This is a good thing, make sure we support it.

[0] https://blog.tingping.se/2021/02/23/future-of-libsoup.html

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1940>
2021-08-25 01:54:07 +02:00
Florian Müllner
3ad569f426 extensionDownloader: Use plain Soup.Session
Unlike for the old Soup.SessionSync/SessionAsync classes,
Soup.Session:ssl-use-system-ca-file already defaults to true.

In Soup3, the behavior was made unconditional and the property
removed.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1940>
2021-08-25 01:54:07 +02:00
Florian Müllner
f14960ff03 extensionDownloader: Stop setting proxy resolver explicitly
Quoting the documentation:

  In libsoup 2.44 and later, you can set the session's “proxy-resolver”
  property to the resolver returned by g_proxy_resolver_get_default() to
  get the same effect. Note that for "plain" SoupSessions (ie, not
  SoupSessionAsync or SoupSessionSync), this is done for you automatically.

libsoup 2.44 was released in 2013, so we can safely assume that Soup is
new enough to handle this for us.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1940>
2021-08-25 01:54:07 +02:00
Florian Müllner
6bf20837c0 extensionDownloader: Use async code for extracting archive
The code that handles extracting extension archives currently uses
an awkward double-callback system. We can do significantly better
by using an async function and exceptions.

Partially based on code from Marco Trevisan.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1940>
2021-08-25 01:54:07 +02:00
Florian Müllner
f16fda5ea1 extensionDownloader: Stop returning distinct errors
Nothing looks at our made-up errors, so we can just as well return
a generic "ExtensionError".

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1940>
2021-08-24 15:48:04 +00:00
Florian Müllner
b3bdcbcf3f extensionDownloader: Fix up style
Move all remaining bits to the new coding style before making
further changes.

The let → const changes are selectively done to the bits that'll
still be around at the end of the patch series.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1940>
2021-08-24 15:48:04 +00:00
Yuri Konotopov
02b06385ea extensionDownloader: Use POST request for checking updates
Usage of GET requests for checking updates was made deprecated
at website some time ago [1], but REST endpoint was
CSRF-protected until recently [2].
The body of update request may be big enough and thus does not
suitable for GET requests.

[1] 0b38da1b2b
[2] e3ab0c07dc

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1781>
2021-03-31 13:31:00 +04:00
Jeremias Ortega
f0d2509dc3 extensionDownloader: Fix check for updates with several extensions
When having several extensions installed checking for updates fails.
This is because we are using GET and query params and since we are
sending all the metadata of the extension the server returns 502
when the URL is too long. This error code is ignored safely.

It is only needed to send the version of the extension to check if it
has updates.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2962
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1363
2020-07-15 18:26:11 -06:00
Michael Lass
a47e0f9845 extensionDownloader: Replace deprecated Soup.SessionAsync
Soup.SessionAsync by default sets timeout and idle_timeout to 0. This
causes connections to hang around in state CLOSE_WAIT forever after the
remote host has closed the connection.

To fix this, we could set timeout and idle_timeout manually. However,
Soup.SessionAsync is marked as deprecated anyway and should be replaced
by Soup.Session. Doing so also sets a default timeout of 60 seconds.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2774
2020-05-14 19:43:56 +00:00
Florian Müllner
660a2b6e62 extensionSystem: Require Extensions app for updates
While we don't technically need the app to download and apply
updates, we do require it for notifying the user about available
updates and listing extensions with pending updates.

So instead of intransparently applying updates in the background
without the user noticing, disable updates altogether if the
Extensions app is not installed.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2346
2020-03-27 13:28:41 +00:00
Florian Müllner
cc347bf6d8 extensionDownloader: Stop handling 'blacklist' operation
Blacklist support was added all the way back in commit 1e286e43, but
the code had been defunctional until recently. While uninstalling an
extension that has been blacklisted makes sense off-hand, unfortunately
we don't know if an extension was *actually* blacklisted:

The website returns that operation for any extensions for which it
doesn't find any versions that match the shell version. That is, the
most likely reason is that the user updated to a new GNOME release
which the extension doesn't support yet.

It doesn't look like the website is going to change that behavior any
time soon[0], so drop the 'blacklist' handling for the time being.

[0] https://gitlab.gnome.org/Infrastructure/extensions-web/-/issues/95

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1132
2020-03-27 12:41:57 +00:00
Florian Müllner
d3939a38a3 extensionDownloader: Remove pending updates with extension
When an extension is uninstalled, there is no point in keeping
a pending update: If the update didn't fail (which it currently
does), we would end up sneakily reinstalling the extension.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2343
2020-03-17 14:19:20 +00:00
Florian Müllner
69ea038a8f extensionDownloader: Only check server if there's something to update
checkForUpdates() will currently always query the server for updates,
even when passing an empty vardict of installed extensions. We know
there won't be any updates in that case, so avoid a pointless network
request.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1100
2020-03-17 13:56:49 +00:00
Florian Müllner
9d941f8202 js: Don't use templates in files with translations
xgettext gained some support for template strings, and no longer
fails when encountering '/' somewhere between backticks.

Unfortunately its support is still buggy as hell, and it is now
silently dropping translatable strings, yay. I hate making the
code worse, but until xgettext really gets its shit together,
the only viable way forward seems to be to not use template
strings in any files listed in POTFILES.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1014
2020-02-17 23:20:40 +01:00
Florian Müllner
ea5732fe6f extensionDownloader: Include version validation in update check
The extensions website will consider the setting to find the best suitable
extension version, so we should transmit the parameter for better results.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/945
2020-01-30 13:37:47 +00:00
Florian Müllner
b7e828fa3c extensionDownloader: Exclude extensions with pending updates from check
While it is possible that an extension has a newer version available
than the previously downloaded update, it's more likely that we end up
downloading the same archive again. That would be a bit silly despite
the usually small size, so we can either use the metadata from the
update, or exclude the extension from the check.

The latter is much easier, so let's go with that for now.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/945
2020-01-30 13:37:47 +00:00
Florian Müllner
cbc9bc5fc6 extensionDownloader: Only check updates for user extensions
System extensions cannot be updated through the website, so don't
even try.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/945
2020-01-30 13:37:47 +00:00
Florian Müllner
9c785ca6b6 extensionDownloader: Make checkForUpdates() check for updates
Currently the method installs updates instead of merely checking for
them (or it would do, if it actually worked).

This is not just surprising considering the method name, the whole idea
of live updates is problematic and will not work properly more often
than not:
 - imports are cached, so any local modules will stay at their
   original version until a shell restart
 - GTypes cannot be unregistered

So change the method to only download available updates, and set the
extensions' hasUpdate state accordingly.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/945
2020-01-30 13:37:47 +00:00
Jonas Dreßler
6c1cd1d8be extensionDownloader: Adapt install dialog to new design
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/962
2020-01-27 23:40:04 +01:00
Sebastian Keller
b4ed8a3d06 extensionDownloader: Use uuid lookup method in checkForUpdates()
The extensions variable the code was trying to access was made private
and turned into a map some time ago.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1958
2020-01-22 17:08:11 +01:00
Jonas Dreßler
5d99bdbe5e dialog: Remove icons from dialogs
According to the new mockups, remove the icon from MessageDialogContent

See https://gitlab.gnome.org/GNOME/gnome-shell/issues/1343

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/886
2020-01-15 00:05:34 +01:00
Florian Müllner
ebf77748a8 cleanup: Require "dangling" commas
Since ES5, trailing commas in arrays and object literals are valid.
We generally haven't used them so far, but they are actually a good
idea, as they make additions and removals in diffs much cleaner.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
c860409da5 cleanup: Use object shorthand where possible
ES6 allows to omit property names where they match the name of the
assigned variable, which makes code less redunant and thus cleaner.
We will soon enforce that in our eslint rules, so make sure we use
the shorthand wherever possible.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
682bd7e97c cleanup: Don't shadow variables
Having variables that share the same name in overlapping scopes is
confusing and error-prone, and is best avoided.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
d3d165243c cleanup: Use non-deprecated key symbols
Clutter originally cluttered its namespace with key symbols, before
prefixing all symbols with KEY. We still use the unprefixed symbols
occasionally, replace them so mutter can drop the deprecated symbols.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/808
2019-11-06 09:42:57 +01:00
Florian Müllner
451f4e3636 cleanup: "Only" use two indentation styles for object literals
We currently use no less than three different ways of indenting
object literals:

    let obj1 = {
        foo: 42,
        bar: 23,
    };

    let obj2 = { foo: 42,
                 bar: 23 };

    let obj3 = { foo: 42,
                 bar: 23
               };

The first is the one we want to use everywhere eventually, while the
second is the most commonly used "legacy" style.

It is the third one that is most problematic, as it throws off eslint
fairly badly: It violates both the rule to have consistent line breaks
in braces as well as the indentation style of both regular and legacy
configurations.

Fortunately the third style was mostly used for tween parameters, so
is quite rare after the Tweener purge. Get rid of the remaining ones
to cut down on pre-existing eslint errors.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/716
2019-09-12 23:18:24 +02:00
Florian Müllner
e357559582 cleanup: Mark globals used from other modules as exported
eslint cannot figure out that those symbols are used from other modules
via imports, so they trigger unused-variable errors. To fix, explicitly
mark those symbols as exported.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/627
2019-07-24 00:28:45 +02:00
Florian Müllner
79cf3a6dd0 cleanup: Remove some unhelpful unused arguments
Those unused arguments aren't bugs - unbeknownst to eslint, they all
correspond to valid signal parameters - but they don't contribute
anything to clarity, so just remove them anyway.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/627
2019-07-24 00:28:45 +02:00
Florian Müllner
43cb3754d9 extensionSystem: Store extensions in a Map
After making the extensions map private to the ExtensionManager, we can
switch it to a proper hash table which is more appropriate.

https://bugzilla.gnome.org/show_bug.cgi?id=789852
2019-07-20 14:17:35 +00:00
Florian Müllner
1d6ddf060b extensionSystem: Move extension loading into ExtensionManager
Now that extension loading and the extensions map are no longer shared
between the gnome-shell and gnome-shell-extension-prefs processes, we
can move both into the ExtensionManager which makes much more sense
conceptually.

https://bugzilla.gnome.org/show_bug.cgi?id=789852
2019-07-20 14:17:35 +00:00
Didier Roche
4589da957b extensionSystem: Add methods to enable/disable extensions
Extensions are currently enabled or disabled by directly changing the
list in the 'enabled-extensions' GSettings key. As we will soon add
an overriding 'disabled-extensions' key as well, it makes sense to
offer explicit API for enabling/disabling to avoid duplicating the
logic.

For the corresponding D-Bus API, the methods were even mentioned in
the GSettings schema, albeit unimplemented until now.

https://bugzilla.gnome.org/show_bug.cgi?id=789852
2019-07-20 14:17:35 +00:00
Florian Müllner
ea17740719 extensionSystem: Turn into a class
The extension system started out as a set of simple functions, but
gained more state later, and even some hacks to emit signals without
having an object to emit them on.

There is no good reason for that weirdness, so rather than imitating an
object, wrap the existing system into a real ExtensionManager object.

https://bugzilla.gnome.org/show_bug.cgi?id=789852
2019-07-20 14:17:35 +00:00
Florian Müllner
0d035a4e53 cleanup: Prefer template strings
Template strings are much nicer than string concatenation, so use
them where possible; this excludes translatable strings and any
strings containing '/' (until we can depend on gettext >= 0.20[0]).

[0] https://savannah.gnu.org/bugs/?50920

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/612
2019-07-05 11:32:31 +00:00
Florian Müllner
7ac35c644e style: Fix stray/missing spaces
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +02:00
Florian Müllner
f250643385 style: Use space after catch
We are currently inconsistent with whether or not to put a space
after catch clauses. While the predominant style is to omit it,
that's inconsistent with the style we use for any other statement.
There's not really a good reason to stick with it, so switch to
the style gjs/eslint default to.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +02:00
Florian Müllner
e56d7f5021 cleanup: Remove unused variables
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:10 +02:00
Florian Müllner
0b08ee54bb cleanup: Clean up unused imports
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:10 +02:00
Florian Müllner
f6b4b96737 cleanup: Use Array.includes() to check for element existence
We can use that newer method where we don't care about the actual position
of an element inside the array.

(Array.includes() and Array.indexOf() do behave differently in edge cases,
for example in the handling of NaN, but those don't matter to us)

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/152
2019-07-01 21:28:52 +00:00
Florian Müllner
2f5086efaf extensionDownloader: Use common message dialog layout
While the confirmation dialog for extension installation is simpler
than - say - authentication dialogs, it still makes sense to re-use
the common content layout instead of duplicating it.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/600
2019-06-26 20:49:46 +02:00
Marco Trevisan (Treviño)
d25bcbc3a7 modalDialog: Inherit from St.Widget
Make the dialog a widget itself, removing the `_group` property used for
handling the actor.

Update all the inherited classes to be also GObject implementations, moving all
the signals to proper object ones.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/55
2019-05-24 16:27:25 -05:00
Florian Müllner
fd50b9a45e cleanup: Use destructuring for imports from GI
This is *much* nicer than repetitive "imports.gi" lines ...

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/399
2019-02-09 07:39:20 +01:00
Florian Müllner
a1534dab02 cleanup: Clean up unused imports
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/399
2019-02-09 05:05:07 +01:00
Florian Müllner
bacfdbbb03 cleanup: Port non-GObject classes to JS6 classes
ES6 finally adds standard class syntax to the language, so we can
replace our custom Lang.Class framework with the new syntax. Any
classes that inherit from GObject will need special treatment,
so limit the port to regular javascript classes for now.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361
2019-01-25 14:02:44 +00:00
Florian Müllner
3b1330880f cleanup: Use Function.prototype.bind()
When not using arrow notation with anonymous functions, we use Lang.bind()
to bind `this` to named callbacks. However since ES5, this functionality
is already provided by Function.prototype.bind() - in fact, Lang.bind()
itself uses it when no extra arguments are specified. Just use the built-in
function directly where possible, and use arrow notation in the few places
where we pass additional arguments.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:02 +00:00
Florian Müllner
213e38c2ef cleanup: Use arrow notation for anonymous functions
Arrow notation is great, use it consistently through-out the code base
to bind `this` to anonymous functions, replacing the more overbose
Lang.bind(this, function() {}).

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:00 +00:00
Florian Müllner
76f09b1e49 cleanup: Use method syntax
Modern javascript has a short-hand for function properties, embrace
it for better readability and to prepare for an eventual port to
ES6 classes.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:54:58 +00:00
Gautier Pelloux-Prayer
35a9c3ec86 extension: log message if extension could not be installed
https://bugzilla.gnome.org/show_bug.cgi?id=776940
2017-11-21 13:15:05 -05:00