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")
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) {
dump("Error opening inbox for server -> " + ex + "\n");
return;

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

@ -748,21 +748,11 @@ function GetMessagesForInboxOnServer(server)
function MsgGetMessage()
{
// if offline, prompt for getting messages
if(CheckOnline()) {
if(CheckOnline())
GetFolderMessages();
else if (DoGetNewMailWhenOffline())
GetFolderMessages();
}
else {
var option = PromptGetMessagesOffline();
if(option == 0) {
if (!gOfflineManager)
GetOfflineMgrService();
gOfflineManager.goOnline(false /* sendUnsentMessages */,
false /* playbackOfflineImapOperations */,
msgWindow);
GetFolderMessages();
}
}
}
function MsgGetMessagesForAllServers(defaultServer)
{
@ -803,21 +793,11 @@ function MsgGetMessagesForAllServers(defaultServer)
*/
function MsgGetMessagesForAllAuthenticatedAccounts()
{
if(CheckOnline()) {
if(CheckOnline())
GetMessagesForAllAuthenticatedAccounts();
else if (DoGetNewMailWhenOffline())
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.
@ -828,21 +808,11 @@ function MsgGetMessagesForAccount(aEvent)
if (!aEvent)
return;
if(CheckOnline()) {
if(CheckOnline())
GetMessagesForAccount(aEvent);
else if (DoGetNewMailWhenOffline())
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
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()
{

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

@ -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