@echo ' make util -- build command-line configuration utility'
@echo ' make diablo-hildon-app -- build standalone Diablo Hildon application'
@echo ' make diablo-plugin -- build Diablo hildon-control-panel plugin'
+ @echo ' make fremantle-util -- build command-line configuration utility for Fremantle'
@echo ' make fremantle-hildon-app -- build standalone Fremantle Hildon application'
@echo ' make fremantle-plugin -- build Fremantle hildon-control-panel plugin'
app: $(APP)
util: $(UTIL)
diablo-hildon-app: $(HILDON_APP)
diablo-plugin: $(PLUGIN)
+fremantle-util:
+ @$(MAKE) EXTRA_CPPFLAGS='-DFREMANTLE $(EXTRA_CPPFLAGS)' $(UTIL)
fremantle-hildon-app:
@$(MAKE) EXTRA_CPPFLAGS='-DFREMANTLE $(EXTRA_CPPFLAGS)' $(HILDON_APP)
fremantle-plugin:
#include <getopt.h>
#include "config.h"
+#include "save-config.h"
#include "browsers.h"
extern struct swb_config_option swb_config_options[];
}
static int set_config_value(char *name, char *value) {
- struct swb_config cfg;
+ struct swb_config orig_cfg, cfg;
struct swb_config_option *optinfo;
ptrdiff_t i;
int retval = 1;
- swb_config_init(&cfg);
+ swb_config_init(&orig_cfg);
- if (!swb_config_load(&cfg))
+ if (!swb_config_load(&orig_cfg))
return 1;
+ swb_config_copy(&cfg, &orig_cfg);
+
for (optinfo = swb_config_options; optinfo->name; ++optinfo) {
if (strcmp(name, optinfo->name))
continue;
if (!swb_config_save(&cfg))
retval = 1;
- swb_config_free(&cfg);
+ /* Reconfigure a running browser-switchboard, if present */
+ swb_reconfig(&orig_cfg, &cfg);
- /* 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");
+ swb_config_free(&orig_cfg);
+ swb_config_free(&cfg);
return retval;
}
#endif /* HILDON */
#include "config.h"
+#include "save-config.h"
#include "browsers.h"
#define CONTINUOUS_MODE_DEFAULT 0
}
swb_config_save(&new_cfg);
-}
-
-static void do_reconfig(void) {
- save_config();
- /* 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");
+ /* Reconfigure a running browser-switchboard, if present */
+ swb_reconfig(&orig_cfg, &new_cfg);
}
response = gtk_dialog_run(dialog);
if (response == GTK_RESPONSE_OK)
- do_reconfig();
+ save_config();
gtk_widget_destroy(GTK_WIDGET(dialog));
response = gtk_dialog_run(dialog);
if (response == GTK_RESPONSE_OK)
- do_reconfig();
+ save_config();
gtk_widget_destroy(GTK_WIDGET(dialog));
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef FREMANTLE
+#include <sys/wait.h>
+#endif
+
#include "configfile.h"
#include "config.h"
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;
+}
--- /dev/null
+/*
+ * save-config.h -- definitions for saving Browser Switchboard configuration
+ *
+ * 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
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA.
+ */
+
+#ifndef _SAVE_CONFIG_H
+#define _SAVE_CONFIG_H
+
+#include "config.h"
+
+int swb_config_save(struct swb_config *cfg);
+void swb_reconfig(struct swb_config *old, struct swb_config *new);
+
+#endif /* _SAVE_CONFIG_H */
int swb_config_load(struct swb_config *cfg);
-int swb_config_save(struct swb_config *cfg);
-
#endif /* _CONFIG_H */