Merge branch 'diablo-package' into fremantle-package
authorSteven Luo <steven+maemo@steven676.net>
Fri, 5 Feb 2010 08:09:33 +0000 (00:09 -0800)
committerSteven Luo <steven+maemo@steven676.net>
Fri, 5 Feb 2010 08:09:33 +0000 (00:09 -0800)
debian/browser-switchboard-cp.desktop [new file with mode: 0644]
debian/changelog
debian/control
debian/rules
launcher.c

diff --git a/debian/browser-switchboard-cp.desktop b/debian/browser-switchboard-cp.desktop
new file mode 100644 (file)
index 0000000..3ddaad9
--- /dev/null
@@ -0,0 +1,9 @@
+[Desktop Entry] 
+Encoding=UTF-8
+Version=1.0
+Name=Browser Switchboard
+Comment=Set the default browser
+Type=HildonControlPanelPlugin
+Icon=general_web
+X-control-panel-plugin=libbrowser-switchboard-cp.so
+Categories=personalisation
index 5455c6e..da19a48 100644 (file)
@@ -6,6 +6,22 @@ browser-switchboard (3.1-2) extras-devel; urgency=low
 
  -- Steven Luo <steven+maemo@steven676.net>  Fri, 05 Feb 2010 00:05:27 -0800 
 
