summaryrefslogtreecommitdiffstats
path: root/config/chroot_local-patches/torbirdy-0002-secure-autoconfig-POP-defaults.diff
blob: 363979fedcb6ffc2d4456680a662526d57d199bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
--- /usr/share/xul-ext/torbirdy/chrome/content/emailwizard.js.orig
+++ /usr/share/xul-ext/torbirdy/chrome/content/emailwizard.js
@@ -108,6 +108,39 @@ if(!org.torbirdy.emailwizard) org.torbirdy.emailwizard = new function() {
       window.close();
     }
     else {
+      var prefer_pop = Preferences.get("extensions.torbirdy.defaultprotocol") != 1;
+      // Both of these monkeypatches hook in only to change the
+      // selection default (POP vs IMAP according to our pref) at
+      // suitable times, i.e. when the page has been pre-filled and is
+      // finally presented to user action.
+      var result_imappop_hacks_run_once = false;
+      var old_displayConfigResult = gEmailConfigWizard.displayConfigResult;
+      gEmailConfigWizard.displayConfigResult = function(config) {
+        old_displayConfigResult.call(this, config);
+        var radiogroup = document.getElementById("result_imappop");
+        if (radiogroup.hidden) return;
+        // We can only run the monkeypatch code below once -- this
+        // method is called every time we change selection, preventing
+        // us from changing the selection away from POP.
+        if (result_imappop_hacks_run_once) return;
+        result_imappop_hacks_run_once = true;
+        var imap_element = document.getElementById("result_select_imap");
+        var pop_element = document.getElementById("result_select_pop3");
+        if (prefer_pop && imap_element.selected && pop_element) {
+          radiogroup.selectedItem = pop_element;
+          gEmailConfigWizard.onResultIMAPOrPOP3();
+        }
+      }
+      var old_fillManualEditFields = gEmailConfigWizard._fillManualEditFields;
+      gEmailConfigWizard._fillManualEditFields = function(config) {
+        old_fillManualEditFields.call(this, config);
+        if (prefer_pop) {
+          // In this itemlist, POP is located at index 1.
+          document.getElementById("incoming_protocol").selectedIndex = 1;
+          gEmailConfigWizard.onChangedProtocolIncoming();
+        }
+      }
+
       // From comm-release/mailnews/base/prefs/content/accountcreation/emailWizard.js : finish().
       // We need somewhere to hook in, so we can access the new
       // account object created through the autoconfig wizard, and