Start TB in offline mode? - SOLVED
-
- Posts: 32
- Joined: June 15th, 2007, 12:35 pm
Start TB in offline mode? - SOLVED
The portable version has a way to start TB in offline mode. I couldn't find a way to start the regular non-portable version of TB in offline mode. Does anyone know if there is a way to do this? I don't want to do this by turning off my internet connection or disable server checking of individual TB accounts (I have too many). I was hoping for a way of doing this from the command line. Thanks
Last edited by Burma on July 31st, 2022, 9:23 pm, edited 1 time in total.
-
- Posts: 6426
- Joined: February 3rd, 2009, 6:29 pm
Re: Start TB in offline mode?
You can configure offline settings with the "Offline Settings" dialog.
i.e. Menu Bar > Tools > Settings > General > Offline
To configure Thunderbird always to start up offline, use the Config Editor to set the preference offline.startup_state to 3.
Outbox - Online and offline states
http://kb.mozillazine.org/Outbox#Online ... ine_states
i.e. Menu Bar > Tools > Settings > General > Offline
To configure Thunderbird always to start up offline, use the Config Editor to set the preference offline.startup_state to 3.
Outbox - Online and offline states
http://kb.mozillazine.org/Outbox#Online ... ine_states
-
- Posts: 6426
- Joined: February 3rd, 2009, 6:29 pm
Re: Start TB in offline mode?
You can use the command-line-startup observer to handle a command-line flag at startup using the autoconfig files. (advanced users only)
e.g.
ThunderbirdPortable.exe --cowabunga
thunderbird.exe --cowabunga
* <install directory>\defaults\pref\autoconfig.js
* <install directory>\mozilla.cfg
I get an error because the main window isn't ready yet. I don't remember how to listen for the opening of the main window.
Edit:
Reference
http://searchfox.org/comm-esr102/search ... tification
http://searchfox.org/mozilla-esr102/sou ... atcher.idl
e.g.
ThunderbirdPortable.exe --cowabunga
thunderbird.exe --cowabunga
* <install directory>\defaults\pref\autoconfig.js
Code: Select all
pref("general.config.sandbox_enabled", false);
pref("general.config.filename", "mozilla.cfg");
pref("general.config.obscure_value", 0);
Code: Select all
// mozilla.cfg file needs to start with a comment line
Components.utils.import("resource://gre/modules/Services.jsm");
Services.obs.addObserver(function (aSubject, aTopic, aData) {
Services.console.logStringMessage("test command-line-startup observer");
var commandLine = aSubject;
if (commandLine.handleFlag("cowabunga", false)) {
if (commandLine.state == Components.interfaces.nsICommandLine.STATE_INITIAL_LAUNCH) {
Services.console.logStringMessage("test STATE_INITIAL_LAUNCH without param");
var win = Services.wm.getMostRecentWindow("mail:3pane"); // null
if (win.MailOfflineMgr.isOnline()) win.MailOfflineMgr.toggleOfflineStatus();
}
}
}, "command-line-startup", false);
Edit:
I guess you can use the nsIWindowWatcher.registerNotification method.morat wrote:I don't remember how to listen for the opening of the main window.
Reference
http://searchfox.org/comm-esr102/search ... tification
http://searchfox.org/mozilla-esr102/sou ... atcher.idl
Last edited by morat on July 31st, 2022, 7:03 pm, edited 1 time in total.
-
- Posts: 32
- Joined: June 15th, 2007, 12:35 pm
Re: Start TB in offline mode?
I can't seem to get autoconfig.js working at all in TB 102.1.0 (64-bit). Could you possibly provide a Hello World type of sample to test that autoconfig.js and mozilla.cfg are functional? Thanks
morat wrote:You can use the command-line-startup observer to handle a command-line flag at startup using the autoconfig files. (advanced users only)
e.g.
ThunderbirdPortable.exe --cowabunga
thunderbird.exe --cowabunga
* <install directory>\defaults\pref\autoconfig.js
* <install directory>\mozilla.cfgCode: Select all
pref("general.config.sandbox_enabled", false); pref("general.config.filename", "mozilla.cfg"); pref("general.config.obscure_value", 0);
I get an error because the main window isn't ready yet. I don't remember how to listen for the opening of the main window.Code: Select all
// mozilla.cfg file needs to start with a comment line Components.utils.import("resource://gre/modules/Services.jsm"); Services.obs.addObserver(function (aSubject, aTopic, aData) { Services.console.logStringMessage("test command-line-startup observer"); var commandLine = aSubject; if (commandLine.handleFlag("cowabunga", false)) { if (commandLine.state == Components.interfaces.nsICommandLine.STATE_INITIAL_LAUNCH) { Services.console.logStringMessage("test STATE_INITIAL_LAUNCH without param"); var win = Services.wm.getMostRecentWindow("mail:3pane"); // null if (win.MailOfflineMgr.isOnline()) win.MailOfflineMgr.toggleOfflineStatus(); } } }, "command-line-startup", false);
-
- Posts: 6426
- Joined: February 3rd, 2009, 6:29 pm
Re: Start TB in offline mode?
Hello World Example:
* <install directory>\defaults\pref\autoconfig.js
* <install directory>\mozilla.cfg
Installation directory
http://kb.mozillazine.org/Installation_directory
Thunderbird Portable 32-bit:
* C:\ThunderbirdPortable\App\Thunderbird\defaults\pref\autoconfig.js
* C:\ThunderbirdPortable\App\Thunderbird\mozilla.cfg
Thunderbird Portable 64-bit:
* C:\ThunderbirdPortable\App\Thunderbird64\defaults\pref\autoconfig.js
* C:\ThunderbirdPortable\App\Thunderbird64\mozilla.cfg
Thunderbird 32-bit:
* C:\Program Files\Mozilla Thunderbird\defaults\pref\autoconfig.js
* C:\Program Files\Mozilla Thunderbird\mozilla.cfg
Thunderbird 64-bit:
* C:\Program Files (x86)\Mozilla Thunderbird\defaults\pref\autoconfig.js
* C:\Program Files (x86)\Mozilla Thunderbird\mozilla.cfg
The autoconfig.js file should be in the same folder as the channel-prefs.js file.
The mozilla.cfg file should be in the same folder as the thunderbird.exe executable.
* <install directory>\defaults\pref\autoconfig.js
Code: Select all
pref("general.config.sandbox_enabled", false);
pref("general.config.filename", "mozilla.cfg");
pref("general.config.obscure_value", 0);
Code: Select all
// mozilla.cfg file needs to start with a comment line
Components.utils.import("resource://gre/modules/Services.jsm");
Services.obs.addObserver(function (aSubject, aTopic, aData) {
var chromeWindow = aSubject;
chromeWindow.addEventListener("load", function (event) {
var doc = event.target;
var url = doc.location.href;
if (url == "chrome://messenger/content/messenger.xhtml") {
chromeWindow.setTimeout(function () {
try {
chromeWindow.alert("Hello, world!");
} catch (e) {
Components.utils.reportError(e);
}
}, 3000);
}
}, false);
}, "chrome-document-global-created", false);
http://kb.mozillazine.org/Installation_directory
Thunderbird Portable 32-bit:
* C:\ThunderbirdPortable\App\Thunderbird\defaults\pref\autoconfig.js
* C:\ThunderbirdPortable\App\Thunderbird\mozilla.cfg
Thunderbird Portable 64-bit:
* C:\ThunderbirdPortable\App\Thunderbird64\defaults\pref\autoconfig.js
* C:\ThunderbirdPortable\App\Thunderbird64\mozilla.cfg
Thunderbird 32-bit:
* C:\Program Files\Mozilla Thunderbird\defaults\pref\autoconfig.js
* C:\Program Files\Mozilla Thunderbird\mozilla.cfg
Thunderbird 64-bit:
* C:\Program Files (x86)\Mozilla Thunderbird\defaults\pref\autoconfig.js
* C:\Program Files (x86)\Mozilla Thunderbird\mozilla.cfg
The autoconfig.js file should be in the same folder as the channel-prefs.js file.
The mozilla.cfg file should be in the same folder as the thunderbird.exe executable.
-
- Posts: 32
- Joined: June 15th, 2007, 12:35 pm
Re: Start TB in offline mode?
That worked, thanks morat. It will give me a starting point to work out the command line observer above.
morat wrote:Hello World Example:
* <install directory>\defaults\pref\autoconfig.js
* <install directory>\mozilla.cfgCode: Select all
pref("general.config.sandbox_enabled", false); pref("general.config.filename", "mozilla.cfg"); pref("general.config.obscure_value", 0);
Installation directoryCode: Select all
// mozilla.cfg file needs to start with a comment line Components.utils.import("resource://gre/modules/Services.jsm"); Services.obs.addObserver(function (aSubject, aTopic, aData) { var chromeWindow = aSubject; chromeWindow.addEventListener("load", function (event) { var doc = event.target; var url = doc.location.href; if (url == "chrome://messenger/content/messenger.xhtml") { chromeWindow.setTimeout(function () { try { chromeWindow.alert("Hello, world!"); } catch (e) { Components.utils.reportError(e); } }, 3000); } }, false); }, "chrome-document-global-created", false);
http://kb.mozillazine.org/Installation_directory
Thunderbird Portable 32-bit:
* C:\ThunderbirdPortable\App\Thunderbird\defaults\pref\autoconfig.js
* C:\ThunderbirdPortable\App\Thunderbird\mozilla.cfg
Thunderbird Portable 64-bit:
* C:\ThunderbirdPortable\App\Thunderbird64\defaults\pref\autoconfig.js
* C:\ThunderbirdPortable\App\Thunderbird64\mozilla.cfg
Thunderbird 32-bit:
* C:\Program Files\Mozilla Thunderbird\defaults\pref\autoconfig.js
* C:\Program Files\Mozilla Thunderbird\mozilla.cfg
Thunderbird 64-bit:
* C:\Program Files (x86)\Mozilla Thunderbird\defaults\pref\autoconfig.js
* C:\Program Files (x86)\Mozilla Thunderbird\mozilla.cfg
The autoconfig.js file should be in the same folder as the channel-prefs.js file.
The mozilla.cfg file should be in the same folder as the thunderbird.exe executable.
-
- Posts: 6426
- Joined: February 3rd, 2009, 6:29 pm
Re: Start TB in offline mode?
I guess you can use the nsIWindowWatcher.registerNotification method.morat wrote:I don't remember how to listen for the opening of the main window.
Reference
http://searchfox.org/comm-esr102/search ... tification
http://searchfox.org/mozilla-esr102/sou ... atcher.idl
-
- Posts: 6426
- Joined: February 3rd, 2009, 6:29 pm
Re: Start TB in offline mode?
Cowabunga Example:
ThunderbirdPortable.exe --cowabunga
thunderbird.exe --cowabunga
* <install directory>\defaults\pref\autoconfig.js
* <install directory>\mozilla.cfg
You could listen for the "DOMContentLoaded" event. That event is fired before the "load" event.
ThunderbirdPortable.exe --cowabunga
thunderbird.exe --cowabunga
* <install directory>\defaults\pref\autoconfig.js
Code: Select all
pref("general.config.sandbox_enabled", false);
pref("general.config.filename", "mozilla.cfg");
pref("general.config.obscure_value", 0);
Code: Select all
// mozilla.cfg file needs to start with a comment line
Components.utils.import("resource://gre/modules/Services.jsm");
Services.obs.addObserver(function (aSubject, aTopic, aData) {
var commandLine = aSubject;
if (commandLine.handleFlag("cowabunga", false)) {
if (commandLine.state == Components.interfaces.nsICommandLine.STATE_INITIAL_LAUNCH) {
Services.ww.registerNotification(function onOpen(aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") {
var chromeWindow = aSubject;
chromeWindow.addEventListener("load", function (event) {
var doc = event.target;
var url = doc.location.href;
if (url == "chrome://messenger/content/messenger.xhtml") {
Services.ww.unregisterNotification(onOpen);
chromeWindow.setTimeout(function () {
try {
chromeWindow.alert("Cowabunga!");
} catch (e) {
Components.utils.reportError(e);
}
}, 3000);
}
}, {once: true});
}
});
}
}
}, "command-line-startup", false);
-
- Posts: 32
- Joined: June 15th, 2007, 12:35 pm
Re: Start TB in offline mode?
This is what I've hacked together from morat's code. I'm not sure of all of what it does but it works. It's certainly not elegant and can use some cleaning up:
To launch TB offline with this configuration you would go:
"C:\Program Files\Mozilla Thunderbird\thunderbird.exe" --offlinemode
Thanks again morat.
Code: Select all
// mozilla.cfg file needs to start with a comment line
Components.utils.import("resource://gre/modules/Services.jsm");
Services.obs.addObserver(function (aSubject, aTopic, aData) {
var commandLine = aSubject;
if (commandLine.handleFlag("offlinemode", false)) {
if (commandLine.state == Components.interfaces.nsICommandLine.STATE_INITIAL_LAUNCH) {
Services.ww.registerNotification(function onOpen(aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") {
var chromeWindow = aSubject;
chromeWindow.addEventListener("load", function (event) {
var doc = event.target;
var url = doc.location.href;
if (url == "chrome://messenger/content/messenger.xhtml") {
Services.ww.unregisterNotification(onOpen);
chromeWindow.setTimeout(function () {
try {
// chromeWindow.alert("offlinemode!");
if (commandLine.state == Components.interfaces.nsICommandLine.STATE_INITIAL_LAUNCH) {
Services.console.logStringMessage("test STATE_INITIAL_LAUNCH without param");
var win = Services.wm.getMostRecentWindow("mail:3pane"); // null
if (win.MailOfflineMgr.isOnline()) win.MailOfflineMgr.toggleOfflineStatus();
}
} catch (e) {
Components.utils.reportError(e);
}
}, 3000);
}
}, {once: true});
}
});
}
}
}, "command-line-startup", false);
"C:\Program Files\Mozilla Thunderbird\thunderbird.exe" --offlinemode
Thanks again morat.
-
- Posts: 6426
- Joined: February 3rd, 2009, 6:29 pm
Re: Start TB in offline mode? - SOLVED
You're welcome.
P.S.
You don't need to use the nsIWindowMediator.getMostRecentWindow method. The onOpen observer gets the most recent window.
P.S.
You don't need to use the nsIWindowMediator.getMostRecentWindow method. The onOpen observer gets the most recent window.
Code: Select all
// mozilla.cfg file needs to start with a comment line
Components.utils.import("resource://gre/modules/Services.jsm");
Services.obs.addObserver(function (aSubject, aTopic, aData) {
var commandLine = aSubject;
if (commandLine.handleFlag("offlinemode", false)) {
if (commandLine.state == Components.interfaces.nsICommandLine.STATE_INITIAL_LAUNCH) {
Services.ww.registerNotification(function onOpen(aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") {
var chromeWindow = aSubject;
chromeWindow.addEventListener("load", function (event) {
var doc = event.target;
var url = doc.location.href;
if (url == "chrome://messenger/content/messenger.xhtml") {
Services.ww.unregisterNotification(onOpen);
chromeWindow.setTimeout(function () {
try {
if (chromeWindow.MailOfflineMgr.isOnline()) {
chromeWindow.MailOfflineMgr.toggleOfflineStatus();
}
} catch (e) {
Components.utils.reportError(e);
}
}, 3000);
}
}, {once: true});
}
});
}
}
}, "command-line-startup", false);
-
- Posts: 32
- Joined: June 15th, 2007, 12:35 pm
Re: Start TB in offline mode? - SOLVED
morat wrote:You're welcome.
P.S.
You don't need to use the nsIWindowMediator.getMostRecentWindow method. The onOpen observer gets the most recent window.
Code: Select all
// mozilla.cfg file needs to start with a comment line Components.utils.import("resource://gre/modules/Services.jsm"); Services.obs.addObserver(function (aSubject, aTopic, aData) { var commandLine = aSubject; if (commandLine.handleFlag("offlinemode", false)) { if (commandLine.state == Components.interfaces.nsICommandLine.STATE_INITIAL_LAUNCH) { Services.ww.registerNotification(function onOpen(aSubject, aTopic, aData) { if (aTopic == "domwindowopened") { var chromeWindow = aSubject; chromeWindow.addEventListener("load", function (event) { var doc = event.target; var url = doc.location.href; if (url == "chrome://messenger/content/messenger.xhtml") { Services.ww.unregisterNotification(onOpen); chromeWindow.setTimeout(function () { try { if (chromeWindow.MailOfflineMgr.isOnline()) { chromeWindow.MailOfflineMgr.toggleOfflineStatus(); } } catch (e) { Components.utils.reportError(e); } }, 3000); } }, {once: true}); } }); } } }, "command-line-startup", false);