~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to patches/sarge/70_extensionManagerBug.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -e
 
2
## 50_mozilla-firebird-mips-xptcstubs-gcc3.dpatch by Alexander Sack <asac@jwsdot.com>
 
3
##
 
4
## All lines beginning with `## DP:' are a description of the patch.
 
5
## DP: No description.
 
6
 
 
7
if [ $# -ne 1 ]; then
 
8
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
 
9
    exit 1
 
10
fi
 
11
 
 
12
[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
 
13
patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
 
14
 
 
15
case "$1" in
 
16
       -patch) patch $patch_opts -p1 < $0;;
 
17
       -unpatch) patch $patch_opts -p1 -R < $0;;
 
18
        *)
 
19
                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
 
20
                exit 1;;
 
21
esac
 
22
 
 
23
exit 0
 
24
 
 
25
@DPATCH@
 
26
--- mozilla.orig/toolkit/mozapps/extensions/content/extensions.js
 
27
+++ mozilla/toolkit/mozapps/extensions/content/extensions.js
 
28
@@ -678,7 +678,8 @@
 
29
       return !selectedItem ||
 
30
              (selectedItem &&
 
31
               selectedItem.getAttribute("toBeUninstalled") != "true" &&
 
32
-              selectedItem.getAttribute("toBeInstalled") != "true");
 
33
+              selectedItem.getAttribute("toBeInstalled") != "true" &&
 
34
+             selectedItem.getAttribute("locked") != "true");
 
35
     case "cmd_reallyEnable":
 
36
     // controls whether to show Enable or Disable in extensions' context menu
 
37
       return selectedItem && 
 
38
--- mozilla.orig/toolkit/mozapps/extensions/src/nsExtensionManager.js.in
 
39
+++ mozilla/toolkit/mozapps/extensions/src/nsExtensionManager.js.in
 
40
@@ -20,6 +20,7 @@
 
41
  *
 
42
  * Contributor(s):
 
43
  *  Ben Goodger <ben@bengoodger.com>
 
44
+ *  Mike Hommey <mh@glandium.org>
 
45
  *
 
46
  * Alternatively, the contents of this file may be used under the terms of
 
47
  * either the GNU General Public License Version 2 or later (the "GPL"), or
 
48
@@ -144,6 +145,19 @@
 
49
 }
 
50
 
 
51
 // Returns the file at the appropriate point in a directory hierarchy under
 
52
+// the specified key. Does NOT create the file NOR the directories along the
 
53
+// way.
 
54
+function getFileNoCreateDir(aKey, aPathToFile)
 
55
+{
 
56
+  var subdirs = [];
 
57
+  for (var i = 0; i < aPathToFile.length - 1; ++i)
 
58
+    subdirs.push(aPathToFile[i]);
 
59
+  var file = getDirNoCreate(aKey, subdirs);
 
60
+  file.append(aPathToFile[aPathToFile.length - 1]);
 
61
+  return file;
 
62
+}
 
63
+
 
64
+// Returns the file at the appropriate point in a directory hierarchy under
 
65
 // the specified key, creating directories along the way if necessary. Does
 
66
 // NOT create the file.
 
67
 function getFile(aKey, aPathToFile)
 
68
@@ -675,7 +689,7 @@
 
69
 function nsInstallLogReader(aExtensionID, aIsProfile, aListener)
 
