From dc39737bd2bb17306bd14ec9fcafaaf33cb0769d Mon Sep 17 00:00:00 2001 From: "bienvenu%nventure.com" Date: Wed, 4 Aug 2004 19:21:19 +0000 Subject: [PATCH] don't allow user to pick local directory that's used by another account, sr=mscott 233265 git-svn-id: svn://10.0.0.236/trunk@160367 18797224-902f-48f8-a5cc-f745e15eee43 --- .../base/prefs/resources/content/amUtils.js | 27 ++++++++++++++++--- .../resources/locale/en-US/prefs.properties | 1 + 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/mozilla/mailnews/base/prefs/resources/content/amUtils.js b/mozilla/mailnews/base/prefs/resources/content/amUtils.js index 7f84cc7a7eb..9902ba1e4e5 100644 --- a/mozilla/mailnews/base/prefs/resources/content/amUtils.js +++ b/mozilla/mailnews/base/prefs/resources/content/amUtils.js @@ -54,10 +54,31 @@ function BrowseForLocalFolders() var ret = fp.show(); - if (ret == nsIFilePicker.returnOK) { - // convert the nsILocalFile into a nsIFileSpec - currentFolderTextBox.value = fp.file.path; + if (ret == nsIFilePicker.returnOK) + { + // check that no other account/server has this same local directory + var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager); + var allServers = accountManager.allServers; + + for (var i=0; i < allServers.Count(); i++) + { + var currentServer = allServers.GetElementAt(i).QueryInterface(Components.interfaces.nsIMsgIncomingServer); + var localPath = currentServer.localPath; + if (currentServer.key != gServer.key && fp.file.path == localPath.nativePath) + { + var directoryAlreadyUsed = + top.gPrefsBundle.getString("directoryUsedByOtherServer"); + + var promptService = + Components.classes["@mozilla.org/embedcomp/prompt-service;1"]. + getService(Components.interfaces.nsIPromptService); + promptService.alert(window, null, directoryAlreadyUsed); + return; + } + } } + // convert the nsILocalFile into a nsIFileSpec + currentFolderTextBox.value = fp.file.path; } function hostnameIsIllegal(hostname) diff --git a/mozilla/mailnews/base/prefs/resources/locale/en-US/prefs.properties b/mozilla/mailnews/base/prefs/resources/locale/en-US/prefs.properties index e8520a330d6..4e2a09c7b6a 100644 --- a/mozilla/mailnews/base/prefs/resources/locale/en-US/prefs.properties +++ b/mozilla/mailnews/base/prefs/resources/locale/en-US/prefs.properties @@ -68,6 +68,7 @@ accountName=%1$S - %2$S confirmDeferAccount=If you store this account's new mail in a different account's Inbox, you will no longer be able to access already downloaded e-mail for this account. If you have mail in this account, please copy it to another account first. If you have filters that filter mail into this account, you should disable them or change the destination folder. If any accounts have special folders in this account (Sent, Drafts, Templates), you should change them to be in another account. Do you still want to store this account's e-mail in a different account? confirmDeferAccountTitle=Defer Account? +directoryUsedByOtherServer=This directory is already used by another server. Please pick a different directory. #Provide default example values for sample email address exampleEmailUserName=user exampleEmailDomain=example.net