From 1e4cc586050c7a1a04e59856d680d33a1708f1c6 Mon Sep 17 00:00:00 2001 From: "scott%scott-macgregor.org" Date: Thu, 22 Jul 2004 18:39:28 +0000 Subject: [PATCH] Bug #2522483 --> Add account wizard support for creating RSS accounts. This allows us to remove the forumzilla.js and .xul from the build since the account wizard is responsible for creating the account. sr=bienvenu --- mail/extensions/newsblog/Makefile.in | 12 ++-- mail/extensions/newsblog/content/Feed.js | 3 +- mail/extensions/newsblog/content/FeedItem.js | 15 +--- mail/extensions/newsblog/content/contents.rdf | 8 +-- .../extensions/newsblog/content/forumzilla.js | 70 ------------------- .../newsblog/content/forumzilla.xul | 39 ----------- .../newsblog/content/subscriptions.js | 30 ++++---- .../newsblog/content/toolbar-icon.xul | 28 +++----- mail/extensions/newsblog/content/utils.js | 3 +- mail/extensions/newsblog/jar.mn | 2 - mail/extensions/newsblog/js/newsblog.js | 1 + mail/extensions/newsblog/rss.rdf | 37 ++++++++++ 12 files changed, 74 insertions(+), 174 deletions(-) delete mode 100755 mail/extensions/newsblog/content/forumzilla.js delete mode 100755 mail/extensions/newsblog/content/forumzilla.xul create mode 100644 mail/extensions/newsblog/rss.rdf diff --git a/mail/extensions/newsblog/Makefile.in b/mail/extensions/newsblog/Makefile.in index dd3c492cbd2a..cc78c474ba1f 100755 --- a/mail/extensions/newsblog/Makefile.in +++ b/mail/extensions/newsblog/Makefile.in @@ -45,7 +45,12 @@ include $(DEPTH)/config/autoconf.mk MODULE = newsblog -include $(DEPTH)/config/autoconf.mk +EXPORT_DIR = $(DIST)/bin/defaults/isp +EXPORT_DIR_L10N = $(DIST)/bin/defaults/isp/US + +libs:: + $(INSTALL) $(addprefix $(srcdir)/, rss.rdf) $(EXPORT_DIR) + $(INSTALL) $(addprefix $(srcdir)/, rss.rdf) $(EXPORT_DIR_L10N) DIRS += skin @@ -53,8 +58,3 @@ EXTRA_COMPONENTS = js/newsblog.js include $(topsrcdir)/config/rules.mk -#libs:: -# @$(REGCHROME) content messenger-newsblog messenger.jar - -#install:: -# @$(REGCHROME_INSTALL) content messenger-newsblog messenger.jar diff --git a/mail/extensions/newsblog/content/Feed.js b/mail/extensions/newsblog/content/Feed.js index 8b370c3fa1f0..95c723c63235 100755 --- a/mail/extensions/newsblog/content/Feed.js +++ b/mail/extensions/newsblog/content/Feed.js @@ -26,6 +26,7 @@ function Feed(resource) { this.request = null; this.folder = null; + this.server = null; this.downloadCallback = null; @@ -454,7 +455,7 @@ function storeNextItem() item.markValid(); // if the listener is tracking progress for storing each item, report it here... - if (item.feed.downloadCallback.onFeedItemStored) + if (item.feed.downloadCallback && item.feed.downloadCallback.onFeedItemStored) item.feed.downloadCallback.onFeedItemStored(item.feed, gItemsToStoreIndex, gItemsToStore.length); gItemsToStoreIndex++ diff --git a/mail/extensions/newsblog/content/FeedItem.js b/mail/extensions/newsblog/content/FeedItem.js index 064482485477..fed6e051540b 100755 --- a/mail/extensions/newsblog/content/FeedItem.js +++ b/mail/extensions/newsblog/content/FeedItem.js @@ -167,12 +167,7 @@ FeedItem.prototype.isStored = function() { debug(this.identity + " checking to see if stored"); - var server; - if (this.feed.folder) - server = this.feed.folder.server; - else - server = getIncomingServer(); - + var server = this.feed.server; var folder = this.feed.folder; try { @@ -184,7 +179,7 @@ FeedItem.prototype.isStored = function() { { debug(this.feed.name + " folder doesn't exist; creating"); debug("creating " + this.feed.name + "as child of " + server.rootMsgFolder + "\n"); - server.rootMsgFolder.createSubfolder(this.feed.name, getMessageWindow()); + server.rootMsgFolder.createSubfolder(this.feed.name, null /* supposed to be a msg window */); folder = server.rootMsgFolder.FindSubFolder(this.feed.name); debug(this.identity + " not stored (folder didn't exist)"); return false; @@ -294,11 +289,7 @@ FeedItem.prototype.toUtf8 = function(str) { FeedItem.prototype.writeToFolder = function() { debug(this.identity + " writing to message folder" + this.feed.name + "\n"); - var server; - if (this.feed.folder) - server = this.feed.folder.server; - else - server = getIncomingServer(); + var server = this.feed.server; // XXX Should we really be modifying the original data here instead of making // a copy of it? Currently we never use the item object again after writing it diff --git a/mail/extensions/newsblog/content/contents.rdf b/mail/extensions/newsblog/content/contents.rdf index 43a9cbffe1f9..ba4df82652d0 100755 --- a/mail/extensions/newsblog/content/contents.rdf +++ b/mail/extensions/newsblog/content/contents.rdf @@ -14,20 +14,14 @@ chrome:author="Team Thunderbird" chrome:name="messenger-newsblog" chrome:description="This extension adds the ability to read news and blog feeds to Mozilla Thunderbird." - chrome:extension="true" - > + chrome:extension="true"> - - - chrome://messenger-newsblog/content/forumzilla.xul - - chrome://messenger-newsblog/content/toolbar-icon.xul diff --git a/mail/extensions/newsblog/content/forumzilla.js b/mail/extensions/newsblog/content/forumzilla.js deleted file mode 100755 index ae7ed2b0f65a..000000000000 --- a/mail/extensions/newsblog/content/forumzilla.js +++ /dev/null @@ -1,70 +0,0 @@ -// Eventually, these DS calls should be removed once we verify that all the consumers -// try to get the database first. -// Load and cache the subscriptions data source so it's available when we need it. -getSubscriptionsDS(); -getItemsDS(); - -const SERVER_NAME = "News & Blogs"; - -var gFzIncomingServer; // cache -function getIncomingServer() { - - if (gFzIncomingServer) - return gFzIncomingServer; - - var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"] - .getService(Components.interfaces.nsIMsgAccountManager); - - gFzIncomingServer = accountManager.FindServer("nobody", SERVER_NAME, "rss"); - - return gFzIncomingServer; -} - -function getMessageWindow() { - return msgWindow; -} - -var gFzAccount; // cache -function getAccount() { - if (gFzAccount) - return gFzAccount; - - var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"] - .getService(Components.interfaces.nsIMsgAccountManager); - - try { - gFzAccount = accountManager.FindAccountForServer(getIncomingServer()); - } - catch (ex) { - debug("no incoming server or account; creating account..."); - gFzAccount = createAccount(); - } - return gFzAccount; -} - -function createAccount() { - // I don't think we need an identity, at least not yet. If we did, though, - // this is how we would create it, and then we'd use the commented-out - // addIdentity() call below to add it to the account. - //var identity = accountManager.createIdentity(); - //identity.email=""; - - var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"] - .getService(Components.interfaces.nsIMsgAccountManager); - - var server = accountManager.createIncomingServer("nobody", SERVER_NAME, "rss"); - - // XXX What's the difference between "name" and "prettyName"? - // This seems to set the name, not the pretty name, but it does what I want, - // which is to display this name in the folder pane of the mail window. - server.prettyName = SERVER_NAME; - - var account = accountManager.createAccount(); - if (!account) - throw("couldn't create account"); - - account.incomingServer = server; - //account.addIdentity(identity); - - return account; -} diff --git a/mail/extensions/newsblog/content/forumzilla.xul b/mail/extensions/newsblog/content/forumzilla.xul deleted file mode 100755 index 3db0a8465b5c..000000000000 --- a/mail/extensions/newsblog/content/forumzilla.xul +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - @@ -43,7 +35,7 @@ insertafter="folderPaneContext-subscribe" label="&folderContextRSSSubscribe.label;" accesskey="&folderContextRSSSubscribe.accesskey;" - oncommand="openSubscriptionsDialog();"/> + oncommand="openSubscriptionsDialogFromFolderPane();"/> diff --git a/mail/extensions/newsblog/content/utils.js b/mail/extensions/newsblog/content/utils.js index bd98b424460f..b34ea484a8f1 100755 --- a/mail/extensions/newsblog/content/utils.js +++ b/mail/extensions/newsblog/content/utils.js @@ -125,7 +125,8 @@ function getSubscriptionsDS() { var file = getSubscriptionsFile(); var url = fileHandler.getURLSpecFromFile(file); - gFzSubscriptionsDS = rdf.GetDataSource(url); + gFzSubscriptionsDS = rdf.GetDataSourceBlocking(url); + if (!gFzSubscriptionsDS) throw("can't get subscriptions data source"); diff --git a/mail/extensions/newsblog/jar.mn b/mail/extensions/newsblog/jar.mn index bdfcfb737f10..f18ac1a7c97e 100755 --- a/mail/extensions/newsblog/jar.mn +++ b/mail/extensions/newsblog/jar.mn @@ -1,7 +1,5 @@ newsblog.jar: * content/messenger-newsblog/toolbar-icon.xul (content/toolbar-icon.xul) -* content/messenger-newsblog/forumzilla.xul (content/forumzilla.xul) -* content/messenger-newsblog/forumzilla.js (content/forumzilla.js) * content/messenger-newsblog/subscriptions.xul (content/subscriptions.xul) * content/messenger-newsblog/edittree.xml (content/edittree.xml) * content/messenger-newsblog/debug-utils.js (content/debug-utils.js) diff --git a/mail/extensions/newsblog/js/newsblog.js b/mail/extensions/newsblog/js/newsblog.js index ad6e04b53954..3b265d86e4a1 100755 --- a/mail/extensions/newsblog/js/newsblog.js +++ b/mail/extensions/newsblog/js/newsblog.js @@ -60,6 +60,7 @@ var nsNewsBlogFeedDownloader = feed = new Feed(id); feed.urlListener = aUrlListener; feed.folder = aFolder; + feed.server = aFolder.server; feed.msgWindow = aMsgWindow; feed.download(); } diff --git a/mail/extensions/newsblog/rss.rdf b/mail/extensions/newsblog/rss.rdf new file mode 100644 index 000000000000..f93e9df004bb --- /dev/null +++ b/mail/extensions/newsblog/rss.rdf @@ -0,0 +1,37 @@ + + + + + + + + + + + News & Blogs + rss + nobody + + + + + + + + + + true + News & Blogs + identitypage,serverpage,loginpage + RSS + RSS News & Blogs Account + true + RSS + false + + + + +