Mercurial > hg > nnchat
changeset 652:58a376f86cdf
Make browser a configurable setting (in addition to environment variable),
and make the execution method configurable also.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 28 Jan 2015 08:07:58 +0200 |
parents | e862edb65b9d |
children | 3fc12a4418ab |
files | main.c |
diffstat | 1 files changed, 34 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/main.c Mon Jan 26 06:44:40 2015 +0200 +++ b/main.c Wed Jan 28 08:07:58 2015 +0200 @@ -41,6 +41,12 @@ #define SET_MAX_HISTORY (64) // Command history length #define SET_KEEPALIVE (15*60) // Ping/keepalive period in seconds +enum +{ + BMT_MOZILLA, + BMT_NEW_FIREFOX, +}; + typedef struct { @@ -66,6 +72,7 @@ optProxyAuthType = TH_PROXY_AUTH_NONE, optProxyAddrType = TH_PROXY_ADDR_DOMAIN; int optUserColor = 0x000000; +int optBrowserRunMethod = BMT_NEW_FIREFOX; char *optServer = "chat.newbienudes.com", *optProxyServer = NULL, *optProxyUserID = NULL, @@ -948,13 +955,27 @@ { printMsgQ(currWin, "Could not create sub-process!\n"); } - else if (pid == 0) + else + if (pid == 0) { dup2(fds[1], STDOUT_FILENO); dup2(fds[0], STDERR_FILENO); - char *url = th_strdup_printf("openurl(%s,new-tab)", uri); - execlp(setBrowser, setBrowser, "-remote", url, (void *)NULL); - th_free(url); + switch (optBrowserRunMethod) + { + case BMT_NEW_FIREFOX: + // Newer method, supported by new-ish versions of Firefox + execlp(setBrowser, setBrowser, "-new-tab", uri, (void *)NULL); + break; + + default: + // Default old method + { + char *url = th_strdup_printf("openurl(%s,new-tab)", uri); + execlp(setBrowser, setBrowser, "-remote", url, (void *)NULL); + th_free(url); + } + } + _exit(th_get_error()); } @@ -2053,6 +2074,14 @@ tmpcfg = NULL; + th_cfg_add_comment(&tmpcfg, "Web browser binary/path to execute (UNIX/Linux only)"); + th_cfg_add_string(&tmpcfg, "browser", &setBrowser, NULL); + th_cfg_add_comment(&tmpcfg, "Browser execution method (0 = default/old Mozilla, 1 = new Firefox)"); + th_cfg_add_int(&tmpcfg, "run-method", &optBrowserRunMethod, BMT_MOZILLA); + th_cfg_add_section(&cfg, "web-browser", tmpcfg); + + + tmpcfg = NULL; th_cfg_add_comment(&tmpcfg, "Enable logging"); th_cfg_add_bool(&tmpcfg, "enable", &optLogEnable, optLogEnable); @@ -2112,7 +2141,7 @@ optNickSep = optNickSepStr ? optNickSepStr[0] : SET_NICK_SEPARATOR; setBrowser = getenv("BROWSER"); - if (setBrowser == NULL) + if (setBrowser == NULL || setBrowser[0] == 0) setBrowser = "firefox"; if (optLogPath == NULL && setHomeDir != NULL)