+browser-switchboard (3.1-1fremantle2) extras-devel; urgency=low
+
+  * Alpha release for Fremantle.
+  * Cherry-pick 6b78dde6... ("Initial support for launching MicroB on
+    Fremantle") and associated cleanups.
+  * Revise build system to reflect updated dependencies.
+
+ -- Steven Luo <steven+maemo@steven676.net>  Tue, 02 Feb 2010 02:45:42 -0800
+
+browser-switchboard (3.1-1fremantle1) extras-devel; urgency=low
+
+  * Alpha release for Fremantle.
+  * Pass EXTRA_CPPFLAGS=-DFREMANTLE to make to compile Fremantle-specific code.
+
+ -- Steven Luo <steven+maemo@steven676.net>  Fri, 15 Jan 2010 02:52:40 -0800
+
 browser-switchboard (3.1-1) extras-devel; urgency=low
 
   * New "upstream" stable release.
@@ -21,6 +37,16 @@ browser-switchboard (3.1-1) extras-devel; urgency=low
 
  -- Steven Luo <steven+maemo@steven676.net>  Fri, 15 Jan 2010 01:54:56 -0800
 
+browser-switchboard (3.0-1fremantle1) extras-devel; urgency=low
+
+  * Experimental build for Fremantle.
+  * Add XSBC-Bugtracker to debian/control to indicate where bugs should be
+    filed; needed for maemo extras QA.
+  * No need to add CPU optimization flags, the Fremantle toolchain
+    automatically optimizes for N900/OMAP3.
+
+ -- Steven Luo <steven+maemo@steven676.net>  Wed, 23 Dec 2009 04:01:53 -0800
+
 browser-switchboard (3.0-1) extras-devel; urgency=low
 
   * New "upstream" stable release.
@@ -42,6 +68,13 @@ browser-switchboard (3.0-1) extras-devel; urgency=low
 
  -- Steven Luo <steven+maemo@steven676.net>  Wed, 23 Dec 2009 03:48:02 -0800
 
+browser-switchboard (3.0~rc1-2fremantle1) extras-devel; urgency=low
+
+  * Experimental build for Fremantle.
+  * Upload to extras-devel.
+
+ -- Steven Luo <steven+maemo@steven676.net>  Fri, 18 Dec 2009 20:44:08 -0800
+
 browser-switchboard (3.0~rc1-2) extras-devel; urgency=low
 
   * Actually upload to extras-devel.
@@ -51,6 +84,15 @@ browser-switchboard (3.0~rc1-2) extras-devel; urgency=low
 
  -- Steven Luo <steven+maemo@steven676.net>  Fri, 18 Dec 2009 19:07:25 -0800
 
+browser-switchboard (3.0~rc1-1fremantle1) extras-devel; urgency=low
+
+  * Experimental build for Fremantle.
+  * Packaging changes:
+    - Add a different .desktop file with the Fremantle location of the stock
+      web browser icon.
+
+ -- Steven Luo <steven+maemo@steven676.net>  Fri, 18 Dec 2009 05:24:16 -0800
+
 browser-switchboard (3.0~rc1-1) extras-devel; urgency=low
 
   * New "upstream" prerelease.
index 74b078f..aa93d6e 100644 (file)
@@ -2,8 +2,9 @@ Source: browser-switchboard
 Section: user/network
 Priority: extra
 Maintainer: Steven Luo <steven+maemo@steven676.net>
-Build-Depends: debhelper (>= 5), libdbus-glib-1-dev, libgtk2.0-dev, libhildon1-dev, libosso-dev, hildon-control-panel-dev
+Build-Depends: debhelper (>= 5), libdbus-1-dev, libdbus-glib-1-dev, libgtk2.0-dev, libhildon1-dev, libosso-dev, hildon-control-panel-dev
 Standards-Version: 3.8.0
+XSBC-Bugtracker: https://garage.maemo.org/tracker/?group_id=1159
 
 Package: browser-switchboard
 Architecture: any
index 014ed5e..33738dd 100755 (executable)
@@ -9,15 +9,17 @@
 # Uncomment this to turn on verbose mode.
 #export DH_VERBOSE=1
 
-# Optimize for N8x0 CPUs if building for armel
 ifeq ($(DEB_HOST_ARCH),armel)
-       EXTRA_CFLAGS += -mcpu=arm1136jf-s
+       #EXTRA_CFLAGS += -mcpu=arm1136jf-s
        # Use Thumb for smaller binaries if requested
        ifneq (,$(filter thumb,$(DEB_BUILD_OPTIONS)))
                EXTRA_CFLAGS += -mthumb
        endif
 endif
 
+EXTRA_CPPFLAGS = -DFREMANTLE `pkg-config --cflags dbus-1`
+EXTRA_LDFLAGS = `pkg-config --libs dbus-1`
+
 configure: configure-stamp
 configure-stamp:
        touch configure-stamp
@@ -28,8 +30,8 @@ build: build-stamp
 build-stamp: configure-stamp 
        dh_testdir
 
-       make EXTRA_CFLAGS="$(EXTRA_CFLAGS)"
-       make -C config-ui EXTRA_CFLAGS="$(EXTRA_CFLAGS)"
+       make EXTRA_CFLAGS="$(EXTRA_CFLAGS)" EXTRA_CPPFLAGS="$(EXTRA_CPPFLAGS)" EXTRA_LDFLAGS="$(EXTRA_LDFLAGS)"
+       make -C config-ui EXTRA_CFLAGS="$(EXTRA_CFLAGS)" EXTRA_CPPFLAGS="$(EXTRA_CPPFLAGS)"
 
        touch $@
 
@@ -53,6 +55,7 @@ install: build
        # debian/browser-switchboard.
        make DESTDIR=debian/browser-switchboard install
        make -C config-ui DESTDIR=../debian/browser-switchboard install
+       install -c -m 0644 debian/browser-switchboard-cp.desktop debian/browser-switchboard/usr/share/applications/hildon-control-panel
 
 
 binary-indep: build install
index f738c63..2667623 100644 (file)
 #include <sys/wait.h>
 #include <dbus/dbus-glib.h>
 
+#ifdef FREMANTLE
+#include <dbus/dbus.h>
+#endif
+
 #include "browser-switchboard.h"
 #include "launcher.h"
 #include "dbus-server-bindings.h"
 
 #define LAUNCH_DEFAULT_BROWSER launch_microb
 
+#ifdef FREMANTLE
+static int microb_started = 0;
+static int kill_microb = 0;
+
+/* Check to see whether MicroB is ready to handle D-Bus requests yet
+   See the comments in launch_microb to understand how this works. */
+static DBusHandlerResult check_microb_started(DBusConnection *connection,
+                                    DBusMessage *message,
+                                    void *user_data) {
+       DBusError error;
+       char *name, *old, *new;
+
+       printf("Checking to see if MicroB is ready\n");
+       dbus_error_init(&error);
+       if (!dbus_message_get_args(message, &error,
+                                  DBUS_TYPE_STRING, &name,
+                                  DBUS_TYPE_STRING, &old,
+                                  DBUS_TYPE_STRING, &new,
+                                  DBUS_TYPE_INVALID)) {
+               printf("%s\n", error.message);
+               dbus_error_free(&error);
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       }
+       /* If old is an empty string, then the name has been acquired, and
+          MicroB should be ready to handle our request */
+       if (strlen(old) == 0) {
+               printf("MicroB ready\n");
+               microb_started = 1;
+       }
+
+       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+/* Check to see whether the last MicroB window has closed
+   See the comments in launch_microb to understand how this works. */
+static DBusHandlerResult check_microb_finished(DBusConnection *connection,
+                                    DBusMessage *message,
+                                    void *user_data) {
+       DBusError error;
+       char *name, *old, *new;
+
+       printf("Checking to see if we should kill MicroB\n");
+       /* Check to make sure that the Mozilla.MicroB name is being released,
+          not acquired -- if it's being acquired, we might be seeing an event
+          at MicroB startup, in which case killing the browser isn't
+          appropriate */
+       dbus_error_init(&error);
+       if (!dbus_message_get_args(message, &error,
+                                  DBUS_TYPE_STRING, &name,
+                                  DBUS_TYPE_STRING, &old,
+                                  DBUS_TYPE_STRING, &new,
+                                  DBUS_TYPE_INVALID)) {
+               printf("%s\n", error.message);
+               dbus_error_free(&error);
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       }
+       /* If old isn't an empty string, the name is being released, and
+          we should now kill MicroB */
+       if (strlen(old) > 0)
+               kill_microb = 1;
+
+       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+#endif
+
 static void launch_tear(struct swb_context *ctx, char *uri) {
        int status;
        static DBusGProxy *tear_proxy = NULL;
@@ -79,6 +148,13 @@ void launch_microb(struct swb_context *ctx, char *uri) {
        int kill_browserd = 0;
        int status;
        pid_t pid;
+#ifdef FREMANTLE
+       DBusConnection *raw_connection;
+       DBusError dbus_error;
+       DBusHandleMessageFunction filter_func;
+       DBusGProxy *g_proxy;
+       GError *gerror = NULL;
+#endif
 
        if (!uri)
                uri = "new_window";
@@ -89,7 +165,11 @@ void launch_microb(struct swb_context *ctx, char *uri) {
        status = system("pidof /usr/sbin/browserd > /dev/null");
        if (WIFEXITED(status) && WEXITSTATUS(status)) {
                kill_browserd = 1;
+#ifdef FREMANTLE
+               system("/usr/sbin/browserd -d -b");
+#else
                system("/usr/sbin/browserd -d");
+#endif
        }
 
        /* Release the osso_browser D-Bus name so that MicroB can take it */
@@ -99,6 +179,194 @@ void launch_microb(struct swb_context *ctx, char *uri) {
                perror("fork");
                exit(1);
        }
+#ifdef FREMANTLE
+       if (pid > 0) {
+               /* Parent process */
+               /* Wait for our child to start the browser UI process and
+                  for it to acquire the com.nokia.osso_browser D-Bus name,
+                  then make the appropriate method call to open the browser
+                  window.
+
+                  Ideas for how to do this monitoring derived from the
+                  dbus-monitor code (tools/dbus-monitor.c in the D-Bus
+                  codebase). */
+               microb_started = 0;
+               dbus_error_init(&dbus_error);
+
+               raw_connection = dbus_bus_get_private(DBUS_BUS_SESSION,
+                                                     &dbus_error);
+               if (!raw_connection) {
+                       fprintf(stderr,
+                               "Failed to open connection to session bus: %s\n",
+                               dbus_error.message);
+                       dbus_error_free(&dbus_error);
+                       exit(1);
+               }
+
+               dbus_bus_add_match(raw_connection,
+                                  "type='signal',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='com.nokia.osso_browser'",
+                                  &dbus_error);
+               if (dbus_error_is_set(&dbus_error)) {
+                       fprintf(stderr,
+                               "Failed to set up watch for browser UI start: %s\n",
+                               dbus_error.message);
+                       dbus_error_free(&dbus_error);
+                       exit(1);
+               }
+               filter_func = check_microb_started;
+               if (!dbus_connection_add_filter(raw_connection,
+                                               filter_func, NULL, NULL)) {
+                       fprintf(stderr, "Failed to set up watch filter!\n");
+                       exit(1);
+               }
+               printf("Waiting for MicroB to start\n");
+               while (!microb_started &&
+                      dbus_connection_read_write_dispatch(raw_connection,
+                                                          -1));
+               dbus_connection_remove_filter(raw_connection,
+                                             filter_func, NULL);
+               dbus_bus_remove_match(raw_connection,
+                                     "type='signal',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='com.nokia.osso_browser'",
+                                     &dbus_error);
+               if (dbus_error_is_set(&dbus_error)) {
+                       fprintf(stderr,
+                               "Failed to remove watch for browser UI start: %s\n",
+                               dbus_error.message);
+                       dbus_error_free(&dbus_error);
+                       exit(1);
+               }
+
+               /* Browser UI's started, send it the request for a new window
+                  via D-Bus */
+               g_proxy = dbus_g_proxy_new_for_name(ctx->session_bus,
+                               "com.nokia.osso_browser",
+                               "/com/nokia/osso_browser/request",
+                               "com.nokia.osso_browser");
+               if (!g_proxy) {
+                       printf("Couldn't get a com.nokia.osso_browser proxy\n");
+                       exit(1);
+               }
+               if (!strcmp(uri, "new_window")) {
+#if 0 /* Since we can't detect when the bookmark window closes, we'd have a
+        corner case where, if the user just closes the bookmark window
+        without opening any browser windows, we don't kill off MicroB or
+        resume handling com.nokia.osso_browser */
+                       if (!dbus_g_proxy_call(g_proxy, "top_application",
+                                              &gerror, G_TYPE_INVALID,
+                                              G_TYPE_INVALID)) {
+                               printf("Opening window failed: %s\n",
+                                      gerror->message);
+                               exit(1);
+                       }
+#endif
+                       if (!dbus_g_proxy_call(g_proxy, "load_url",
+                                              &gerror,
+                                              G_TYPE_STRING, "about:blank",
+                                              G_TYPE_INVALID,
+                                              G_TYPE_INVALID)) {
+                               printf("Opening window failed: %s\n",
+                                      gerror->message);
+                               exit(1);
+                       }
+               } else {
+                       if (!dbus_g_proxy_call(g_proxy, "load_url",
+                                              &gerror,
+                                              G_TYPE_STRING, uri,
+                                              G_TYPE_INVALID,
+                                              G_TYPE_INVALID)) {
+                               printf("Opening window failed: %s\n",
+                                      gerror->message);
+                               exit(1);
+                       }
+               }
+
+               /* Workaround: the browser process we started is going to want
+                  to hang around forever, hogging the com.nokia.osso_browser
+                  D-Bus interface while at it.  To fix this, we notice that
+                  when the last browser window closes, the browser UI restarts
+                  its attached browserd process, which causes an observable
+                  change in the ownership of the Mozilla.MicroB D-Bus name.
+                  Watch for this change and kill off the browser UI process
+                  when it happens.
+
+                  This has the problem of not being able to detect whether
+                  the bookmark window is open and/or in use, but it's the best
+                  that I can think of.  Better suggestions would be greatly
+                  appreciated. */
+               kill_microb = 0;
+               dbus_bus_add_match(raw_connection,
+                                  "type='signal',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='Mozilla.MicroB'",
+                                  &dbus_error);
+               if (dbus_error_is_set(&dbus_error)) {
+                       fprintf(stderr,
+                               "Failed to set up watch for browserd restart: %s\n",
+                               dbus_error.message);
+                       dbus_error_free(&dbus_error);
+                       exit(1);
+               }
+               /* Maemo 5 PR1.1 seems to have changed the name browserd takes
+                  to com.nokia.microb-engine; look for this too */
+               dbus_bus_add_match(raw_connection,
+                                  "type='signal',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='com.nokia.microb-engine'",
+                                  &dbus_error);
+               if (dbus_error_is_set(&dbus_error)) {
+                       fprintf(stderr,
+                               "Failed to set up watch for browserd restart: %s\n",
+                               dbus_error.message);
+                       dbus_error_free(&dbus_error);
+                       exit(1);
+               }
+               filter_func = check_microb_finished;
+               if (!dbus_connection_add_filter(raw_connection,
+                                               filter_func, NULL, NULL)) {
+                       fprintf(stderr, "Failed to set up watch filter!\n");
+                       exit(1);
+               }
+               while (!kill_microb &&
+                      dbus_connection_read_write_dispatch(raw_connection,
+                                                          -1));
+               dbus_connection_remove_filter(raw_connection,
+                                             filter_func, NULL);
+               dbus_bus_remove_match(raw_connection,
+                                  "type='signal',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='Mozilla.MicroB'",
+                                  &dbus_error);
+               if (dbus_error_is_set(&dbus_error))
+                       /* Don't really care -- about to disconnect from the
+                          bus anyhow */
+                       dbus_error_free(&dbus_error);
+               dbus_bus_remove_match(raw_connection,
+                                  "type='signal',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='com.nokia.microb-engine'",
+                                  &dbus_error);
+               if (dbus_error_is_set(&dbus_error))
+                       dbus_error_free(&dbus_error);
+               dbus_connection_close(raw_connection);
+               dbus_connection_unref(raw_connection);
+
+               /* Tell browser UI to exit nicely */
+               printf("Closing MicroB\n");
+               if (!dbus_g_proxy_call(g_proxy, "exit_browser", &gerror,
+                                      G_TYPE_INVALID, G_TYPE_INVALID)) {
+                       /* We don't expect a reply; any other error indicates
+                          a problem */
+                       if (gerror->domain != DBUS_GERROR ||
+                           gerror->code != DBUS_GERROR_NO_REPLY) {
+                               printf("exit_browser failed: %s\n",
+                                      gerror->message);
+                               exit(1);
+                       }
+               }
+               g_object_unref(g_proxy);
+       } else {
+               /* Child process */
+               /* exec maemo-invoker directly instead of relying on the
+                  /usr/bin/browser symlink, since /usr/bin/browser may have
+                  been replaced with a shell script calling us via D-Bus */
+               /* Launch the browser in the background -- our parent will
+                  wait for it to claim the D-Bus name and then display the
+                  window using D-Bus */
+               execl("/usr/bin/maemo-invoker", "browser", (char *)NULL);
+       }
+#else /* !FREMANTLE */
        if (pid > 0) {
                /* Parent process */
                waitpid(pid, &status, 0);
@@ -115,6 +383,7 @@ void launch_microb(struct swb_context *ctx, char *uri) {
                              "browser", "--url", uri, (char *)NULL);
                }
        }
+#endif /* FREMANTLE */
 
        /* Kill off browserd if we started it */
        if (kill_browserd)