diff --git a/mail/base/content/mailWindow.js b/mail/base/content/mailWindow.js index 6e40eb17b1a..4d10ce976c5 100644 --- a/mail/base/content/mailWindow.js +++ b/mail/base/content/mailWindow.js @@ -552,17 +552,8 @@ function OpenInboxForServer(server) if (server.type != "imap") GetMessagesForInboxOnServer(server); } - else { - var option = PromptGetMessagesOffline(); - if(option == 0) { - if (!gOfflineManager) - GetOfflineMgrService(); - - gOfflineManager.goOnline(false /* sendUnsentMessages */, - false /* playbackOfflineImapOperations */, - msgWindow); + else if (DoGetNewMailWhenOffline()) { GetMessagesForInboxOnServer(server); - } } } catch (ex) { diff --git a/mail/base/content/mailWindowOverlay.js b/mail/base/content/mailWindowOverlay.js index 57bd945b04a..9786d09b120 100644 --- a/mail/base/content/mailWindowOverlay.js +++ b/mail/base/content/mailWindowOverlay.js @@ -748,21 +748,11 @@ function GetMessagesForInboxOnServer(server) function MsgGetMessage() { // if offline, prompt for getting messages - if(CheckOnline()) { + if(CheckOnline()) GetFolderMessages(); - } - else { - var option = PromptGetMessagesOffline(); - if(option == 0) { - if (!gOfflineManager) - GetOfflineMgrService(); - gOfflineManager.goOnline(false /* sendUnsentMessages */, - false /* playbackOfflineImapOperations */, - msgWindow); + else if (DoGetNewMailWhenOffline()) GetFolderMessages(); } - } -} function MsgGetMessagesForAllServers(defaultServer) { @@ -803,21 +793,11 @@ function MsgGetMessagesForAllServers(defaultServer) */ function MsgGetMessagesForAllAuthenticatedAccounts() { - if(CheckOnline()) { + if(CheckOnline()) GetMessagesForAllAuthenticatedAccounts(); - } - else { - var option = PromptGetMessagesOffline(); - if(option == 0) { - if (!gOfflineManager) - GetOfflineMgrService(); - gOfflineManager.goOnline(false /* sendUnsentMessages */, - false /* playbackOfflineImapOperations */, - msgWindow); + else if (DoGetNewMailWhenOffline()) GetMessagesForAllAuthenticatedAccounts(); } - } -} /** * Get messages for the account selected from Menu dropdowns. @@ -828,21 +808,11 @@ function MsgGetMessagesForAccount(aEvent) if (!aEvent) return; - if(CheckOnline()) { + if(CheckOnline()) GetMessagesForAccount(aEvent); - } - else { - var option = PromptGetMessagesOffline(); - if(option == 0) { - if (!gOfflineManager) - GetOfflineMgrService(); - gOfflineManager.goOnline(false /* sendUnsentMessages */, - false /* playbackOfflineImapOperations */, - msgWindow); + else if (DoGetNewMailWhenOffline()) GetMessagesForAccount(aEvent); } - } -} // if offline, prompt for getNextNMessages function MsgGetNextNMessages() @@ -854,21 +824,14 @@ function MsgGetNextNMessages() if(folder) GetNextNMessages(folder); } - else { - var option = PromptGetMessagesOffline(); - if(option == 0) { - if (!gOfflineManager) - GetOfflineMgrService(); - gOfflineManager.goOnline(false /* sendUnsentMessages */, - false /* playbackOfflineImapOperations */, - msgWindow); + + else if(DoGetNewMailWhenOffline()) { folder = GetFirstSelectedMsgFolder(); if(folder) { GetNextNMessages(folder); } } } -} function MsgDeleteMessage(reallyDelete, fromToolbar) { @@ -1802,6 +1765,33 @@ function InitPrompts() gOfflinePromptsBundle = document.getElementById("bundle_offlinePrompts"); } +function DoGetNewMailWhenOffline() +{ + var sendUnsent = false; + var goOnline = PromptGetMessagesOffline() == 0; + if (goOnline) + { + if (this.CheckForUnsentMessages != undefined && CheckForUnsentMessages()) + { + sendUnsent = gPromptService.confirmEx(window, + gOfflinePromptsBundle.getString('sendMessagesOfflineWindowTitle'), + gOfflinePromptsBundle.getString('sendMessagesLabel'), + gPromptService.BUTTON_TITLE_IS_STRING * (gPromptService.BUTTON_POS_0 + + gPromptService.BUTTON_POS_1), + gOfflinePromptsBundle.getString('sendMessagesSendButtonLabel'), + gOfflinePromptsBundle.getString('sendMessagesNoSendButtonLabel'), + null, null, {value:0}) == 0; + } + if (!gOfflineManager) + GetOfflineMgrService(); + gOfflineManager.goOnline(sendUnsent /* sendUnsentMessages */, + false /* playbackOfflineImapOperations */, + msgWindow); + + } + return goOnline; +} + // prompt for getting messages when offline function PromptGetMessagesOffline() { diff --git a/mail/base/content/msgMail3PaneWindow.js b/mail/base/content/msgMail3PaneWindow.js index b612ed22f19..32a5dbe5e28 100644 --- a/mail/base/content/msgMail3PaneWindow.js +++ b/mail/base/content/msgMail3PaneWindow.js @@ -752,6 +752,29 @@ function delayedOnLoadMessenger() gSearchEmailAddress = (window.arguments.length > 2) ? window.arguments[2] : null; } + if (this.CheckForUnsentMessages != undefined && CheckForUnsentMessages()) + { + var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); + if (!ioService.offline) + { + InitPrompts(); + InitServices(); + + if (gPromptService) + { + var buttonPressed = gPromptService.confirmEx(window, + gOfflinePromptsBundle.getString('sendMessagesOfflineWindowTitle'), + gOfflinePromptsBundle.getString('sendMessagesLabel'), + gPromptService.BUTTON_TITLE_IS_STRING * (gPromptService.BUTTON_POS_0 + + gPromptService.BUTTON_POS_1), + gOfflinePromptsBundle.getString('sendMessagesSendButtonLabel'), + gOfflinePromptsBundle.getString('sendMessagesNoSendButtonLabel'), + null, null, {value:0}); + if (buttonPressed == 0) + SendUnsentMessages(); + } + } + } setTimeout("loadStartFolder(gStartFolderUri);", 0); // FIX ME - later we will be able to use onload from the overlay