Add automatic update block to custom.js.example user/tsbere/custom_updater
authorThomas Berezansky <tsbere@mvlc.org>
Mon, 10 Oct 2011 16:48:45 +0000 (12:48 -0400)
committerThomas Berezansky <tsbere@mvlc.org>
Mon, 10 Oct 2011 16:54:14 +0000 (12:54 -0400)
For those that want to enable automatic updates but use the official
download for the client.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Open-ILS/xul/staff_client/server/skin/custom.js.example

index b23a31f..74047d3 100644 (file)
@@ -66,3 +66,47 @@ function dump_xulG(msg) {
     }
     dump(']]]]]]]]]]]]]]]]]]]]]]]]]]]]]\n');
 }
+
+
+// This entire block basically dupliates autoupdate.js as a default preference file
+// Useful if you did not build your initial 2.1+ client, but are using the official download
+try {
+    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+    var appInfo = Components.classes["@mozilla.org/xre/app-info;1"] 
+            .getService(Components.interfaces.nsIXULAppInfo); 
+    // This ensures that if someone is running in extension mode we don't break the host app's updater
+    // And that we likely have a valid web hostname for later
+    if (appInfo.ID == "staff-client@open-ils.org" && (window.location.protocol == 'http:' || window.location.protocol == 'https:'))
+    {
+        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']);
+        // Enable Updater
+        prefs.setBoolPref("app.update.enabled", true);
+        // Change to "false" to not automatically update
+        prefs.setBoolPref("app.update.auto", true);
+        // 0 downloads without prompt always
+        prefs.setIntPref("app.update.mode", 0);
+
+        // These settings are in seconds
+        // Interval for checking
+        prefs.setIntPref("app.update.interval", 86400);
+        // Time before prompting to download - If auto is off, mainly
+        prefs.setIntPref("app.update.nagTimer.download", 86400);
+        // Time before prompting to restart to apply update that has downloaded
+        prefs.setIntPref("app.update.nagTimer.restart", 1800);
+
+        // How often to check timers (above) - in MILLIseconds
+        prefs.setIntPref("app.update.timer", 600000);
+
+        // URL for downloading. For Thomas Berezansky's script the update.xml part isn't needed.
+        // NOTE: Certs that default to invalid, even those overridden with cert_override.txt, won't work with this!
+        prefs.setCharPref("app.update.url", "https://" + window.location.hostname + "/updates/check/%CHANNEL%/%VERSION%/update.xml");
+
+        // URL for manual update information
+        prefs.setCharPref("app.update.url.manual", "http://" + window.location.hostname + "/updates/manualupdate.html");
+
+        // Default details URL for updates
+        prefs.setCharPref("app.update.url.details", "http://" + window.location.hostname + "/updates/updatedetails.html");
+    }
+} catch(E) {
+    dump('Error updating automatic update settings for ' + location.href + '\n');
+}