-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unzip tagsieve-4.2.8.xpi from www.grue.in/tagsieve
- Loading branch information
Showing
47 changed files
with
379 additions
and
1,237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,278 +18,44 @@ | |
* Portions created by the Initial Developer are Copyright (C) 2005, 2006, | ||
* 2007, 2008 the Initial Developer. All Rights Reserved. | ||
* | ||
* Contributor(s): | ||
* Contributor(s): hark <[email protected]> | ||
* | ||
* ***** END LICENSE BLOCK ***** */ | ||
|
||
const CURRENT_VERSION= "4.1.4"; | ||
|
||
const CI= Components.interfaces; | ||
const CC= Components.classes; | ||
const CR= Components.results; | ||
|
||
const catMan= | ||
CC["@mozilla.org/categorymanager;1"]. | ||
getService(CI.nsICategoryManager); | ||
|
||
const obsServ= | ||
CC["@mozilla.org/observer-service;1"]. | ||
getService(CI.nsIObserverService); | ||
const Cc = Components.classes; | ||
const Ci = Components.interfaces; | ||
const Cu = Components.utils; | ||
|
||
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | ||
/* | ||
const prefs= | ||
CC["@mozilla.org/preferences-service;1"]. | ||
getService(CI.nsIPrefService). | ||
Cc["@mozilla.org/preferences-service;1"]. | ||
getService(Ci.nsIPrefService). | ||
getBranch("bookmarktags."); | ||
|
||
// Can't do this on app-startup because profile folder is not ready then, | ||
// and we need local-store. final-ui-startup is sent right before first window | ||
// of app is displayed. See | ||
// http://developer.mozilla.org/en/docs/Observer_Notifications | ||
const appObserver= | ||
{ | ||
observe: function (subject, topic, data) | ||
{ | ||
onFinalUIStartup(); | ||
} | ||
}; | ||
|
||
// 4.0.0 changes: | ||
// - Removed the default sidebar keybinding. But, if upgrading from | ||
// a previous version, ensure: | ||
// 1. If user customized keybinding, don't remove it. We don't actually | ||
// have to do anything to not remove it since user prefs persist | ||
// automatically. | ||
// 2. Otherwise, continue the old accel+` keybinding. | ||
// - bmt-tagtree, bmt-tagcloud elements removed in favor of | ||
// box[type="bookmarktags:tagcloud"], tree[type="bookmarktags:tagtree"]. | ||
// Rewrite tag color CSS. | ||
function check400Changes(currVer) | ||
*/ | ||
const os = Cc["@mozilla.org/observer-service;1"]. | ||
getService(Ci.nsIObserverService); | ||
function TagSieveService() {} | ||
TagSieveService.prototype = | ||
{ | ||
var vers; | ||
|
||
// new install | ||
if (!currVer) return; | ||
classDescription: "TagSieve Service", | ||
contractID: "@grue.in/tagsieve/service;1", | ||
classID: Components.ID("{1eaf3208-736b-4f7c-997f-713db7825149}"), | ||
_xpcom_categories: [{ category: "app-startup", service: true }], | ||
|
||
vers= currVer.split("."); | ||
if (parseInt(vers[0]) >= 4) return; | ||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, | ||
Ci.nsISupportsWeakReference]), | ||
|
||
// At this point there was a previous version, and it was less than 4. | ||
|
||
// Sidebar keybinding | ||
if (!prefs.prefHasUserValue("sidebarKey")) | ||
observe: function BSS__observe(subject, topic, data) | ||
{ | ||
prefs.setCharPref("sidebarKey", "accel+`"); | ||
} | ||
|
||
// Tag color CSS. | ||
try | ||
{ | ||
// commands.js must be imported first. | ||
Components.utils.import("resource://bookmarktags/commands.js"); | ||
Components.utils.import("resource://bookmarktags/color.js"); | ||
Components.utils.import("resource://bookmarktags/util.js"); | ||
BookmarkTags.Color= BookmarkTagsColor; | ||
BookmarkTags.Util= BookmarkTagsUtil; | ||
BookmarkTags.TagCmds.rewriteTagColorCSS(); | ||
} | ||
catch (exc) {} | ||
} | ||
|
||
// A hack to determine whether the installation is an upgrade from pre-1 | ||
// versions (as opposed to a fresh install). Checks local-store for persisted | ||
// values related to Bookmark Tags. | ||
function isUpgrade() | ||
{ | ||
var localStore; | ||
var arcs; | ||
|
||
const rdfServ= | ||
CC["@mozilla.org/rdf/rdf-service;1"]. | ||
getService(CI.nsIRDFService); | ||
|
||
localStore= rdfServ.GetDataSource("rdf:local-store"); | ||
|
||
// values related to the sidebar | ||
arcs= | ||
localStore.ArcLabelsOut( | ||
rdfServ.GetResource( | ||
"chrome://bookmarktags/content/tagBrowserSidebar.xul")); | ||
if (arcs.hasMoreElements()) return true; | ||
|
||
// values related to the prefs window | ||
arcs= | ||
localStore.ArcLabelsOut( | ||
rdfServ.GetResource("chrome://bookmarktags/content/prefs.xul")); | ||
if (arcs.hasMoreElements()) return true; | ||
|
||
// if toolbarbuttons are persisted | ||
navBarSet= | ||
localStore.GetTarget( | ||
rdfServ.GetResource("chrome://browser/content/browser.xul#nav-bar"), | ||
rdfServ.GetResource("currentset"), | ||
true); | ||
if (navBarSet && | ||
navBarSet instanceof CI.nsIRDFLiteral && | ||
/BookmarkTags-sidebarButton|BookmarkTags-bmMenuToolbarbutton/. | ||
test(navBarSet.Value)) | ||
{ | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
function onAppStartup() | ||
{ | ||
obsServ.addObserver(appObserver, "final-ui-startup", false); | ||
} | ||
|
||
// Everything is loaded by the time this is called, so this is the startup | ||
// callback where we do all the real work. | ||
function onFinalUIStartup() | ||
{ | ||
var ver; | ||
var isUpgr; | ||
|
||
obsServ.removeObserver(appObserver, "final-ui-startup"); | ||
|
||
ver= prefs.getCharPref("currentVersion"); | ||
|
||
// !ver => pre-2 versions or new install | ||
if (!ver) | ||
{ | ||
// Set tag display to cloud if upgrade. | ||
if (isUpgrade()) | ||
switch (topic) | ||
{ | ||
isUpgr= true; | ||
prefs.setIntPref("tagDisplay", 0); | ||
} | ||
} | ||
if (ver !== CURRENT_VERSION) | ||
{ | ||
check400Changes(ver); | ||
prefs.setCharPref("currentVersion", CURRENT_VERSION); | ||
} | ||
if (prefs.getBoolPref("show2Welcome")) | ||
{ | ||
if (isUpgr || isUpgrade()) showWelcome(); | ||
else prefs.setBoolPref("show2Welcome", false); | ||
} | ||
} | ||
|
||
function showWelcome() | ||
{ | ||
var checkState; | ||
var buttonFlags; | ||
var buttonPress; | ||
|
||
const strings= | ||
CC["@mozilla.org/intl/stringbundle;1"]. | ||
getService(CI.nsIStringBundleService). | ||
createBundle("chrome://bookmarktags/locale/update.properties"); | ||
const prompts= | ||
CC["@mozilla.org/embedcomp/prompt-service;1"]. | ||
getService(CI.nsIPromptService); | ||
|
||
checkState= { value: false }; | ||
buttonFlags= | ||
CI.nsIPromptService.BUTTON_TITLE_IS_STRING * | ||
(CI.nsIPromptService.BUTTON_POS_0 + | ||
CI.nsIPromptService.BUTTON_POS_1); | ||
buttonPress= | ||
prompts.confirmEx(null, | ||
strings.GetStringFromName("title"), | ||
strings.GetStringFromName("message"), | ||
buttonFlags, | ||
strings.GetStringFromName("closeButton.label"), | ||
strings.GetStringFromName("migrateButton.label"), | ||
null, | ||
strings.GetStringFromName("suppressCheckbox.label"), | ||
checkState); | ||
if (checkState.value) prefs.setBoolPref("show2Welcome", false); | ||
if (buttonPress === 1) | ||
{ | ||
CC["@mozilla.org/embedcomp/window-watcher;1"]. | ||
getService(CI.nsIWindowWatcher). | ||
openWindow(null, "chrome://bookmarktags/content/migrate.xul", | ||
"BookmarkTagsMigrator", "chrome,centerscreen,resizable", | ||
null); | ||
} | ||
} | ||
|
||
function BookmarkTags() {} | ||
|
||
BookmarkTags.prototype= | ||
{ | ||
QueryInterface: function(iid) | ||
{ | ||
if (iid.equals(CI.nsIObserver) || | ||
iid.equals(CI.nsISupports)) | ||
{ | ||
return this; | ||
} | ||
throw CR.NS_ERROR_NO_INTERFACE; | ||
}, | ||
observe: function (subject, topic, data) | ||
{ | ||
onAppStartup(); | ||
} | ||
}; | ||
|
||
// XPCOM BOILERPLATE BELOW | ||
// taken from http://developer.mozilla.org/en/docs/Code_snippets:JS_XPCOM | ||
var initModule= | ||
{ | ||
serviceCID: Components.ID("{698eda3c-a27f-4c8a-901c-7ea0096f0841}"), | ||
serviceContractID: "@cs.stanford.edu/people/adw/bookmarktags;1", | ||
serviceName: "Bookmark Tags", | ||
|
||
registerSelf: function (compMgr, fileSpec, location, type) | ||
{ | ||
compMgr= compMgr.QueryInterface(CI.nsIComponentRegistrar); | ||
compMgr.registerFactoryLocation(this.serviceCID, this.serviceName, | ||
this.serviceContractID, fileSpec, | ||
location, type); | ||
// Add app-startup observer. | ||
catMan.addCategoryEntry("app-startup", "BookmarkTagsAppStartupObserver", | ||
"service," + this.serviceContractID, true, true); | ||
}, | ||
unregisterSelf: function (compMgr, fileSpec, location) | ||
{ | ||
compMgr= compMgr.QueryInterface(CI.nsIComponentRegistrar); | ||
compMgr.unregisterFactoryLocation(this.serviceCID, fileSpec); | ||
|
||
// Remove app-startup observer. | ||
catMan.deleteCategoryEntry("app-startup", | ||
"BookmarkTagsAppStartupObserver", true); | ||
}, | ||
getClassObject: function (compMgr, cid, iid) | ||
{ | ||
if (!cid.equals(this.serviceCID)) | ||
{ | ||
throw CR.NS_ERROR_NO_INTERFACE | ||
} | ||
if (!iid.equals(CI.nsIFactory)) | ||
{ | ||
throw CR.NS_ERROR_NOT_IMPLEMENTED; | ||
} | ||
return this.instanceFactory; | ||
}, | ||
canUnload: function(compMgr) | ||
{ | ||
return true; | ||
}, | ||
instanceFactory: | ||
{ | ||
createInstance: function (outer, iid) | ||
{ | ||
if (outer !== null) throw CR.NS_ERROR_NO_AGGREGATION; | ||
return new BookmarkTags().QueryInterface(iid); | ||
case "app-startup": | ||
//os.addObserver(this, "", true); | ||
break; | ||
} | ||
} | ||
}; | ||
|
||
function NSGetModule(compMgr, fileSpec) | ||
{ | ||
return initModule; | ||
function NSGetModule(compMgr, fileSpec) { | ||
return XPCOMUtils.generateModule([TagSieveService]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
* Portions created by the Initial Developer are Copyright (C) 2005, 2006, | ||
* 2007, 2008 the Initial Developer. All Rights Reserved. | ||
* | ||
* Contributor(s): | ||
* Contributor(s): hark <[email protected]> | ||
* | ||
* ***** END LICENSE BLOCK ***** */ | ||
|
||
|
@@ -226,7 +226,7 @@ var BookmarkTags= function () | |
{ | ||
if (loaded) return; | ||
loaded= true; | ||
|
||
handleFirstTime(); | ||
sbKeyElt= document.getElementById(sbKeyEltId); | ||
sbBroadcaster= document.getElementById(sbBroadcasterId); | ||
toolbox= document.getElementById("navigator-toolbox"); | ||
|
@@ -253,6 +253,43 @@ var BookmarkTags= function () | |
window.controllers.appendController(tagController); | ||
} | ||
|
||
function handleFirstTime() | ||
{ | ||
var prefs = Components.classes["@mozilla.org/preferences-service;1"] | ||
.getService(Components.interfaces.nsIPrefService); | ||
prefs = prefs.getBranch("bookmarktags."); | ||
|
||
var ver = -1, firstrun = true; | ||
var extensionManager = Components.classes["@mozilla.org/extensions/manager;1"] | ||
.getService(Components.interfaces.nsIExtensionManager); | ||
var current = extensionManager.getItemForID("[email protected]").version; | ||
try | ||
{ | ||
ver = prefs.getCharPref("currentVersion"); | ||
firstrun = prefs.getBoolPref("firstrun"); | ||
} | ||
catch(e){} | ||
finally | ||
{ | ||
if (firstrun) | ||
{ | ||
prefs.setBoolPref("firstrun", false); | ||
prefs.setCharPref("currentVersion", current); | ||
window.setTimeout(function() | ||
{ | ||
gBrowser.selectedTab = gBrowser.addTab("chrome://bookmarktags/locale/hello.html"); | ||
}, 1500); | ||
} | ||
// !firstrun ensures that this section does not get loaded if its a first run | ||
if (ver != current && !firstrun) | ||
{ | ||
prefs.setCharPref("currentVersion", current); | ||
// for upgrade add code here | ||
} | ||
} | ||
|
||
} | ||
|
||
// The CSS rules of Cute Menus and other extensions and themes that add | ||
// icons to Firefox's menus are inserted after our tag menu binding rule | ||
// (menu[type="bookmarktags:tagmenu"]). Their binding, which is something | ||
|
@@ -290,7 +327,8 @@ var BookmarkTags= function () | |
elt= event.target; | ||
if (elt.parentNode && | ||
elt.parentNode.getAttribute("type") === "bookmarktags:tagpopup" && | ||
!document.getElementById("BookmarkTags-bmMenuToolbarbutton").open && | ||
(document.getElementById("BookmarkTags-bmMenuToolbarbutton") && | ||
!document.getElementById("BookmarkTags-bmMenuToolbarbutton").open) && | ||
!document.getElementById("BookmarkTags-tagMenuBookmarksPopup").open) | ||
{ | ||
window.XULBrowserWindow.setOverLink("", null); | ||
|
Oops, something went wrong.