!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Alec Flett <alecf@netscape.com>
24 * David Bienvenu <bienvenu@nventure.com>
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
37 *
38 * ***** END LICENSE BLOCK ***** */
39
40 // pull stuff out of window.arguments
41 var gServerSettings = window.arguments[0];
42
43 var serverList;
44
45 var gAccountManager;
46 var gFirstDeferredAccount;
47 // initialize the controls with the "gServerSettings" argument
48
49 var gControls;
getControls
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
50 function getControls()
51 {
52 if (!gControls)
53 gControls = document.getElementsByAttribute("amsa_persist", "true");
54 return gControls;
55 }
56
getLocalFoldersAccount
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
57 function getLocalFoldersAccount()
58 {
59 var localFoldersServer = gAccountManager.localFoldersServer;
60 return gAccountManager.FindAccountForServer(localFoldersServer);
61 }
62
onLoad
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
63 function onLoad()
64 {
65 if (gServerSettings.serverType == "imap")
66 {
67 document.getElementById("pop3Panel").hidden = true;
68 }
69 else if (gServerSettings.serverType == "pop3")
70 {
71 var radioGroup = document.getElementById("folderStorage");
72 document.getElementById("imapPanel").hidden = true;
73 gAccountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager);
74 gFirstDeferredAccount = gServerSettings.deferredToAccount;
75 var localFoldersAccount = getLocalFoldersAccount();
76 if (gFirstDeferredAccount.length)
77 {
78 var account = gAccountManager.getAccount(gFirstDeferredAccount);
79 if (account)
80 {
81 var thisServer = account.incomingServer;
82 SetFolderPicker(thisServer.serverURI, 'deferedServerFolderPicker');
83 }
84 if (gFirstDeferredAccount == localFoldersAccount.key)
85 {
86 radioGroup.selectedItem = document.getElementById("globalInbox");
87 SetFolderPicker(localFoldersAccount.incomingServer.serverURI, 'deferedServerFolderPicker');
88 updateInboxAccount(false, true);
89 }
90 else
91 {
92 radioGroup.selectedItem = document.getElementById("deferToServer");
93 SetFolderPicker(account.incomingServer.serverURI, 'deferedServerFolderPicker');
94 updateInboxAccount(true, true);
95 }
96 }
97 else
98 {
99 radioGroup.selectedItem = document.getElementById("accountDirectory");
100
101 // we should find out if there's another pop3/movemail server to defer to,
102 // perhaps by checking the number of elements in the picker. For now,
103 // just use the local folders account
104 SetFolderPicker(localFoldersAccount.incomingServer.serverURI, 'deferedServerFolderPicker');
105
106 updateInboxAccount(false, false);
107
108 }
109 }
110
111 var controls = getControls();
112
113 for (var i = 0; i < controls.length; i++)
114 {
115 var slot = controls[i].id;
116 if (slot in gServerSettings)
117 {
118 if (controls[i].localName == "checkbox")
119 controls[i].checked = gServerSettings[slot];
120 else
121 controls[i].value = gServerSettings[slot];
122 }
123 }
124 }
125
onOk
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
126 function onOk()
127 {
128 // Handle account deferral settings for POP3 accounts.
129 if (gServerSettings.serverType == "pop3")
130 {
131 var radioGroup = document.getElementById("folderStorage");
132 var gPrefsBundle = document.getElementById("bundle_prefs");
133
134 // if this account wasn't deferred, and is now...
135 if (radioGroup.value != 1 && !gFirstDeferredAccount.length)
136 {
137 var confirmDeferAccount =
138 gPrefsBundle.getString("confirmDeferAccount");
139
140 var confirmTitle = gPrefsBundle.getString("confirmDeferAccountTitle");
141
142 var promptService =
143 Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
144 getService(Components.interfaces.nsIPromptService);
145 if (!promptService ||
146 !promptService.confirm(window, confirmTitle, confirmDeferAccount))
147 return false;
148 }
149 switch (radioGroup.value)
150 {
151 case "0":
152 gServerSettings['deferredToAccount'] = getLocalFoldersAccount().key;
153 break;
154 case "1":
155 gServerSettings['deferredToAccount'] = "";
156 break;
157 case "2":
158 picker = document.getElementById("deferedServerFolderPicker");
159 var server = GetMsgFolderFromUri(picker.getAttribute("uri"), false).server;
160 var account = gAccountManager.FindAccountForServer(server);
161 gServerSettings['deferredToAccount'] = account.key;
162 break;
163 }
164 }
165
166 // Save the controls back to the "gServerSettings" array.
167 var controls = getControls();
168 for (var i = 0; i < controls.length; i++)
169 {
170 var slot = controls[i].id;
171 if (slot in gServerSettings)
172 {
173 if (controls[i].localName == "checkbox")
174 gServerSettings[slot] = controls[i].checked;
175 else
176 gServerSettings[slot] = controls[i].value;
177 }
178 }
179
180 return true;
181 }
182
183
184 // Set radio element choices and picker states
updateInboxAccount
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
185 function updateInboxAccount(enablePicker, enableDeferGetNewMail, event)
186 {
187 var picker = document.getElementById('deferedServerFolderPicker');
188 picker.disabled = !enablePicker;
189
190 var deferCheckbox = document.getElementById('deferGetNewMail');
191 deferCheckbox.disabled = !enableDeferGetNewMail
192 }