Bug #252688 --> Move feeds.rdf and feeditems.rdf into the RSS account directory.

Any time we try to fetch one of the data sources, we have to passing the incoming server
for those data sources.

Minor improvements to the RSS account settings panel, allow the user to change the name
of the RSS server in the folder pane. Allow the user to reach the subscriptions dialog from
the account settings panel.

Make the feed parser clear out the xml http request after it is done with it to eliminate some weird
shut down errors.
This commit is contained in:
scott%scott-macgregor.org 2004-07-22 23:29:36 +00:00
Родитель 9962db3236
Коммит e7d0e02634
7 изменённых файлов: 86 добавлений и 77 удалений

Просмотреть файл

@ -70,7 +70,6 @@ Feed.prototype.download = function(parseItems, aCallback) {
this.downloadCallback = aCallback; // may be null
// var loadgroup = this.request.channel.loadgroup;
this.request.overrideMimeType("text/xml");
this.request.onload = Feed.onDownloaded;
this.request.onerror = Feed.onDownloadError;
@ -115,7 +114,7 @@ Feed.onDownloadError = function(event) {
}
Feed.prototype.url getter = function() {
var ds = getSubscriptionsDS();
var ds = getSubscriptionsDS(this.server);
var url = ds.GetTarget(this.resource, DC_IDENTIFIER, true);
if (url)
url = url.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
@ -125,7 +124,7 @@ Feed.prototype.url getter = function() {
}
Feed.prototype.title getter = function() {
var ds = getSubscriptionsDS();
var ds = getSubscriptionsDS(this.server);
var title = ds.GetTarget(this.resource, DC_TITLE, true);
if (title)
title = title.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
@ -133,7 +132,7 @@ Feed.prototype.title getter = function() {
}
Feed.prototype.title setter = function(new_title) {
var ds = getSubscriptionsDS();
var ds = getSubscriptionsDS(this.server);
new_title = rdf.GetLiteral(new_title || "");
var old_title = ds.GetTarget(this.resource, DC_TITLE, true);
if (old_title)
@ -143,7 +142,7 @@ Feed.prototype.title setter = function(new_title) {
}
Feed.prototype.quickMode getter = function() {
var ds = getSubscriptionsDS();
var ds = getSubscriptionsDS(this.server);
var quickMode = ds.GetTarget(this.resource, FZ_QUICKMODE, true);
if (quickMode) {
quickMode = quickMode.QueryInterface(Components.interfaces.nsIRDFLiteral);
@ -186,7 +185,7 @@ Feed.prototype.parse = function() {
debug(this.url + " is of unknown format; assuming an RSS 0.9x feed");
this.parseAsRSS2();
}
var ds = getItemsDS();
var ds = getItemsDS(this.server);
ds = ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
ds.Flush();
}
@ -409,7 +408,7 @@ Feed.prototype.parseAsAtom = function() {
}
Feed.prototype.invalidateItems = function invalidateItems() {
var ds = getItemsDS();
var ds = getItemsDS(this.server);
debug("invalidating items for " + this.url);
var items = ds.GetSources(FZ_FEED, this.resource, true);
var item;
@ -424,7 +423,7 @@ Feed.prototype.invalidateItems = function invalidateItems() {
}
Feed.prototype.removeInvalidItems = function() {
var ds = getItemsDS();
var ds = getItemsDS(this.server);
debug("removing invalid items for " + this.url);
var items = ds.GetSources(FZ_FEED, this.resource, true);
var item;
@ -475,9 +474,13 @@ function storeNextItem()
else
{
item.feed.removeInvalidItems();
if (item.feed.downloadCallback)
item.feed.downloadCallback.downloaded(item.feed);
item.feed.request = null; // force the xml http request to go away. This helps reduce some
// nasty assertions on shut down of all things.
gItemsToStore = "";
gItemsToStoreIndex = 0;
}

Просмотреть файл

@ -185,7 +185,7 @@ FeedItem.prototype.isStored = function() {
return false;
}
var ds = getItemsDS();
var ds = getItemsDS(server);
var itemResource = rdf.GetResource(this.url || ("urn:" + this.id));
var downloaded = ds.GetTarget(itemResource, FZ_STORED, true);
if (!downloaded || downloaded.QueryInterface(Components.interfaces.nsIRDFLiteral).Value == "false")
@ -204,7 +204,7 @@ FeedItem.prototype.isStored = function() {
FeedItem.prototype.markValid = function() {
debug("validating " + this.url);
var ds = getItemsDS();
var ds = getItemsDS(this.feed.server);
var resource = rdf.GetResource(this.url || ("urn:" + this.id));
if (!ds.HasAssertion(resource, FZ_FEED, rdf.GetResource(this.feed.url), true))
@ -221,7 +221,7 @@ FeedItem.prototype.markValid = function() {
FeedItem.prototype.markStored = function() {
var ds = getItemsDS();
var ds = getItemsDS(this.feed.server);
var resource = rdf.GetResource(this.url || ("urn:" + this.id));
if (!ds.HasAssertion(resource, FZ_FEED, rdf.GetResource(this.feed.url), true))

Просмотреть файл

@ -29,7 +29,29 @@
# the terms of any one of the MPL, the GPL or the LGPL.
# ***** END LICENSE BLOCK *****
var gIncomingServer;
function onInit()
{
// nothing to do here yet...
}
function onPreInit(account, accountValues)
{
gIncomingServer = account.incomingServer;
}
function manageSubscriptions()
{
// XXX: This code should be shared with the JS in toolbar-icon.xul
const kWindowMediatorContractID = "@mozilla.org/appshell/window-mediator;1";
const kWindowMediatorIID = Components.interfaces.nsIWindowMediator;
const kWindowMediator = Components.classes[kWindowMediatorContractID].getService(kWindowMediatorIID);
var lastSubscriptionWindow = kWindowMediator.getMostRecentWindow("Mail:News-BlogSubscriptions");
if (lastSubscriptionWindow)
lastSubscriptionWindow.focus();
else
window.openDialog("chrome://messenger-newsblog/content/subscriptions.xul", "",
"centerscreen,resizable=yes", { server: gIncomingServer});
}

Просмотреть файл

@ -31,7 +31,12 @@
<?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
<!DOCTYPE page SYSTEM "chrome://messenger-newsblog/locale/am-newsblog.dtd">
<!DOCTYPE page [
<!ENTITY % newsblogDTD SYSTEM "chrome://messenger-newsblog/locale/am-newsblog.dtd" >
%newsblogDTD;
<!ENTITY % accountNoIdentDTD SYSTEM "chrome://messenger/locale/am-serverwithnoidentities.dtd" >
%accountNoIdentDTD;
]>
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
class="color-dialog"
@ -42,8 +47,16 @@
<script type="application/x-javascript" src="chrome://messenger-newsblog/content/am-newsblog.js"/>
<dialogheader title="&newsblogTitle.label;"/>
<vbox align="start">
<hbox align="center">
<label value="&accountName.label;" control="server.prettyName"
accesskey="&accountName.accesskey;"/>
<textbox wsm_persist="true" size="30" id="server.prettyName"
prefstring="mail.server.%serverkey%.name"/>
</hbox>
<separator/>
<hbox align="center">
<checkbox wsm_persist="true" id="server.doBiff" label="&biffStart.label;"
accesskey="&biffStart.accesskey;"
@ -60,6 +73,11 @@
label="&loginAtStartup.label;"
accesskey="&loginAtStartup.accesskey;"
prefattribute="value"
prefstring="mail.server.%serverkey%.login_at_startup"/>
</vbox>
prefstring="mail.server.%serverkey%.login_at_startup"/>
<hbox align="center">
<spacer flex="1"/>
<button label="&manageSubscriptions.label;" oncommand="manageSubscriptions();"
accesskey="&manageSubscriptions.accesskey;"/>
</hbox>
</page>

Просмотреть файл

@ -38,16 +38,14 @@ var kFeedUrlDelimiter = '|'; // the delimiter used to delimit feed urls in the m
var gRSSServer = null;
function doLoad() {
// Display the list of feed subscriptions.
var file = getSubscriptionsFile();
var ds = getSubscriptionsDS();
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;
var ds = getSubscriptionsDS(gRSSServer);
var tree = document.getElementById('subscriptions');
tree.database.AddDataSource(ds);
tree.builder.rebuild();
}
// opens the feed properties dialog
@ -178,7 +176,7 @@ function doEdit() {
// XXX There should be some way of correlating feed RDF resources
// with their corresponding Feed objects. Perhaps in the end much
// of this code could hang off methods of the Feed object.
var ds = getSubscriptionsDS();
var ds = getSubscriptionsDS(gRSSServer);
var tree = document.getElementById('subscriptions');
var item = tree.view.getItemAtIndex(tree.view.selection.currentIndex);
var resource = rdf.GetResource(item.id);
@ -232,10 +230,10 @@ function doRemove() {
var item = tree.view.getItemAtIndex(tree.view.selection.currentIndex);
var resource = rdf.GetResource(item.id);
var feed = new Feed(resource);
var ds = getSubscriptionsDS();
var ds = getSubscriptionsDS(gRSSServer);
// remove the feed from the subscriptions ds
var feeds = getSubscriptionsList();
var feeds = getSubscriptionsList(gRSSServer);
var index = feeds.IndexOf(resource);
if (index != -1)
feeds.RemoveElementAt(index, false);
@ -257,7 +255,7 @@ function doRemove() {
ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush(); // flush any changes
// Remove all assertions about items in the feed from the items database.
var itemds = getItemsDS();
var itemds = getItemsDS(gRSSServer);
feed.invalidateItems();
feed.removeInvalidItems();
itemds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush(); // flush any changes

Просмотреть файл

@ -60,8 +60,8 @@ var fileHandler =
.QueryInterface(Components.interfaces.nsIFileProtocolHandler);
function addFeed(url, title, quickMode, destFolder) {
var ds = getSubscriptionsDS();
var feeds = getSubscriptionsList();
var ds = getSubscriptionsDS(destFolder.server);
var feeds = getSubscriptionsList(destFolder.server);
// Give quickMode a default value of "true"; otherwise convert value
// to either "true" or "false" string.
@ -118,11 +118,11 @@ function getRDFTargetValue(ds, source, property) {
}
var gFzSubscriptionsDS; // cache
function getSubscriptionsDS() {
function getSubscriptionsDS(server) {
if (gFzSubscriptionsDS)
return gFzSubscriptionsDS;
var file = getSubscriptionsFile();
var file = getSubscriptionsFile(server);
var url = fileHandler.getURLSpecFromFile(file);
gFzSubscriptionsDS = rdf.GetDataSourceBlocking(url);
@ -130,16 +130,11 @@ function getSubscriptionsDS() {
if (!gFzSubscriptionsDS)
throw("can't get subscriptions data source");
// Note that it this point the datasource may not be loaded yet.
// You have to QueryInterface it to nsIRDFRemoteDataSource and check
// its "loaded" property to be sure. You can also attach an observer
// which will get notified when the load is complete.
return gFzSubscriptionsDS;
}
function getSubscriptionsList() {
var ds = getSubscriptionsDS();
function getSubscriptionsList(server) {
var ds = getSubscriptionsDS(server);
var list = ds.GetTarget(FZ_ROOT, FZ_FEEDS, true);
//list = feeds.QueryInterface(Components.interfaces.nsIRDFContainer);
list = list.QueryInterface(Components.interfaces.nsIRDFResource);
@ -147,24 +142,9 @@ function getSubscriptionsList() {
return list;
}
function getSubscriptionsFile() {
// Get the app directory service so we can look up the user's profile dir.
var appDirectoryService =
Components
.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
if ( !appDirectoryService )
throw("couldn't get the directory service");
// Get the user's profile directory.
var profileDir =
appDirectoryService.get("ProfD", Components.interfaces.nsIFile);
if ( !profileDir )
throw ("couldn't get the user's profile directory");
// Get the user's subscriptions file.
var file = profileDir.clone();
file.append("feeds.rdf");
function getSubscriptionsFile(server) {
server.QueryInterface(Components.interfaces.nsIRssIncomingServer);
var file = server.subscriptionsDataSourcePath;
// If the file doesn't exist, create it.
if (!file.exists())
@ -192,11 +172,11 @@ function createSubscriptionsFile(file) {
}
var gFzItemsDS; // cache
function getItemsDS() {
function getItemsDS(server) {
if (gFzItemsDS)
return gFzItemsDS;
var file = getItemsFile();
var file = getItemsFile(server);
var url = fileHandler.getURLSpecFromFile(file);
gFzItemsDS = rdf.GetDataSourceBlocking(url);
@ -211,24 +191,9 @@ function getItemsDS() {
return gFzItemsDS;
}
function getItemsFile() {
// Get the app directory service so we can look up the user's profile dir.
var appDirectoryService =
Components
.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
if ( !appDirectoryService )
throw("couldn't get the directory service");
// Get the user's profile directory.
var profileDir =
appDirectoryService.get("ProfD", Components.interfaces.nsIFile);
if ( !profileDir )
throw ("couldn't get the user's profile directory");
// Get the user's subscriptions file.
var file = profileDir.clone();
file.append("feeditems.rdf");
function getItemsFile(server) {
server.QueryInterface(Components.interfaces.nsIRssIncomingServer);
var file = server.subscriptionsDataSourcePath;
// If the file doesn't exist, create it.
if (!file.exists()) {

Просмотреть файл

@ -1,4 +1,4 @@
<!ENTITY newsblogTitle.label "News &amp; Blog Settings">
<!ENTITY newsblogTitle.label "RSS Account Settings">
<!ENTITY biffStart.label "Check for new articles every ">
<!ENTITY biffStart.accesskey "k">
@ -6,3 +6,6 @@
<!ENTITY loginAtStartup.label "Check for new articles at startup">
<!ENTITY loginAtStartup.accesskey "C">
<!ENTITY manageSubscriptions.label "Manage Subscriptions...">
<!ENTITY manageSubscriptions.accesskey "M">