[Pkg-mozext-commits] [greasemonkey] 02/04: Imported Upstream version 1.13~beta5

David Prévot taffit at alioth.debian.org
Thu Oct 24 17:19:56 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository greasemonkey.

commit 123d8957681c8355a7337c47226cc0ed478cb7e4
Author: David Prévot <taffit at debian.org>
Date:   Thu Oct 24 13:09:59 2013 -0400

    Imported Upstream version 1.13~beta5
---
 components/greasemonkey.js           |    3 ++
 content/config.js                    |    4 ---
 defaults/preferences/greasemonkey.js |   10 ++++++
 install.rdf                          |    2 +-
 locale/sv-SE/gm-addons.dtd           |    2 +-
 locale/sv-SE/gm-addons.properties    |    2 +-
 locale/sv-SE/gm-browser.properties   |   12 +++----
 locale/sv-SE/greasemonkey.dtd        |    8 ++---
 locale/sv-SE/greasemonkey.properties |    2 +-
 modules/miscapis.js                  |   19 +++++++++--
 modules/remoteScript.js              |   31 ++++++++++++------
 modules/script.js                    |   26 +++++++++++----
 modules/util/enqueueRemoveFile.js    |   59 ++++++++++++++++++++++++++++++++++
 13 files changed, 145 insertions(+), 35 deletions(-)

diff --git a/components/greasemonkey.js b/components/greasemonkey.js
index 6ebc422..09ed2f8 100644
--- a/components/greasemonkey.js
+++ b/components/greasemonkey.js
@@ -310,6 +310,9 @@ function startup(aService) {
   var observerService = Components.classes['@mozilla.org/observer-service;1']
      .getService(Components.interfaces.nsIObserverService);
   observerService.addObserver(aService, 'document-element-inserted', false);
+
+  // Import this once, early, so that enqueued deletes can happen.
+  Cu.import("resource://greasemonkey/util/enqueueRemoveFile.js");
 }
 
 /////////////////////////////////// Service ////////////////////////////////////
diff --git a/content/config.js b/content/config.js
index 0c3a54a..431699e 100644
--- a/content/config.js
+++ b/content/config.js
@@ -138,10 +138,6 @@ Config.prototype.install = function(script, oldScript, tempDir) {
     script.userExcludes = oldScript.userExcludes;
     script.userIncludes = oldScript.userIncludes;
 
-    // Migrate stored values.
-    var storage = new GM_ScriptStorage(oldScript);
-    storage.dbFile.moveTo(tempDir, storage.dbFileName);
-
     // Uninstall the old script.
     this.uninstall(oldScript, true);
   }
diff --git a/defaults/preferences/greasemonkey.js b/defaults/preferences/greasemonkey.js
index 417cbd3..a6afdde 100644
--- a/defaults/preferences/greasemonkey.js
+++ b/defaults/preferences/greasemonkey.js
@@ -21,3 +21,13 @@ pref("extensions.greasemonkey.sync.values", false);
 pref("extensions.greasemonkey.sync.values_max_size_per_script", 65536);
 pref("extensions.greasemonkey.unmhtIsGreaseable", false);
 pref("extensions.greasemonkey.version", "0.0");
+pref("services.sync.prefs.sync.extensions.greasemonkey.enableScriptRefreshing", true);
+pref("services.sync.prefs.sync.extensions.greasemonkey.globalExcludes", true);
+pref("services.sync.prefs.sync.extensions.greasemonkey.newScript.removeUnused", true);
+pref("services.sync.prefs.sync.extensions.greasemonkey.newScript.template", true);
+pref("services.sync.prefs.sync.extensions.greasemonkey.requireSecureUpdates", true);
+pref("services.sync.prefs.sync.extensions.greasemonkey.showGrantsWarning", true);
+pref("services.sync.prefs.sync.extensions.greasemonkey.stats.optedin", true);
+pref("services.sync.prefs.sync.extensions.greasemonkey.stats.lastsubmittime", true);
+pref("services.sync.prefs.sync.extensions.greasemonkey.sync.enabled", true);
+pref("services.sync.prefs.sync.extensions.greasemonkey.sync.values", true);
diff --git a/install.rdf b/install.rdf
index a9d6cce..05062aa 100644
--- a/install.rdf
+++ b/install.rdf
@@ -6,7 +6,7 @@
   <Description about="urn:mozilla:install-manifest">
 
     <em:id>{e4a8a97b-f2ed-450b-b12d-ee082ba24781}</em:id>
