⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newsblog.js

📁 现在很火的邮件客户端软件thunderbird的源码
💻 JS
📖 第 1 页 / 共 2 页
字号:
  },  helpInfo : ""};var nsNewsBlogFeedDownloaderModule ={  getClassObject: function(aCompMgr, aCID, aIID)  {    if (!aIID.equals(Components.interfaces.nsIFactory))      throw Components.results.NS_ERROR_NOT_IMPLEMENTED;    for (var key in this.mObjects)       if (aCID.equals(this.mObjects[key].CID))        return this.mObjects[key].factory;    throw Components.results.NS_ERROR_NO_INTERFACE;  },  mObjects:   {    feedDownloader:     {       CID: Components.ID("{5c124537-adca-4456-b2b5-641ab687d1f6}"),      contractID: "@mozilla.org/newsblog-feed-downloader;1",      className: "News+Blog Feed Downloader",      factory:       {        createInstance: function (aOuter, aIID)         {          if (aOuter != null)            throw Components.results.NS_ERROR_NO_AGGREGATION;          if (!aIID.equals(Components.interfaces.nsINewsBlogFeedDownloader) &&              !aIID.equals(Components.interfaces.nsISupports))            throw Components.results.NS_ERROR_INVALID_ARG;          // return the singleton          return nsNewsBlogFeedDownloader.QueryInterface(aIID);        }             } // factory    }, // feed downloader        nsNewsBlogAcctMgrExtension:     {       CID: Components.ID("{E109C05F-D304-4ca5-8C44-6DE1BFAF1F74}"),      contractID: "@mozilla.org/accountmanager/extension;1?name=newsblog",      className: "News+Blog Account Manager Extension",      factory:       {        createInstance: function (aOuter, aIID)         {          if (aOuter != null)            throw Components.results.NS_ERROR_NO_AGGREGATION;          if (!aIID.equals(Components.interfaces.nsIMsgAccountManagerExtension) &&              !aIID.equals(Components.interfaces.nsISupports))            throw Components.results.NS_ERROR_INVALID_ARG;          // return the singleton          return nsNewsBlogAcctMgrExtension.QueryInterface(aIID);        }             } // factory    }, // account manager extension    nsFeedCommandLineHandler:     {      CID: Components.ID("{0E377BF7-E4FE-4c94-804C-0C33D49F883E}"),      contractID: "@mozilla.org/newsblog-feed-downloader/clh;1",      className: "Feed CommandLine Handler",      factory:       {        createInstance: function (aOuter, aIID)         {          if (aOuter != null)            throw Components.results.NS_ERROR_NO_AGGREGATION;          if (!aIID.equals(Components.interfaces.nsICommandLineHandler) &&              !aIID.equals(Components.interfaces.nsISupports))            throw Components.results.NS_ERROR_INVALID_ARG;          // return the singleton          return nsFeedCommandLineHandler.QueryInterface(aIID);        }             } // factory    }  },  registerSelf: function(aCompMgr, aFileSpec, aLocation, aType)  {            aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);    for (var key in this.mObjects)     {      var obj = this.mObjects[key];      aCompMgr.registerFactoryLocation(obj.CID, obj.className, obj.contractID, aFileSpec, aLocation, aType);    }    // we also need to do special account extension registration    var catman = Components.classes["@mozilla.org/categorymanager;1"].getService(Components.interfaces.nsICategoryManager);    catman.addCategoryEntry("mailnews-accountmanager-extensions",                            "newsblog account manager extension",                            "@mozilla.org/accountmanager/extension;1?name=newsblog", true, true);    catman.addCategoryEntry("command-line-handler",                            "l-feed",                            "@mozilla.org/newsblog-feed-downloader/clh;1", true, true);  },  unregisterSelf: function(aCompMgr, aFileSpec, aLocation)  {    aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);    for (var key in this.mObjects)     {      var obj = this.mObjects[key];      aCompMgr.unregisterFactoryLocation(obj.CID, aFileSpec);    }    // unregister the account manager extension    catman = Components.classes["@mozilla.org/categorymanager;1"].getService(Components.interfaces.nsICategoryManager);    catman.deleteCategoryEntry("mailnews-accountmanager-extensions",                               "@mozilla.org/accountmanager/extension;1?name=newsblog", true);    catMan.addCategoryEntry("command-line-handler",                            "@mozilla.org/newsblog-feed-downloader/clh;1", true);  },  canUnload: function(aCompMgr)  {    return true;  }};function NSGetModule(aCompMgr, aFileSpec){  return nsNewsBlogFeedDownloaderModule;}function loadScripts(){  var scriptLoader =  Components.classes["@mozilla.org/moz/jssubscript-loader;1"]                     .getService(Components.interfaces.mozIJSSubScriptLoader);  if (scriptLoader)  {     scriptLoader.loadSubScript("chrome://messenger-newsblog/content/Feed.js");    scriptLoader.loadSubScript("chrome://messenger-newsblog/content/FeedItem.js");    scriptLoader.loadSubScript("chrome://messenger-newsblog/content/feed-parser.js");    scriptLoader.loadSubScript("chrome://messenger-newsblog/content/file-utils.js");    scriptLoader.loadSubScript("chrome://messenger-newsblog/content/utils.js");  }  gExternalScriptsLoaded = true;}// Progress glue code. Acts as a go between the RSS back end and the mail window front end// determined by the aMsgWindow parameter passed into nsINewsBlogFeedDownloader.// gNumPendingFeedDownloads: keeps track of the total number of feeds we have been asked to download//                           this number may not reflect the # of entries in our mFeeds array because not all//                           feeds may have reported in for the first time...var gNumPendingFeedDownloads = 0;var progressNotifier = {  mSubscribeMode: false,  mMsgWindow: null,   mStatusFeedback: null,  mFeeds: new Array,  init: function(aMsgWindow, aSubscribeMode)  {    if (!gNumPendingFeedDownloads) // if we aren't already in the middle of downloading feed items...    {      this.mStatusFeedback = aMsgWindow ? aMsgWindow.statusFeedback : null;      this.mSubscribeMode = aSubscribeMode;      this.mMsgWindow = aMsgWindow;      if (this.mStatusFeedback)      {        this.mStatusFeedback.startMeteors();        this.mStatusFeedback.showStatusString(aSubscribeMode ? GetNewsBlogStringBundle().GetStringFromName('subscribe-validating')                                             : GetNewsBlogStringBundle().GetStringFromName('newsblog-getNewMailCheck'));      }    }  },  downloaded: function(feed, aErrorCode)  {    if (this.mSubscribeMode && aErrorCode == kNewsBlogSuccess)    {      // if we get here...we should always have a folder by now...either      // in feed.folder or FeedItems created the folder for us....      updateFolderFeedUrl(feed.folder, feed.url, false);              addFeed(feed.url, feed.name, feed.folder); // add feed just adds the feed to the subscription UI and flushes the datasource            // Nice touch: select the folder that now contains the newly subscribed feed...this is particularly nice       // if we just finished subscribing to a feed URL that the operating system gave us.      this.mMsgWindow.SelectFolder(feed.folder.URI);    }     else if (feed.folder)      feed.folder.setMsgDatabase(null);    if (this.mStatusFeedback)    {      var newsBlogBundle = GetNewsBlogStringBundle();      if (aErrorCode == kNewsBlogNoNewItems)        this.mStatusFeedback.showStatusString(newsBlogBundle.GetStringFromName("newsblog-noNewArticlesForFeed"));      else if (aErrorCode == kNewsBlogInvalidFeed)        this.mStatusFeedback.showStatusString(newsBlogBundle.formatStringFromName("newsblog-invalidFeed",                                              [feed.url], 1));      else if (aErrorCode == kNewsBlogRequestFailure)        this.mStatusFeedback.showStatusString(newsBlogBundle.formatStringFromName("newsblog-networkError",                                              [feed.url], 1));                                                 this.mStatusFeedback.stopMeteors();    }    gNumPendingFeedDownloads--;    if (!gNumPendingFeedDownloads)    {      this.mFeeds = new Array;      this.mSubscribeMode = false;      // should we do this on a timer so the text sticks around for a little while?       // It doesnt look like we do it on a timer for newsgroups so we'll follow that model.      if (aErrorCode == kNewsBlogSuccess && this.mStatusFeedback) // don't clear the status text if we just dumped an error to the status bar!        this.mStatusFeedback.showStatusString("");    }  },  // this gets called after the RSS parser finishes storing a feed item to disk  // aCurrentFeedItems is an integer corresponding to how many feed items have been downloaded so far  // aMaxFeedItems is an integer corresponding to the total number of feed items to download  onFeedItemStored: function (feed, aCurrentFeedItems, aMaxFeedItems)  {     // we currently don't do anything here. Eventually we may add    // status text about the number of new feed articles received.    if (this.mSubscribeMode && this.mStatusFeedback) // if we are subscribing to a feed, show feed download progress    {      this.mStatusFeedback.showStatusString(GetNewsBlogStringBundle().formatStringFromName("subscribe-fetchingFeedItems", [aCurrentFeedItems, aMaxFeedItems], 2));      this.onProgress(feed, aCurrentFeedItems, aMaxFeedItems);    }  },  onProgress: function(feed, aProgress, aProgressMax)  {    if (feed.url in this.mFeeds) // have we already seen this feed?      this.mFeeds[feed.url].currentProgress = aProgress;    else      this.mFeeds[feed.url] = {currentProgress: aProgress, maxProgress: aProgressMax};        this.updateProgressBar();       },  updateProgressBar: function()  {    var currentProgress = 0;    var maxProgress = 0;    for (index in this.mFeeds)    {      currentProgress += this.mFeeds[index].currentProgress;      maxProgress += this.mFeeds[index].maxProgress;    }    // if we start seeing weird "jumping" behavior where the progress bar goes below a threshold then above it again,    // then we can factor a fudge factor here based on the number of feeds that have not reported yet and the avg    // progress we've already received for existing feeds. Fortunately the progressmeter is on a timer    // and only updates every so often. For the most part all of our request have initial progress    // before the UI actually picks up a progress value.     if (this.mStatusFeedback)    {      var progress = (currentProgress * 100) / maxProgress;      this.mStatusFeedback.showProgress(progress);    }  }}function GetNewsBlogStringBundle(name){  var strBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService();   strBundleService = strBundleService.QueryInterface(Components.interfaces.nsIStringBundleService);  var strBundle = strBundleService.createBundle("chrome://messenger-newsblog/locale/newsblog.properties");   return strBundle;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -