Blob Blame History Raw
From d1a20dc80c3414ba4cb7bf839a25de49d30ab400 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Mon, 21 Sep 2015 20:18:12 +0200
Subject: [PATCH] extensionSystem: Notify about extension issues on update

---
 js/ui/extensionSystem.js | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js
index 9ffdb4f3d..eb820ba4f 100644
--- a/js/ui/extensionSystem.js
+++ b/js/ui/extensionSystem.js
@@ -1,8 +1,9 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
-const { Gio, St } = imports.gi;
+const { Gio, GLib, St } = imports.gi;
 const Signals = imports.signals;
 
+const Config = imports.misc.config;
 const ExtensionUtils = imports.misc.extensionUtils;
 const Main = imports.ui.main;
 
@@ -312,6 +313,36 @@ function _onVersionValidationChanged() {
     }
 }
 
+function _doUpdateCheck() {
+    let version = Config.PACKAGE_VERSION.split('.');
+    if (parseInt(version[1]) % 2 == 0)
+        version.pop();
+
+    let pkgCacheDir = GLib.get_user_cache_dir() + '/gnome-shell/';
+    let updateStamp = Gio.file_new_for_path(pkgCacheDir +
+                                            'update-check-' + version.join('.'));
+    if (updateStamp.query_exists(null))
+        return;
+
+    GLib.mkdir_with_parents (pkgCacheDir, 0o755);
+    updateStamp.create(0, null).close(null);
+
+   let nOutdated = enabledExtensions.reduce(function(n, uuid) {
+       let extension = ExtensionUtils.extensions[uuid];
+       if (extension && extension.state == ExtensionState.OUT_OF_DATE)
+           n++;
+       return n;
+   }, 0);
+
+   if (nOutdated == 0)
+       return;
+
+   Main.notify(ngettext("%d extension is out of date",
+                        "%d extensions are out of date",
+                        nOutdated).format(nOutdated),
+               _("You can visit http://extensions.gnome.org for updates"));
+}
+
 function _loadExtensions() {
     global.settings.connect('changed::' + ENABLED_EXTENSIONS_KEY, onEnabledExtensionsChanged);
     global.settings.connect('changed::' + DISABLE_USER_EXTENSIONS_KEY, onEnabledExtensionsChanged);
@@ -326,6 +357,7 @@ function _loadExtensions() {
             extension.type = ExtensionUtils.ExtensionType.SESSION_MODE;
     });
     finder.scanExtensions();
+    _doUpdateCheck();
 }
 
 function enableAllExtensions() {
-- 
2.21.0