-    <em:version>1.13beta3</em:version>
+    <em:version>1.13beta5</em:version>
     <em:creator>Aaron Boodman; http://youngpup.net/</em:creator>
     <em:homepageURL>http://www.greasespot.net/</em:homepageURL>
     <em:optionsURL>chrome://greasemonkey/content/options.xul</em:optionsURL>
diff --git a/locale/sv-SE/gm-addons.dtd b/locale/sv-SE/gm-addons.dtd
index c3d1697..990372f 100644
--- a/locale/sv-SE/gm-addons.dtd
+++ b/locale/sv-SE/gm-addons.dtd
@@ -6,7 +6,7 @@
 <!ENTITY ExecuteLater "Kör senare">
 <!ENTITY ExecuteSooner "Kör tidigare">
 <!ENTITY FindUpdate "Sök efter uppdatering">
-<!ENTITY ForcedFindUpdate "Forced Find Updates">
+<!ENTITY ForcedFindUpdate "Tvingad sökning efter uppdateringar">
 <!ENTITY InstallUpdate "Installera uppdatering">
 <!ENTITY MoveDown "Flytta nedåt">
 <!ENTITY MoveDown.accesskey "n">
diff --git a/locale/sv-SE/gm-addons.properties b/locale/sv-SE/gm-addons.properties
index 3183f6e..db017cf 100644
--- a/locale/sv-SE/gm-addons.properties
+++ b/locale/sv-SE/gm-addons.properties
@@ -1,4 +1,4 @@
-confirmForceUpdate=This script appears to be locally modified.  Overwrite with remote contents?  This action cannot be undone.
+confirmForceUpdate=Detta skript verkar ha ändrats lokalt.  Vill du ersätta det med fjärrinnehållet?  Denna åtgärd kan inte ångras.
 executionorder=Körningsordning
 executionorder.tooltip=Sortera efter körningsordning
 userscripts=Användarskript
diff --git a/locale/sv-SE/gm-browser.properties b/locale/sv-SE/gm-browser.properties
index 2187311..5149c05 100644
--- a/locale/sv-SE/gm-browser.properties
+++ b/locale/sv-SE/gm-browser.properties
@@ -18,10 +18,10 @@ editor.could_not_launch=Det gick inte att starta redigeringsprogrammet.
 newscript.noname=Ange ett namn på ditt skript.
 newscript.nonamespace=Ange en giltig namnrymds-URI för ditt skript.\n(t.ex. "http://userscripts.org/users/användarensIDnummer")
 newscript.exists=Ett skript med det namnet har redan installerats.\nSkall det ersättas?
-disabledWarning=Warning: You've navigated to a User Script but Greasemonkey is disabled.
-disabledWarning.enable=Enable
-disabledWarning.enable.accessKey=E
-disabledWarning.enableAndInstall=Enable & Install Script
-disabledWarning.enableAndInstall.accessKey=S
-disabledWarning.install=Install Script
+disabledWarning=Varning: Du har tagit dig till ett användarskript, men Greasemonkey är inaktiverat.
+disabledWarning.enable=Aktivera
+disabledWarning.enable.accessKey=A
+disabledWarning.enableAndInstall=Aktivera & installera skript
+disabledWarning.enableAndInstall.accessKey=s
+disabledWarning.install=Installera skript
 disabledWarning.install.accessKey=I
diff --git a/locale/sv-SE/greasemonkey.dtd b/locale/sv-SE/greasemonkey.dtd
index 9987e02..71047ff 100644
--- a/locale/sv-SE/greasemonkey.dtd
+++ b/locale/sv-SE/greasemonkey.dtd
@@ -35,15 +35,15 @@
 <!ENTITY newscript.excludes "Undantag (ett per rad)">
 <!ENTITY newscript.fromClipboard "Använd skript från Urklipp">
 <!ENTITY options.editor "Redigeringsprogram">
-<!ENTITY options.experimental "Experimental">
+<!ENTITY options.experimental "Experimentell">
 <!ENTITY options.defaultEditor "Använd standardredigeringsprogrammet">
 <!ENTITY options.browseForEditor "Bläddra efter redigeringsprogram">
 <!ENTITY options.globalExcludes "Globala undantag">
