diff options
author | dave@33eels.com <dave@33eels.com@4eb1ac78-321c-0410-a911-ec516a8615a5> | 2009-03-06 19:02:33 (GMT) |
---|---|---|
committer | dave@33eels.com <dave@33eels.com@4eb1ac78-321c-0410-a911-ec516a8615a5> | 2009-03-06 19:02:33 (GMT) |
commit | d93455ce04cb0f6b11649babd601b1ec8addffce (patch) | |
tree | 9ced11f86d07a9f206dfac238c98ecdfa557ecae | |
parent | 92e7daadd85ae7e6ff88eb229827d6cf1fab3c0f (diff) |
Bringing extension up-to-date with API changes.
git-svn-id: http://svn.mozilla.org/addons/trunk@22947 4eb1ac78-321c-0410-a911-ec516a8615a5
-rw-r--r-- | bandwagon/components/bandwagon-service.js | 66 | ||||
-rw-r--r-- | bandwagon/content/scripts/factory/collectionFactory.js | 8 | ||||
-rw-r--r-- | bandwagon/content/scripts/model/collection.js | 3 | ||||
-rw-r--r-- | bandwagon/content/ui/bindings/bandwagon.xml | 10 | ||||
-rw-r--r-- | bandwagon/content/ui/collectionsPaneController.js | 8 | ||||
-rw-r--r-- | bandwagon/content/ui/overlays/browserOverlayController.js | 4 | ||||
-rw-r--r-- | bandwagon/content/ui/settingsController.js | 14 | ||||
-rw-r--r-- | bandwagon/locale/en-US/extensionOverlay.properties | 2 | ||||
-rw-r--r-- | bandwagon/locale/en-US/extensionsOverlay.dtd | 2 |
9 files changed, 80 insertions, 37 deletions
diff --git a/bandwagon/components/bandwagon-service.js b/bandwagon/components/bandwagon-service.js index 8d42071..1632e3a 100644 --- a/bandwagon/components/bandwagon-service.js +++ b/bandwagon/components/bandwagon-service.js @@ -104,6 +104,7 @@ BandwagonService.prototype = { this._service = new Bandwagon.RPC.Service(); this._service.registerLogger(Bandwagon.Logger); this._service.registerObserver(this._getCollectionObserver); + this._service.registerObserver(this._getServiceDocumentObserver); this.registerCollectionUpdateObserver(this._collectionUpdateObserver); @@ -212,7 +213,7 @@ BandwagonService.prototype = { if (!collection.autoPublish) continue; - Bandwagon.Logger.debug("...to collection '" + collection.url + "'"); + Bandwagon.Logger.debug("...to collection '" + collection.resourceURL + "'"); var extension = { @@ -246,10 +247,10 @@ BandwagonService.prototype = { } else { - if (collection != null && collection.url != null) + if (collection != null && collection.resourceURL != null) { - Bandwagon.Logger.info("Finished getting updates for collection '" + collection.url + "'"); - bandwagonService.collections[collection.url] = collection; + Bandwagon.Logger.info("Finished getting updates for collection '" + collection.resourceURL + "'"); + bandwagonService.collections[collection.resourceURL] = collection; } } @@ -259,6 +260,39 @@ BandwagonService.prototype = { } }, + _getServiceDocumentObserver: function(event) + { + Bandwagon.Logger.info("in _getServiceDocumentObserver()"); + + if (event.getType() == Bandwagon.RPC.Constants.BANDWAGON_RPC_EVENT_TYPE_BANDWAGON_RPC_GET_SERVICE_DOCUMENT_COMPLETE) + { + if (event.isError()) + { + } + else + { + Bandwagon.Logger.debug("Updating collections list: have " + event.collections.length + " collections"); + + for (var i=0; i<event.collections.length; i++) + { + var collection = event.collections[i]; + + // TODO: do this properly, add/remove what we do/don't have. + + Bandwagon.Logger.debug("Updating collections list: adding " + collection.toString()); + + this.collections[collection] = collection; + + // TODO notify CollectionUpdate observers + } + + if (Bandwagon.COMMIT_NOW) + this.commit(collection); + } + } + }, + + _notifyCollectionUpdateObservers: function(collection) { Bandwagon.Logger.debug("Notifying collection update observers"); @@ -323,6 +357,15 @@ BandwagonService.prototype = { } }, + updateCollectionsList: function() + { + Bandwagon.Logger.debug("Updating collections list..."); + + // TODO, are we logged in? + + this._service.getServiceDocument(); + }, + checkForUpdates: function(collection) { var doCheck = false; @@ -357,7 +400,7 @@ BandwagonService.prototype = { } else { - Bandwagon.Logger.warn(collection.url + ": no global update interval nor collection update interval -- won't update"); + Bandwagon.Logger.warn(collection.resourceURL + ": no global update interval nor collection update interval -- won't update"); } if (doCheck) @@ -436,6 +479,9 @@ BandwagonService.prototype = { // FIXME temporarily disabling this //this._addDefaultCollection(Bandwagon.DEFAULT_COLLECTION1_URL, Bandwagon.DEFAULT_COLLECTION1_NAME); //this._addDefaultCollection("http://www.33eels.com/clients/briks/bandwagon/testcollection.xml", "test collection"); + + // get the user's list of collections + this.updateCollectionsList(); // check for cookie to see if we have to add a collection like that @@ -462,11 +508,11 @@ BandwagonService.prototype = { _addDefaultCollection: function(url, name) { var collection = this._collectionFactory.newCollection(); - collection.url = url; + collection.resourceURL = url; collection.name = name; collection.showNotifications = false; - this.collections[collection.url] = collection; + this.collections[collection.resourceURL] = collection; if (Bandwagon.COMMIT_NOW) this.commit(collection); @@ -478,9 +524,9 @@ BandwagonService.prototype = { addPreviewCollection: function(url) { var collection = this._collectionFactory.newCollection(); - collection.url = url; + collection.resourceURL = url; collection.preview = true; - this.collections[collection.url] = collection; + this.collections[collection.resourceURL] = collection; this.forceCheckForUpdates(collection); @@ -502,7 +548,7 @@ BandwagonService.prototype = { if (collection.preview) return; - Bandwagon.Logger.debug("In commit() with collection: " + collection.url); + Bandwagon.Logger.debug("In commit() with collection: " + collection.resourceURL); bandwagonService._collectionFactory.commitCollection(collection); }, diff --git a/bandwagon/content/scripts/factory/collectionFactory.js b/bandwagon/content/scripts/factory/collectionFactory.js index 6cdd585..38293a5 100644 --- a/bandwagon/content/scripts/factory/collectionFactory.js +++ b/bandwagon/content/scripts/factory/collectionFactory.js @@ -66,7 +66,7 @@ Bandwagon.Factory.CollectionFactory.prototype.openCollection = function(collecti collection.addons = this._openCollectionItems(collection); - collections[collection.url] = collection; + collections[collection.resourceURL] = collection; } finally { @@ -96,7 +96,7 @@ Bandwagon.Factory.CollectionFactory.prototype.openCollections = function() collection.addons = this._openCollectionItems(collection); - collections[collection.url] = collection; + collections[collection.resourceURL] = collection; } } finally @@ -117,7 +117,7 @@ Bandwagon.Factory.CollectionFactory.prototype.commitCollection = function(collec try { (collection.id==-1?statement.bindNullParameter(0):statement.bindInt32Parameter(0, collection.id)); - statement.bindUTF8StringParameter(1, collection.url); + statement.bindUTF8StringParameter(1, collection.resourceURL); statement.bindUTF8StringParameter(2, collection.name); statement.bindUTF8StringParameter(3, collection.description); statement.bindInt32Parameter(4, collection.dateAdded.getTime()/1000); @@ -189,7 +189,7 @@ Bandwagon.Factory.CollectionFactory.prototype._openCollectionFromRS = function(r { var collection = new this.Bandwagon.Model.Collection(); collection.id = resultset.getInt32(0); - collection.url = resultset.getUTF8String(1); + collection.resourceURL = resultset.getUTF8String(1); collection.name = resultset.getUTF8String(2); collection.description = resultset.getUTF8String(3); collection.dateAdded = new Date(resultset.getInt32(4)*1000); diff --git a/bandwagon/content/scripts/model/collection.js b/bandwagon/content/scripts/model/collection.js index 67fb958..f89e701 100644 --- a/bandwagon/content/scripts/model/collection.js +++ b/bandwagon/content/scripts/model/collection.js @@ -48,9 +48,6 @@ Bandwagon.Model.Collection = function() this.subscribed = false; this.lastModified = new Date(); - this.id = -1; // internal bandwagon id - this.url = ""; - this.password = null; this.dateAdded = new Date(); this.dateLastCheck = null; diff --git a/bandwagon/content/ui/bindings/bandwagon.xml b/bandwagon/content/ui/bindings/bandwagon.xml index 027170c..919d066 100644 --- a/bandwagon/content/ui/bindings/bandwagon.xml +++ b/bandwagon/content/ui/bindings/bandwagon.xml @@ -101,8 +101,8 @@ <body> <![CDATA[ this.collection = collection; - this.name = (collection.name && collection.name !=""?collection.name:collection.url); - this.url = collection.url; + this.name = (collection.name && collection.name !=""?collection.name:collection.resourceURL); + this.url = collection.resourceURL; this.preview = collection.preview; this.editable = collection.editable; this.unread = collection.getUnreadAddons().length; @@ -634,14 +634,14 @@ { var collection = this.writableCollections[i]; - if (document.getAnonymousElementByAttribute(this, "anonid", "bandwagon-collection-" + collection.url)) + if (document.getAnonymousElementByAttribute(this, "anonid", "bandwagon-collection-" + collection.resourceURL)) continue; var callback = createCollectionCallbackFunction(collection); var elemWritableCollection = document.createElementNS(XULNS, "menuitem"); - elemWritableCollection.setAttribute("label", (collection.name?collection.name:collection.url)); - elemWritableCollection.setAttribute("anonid", "bandwagon-collection-" + collection.url); + elemWritableCollection.setAttribute("label", (collection.name?collection.name:collection.resourceURL)); + elemWritableCollection.setAttribute("anonid", "bandwagon-collection-" + collection.resourceURL); elemWritableCollection.addEventListener("command", callback, true); elemWritableCollectionsPopup.insertBefore(elemWritableCollection, elemWritableCollectionSeparator); diff --git a/bandwagon/content/ui/collectionsPaneController.js b/bandwagon/content/ui/collectionsPaneController.js index 67b2e79..b1a9a39 100644 --- a/bandwagon/content/ui/collectionsPaneController.js +++ b/bandwagon/content/ui/collectionsPaneController.js @@ -205,7 +205,7 @@ Bandwagon.Controller.CollectionsPane.collectionUpdateObserver = function(collect } else { - Bandwagon.Logger.debug("In Bandwagon.Controller.CollectionsPane.collectionUpdateObserver() with collection '" + collection.url + "'"); + Bandwagon.Logger.debug("In Bandwagon.Controller.CollectionsPane.collectionUpdateObserver() with collection '" + collection.toString() + "'"); // update the unread count for this collection @@ -328,7 +328,7 @@ Bandwagon.Controller.CollectionsPane.doShowCollection = function() // misc. ui - Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionTitle.setAttribute("value", (collection?(collection.name?collection.name:collection.url):"")); + Bandwagon.Controller.CollectionsPane.elemBandwagonCollectionTitle.setAttribute("value", (collection?(collection.name?collection.name:collection.resourceURL):"")); if (collection && collection.description != "") { @@ -671,7 +671,7 @@ Bandwagon.Controller.CollectionsPane._selectPreferredCollection = function() // select a collection - last selected or the first one var elemsBandwagonCollection = Bandwagon.Controller.CollectionsPane.elemBandwagonCollections.getElementsByTagName("bandwagonCollection"); - if (Bandwagon.Controller.CollectionsPane.preferredCollection != null && bandwagonService.collections[Bandwagon.Controller.CollectionsPane.preferredCollection.url] != null) + if (Bandwagon.Controller.CollectionsPane.preferredCollection != null && bandwagonService.collections[Bandwagon.Controller.CollectionsPane.preferredCollection.resourceURL] != null) { Bandwagon.Logger.debug("selecting preferred collection (defined)"); Bandwagon.Controller.CollectionsPane._selectCollection(Bandwagon.Controller.CollectionsPane.preferredCollection); @@ -731,7 +731,7 @@ Bandwagon.Controller.CollectionsPane._repopulateAddonsList = function(collection if (collection == null) return; - Bandwagon.Logger.debug("Bandwagon.Controller.CollectionsPane: repopulating collection '" + collection.url + "'"); + Bandwagon.Logger.debug("Bandwagon.Controller.CollectionsPane: repopulating collection '" + collection.resourceURL + "'"); // sort by collectionItem.dateAdded diff --git a/bandwagon/content/ui/overlays/browserOverlayController.js b/bandwagon/content/ui/overlays/browserOverlayController.js index ada0300..23691ce 100644 --- a/bandwagon/content/ui/overlays/browserOverlayController.js +++ b/bandwagon/content/ui/overlays/browserOverlayController.js @@ -154,8 +154,8 @@ Bandwagon.Controller.BrowserOverlay.showNewAddonsAlert = function(collection) .getService(Components.interfaces.nsIAlertsService); var unnotifiedCount = collection.getUnnotifiedAddons().length; - var collectionName = (collection.name?collection.name:collection.url); - var collectionURL = collection.url; + var collectionName = (collection.name?collection.name:collection.resourceURL); + var collectionURL = collection.resourceURL; var listener = { diff --git a/bandwagon/content/ui/settingsController.js b/bandwagon/content/ui/settingsController.js index 79c0a30..4e5de97 100644 --- a/bandwagon/content/ui/settingsController.js +++ b/bandwagon/content/ui/settingsController.js @@ -151,9 +151,9 @@ Bandwagon.Controller.Settings.doShowCollection = function() var selectedItem = Bandwagon.Controller.Settings.elemBandwagonCollections.selectedItem; if (selectedItem && Bandwagon.Controller.Settings.elemBandwagonCollections.selectedItem.collection) - collection = Bandwagon.Controller.Settings.collections[Bandwagon.Controller.Settings.elemBandwagonCollections.selectedItem.collection.url]; + collection = Bandwagon.Controller.Settings.collections[Bandwagon.Controller.Settings.elemBandwagonCollections.selectedItem.collection.resourceURL]; - Bandwagon.Logger.debug("showing collection: " + (collection?collection.url:"<none>")); + Bandwagon.Logger.debug("showing collection: " + (collection?collection.resourceURL:"<none>")); if (!collection) { @@ -162,7 +162,7 @@ Bandwagon.Controller.Settings.doShowCollection = function() return; } - Bandwagon.Controller.Settings.elemCollectionName.value = (collection.name&&collection.name!=""?collection.name:collection.url); + Bandwagon.Controller.Settings.elemCollectionName.value = (collection.name&&collection.name!=""?collection.name:collection.resourceURL); //if (document.getElementById("checkbox-updateinterval-global").checked) if (true) @@ -208,7 +208,7 @@ Bandwagon.Controller.Settings.doSaveCollection = function() // save settings to local copy of the collection objects - var collection = Bandwagon.Controller.Settings.collections[Bandwagon.Controller.Settings.elemBandwagonCollections.selectedItem.collection.url]; + var collection = Bandwagon.Controller.Settings.collections[Bandwagon.Controller.Settings.elemBandwagonCollections.selectedItem.collection.resourceURL]; if (!collection) return; @@ -262,7 +262,7 @@ Bandwagon.Controller.Settings._repopulateCollectionsList = function() Bandwagon.Controller.Settings.collections[id] = { name: collection.name, - url: collection.url, + url: collection.resourceURL, updateInterval: collection.updateInterval, showNotifications: collection.showNotifications, addonsPerPage: collection.addonsPerPage, @@ -364,7 +364,7 @@ Bandwagon.Controller.Settings.doAccept = function() if (bwCollection.addonsPerPage != localCollection.addonsPerPage) { bwCollection.addonsPerPage = localCollection.addonsPerPage; - Bandwagon.Preferences.notifyObservers("addonsperpage:" + bwCollection.url); + Bandwagon.Preferences.notifyObservers("addonsperpage:" + bwCollection.resourceURL); } bwCollection.updateInterval = localCollection.updateInterval; @@ -416,7 +416,7 @@ Bandwagon.Controller.Settings.doRemove = function() } catch (e) { return; } var promptTitle = Bandwagon.Controller.Settings.stringBundle.getString("remove.collection"); - var promptMsg = Bandwagon.Controller.Settings.stringBundle.getFormattedString("are.you.sure.you.want.to.remove", [(collection.name?collection.name:collection.url)]); + var promptMsg = Bandwagon.Controller.Settings.stringBundle.getFormattedString("are.you.sure.you.want.to.remove", [(collection.name?collection.name:collection.resourceURL)]); var proceed = promptService.confirm( window, promptTitle, diff --git a/bandwagon/locale/en-US/extensionOverlay.properties b/bandwagon/locale/en-US/extensionOverlay.properties index ec7b639..212cbf1 100644 --- a/bandwagon/locale/en-US/extensionOverlay.properties +++ b/bandwagon/locale/en-US/extensionOverlay.properties @@ -1,5 +1,5 @@ collectionspane.this.is.only.a.preview=This is only a preview! -collectionspane.if.you.do.not.subscribe=If you do not subscribe, this subscription will disappear when you close Firefox. +collectionspane.if.you.do.not.subscribe=If you do not subscribe, this collection will disappear when you close Firefox. collectionspane.subscribe=Subscribe collectionspane.dont.subscribe=Don't Subscribe collectionspane.subscribe.accesskey=s diff --git a/bandwagon/locale/en-US/extensionsOverlay.dtd b/bandwagon/locale/en-US/extensionsOverlay.dtd index 72d1394..3373202 100644 --- a/bandwagon/locale/en-US/extensionsOverlay.dtd +++ b/bandwagon/locale/en-US/extensionsOverlay.dtd @@ -46,7 +46,7 @@ <!ENTITY view.label "View Collection">
<!ENTITY unsubscribe.label "Unsubscribe">
-<!ENTITY nocollectionssubscribed.label "You are not subscribed to any subscriptions">
+<!ENTITY nocollectionssubscribed.label "You are not subscribed to any collections">
<!ENTITY clicktosubscribe.label "Browse subscriptions">
<!ENTITY collectionisloading.label "Retrieving subscription">
<!ENTITY collectionhasnoitems.label "This collection contains no add-ons.">
|