70
 {
 
71
   this._isProfile = aIsProfile;
 
72
-  this.uninstallLog = getFile(getDirKey(aIsProfile),
 
73
+  this.uninstallLog = getFileNoCreateDir(getDirKey(aIsProfile),
 
74
                               [DIR_EXTENSIONS, aExtensionID, 
 
75
                                DIR_UNINSTALL, FILE_UNINSTALL_LOG]);
 
76
   this._listener = aListener
 
77
@@ -829,26 +843,20 @@
 
78
   {
 
79
     // extension,{GUID} or theme,{GUID}
 
80
     var parts = aLine.split(",");
 
81
-    var manifest = getFile(KEY_APPDIR, 
 
82
+    var manifest = getFileNoCreateDir(KEY_APPDIR, 
 
83
                            [DIR_EXTENSIONS, parts[1], FILE_INSTALL_MANIFEST]);
 
84
     if (parts.length != 2)
 
85
       return;
 
86
       
 
87
-    if (!manifest.exists()) {
 
88
-      defaultManifest = defaultFile = getFile(KEY_DEFAULTS, 
 
89
-                                              [DIR_DEFAULTS_EXTENSIONS, parts[1], FILE_INSTALL_MANIFEST]);
 
90
-      var extensionDir = getDir(KEY_APPDIR, [DIR_EXTENSIONS, parts[1]]);
 
91
-      defaultManifest.copyTo(extensionDir, FILE_INSTALL_MANIFEST);
 
92
-      manifest = getFile(KEY_APPDIR, 
 
93
-                         [DIR_EXTENSIONS, parts[1], FILE_INSTALL_MANIFEST]);
 
94
-    }
 
95
-    switch (parts[0]) {
 
96
-    case this.TOKEN_EXTENSION:
 
97
-      this._manager.ensurePreConfiguredItem(parts[1], nsIUpdateItem.TYPE_EXTENSION, manifest);
 
98
-      break;
 
99
-    case this.TOKEN_THEME:
 
100
-      this._manager.ensurePreConfiguredItem(parts[1], nsIUpdateItem.TYPE_THEME, manifest);
 
101
-      break;
 
102
+    if (manifest.exists()) {
 
103
+      switch (parts[0]) {
 
104
+      case this.TOKEN_EXTENSION:
 
105
+        this._manager.ensurePreConfiguredItem(parts[1], nsIUpdateItem.TYPE_EXTENSION, manifest);
 
106
+        break;
 
107
+      case this.TOKEN_THEME:
 
108
+        this._manager.ensurePreConfiguredItem(parts[1], nsIUpdateItem.TYPE_THEME, manifest);
 
109
+        break;
 
110
+      }
 
111
     }
 
112
   }
 
113
 };
 
114
@@ -917,21 +925,26 @@
 
115
     this._writer = new nsInstallLogWriter(this._extensionID, this._isProfile);
 
116
     this._writer.open();
 
117
     
 
118
-    // Move files from the staging dir into the extension's final home.
 
119
-    // This function generates uninstall log files and creates backups of
 
120
-    // existing files. 
 
121
-    // XXXben - would like to add exception handling here to test for file
 
122
-    //          I/O failures on uninstall log so that if there's a crash
 
123
-    //          and the uninstall log is incorrectly/incompletely written 
 
124
-    //          we can roll back. It's not critical that we do so right now
 
125
-    //          since if this throws the extension's chrome is never 
 
126
-    //          registered. 
 
127
-    this._installExtensionFiles();
 
128
-    
 
129
     // Load the metadata datasource
 
130
-    var metadataFile = getFile(this._extDirKey, 
 
131
+    var metadataFile = getFileNoCreateDir(this._extDirKey, 
 
132
                                [DIR_EXTENSIONS, aExtensionID, FILE_INSTALL_MANIFEST]);
 
133
     
 
134
+    // If the metadata file exists, it means we don't have to to extract the xpi.
 
135
+    // Useful for pre-configured extensions.
 
136
+
 
137
+    if (aIsProfile && !metadataFile.exists()) {
 
138
+      // Move files from the staging dir into the extension's final home.
 
139
+      // This function generates uninstall log files and creates backups of
 
140
+      // existing files. 
 
141
+      // XXXben - would like to add exception handling here to test for file
 
142
+      //          I/O failures on uninstall log so that if there's a crash
 
143
+      //          and the uninstall log is incorrectly/incompletely written 
 
144
+      //          we can roll back. It's not critical that we do so right now
 
145
+      //          since if this throws the extension's chrome is never 
 
146
+      //          registered. 
 
147
+      this._installExtensionFiles();
 
148
+    }
 
149
+
 
150
     this._metadataDS = getInstallManifest(metadataFile);
 
151
     if (!this._metadataDS) return;
 
152
     
 
153
@@ -1752,6 +1765,9 @@
 
154
       // Write bin/components.ini
 
155
       var manifest = getFile(KEY_APPDIR, [FILE_COMPONENT_MANIFEST]);
 
156
       this._writeProfileFile(manifest, this._getComponentsDir, false);
 
157
+
 
158
+      // Update the Defaults Manifest
 
159
+      this._writeDefaults(false);
 
160
     }
 
161
   },
 
162
 
 
163
@@ -1823,7 +1839,7 @@
 
164
         cr.selectSkin(KEY_DEFAULT_THEME, true);
 
165
       }
 
166
       catch (e) {
 
167
-        dump("*** nsExtensionManager::_disableObsoleteExtensions - failure, catching exception so finalize window can close\n");
 
168
+//        dump("*** nsExtensionManager::_disableObsoleteExtensions - failure, catching exception so finalize window can close\n");
 
169
       }
 
170
       win.close();
 
171
       
 
172
@@ -2002,6 +2018,34 @@
 
173
     this._ds.insertForthcomingItem(aItemID, aItemType, false);
 
174
     var metadataDS = getInstallManifest(aManifest);
 
175
     this._ds.addItemMetadata(aItemID, aItemType, metadataDS, false);
 
176
+
 
177
+    // Check whether the extension is installable (thunderbird_version fitting between
 
178
+    // em:MaxVersion and em:MinVersion)
 
179
+    var extensionID = this.canInstallItem(metadataDS);
 
180
+    // |extensionID| must be a GUID string, not a number - a number means failure.
 
181
+    if (isNaN(parseInt(extensionID))) {
 
182
+      // Do install the extension, meaning we register its chrome and components
 
183
+      if (!this._extInstaller)
 
184
+          this._extInstaller = new nsExtensionInstaller(this._ds);
 
185
+      try {
 
186
+          this._extInstaller.install(aItemID, false);
 
187
+      }
 
188
+      catch (e) {
 
189
+          // If the installation failed, we disable the extension in addition
 
190
+         // to _not_ uninstalling it (which would fail anyway because it
 
191
+         // would be done at launch time... as a user).
 
192
+         this._ds.setItemProperty(aItemID, this._ds._emR("toBeUninstalled"),
 
193
+                                  null, false, aItemType);
 
194
+          this._ds.setItemProperty(aItemID, this._ds._emR("disabled"),
 
195
+                                   this._ds._emL("true"), false, aItemType);
 
196
+      }
 
197
+    } else {
 
198
+      // disable extensions that aren't installable
 
199
+      this._ds.setItemProperty(aItemID, this._ds._emR("disabled"),
 
200
+                              this._ds._emL("true"), false, aItemType);
 
201
+    }
 
202
+    // Force locking pre-configured items.
 
203
+    this._ds.lockUnlockItem(aItemID, true);
 
204
   },
 
