| 1219 |
1220 |
| 1220 c++; |
1221 c++; |
| 1221 } |
1222 } |
| 1222 |
1223 |
| 1223 /* NOTE: HTTP_PROXY takes precendence. */ |
1224 /* NOTE: HTTP_PROXY takes precendence. */ |
| 1224 if (host[0]) |
1225 info = gaim_global_proxy_get_info(); |
| 1225 strcpy(global_proxy_info.proxyhost, host); |
1226 |
| 1226 else |
1227 if (*host) gaim_proxy_info_set_host(info, host); |
| 1227 *global_proxy_info.proxyhost = '\0'; |
1228 if (*user) gaim_proxy_info_set_username(info, user); |
| 1228 |
1229 if (*pass) gaim_proxy_info_set_password(info, pass); |
| 1229 if (user[0]) |
1230 |
| 1230 strcpy(global_proxy_info.proxyuser, user); |
1231 gaim_proxy_info_set_port(info, port); |
| 1231 else |
|
| 1232 *global_proxy_info.proxyuser = '\0'; |
|
| 1233 |
|
| 1234 if (pass[0]) |
|
| 1235 strcpy(global_proxy_info.proxypass, pass); |
|
| 1236 else |
|
| 1237 *global_proxy_info.proxypass = '\0'; |
|
| 1238 |
|
| 1239 global_proxy_info.proxyport = port; |
|
| 1240 |
1232 |
| 1241 gaim_debug(GAIM_DEBUG_MISC, "gaimrc", |
1233 gaim_debug(GAIM_DEBUG_MISC, "gaimrc", |
| 1242 "Host: '%s', User: '%s', Password: '%s', Port: %d\n", |
1234 "Host: '%s', User: '%s', Password: '%s', Port: %d\n", |
| 1243 global_proxy_info.proxyhost, global_proxy_info.proxyuser, |
1235 gaim_proxy_info_get_host(info), |
| 1244 global_proxy_info.proxypass, global_proxy_info.proxyport); |
1236 gaim_proxy_info_get_username(info), |
| |
1237 gaim_proxy_info_get_password(info), |
| |
1238 gaim_proxy_info_get_port(info)); |
| 1245 |
1239 |
| 1246 return TRUE; |
1240 return TRUE; |
| 1247 } |
1241 } |
| 1248 |
1242 |
| 1249 static void gaimrc_read_proxy(FILE *f) |
1243 static void gaimrc_read_proxy(FILE *f) |
| 1250 { |
1244 { |
| 1251 char buf[2048]; |
1245 char buf[2048]; |
| 1252 struct parse parse_buffer; |
1246 struct parse parse_buffer; |
| 1253 struct parse *p; |
1247 struct parse *p; |
| |
1248 GaimProxyInfo *info; |
| |
1249 |
| |
1250 info = gaim_global_proxy_get_info(); |
| 1254 |
1251 |
| 1255 buf[0] = 0; |
1252 buf[0] = 0; |
| 1256 global_proxy_info.proxyhost[0] = 0; |
|
| 1257 gaim_debug(GAIM_DEBUG_MISC, "gaimrc", "gaimrc_read_proxy\n"); |
1253 gaim_debug(GAIM_DEBUG_MISC, "gaimrc", "gaimrc_read_proxy\n"); |
| 1258 |
1254 |
| 1259 while (buf[0] != '}') { |
1255 while (buf[0] != '}') { |
| 1260 if (buf[0] == '#') |
1256 if (buf[0] == '#') |
| 1261 continue; |
1257 continue; |
| 1264 return; |
1260 return; |
| 1265 |
1261 |
| 1266 p = parse_line(buf, &parse_buffer); |
1262 p = parse_line(buf, &parse_buffer); |
| 1267 |
1263 |
| 1268 if (!strcmp(p->option, "host")) { |
1264 if (!strcmp(p->option, "host")) { |
| 1269 g_snprintf(global_proxy_info.proxyhost, |
1265 gaim_proxy_info_set_host(info, p->value[0]); |
| 1270 sizeof(global_proxy_info.proxyhost), "%s", p->value[0]); |
|
| 1271 gaim_debug(GAIM_DEBUG_MISC, "gaimrc", |
1266 gaim_debug(GAIM_DEBUG_MISC, "gaimrc", |
| 1272 "Set proxyhost %s\n", global_proxy_info.proxyhost); |
1267 "Set proxyhost %s\n", p->value[0]); |
| 1273 } else if (!strcmp(p->option, "port")) { |
1268 } else if (!strcmp(p->option, "port")) { |
| 1274 global_proxy_info.proxyport = atoi(p->value[0]); |
1269 gaim_proxy_info_set_port(info, atoi(p->value[0])); |
| 1275 } else if (!strcmp(p->option, "type")) { |
1270 } else if (!strcmp(p->option, "type")) { |
| 1276 global_proxy_info.proxytype = atoi(p->value[0]); |
1271 gaim_proxy_info_set_type(info, atoi(p->value[0])); |
| 1277 } else if (!strcmp(p->option, "user")) { |
1272 } else if (!strcmp(p->option, "user")) { |
| 1278 g_snprintf(global_proxy_info.proxyuser, |
1273 gaim_proxy_info_set_username(info, p->value[0]); |
| 1279 sizeof(global_proxy_info.proxyuser), "%s", p->value[0]); |
|
| 1280 } else if (!strcmp(p->option, "pass")) { |
1274 } else if (!strcmp(p->option, "pass")) { |
| 1281 g_snprintf(global_proxy_info.proxypass, |
1275 gaim_proxy_info_set_password(info, p->value[0]); |
| 1282 sizeof(global_proxy_info.proxypass), "%s", p->value[0]); |
1276 } |
| 1283 } |
1277 } |
| 1284 } |
1278 |
| 1285 if (global_proxy_info.proxyhost[0]) |
1279 if (gaim_proxy_info_get_host(info) != NULL) |
| 1286 proxy_info_is_from_gaimrc = 1; |
1280 gaim_global_proxy_set_from_prefs(TRUE); |
| 1287 else { |
1281 else { |
| |
1282 const char *host; |
| 1288 gboolean getVars = TRUE; |
1283 gboolean getVars = TRUE; |
| 1289 proxy_info_is_from_gaimrc = 0; |
1284 |
| 1290 |
1285 if ((host = g_getenv("HTTP_PROXY")) != NULL || |
| 1291 if (g_getenv("HTTP_PROXY")) |
1286 (host = g_getenv("http_proxy")) != NULL || |
| 1292 g_snprintf(global_proxy_info.proxyhost, |
1287 (host = g_getenv("HTTPPROXY")) != NULL) { |
| 1293 sizeof(global_proxy_info.proxyhost), "%s", |
1288 |
| 1294 g_getenv("HTTP_PROXY")); |
1289 gaim_proxy_info_set_host(info, host); |
| 1295 else if (g_getenv("http_proxy")) |
1290 } |
| 1296 g_snprintf(global_proxy_info.proxyhost, |
1291 |
| 1297 sizeof(global_proxy_info.proxyhost), "%s", |
1292 if (gaim_proxy_info_get_host(info) != NULL) |
| 1298 g_getenv("http_proxy")); |
1293 getVars = !gaimrc_parse_proxy_uri(gaim_proxy_info_get_host(info)); |
| 1299 else if (g_getenv("HTTPPROXY")) |
|
| 1300 g_snprintf(global_proxy_info.proxyhost, |
|
| 1301 sizeof(global_proxy_info.proxyhost), "%s", |
|
| 1302 g_getenv("HTTPPROXY")); |
|
| 1303 |
|
| 1304 if (*global_proxy_info.proxyhost != '\0') |
|
| 1305 getVars = !gaimrc_parse_proxy_uri(global_proxy_info.proxyhost); |
|
| 1306 |
1294 |
| 1307 if (getVars) |
1295 if (getVars) |
| 1308 { |
1296 { |
| 1309 if (g_getenv("HTTP_PROXY_PORT")) |
1297 const char *port_str, *user, *pass; |
| 1310 global_proxy_info.proxyport = atoi(g_getenv("HTTP_PROXY_PORT")); |
1298 |
| 1311 else if (g_getenv("http_proxy_port")) |
1299 if ((port_str = g_getenv("HTTP_PROXY_PORT")) != NULL || |
| 1312 global_proxy_info.proxyport = atoi(g_getenv("http_proxy_port")); |
1300 (port_str = g_getenv("http_proxy_port")) != NULL || |
| 1313 else if (g_getenv("HTTPPROXYPORT")) |
1301 (port_str = g_getenv("HTTPPROXYPORT")) != NULL) { |
| 1314 global_proxy_info.proxyport = atoi(g_getenv("HTTPPROXYPORT")); |
1302 |
| 1315 |
1303 gaim_proxy_info_set_port(info, atoi(port_str)); |
| 1316 if (g_getenv("HTTP_PROXY_USER")) |
1304 } |
| 1317 g_snprintf(global_proxy_info.proxyuser, |
1305 |
| 1318 sizeof(global_proxy_info.proxyuser), "%s", |
1306 if ((user = g_getenv("HTTP_PROXY_USER")) != NULL || |
| 1319 g_getenv("HTTP_PROXY_USER")); |
1307 (user = g_getenv("http_proxy_user")) != NULL || |
| 1320 else if (g_getenv("http_proxy_user")) |
1308 (user = g_getenv("HTTPPROXYUSER")) != NULL) { |
| 1321 g_snprintf(global_proxy_info.proxyuser, |
1309 |
| 1322 sizeof(global_proxy_info.proxyuser), "%s", |
1310 gaim_proxy_info_set_username(info, user); |
| 1323 g_getenv("http_proxy_user")); |
1311 } |
| 1324 else if (g_getenv("HTTPPROXYUSER")) |
1312 |
| 1325 g_snprintf(global_proxy_info.proxyuser, |
1313 if ((pass = g_getenv("HTTP_PROXY_PASS")) != NULL || |
| 1326 sizeof(global_proxy_info.proxyuser), "%s", |
1314 (pass = g_getenv("http_proxy_pass")) != NULL || |
| 1327 g_getenv("HTTPPROXYUSER")); |
1315 (pass = g_getenv("HTTPPROXYPASS")) != NULL) { |
| 1328 |
1316 |
| 1329 if (g_getenv("HTTP_PROXY_PASS")) |
1317 gaim_proxy_info_set_password(info, pass); |
| 1330 g_snprintf(global_proxy_info.proxypass, |
1318 } |
| 1331 sizeof(global_proxy_info.proxypass), "%s", |
|
| 1332 g_getenv("HTTP_PROXY_PASS")); |
|
| 1333 else if (g_getenv("http_proxy_pass")) |
|
| 1334 g_snprintf(global_proxy_info.proxypass, |
|
| 1335 sizeof(global_proxy_info.proxypass), "%s", |
|
| 1336 g_getenv("http_proxy_pass")); |
|
| 1337 else if (g_getenv("HTTPPROXYPASS")) |
|
| 1338 g_snprintf(global_proxy_info.proxypass, |
|
| 1339 sizeof(global_proxy_info.proxypass), "%s", |
|
| 1340 g_getenv("HTTPPROXYPASS")); |
|
| 1341 } |
1319 } |
| 1342 } |
1320 } |
| 1343 } |
1321 } |
| 1344 |
1322 |
| 1345 static void set_defaults() |
1323 static void set_defaults() |