X-Git-Url: http://git.maemo.org/git/?p=browser-switch;a=blobdiff_plain;f=config-ui%2Fbrowser-switchboard-config.c;h=752725e1dc428e60a64b1d5992671be959c8db38;hp=01d301fe88a2f3932cf6a22f94d538ea853a6f24;hb=57b70bf816859abf1de95d4570bcc1b75983b7d9;hpb=717d5e7fb0b84458e74468f0507d6dcfc1ba071d diff --git a/config-ui/browser-switchboard-config.c b/config-ui/browser-switchboard-config.c index 01d301f..752725e 100644 --- a/config-ui/browser-switchboard-config.c +++ b/config-ui/browser-switchboard-config.c @@ -25,9 +25,11 @@ #include #include #include +#include #include #include "config.h" +#include "browsers.h" extern struct swb_config_option swb_config_options[]; @@ -67,6 +69,39 @@ static int get_config_value(char *name) { return retval; } +static int get_default_browser(void) { + struct swb_config cfg; + int i; + + swb_config_init(&cfg); + + if (!swb_config_load(&cfg)) + return 1; + + /* Check to see if the configured default browser is installed + If not, report the default default browser */ + for (i = 0; browsers[i].config; ++i) { + if (strcmp(browsers[i].config, cfg.default_browser)) + continue; + + if (browsers[i].binary && access(browsers[i].binary, X_OK)) + printf("%s\n", browsers[0].config); + else + printf("%s\n", browsers[i].config); + + break; + } + + if (!browsers[i].config) + /* Unknown browser configured as default, report the default + default browser */ + printf("%s\n", browsers[0].config); + + swb_config_free(&cfg); + + return 0; +} + static int set_config_value(char *name, char *value) { struct swb_config cfg; struct swb_config_option *optinfo; @@ -194,6 +229,9 @@ int main(int argc, char **argv) { exit(1); } return set_config_value(selected_opt, argv[optind]); - } else + } else if (!strcmp(selected_opt, "default_browser")) + /* Default browser value needs special handling */ + return get_default_browser(); + else return get_config_value(selected_opt); }