205
   
 
206
   checkForMismatches: function nsExtensionManager_checkForMismatches () 
 
207
@@ -2028,22 +2072,31 @@
 
208
       if (items.length > 0) {
 
209
         for (var i = 0; i < items.length; ++i) {
 
210
           // Now disable the extension so it won't hurt anything. 
 
211
+         var alreadyDisabled = this._ds.getItemProperty(items[i].id, "disabled");
 
212
           var itemType = getItemType(this._ds._getResourceForItem(items[i].id).Value);
 
213
           if (itemType != -1 && itemType & nsIUpdateItem.TYPE_EXTENSION)
 
214
-            this.disableExtension(items[i].id);
 
215
+            if (!alreadyDisabled) this.disableExtension(items[i].id);
 
216
           else if (itemType & nsIUpdateItem.TYPE_THEME) {
 
217
             if (gPref.prefHasUserValue(PREF_GENERAL_SKINS_SELECTEDSKIN))
 
218
               gPref.clearUserPref(PREF_GENERAL_SKINS_SELECTEDSKIN);
 
219
-            this._ds.disableTheme(items[i].id);
 
220
+            if (!alreadyDisabled) this._ds.disableTheme(items[i].id);
 
221
           }
 
222
         }
 
223
-        var updates = Components.classes["@mozilla.org/updates/update-service;1"]
 
224
-                                .getService(Components.interfaces.nsIUpdateService);
 
225
-        updates.checkForUpdates(items, items.length, nsIUpdateItem.TYPE_ADDON, 
 
226
-                                nsIUpdateService.SOURCE_EVENT_MISMATCH,
 
227
-                                null);
 
228
+       // We want to eliminate locked extensions
 
229
+       newitems = [];
 
230
+       for (var i = 0; i < items.length; ++i) {
 
231
+         if (!this._ds.getItemProperty(items[i].id, "locked"))
 
232
+           newitems.push(items[i]);
 
233
+       }
 
234
+       if (newitems.length > 0) {
 
235
+          var updates = Components.classes["@mozilla.org/updates/update-service;1"]
 
236
+                                  .getService(Components.interfaces.nsIUpdateService);
 
237
+          updates.checkForUpdates(newitems, newitems.length, nsIUpdateItem.TYPE_ADDON, 
 
238
+                                  nsIUpdateService.SOURCE_EVENT_MISMATCH,
 
239
+                                  null);
 
240
         
 
241
-        needsRestart = true;
 
242
+          needsRestart = true;
 
243
+       }
 
244
       }
 
