!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 /* -*- Mode: C++; 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 Communicator client code, released
16 * March 31, 1998.
17 *
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998-1999
21 * the Initial Developer. All Rights Reserved.
22 *
23 * Contributor(s):
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39 var gPrefsBundle;
40
donePageInit
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
41 function donePageInit() {
42 var pageData = parent.GetPageData();
43 var currentAccountData = gCurrentAccountData;
44
45 if ("testingIspServices" in this) {
46 if (testingIspServices()) {
47 if ("setOtherISPServices" in this) {
48 setOtherISPServices();
49 }
50
51 if (currentAccountData && currentAccountData.useOverlayPanels && currentAccountData.createNewAccount) {
52 var backButton = document.documentElement.getButton("back");
53 backButton.setAttribute("disabled", true);
54
55 var cancelButton = document.documentElement.getButton("cancel");
56 cancelButton.setAttribute("disabled", true);
57
58 setPageData(pageData, "identity", "email", gEmailAddress);
59 setPageData(pageData, "identity", "fullName", gUserFullName);
60 setPageData(pageData, "login", "username", gScreenName);
61 }
62 }
63 }
64
65 gPrefsBundle = document.getElementById("bundle_prefs");
66 var showMailServerDetails = true;
67
68 if (currentAccountData) {
69 // find out if we need to hide server details
70 showMailServerDetails = currentAccountData.showServerDetailsOnWizardSummary;
71 // Change the username field description to email field label in aw-identity
72 setUserNameDescField(currentAccountData.emailIDFieldTitle);
73 }
74
75 // Find out if we need to hide details for incoming servers
76 var hideIncoming = (gCurrentAccountData && gCurrentAccountData.wizardHideIncoming);
77
78 var email = "";
79 if (pageData.identity && pageData.identity.email) {
80 // fixup the email
81 email = pageData.identity.email.value;
82 if (email.split('@').length < 2 &&
83 currentAccountData &&
84 currentAccountData.domain)
85 email += "@" + currentAccountData.domain;
86 }
87 setDivTextFromForm("identity.email", email);
88
89 var userName="";
90 if (pageData.login && pageData.login.username)
91 userName = pageData.login.username.value;
92 if (!userName && email)
93 userName = getUsernameFromEmail(email, currentAccountData &&
94 currentAccountData.incomingServerUserNameRequiresDomain);
95
96 // Hide the "username" field if we don't want to show information
97 // on the incoming server.
98 setDivTextFromForm("server.username", hideIncoming ? null : userName);
99
100 var smtpUserName="";
101 if (pageData.login && pageData.login.smtpusername)
102 smtpUserName = pageData.login.smtpusername.value;
103 if (!smtpUserName && email)
104 smtpUserName = getUsernameFromEmail(email, currentAccountData &&
105 currentAccountData.smtpUserNameRequiresDomain);
106 setDivTextFromForm("smtpServer.username", smtpUserName);
107
108 if (pageData.accname && pageData.accname.prettyName) {
109 // If currentAccountData has a pretty name (e.g. news link or from
110 // isp data) only set the user name with the pretty name if the
111 // pretty name originally came from ispdata
112 if ((currentAccountData &&
113 currentAccountData.incomingServer.prettyName) &&
114 (pageData.ispdata &&
115 pageData.ispdata.supplied &&
116 pageData.ispdata.supplied.value))
117 {
118 // Get the polished account name - if the user has modified the
119 // account name then use that, otherwise use the userName.
120 pageData.accname.prettyName.value =
121 gPrefsBundle.getFormattedString("accountName",
122 [currentAccountData.incomingServer.prettyName,
123 (pageData.accname.userset && pageData.accname.userset.value) ? pageData.accname.prettyName.value : userName]);
124 }
125 // else just use the default supplied name
126
127 setDivTextFromForm("account.name", pageData.accname.prettyName.value);
128 } else {
129 setDivTextFromForm("account.name", "");
130 }
131
132 // Show mail servers (incoming&outgoing) details
133 // based on current account data. ISP can set
134 // rdf value of literal showServerDetailsOnWizardSummary
135 // to false to hide server details
136 if (showMailServerDetails && !serverIsNntp(pageData)) {
137 var incomingServerName="";
138 if (pageData.server && pageData.server.hostname) {
139 incomingServerName = pageData.server.hostname.value;
140 if (!incomingServerName &&
141 currentAccountData &&
142 currentAccountData.incomingServer.hostname)
143 incomingServerName = currentAccountData.incomingServer.hostName;
144 }
145 // Hide the incoming server name field if the user specified
146 // wizardHideIncoming in the ISP defaults file
147 setDivTextFromForm("server.name", hideIncoming ? null : incomingServerName);
148
149 var incomingServerType="";
150 if (pageData.server && pageData.server.servertype) {
151 incomingServerType = pageData.server.servertype.value;
152 if (!incomingServerType &&
153 currentAccountData &&
154 currentAccountData.incomingServer.type)
155 incomingServerType = currentAccountData.incomingServer.type;
156 }
157 setDivTextFromForm("server.type", incomingServerType.toUpperCase());
158
159 var smtpServerName="";
160 if (pageData.server && pageData.server.smtphostname) {
161 var smtpServer = parent.smtpService.defaultServer;
162 smtpServerName = pageData.server.smtphostname.value;
163 if (!smtpServerName && smtpServer && smtpServer.hostname)
164 smtpServerName = smtpServer.hostname;
165 }
166 setDivTextFromForm("smtpServer.name", smtpServerName);
167 }
168 else {
169 setDivTextFromForm("server.name", null);
170 setDivTextFromForm("server.type", null);
171 setDivTextFromForm("smtpServer.name", null);
172 }
173
174 if (serverIsNntp(pageData)) {
175 var newsServerName="";
176 if (pageData.newsserver && pageData.newsserver.hostname)
177 newsServerName = pageData.newsserver.hostname.value;
178 if (newsServerName) {
179 // No need to show username for news account
180 setDivTextFromForm("server.username", null);
181 }
182 setDivTextFromForm("newsServer.name", newsServerName);
183 }
184 else {
185 setDivTextFromForm("newsServer.name", null);
186 }
187
188 var isPop = false;
189 if (pageData.server && pageData.server.servertype) {
190 isPop = (pageData.server.servertype.value == "pop3");
191 }
192
193 hideShowDownloadMsgsUI(isPop);
194 }
195
hideShowDownloadMsgsUI
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
196 function hideShowDownloadMsgsUI(isPop)
197 {
198 // only show the "download messages now" UI
199 // if this is a pop account, we are online, and this was opened
200 // from the 3 pane
201 var downloadMsgs = document.getElementById("downloadMsgs");
202 if (isPop) {
203 var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
204 if (!ioService.offline) {
205 if (window.opener.location.href == "chrome://messenger/content/messenger.xul") {
206 downloadMsgs.hidden = false;
207 return;
208 }
209 }
210 }
211
212 // else hide it
213 downloadMsgs.hidden = true;
214 }
215
setDivTextFromForm
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
216 function setDivTextFromForm(divid, value) {
217
218 // collapse the row if the div has no value
219 var div = document.getElementById(divid);
220 if (!value) {
221 div.setAttribute("collapsed","true");
222 return;
223 }
224 else {
225 div.removeAttribute("collapsed");
226 }
227
228 // otherwise fill in the .text element
229 div = document.getElementById(divid+".text");
230 if (!div) return;
231
232 // set the value
233 div.setAttribute("value", value);
234 }
235
setUserNameDescField
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
236 function setUserNameDescField(name)
237 {
238 if (name) {
239 var userNameField = document.getElementById("server.username.label");
240 userNameField.setAttribute("value", name);
241 }
242 }
243
setupAnother
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
244 function setupAnother(event)
245 {
246 window.alert("Unimplemented, see bug #19982");
247 }