Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I enter offline/online mode via XPCOM code?

0 views
Skip to first unread message

Sebastian Lisken

unread,
Oct 12, 2008, 2:44:51 PM10/12/08
to
Hi, I'm writing a Firefox extension that notices when the browser enters
offline or online mode. Now I'm wondering if I can also cause that mode
to change myself (from a singleton XPCOM component written in
JavaScript). A web search has not turned up much beyond
http://developer.mozilla.org/en/Online_and_offline_events - that's for
JavaScript running within a content document - and
http://developer.mozilla.org/en/NsIIOService plus
http://developer.mozilla.org/en/Observer_Notifications#IO_Notifications
- these are very helpful for getting the offline/online status and
reacting to when it changes. But nothing about actually setting the
status from code. Is that allowed? If yes, could someone supply me with
a code fragment?

Thanks in advance

Sebastian Lisken

Sebastian Lisken

unread,
Oct 12, 2008, 3:40:30 PM10/12/08
to
I searched some more and found the answer myself:

Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService)
.offline = false;

Sebastian

Gijs Kruitbosch

unread,
Oct 12, 2008, 6:22:48 PM10/12/08
to Sebastian Lisken

Yeah, unfortunately, to my knowledge that won't notify the nsIObserverService,
so if you want to play nice with things like the download manager, that would be
a good thing to do.

~ Gijs

PS: writing this close to midnight, greatly tired, so I could very well be wrong
- best check! :-)

Sebastian Lisken

unread,
Oct 13, 2008, 4:38:12 PM10/13/08
to
Gijs Kruitbosch wrote:
> Yeah, unfortunately, to my knowledge that won't notify the
> nsIObserverService

Just checked on FF 3. I have two components, one sets offline to false,
the other does get notified.

Sebastian

0 new messages