245
     }
 
246
     
 
247
@@ -2087,7 +2140,7 @@
 
248
       this._writeDefaults(false);
 
249
     }
 
250
     catch (e) { 
 
251
-      dump("*** ExtensionManager:_updateManifests: no access privileges to application directory, skipping.\n"); 
 
252
+//      dump("*** ExtensionManager:_updateManifests: no access privileges to application directory, skipping.\n"); 
 
253
     };
 
254
     this._writeComponentManifest(true);
 
255
     this._writeDefaults(true);
 
256
@@ -2133,6 +2186,11 @@
 
257
         validExtensions.push({ sourceDir: sourceDir, isProfile: isProfile });
 
258
     }
 
259
     
 
260
+    // Debian hook to insert defaults/syspref into defaults.ini
 
261
+    if ((aFile.leafName == FILE_DEFAULTS) && aIsProfile == false) {
 
262
+      validExtensions.push({ sourceDir: getDirNoCreate(getDirKey(false), [DIR_DEFAULTS, "syspref"]), isProfile: false });
 
263
+    }
 
264
+
 
265
     var lines = ["[Extra Files]\r\n",
 
266
                  "Count=" + validExtensions.length + "\r\n"];
 
267
     for (i = 0; i < lines.length; ++i)
 
268
@@ -3090,8 +3148,10 @@
 
269
   checkForUpdates: function (aItem, aVersionUpdateOnly)
 
270
   {
 
271
     // A preference setting can disable updating for this item
 
272
+    // We'll also skip locked items.
 
273
     try {
 
274
-      if (!gPref.getBoolPref(PREF_EM_ITEM_UPDATE_ENABLED.replace(/%UUID%/, aItem.id))) {
 
275
+      if (this._updater._emDS.getItemProperty(aItem.id, "locked") ||
 
276
+          !gPref.getBoolPref(PREF_EM_ITEM_UPDATE_ENABLED.replace(/%UUID%/, aItem.id))) {
 
277
         gOS.notifyObservers(null, "Update:Extension:Item-Ended", "");
 
278
         this._updater._checkForDone();
 
279
         return;
 
280
@@ -3557,7 +3617,7 @@
 
281
   
 
282
   isProfileItem: function nsExtensionsDataSource_isProfileItem (aItemID)
 
283
   {
 
284
-    return this.getItemProperty(aItemID, "installLocation") != "global";
 
285
+    return this.getItemProperty(aItemID, "installLocation") == "profile";
 
286
   },
 
287
   
 
288
   _setProperty: function nsExtensionsDataSource__setProperty (aDS, aSource, aProperty, aNewValue)
 
289
--- mozilla.orig/toolkit/mozapps/update/src/nsUpdateService.js.in
 
290
+++ mozilla/toolkit/mozapps/update/src/nsUpdateService.js.in
 
291
@@ -178,9 +178,10 @@
 
292
       if (aRequestedTypes & nsIUpdateItem.TYPE_THEME)
 
293
         types |= nsIUpdateItem.TYPE_THEME;
 
294
     }
 
295
-    if (appUpdateEnabled && 
 
296
-        (aRequestedTypes & nsIUpdateItem.TYPE_APP))
 
297
-      types |= nsIUpdateItem.TYPE_APP;
 
298
+    // Disable application updates
 
299
+    //if (appUpdateEnabled && 
 
300
+    //    (aRequestedTypes & nsIUpdateItem.TYPE_APP))
 
301
+    //  types |= nsIUpdateItem.TYPE_APP;
 
302
 
 
303
     return types;
 
304
   },