Mercurial > pidgin
comparison src/proxy.c @ 11878:f672349cfc1c
[gaim-migrate @ 14169]
Use GNOME proxy preferences.
Works For Me. People are going to go crazy.
We'll try it out in beta.
committer: Tailor Script <tailor@pidgin.im>
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Fri, 28 Oct 2005 23:12:04 +0000 |
| parents | c39a48818f66 |
| children | c5f12ada46d1 |
comparison
equal
deleted
inserted
replaced
| 11877:f1f7c83d7b6c | 11878:f672349cfc1c |
|---|---|
| 181 gaim_global_proxy_get_info(void) | 181 gaim_global_proxy_get_info(void) |
| 182 { | 182 { |
| 183 return global_proxy_info; | 183 return global_proxy_info; |
| 184 } | 184 } |
| 185 | 185 |
| 186 GaimProxyInfo * | |
| 187 gaim_gnome_proxy_get_info(void) | |
| 188 { | |
| 189 static GaimProxyInfo info = {0, NULL, 0, NULL, NULL}; | |
| 190 gchar *path; | |
| 191 if ((path = g_find_program_in_path("gconftool-2"))) { | |
| 192 gchar *tmp; | |
| 193 | |
| 194 /* See whether to use a proxy. */ | |
| 195 if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/use_http_proxy", &tmp, | |
| 196 NULL, NULL, NULL)) | |
| 197 return gaim_global_proxy_get_info(); | |
| 198 if (strcmp(tmp, "true\n")) { | |
| 199 info.type = GAIM_PROXY_NONE; | |
| 200 g_free(tmp); | |
| 201 return gaim_global_proxy_get_info(); | |
| 202 } | |
| 203 | |
| 204 g_free(tmp); | |
| 205 info.type = GAIM_PROXY_HTTP; | |
| 206 | |
| 207 /* Free the old fields */ | |
| 208 if (info.host) { | |
| 209 g_free(info.host); | |
| 210 info.host = NULL; | |
| 211 } | |
| 212 if (info.username) { | |
| 213 g_free(info.username); | |
| 214 info.username = NULL; | |
| 215 } | |
| 216 if (info.password) { | |
| 217 g_free(info.password); | |
| 218 info.password = NULL; | |
| 219 } | |
| 220 | |
| 221 /* Get the new ones */ | |
| 222 if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/host", &info.host, | |
| 223 NULL, NULL, NULL)) | |
| 224 return gaim_global_proxy_get_info(); | |
| 225 g_strchomp(info.host); | |
| 226 | |
| 227 if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_user", &info.username, | |
| 228 NULL, NULL, NULL)) | |
| 229 return gaim_global_proxy_get_info(); | |
| 230 g_strchomp(info.username); | |
| 231 | |
| 232 if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_password", &info.password, | |
| 233 NULL, NULL, NULL)) | |
| 234 return gaim_global_proxy_get_info(); | |
| 235 g_strchomp(info.password); | |
| 236 | |
| 237 if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/port", &tmp, | |
| 238 NULL, NULL, NULL)) | |
| 239 return gaim_global_proxy_get_info(); | |
| 240 info.port = atoi(tmp); | |
| 241 | |
| 242 g_free(path); | |
| 243 return &info; | |
| 244 } | |
| 245 return gaim_global_proxy_get_info(); | |
| 246 } | |
| 186 /************************************************************************** | 247 /************************************************************************** |
| 187 * Proxy API | 248 * Proxy API |
| 188 **************************************************************************/ | 249 **************************************************************************/ |
| 189 | 250 |
| 190 #ifdef __unix__ | 251 #ifdef __unix__ |
| 1804 g_return_val_if_fail(port != 0 && port != -1, -1); | 1865 g_return_val_if_fail(port != 0 && port != -1, -1); |
| 1805 g_return_val_if_fail(func != NULL, -1); | 1866 g_return_val_if_fail(func != NULL, -1); |
| 1806 | 1867 |
| 1807 phb = g_new0(struct PHB, 1); | 1868 phb = g_new0(struct PHB, 1); |
| 1808 | 1869 |
| 1809 if (account == NULL || gaim_account_get_proxy_info(account) == NULL) | 1870 if (account && gaim_account_get_proxy_info(account) != NULL) |
| 1871 phb->gpi = gaim_account_get_proxy_info(account); | |
| 1872 else if (gaim_running_gnome()) | |
| 1873 phb->gpi = gaim_gnome_proxy_get_info(); | |
| 1874 else | |
| 1810 phb->gpi = gaim_global_proxy_get_info(); | 1875 phb->gpi = gaim_global_proxy_get_info(); |
| 1811 else | |
| 1812 phb->gpi = gaim_account_get_proxy_info(account); | |
| 1813 | 1876 |
| 1814 phb->func = func; | 1877 phb->func = func; |
| 1815 phb->data = data; | 1878 phb->data = data; |
| 1816 phb->host = g_strdup(host); | 1879 phb->host = g_strdup(host); |
| 1817 phb->port = port; | 1880 phb->port = port; |
