Initial support for launching MicroB on Fremantle
authorSteven Luo <steven+maemo@steven676.net>
Tue, 2 Feb 2010 09:23:23 +0000 (01:23 -0800)
committerSteven Luo <steven+maemo@steven676.net>
Tue, 2 Feb 2010 10:36:47 +0000 (02:36 -0800)
commitf4665fd53d5c0e352e36326efee27e6ce6edce1d
treea1e72c6d18532970956655eb594354e8b7257288
parent2130f1a2b306c96924b7a593fefe0995869b632a
Initial support for launching MicroB on Fremantle

MicroB in Fremantle has been changed to accommodate keeping the UI in
the background full-time as well as the browser engine (browserd).  As a
result, running "browser" no longer shows a browser window, and the
browser process doesn't relinquish the com.nokia.osso_browser D-Bus name
and quit when the last browser window closes.

Instead, launch the browser by starting the UI process in the
background, waiting for it to acquire the com.nokia.osso_browser name,
then using the D-Bus API to open a window.

Detecting when the last browser window is closed is trickier.  The
method we use is to notice that when the last browser window closes,
the UI process closes and reopens the browserd renderer, causing a
change in the ownership of the Mozilla.MicroB D-Bus name (or
com.nokia.microb-engine in Maemo 5 PR1.1).  We detect this change and
send the UI process an exit_browser D-Bus method call, causing it to
quit and relinquish the com.nokia.osso_browser name back to us.

Unfortunately, this method cannot detect when the bookmarks window is
closed.  This means two unpleasant surprises, both needed to make sure
that the bookmarks window is never the only MicroB window open (in that
situation, if the user closes the bookmarks window without first opening
another normal browser window, we wouldn't be able to detect the window
closing and ensure we get the com.nokia.osso_browser name back):

(1) Our top_application method, which should behave exactly like opening
    MicroB from the menu normally does (bring up the bookmarks window),
    brings up about:blank instead.
(2) We kill off MicroB and reclaim the com.nokia.osso_browser name when
    the last normal browser window closes, regardless of whether the
    bookmarks window is open.

Ideas for better ways to detect when all MicroB windows have closed are
welcome.

Code for monitoring when a D-Bus name changes hands draws on ideas from
the dbus-monitor source (tools/dbus-monitor.c in the D-Bus
distribution).
launcher.c