зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
57b7ad0ec2
Коммит
eb5e68f11e
|
@ -40,7 +40,7 @@
|
||||||
* on values set in the previous step.
|
* on values set in the previous step.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var gSmtpHostNameIsIllegal = false;
|
||||||
var accountArray;
|
var accountArray;
|
||||||
var gGenericAttributeTypes;
|
var gGenericAttributeTypes;
|
||||||
var accounttree;
|
var accounttree;
|
||||||
|
@ -51,12 +51,14 @@ var currentPageId;
|
||||||
var pendingServerId;
|
var pendingServerId;
|
||||||
var pendingPageId;
|
var pendingPageId;
|
||||||
var gPrefsBundle;
|
var gPrefsBundle;
|
||||||
|
var gBrandBundle;
|
||||||
|
|
||||||
// services used
|
// services used
|
||||||
var RDF;
|
var RDF;
|
||||||
var accountManager;
|
var accountManager;
|
||||||
var smtpService;
|
var smtpService;
|
||||||
var nsPrefBranch;
|
var nsPrefBranch;
|
||||||
|
var gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
|
||||||
|
|
||||||
// widgets
|
// widgets
|
||||||
var duplicateButton;
|
var duplicateButton;
|
||||||
|
@ -94,6 +96,7 @@ function updateElementWithKeys(account, element, type) {
|
||||||
// perform initialization here
|
// perform initialization here
|
||||||
function onLoad() {
|
function onLoad() {
|
||||||
gPrefsBundle = document.getElementById("bundle_prefs");
|
gPrefsBundle = document.getElementById("bundle_prefs");
|
||||||
|
gBrandBundle = document.getElementById("bundle_brand");
|
||||||
|
|
||||||
var selectedServer;
|
var selectedServer;
|
||||||
var selectPage = null;
|
var selectPage = null;
|
||||||
|
@ -239,6 +242,11 @@ function onAccept() {
|
||||||
if (!checkUserServerChanges(true))
|
if (!checkUserServerChanges(true))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (gSmtpHostNameIsIllegal) {
|
||||||
|
gSmtpHostNameIsIllegal = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
onSave();
|
onSave();
|
||||||
// hack hack - save the prefs file NOW in case we crash
|
// hack hack - save the prefs file NOW in case we crash
|
||||||
try {
|
try {
|
||||||
|
@ -255,6 +263,24 @@ function onAccept() {
|
||||||
// if so check if the new names already exists for an account.
|
// if so check if the new names already exists for an account.
|
||||||
//
|
//
|
||||||
function checkUserServerChanges(showAlert) {
|
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);
|
var accountValues = getValueArrayFor(currentServerId);
|
||||||
if (!accountValues)
|
if (!accountValues)
|
||||||
return true;
|
return true;
|
||||||
|
@ -679,6 +705,11 @@ function showPage(serverId, pageId) {
|
||||||
// check if user/host names have been changed
|
// check if user/host names have been changed
|
||||||
checkUserServerChanges(false);
|
checkUserServerChanges(false);
|
||||||
|
|
||||||
|
if (gSmtpHostNameIsIllegal) {
|
||||||
|
gSmtpHostNameIsIllegal = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// save the previous page
|
// save the previous page
|
||||||
savePage(currentServerId);
|
savePage(currentServerId);
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,9 @@
|
||||||
onload="onLoad(event);"
|
onload="onLoad(event);"
|
||||||
ondialogaccept="return onAccept();"
|
ondialogaccept="return onAccept();"
|
||||||
ondialoghelp="return doHelpButton();">
|
ondialoghelp="return doHelpButton();">
|
||||||
|
<stringbundle id="bundle_brand" src="chrome://global/locale/brand.properties"/>
|
||||||
<stringbundle id="bundle_prefs" src="chrome://messenger/locale/prefs.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/accountUtils.js"/>
|
||||||
<script type="application/x-javascript" src="chrome://messenger/content/am-prefs.js"/>
|
<script type="application/x-javascript" src="chrome://messenger/content/am-prefs.js"/>
|
||||||
<script type="application/x-javascript" src="chrome://messenger/content/AccountManager.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_prefs" src="chrome://messenger/locale/prefs.properties"/>
|
||||||
<stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.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/accountUtils.js"/>
|
||||||
<script type="application/x-javascript" src="chrome://messenger/content/AccountWizard.js"/>
|
<script type="application/x-javascript" src="chrome://messenger/content/AccountWizard.js"/>
|
||||||
<script type="application/x-javascript" src="chrome://messenger/content/ispUtils.js"/>
|
<script type="application/x-javascript" src="chrome://messenger/content/ispUtils.js"/>
|
||||||
|
|
|
@ -62,6 +62,21 @@ function initializeDialog(server)
|
||||||
|
|
||||||
function onAccept()
|
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,
|
// if we didn't have an SMTP server to initialize with,
|
||||||
// we must be creating one.
|
// we must be creating one.
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -37,7 +37,9 @@
|
||||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
onload="onLoad();"
|
onload="onLoad();"
|
||||||
ondialogaccept="return onAccept();">
|
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"/>
|
<script type="application/x-javascript" src="SmtpServerEdit.js"/>
|
||||||
<vbox id="smtpServerEditor"/>
|
<vbox id="smtpServerEditor"/>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|
|
@ -53,12 +53,14 @@ function onLoad()
|
||||||
|
|
||||||
// Get the default smtp server preference to check if we need to lock the
|
// Get the default smtp server preference to check if we need to lock the
|
||||||
// advance button on the panel.
|
// advance button on the panel.
|
||||||
var defaultSmtpServerKey = gPrefBranch.getCharPref("mail.smtp.defaultserver");
|
if (defaultSmtpServer) {
|
||||||
var prefString = "mail.smtpserver."+ defaultSmtpServerKey + ".advanced.disable";
|
var defaultSmtpServerKey = gPrefBranch.getCharPref("mail.smtp.defaultserver");
|
||||||
|
var prefString = "mail.smtpserver."+ defaultSmtpServerKey + ".advanced.disable";
|
||||||
|
|
||||||
var advButton = document.getElementById("smtp.advancedbutton");
|
var advButton = document.getElementById("smtp.advancedbutton");
|
||||||
if (gPrefBranch.prefIsLocked(prefString)) {
|
if (gPrefBranch.prefIsLocked(prefString)) {
|
||||||
advButton.setAttribute("disabled", "true");
|
advButton.setAttribute("disabled", "true");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +73,13 @@ function onSave()
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
defaultSmtpServer = null;
|
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);
|
saveSmtpSettings(defaultSmtpServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +95,18 @@ function onExitAdvancedDialog(deleteSmtpServers,replaceWithDefault)
|
||||||
|
|
||||||
function onAdvanced(event)
|
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
|
// fix for bug #60647
|
||||||
// when the user presses "Advanced..." we save any changes
|
// when the user presses "Advanced..." we save any changes
|
||||||
// they made so that the changes will show up in the advanced dialog
|
// 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"
|
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
onload="onLoad();">
|
onload="onLoad();">
|
||||||
|
<script type="application/x-javascript" src="amUtils.js"/>
|
||||||
<script type="application/x-javascript" src="am-smtp.js"/>
|
<script type="application/x-javascript" src="am-smtp.js"/>
|
||||||
|
|
||||||
<dialogheader title="&smtpServer.label;"/>
|
<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 gOnMailServersPage;
|
||||||
var gOnNewsServerPage;
|
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()
|
function serverPageValidate()
|
||||||
{
|
{
|
||||||
var smtpserver = document.getElementById("smtphostname");
|
var smtpserver = document.getElementById("smtphostname");
|
||||||
|
|
|
@ -49,7 +49,7 @@ var gSmtpAuthMethod;
|
||||||
var gSmtpTrySSL;
|
var gSmtpTrySSL;
|
||||||
var gSmtpPrefBranch;
|
var gSmtpPrefBranch;
|
||||||
var gPrefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
|
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="";
|
var gSavedUsername="";
|
||||||
|
|
||||||
function initSmtpSettings(server) {
|
function initSmtpSettings(server) {
|
||||||
|
@ -86,7 +86,8 @@ function initSmtpSettings(server) {
|
||||||
|
|
||||||
onUseUsername(gSmtpUseUsername, false);
|
onUseUsername(gSmtpUseUsername, false);
|
||||||
updateControls();
|
updateControls();
|
||||||
onLockPreference();
|
if (gSmtpService.defaultServer)
|
||||||
|
onLockPreference();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disables xul elements that have associated preferences locked.
|
// Disables xul elements that have associated preferences locked.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче