This is just some static backup of the original site, don't expect every link to work!

source: content/modules/vI_helper.js @ 184c6c

ng_0.9
Last change on this file since 184c6c was 184c6c, checked in by rene <rene@…>, 11 years ago

rearranged tree structure / added build-script

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2    This program is free software; you can redistribute it and/or modify
3    it under the terms of the GNU General Public License as published by
4    the Free Software Foundation; either version 2 of the License, or
5    (at your option) any later version.
6
7    This program is distributed in the hope that it will be useful,
8    but WITHOUT ANY WARRANTY; without even the implied warranty of
9    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10    GNU General Public License for more details.
11
12    You should have received a copy of the GNU General Public License
13    along with this program; if not, write to the Free Software
14    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
15
16    The Original Code is the Virtual Identity Extension.
17
18    The Initial Developer of the Original Code is Rene Ejury.
19    Portions created by the Initial Developer are Copyright (C) 2007
20    the Initial Developer. All Rights Reserved.
21
22    Contributor(s):
23 * ***** END LICENSE BLOCK ***** */
24
25/* this is now used as a module - there is no required reference to any other interface-elements in this code */
26
27virtualIdentityExtension.ns(function() { with (virtualIdentityExtension.LIB) {
28var helper = {
29    // simplified versionChecker, type is "TB" or "SM"
30    // returns true if appVersion is smaller or equal version
31    olderVersion : function (type, version) {
32        var appID = null; var appVersion = null;
33        const THUNDERBIRD_ID = "{3550f703-e582-4d05-9a08-453d09bdfdc6}";
34        const SEAMONKEY_ID = "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}";
35
36        var versionChecker;
37        if("@mozilla.org/xre/app-info;1" in Components.classes) {
38            var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
39                .getService(Components.interfaces.nsIXULAppInfo);
40            appID = appInfo.ID
41            appVersion = appInfo.version
42        }
43        if ((type == "TB" && appID != THUNDERBIRD_ID) ||
44            (type == "SM" && appID != SEAMONKEY_ID)) return null;
45
46        if (!version) return ((type == "TB" && appID == THUNDERBIRD_ID) ||
47            (type == "SM" && appID == SEAMONKEY_ID))
48
49        if("@mozilla.org/xpcom/version-comparator;1" in Components.classes)
50            versionChecker = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
51                .getService(Components.interfaces.nsIVersionComparator);
52        else return null;
53       
54        return (versionChecker.compare(appVersion, version) < 0)
55    },
56
57    extensionActive : function (extensionID) {
58    // new AddonManager uses asynchronous calls, therefore status is pre-stored in vI.upgradeOverlay.js
59        try {
60            var prefroot = Components.classes["@mozilla.org/preferences-service;1"]
61            .getService(Components.interfaces.nsIPrefService)
62            .getBranch(null);
63            return prefroot.getBoolPref("extensions.virtualIdentity." + extensionID)
64        } catch(e) { return false };
65    }
66}
67vI.helper = helper;
68}});
Note: See TracBrowser for help on using the repository browser.