Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Observe application on shutdown
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ivan Enderlin @ Hoa  
View profile  
 More options Mar 11 2012, 2:47 pm
Newsgroups: mozilla.dev.platform
From: "Ivan Enderlin @ Hoa" <ivan.ender...@hoa-project.net>
Date: Sun, 11 Mar 2012 19:47:29 +0100
Local: Sun, Mar 11 2012 2:47 pm
Subject: Observe application on shutdown
Hi there :-),

I am currently working with Gecko SDK/XULRunner 10.* and I am trying to
observe application on shutdown thanks to nsIObserverService. Well,
according to [1], it is possible to observe the topic
“quit-application*” but none of them seems to work with me (and it is a
little bit frustrating ;-)). Here is the code I use:

    var applicationQuitObserver = {

    get observerService ( ) {

    return Cc['...@mozilla.org/observer-service;1'].getService(
    Ci.nsIObserverService
    );
    },

    observe: function ( subject, topic, data ) {

    dump('Here?');
    // Just as an example.
    },

    register: function ( ) {

    dump('Register');
    this.observerService.addObserver(this, 'quit-application-granted',
    false);
    },

    unregister: function ( ) {

    this.observerService.removeObserver(this,
    'quit-application-granted', false);
    }
    };
    applicationQuitObserver.register();

And when I close the window with the “close button” or with the
nsIAppStartup [2], the dump “Here?” does not appear in console whereas
the dump “Register” appears as expected. If you want to try, you can
start with the sample-app [3] proposed by Mark Finkle with the simple
following prefs.js:

    pref("toolkit.defaultChromeURI", "chrome://myapp/content/main.xul");
    pref("browser.dom.window.dump.enabled", true);
    pref("javascript.options.showInConsole", true);
    pref("javascript.options.strict", true);
    pref("nglayout.debug.disable_xul_cache", true);
    pref("nglayout.debug.disable_xul_fastload", true);

Immediatly, I thought the I/O was closed to early for me. So I have
tried to open a new file and writing in it. It works when I was
observing the topic “xul-window-visible” (for a test) but still not with
“quit-application*”.

So. Any thoughts?
Cheers.

[1] <https://developer.mozilla.org/en/Observer_Notifications>
[2]
<https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIAppStartup>
[3] <https://developer.mozilla.org/en/Getting_started_with_XULRunner>

--
Ivan Enderlin
Developer of Hoa
http://hoa.42/ or http://hoa-project.net/

PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis)
http://lifc.univ-fcomte.fr/ and http://www.inria.fr/

Member of HTML and WebApps Working Group of W3C
http://w3.org/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Benjamin Smedberg  
View profile  
 More options Mar 12 2012, 2:28 pm
Newsgroups: mozilla.dev.platform
From: Benjamin Smedberg <benja...@smedbergs.us>
Date: Mon, 12 Mar 2012 14:28:27 -0400
Local: Mon, Mar 12 2012 2:28 pm
Subject: Re: Observe application on shutdown
On 3/11/2012 2:47 PM, Ivan Enderlin @ Hoa wrote:
> I am currently working with Gecko SDK/XULRunner 10.* and I am trying
> to observe application on shutdown thanks to nsIObserverService. Well,
> according to [1], it is possible to observe the topic
> “quit-application*” but none of them seems to work with me (and it is
> a little bit frustrating ;-)). Here is the code I use:

What are you actually trying to accomplish? If you have unsaved user
data, you should be observing profile-before-change and persisting the
data then.

The quit-application-requested notification is fired in the following cases:

* when the user is logging out of Windows
* when the user chooses "quit" from the mac application menu
* when the addons service or update services wishes to restart the
application
* when gnome on Linux tells Firefox that the desktop is logging out
* when something in the XUL code calls "goQuitApplication" on
globalOverlay.js (which is used by the "Quit Firefox" menu item
* when something calls "closeWindow" on globalOverlay.js (which is used
by the Firefox frontend)

But as you'll note, if you have just written your own XUL app and close
a window, the application will quit without any of those conditions
being triggered, so no quit-application-requested will ever be fired.
Quit-application-granted is fired by the app runner, so it should be
fired in almost all shutdown cases:
http://mxr.mozilla.org/mozilla-central/source/toolkit/components/star...

In any case, I'm not sure who maintains that Devmo page, and it looks
pretty woeful: I would recommend using
https://wiki.mozilla.org/XPCOM_Shutdown instead.

--BDS


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ivan Enderlin @ Hoa  
View profile  
 More options Mar 13 2012, 3:12 am
Newsgroups: mozilla.dev.platform
From: "Ivan Enderlin @ Hoa" <ivan.ender...@hoa-project.net>
Date: Tue, 13 Mar 2012 08:12:04 +0100
Local: Tues, Mar 13 2012 3:12 am
Subject: Re: Observe application on shutdown
Hi Benjamin :-),

On 12/03/12 19:28, Benjamin Smedberg wrote:

Hmm, interesting. I didn't notice the last one.

> But as you'll note, if you have just written your own XUL app and
> close a window, the application will quit without any of those
> conditions being triggered, so no quit-application-requested will ever
> be fired. Quit-application-granted is fired by the app runner, so it
> should be fired in almost all shutdown cases:
> http://mxr.mozilla.org/mozilla-central/source/toolkit/components/star...

Yup.

> In any case, I'm not sure who maintains that Devmo page, and it looks
> pretty woeful: I would recommend using
> https://wiki.mozilla.org/XPCOM_Shutdown instead.

Actually, I have succeeded yesterday by writing an XPCOM component and
by listening the topic “quit-application-granted”. Your last link is
very interesting. Why these informations do not figure in the MDN ?

Thank you :-).
Best regards.

--
Ivan Enderlin
Developer of Hoa
http://hoa.42/ or http://hoa-project.net/

PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis)
http://lifc.univ-fcomte.fr/ and http://www.inria.fr/

Member of HTML and WebApps Working Group of W3C
http://w3.org/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »