зеркало из https://github.com/mozilla/pjs.git
move offline js stuff to its own file r=ducarroz, sr=sspitzer part of work for 83216
This commit is contained in:
Родитель
2138556093
Коммит
629a2c1b17
|
@ -63,3 +63,4 @@ mailWidgets.xml
|
|||
msgSynchronize.xul
|
||||
msgSynchronize.js
|
||||
msgSelectOffline.xul
|
||||
mail-offline.js
|
||||
|
|
|
@ -38,11 +38,6 @@ var MSG_FOLDER_FLAG_QUEUE = 0x0800;
|
|||
var MSG_FOLDER_FLAG_INBOX = 0x1000;
|
||||
var MSG_FOLDER_FLAG_TEMPLATES = 0x400000;
|
||||
|
||||
var gPrefs;
|
||||
var gOfflinePromptsBundle;
|
||||
var gPromptService;
|
||||
var gOfflineManager;
|
||||
|
||||
function OpenURL(url)
|
||||
{
|
||||
//dump("\n\nOpenURL from XUL\n\n\n");
|
||||
|
@ -844,7 +839,6 @@ function Redo()
|
|||
{
|
||||
messenger.Redo(msgWindow);
|
||||
}
|
||||
|
||||
var mailOfflineObserver = {
|
||||
Observe: function(subject, topic, state) {
|
||||
// sanity checks
|
||||
|
@ -865,248 +859,3 @@ function RemoveMailOfflineObserver()
|
|||
observerService.RemoveObserver(mailOfflineObserver,"network:offline-status-changed");
|
||||
}
|
||||
|
||||
function MailOfflineStateChanged(goingOffline)
|
||||
{
|
||||
// tweak any mail UI here that needs to change when we go offline or come back online
|
||||
}
|
||||
|
||||
// return false if you want to prevent the offline state change
|
||||
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 = gPrefs.GetIntPref("offline.send.unsent_messages");
|
||||
var prefDownloadMessages = gPrefs.GetIntPref("offline.download.download_messages");
|
||||
|
||||
if(goingOnline) {
|
||||
switch(prefSendUnsentMessages) {
|
||||
case 0:
|
||||
if(CheckForUnsentMessages()) {
|
||||
if(! PromptSendMessages())
|
||||
return false;
|
||||
}
|
||||
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(false, 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function MsgSettingsOffline()
|
||||
{
|
||||
window.parent.MsgAccountManager('am-offline.xul');
|
||||
}
|
||||
|
||||
// Init PrefsService
|
||||
function GetPrefsService()
|
||||
{
|
||||
// Store the prefs object
|
||||
try {
|
||||
var prefsService = Components.classes["@mozilla.org/preferences;1"];
|
||||
if (prefsService)
|
||||
prefsService = prefsService.getService();
|
||||
if (prefsService)
|
||||
gPrefs = prefsService.QueryInterface(Components.interfaces.nsIPref);
|
||||
|
||||
if (!gPrefs)
|
||||
dump("failed to get prefs service!\n");
|
||||
}
|
||||
catch(ex) {
|
||||
dump("failed to get prefs service!\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Check for unsent messages
|
||||
function CheckForUnsentMessages()
|
||||
{
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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 buttonPressed = {value:0};
|
||||
var checkValue = {value:true};
|
||||
gPromptService.confirmEx(window,
|
||||
gOfflinePromptsBundle.getString('sendMessagesWindowTitle'),
|
||||
gOfflinePromptsBundle.getString('sendMessagesLabel'),
|
||||
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_0) +
|
||||
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_2) +
|
||||
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_1),
|
||||
gOfflinePromptsBundle.getString('sendMessagesSendButtonLabel'),
|
||||
gOfflinePromptsBundle.getString('sendMessagesCancelButtonLabel'),
|
||||
gOfflinePromptsBundle.getString('sendMessagesNoSendButtonLabel'),
|
||||
gOfflinePromptsBundle.getString('sendMessagesCheckboxLabel'),
|
||||
checkValue, buttonPressed);
|
||||
if(buttonPressed) {
|
||||
if(buttonPressed.value == 0) {
|
||||
if(checkValue.value)
|
||||
gPrefs.SetIntPref("offline.send.unsent_messages", 0);
|
||||
else
|
||||
gPrefs.SetIntPref("offline.send.unsent_messages", 1);
|
||||
|
||||
gOfflineManager.goOnline(true /* sendUnsentMessages */,
|
||||
true /* playbackOfflineImapOperations */,
|
||||
msgWindow);
|
||||
return true;
|
||||
}
|
||||
else if(buttonPressed.value == 1) {
|
||||
return false;
|
||||
}
|
||||
else if(buttonPressed.value == 2) {
|
||||
if(checkValue.value)
|
||||
gPrefs.SetIntPref("offline.send.unsent_messages", 0);
|
||||
else
|
||||
gPrefs.SetIntPref("offline.send.unsent_messages", 2);
|
||||
gOfflineManager.goOnline(false /* sendUnsentMessages */,
|
||||
true /* playbackOfflineImapOperations */,
|
||||
msgWindow);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// prompt for downlading messages while going offline, and synchronise
|
||||
function PromptDownloadMessages()
|
||||
{
|
||||
InitPrompts();
|
||||
InitServices();
|
||||
|
||||
if(gPromptService) {
|
||||
var buttonPressed = {value:0};
|
||||
var checkValue = {value:true};
|
||||
gPromptService.confirmEx(window,
|
||||
gOfflinePromptsBundle.getString('downloadMessagesWindowTitle'),
|
||||
gOfflinePromptsBundle.getString('downloadMessagesLabel'),
|
||||
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_0) +
|
||||
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_2) +
|
||||
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_1),
|
||||
gOfflinePromptsBundle.getString('downloadMessagesDownloadButtonLabel'),
|
||||
gOfflinePromptsBundle.getString('downloadMessagesCancelButtonLabel'),
|
||||
gOfflinePromptsBundle.getString('downloadMessagesNoDownloadButtonLabel'),
|
||||
gOfflinePromptsBundle.getString('downloadMessagesCheckboxLabel'),
|
||||
checkValue, buttonPressed);
|
||||
if(buttonPressed) {
|
||||
if(buttonPressed.value == 0) {
|
||||
if(checkValue.value)
|
||||
gPrefs.SetIntPref("offline.download.download_messages", 0);
|
||||
else
|
||||
gPrefs.SetIntPref("offline.download.download_messages", 1);
|
||||
// download news, download mail, send unsent messages, go offline when done, msg window
|
||||
gOfflineManager.synchronizeForOffline(false, true, false, true, msgWindow);
|
||||
return true;
|
||||
}
|
||||
else if(buttonPressed.value == 1) {
|
||||
return false;
|
||||
}
|
||||
else if(buttonPressed.value == 2) {
|
||||
if(checkValue.value)
|
||||
gPrefs.SetIntPref("offline.download.download_messages", 0);
|
||||
else
|
||||
gPrefs.SetIntPref("offline.download.download_messages", 2);
|
||||
// download news, download mail, send unsent messages, go offline when done, msg window
|
||||
gOfflineManager.synchronizeForOffline(false, false, false, true, msgWindow);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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 (!gPrefs)
|
||||
GetPrefsService();
|
||||
|
||||
if (!gOfflineManager)
|
||||
GetOfflineMgrService();
|
||||
}
|
||||
|
||||
// Init Offline Manager
|
||||
function GetOfflineMgrService()
|
||||
{
|
||||
if (!gOfflineManager) {
|
||||
gOfflineManager = Components.classes["@mozilla.org/messenger/offline-manager;1"]
|
||||
.getService(Components.interfaces.nsIMsgOfflineManager);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ Rights Reserved.
|
|||
<script type="application/x-javascript" src="chrome://messenger/content/mailContextMenus.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/messengerdnd.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/accountUtils.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/mail-offline.js"/>
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaClick.js"/>
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaDD.js"/>
|
||||
<script type="application/x-javascript" src="chrome://global/content/nsJSSupportsUtils.js"/>
|
||||
|
|
|
@ -76,6 +76,7 @@ CHROME_CONTENT = \
|
|||
.\msgSynchronize.xul \
|
||||
.\msgSynchronize.js \
|
||||
.\msgSelectOffline.xul \
|
||||
.\mail-offline.js \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -74,6 +74,7 @@ Rights Reserved.
|
|||
<script type="application/x-javascript" src="chrome://messenger/content/messengerdnd.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/accountUtils.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/msgAccountCentral.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/mail-offline.js"/>
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaClick.js"/>
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaDD.js"/>
|
||||
<script type="application/x-javascript" src="chrome://global/content/nsJSSupportsUtils.js"/>
|
||||
|
|
|
@ -141,6 +141,7 @@ messenger.jar:
|
|||
content/messenger/FilterListDialog.js (base/search/resources/content/FilterListDialog.js)
|
||||
content/messenger/FilterEditor.xul (base/search/resources/content/FilterEditor.xul)
|
||||
content/messenger/FilterEditor.js (base/search/resources/content/FilterEditor.js)
|
||||
content/messenger/mail-offline.js (base/resources/content/mail-offline.js)
|
||||
content/messenger/messengercompose/pref-composing_messages.xul (compose/prefs/resources/content/pref-composing_messages.xul)
|
||||
content/messenger/messengercompose/pref-formatting.xul (compose/prefs/resources/content/pref-formatting.xul)
|
||||
content/messenger/messengercompose/pref-formatting.js (compose/prefs/resources/content/pref-formatting.js)
|
||||
|
|
Загрузка…
Ссылка в новой задаче