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

This is a discussion on How do I enter offline/online mode via XPCOM code? - Mozilla ; 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 ...

+ Reply to Thread
Results 1 to 4 of 4

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

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

    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/Onli...offline_events - that's for
    JavaScript running within a content document - and
    http://developer.mozilla.org/en/NsIIOService plus
    http://developer.mozilla.org/en/Obse..._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

  2. Re: How do I enter offline/online mode via XPCOM code?

    I searched some more and found the answer myself:

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

    Sebastian

  3. Re: How do I enter offline/online mode via XPCOM code?

    Sebastian Lisken wrote:
    > I searched some more and found the answer myself:
    >
    > Components.classes["@mozilla.org/network/io-service;1"]
    > .getService(Components.interfaces.nsIIOService)
    > .offline = false;
    >
    > Sebastian


    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! :-)

  4. Re: How do I enter offline/online mode via XPCOM code?

    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

+ Reply to Thread