prompt to send unsent messages when starting up online, or going online via pressing get new mail while offline sr=mscott 232452

This commit is contained in:
bienvenu%nventure.com 2004-02-20 18:12:51 +00:00
Родитель 80c0160f25
Коммит b439daa438
3 изменённых файлов: 59 добавлений и 55 удалений

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

@ -552,19 +552,10 @@ function OpenInboxForServer(server)
if (server.type != "imap") if (server.type != "imap")
GetMessagesForInboxOnServer(server); GetMessagesForInboxOnServer(server);
} }
else { else if (DoGetNewMailWhenOffline()) {
var option = PromptGetMessagesOffline();
if(option == 0) {
if (!gOfflineManager)
GetOfflineMgrService();
gOfflineManager.goOnline(false /* sendUnsentMessages */,
false /* playbackOfflineImapOperations */,
msgWindow);
GetMessagesForInboxOnServer(server); GetMessagesForInboxOnServer(server);
} }
} }
}
catch (ex) { catch (ex) {
dump("Error opening inbox for server -> " + ex + "\n"); dump("Error opening inbox for server -> " + ex + "\n");
return; return;

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

@ -748,21 +748,11 @@ function GetMessagesForInboxOnServer(server)
function MsgGetMessage() function MsgGetMessage()
{ {
// if offline, prompt for getting messages // if offline, prompt for getting messages
if(CheckOnline()) { if(CheckOnline())
GetFolderMessages();
else if (DoGetNewMailWhenOffline())
GetFolderMessages(); GetFolderMessages();
} }
else {
var option = PromptGetMessagesOffline();
if(option == 0) {
if (!gOfflineManager)
GetOfflineMgrService();
gOfflineManager.goOnline(false /* sendUnsentMessages */,
false /* playbackOfflineImapOperations */,
msgWindow);
GetFolderMessages();
}
}
}
function MsgGetMessagesForAllServers(defaultServer) function MsgGetMessagesForAllServers(defaultServer)
{ {
@ -803,21 +793,11 @@ function MsgGetMessagesForAllServers(defaultServer)
*/ */
function MsgGetMessagesForAllAuthenticatedAccounts() function MsgGetMessagesForAllAuthenticatedAccounts()
{ {
if(CheckOnline()) { if(CheckOnline())
GetMessagesForAllAuthenticatedAccounts();
else if (DoGetNewMailWhenOffline())
GetMessagesForAllAuthenticatedAccounts(); GetMessagesForAllAuthenticatedAccounts();
} }
else {
var option = PromptGetMessagesOffline();
if(option == 0) {
if (!gOfflineManager)
GetOfflineMgrService();
gOfflineManager.goOnline(false /* sendUnsentMessages */,
false /* playbackOfflineImapOperations */,
msgWindow);
GetMessagesForAllAuthenticatedAccounts();
}
}
}
/** /**
* Get messages for the account selected from Menu dropdowns. * Get messages for the account selected from Menu dropdowns.
@ -828,21 +808,11 @@ function MsgGetMessagesForAccount(aEvent)
if (!aEvent) if (!aEvent)
return; return;
if(CheckOnline()) { if(CheckOnline())
GetMessagesForAccount(aEvent);
else if (DoGetNewMailWhenOffline())
GetMessagesForAccount(aEvent); GetMessagesForAccount(aEvent);
} }
else {
var option = PromptGetMessagesOffline();
if(option == 0) {
if (!gOfflineManager)
GetOfflineMgrService();
gOfflineManager.goOnline(false /* sendUnsentMessages */,
false /* playbackOfflineImapOperations */,
msgWindow);
GetMessagesForAccount(aEvent);
}
}
}
// if offline, prompt for getNextNMessages // if offline, prompt for getNextNMessages
function MsgGetNextNMessages() function MsgGetNextNMessages()
@ -854,21 +824,14 @@ function MsgGetNextNMessages()
if(folder) if(folder)
GetNextNMessages(folder); GetNextNMessages(folder);
} }
else {
var option = PromptGetMessagesOffline(); else if(DoGetNewMailWhenOffline()) {
if(option == 0) {
if (!gOfflineManager)
GetOfflineMgrService();
gOfflineManager.goOnline(false /* sendUnsentMessages */,
false /* playbackOfflineImapOperations */,
msgWindow);
folder = GetFirstSelectedMsgFolder(); folder = GetFirstSelectedMsgFolder();
if(folder) { if(folder) {
GetNextNMessages(folder); GetNextNMessages(folder);
} }
} }
} }
}
function MsgDeleteMessage(reallyDelete, fromToolbar) function MsgDeleteMessage(reallyDelete, fromToolbar)
{ {
@ -1802,6 +1765,33 @@ function InitPrompts()
gOfflinePromptsBundle = document.getElementById("bundle_offlinePrompts"); 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 // prompt for getting messages when offline
function PromptGetMessagesOffline() function PromptGetMessagesOffline()
{ {

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

@ -752,6 +752,29 @@ function delayedOnLoadMessenger()
gSearchEmailAddress = (window.arguments.length > 2) ? window.arguments[2] : null; 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); setTimeout("loadStartFolder(gStartFolderUri);", 0);
// FIX ME - later we will be able to use onload from the overlay // FIX ME - later we will be able to use onload from the overlay