Mercurial > hg > nnchat
comparison main.c @ 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 | 98f5d15d5ec4 |
children | 9c2ae1b96674 |
comparison
equal
deleted
inserted
replaced
651:e862edb65b9d | 652:58a376f86cdf |
---|---|
39 | 39 |
40 #define SET_PROXY_PORT 1080 | 40 #define SET_PROXY_PORT 1080 |
41 #define SET_MAX_HISTORY (64) // Command history length | 41 #define SET_MAX_HISTORY (64) // Command history length |
42 #define SET_KEEPALIVE (15*60) // Ping/keepalive period in seconds | 42 #define SET_KEEPALIVE (15*60) // Ping/keepalive period in seconds |
43 | 43 |
44 enum | |
45 { | |
46 BMT_MOZILLA, | |
47 BMT_NEW_FIREFOX, | |
48 }; | |
49 | |
44 | 50 |
45 typedef struct | 51 typedef struct |
46 { | 52 { |
47 char *name; | 53 char *name; |
48 int port; | 54 int port; |
64 optProxyPort = SET_PROXY_PORT, | 70 optProxyPort = SET_PROXY_PORT, |
65 optProxyType = TH_PROXY_NONE, | 71 optProxyType = TH_PROXY_NONE, |
66 optProxyAuthType = TH_PROXY_AUTH_NONE, | 72 optProxyAuthType = TH_PROXY_AUTH_NONE, |
67 optProxyAddrType = TH_PROXY_ADDR_DOMAIN; | 73 optProxyAddrType = TH_PROXY_ADDR_DOMAIN; |
68 int optUserColor = 0x000000; | 74 int optUserColor = 0x000000; |
75 int optBrowserRunMethod = BMT_NEW_FIREFOX; | |
69 char *optServer = "chat.newbienudes.com", | 76 char *optServer = "chat.newbienudes.com", |
70 *optProxyServer = NULL, | 77 *optProxyServer = NULL, |
71 *optProxyUserID = NULL, | 78 *optProxyUserID = NULL, |
72 *optProxyPassword = NULL, | 79 *optProxyPassword = NULL, |
73 *optUserName = NULL, | 80 *optUserName = NULL, |
946 | 953 |
947 if ((pid = fork()) < 0) | 954 if ((pid = fork()) < 0) |
948 { | 955 { |
949 printMsgQ(currWin, "Could not create sub-process!\n"); | 956 printMsgQ(currWin, "Could not create sub-process!\n"); |
950 } | 957 } |
951 else if (pid == 0) | 958 else |
959 if (pid == 0) | |
952 { | 960 { |
953 dup2(fds[1], STDOUT_FILENO); | 961 dup2(fds[1], STDOUT_FILENO); |
954 dup2(fds[0], STDERR_FILENO); | 962 dup2(fds[0], STDERR_FILENO); |
955 char *url = th_strdup_printf("openurl(%s,new-tab)", uri); | 963 switch (optBrowserRunMethod) |
956 execlp(setBrowser, setBrowser, "-remote", url, (void *)NULL); | 964 { |
957 th_free(url); | 965 case BMT_NEW_FIREFOX: |
966 // Newer method, supported by new-ish versions of Firefox | |
967 execlp(setBrowser, setBrowser, "-new-tab", uri, (void *)NULL); | |
968 break; | |
969 | |
970 default: | |
971 // Default old method | |
972 { | |
973 char *url = th_strdup_printf("openurl(%s,new-tab)", uri); | |
974 execlp(setBrowser, setBrowser, "-remote", url, (void *)NULL); | |
975 th_free(url); | |
976 } | |
977 } | |
978 | |
958 _exit(th_get_error()); | 979 _exit(th_get_error()); |
959 } | 980 } |
960 | 981 |
961 wait(&status); | 982 wait(&status); |
962 #endif | 983 #endif |
2051 th_cfg_add_string(&tmpcfg, "uri", &setProxyURI, NULL); | 2072 th_cfg_add_string(&tmpcfg, "uri", &setProxyURI, NULL); |
2052 th_cfg_add_section(&cfg, "proxy", tmpcfg); | 2073 th_cfg_add_section(&cfg, "proxy", tmpcfg); |
2053 | 2074 |
2054 | 2075 |
2055 tmpcfg = NULL; | 2076 tmpcfg = NULL; |
2077 th_cfg_add_comment(&tmpcfg, "Web browser binary/path to execute (UNIX/Linux only)"); | |
2078 th_cfg_add_string(&tmpcfg, "browser", &setBrowser, NULL); | |
2079 th_cfg_add_comment(&tmpcfg, "Browser execution method (0 = default/old Mozilla, 1 = new Firefox)"); | |
2080 th_cfg_add_int(&tmpcfg, "run-method", &optBrowserRunMethod, BMT_MOZILLA); | |
2081 th_cfg_add_section(&cfg, "web-browser", tmpcfg); | |
2082 | |
2083 | |
2084 tmpcfg = NULL; | |
2056 th_cfg_add_comment(&tmpcfg, "Enable logging"); | 2085 th_cfg_add_comment(&tmpcfg, "Enable logging"); |
2057 th_cfg_add_bool(&tmpcfg, "enable", &optLogEnable, optLogEnable); | 2086 th_cfg_add_bool(&tmpcfg, "enable", &optLogEnable, optLogEnable); |
2058 | 2087 |
2059 th_cfg_add_comment(&tmpcfg, "Use daily logfiles for room logs"); | 2088 th_cfg_add_comment(&tmpcfg, "Use daily logfiles for room logs"); |
2060 th_cfg_add_bool(&tmpcfg, "daily", &optLogDaily, optLogDaily); | 2089 th_cfg_add_bool(&tmpcfg, "daily", &optLogDaily, optLogDaily); |
2110 goto err_exit; | 2139 goto err_exit; |
2111 | 2140 |
2112 optNickSep = optNickSepStr ? optNickSepStr[0] : SET_NICK_SEPARATOR; | 2141 optNickSep = optNickSepStr ? optNickSepStr[0] : SET_NICK_SEPARATOR; |
2113 | 2142 |
2114 setBrowser = getenv("BROWSER"); | 2143 setBrowser = getenv("BROWSER"); |
2115 if (setBrowser == NULL) | 2144 if (setBrowser == NULL || setBrowser[0] == 0) |
2116 setBrowser = "firefox"; | 2145 setBrowser = "firefox"; |
2117 | 2146 |
2118 if (optLogPath == NULL && setHomeDir != NULL) | 2147 if (optLogPath == NULL && setHomeDir != NULL) |
2119 { | 2148 { |
2120 optLogPath = th_strdup_printf("%s%c%s%c", | 2149 optLogPath = th_strdup_printf("%s%c%s%c", |