X-Git-Url: http://git.maemo.org/git/?p=browser-switch;a=blobdiff_plain;f=config-ui%2Fsave-config.c;h=1787f0ef39e55af749247542352a07f046fc8eb0;hp=a80e089519f57bd868e058e325e094fb9b344af7;hb=6bbfa71a0fb705e38f30e69fdad8177906050015;hpb=16ad4992d0c5b982f660e8a533f7c37c77c2fdbe diff --git a/config-ui/save-config.c b/config-ui/save-config.c index a80e089..1787f0e 100644 --- a/config-ui/save-config.c +++ b/config-ui/save-config.c @@ -28,6 +28,10 @@ #include #include +#ifdef FREMANTLE +#include +#endif + #include "configfile.h" #include "config.h" @@ -145,3 +149,48 @@ out: fclose(fp); return retval; } + +/* Reconfigure a running browser-switchboard process with new settings */ +void swb_reconfig(struct swb_config *old, struct swb_config *new) { +#ifdef FREMANTLE + int microb_was_autostarted, microb_should_autostart; + pid_t pid; + int status; +#endif + + /* Try to send SIGHUP to any running browser-switchboard process + This causes it to reread config files if in continuous_mode, or + die so that the config will be reloaded on next start otherwise */ + system("kill -HUP `pidof browser-switchboard` > /dev/null 2>&1"); + +#ifdef FREMANTLE + if (!old || !new) + return; + + microb_was_autostarted = (old->autostart_microb == 1) || + (!strcmp(old->default_browser, "microb") && + old->autostart_microb); + microb_should_autostart = (new->autostart_microb == 1) || + (!strcmp(new->default_browser, "microb") && + new->autostart_microb); + if (!microb_was_autostarted && microb_should_autostart) { + /* MicroB should be started if it's not running */ + status = system("pidof browser > /dev/null"); + if (WIFEXITED(status) && WEXITSTATUS(status)) { + if ((pid = fork()) == -1) + return; + + if (!pid) { + /* Child process, start MicroB */ + execl("/usr/bin/maemo-invoker", "browser", + (char *)NULL); + } + } + } + /* XXX: We'd like to stop MicroB if (microb_was_autostarted && + !microb_should_autostart), but we don't know if the open MicroB + process has open windows. */ +#endif /* FREMANTLE */ + + return; +}