fix for 164678;169366;-should be able to set outgoing smtp server in smtp panel;not add empty smtp servers in advanced panels;r/sr=sspitzer

This commit is contained in:
varada%netscape.com 2002-09-30 01:50:39 +00:00
Родитель 57b7ad0ec2
Коммит eb5e68f11e
10 изменённых файлов: 135 добавлений и 25 удалений

Просмотреть файл

@ -40,7 +40,7 @@
* on values set in the previous step.
*/
var gSmtpHostNameIsIllegal = false;
var accountArray;
var gGenericAttributeTypes;
var accounttree;
@ -51,12 +51,14 @@ var currentPageId;
var pendingServerId;
var pendingPageId;
var gPrefsBundle;
var gBrandBundle;
// services used
var RDF;
var accountManager;
var smtpService;
var nsPrefBranch;
var gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
// widgets
var duplicateButton;
@ -94,6 +96,7 @@ function updateElementWithKeys(account, element, type) {
// perform initialization here
function onLoad() {
gPrefsBundle = document.getElementById("bundle_prefs");
gBrandBundle = document.getElementById("bundle_brand");
var selectedServer;
var selectPage = null;
@ -239,6 +242,11 @@ function onAccept() {
if (!checkUserServerChanges(true))
return false;
if (gSmtpHostNameIsIllegal) {
gSmtpHostNameIsIllegal = false;
return false;
}
onSave();
// hack hack - save the prefs file NOW in case we crash
try {
@ -255,6 +263,24 @@ function onAccept() {
// if so check if the new names already exists for an account.
//
function checkUserServerChanges(showAlert) {
if (smtpService.defaultServer) {
try {
var smtpHostName = top.frames["contentFrame"].document.getElementById("smtp.hostname");
if (hostnameIsIllegal(smtpHostName.value)) {
var alertTitle = gBrandBundle.getString("brandShortName");
var alertMsg = gPrefsBundle.getString("enterValidHostname");
if (gPromptService)
gPromptService.alert(window, alertTitle, alertMsg);
else
window.alert(alertMsg);
gSmtpHostNameIsIllegal = true;
}
}
catch (ex) {}
}
var accountValues = getValueArrayFor(currentServerId);
if (!accountValues)
return true;
@ -679,6 +705,11 @@ function showPage(serverId, pageId) {
// check if user/host names have been changed
checkUserServerChanges(false);
if (gSmtpHostNameIsIllegal) {
gSmtpHostNameIsIllegal = false;
return false;
}
// save the previous page
savePage(currentServerId);

Просмотреть файл

@ -12,8 +12,9 @@
onload="onLoad(event);"
ondialogaccept="return onAccept();"
ondialoghelp="return doHelpButton();">
<stringbundle id="bundle_brand" src="chrome://global/locale/brand.properties"/>
<stringbundle id="bundle_prefs" src="chrome://messenger/locale/prefs.properties"/>
<script type="application/x-javascript" src="chrome://messenger/content/amUtils.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/accountUtils.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/am-prefs.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/AccountManager.js"/>

Просмотреть файл

@ -33,6 +33,7 @@ Rights Reserved.
<stringbundle id="bundle_prefs" src="chrome://messenger/locale/prefs.properties"/>
<stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
<script type="application/x-javascript" src="chrome://messenger/content/amUtils.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/accountUtils.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/AccountWizard.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/ispUtils.js"/>

Просмотреть файл

@ -62,6 +62,21 @@ function initializeDialog(server)
function onAccept()
{
if (hostnameIsIllegal(gSmtpHostname.value)) {
var prefsBundle = document.getElementById("bundle_prefs");
var brandBundle = document.getElementById("bundle_brand");
var alertTitle = brandBundle.getString("brandShortName");
var alertMsg = prefsBundle.getString("enterValidHostname");
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
if (promptService)
promptService.alert(window, alertTitle, alertMsg);
else
window.alert(alertMsg);
window.arguments[0].result = false;
return false;
}
// if we didn't have an SMTP server to initialize with,
// we must be creating one.
try {

Просмотреть файл

@ -37,7 +37,9 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="onLoad();"
ondialogaccept="return onAccept();">
<stringbundle id="bundle_prefs" src="chrome://messenger/locale/prefs.properties"/>
<stringbundle id="bundle_brand" src="chrome://global/locale/brand.properties"/>
<script type="application/x-javascript" src="amUtils.js"/>
<script type="application/x-javascript" src="SmtpServerEdit.js"/>
<vbox id="smtpServerEditor"/>
</dialog>

Просмотреть файл

@ -53,12 +53,14 @@ function onLoad()
// Get the default smtp server preference to check if we need to lock the
// advance button on the panel.
var defaultSmtpServerKey = gPrefBranch.getCharPref("mail.smtp.defaultserver");
var prefString = "mail.smtpserver."+ defaultSmtpServerKey + ".advanced.disable";
if (defaultSmtpServer) {
var defaultSmtpServerKey = gPrefBranch.getCharPref("mail.smtp.defaultserver");
var prefString = "mail.smtpserver."+ defaultSmtpServerKey + ".advanced.disable";
var advButton = document.getElementById("smtp.advancedbutton");
if (gPrefBranch.prefIsLocked(prefString)) {
advButton.setAttribute("disabled", "true");
var advButton = document.getElementById("smtp.advancedbutton");
if (gPrefBranch.prefIsLocked(prefString)) {
advButton.setAttribute("disabled", "true");
}
}
}
@ -71,6 +73,13 @@ function onSave()
catch (ex) {
defaultSmtpServer = null;
}
//if we have a null defaultSmtpServer and if the hostname field has valid
//values then we create a server and make it as the default.
if ((defaultSmtpServer == null) && (!hostnameIsIllegal(gSmtpHostname.value))) {
defaultSmtpServer = smtpService.createSmtpServer();
}
saveSmtpSettings(defaultSmtpServer);
}
@ -86,6 +95,18 @@ function onExitAdvancedDialog(deleteSmtpServers,replaceWithDefault)
function onAdvanced(event)
{
if (smtpService.defaultServer && hostnameIsIllegal(gSmtpHostname.value)) {
var alertTitle = window.parent.gBrandBundle.getString("brandShortName");
var alertMsg = window.parent.gPrefsBundle.getString("enterValidHostname");
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
if (promptService)
promptService.alert(window, alertTitle, alertMsg);
else
window.alert(alertMsg);
return false;
}
// fix for bug #60647
// when the user presses "Advanced..." we save any changes
// they made so that the changes will show up in the advanced dialog

Просмотреть файл

@ -8,7 +8,7 @@
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="onLoad();">
<script type="application/x-javascript" src="amUtils.js"/>
<script type="application/x-javascript" src="am-smtp.js"/>
<dialogheader title="&smtpServer.label;"/>

Просмотреть файл

@ -0,0 +1,52 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Varada Parthasarathi <varada@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function hostnameIsIllegal(hostname)
{
// XXX TODO do a complete check.
// this only checks for illegal characters in the hostname
// but hostnames like "...." and "_" and ".111" will get by
// my test.
var validChars = hostname.match(/[A-Za-z0-9.-]/g);
if (!validChars || (validChars.length != hostname.length)) {
return true;
}
return false;
}

Просмотреть файл

@ -41,20 +41,6 @@ var gPrefsBundle;
var gOnMailServersPage;
var gOnNewsServerPage;
function hostnameIsIllegal(hostname)
{
// XXX TODO do a complete check.
// this only checks for illegal characters in the hostname
// but hostnames like "...." and "_" and ".111" will get by
// my test.
var validChars = hostname.match(/[A-Za-z0-9.-]/g);
if (!validChars || (validChars.length != hostname.length)) {
return true;
}
return false;
}
function serverPageValidate()
{
var smtpserver = document.getElementById("smtphostname");

Просмотреть файл

@ -49,7 +49,7 @@ var gSmtpAuthMethod;
var gSmtpTrySSL;
var gSmtpPrefBranch;
var gPrefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var gSmtpService = Components.classes["@mozilla.org/messengercompose/smtp;1"].getService(Components.interfaces.nsISmtpService);
var gSavedUsername="";
function initSmtpSettings(server) {
@ -86,7 +86,8 @@ function initSmtpSettings(server) {
onUseUsername(gSmtpUseUsername, false);
updateControls();
onLockPreference();
if (gSmtpService.defaultServer)
onLockPreference();
}
// Disables xul elements that have associated preferences locked.