X-Git-Url: http://git.maemo.org/git/?p=browser-switch;a=blobdiff_plain;f=launcher.c;h=6a70c8250d6530f161ffe4d7cc5760a6d9c6bc5e;hp=93cce2f4c6695caaa690f865dd0492b2a7a4fd4a;hb=db714df9d7801937cf94cb328210159a6bcf4a8a;hpb=d8d8d1ed9bd347c8bf6c21e66eba7bf3c5c2b2b1 diff --git a/launcher.c b/launcher.c index 93cce2f..6a70c82 100644 --- a/launcher.c +++ b/launcher.c @@ -1,7 +1,7 @@ /* * launcher.c -- functions for launching web browsers for browser-switchboard * - * Copyright (C) 2009 Steven Luo + * Copyright (C) 2009-2010 Steven Luo * Derived from a Python implementation by Jason Simpson and Steven Luo * * This program is free software; you can redistribute it and/or @@ -32,6 +32,7 @@ #ifdef FREMANTLE #include +#include #endif #include "browser-switchboard.h" @@ -138,12 +139,23 @@ static void launch_tear(struct swb_context *ctx, char *uri) { around by just invoking Tear with exec() if it's not running. */ status = system("pidof tear > /dev/null"); if (WIFEXITED(status) && !WEXITSTATUS(status)) { - if (!tear_proxy) - tear_proxy = dbus_g_proxy_new_for_name(ctx->session_bus, - "com.nokia.tear", "/com/nokia/tear", - "com.nokia.Tear"); - dbus_g_proxy_call(tear_proxy, "OpenAddress", &error, - G_TYPE_STRING, uri, G_TYPE_INVALID); + if (!tear_proxy) { + if (!(tear_proxy = dbus_g_proxy_new_for_name( + ctx->session_bus, + "com.nokia.tear", + "/com/nokia/tear", + "com.nokia.Tear"))) { + printf("Failed to create proxy for com.nokia.Tear D-Bus interface\n"); + exit(1); + } + } + + if (!dbus_g_proxy_call(tear_proxy, "OpenAddress", &error, + G_TYPE_STRING, uri, G_TYPE_INVALID, + G_TYPE_INVALID)) { + printf("Opening window failed: %s\n", error->message); + exit(1); + } if (!ctx->continuous_mode) exit(0); } else { @@ -179,13 +191,13 @@ void launch_microb(struct swb_context *ctx, char *uri) { printf("launch_microb with uri '%s'\n", uri); /* Launch browserd if it's not running */ - status = system("pidof /usr/sbin/browserd > /dev/null"); + status = system("pidof browserd > /dev/null"); if (WIFEXITED(status) && WEXITSTATUS(status)) { kill_browserd = 1; #ifdef FREMANTLE - system("/usr/sbin/browserd -d -b"); + system("/usr/sbin/browserd -d -b > /dev/null 2>&1"); #else - system("/usr/sbin/browserd -d"); + system("/usr/sbin/browserd -d > /dev/null 2>&1"); #endif } @@ -296,6 +308,7 @@ void launch_microb(struct swb_context *ctx, char *uri) { exit(1); } } + g_object_unref(g_proxy); /* Workaround: the browser process we started is going to want to hang around forever, hogging the com.nokia.osso_browser @@ -359,20 +372,10 @@ void launch_microb(struct swb_context *ctx, char *uri) { 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); + /* Kill off browser UI + XXX: Hope we don't cause data loss here! */ + printf("Killing MicroB\n"); + kill(pid, SIGTERM); } else { /* Child process */ close_stdio(); @@ -408,7 +411,7 @@ void launch_microb(struct swb_context *ctx, char *uri) { /* Kill off browserd if we started it */ if (kill_browserd) - system("kill `pidof /usr/sbin/browserd`"); + system("kill `pidof browserd`"); if (!ctx || !ctx->continuous_mode) exit(0);