[tor-commits] [torbirdy/master] Add overlay to disable automatic checking and fetching of RSS feeds (#19031)

sukhbir at torproject.org sukhbir at torproject.org
Thu May 12 01:34:45 UTC 2016


commit 0968621f307da8a9a0fcf6de9b30fb757169ccfe
Author: Sukhbir Singh <sukhbir at torproject.org>
Date:   Wed May 11 21:32:14 2016 -0400

    Add overlay to disable automatic checking and fetching of RSS feeds (#19031)
    
    To disable checking of new articles on startup and after a fixed interval (100
    minutes as defined in FeedUtils.jsm), add an overlay which disables both these
    settings after a new RSS account is created. This is similar to what we are
    doing with the manual email configuration wizard.
---
 chrome.manifest               |  1 +
 chrome/content/feedwizard.js  | 43 +++++++++++++++++++++++++++++++++++++++++++
 chrome/content/feedwizard.xul | 10 ++++++++++
 3 files changed, 54 insertions(+)

diff --git a/chrome.manifest b/chrome.manifest
index 78f1183..431b4c9 100644
--- a/chrome.manifest
+++ b/chrome.manifest
@@ -3,6 +3,7 @@ content castironthunderbirdclub chrome/content/
 overlay chrome://messenger/content/messenger.xul chrome://castironthunderbirdclub/content/overlay.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6}
 overlay chrome://messenger/content/messengercompose/messengercompose.xul chrome://castironthunderbirdclub/content/composeoverlay.xul
 overlay chrome://messenger/content/accountcreation/emailWizard.xul chrome://castironthunderbirdclub/content/emailwizard.xul
+overlay chrome://messenger-newsblog/content/feedAccountWizard.xul chrome://castironthunderbirdclub/content/feedwizard.xul
 
 component {ebd85413-18c8-4265-a708-a8890ec8d1ed} components/torbirdy.js
 contract @torproject.org/torbirdy;1 {ebd85413-18c8-4265-a708-a8890ec8d1ed}
diff --git a/chrome/content/feedwizard.js b/chrome/content/feedwizard.js
new file mode 100644
index 0000000..07b01bc
--- /dev/null
+++ b/chrome/content/feedwizard.js
@@ -0,0 +1,43 @@
+Components.utils.import("resource://gre/modules/Preferences.jsm");
+
+if (!org) var org = {};
+if (!org.torbirdy) org.torbirdy = {};
+
+if (!org.torbirdy.feedwizard) org.torbirdy.feedwizard = new function() {
+  var pub = {};
+
+  pub.fixFeedAccount = function(account) {
+    let accountKey = account.incomingServer.key;
+
+    let pref_spec = [
+      ['mail.server.%serverkey%.check_new_mail', false],
+      ['mail.server.%serverkey%.login_at_startup', false]
+    ];
+
+    for each (var [pref_template, value] in pref_spec) {
+        let pref = pref_template.replace("%serverkey%", accountKey);
+        Preferences.set(pref, value);
+    }
+  };
+
+  // From comm-release/mailnews/extensions/newsblog/content/feedAccountWizard.js : onFinish().
+  // We need to disable automatic checking of articles on startup and every X
+  // (100 is the default) minutes. Since these values are in FeedUtils.jsm, we
+  // use this overlay, create the account, and then apply our settings.
+  FeedAccountWizard.onFinish = function() {
+    let account = FeedUtils.createRssAccount(this.accountName);
+    if ("gFolderTreeView" in window.opener.top)
+      // Opened from 3pane File->New or Appmenu New Message, or
+      // Account Central link.
+      window.opener.top.gFolderTreeView.selectFolder(account.incomingServer.rootMsgFolder);
+    else if ("selectServer" in window.opener)
+      // Opened from Account Settings.
+      window.opener.selectServer(account.incomingServer);
+
+    // Now apply the settings.
+    pub.fixFeedAccount(account);
+    window.close();
+  };
+
+  return pub;
+};
diff --git a/chrome/content/feedwizard.xul b/chrome/content/feedwizard.xul
new file mode 100644
index 0000000..2f3c935
--- /dev/null
+++ b/chrome/content/feedwizard.xul
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+
+<?xml-stylesheet href="chrome://messenger/skin/accountWizard.css" type="text/css"?>
+
+<wizard id="castironthunderbirdclub-feedwizard-overlay"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+  <script type="application/javascript" src="chrome://castironthunderbirdclub/content/feedwizard.js" />
+
+</wizard>



More information about the tor-commits mailing list