-<!ENTITY options.newScript.template "New script template">
-<!ENTITY options.newScript.removeUnused "Remove unused lines">
+<!ENTITY options.newScript.template "Ny skriptmall">
+<!ENTITY options.newScript.removeUnused "Ta bort oanvända rader">
 <!ENTITY Uninstall "Avinstallera">
 <!ENTITY AnonymousStatistics "Anonym statistik">
-<!ENTITY EnableFirefoxSync "Enable Firefox Sync for User Scripts">
+<!ENTITY EnableFirefoxSync "Aktivera Firefox Sync för användarskript">
 <!ENTITY SubmitStats "Samla in och skicka in anonym användningsstatistik för att förbättra Greasemonkey.">
 <!ENTITY UpdateChecking "Uppdateringskontroll">
 <!ENTITY RequireSecureUpdates "Kräv säkra uppdateringar">
diff --git a/locale/sv-SE/greasemonkey.properties b/locale/sv-SE/greasemonkey.properties
index 108c782..58e4294 100644
--- a/locale/sv-SE/greasemonkey.properties
+++ b/locale/sv-SE/greasemonkey.properties
@@ -38,7 +38,7 @@ warning.scripts-should-grant.dont-show.key=V
 script.duplicate-installed=Fel: Ett annat skript med namnet (@name) "%1" och namnrymden (@namespace) "%2" är redan installerat.\nDessa värden måste vara unika.
 script.no-delete-directory=Varning!!! Vägrar att ta bort skriptmapp.
 script.delete-failed=Varning, borttagning inför uppdatering misslyckades:\n%1
-setClipboard.unsupportedType=Unsupported type for GM_setClipboard: "%1"
+setClipboard.unsupportedType=En typ för GM_setClipboard stöds inte: "%1"
 stats-prompt.msg=Hjälp oss gärna att förbättra Greasemonkey genom att skicka in anonym användningsstatistik.
 stats-prompt.optin=Godkänn
 stats-prompt.optin.accesskey=G
diff --git a/modules/miscapis.js b/modules/miscapis.js
index de9932d..22fea8d 100644
--- a/modules/miscapis.js
+++ b/modules/miscapis.js
@@ -24,8 +24,20 @@ GM_ScriptStorage.prototype.dbFileName = 'values.db';
 
 GM_ScriptStorage.prototype.__defineGetter__('dbFile',
 function GM_ScriptStorage_getDbFile() {
-  var file = this._script.baseDirFile;
-  file.append(this.dbFileName);
+  // TODO: Remove this before 1.13 is final.
+  // Migrate early beta in-script-dir values DB to beside-script-dir.
+  var legacyDbFile = this._script.baseDirFile;
+  legacyDbFile.append('values.db');
+  if (legacyDbFile.exists()) {
+    try {
+      legacyDbFile.moveTo(GM_util.scriptDir(), this._script.baseDirName + '.db');
+    } catch (e) {
+      dump('Could not migrate legacy db file:\n' + e + '\n');
+    }
+  }
+
+  var file = GM_util.scriptDir();
+  file.append(this._script.baseDirName + '.db');
   return file;
 });
 
@@ -41,6 +53,9 @@ function GM_ScriptStorage_getDb() {
         + 'value TEXT '
         + ')'
         );
+    this._db.executeSimpleSQL('PRAGMA auto_vaccum = INCREMENTAL;');
+    this._db.executeSimpleSQL('PRAGMA incremental_vacuum(10);');
+    this._db.executeSimpleSQL('PRAGMA journal_mode = TRUNCATE;');
   }
   return this._db;
 });
diff --git a/modules/remoteScript.js b/modules/remoteScript.js
index bfb6bbd..6970336 100644
--- a/modules/remoteScript.js
+++ b/modules/remoteScript.js
@@ -6,6 +6,7 @@ var Ci = Components.interfaces;
 Components.utils.import("resource://greasemonkey/GM_notification.js");
 Components.utils.import('resource://greasemonkey/addons4.js');
 Components.utils.import('resource://greasemonkey/script.js');
+Components.utils.import('resource://greasemonkey/scriptIcon.js');
 Components.utils.import('resource://greasemonkey/util.js');
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
@@ -80,9 +81,12 @@ function filenameFromUri(aUri, aDefault) {
 ////////////////////////// Private Download Listener ///////////////////////////
 
 function DownloadListener(
-    aTryToParse, aProgressCb, aCompletionCallback, aFile, aUri, aRemoteScript) {
+    aTryToParse, aProgressCb, aCompletionCallback, aFile, aUri, aRemoteScript,
+    aErrorsAreFatal) {
   this._completionCallback = aCompletionCallback;
   this._data = [];
+  this._errorsAreFatal = ('undefined' == typeof aErrorsAreFatal)
+      ? true : aErrorsAreFatal;
   this._progressCallback = aProgressCb;
   this._remoteScript = aRemoteScript;
   this._tryToParse = aTryToParse;
@@ -188,7 +192,7 @@ DownloadListener.prototype = {
       }
     }
 
-    if (error) {
+    if (error && this._errorsAreFatal) {
       errorMessage = stringBundle.GetStringFromName('error.downloadingUrl')
           + '\n' + this._uri.spec + '\n\n' + errorMessage;
       this._remoteScript.cleanup(errorMessage);
@@ -292,7 +296,9 @@ RemoteScript.prototype.downloadScript = function(aCompletionCallback) {
       this._tempDir, filenameFromUri(this._uri, 'gm_script'));
 
   this._downloadFile(this._uri, this._scriptFile,
-      GM_util.hitch(this, this._downloadScriptCb, aCompletionCallback));
+      GM_util.hitch(this, this._downloadScriptCb, aCompletionCallback),
+      true // aErrorsAreFatal
+      );
 };
 
 RemoteScript.prototype.install = function(aOldScript, aOnlyDependencies) {
@@ -475,8 +481,12 @@ RemoteScript.prototype._downloadDependencies = function(aCompletionCallback) {
 
   function dependencyDownloadComplete(aChannel, aSuccess) {
     if (!aSuccess) {
-      aCompletionCallback(aSuccess, 'dependency');
-      return;
+      if (dependency instanceof ScriptIcon) {
+        // Ignore the failure to download the icon.
+      } else {
+        aCompletionCallback(aSuccess, 'dependency');
+        return;
+      }
     }
     if (dependency.setMimetype) {
       dependency.setMimetype(aChannel.contentType);
@@ -488,12 +498,14 @@ RemoteScript.prototype._downloadDependencies = function(aCompletionCallback) {
   }
 
   this._downloadFile(
-      uri, file, GM_util.hitch(this, dependencyDownloadComplete));
+      uri, file, GM_util.hitch(this, dependencyDownloadComplete),
+      !(dependency instanceof ScriptIcon)  // aErrorsAreFatal
+      );
 };
 
 /** Download a given nsIURI to a given nsIFile, with optional callback. */
 RemoteScript.prototype._downloadFile = function(
-    aUri, aFile, aCompletionCallback) {
+    aUri, aFile, aCompletionCallback, aErrorsAreFatal) {
   aUri = aUri.QueryInterface(Ci.nsIURI);
   aFile = aFile.QueryInterface(Ci.nsIFile);
   aCompletionCallback = aCompletionCallback || function() {};
@@ -519,12 +531,13 @@ RemoteScript.prototype._downloadFile = function(
   var channel = ioService.newChannelFromURI(aUri);
   this._channels.push(channel);
   var dsl = new DownloadListener(
-      0 == this._progressIndex,
+      0 == this._progressIndex,  // aTryToParse
       GM_util.hitch(this, this._downloadFileProgress),
       aCompletionCallback,
       aFile,
       aUri,
-      this
+      this,
+      aErrorsAreFatal
       );
   channel.notificationCallbacks = dsl;
   channel.asyncOpen(dsl, this);
diff --git a/modules/script.js b/modules/script.js
index 70b181d..93a79ba 100644
--- a/modules/script.js
+++ b/modules/script.js
@@ -3,6 +3,7 @@ var EXPORTED_SYMBOLS = ['Script'];
 Components.utils.import('resource://gre/modules/AddonManager.jsm');
 Components.utils.import('resource://greasemonkey/GM_notification.js');
 Components.utils.import('resource://greasemonkey/constants.js');
+Components.utils.import('resource://greasemonkey/miscapis.js');
 Components.utils.import("resource://greasemonkey/parseScript.js");
 Components.utils.import('resource://greasemonkey/prefmanager.js');
 Components.utils.import('resource://greasemonkey/scriptIcon.js');
@@ -224,6 +225,11 @@ function Script_getUpdateIsSecure() {
   return /^https/.test(this.downloadURL);
 });
 
+Script.prototype.__defineGetter__('baseDirName',
+function Script_getBaseDirName() {
+  return '' + this._basedir;
+});
+
 Script.prototype.__defineGetter__('baseDirFile',
 function Script_getBaseDirFile() {
   var file = GM_util.scriptDir();
@@ -784,20 +790,28 @@ Script.prototype.uninstall = function(forUpdate) {
   if ('undefined' == typeof(forUpdate)) forUpdate = false;
 
   if (this.baseDirFile.equals(GM_util.scriptDir())) {
-    // if script is in the root, just remove the file
+    // If script is in the root, just remove the file.
     try {
-      this.file.remove(false);
+      if (this.file.exists()) this.file.remove(false);
     } catch (e) {
-      // Fail silently if it already does not exist.
+      dump('Remove failed: ' + this.file.path + '\n');
     }
-  } else {
-    // if script has its own dir, remove the dir + contents
+  } else if (this.baseDirFile.exists()) {
+    // If script has its own dir, remove the dir + contents.
     try {
       this.baseDirFile.remove(true);
     } catch (e) {
-      // Fail silently if it already does not exist.
+      dump('Remove failed: ' + this.baseDirFile.path + '\n');
     }
   }
 
+  if (!forUpdate) {
+    var storage = new GM_ScriptStorage(this);
+    var file = storage.dbFile;
+    GM_util.enqueueRemoveFile(file);
+    file.leafName += '-journal';
+    GM_util.enqueueRemoveFile(file);
+  }
+
   this._changed('uninstall', forUpdate);
 };
diff --git a/modules/util/enqueueRemoveFile.js b/modules/util/enqueueRemoveFile.js
new file mode 100644
index 0000000..55da866
--- /dev/null
+++ b/modules/util/enqueueRemoveFile.js
@@ -0,0 +1,59 @@
+Components.utils.import('resource://greasemonkey/prefmanager.js');
+
+const EXPORTED_SYMBOLS = ['enqueueRemoveFile'];
+
+
+function addEnqueuedPath(aPath) {
+  var paths = getEnqueuedPaths();
+  paths.push(aPath);
+  GM_prefRoot.setValue('enqueuedRemovals', JSON.stringify(paths));
+}
+
+function getEnqueuedPaths() {
+  return JSON.parse(GM_prefRoot.getValue('enqueuedRemovals', '[]'));
+}
+
+function removeEnqueuedPath(aPath) {
+  var paths = getEnqueuedPaths();
+  do {
+    var i = paths.indexOf(aPath);
+    if (i != -1) paths.slice(i, 1);
+  } while (i != -1);
+  GM_prefRoot.setValue('enqueuedRemovals', JSON.stringify(paths));
+}
+
+function removePath(aPath, aDoEnqueueFailure) {
+  var file = Components.classes["@mozilla.org/file/local;1"]
+      .createInstance(Components.interfaces.nsILocalFile);
+  try {
+    file.initWithPath(aPath);
+  } catch (e) {
+    // Invalid path; just act like it was removed.
+    return true;
+  }
+
+  if (file.exists()) {
+    try {
+      file.remove(false);
+      return true;
+    } catch (e) {
+      if (aDoEnqueueFailure) addEnqueuedPath(aPath);
+    }
+  }
+  return false;
+}
+
+/** Given string data and an nsIFile, write it safely to that file. */
+function enqueueRemoveFile(aFile) {
+  removePath(aFile.path, true);
+}
+
+// Once at start up, try to remove all enqueued paths.
+(function() {
+  var paths = getEnqueuedPaths();
+  for (var i = 0, path = null; path = paths[i]; i++) {
+    if (!removePath(path, false)) {
+      removeEnqueuedPath(path);
+    }
+  }
+})();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/greasemonkey.git



More information about the Pkg-mozext-commits mailing list