Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordave@33eels.com <dave@33eels.com@4eb1ac78-321c-0410-a911-ec516a8615a5>2008-09-23 16:36:38 (GMT)
committer dave@33eels.com <dave@33eels.com@4eb1ac78-321c-0410-a911-ec516a8615a5>2008-09-23 16:36:38 (GMT)
commitf5ed1348a70414dff9ae603a5ea91675a669fb94 (patch)
tree933adb6f787a356ec61c61fa9ccd3df92373087f
parentecc0899832f57d28541cb13b5eb3675a594338f7 (diff)
A start on the notification system (bug 774)
git-svn-id: http://svn.mozilla.org/addons/trunk@18507 4eb1ac78-321c-0410-a911-ec516a8615a5
-rw-r--r--bandwagon/components/bandwagon-service.js54
-rw-r--r--bandwagon/content/scripts/bandwagon.js2
-rw-r--r--bandwagon/content/scripts/factory/feedFactory.js1
-rw-r--r--bandwagon/content/scripts/model/feed.js2
-rw-r--r--bandwagon/content/scripts/model/feedItem.js6
-rw-r--r--bandwagon/content/ui/bindings/bandwagon.xml6
-rw-r--r--bandwagon/content/ui/feedsPaneController.js13
-rw-r--r--bandwagon/content/ui/overlays/extensionsOverlayController.js15
-rw-r--r--bandwagon/skin/extensionsOverlay.css5
9 files changed, 95 insertions, 9 deletions
diff --git a/bandwagon/components/bandwagon-service.js b/bandwagon/components/bandwagon-service.js
index d2899cd..20fc58c 100644
--- a/bandwagon/components/bandwagon-service.js
+++ b/bandwagon/components/bandwagon-service.js
@@ -46,11 +46,13 @@ const WindowMediator = Cc["@mozilla.org/appshell/window-mediator;1"];
const Timer = Cc["@mozilla.org/timer;1"];
const ExtensionsManager = Cc["@mozilla.org/extensions/manager;1"];
const Storage = Cc["@mozilla.org/storage/service;1"];
+const AppShellService = Cc["@mozilla.org/appshell/appShellService;1"];
const nsIWindowMediator = Ci.nsIWindowMediator;
const nsITimer = Ci.nsITimer;
const nsIExtensionManager = Ci.nsIExtensionManager;
const mozIStorageService = Ci.mozIStorageService;
+const nsIAppShellService = Ci.nsIAppShellService;
var Bandwagon;
var bandwagonService;
@@ -98,7 +100,8 @@ BandwagonService.prototype = {
this._service = new Bandwagon.RPC.Service();
this._service.registerLogger(Bandwagon.Logger);
this._service.registerObserver(this._getFeedObserver);
- this.registerFeedUpdateObserver(this.commit);
+
+ this.registerFeedUpdateObserver(this._feedUpdateObserver);
// init sqlite storage (also creating tables in sqlite if needed). create factory objects.
@@ -140,7 +143,11 @@ BandwagonService.prototype = {
};
this._feedUpdateTimer = Timer.createInstance(nsITimer);
- this._feedUpdateTimer.init(this._nsUpdateNotifier, Bandwagon.FEED_UPDATE_TIMER_DELAY*1000, nsITimer.TYPE_REPEATING_SLACK);
+ this._feedUpdateTimer.init(
+ this._nsUpdateNotifier,
+ (Bandwagon.Preferences.getPreference("debug")?30*1000:Bandwagon.FEED_UPDATE_TIMER_DELAY*1000),
+ nsITimer.TYPE_REPEATING_SLACK
+ );
this._initialized = true;
@@ -443,6 +450,49 @@ BandwagonService.prototype = {
}
},
+ _feedUpdateObserver: function(feed)
+ {
+ // called when a feed is updated
+
+ // if there's new items, notify the user
+
+ //Bandwagon.Logger.debug("in _feedUpdateObserver() with feed '" + feed + "', unread feed items = " + feed.getUnreadFeedItems().length)
+
+ if (feed.getUnreadFeedItems().length > 0)
+ {
+ var theEM = WindowMediator.getService(nsIWindowMediator).getMostRecentWindow("Extension:Manager");
+
+ if (theEM)
+ {
+ theEM.focus();
+ theEM.showView('bandwagon-feeds');
+
+ // if the em is open, select the bandwagon-feeds pane, but don't select the feed itself.
+ // the user will be notified by the unread count in the left hand side bar
+
+ //theEM.setTimeout(function() { Bandwagon.Controller.FeedsPane._selectFeed(feed); }, 500);
+ }
+ else
+ {
+ const EMURL = "chrome://mozapps/content/extensions/extensions.xul";
+ const EMFEATURES = "chrome,menubar,extra-chrome,toolbar,dialog=no,resizable";
+
+ // the em is not open - open it, and select this feed
+
+ var navwin = WindowMediator.getService(nsIWindowMediator).getMostRecentWindow("navigator:browser");
+
+ if (navwin)
+ navwin.openDialog(EMURL, "", EMFEATURES, {selectFeed: feed});
+ else
+ Bandwagon.Logger.error("No browser windows open - can't open EM");
+ }
+ }
+
+ // commit the feed
+
+ bandwagonService.commit(feed);
+ },
+
_initStorage: function()
{
var storageService = Storage.getService(mozIStorageService);
diff --git a/bandwagon/content/scripts/bandwagon.js b/bandwagon/content/scripts/bandwagon.js
index 9651852..5da90cc 100644
--- a/bandwagon/content/scripts/bandwagon.js
+++ b/bandwagon/content/scripts/bandwagon.js
@@ -42,7 +42,7 @@ Bandwagon.RPC = new function() {}
Bandwagon.EMID = "sharing@addons.mozilla.org";
Bandwagon.SQLITE_FILENAME = "bandwagon.sqlite";
-Bandwagon.FEED_UPDATE_TIMER_DELAY = 60 * 60; // interval between checking if feeds need updating (in seconds)
+Bandwagon.FEED_UPDATE_TIMER_DELAY = 60 * 60; // interval between checking if feeds need updating (in seconds) (this will always be 30 seconds in debug mode)
Bandwagon.DEFAULT_FEED_UPDATE_INTERVAL = 24 * 60 * 60; // default individual feed update interval (in seconds)
Bandwagon.DEFAULT_FEED1_URL = "https://services.addons.mozilla.org/en-US/firefox/api/1.1/list/featured/all/10/";
Bandwagon.DEFAULT_FEED1_NAME = "Featured Add-ons";
diff --git a/bandwagon/content/scripts/factory/feedFactory.js b/bandwagon/content/scripts/factory/feedFactory.js
index 0a1ee64..e700bff 100644
--- a/bandwagon/content/scripts/factory/feedFactory.js
+++ b/bandwagon/content/scripts/factory/feedFactory.js
@@ -216,6 +216,7 @@ Bandwagon.Factory.FeedFactory.prototype._openFeedItems = function(feed)
while (statement.executeStep())
{
var feedItem = new this.Bandwagon.Model.FeedItem();
+ feedItem.Bandwagon = this.Bandwagon;
feedItem.id = statement.getInt32(0);
feedItem.guid = statement.getUTF8String(1);
diff --git a/bandwagon/content/scripts/model/feed.js b/bandwagon/content/scripts/model/feed.js
index 0313f02..eb4fc70 100644
--- a/bandwagon/content/scripts/model/feed.js
+++ b/bandwagon/content/scripts/model/feed.js
@@ -98,6 +98,8 @@ Bandwagon.Model.Feed.prototype.unserialize = function(xaddons)
for each (var xaddon in xaddons.addon)
{
var feedItem = new this.Bandwagon.Model.FeedItem();
+ feedItem.Bandwagon = this.Bandwagon;
+
feedItem.unserialize(xaddon);
if (feedItem.guid && feedItem.guid != "" && feedItem.name && feedItem.name != "")
diff --git a/bandwagon/content/scripts/model/feedItem.js b/bandwagon/content/scripts/model/feedItem.js
index 7767d76..a667d51 100644
--- a/bandwagon/content/scripts/model/feedItem.js
+++ b/bandwagon/content/scripts/model/feedItem.js
@@ -36,7 +36,11 @@
Bandwagon.Model.FeedItem = function()
{
- this.Bandwagon = Bandwagon;
+ try
+ {
+ this.Bandwagon = Bandwagon;
+ }
+ catch (e) {}
this.TYPE_EXTENSION = 1;
this.STATUS_PUBLIC = 4;
diff --git a/bandwagon/content/ui/bindings/bandwagon.xml b/bandwagon/content/ui/bindings/bandwagon.xml
index f751568..30b061b 100644
--- a/bandwagon/content/ui/bindings/bandwagon.xml
+++ b/bandwagon/content/ui/bindings/bandwagon.xml
@@ -288,6 +288,11 @@
onset="document.getAnonymousElementByAttribute(this, 'anonid', 'category').value = this._stringBundle.getFormattedString('bandwagon.feeditem.category', [val])"
/>
+ <property name="read"
+ onget="return this.getAttribute('read')"
+ onset="this.setAttribute('read', val);"
+ />
+
<property name="dateAdded" onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'dateadded').value">
<setter>
<![CDATA[
@@ -380,6 +385,7 @@
this.author = (feedItem.author?feedItem.author:"Unknown");
this.category = (feedItem.category?feedItem.category:"Unknown");
this.dateAdded = feedItem.dateAdded;
+ this.read = feedItem.read;
if (feedItem.comments.length > 0)
{
diff --git a/bandwagon/content/ui/feedsPaneController.js b/bandwagon/content/ui/feedsPaneController.js
index 42d8b1a..cd15d4a 100644
--- a/bandwagon/content/ui/feedsPaneController.js
+++ b/bandwagon/content/ui/feedsPaneController.js
@@ -39,6 +39,8 @@ Bandwagon.Controller.FeedsPane = new function()
this.initialized = false;
this.initializedBindings = false;
+ this.preferredFeed = null;
+
this.elemBandwagonFeeds = null;
this.elemBandwagonFeedItems = null;
this.elemBandwagonButtonViewSite = null;
@@ -302,7 +304,12 @@ Bandwagon.Controller.FeedsPane.doExpandFeedItem = function(event)
if (selectedElemBandwagonFeedItem != null)
{
+ selectedElemBandwagonFeedItem.read = true;
+
feedItem = selectedElemBandwagonFeedItem.feedItem;
+ feedItem.read = true;
+
+ Bandwagon.Controller.FeedsPane.elemBandwagonFeeds.selectedItem.unread = Bandwagon.Controller.FeedsPane.elemBandwagonFeeds.selectedItem.feed.getUnreadFeedItems().length;
}
}
@@ -491,7 +498,11 @@ Bandwagon.Controller.FeedsPane._selectPreferredFeed = function()
var elemsBandwagonFeed = Bandwagon.Controller.FeedsPane.elemBandwagonFeeds.getElementsByTagName("bandwagonFeed");
- if (elemsBandwagonFeed.length > 0)
+ if (Bandwagon.Controller.FeedsPane.preferredFeed)
+ {
+ Bandwagon.Controller.FeedsPane._selectFeed(Bandwagon.Controller.FeedsPane.preferredFeed);
+ }
+ else if (elemsBandwagonFeed.length > 0)
{
Bandwagon.Controller.FeedsPane._selectFeed(elemsBandwagonFeed[0].feed);
}
diff --git a/bandwagon/content/ui/overlays/extensionsOverlayController.js b/bandwagon/content/ui/overlays/extensionsOverlayController.js
index d134f9f..1a05b18 100644
--- a/bandwagon/content/ui/overlays/extensionsOverlayController.js
+++ b/bandwagon/content/ui/overlays/extensionsOverlayController.js
@@ -60,11 +60,18 @@ Bandwagon.Controller.ExtensionsOverlay.init = function()
{
var inArgs = window.arguments[0];
- if (inArgs && inArgs.subscribe)
+ if (inArgs)
{
- Bandwagon.Controller.ExtensionsOverlay._showFeedsPaneView();
-
- setTimeout(function() { Bandwagon.Controller.FeedsPane.doShowFeedPreview(inArgs.subscribe); }, 500);
+ if (inArgs.subscribe)
+ {
+ Bandwagon.Controller.ExtensionsOverlay._showFeedsPaneView();
+ setTimeout(function() { Bandwagon.Controller.FeedsPane.doShowFeedPreview(inArgs.subscribe); }, 500);
+ }
+ else if (inArgs.selectFeed)
+ {
+ Bandwagon.Controller.FeedsPane.preferredFeed = inArgs.selectFeed;
+ Bandwagon.Controller.ExtensionsOverlay._showFeedsPaneView();
+ }
}
}
}
diff --git a/bandwagon/skin/extensionsOverlay.css b/bandwagon/skin/extensionsOverlay.css
index 73c3847..f855eb8 100644
--- a/bandwagon/skin/extensionsOverlay.css
+++ b/bandwagon/skin/extensionsOverlay.css
@@ -132,6 +132,11 @@ richlistbox:focus > bandwagonFeedItem[selected="true"] {
color: HighlightText;
}
+bandwagonFeedItem[read="false"] {
+ background-color: #fdf2ab;
+ color: #585620;
+}
+
bandwagonFeedItem .right {
text-align: right;
}