Bug #359134 --> integrate Thunderbird with necko's automatic online/offline management. When we detect the network connection has gone down, automatically move the client into offline mode, and back to online mode when the connection comes back up.

tools/cross-commit  mail/app/profile/all-thunderbird.js  mail/base/content/mail-offline.js mailnews/extensions/offline-startup/js/offlineStartup.js mailnews/mailnews.js -m Bug
This commit is contained in:
scott%scott-macgregor.org 2006-11-08 23:59:04 +00:00
parent 7e8435d358
commit a4a2f7ef6d
4 changed files with 18 additions and 11 deletions

View File

@ -262,6 +262,7 @@ pref("offline.send.unsent_messages", 0);
// 2 Never synchronize the offline store when going offline
pref("offline.download.download_messages", 0);
pref("offline.prompt_synch_on_exit", true);
pref("offline.autoDetect", true); // automatically move the user offline or online based on the network connection
// Expose only select protocol handlers. All others should go
// through the external protocol handler route.

View File

@ -46,11 +46,6 @@ var MailOfflineMgr = {
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);
@ -84,6 +79,8 @@ var MailOfflineMgr = {
*/
toggleOfflineStatus: function()
{
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService2);
// the offline manager(goOnline and synchronizeForOffline) actually does the dirty work of
// changing the offline state with the networking service.
if (!this.isOnline())
@ -93,9 +90,14 @@ var MailOfflineMgr = {
var sendUnsentMessages = (prefSendUnsentMessages == 0 && this.haveUnsentMessages()
&& this.confirmSendUnsentMessages()) || prefSendUnsentMessages == 1;
this.offlineManager.goOnline(sendUnsentMessages, true /* playbackOfflineImapOperations */, msgWindow);
// resume managing offline status now that we are going back online.
ioService.manageOfflineStatus = gPrefBranch.getBoolPref("offline.autoDetect");
}
else // going offline
{
{
// Stop automatic management of the offline status since the user as decided to go offline.
ioService.manageOfflineStatus = false;
var prefDownloadMessages = gPrefBranch.getIntPref("offline.download.download_messages");
// 0 == Ask, 1 == Always Download, 2 == Never Download
var downloadForOfflineUse = (prefDownloadMessages == 0 && this.confirmDownloadMessagesForOfflineUse())

View File

@ -44,6 +44,7 @@ const kRememberLastState = 0;
const kAskForOnlineState = 1;
const kAlwaysOnline = 2;
const kAlwaysOffline = 3;
////////////////////////////////////////////////////////////////////////
//
// nsOfflineStartup : nsIObserver
@ -75,6 +76,7 @@ var nsOfflineStartup =
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var manageOfflineStatus = prefs.getBoolPref("offline.autoDetect");
gOfflineStartupMode = prefs.getIntPref(kOfflineStartupPref);
if (gOfflineStartupMode == kAlwaysOffline)
@ -84,13 +86,14 @@ var nsOfflineStartup =
}
else if (gOfflineStartupMode == kAlwaysOnline)
{
ioService.manageOfflineStatus = false;
ioService.manageOfflineStatus = manageOfflineStatus;
ioService.offline = false;
}
else if (gOfflineStartupMode == kRememberLastState)
{
ioService.manageOfflineStatus = false;
ioService.offline = !prefs.getBoolPref("network.online");
var wasOffline = !prefs.getBoolPref("network.online");
ioService.manageOfflineStatus = manageOfflineStatus && !wasOffline;
ioService.offline = wasOffline;
}
else if (gOfflineStartupMode == kAskForOnlineState)
{
@ -113,7 +116,7 @@ var nsOfflineStartup =
(promptService.BUTTON_POS_1 * promptService.BUTTON_TITLE_IS_STRING),
button0Text, button1Text, null, null, checkVal);
debug ("result = " + result + "\n");
ioService.manageOfflineStatus = false;
ioService.manageOfflineStatus = manageOfflineStatus && result != 1;
ioService.offline = result == 1;
}
},

View File

@ -236,7 +236,7 @@ pref("mailnews.offline_sync_mail", false);
pref("mailnews.offline_sync_news", false);
pref("mailnews.offline_sync_send_unsent", true);
pref("mailnews.offline_sync_work_offline", false);
pref("mailnews.force_ascii_search", false);
pref("mailnews.force_ascii_search", false);
pref("mailnews.send_default_charset", "chrome://messenger/locale/messenger.properties");
pref("mailnews.view_default_charset", "chrome://messenger/locale/messenger.properties");
@ -253,6 +253,7 @@ pref("mailnews.quotingPrefs.version", 0); // used to decide whether to mi
// the first time, we'll warn the user about the blind send, and they can disable the warning if they want.
pref("mapi.blind-send.enabled", true);
pref("offline.autoDetect", false); // automatically move the user offline or online based on the network connection
pref("offline.news.download.unread_only", true);
pref("offline.news.download.by_date", true);
pref("offline.news.download.days", 30); // days