Bug #359653 --> Consolidate Offline management in the front end.
sr=bienvenu git-svn-id: svn://10.0.0.236/trunk@214860 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
c746023b23
commit
8854b06dc8
@ -252,7 +252,14 @@ pref("general.startup.compose", false);
|
||||
pref("general.startup.addressbook", false);
|
||||
|
||||
pref("offline.startup_state", 2);
|
||||
// 0 Ask before sending unsent messages when going online
|
||||
// 1 Always send unsent messages when going online
|
||||
// 2 Never send unsent messages when going online
|
||||
pref("offline.send.unsent_messages", 0);
|
||||
|
||||
// 0 Ask before synchronizing the offline mail store when going offline
|
||||
// 1 Always synchronize the offline store when going offline
|
||||
// 2 Never synchronize the offline store when going offline
|
||||
pref("offline.download.download_messages", 0);
|
||||
pref("offline.prompt_synch_on_exit", true);
|
||||
|
||||
|
||||
@ -1006,36 +1006,6 @@ function Redo()
|
||||
messenger.Redo(msgWindow);
|
||||
}
|
||||
|
||||
var mailOfflineObserver = {
|
||||
observe: function(subject, topic, state) {
|
||||
// sanity checks
|
||||
if (topic == "network:offline-status-changed")
|
||||
MailOfflineStateChanged(state == "offline");
|
||||
}
|
||||
}
|
||||
|
||||
function AddMailOfflineObserver()
|
||||
{
|
||||
var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
|
||||
observerService.addObserver(mailOfflineObserver, "network:offline-status-changed", false);
|
||||
|
||||
try {
|
||||
// Stop automatic management of the offline status.
|
||||
// XXX need to watch the link status changes and manage
|
||||
// offline mode accordingly.
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"].
|
||||
getService(Components.interfaces.nsIIOService2);
|
||||
ioService.manageOfflineStatus = false;
|
||||
} catch (ex) {
|
||||
}
|
||||
}
|
||||
|
||||
function RemoveMailOfflineObserver()
|
||||
{
|
||||
var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
|
||||
observerService.removeObserver(mailOfflineObserver,"network:offline-status-changed");
|
||||
}
|
||||
|
||||
function getSearchTermString(searchTerms)
|
||||
{
|
||||
var searchIndex;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
# -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
@ -21,6 +21,7 @@
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Scott MacGregor <mscott@mozilla.org>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -36,225 +37,257 @@
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
var gMailOfflinePrefs = null;
|
||||
var gOfflinePromptsBundle;
|
||||
var gPromptService;
|
||||
var gOfflineManager;
|
||||
|
||||
|
||||
function MailOfflineStateChanged(goingOffline)
|
||||
{
|
||||
// tweak any mail UI here that needs to change when we go offline or come back online
|
||||
gFolderJustSwitched = true;
|
||||
}
|
||||
|
||||
function MsgSettingsOffline()
|
||||
{
|
||||
window.parent.MsgAccountManager('am-offline.xul');
|
||||
}
|
||||
|
||||
// Init PrefsService
|
||||
function GetMailOfflinePrefs()
|
||||
{
|
||||
gMailOfflinePrefs = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService).getBranch(null);
|
||||
}
|
||||
|
||||
// Check for unsent messages
|
||||
function CheckForUnsentMessages()
|
||||
{
|
||||
try
|
||||
var MailOfflineMgr = {
|
||||
offlineManager: null,
|
||||
offlineBundle: null,
|
||||
|
||||
init: function()
|
||||
{
|
||||
var am = Components.classes["@mozilla.org/messenger/account-manager;1"]
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
os.addObserver(this, "network:offline-status-changed", false);
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService2);
|
||||
|
||||
// Stop automatic management of the offline status.
|
||||
ioService.manageOfflineStatus = false;
|
||||
|
||||
this.offlineManager = Components.classes["@mozilla.org/messenger/offline-manager;1"]
|
||||
.getService(Components.interfaces.nsIMsgOfflineManager);
|
||||
this.offlineBundle = document.getElementById("bundle_offlinePrompts");
|
||||
|
||||
// initialize our offline state UI
|
||||
this.updateOfflineUI(!this.isOnline());
|
||||
},
|
||||
|
||||
uninit: function()
|
||||
{
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
os.removeObserver(this, "network:offline-status-changed");
|
||||
},
|
||||
|
||||
/**
|
||||
* @return true if we are online
|
||||
*/
|
||||
isOnline: function()
|
||||
{
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
return (!ioService.offline);
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggles the online / offline state, initiated by the user. Depending on user settings
|
||||
* we may prompt the user to send unsent messages when going online or to download messages for
|
||||
* offline use when going offline.
|
||||
*/
|
||||
toggleOfflineStatus: function()
|
||||
{
|
||||
// the offline manager(goOnline and synchronizeForOffline) actually does the dirty work of
|
||||
// changing the offline state with the networking service.
|
||||
if (!this.isOnline())
|
||||
{
|
||||
var prefSendUnsentMessages = gPrefBranch.getIntPref("offline.send.unsent_messages");
|
||||
// 0 == Ask, 1 == Always Send, 2 == Never Send
|
||||
var sendUnsentMessages = (prefSendUnsentMessages == 0 && this.haveUnsentMessages()
|
||||
&& this.confirmSendUnsentMessages()) || prefSendUnsentMessages == 1;
|
||||
this.offlineManager.goOnline(sendUnsentMessages, true /* playbackOfflineImapOperations */, msgWindow);
|
||||
}
|
||||
else // going offline
|
||||
{
|
||||
var prefDownloadMessages = gPrefBranch.getIntPref("offline.download.download_messages");
|
||||
// 0 == Ask, 1 == Always Download, 2 == Never Download
|
||||
var downloadForOfflineUse = (prefDownloadMessages == 0 && this.confirmDownloadMessagesForOfflineUse())
|
||||
|| prefDownloadMessages == 1;
|
||||
this.offlineManager.synchronizeForOffline(downloadForOfflineUse, downloadForOfflineUse, false, true, msgWindow);
|
||||
}
|
||||
},
|
||||
|
||||
observe: function (aSubject, aTopic, aState)
|
||||
{
|
||||
if (aTopic == "network:offline-status-changed")
|
||||
this.mailOfflineStateChanged(aState == "offline");
|
||||
},
|
||||
|
||||
/**
|
||||
* @return true if there are unsent messages
|
||||
*/
|
||||
haveUnsentMessages: function()
|
||||
{
|
||||
try
|
||||
{
|
||||
var am = Components.classes["@mozilla.org/messenger/account-manager;1"]
|
||||
.getService(Components.interfaces.nsIMsgAccountManager);
|
||||
var msgSendlater = Components.classes["@mozilla.org/messengercompose/sendlater;1"]
|
||||
.getService(Components.interfaces.nsIMsgSendLater);
|
||||
var identitiesCount, allIdentities, currentIdentity, numMessages, msgFolder;
|
||||
var msgSendlater = Components.classes["@mozilla.org/messengercompose/sendlater;1"]
|
||||
.getService(Components.interfaces.nsIMsgSendLater);
|
||||
var identitiesCount, allIdentities, currentIdentity, numMessages, msgFolder;
|
||||
|
||||
if(am) {
|
||||
allIdentities = am.allIdentities;
|
||||
identitiesCount = allIdentities.Count();
|
||||
for (var i = 0; i < identitiesCount; i++) {
|
||||
currentIdentity = allIdentities.QueryElementAt(i, Components.interfaces.nsIMsgIdentity);
|
||||
msgFolder = msgSendlater.getUnsentMessagesFolder(currentIdentity);
|
||||
if(msgFolder) {
|
||||
// if true, descends into all subfolders
|
||||
numMessages = msgFolder.getTotalMessages(false);
|
||||
if(numMessages > 0) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(ex) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Init nsIPromptService & strings.
|
||||
function InitPrompts()
|
||||
{
|
||||
if(!gPromptService) {
|
||||
gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
|
||||
gPromptService = gPromptService.QueryInterface(Components.interfaces.nsIPromptService);
|
||||
}
|
||||
if (!gOfflinePromptsBundle)
|
||||
gOfflinePromptsBundle = document.getElementById("bundle_offlinePrompts");
|
||||
}
|
||||
|
||||
// prompt for sending messages while going online, and go online.
|
||||
function PromptSendMessages()
|
||||
{
|
||||
InitPrompts();
|
||||
InitServices();
|
||||
|
||||
if (gPromptService) {
|
||||
var checkValue = {value:true};
|
||||
var buttonPressed = gPromptService.confirmEx(window,
|
||||
gOfflinePromptsBundle.getString('sendMessagesWindowTitle'),
|
||||
gOfflinePromptsBundle.getString('sendMessagesLabel'),
|
||||
gPromptService.BUTTON_TITLE_IS_STRING * (gPromptService.BUTTON_POS_0 +
|
||||
gPromptService.BUTTON_POS_1 + gPromptService.BUTTON_POS_2),
|
||||
gOfflinePromptsBundle.getString('sendMessagesSendButtonLabel'),
|
||||
gOfflinePromptsBundle.getString('sendMessagesCancelButtonLabel'),
|
||||
gOfflinePromptsBundle.getString('sendMessagesNoSendButtonLabel'),
|
||||
gOfflinePromptsBundle.getString('sendMessagesCheckboxLabel'),
|
||||
checkValue);
|
||||
if(buttonPressed == 0) {
|
||||
gMailOfflinePrefs.setIntPref("offline.send.unsent_messages", !checkValue.value);
|
||||
gOfflineManager.goOnline(true, true, msgWindow);
|
||||
return true;
|
||||
}
|
||||
if(buttonPressed == 1) {
|
||||
return false;
|
||||
}
|
||||
if(buttonPressed == 2) {
|
||||
gMailOfflinePrefs.setIntPref("offline.send.unsent_messages", 2*!checkValue.value);
|
||||
gOfflineManager.goOnline(false, true, msgWindow);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// prompt for downlading messages while going offline, and synchronise
|
||||
function PromptDownloadMessages()
|
||||
{
|
||||
InitPrompts();
|
||||
InitServices();
|
||||
|
||||
if(gPromptService) {
|
||||
var checkValue = {value:true};
|
||||
var buttonPressed = gPromptService.confirmEx(window,
|
||||
gOfflinePromptsBundle.getString('downloadMessagesWindowTitle'),
|
||||
gOfflinePromptsBundle.getString('downloadMessagesLabel'),
|
||||
gPromptService.BUTTON_TITLE_IS_STRING * (gPromptService.BUTTON_POS_0 +
|
||||
gPromptService.BUTTON_POS_1 + gPromptService.BUTTON_POS_2),
|
||||
gOfflinePromptsBundle.getString('downloadMessagesDownloadButtonLabel'),
|
||||
gOfflinePromptsBundle.getString('downloadMessagesCancelButtonLabel'),
|
||||
gOfflinePromptsBundle.getString('downloadMessagesNoDownloadButtonLabel'),
|
||||
gOfflinePromptsBundle.getString('downloadMessagesCheckboxLabel'),
|
||||
checkValue);
|
||||
if(buttonPressed == 0) {
|
||||
gMailOfflinePrefs.setIntPref("offline.download.download_messages", !checkValue.value);
|
||||
gOfflineManager.synchronizeForOffline(true, true, false, true, msgWindow);
|
||||
return true;
|
||||
}
|
||||
if(buttonPressed == 1) {
|
||||
return false;
|
||||
}
|
||||
if(buttonPressed == 2) {
|
||||
gMailOfflinePrefs.setIntPref("offline.download.download_messages", 2*!checkValue.value);
|
||||
gOfflineManager.synchronizeForOffline(false, false, false, true, msgWindow);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// online?
|
||||
function CheckOnline()
|
||||
{
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
return (!ioService.offline);
|
||||
}
|
||||
|
||||
// Init Pref Service & Offline Manager
|
||||
function InitServices()
|
||||
{
|
||||
if (!gMailOfflinePrefs)
|
||||
GetMailOfflinePrefs();
|
||||
|
||||
if (!gOfflineManager)
|
||||
GetOfflineMgrService();
|
||||
}
|
||||
|
||||
// Init Offline Manager
|
||||
function GetOfflineMgrService()
|
||||
{
|
||||
if (!gOfflineManager) {
|
||||
gOfflineManager = Components.classes["@mozilla.org/messenger/offline-manager;1"]
|
||||
.getService(Components.interfaces.nsIMsgOfflineManager);
|
||||
}
|
||||
}
|
||||
|
||||
// This function must always return false to prevent toggling of offline state because
|
||||
// we change the offline state ourselves
|
||||
function MailCheckBeforeOfflineChange()
|
||||
{
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
|
||||
var goingOnline = ioService.offline;
|
||||
var bundle = srGetStrBundle("chrome://communicator/locale/utilityOverlay.properties");
|
||||
|
||||
// messenger.SetWindow(window, msgWindow);
|
||||
|
||||
InitServices();
|
||||
|
||||
var prefSendUnsentMessages = gMailOfflinePrefs.getIntPref("offline.send.unsent_messages");
|
||||
var prefDownloadMessages = gMailOfflinePrefs.getIntPref("offline.download.download_messages");
|
||||
|
||||
if(goingOnline) {
|
||||
switch(prefSendUnsentMessages) {
|
||||
case 0:
|
||||
if(CheckForUnsentMessages()) {
|
||||
if(! PromptSendMessages())
|
||||
return false;
|
||||
if (am)
|
||||
{
|
||||
allIdentities = am.allIdentities;
|
||||
identitiesCount = allIdentities.Count();
|
||||
for (var i = 0; i < identitiesCount; i++)
|
||||
{
|
||||
currentIdentity = allIdentities.QueryElementAt(i, Components.interfaces.nsIMsgIdentity);
|
||||
msgFolder = msgSendlater.getUnsentMessagesFolder(currentIdentity);
|
||||
if(msgFolder)
|
||||
{
|
||||
// if true, descends into all subfolders
|
||||
numMessages = msgFolder.getTotalMessages(false);
|
||||
if(numMessages > 0)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
gOfflineManager.goOnline(false /* sendUnsentMessages */,
|
||||
true /* playbackOfflineImapOperations */,
|
||||
msgWindow);
|
||||
break;
|
||||
case 1:
|
||||
gOfflineManager.goOnline(CheckForUnsentMessages() /* sendUnsentMessages */,
|
||||
true /* playbackOfflineImapOperations */,
|
||||
msgWindow);
|
||||
break;
|
||||
case 2:
|
||||
gOfflineManager.goOnline(false /* sendUnsentMessages */,
|
||||
true /* playbackOfflineImapOperations */,
|
||||
msgWindow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// going offline
|
||||
switch(prefDownloadMessages) {
|
||||
case 0:
|
||||
if(! PromptDownloadMessages()) return false;
|
||||
break;
|
||||
case 1:
|
||||
// download news, download mail, send unsent messages, go offline when done, msg window
|
||||
gOfflineManager.synchronizeForOffline(true, true, false, true, msgWindow);
|
||||
break;
|
||||
case 2:
|
||||
// download news, download mail, send unsent messages, go offline when done, msg window
|
||||
gOfflineManager.synchronizeForOffline(false, false, false, true, msgWindow);
|
||||
break;
|
||||
catch(ex) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* open the offline panel in the account manager for the currently loaded
|
||||
* account.
|
||||
*/
|
||||
openOfflineAccountSettings: function()
|
||||
{
|
||||
window.parent.MsgAccountManager('am-offline.xul');
|
||||
},
|
||||
|
||||
/**
|
||||
* Prompt the user about going online to send unsent messages, and then send them
|
||||
* if appropriate. Puts the app back into online mode.
|
||||
*
|
||||
* @param aMsgWindow the msg window to be used when going online
|
||||
*/
|
||||
goOnlineToSendMessages: function(aMsgWindow)
|
||||
{
|
||||
const nsIPS = Components.interfaces.nsIPromptService;
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(nsIPS);
|
||||
var goOnlineToSendMsgs = promptService.confirm(window,
|
||||
this.offlineBundle.getString('sendMessagesOfflineWindowTitle1'),
|
||||
this.offlineBundle.getString('sendMessagesOfflineLabel1'));
|
||||
if (goOnlineToSendMsgs)
|
||||
this.offlineManager.goOnline(true /* send unsent messages*/, false, aMsgWindow);
|
||||
},
|
||||
|
||||
/**
|
||||
* Prompts the user to confirm sending of unsent messages. This is different from
|
||||
* goOnlineToSendMessages which involves going online to send unsent messages.
|
||||
*
|
||||
* @return true if the user wants to send unsent messages
|
||||
*/
|
||||
confirmSendUnsentMessages: function()
|
||||
{
|
||||
const nsIPS = Components.interfaces.nsIPromptService;
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(nsIPS);
|
||||
var alwaysAsk = {value: true};
|
||||
var sendUnsentMessages = promptService.confirmEx(window,
|
||||
this.offlineBundle.getString('sendMessagesWindowTitle1'),
|
||||
this.offlineBundle.getString('sendMessagesLabel1'),
|
||||
nsIPS.STD_YES_NO_BUTTONS,
|
||||
null, null, null,
|
||||
this.offlineBundle.getString('sendMessagesCheckboxLabel1'),
|
||||
alwaysAsk) == 0 ? true : false;
|
||||
|
||||
// if the user changed the ask me setting then update the global pref based on their yes / no answer
|
||||
if (!alwaysAsk.value)
|
||||
gPrefBranch.setIntPref("offline.send.unsent_messages", sendUnsentMessages ? 1 : 2);
|
||||
return sendUnsentMessages;
|
||||
},
|
||||
|
||||
/**
|
||||
* Should we send unsent messages? Based on the value of
|
||||
* offline.send.unsent_messages, this method may prompt the user.
|
||||
* @return true if we should send unsent messages
|
||||
*/
|
||||
shouldSendUnsentMessages: function()
|
||||
{
|
||||
// if we are online already, and we have unsent messages, then honor the
|
||||
// offline.send.unsent_messages pref.
|
||||
if (this.isOnline() && this.haveUnsentMessages())
|
||||
{
|
||||
var sendUnsentWhenGoingOnlinePref = gPrefBranch.getIntPref("offline.send.unsent_messages");
|
||||
if ((sendUnsentWhenGoingOnlinePref == 0 && this.confirmSendUnsentMessages()) || sendUnsentWhenGoingOnlinePref == 1)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Prompts the user to download messages for offline use before going offline.
|
||||
* May update the value of offline.download.download_messages
|
||||
*
|
||||
* @return true if the user wants to download messages for offline use.
|
||||
*/
|
||||
confirmDownloadMessagesForOfflineUse: function()
|
||||
{
|
||||
const nsIPS = Components.interfaces.nsIPromptService;
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(nsIPS);
|
||||
var alwaysAsk = {value: true};
|
||||
var downloadMessages = promptService.confirmEx(window,
|
||||
this.offlineBundle.getString('downloadMessagesWindowTitle1'),
|
||||
this.offlineBundle.getString('downloadMessagesLabel1'),
|
||||
nsIPS.STD_YES_NO_BUTTONS,
|
||||
null, null, null,
|
||||
this.offlineBundle.getString('downloadMessagesCheckboxLabel1'),
|
||||
alwaysAsk) == 0 ? true : false;
|
||||
|
||||
// if the user changed the ask me setting then update the global pref based on their yes / no answer
|
||||
if (!alwaysAsk.value)
|
||||
gPrefBranch.setIntPref("offline.download.download_messages", downloadMessages ? 1 : 2);
|
||||
return downloadMessages;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get New Mail When Offline
|
||||
* Prompts the user about going online in order to download new messages.
|
||||
* Based on the response, will move us back to online mode.
|
||||
*
|
||||
* @return true if the user confirms going online.
|
||||
*/
|
||||
getNewMail: function()
|
||||
{
|
||||
const nsIPS = Components.interfaces.nsIPromptService;
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(nsIPS);
|
||||
var goOnline = promptService.confirm(window,
|
||||
this.offlineBundle.getString('getMessagesOfflineWindowTitle1'),
|
||||
this.offlineBundle.getString('getMessagesOfflineLabel1'));
|
||||
if (goOnline)
|
||||
this.offlineManager.goOnline(this.haveUnsentMessages() && this.confirmSendUnsentMessages(),
|
||||
false /* playbackOfflineImapOperations */, msgWindow);
|
||||
return goOnline;
|
||||
},
|
||||
|
||||
/**
|
||||
* Private helper method to update the state of the Offline menu item
|
||||
* and the offline status bar indicator
|
||||
*/
|
||||
updateOfflineUI: function(aIsOffline)
|
||||
{
|
||||
document.getElementById('goOfflineMenuItem').setAttribute("checked", aIsOffline);
|
||||
var statusBarPanel = document.getElementById('offline-status');
|
||||
if (aIsOffline)
|
||||
{
|
||||
statusBarPanel.setAttribute("offline", "true");
|
||||
statusBarPanel.setAttribute("tooltiptext", this.offlineBundle.getString("offlineTooltip"));
|
||||
}
|
||||
else
|
||||
{
|
||||
statusBarPanel.removeAttribute("offline");
|
||||
statusBarPanel.setAttribute("tooltiptext", this.offlineBundle.getString("onlineTooltip"));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* private helper method called whenever we detect a change to the offline state
|
||||
*/
|
||||
mailOfflineStateChanged: function (aGoingOffline)
|
||||
{
|
||||
gFolderJustSwitched = true;
|
||||
this.updateOfflineUI(aGoingOffline);
|
||||
},
|
||||
};
|
||||
|
||||
@ -232,7 +232,7 @@ var DefaultController =
|
||||
case "cmd_downloadFlagged":
|
||||
case "cmd_downloadSelected":
|
||||
case "cmd_synchronizeOffline":
|
||||
return(CheckOnline());
|
||||
return MailOfflineMgr.isOnline();
|
||||
|
||||
case "cmd_watchThread":
|
||||
case "cmd_killThread":
|
||||
@ -421,11 +421,11 @@ var DefaultController =
|
||||
case "cmd_close":
|
||||
return true;
|
||||
case "cmd_downloadFlagged":
|
||||
return(CheckOnline());
|
||||
return(IsFolderSelected() && MailOfflineMgr.isOnline());
|
||||
case "cmd_downloadSelected":
|
||||
return (IsFolderSelected() && CheckOnline() && GetNumSelectedMessages() > 0);
|
||||
return (IsFolderSelected() && MailOfflineMgr.isOnline() && GetNumSelectedMessages() > 0);
|
||||
case "cmd_synchronizeOffline":
|
||||
return CheckOnline() && IsAccountOfflineEnabled();
|
||||
return MailOfflineMgr.isOnline() && IsAccountOfflineEnabled();
|
||||
case "cmd_settingsOffline":
|
||||
return IsAccountOfflineEnabled();
|
||||
case "cmd_moveToFolderAgain":
|
||||
@ -675,7 +675,7 @@ var DefaultController =
|
||||
MsgSynchronizeOffline();
|
||||
break;
|
||||
case "cmd_settingsOffline":
|
||||
MsgSettingsOffline();
|
||||
MailOfflineMgr.openOfflineAccountSettings();
|
||||
break;
|
||||
case "cmd_moveToFolderAgain":
|
||||
var folderId = pref.getCharPref("mail.last_msg_movecopy_target_uri");
|
||||
|
||||
@ -372,7 +372,7 @@ function SetupNewMenuItem(folderResource, numSelected, isServer, serverType,spec
|
||||
var showNew = ((numSelected <=1) && (serverType != 'nntp') && canCreateNew) || isInbox;
|
||||
ShowMenuItem("folderPaneContext-new", showNew);
|
||||
|
||||
EnableMenuItem("folderPaneContext-new", !isIMAPFolder || !ioService.offline);
|
||||
EnableMenuItem("folderPaneContext-new", !isIMAPFolder || MailOfflineMgr.isOnline());
|
||||
|
||||
if (showNew)
|
||||
{
|
||||
|
||||
@ -42,15 +42,10 @@
|
||||
var messengerContractID = "@mozilla.org/messenger;1";
|
||||
var statusFeedbackContractID = "@mozilla.org/messenger/statusfeedback;1";
|
||||
var mailSessionContractID = "@mozilla.org/messenger/services/session;1";
|
||||
var secureUIContractID = "@mozilla.org/secure_browser_ui;1";
|
||||
|
||||
|
||||
var prefContractID = "@mozilla.org/preferences-service;1";
|
||||
var msgWindowContractID = "@mozilla.org/messenger/msgwindow;1";
|
||||
|
||||
var messenger;
|
||||
var pref;
|
||||
var prefServices;
|
||||
var statusFeedback;
|
||||
var msgWindow;
|
||||
|
||||
@ -84,11 +79,10 @@ var gFakeAccountPageLoaded = false;
|
||||
|
||||
// for checking if the folder loaded is Draft or Unsent which msg is editable
|
||||
var gIsEditableMsgFolder = false;
|
||||
var gOfflineManager;
|
||||
|
||||
function OnMailWindowUnload()
|
||||
{
|
||||
RemoveMailOfflineObserver();
|
||||
MailOfflineMgr.uninit();
|
||||
ClearPendingReadTimer();
|
||||
|
||||
var searchSession = GetSearchSession();
|
||||
@ -142,8 +136,8 @@ function CreateMailWindowGlobals()
|
||||
// get the messenger instance
|
||||
CreateMessenger();
|
||||
|
||||
prefServices = Components.classes[prefContractID].getService(Components.interfaces.nsIPrefService);
|
||||
pref = prefServices.getBranch(null);
|
||||
pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch2);
|
||||
|
||||
//Create windows status feedback
|
||||
// set the JS implementation of status feedback before creating the c++ one..
|
||||
@ -160,29 +154,6 @@ function CreateMailWindowGlobals()
|
||||
statusFeedback = statusFeedback.QueryInterface(Components.interfaces.nsIMsgStatusFeedback);
|
||||
statusFeedback.setWrappedStatusFeedback(window.MsgStatusFeedback);
|
||||
|
||||
/*
|
||||
not in use unless we want the lock button back
|
||||
|
||||
// try to create and register ourselves with a security icon...
|
||||
var securityIcon = document.getElementById("security-button");
|
||||
if (securityIcon) {
|
||||
// if the client isn't built with psm enabled then we won't have a secure UI to monitor the lock icon
|
||||
// so be sure to wrap this in a try / catch clause...
|
||||
try {
|
||||
var secureUI;
|
||||
// we may not have a secure UI if psm isn't installed!
|
||||
if (secureUIContractID in Components.classes) {
|
||||
secureUI = Components.classes[secureUIContractID].createInstance();
|
||||
if (secureUI) {
|
||||
secureUI = secureUI.QueryInterface(Components.interfaces.nsISecureBrowserUI);
|
||||
secureUI.init(_content, securityIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ex) {}
|
||||
}
|
||||
*/
|
||||
|
||||
//Create message window object
|
||||
msgWindow = Components.classes[msgWindowContractID].createInstance();
|
||||
msgWindow = msgWindow.QueryInterface(Components.interfaces.nsIMsgWindow);
|
||||
@ -605,12 +576,10 @@ function OpenInboxForServer(server)
|
||||
var inboxFolder = GetInboxFolder(server);
|
||||
SelectFolder(inboxFolder.URI);
|
||||
|
||||
if(CheckOnline()) {
|
||||
if (MailOfflineMgr.isOnline() || MailOfflineMgr.getNewMail()) {
|
||||
if (server.type != "imap")
|
||||
GetMessagesForInboxOnServer(server);
|
||||
}
|
||||
else if (DoGetNewMailWhenOffline())
|
||||
GetMessagesForInboxOnServer(server);
|
||||
}
|
||||
catch (ex) {
|
||||
dump("Error opening inbox for server -> " + ex + "\n");
|
||||
|
||||
@ -71,9 +71,6 @@ const kMsgNotificationJunkBar = 2;
|
||||
const kMsgNotificationRemoteImages = 3;
|
||||
|
||||
var gMessengerBundle;
|
||||
var gPromptService;
|
||||
var gOfflinePromptsBundle;
|
||||
var gOfflineManager;
|
||||
var gWindowManagerInterface;
|
||||
var gPrefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch(null);
|
||||
var gPrintSettings = null;
|
||||
@ -129,7 +126,7 @@ function menu_new_init()
|
||||
ShowMenuItem("menu_newFolder", showNew);
|
||||
ShowMenuItem("menu_newVirtualFolder", showNew);
|
||||
|
||||
EnableMenuItem("menu_newFolder", !isIMAPFolder || !ioService.offline);
|
||||
EnableMenuItem("menu_newFolder", !isIMAPFolder || MailOfflineMgr.isOnline());
|
||||
EnableMenuItem("menu_newVirtualFolder", true);
|
||||
if (showNew)
|
||||
SetMenuItemLabel("menu_newFolder", gMessengerBundle.getString((isServer || isInbox) ? "newFolderMenuItem" : "newSubfolderMenuItem"));
|
||||
@ -982,11 +979,9 @@ function GetMessagesForInboxOnServer(server)
|
||||
function MsgGetMessage()
|
||||
{
|
||||
// if offline, prompt for getting messages
|
||||
if(CheckOnline())
|
||||
if (MailOfflineMgr.isOnline() || MailOfflineMgr.getNewMail())
|
||||
GetFolderMessages();
|
||||
else if (DoGetNewMailWhenOffline())
|
||||
GetFolderMessages();
|
||||
}
|
||||
}
|
||||
|
||||
function MsgGetMessagesForAllServers(defaultServer)
|
||||
{
|
||||
@ -1044,11 +1039,9 @@ function MsgGetMessagesForAllServers(defaultServer)
|
||||
*/
|
||||
function MsgGetMessagesForAllAuthenticatedAccounts()
|
||||
{
|
||||
if(CheckOnline())
|
||||
if (MailOfflineMgr.isOnline() || MailOfflineMgr.getNewMail())
|
||||
GetMessagesForAllAuthenticatedAccounts();
|
||||
else if (DoGetNewMailWhenOffline())
|
||||
GetMessagesForAllAuthenticatedAccounts();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get messages for the account selected from Menu dropdowns.
|
||||
@ -1059,30 +1052,21 @@ function MsgGetMessagesForAccount(aEvent)
|
||||
if (!aEvent)
|
||||
return;
|
||||
|
||||
if(CheckOnline())
|
||||
if (MailOfflineMgr.isOnline() || MailOfflineMgr.getNewMail())
|
||||
GetMessagesForAccount(aEvent);
|
||||
else if (DoGetNewMailWhenOffline())
|
||||
GetMessagesForAccount(aEvent);
|
||||
}
|
||||
}
|
||||
|
||||
// if offline, prompt for getNextNMessages
|
||||
function MsgGetNextNMessages()
|
||||
{
|
||||
var folder;
|
||||
|
||||
if(CheckOnline()) {
|
||||
if (MailOfflineMgr.isOnline() || MailOfflineMgr.getNewMail())
|
||||
{
|
||||
folder = GetFirstSelectedMsgFolder();
|
||||
if(folder)
|
||||
if (folder)
|
||||
GetNextNMessages(folder);
|
||||
}
|
||||
|
||||
else if(DoGetNewMailWhenOffline()) {
|
||||
folder = GetFirstSelectedMsgFolder();
|
||||
if(folder) {
|
||||
GetNextNMessages(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function MsgDeleteMessage(reallyDelete, fromToolbar)
|
||||
{
|
||||
@ -1434,12 +1418,13 @@ function MsgOpenSelectedMessages()
|
||||
|
||||
var openWindowWarning = gPrefBranch.getIntPref("mailnews.open_window_warning");
|
||||
if ((openWindowWarning > 1) && (numMessages >= openWindowWarning)) {
|
||||
InitPrompts();
|
||||
if (!gMessengerBundle)
|
||||
gMessengerBundle = document.getElementById("bundle_messenger");
|
||||
var title = gMessengerBundle.getString("openWindowWarningTitle");
|
||||
var text = gMessengerBundle.getFormattedString("openWindowWarningText", [numMessages]);
|
||||
if (!gPromptService.confirm(window, title, text))
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
if (!promptService.confirm(window, title, text))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1797,20 +1782,10 @@ function MsgStop()
|
||||
function MsgSendUnsentMsgs()
|
||||
{
|
||||
// if offline, prompt for sendUnsentMessages
|
||||
if(CheckOnline()) {
|
||||
SendUnsentMessages();
|
||||
}
|
||||
else {
|
||||
var option = PromptSendMessagesOffline();
|
||||
if(option == 0) {
|
||||
if (!gOfflineManager)
|
||||
GetOfflineMgrService();
|
||||
gOfflineManager.goOnline(false /* sendUnsentMessages */,
|
||||
false /* playbackOfflineImapOperations */,
|
||||
msgWindow);
|
||||
SendUnsentMessages();
|
||||
}
|
||||
}
|
||||
if (MailOfflineMgr.isOnline())
|
||||
SendUnsentMessages();
|
||||
else
|
||||
MailOfflineMgr.goOnlineToSendMessages(msgWindow);
|
||||
}
|
||||
|
||||
function GetPrintSettings()
|
||||
@ -1989,9 +1964,8 @@ function getMarkupDocumentViewer()
|
||||
|
||||
function MsgSynchronizeOffline()
|
||||
{
|
||||
//dump("in MsgSynchronize() \n");
|
||||
window.openDialog("chrome://messenger/content/msgSynchronize.xul",
|
||||
"", "centerscreen,chrome,modal,titlebar,resizable=yes",{msgWindow:msgWindow});
|
||||
window.openDialog("chrome://messenger/content/msgSynchronize.xul",
|
||||
"", "centerscreen,chrome,modal,titlebar,resizable=yes",{msgWindow:msgWindow});
|
||||
}
|
||||
|
||||
|
||||
@ -2056,80 +2030,6 @@ function IsAccountOfflineEnabled()
|
||||
return false;
|
||||
}
|
||||
|
||||
// init nsIPromptService and strings
|
||||
function InitPrompts()
|
||||
{
|
||||
if(!gPromptService) {
|
||||
gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
|
||||
gPromptService = gPromptService.QueryInterface(Components.interfaces.nsIPromptService);
|
||||
}
|
||||
if (!gOfflinePromptsBundle)
|
||||
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()
|
||||
{
|
||||
var buttonPressed = false;
|
||||
InitPrompts();
|
||||
if (gPromptService) {
|
||||
var checkValue = {value:false};
|
||||
buttonPressed = gPromptService.confirmEx(window,
|
||||
gOfflinePromptsBundle.getString('getMessagesOfflineWindowTitle'),
|
||||
gOfflinePromptsBundle.getString('getMessagesOfflineLabel'),
|
||||
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_0) +
|
||||
(gPromptService.BUTTON_TITLE_CANCEL * gPromptService.BUTTON_POS_1),
|
||||
gOfflinePromptsBundle.getString('getMessagesOfflineGoButtonLabel'),
|
||||
null, null, null, checkValue);
|
||||
}
|
||||
return buttonPressed;
|
||||
}
|
||||
|
||||
// prompt for sending messages when offline
|
||||
function PromptSendMessagesOffline()
|
||||
{
|
||||
var buttonPressed = false;
|
||||
InitPrompts();
|
||||
if (gPromptService) {
|
||||
var checkValue= {value:false};
|
||||
buttonPressed = gPromptService.confirmEx(window,
|
||||
gOfflinePromptsBundle.getString('sendMessagesOfflineWindowTitle'),
|
||||
gOfflinePromptsBundle.getString('sendMessagesOfflineLabel'),
|
||||
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_0) +
|
||||
(gPromptService.BUTTON_TITLE_CANCEL * gPromptService.BUTTON_POS_1),
|
||||
gOfflinePromptsBundle.getString('sendMessagesOfflineGoButtonLabel'),
|
||||
null, null, null, checkValue, buttonPressed);
|
||||
}
|
||||
return buttonPressed;
|
||||
}
|
||||
|
||||
function GetDefaultAccountRootFolder()
|
||||
{
|
||||
try {
|
||||
|
||||
@ -1216,10 +1216,11 @@
|
||||
<menuseparator id="trashMenuSeparator"/>
|
||||
<menu id="offlineMenuItem" label="&offlineMenu.label;" accesskey="&offlineMenu.accesskey;">
|
||||
<menupopup>
|
||||
<menuitem id="offlineGoOfflineCmd"/>
|
||||
<menuitem id="goOfflineMenuItem" type="checkbox" label="&offlineGoOfflineCmd.label;"
|
||||
accesskey="&offlineGoOfflineCmd.accesskey;" oncommand="MailOfflineMgr.toggleOfflineStatus();"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&synchronizeOfflineCmd.label;" accesskey="&synchronizeOfflineCmd.accesskey;" observes="cmd_synchronizeOffline"/>
|
||||
<menuitem label="&settingsOfflineCmd.label;" accesskey="&settingsOfflineCmd.accesskey;" oncommand="openOptionsDialog('paneAdvanced', 'offlineTab');"/>
|
||||
<menuitem label="&settingsOfflineCmd.label;" accesskey="&settingsOfflineCmd.accesskey;" observes="cmd_settingsOffline"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&downloadStarredCmd.label;" accesskey="&downloadStarredCmd.accesskey;" observes="cmd_downloadFlagged"/>
|
||||
<menuitem label="&downloadSelectedCmd.label;" accesskey="&downloadSelectedCmd.accesskey;" observes="cmd_downloadSelected"/>
|
||||
@ -2201,7 +2202,7 @@
|
||||
|
||||
<statusbar class="chromeclass-status" id="status-bar">
|
||||
<hbox insertbefore="unreadMessageCount" id="statusTextBox" flex="1">
|
||||
<statusbarpanel checkfunc="MailCheckBeforeOfflineChange()" id="offline-status" class="statusbarpanel-iconic"/>
|
||||
<statusbarpanel id="offline-status" class="statusbarpanel-iconic" oncommand="MailOfflineMgr.toggleOfflineStatus();"/>
|
||||
<statusbarpanel id="statusText" label="&statusText.label;" flex="1"/>
|
||||
<statusbarpanel class="statusbarpanel-progress" collapsed="true" id="statusbar-progresspanel">
|
||||
<progressmeter class="progressmeter-statusbar" id="statusbar-icon" mode="normal" value="0"/>
|
||||
|
||||
@ -256,7 +256,7 @@ function delayedOnLoadMessageWindow()
|
||||
HideMenus();
|
||||
HideToolbarButtons();
|
||||
ShowMenus();
|
||||
AddMailOfflineObserver();
|
||||
MailOfflineMgr.init();
|
||||
CreateMailWindowGlobals();
|
||||
CreateMessageWindowGlobals();
|
||||
verifyAccounts(null);
|
||||
@ -833,7 +833,7 @@ var MessageWindowController =
|
||||
case "cmd_synchronizeOffline":
|
||||
case "cmd_downloadFlagged":
|
||||
case "cmd_downloadSelected":
|
||||
return CheckOnline();
|
||||
return MailOfflineMgr.isOnline();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -904,9 +904,9 @@ var MessageWindowController =
|
||||
case "cmd_downloadFlagged":
|
||||
case "cmd_downloadSelected":
|
||||
case "cmd_synchronizeOffline":
|
||||
return CheckOnline();
|
||||
return MailOfflineMgr.isOnline();
|
||||
case "cmd_settingsOffline":
|
||||
return IsAccountOfflineEnabled();
|
||||
return IsAccountOfflineEnabled();
|
||||
case "cmd_close":
|
||||
case "cmd_nextMsg":
|
||||
case "button_next":
|
||||
@ -1092,7 +1092,7 @@ var MessageWindowController =
|
||||
MsgSynchronizeOffline();
|
||||
return;
|
||||
case "cmd_settingsOffline":
|
||||
MsgSettingsOffline();
|
||||
MailOfflineMgr.openOfflineAccountSettings();
|
||||
return;
|
||||
case "cmd_nextUnreadMsg":
|
||||
case "button_next":
|
||||
|
||||
@ -1113,7 +1113,7 @@ function detachAttachment(aAttachment, aSaveFirst)
|
||||
function CanDetachAttachments()
|
||||
{
|
||||
var uri = GetLoadedMessage();
|
||||
var canDetach = !IsNewsMessage(uri) && (!IsImapMessage(uri) || CheckOnline());
|
||||
var canDetach = !IsNewsMessage(uri) && (!IsImapMessage(uri) || MailOfflineMgr.isOnline());
|
||||
if (canDetach && ("content-type" in currentHeaderData))
|
||||
{
|
||||
var contentType = currentHeaderData["content-type"].headerValue;
|
||||
@ -1413,7 +1413,7 @@ function addAttachmentToPopup(popup, attachment, attachmentIndex)
|
||||
}
|
||||
var canDetach = !(/news-message:/.test(attachment.uri)) &&
|
||||
!signedOrEncrypted &&
|
||||
(!(/imap-message/.test(attachment.uri)) || CheckOnline());
|
||||
(!(/imap-message/.test(attachment.uri)) || MailOfflineMgr.isOnline());
|
||||
menuitementry.setAttribute('label', gOpenLabel);
|
||||
menuitementry.setAttribute('accesskey', gOpenLabelAccesskey);
|
||||
menuitementry = openpopup.appendChild(menuitementry);
|
||||
|
||||
@ -822,7 +822,7 @@ function delayedOnLoadMessenger()
|
||||
pref.addObserver("mail.pane_config.dynamic", MailPrefObserver, false);
|
||||
pref.addObserver("mail.showFolderPaneColumns", MailPrefObserver, false);
|
||||
|
||||
AddMailOfflineObserver();
|
||||
MailOfflineMgr.init();
|
||||
CreateMailWindowGlobals();
|
||||
accountCentralBox = document.getElementById("accountCentralBox");
|
||||
GetMessagePane().collapsed = true;
|
||||
@ -1001,46 +1001,22 @@ function loadStartFolder(initialUri)
|
||||
// and we aren't supposed to initially download mail. (Bug #270743)
|
||||
if (gLoadStartFolder)
|
||||
MsgGetMessagesForAllServers(defaultServer);
|
||||
|
||||
if (this.CheckForUnsentMessages != undefined && CheckForUnsentMessages())
|
||||
{
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
|
||||
if (!ioService.offline)
|
||||
{
|
||||
InitPrompts();
|
||||
InitServices();
|
||||
|
||||
var sendUnsentWhenGoingOnlinePref = pref.getIntPref("offline.send.unsent_messages");
|
||||
if(gPromptService && sendUnsentWhenGoingOnlinePref == 0) // pref is "ask"
|
||||
{
|
||||
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();
|
||||
}
|
||||
else if(sendUnsentWhenGoingOnlinePref == 1) // pref is "yes"
|
||||
SendUnsentMessages();
|
||||
}
|
||||
}
|
||||
|
||||
// if appropriate, send unsent messages. This may end up prompting the user
|
||||
if (MailOfflineMgr.shouldSendUnsentMessages())
|
||||
SendUnsentMessages();
|
||||
}
|
||||
|
||||
function AddToSession()
|
||||
{
|
||||
try {
|
||||
var mailSession = Components.classes[mailSessionContractID].getService(Components.interfaces.nsIMsgMailSession);
|
||||
|
||||
var nsIFolderListener = Components.interfaces.nsIFolderListener;
|
||||
var notifyFlags = nsIFolderListener.intPropertyChanged | nsIFolderListener.event;
|
||||
mailSession.AddFolderListener(folderListener, notifyFlags);
|
||||
try {
|
||||
var mailSession = Components.classes[mailSessionContractID].getService(Components.interfaces.nsIMsgMailSession);
|
||||
var nsIFolderListener = Components.interfaces.nsIFolderListener;
|
||||
var notifyFlags = nsIFolderListener.intPropertyChanged | nsIFolderListener.event;
|
||||
mailSession.AddFolderListener(folderListener, notifyFlags);
|
||||
} catch (ex) {
|
||||
dump("Error adding to session\n");
|
||||
}
|
||||
dump("Error adding to session\n");
|
||||
}
|
||||
}
|
||||
|
||||
function InitPanes()
|
||||
|
||||
190
mozilla/mail/base/content/utilityOverlay.js
Normal file
190
mozilla/mail/base/content/utilityOverlay.js
Normal file
@ -0,0 +1,190 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* Communicator Shared Utility Library
|
||||
* for shared application glue for the Communicator suite of applications
|
||||
**/
|
||||
|
||||
/*
|
||||
Note: All Editor/Composer-related methods have been moved to editorApplicationOverlay.js,
|
||||
so app windows that require those must include editorNavigatorOverlay.xul
|
||||
*/
|
||||
|
||||
var gShowBiDi = false;
|
||||
|
||||
function GetStringPref(name)
|
||||
{
|
||||
try {
|
||||
return pref.getComplexValue(name, Components.interfaces.nsISupportsString).data;
|
||||
} catch (e) {}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
var goPrefWindow = 0;
|
||||
|
||||
function getBrowserURL() {
|
||||
|
||||
try {
|
||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
var url = prefs.getCharPref("browser.chromeURL");
|
||||
if (url)
|
||||
return url;
|
||||
} catch(e) {
|
||||
}
|
||||
return "chrome://navigator/content/navigator.xul";
|
||||
}
|
||||
|
||||
// update menu items that rely on focus
|
||||
function goUpdateGlobalEditMenuItems()
|
||||
{
|
||||
goUpdateCommand('cmd_undo');
|
||||
goUpdateCommand('cmd_redo');
|
||||
goUpdateCommand('cmd_cut');
|
||||
goUpdateCommand('cmd_copy');
|
||||
goUpdateCommand('cmd_paste');
|
||||
goUpdateCommand('cmd_selectAll');
|
||||
goUpdateCommand('cmd_delete');
|
||||
if (gShowBiDi)
|
||||
goUpdateCommand('cmd_switchTextDirection');
|
||||
}
|
||||
|
||||
// update menu items that rely on the current selection
|
||||
function goUpdateSelectEditMenuItems()
|
||||
{
|
||||
goUpdateCommand('cmd_cut');
|
||||
goUpdateCommand('cmd_copy');
|
||||
goUpdateCommand('cmd_delete');
|
||||
goUpdateCommand('cmd_selectAll');
|
||||
}
|
||||
|
||||
// update menu items that relate to undo/redo
|
||||
function goUpdateUndoEditMenuItems()
|
||||
{
|
||||
goUpdateCommand('cmd_undo');
|
||||
goUpdateCommand('cmd_redo');
|
||||
}
|
||||
|
||||
// update menu items that depend on clipboard contents
|
||||
function goUpdatePasteMenuItems()
|
||||
{
|
||||
goUpdateCommand('cmd_paste');
|
||||
}
|
||||
|
||||
// update Find As You Type menu items, they rely on focus
|
||||
function goUpdateFindTypeMenuItems()
|
||||
{
|
||||
goUpdateCommand('cmd_findTypeText');
|
||||
goUpdateCommand('cmd_findTypeLinks');
|
||||
}
|
||||
|
||||
// Gather all descendent text under given document node.
|
||||
function gatherTextUnder ( root )
|
||||
{
|
||||
var text = "";
|
||||
var node = root.firstChild;
|
||||
var depth = 1;
|
||||
while ( node && depth > 0 ) {
|
||||
// See if this node is text.
|
||||
if ( node.nodeType == Node.TEXT_NODE ) {
|
||||
// Add this text to our collection.
|
||||
text += " " + node.data;
|
||||
} else if ( node instanceof HTMLImageElement ) {
|
||||
// If it has an alt= attribute, use that.
|
||||
var altText = node.getAttribute( "alt" );
|
||||
if ( altText && altText != "" ) {
|
||||
text = altText;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Find next node to test.
|
||||
// First, see if this node has children.
|
||||
if ( node.hasChildNodes() ) {
|
||||
// Go to first child.
|
||||
node = node.firstChild;
|
||||
depth++;
|
||||
} else {
|
||||
// No children, try next sibling.
|
||||
if ( node.nextSibling ) {
|
||||
node = node.nextSibling;
|
||||
} else {
|
||||
// Last resort is our next oldest uncle/aunt.
|
||||
node = node.parentNode.nextSibling;
|
||||
depth--;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Strip leading whitespace.
|
||||
text = text.replace( /^\s+/, "" );
|
||||
// Strip trailing whitespace.
|
||||
text = text.replace( /\s+$/, "" );
|
||||
// Compress remaining whitespace.
|
||||
text = text.replace( /\s+/g, " " );
|
||||
return text;
|
||||
}
|
||||
|
||||
function GenerateValidFilename(filename, extension)
|
||||
{
|
||||
if (filename) // we have a title; let's see if it's usable
|
||||
{
|
||||
// clean up the filename to make it usable and
|
||||
// then trim whitespace from beginning and end
|
||||
filename = validateFileName(filename).replace(/^\s+|\s+$/g, "");
|
||||
if (filename.length > 0)
|
||||
return filename + extension;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function validateFileName(aFileName)
|
||||
{
|
||||
var re = /[\/]+/g;
|
||||
if (navigator.appVersion.indexOf("Windows") != -1) {
|
||||
re = /[\\\/\|]+/g;
|
||||
aFileName = aFileName.replace(/[\"]+/g, "'");
|
||||
aFileName = aFileName.replace(/[\*\:\?]+/g, " ");
|
||||
aFileName = aFileName.replace(/[\<]+/g, "(");
|
||||
aFileName = aFileName.replace(/[\>]+/g, ")");
|
||||
}
|
||||
else if (navigator.appVersion.indexOf("Macintosh") != -1)
|
||||
re = /[\:\/]+/g;
|
||||
|
||||
return aFileName.replace(re, "_");
|
||||
}
|
||||
@ -15,16 +15,7 @@
|
||||
|
||||
<script type="application/x-javascript" src="chrome://global/content/strres.js"/>
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/utilityOverlay.js"/>
|
||||
|
||||
<!-- online/offline status indicators -->
|
||||
<broadcaster id="Communicator:WorkMode"
|
||||
label="&offlineGoOfflineCmd.label;"
|
||||
type="checkbox"
|
||||
oncommand="toggleOfflineStatus();"/>
|
||||
|
||||
<statusbarpanel id="offline-status" observes="Communicator:WorkMode"/>
|
||||
<menuitem id="offlineGoOfflineCmd" label="&offlineGoOfflineCmd.label;" accesskey="&offlineGoOfflineCmd.accesskey;" observes="Communicator:WorkMode"/>
|
||||
|
||||
|
||||
<!-- File Menu -->
|
||||
<menu id="menu_File" label="&fileMenu.label;" accesskey="&fileMenu.accesskey;"/>
|
||||
<menu id="menu_New" label="&newMenu.label;" accesskey="&newMenu.accesskey;"/>
|
||||
|
||||
@ -122,6 +122,7 @@ messenger.jar:
|
||||
comm.jar:
|
||||
*+ content/communicator/contentAreaClick.js (content/contentAreaClick.js)
|
||||
*+ content/communicator/utilityOverlay.xul (content/utilityOverlay.xul)
|
||||
*+ content/communicator/utilityOverlay.js (content/utilityOverlay.js)
|
||||
*+ content/communicator/nsContextMenu.js (content/nsContextMenu.js)
|
||||
+ content/help/contextHelp.js (content/contextHelp.js)
|
||||
% content help %content/help/ xpcnativewrappers=yes
|
||||
|
||||
@ -673,21 +673,21 @@ function updateEditItems()
|
||||
goUpdateCommand("cmd_findPrev");
|
||||
}
|
||||
|
||||
var messageComposeOfflineObserver = {
|
||||
observe: function(subject, topic, state) {
|
||||
var messageComposeOfflineObserver =
|
||||
{
|
||||
observe: function(subject, topic, state)
|
||||
{
|
||||
// sanity checks
|
||||
if (topic != "network:offline-status-changed") return;
|
||||
if (state == "offline")
|
||||
gIsOffline = true;
|
||||
else
|
||||
gIsOffline = false;
|
||||
if (topic != "network:offline-status-changed")
|
||||
return;
|
||||
gIsOffline = state == "offline";
|
||||
MessageComposeOfflineStateChanged(gIsOffline);
|
||||
|
||||
try {
|
||||
setupLdapAutocompleteSession();
|
||||
setupLdapAutocompleteSession();
|
||||
} catch (ex) {
|
||||
// catch the exception and ignore it, so that if LDAP setup
|
||||
// fails, the entire compose window stuff doesn't get aborted
|
||||
// catch the exception and ignore it, so that if LDAP setup
|
||||
// fails, the entire compose window stuff doesn't get aborted
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,8 +168,6 @@
|
||||
|
||||
<broadcasterset id="composeBroadcasters">
|
||||
<broadcaster id="Editor:Throbber" busy="false"/>
|
||||
<broadcaster id="Communicator:WorkMode" label="&offlineGoOfflineCmd.label;"
|
||||
type="checkbox" oncommand="toggleOfflineStatus();"/>
|
||||
<broadcaster id="args" value="editorType=default"/>
|
||||
<broadcaster id="viewAddressPicker" autoCheck="false" type="checkbox" oncommand="toggleAddressPicker();"/>
|
||||
</broadcasterset>
|
||||
@ -314,7 +312,6 @@
|
||||
<menuitem type="checkbox" label="&attachVCardCmd.label;" accesskey="&attachVCardCmd.accesskey;" command="cmd_attachVCard"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menuitem id="offlineGoOfflineCmd" hidden="true" label="&offlineGoOfflineCmd.label;" accesskey="&offlineGoOfflineCmd.accesskey;" observes="Communicator:WorkMode"/>
|
||||
<menuitem id="menu_close" label="&closeCmd.label;" key="key_close" accesskey="&closeCmd.accesskey;" command="cmd_close"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&saveCmd.label;" accesskey="&saveCmd.accesskey;" key="key_save" command="cmd_saveDefault"/>
|
||||
@ -571,7 +568,6 @@
|
||||
now_tooltiptext="&sendButton.tooltip;"
|
||||
later_label="&sendLaterCmd.label;"
|
||||
later_tooltiptext="&sendlaterButton.tooltip;">
|
||||
<observes element="Communicator:WorkMode" attribute="offline"/>
|
||||
</toolbarbutton>
|
||||
|
||||
<toolbarbutton class="toolbarbutton-1"
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
<!-- these things need to move into utilityOverlay.xul -->
|
||||
<!ENTITY offlineGoOfflineCmd.label "Work Offline">
|
||||
<!ENTITY offlineGoOfflineCmd.accesskey "w">
|
||||
|
||||
<!-- LOCALIZATION NOTE : FILE This file contains the global menu items -->
|
||||
|
||||
|
||||
@ -45,6 +45,8 @@
|
||||
<!ENTITY importCmd.accesskey "I">
|
||||
<!ENTITY offlineMenu.label "Offline">
|
||||
<!ENTITY offlineMenu.accesskey "l">
|
||||
<!ENTITY offlineGoOfflineCmd.label "Work Offline">
|
||||
<!ENTITY offlineGoOfflineCmd.accesskey "w">
|
||||
<!ENTITY synchronizeOfflineCmd.label "Download/Sync Now...">
|
||||
<!ENTITY synchronizeOfflineCmd.accesskey "S">
|
||||
<!ENTITY settingsOfflineCmd.label "Offline Settings...">
|
||||
|
||||
@ -35,8 +35,6 @@
|
||||
<!ENTITY saveAsDraftCmd.accesskey "D">
|
||||
<!ENTITY saveAsTemplateCmd.label "Template">
|
||||
<!ENTITY saveAsTemplateCmd.accesskey "T">
|
||||
<!ENTITY offlineGoOfflineCmd.label "Work Offline">
|
||||
<!ENTITY offlineGoOfflineCmd.accesskey "w">
|
||||
<!ENTITY sendNowCmd.label "Send Now">
|
||||
<!ENTITY sendCmd.keycode "VK_RETURN">
|
||||
<!ENTITY sendNowCmd.accesskey "d">
|
||||
|
||||
@ -1,87 +1,20 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# LOCALIZATION NOTE :
|
||||
# do not localize "\n". use "\n" to make the text fit nicely in the dialog.
|
||||
|
||||
#
|
||||
# Download Messages Prompt
|
||||
#
|
||||
downloadMessagesWindowTitle=Work Offline
|
||||
downloadMessagesWindowTitle1=Download Messages
|
||||
downloadMessagesLabel1=Do you want to download messages for offline use before going offline?
|
||||
downloadMessagesCheckboxLabel1=Always ask me when I go offline
|
||||
|
||||
# LOCALIZATION NOTE :
|
||||
# do not localize "\n". use "\n" to make the text fit nicely in the dialog.
|
||||
downloadMessagesLabel=Do you want to download messages \nfor offline use before you go offline?\n\n
|
||||
|
||||
downloadMessagesCheckboxLabel=Always ask me when I go offline
|
||||
downloadMessagesDownloadButtonLabel=Download
|
||||
downloadMessagesNoDownloadButtonLabel=Don't Download
|
||||
downloadMessagesCancelButtonLabel=Cancel
|
||||
|
||||
#
|
||||
# Send Messages Prompt
|
||||
#
|
||||
sendMessagesWindowTitle=Work Online
|
||||
sendMessagesWindowTitle1=Unsent Messages
|
||||
sendMessagesLabel1=Do you want to send the messages in your Unsent Messages folder?
|
||||
sendMessagesCheckboxLabel1=Always ask me when I go online
|
||||
|
||||
# LOCALIZATION NOTE :
|
||||
# do not localize "\n". use "\n" to make the text fit nicely in the dialog.
|
||||
sendMessagesLabel=Would you like to send the messages \nin your Unsent Messages folder?\n\n
|
||||
sendMessagesCheckboxLabel=Always ask me when I go online
|
||||
sendMessagesSendButtonLabel=Send
|
||||
sendMessagesNoSendButtonLabel=Don't Send
|
||||
sendMessagesCancelButtonLabel=Cancel
|
||||
# GetMessages While Offline Prompt
|
||||
getMessagesOfflineWindowTitle1=Get Messages
|
||||
getMessagesOfflineLabel1=You are currently offline. Do you want to go online to get new messages?
|
||||
|
||||
#
|
||||
# GetMessages Offline Prompt
|
||||
#
|
||||
getMessagesOfflineWindowTitle=Get Messages
|
||||
|
||||
# LOCALIZATION NOTE :
|
||||
# do not localize "\n". use "\n" to make the text fit nicely in the dialog.
|
||||
getMessagesOfflineLabel=You are currently offline. Would you like \nto go online to get your new messages?\n\n
|
||||
getMessagesOfflineGoButtonLabel=Go online
|
||||
getMessagesOfflineCancelButtonLabel=Cancel
|
||||
|
||||
#
|
||||
# Send Messages Offline Prompt
|
||||
#
|
||||
sendMessagesOfflineWindowTitle=Send Messages
|
||||
sendMessagesOfflineWindowTitle1=Unsent Messages
|
||||
sendMessagesOfflineLabel=You are currently offline. Do you want to go online to send unsent messages?
|
||||
|
||||
# LOCALIZATION NOTE :
|
||||
# do not localize "\n". use "\n" to make the text fit nicely in the dialog.
|
||||
sendMessagesOfflineLabel=You are currently offline. Would you like \nto go online and send your unsent messages?\n\n
|
||||
sendMessagesOfflineGoButtonLabel=Go online
|
||||
sendMessagesOfflineCancelButtonLabel=Cancel
|
||||
offlineTooltip=You are currently offline.
|
||||
onlineTooltip=You are currently online.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user