mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
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
This commit is contained in:
parent
e55f07390a
commit
1e4cc58605
@ -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
|
||||
|
@ -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++
|
||||
|
@ -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
|
||||
|
@ -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">
|
||||
</RDF:Description>
|
||||
|
||||
<!-- overlay information -->
|
||||
<RDF:Seq about="urn:mozilla:overlays">
|
||||
<RDF:li resource="chrome://messenger/content/messenger.xul"/>
|
||||
<RDF:li resource="chrome://messenger/content/mailWindowOverlay.xul"/>
|
||||
</RDF:Seq>
|
||||
|
||||
<RDF:Seq about="chrome://messenger/content/messenger.xul">
|
||||
<RDF:li>chrome://messenger-newsblog/content/forumzilla.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<RDF:Seq about="chrome://messenger/content/mailWindowOverlay.xul">
|
||||
<RDF:li>chrome://messenger-newsblog/content/toolbar-icon.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
@ -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="<INSERT IDENTITY HERE>";
|
||||
|
||||
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;
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- XXX review this license for accuracy! -->
|
||||
<!--
|
||||
The contents of this file are subject to the Mozilla Public
|
||||
License Version 1.1 (the "License"); you may not use this file
|
||||
except in compliance with the License. You may obtain a copy of
|
||||
the License at http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS
|
||||
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
implied. See the License for the specific language governing
|
||||
rights and limitations under the License.
|
||||
|
||||
The Original Code is ForumZilla 0.1.1.
|
||||
|
||||
The Initial Developer of the Original Code is Zapogee, Inc.
|
||||
Portions created by Zapogee, Inc. are Copyright (C) 2001
|
||||
Zapogee, Inc. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Myk Melez, <myk@melez.com>, original author
|
||||
-->
|
||||
|
||||
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/x-javascript" src="utils.js" />
|
||||
<script type="application/x-javascript" src="file-utils.js" />
|
||||
<script type="application/x-javascript" src="debug-utils.js" />
|
||||
<script type="application/x-javascript" src="forumzilla.js" />
|
||||
<script type="application/x-javascript" src="Feed.js" />
|
||||
<script type="application/x-javascript" src="FeedItem.js" />
|
||||
|
||||
<!-- some debugging code
|
||||
<statusbar id="status-bar">
|
||||
<button label="download feeds" oncommand="downloadFeeds();"/>
|
||||
</statusbar>
|
||||
-->
|
||||
|
||||
</overlay>
|
||||
|
@ -35,6 +35,7 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
var kFeedUrlDelimiter = '|'; // the delimiter used to delimit feed urls in the msg folder database "feedUrl" property
|
||||
var gRSSServer = null;
|
||||
|
||||
function doLoad() {
|
||||
// Display the list of feed subscriptions.
|
||||
@ -43,6 +44,10 @@ function doLoad() {
|
||||
var tree = document.getElementById('subscriptions');
|
||||
tree.database.AddDataSource(ds);
|
||||
tree.builder.rebuild();
|
||||
|
||||
// extract the server argument
|
||||
if (window.arguments[0].server)
|
||||
gRSSServer = window.arguments[0].server;
|
||||
}
|
||||
|
||||
// opens the feed properties dialog
|
||||
@ -78,10 +83,9 @@ var feedDownloadCallback = {
|
||||
{
|
||||
updateStatusItem('progressMeter', 100);
|
||||
|
||||
var server = getIncomingServer();
|
||||
// if we get here...we should always have a folder by now...either
|
||||
// in feed.folder or FeedItems created the folder for us....
|
||||
var folder = feed.folder ? feed.folder : server.rootMsgFolder.getChildNamed(feed.name);
|
||||
var folder = feed.folder ? feed.folder : gRSSServer.rootMsgFolder.getChildNamed(feed.name);
|
||||
|
||||
updateFolderFeedUrl(folder, feed.url, false);
|
||||
|
||||
@ -133,8 +137,7 @@ function updateFolderFeedUrl(aFolder, aFeedUrl, aRemoveUrl)
|
||||
|
||||
function doAdd() {
|
||||
var userAddedFeed = false;
|
||||
var server = getIncomingServer();
|
||||
var feedProperties = { feedName: "", feedLocation: "", serverURI: server.serverURI, folderURI: "", result: userAddedFeed};
|
||||
var feedProperties = { feedName: "", feedLocation: "", serverURI: gRSSServer.serverURI, folderURI: "", result: userAddedFeed};
|
||||
|
||||
feedProperties = openFeedEditor(feedProperties);
|
||||
|
||||
@ -156,6 +159,9 @@ function doAdd() {
|
||||
feed.folder = folderResource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
}
|
||||
|
||||
// set the server for the feed
|
||||
feed.server = gRSSServer;
|
||||
|
||||
// update status text
|
||||
updateStatusItem('statusText', document.getElementById("bundle_newsblog").getString('subscribe-validating'));
|
||||
updateStatusItem('progressMeter', 0);
|
||||
@ -184,9 +190,8 @@ function doEdit() {
|
||||
|
||||
currentFolder = rdf.GetResource(currentFolderURI).QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
|
||||
var server = getIncomingServer();
|
||||
var userModifiedFeed = false;
|
||||
var feedProperties = { feedLocation: old_url, serverURI: server.serverURI, folderURI: currentFolderURI, result: userModifiedFeed};
|
||||
var feedProperties = { feedLocation: old_url, serverURI: gRSSServer.serverURI, folderURI: currentFolderURI, result: userModifiedFeed};
|
||||
|
||||
feedProperties = openFeedEditor(feedProperties);
|
||||
if (!feedProperties.result) // did the user cancel?
|
||||
@ -269,24 +274,13 @@ function doRemove() {
|
||||
if (!oldFeedUrl) // no more feeds pointing to the folder?
|
||||
{
|
||||
try {
|
||||
var server = getIncomingServer();
|
||||
var openerResource = server.rootMsgFolder.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
var openerResource = gRSSServer.rootMsgFolder.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
var folderResource = currentFolder.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
window.opener.messenger.DeleteFolders(window.opener.GetFolderDatasource(), openerResource, folderResource);
|
||||
} catch (e) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getIncomingServer() {
|
||||
return window.opener.getIncomingServer();
|
||||
}
|
||||
|
||||
function getMessageWindow() {
|
||||
return window.opener.getMessageWindow();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Disabled/Future Stuff
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/x-javascript">
|
||||
function openSubscriptionsDialog() {
|
||||
function openSubscriptionsDialog(aRSSServer) {
|
||||
|
||||
//check for an existing subscriptions window and focus it.
|
||||
const kWindowMediatorContractID = "@mozilla.org/appshell/window-mediator;1";
|
||||
@ -16,25 +16,17 @@
|
||||
lastSubscriptionWindow.focus();
|
||||
else
|
||||
window.openDialog("chrome://messenger-newsblog/content/subscriptions.xul", "",
|
||||
"centerscreen,resizable=yes");
|
||||
"centerscreen,resizable=yes", { server: aRSSServer});
|
||||
}
|
||||
|
||||
function openSubscriptionsDialogFromFolderPane()
|
||||
{
|
||||
// get the incoming server for the seleted folder
|
||||
var selectedFolders = GetSelectedMsgFolders();
|
||||
openSubscriptionsDialog(selectedFolders[0].server);
|
||||
}
|
||||
</script>
|
||||
|
||||
<menupopup id="taskPopup">
|
||||
<menuitem id="newsAndBlogsCmd"
|
||||
label="&newsBlogMenu.label;"
|
||||
insertbefore="menu_preferences"
|
||||
accesskey="&newsBlogMenu.accesskey;"
|
||||
oncommand="openSubscriptionsDialog();"/>
|
||||
</menupopup>
|
||||
|
||||
<toolbarpalette id="MailToolbarPalette">
|
||||
<toolbarbutton id="button-newsandblogs"
|
||||
label="&newsBlogMenu.label;"
|
||||
tooltiptext="&newsBlogMenu.tooltip;"
|
||||
oncommand="openSubscriptionsDialog();"/>
|
||||
</toolbarpalette>
|
||||
|
||||
<!-- Overlay into the folder pane context menu. If you change the id for the menu item, please
|
||||
update mailContextMenus.js
|
||||
-->
|
||||
@ -43,7 +35,7 @@
|
||||
insertafter="folderPaneContext-subscribe"
|
||||
label="&folderContextRSSSubscribe.label;"
|
||||
accesskey="&folderContextRSSSubscribe.accesskey;"
|
||||
oncommand="openSubscriptionsDialog();"/>
|
||||
oncommand="openSubscriptionsDialogFromFolderPane();"/>
|
||||
</popup>
|
||||
|
||||
</overlay>
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
}
|
||||
|
37
mail/extensions/newsblog/rss.rdf
Normal file
37
mail/extensions/newsblog/rss.rdf
Normal file
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0"?>
|
||||
<RDF:RDF
|
||||
xmlns:NC="http://home.netscape.com/NC-rdf#"
|
||||
xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
|
||||
<RDF:Description about="NC:ispinfo">
|
||||
<NC:providers>
|
||||
<NC:nsIMsgAccount about="domain:">
|
||||
|
||||
<!-- server info -->
|
||||
<NC:incomingServer>
|
||||
<NC:nsIMsgIncomingServer>
|
||||
<NC:hostName>News & Blogs</NC:hostName>
|
||||
<NC:type>rss</NC:type>
|
||||
<NC:username>nobody</NC:username>
|
||||
</NC:nsIMsgIncomingServer>
|
||||
</NC:incomingServer>
|
||||
|
||||
<!-- identity defaults -->
|
||||
<NC:identity>
|
||||
<NC:nsIMsgIdentity>
|
||||
</NC:nsIMsgIdentity>
|
||||
</NC:identity>
|
||||
|
||||
<NC:wizardHideIncoming>true</NC:wizardHideIncoming>
|
||||
<NC:wizardAccountName>News & Blogs</NC:wizardAccountName>
|
||||
<NC:wizardSkipPanels>identitypage,serverpage,loginpage</NC:wizardSkipPanels>
|
||||
<NC:wizardShortName>RSS</NC:wizardShortName>
|
||||
<NC:wizardLongName>RSS News & Blogs Account</NC:wizardLongName>
|
||||
<NC:wizardShow>true</NC:wizardShow>
|
||||
<NC:emailProviderName>RSS</NC:emailProviderName>
|
||||
<NC:showServerDetailsOnWizardSummary>false</NC:showServerDetailsOnWizardSummary>
|
||||
</NC:nsIMsgAccount>
|
||||
</NC:providers>
|
||||
</RDF:Description>
|
||||
|
||||
</RDF:RDF>
|
Loading…
Reference in New Issue
Block a user