# HG changeset patch # User Andrew O. Shadoura # Date 1218633329 -10800 # Node ID ff9b4776b938e291eadd2b487afc6014a005d28a # Parent 9c623f4ac901fba004eb655fd30fb52f828f33d1 now scrobbler uses proxy settings; whole scrobbler plugin needs to be re-written using neon diff -r 9c623f4ac901 -r ff9b4776b938 src/scrobbler/gerpok.c --- a/src/scrobbler/gerpok.c Wed Aug 13 14:10:14 2008 +0300 +++ b/src/scrobbler/gerpok.c Wed Aug 13 16:15:29 2008 +0300 @@ -5,9 +5,9 @@ #include #include #include -#include #include #include "fmt.h" +#include "plugin.h" #include "scrobbler.h" #include "config.h" #include @@ -416,6 +416,7 @@ SCROBBLER_CLI_ID, SCROBBLER_IMPLEMENTATION, gerpok_sc_username); curl = curl_easy_init(); + setup_proxy(curl); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); curl_easy_setopt(curl, CURLOPT_URL, buf); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, @@ -621,6 +622,7 @@ GString *submission; curl = curl_easy_init(); + setup_proxy(curl); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); curl_easy_setopt(curl, CURLOPT_URL, gerpok_sc_submit_url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, diff -r 9c623f4ac901 -r ff9b4776b938 src/scrobbler/plugin.c --- a/src/scrobbler/plugin.c Wed Aug 13 14:10:14 2008 +0300 +++ b/src/scrobbler/plugin.c Wed Aug 13 16:15:29 2008 +0300 @@ -19,6 +19,8 @@ #include #include +#include + #include "plugin.h" #include "scrobbler.h" #include "gerpok.h" @@ -338,6 +340,39 @@ return NULL; } +void setup_proxy(CURL *curl) +{ + mcs_handle_t *db; + gboolean use_proxy; + + db = aud_cfg_db_open(); + aud_cfg_db_get_bool(db, NULL, "use_proxy", &use_proxy); + if (use_proxy == FALSE) + { + curl_easy_setopt(curl, CURLOPT_PROXY, ""); + } + else + { + gchar *proxy_host, *proxy_port; + gboolean proxy_use_auth; + aud_cfg_db_get_string(db, NULL, "proxy_host", &proxy_host); + aud_cfg_db_get_string(db, NULL, "proxy_port", &proxy_port); + curl_easy_setopt(curl, CURLOPT_PROXY, proxy_host); + curl_easy_setopt(curl, CURLOPT_PROXYPORT, proxy_port); + aud_cfg_db_get_bool(db, NULL, "proxy_use_auth", &proxy_use_auth); + if (proxy_use_auth != FALSE) + { + gchar *userpwd, *user, *pass; + aud_cfg_db_get_string(db, NULL, "proxy_user", &user); + aud_cfg_db_get_string(db, NULL, "proxy_pass", &pass); + userpwd = g_strdup_printf("%s:%s", user, pass); + curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd); + g_free(userpwd); + } + } + aud_cfg_db_close(db); +} + GeneralPlugin *scrobbler_gplist[] = { &scrobbler_gp, NULL }; DECLARE_PLUGIN(scrobbler, NULL, NULL, NULL, NULL, NULL, scrobbler_gplist, NULL, NULL); diff -r 9c623f4ac901 -r ff9b4776b938 src/scrobbler/plugin.h --- a/src/scrobbler/plugin.h Wed Aug 13 14:10:14 2008 +0300 +++ b/src/scrobbler/plugin.h Wed Aug 13 16:15:29 2008 +0300 @@ -1,7 +1,10 @@ #ifndef PLUGIN_H #define PLUGIN_H +#include + void start(void); void stop(void); +void setup_proxy(CURL *curl); #endif diff -r 9c623f4ac901 -r ff9b4776b938 src/scrobbler/scrobbler.c --- a/src/scrobbler/scrobbler.c Wed Aug 13 14:10:14 2008 +0300 +++ b/src/scrobbler/scrobbler.c Wed Aug 13 16:15:29 2008 +0300 @@ -3,9 +3,9 @@ #include #include #include -#include #include #include "fmt.h" +#include "plugin.h" #include "scrobbler.h" #include "config.h" #include "settings.h" @@ -489,6 +489,7 @@ g_free(auth_tmp); curl = curl_easy_init(); + setup_proxy(curl); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); curl_easy_setopt(curl, CURLOPT_URL, buf); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, @@ -704,6 +705,7 @@ gchar *entry; curl = curl_easy_init(); + setup_proxy(curl); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); curl_easy_setopt(curl, CURLOPT_URL, sc_np_url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, @@ -763,6 +765,7 @@ GString *submission; curl = curl_easy_init(); + setup_proxy(curl); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); curl_easy_setopt(curl, CURLOPT_URL, sc_submit_url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,