bug57839 'Local Folders' not created after cancel Wiz & import settings, r=bhuvan

, sr=sspitzer, a=asa@mozilla.org


git-svn-id: svn://10.0.0.236/trunk@97454 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
chuang%netscape.com 2001-06-19 22:30:30 +00:00
parent 4a230f52b7
commit 5d8aa58eb9
2 changed files with 41 additions and 5 deletions

View File

@ -1955,6 +1955,10 @@ NS_IMETHODIMP nsMsgAccountManager::GetLocalFoldersServer(nsIMsgIncomingServer **
if (!aServer) return NS_ERROR_NULL_POINTER;
if (!m_prefs) {
rv = getPrefService();
NS_ENSURE_SUCCESS(rv,rv);
}
rv = m_prefs->CopyCharPref(PREF_MAIL_ACCOUNTMANAGER_LOCALFOLDERSSERVER,
getter_Copies(serverKey));

View File

@ -42,6 +42,7 @@ function OnLoadImportDialog()
progressInfo.intervalState = 0;
progressInfo.importSuccess = false;
progressInfo.importType = null;
progressInfo.localFolderExists = false;
// look in arguments[0] for parameters
if (window.arguments && window.arguments.length >= 1 &&
@ -98,6 +99,19 @@ function SetDivText(id, text)
}
}
function CheckIfLocalFolderExists()
{
var acctMgr = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager);
if (acctMgr) {
try {
if (acctMgr.localFoldersServer)
progressInfo.localFolderExists = true;
}
catch (ex) {
progressInfo.localFolderExists = false;
}
}
}
function ImportDialogOKButton()
{
@ -124,10 +138,20 @@ function ImportDialogOKButton()
selectedModuleName = name;
if (module)
{
// Fix for Bug 57839 & 85219
// We use localFoldersServer(in nsIMsgAccountManager) to check if Local Folder exists.
// We need to check localFoldersServer before importing "mail" or "settings".
// Reason: We will create an account with an incoming server of type "none" after
// importing "mail", so the localFoldersServer is valid even though the Local Folder
// is not created.
if (importType == "mail" || importType == "settings")
CheckIfLocalFolderExists();
var meterText = "";
switch(importType)
{
case "mail":
top.successStr = Components.classes["@mozilla.org/supports-wstring;1"].createInstance();
if (top.successStr) {
top.successStr = top.successStr.QueryInterface( Components.interfaces.nsISupportsWString);
@ -156,7 +180,6 @@ function ImportDialogOKButton()
deck.setAttribute("index", "2");
progressInfo.progressWindow = top.window;
progressInfo.intervalState = setInterval("ContinueImportCallback()", 100);
return( true);
}
}
@ -212,13 +235,13 @@ function ImportDialogOKButton()
if (!ImportSettings( module, newAccount, error))
{
if (error.value)
ShowImportResultsRaw(gImportMsgsBundle.getString('ImportSettingsFailed'), null);
ShowImportResultsRaw(gImportMsgsBundle.getString('ImportSettingsFailed'), null, false);
// the user canceled the operation, shoud we dismiss
// this dialog or not?
return false;
}
else
ShowImportResultsRaw(gImportMsgsBundle.getFormattedString('ImportSettingsSuccess', [ name ]), null);
ShowImportResultsRaw(gImportMsgsBundle.getFormattedString('ImportSettingsSuccess', [ name ]), null, true);
break;
}
}
@ -356,10 +379,10 @@ function ShowImportResults(good, module)
}
if (results && title)
ShowImportResultsRaw(title, results)
ShowImportResultsRaw(title, results, good);
}
function ShowImportResultsRaw(title, results)
function ShowImportResultsRaw(title, results, good)
{
SetDivText("status", title);
var header = document.getElementById("header");
@ -373,6 +396,15 @@ function ShowImportResultsRaw(title, results)
nextButton.removeAttribute("disabled");
var cancelButton = document.getElementById("cancel");
cancelButton.setAttribute("disabled", "true");
// If the Local Folder is not existed, create it after successfully
// import "mail" and "settings"
var checkLocalFolder = (top.progressInfo.importType == 'mail' || top.progressInfo.importType == 'settings') ? true : false;
if (good && checkLocalFolder && !top.progressInfo.localFolderExists) {
var messengerMigrator = Components.classes["@mozilla.org/messenger/migrator;1"].getService(Components.interfaces.nsIMessengerMigrator);
if (messengerMigrator)
messengerMigrator.createLocalMailAccount(false);
}
}
function attachStrings(aNode, aString)