?? feed.js
字號:
url = url.QueryInterface(Components.interfaces.nsIRDFLiteral).Value; else url = this.resource.Value; return url; }, get title() { var ds = getSubscriptionsDS(this.server); var title = ds.GetTarget(this.resource, DC_TITLE, true); if (title) title = title.QueryInterface(Components.interfaces.nsIRDFLiteral).Value; return title; }, set title (aNewTitle) { var ds = getSubscriptionsDS(this.server); aNewTitle = rdf.GetLiteral(aNewTitle); var old_title = ds.GetTarget(this.resource, DC_TITLE, true); if (old_title) ds.Change(this.resource, DC_TITLE, old_title, aNewTitle); else ds.Assert(this.resource, DC_TITLE, aNewTitle, true); }, get lastModified() { var ds = getSubscriptionsDS(this.server); var lastModified = ds.GetTarget(this.resource, DC_LASTMODIFIED, true); if (lastModified) lastModified = lastModified.QueryInterface(Components.interfaces.nsIRDFLiteral).Value; return lastModified; }, set lastModified(aLastModified) { var ds = getSubscriptionsDS(this.server); aLastModified = rdf.GetLiteral(aLastModified); var old_lastmodified = ds.GetTarget(this.resource, DC_LASTMODIFIED, true); if (old_lastmodified) ds.Change(this.resource, DC_LASTMODIFIED, old_lastmodified, aLastModified); else ds.Assert(this.resource, DC_LASTMODIFIED, aLastModified, true); // do we need to flush every time this property changes? ds = ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource); ds.Flush(); }, get quickMode () { var ds = getSubscriptionsDS(this.server); var quickMode = ds.GetTarget(this.resource, FZ_QUICKMODE, true); if (quickMode) { quickMode = quickMode.QueryInterface(Components.interfaces.nsIRDFLiteral); quickMode = quickMode.Value; quickMode = eval(quickMode); } return quickMode; }, set quickMode (aNewQuickMode) { var ds = getSubscriptionsDS(this.server); aNewQuickMode = rdf.GetLiteral(aNewQuickMode); var old_quickMode = ds.GetTarget(this.resource, FZ_QUICKMODE, true); if (old_quickMode) ds.Change(this.resource, FZ_QUICKMODE, old_quickMode, aNewQuickMode); else ds.Assert(this.resource, FZ_QUICKMODE, aNewQuickMode, true); }, get link () { var ds = getSubscriptionsDS(this.server); var link = ds.GetTarget(this.resource, RSS_LINK, true); if(link) link = link.QueryInterface(Components.interfaces.nsIRDFLiteral).Value; return link; }, set link (aNewLink) { var ds = getSubscriptionsDS(this.server); aNewLink = rdf.GetLiteral(aNewLink); var old_link = ds.GetTarget(this.resource, RSS_LINK, true); if (old_link) ds.Change(this.resource, RSS_LINK, old_link, aNewLink); else ds.Assert(this.resource, RSS_LINK, aNewLink, true); }, parse: function() { // Figures out what description language (RSS, Atom) and version this feed // is using and calls a language/version-specific feed parser. debug("parsing feed " + this.url); if (!this.request.responseText) return this.onParseError(this); // create a feed parser which will parse the feed for us var parser = new FeedParser(); this.itemsToStore = parser.parseFeed(this, this.request.responseText, this.request.responseXML, this.request.channel.URI); // storeNextItem will iterate through the parsed items, storing each one. this.itemsToStoreIndex = 0; this.storeNextItem(); }, invalidateItems: function () { var ds = getItemsDS(this.server); debug("invalidating items for " + this.url); var items = ds.GetSources(FZ_FEED, this.resource, true); var item; while (items.hasMoreElements()) { item = items.getNext(); item = item.QueryInterface(Components.interfaces.nsIRDFResource); debug("invalidating " + item.Value); var valid = ds.GetTarget(item, FZ_VALID, true); if (valid) ds.Unassert(item, FZ_VALID, valid, true); } }, removeInvalidItems: function() { var ds = getItemsDS(this.server); debug("removing invalid items for " + this.url); var items = ds.GetSources(FZ_FEED, this.resource, true); var item; while (items.hasMoreElements()) { item = items.getNext(); item = item.QueryInterface(Components.interfaces.nsIRDFResource); if (ds.HasAssertion(item, FZ_VALID, RDF_LITERAL_TRUE, true)) continue; debug("removing " + item.Value); ds.Unassert(item, FZ_FEED, this.resource, true); if (ds.hasArcOut(item, FZ_FEED)) debug(item.Value + " is from more than one feed; only the reference to this feed removed"); else removeAssertions(ds, item); } }, createFolder: function() { if (!this.folder) this.server.rootMsgFolder.createSubfolder(this.name, null /* supposed to be a msg window */); }, // gets the next item from gItemsToStore and forces that item to be stored // to the folder. If more items are left to be stored, fires a timer for the next one. // otherwise it triggers a download done notification to the UI storeNextItem: function() { if (!this.itemsToStore || !this.itemsToStore.length) { this.createFolder(); return this.cleanupParsingState(this); } var item = this.itemsToStore[this.itemsToStoreIndex]; item.store(); item.markValid(); // if the listener is tracking progress for storing each item, report it here... if (item.feed.downloadCallback && item.feed.downloadCallback.onFeedItemStored) item.feed.downloadCallback.onFeedItemStored(item.feed, this.itemsToStoreIndex, this.itemsToStore.length); this.itemsToStoreIndex++ // eventually we'll report individual progress here.... if (this.itemsToStoreIndex < this.itemsToStore.length) { if (!this.storeItemsTimer) this.storeItemsTimer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer); this.storeItemsTimer.initWithCallback(this, 50, Components.interfaces.nsITimer.TYPE_ONE_SHOT); } else { // we have just finished downloading one or more feed items into the destination folder, // if the folder is still listed as having new messages in it, then we should set the biff state on the folder // so the right RDF UI changes happen in the folder pane to indicate new mail. if (item.feed.folder.hasNewMessages) item.feed.folder.biffState = Components.interfaces.nsIMsgFolder.nsMsgBiffState_NewMail; this.cleanupParsingState(item.feed); } }, cleanupParsingState: function(aFeed) { // now that we are done parsing the feed, remove the feed from our feed cache FeedCache.removeFeed(aFeed.url); aFeed.removeInvalidItems(); // let's be sure to flush any feed item changes back to disk var ds = getItemsDS(aFeed.server); ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush(); // flush any changes if (aFeed.downloadCallback) aFeed.downloadCallback.downloaded(aFeed, kNewsBlogSuccess); this.request = null; // force the xml http request to go away. This helps reduce some nasty assertions on shut down. this.itemsToStore = ""; this.itemsToStoreIndex = 0; this.storeItemsTimer = null; }, notify: function(aTimer) { this.storeNextItem(); }, QueryInterface: function(aIID) { if (aIID.equals(Components.interfaces.nsITimerCallback) || aIID.equals(Components.interfaces.nsISupports)) return this; Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE; return null; }};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -