ALT Linux Bugzilla
– Attachment 2412 Details for
Bug 14017
proxy patch wontfix
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
[patch]
xmms-scrobbler-0.3.8.1-proxy.patch
xmms-scrobbler-0.3.8.1-proxy.patch (text/plain), 10.74 KB, created by
Michael Shigorin
on 2008-02-04 23:56:53 MSK
(
hide
)
Description:
xmms-scrobbler-0.3.8.1-proxy.patch
Filename:
MIME Type:
Creator:
Michael Shigorin
Created:
2008-02-04 23:56:53 MSK
Size:
10.74 KB
patch
obsolete
>Only in xmms-scrobbler-0.3.8.1-proxy: .deps >diff -urp xmms-scrobbler-0.3.8.1/gtkstuff.c xmms-scrobbler-0.3.8.1-proxy/gtkstuff.c >--- xmms-scrobbler-0.3.8.1/gtkstuff.c 2006-07-06 18:38:16.000000000 +0700 >+++ xmms-scrobbler-0.3.8.1-proxy/gtkstuff.c 2006-07-06 18:15:12.000000000 +0700 >@@ -19,7 +19,8 @@ > > static GtkWidget *eduname, > *edpwd, >- *edenc; >+ *edenc, >+ *edprx; > static int errorbox_done; > void about_show(void) > { >@@ -118,6 +119,7 @@ static void saveconfig(GtkWidget *wid, g > const char *pwd = gtk_entry_get_text(GTK_ENTRY(edpwd)); > const char *uid = gtk_entry_get_text(GTK_ENTRY(eduname)); > const char *enc = gtk_entry_get_text(GTK_ENTRY(edenc)); >+ const char *prx = gtk_entry_get_text(GTK_ENTRY(edprx)); > > g_free(tags_encoding); > tags_encoding = g_strdup(enc); >@@ -138,7 +140,9 @@ static void saveconfig(GtkWidget *wid, g > } > > xmms_cfg_write_string(cfgfile, "audioscrobbler", "encoding", (char *)enc); >- >+ if (strcmp(prx, "")) >+ xmms_cfg_write_string(cfgfile, "audioscrobbler", "proxy", (char *)prx); >+ > #ifdef MAKE_XMMS > xmms_cfg_write_default_file(cfgfile); > #endif >@@ -157,9 +161,11 @@ void configure_dialog(void) > *unhbox, > *pwhbox, > *enhbox, >+ *prhbox, > *lblun, > *lblpw, > *lblen, >+ *lblpr, > *frame; > > ConfigFile *cfgfile; >@@ -202,10 +208,18 @@ void configure_dialog(void) > gtk_box_pack_start(GTK_BOX(enhbox), lblen, FALSE, FALSE, 3); > gtk_box_pack_start(GTK_BOX(enhbox), edenc, FALSE, FALSE, 3); > >+ prhbox = gtk_hbox_new(FALSE, 0); >+ edprx = gtk_entry_new(); >+ lblpr = gtk_label_new("Proxy server"); >+ gtk_box_pack_start(GTK_BOX(prhbox), lblpr, FALSE, FALSE, 3); >+ gtk_box_pack_start(GTK_BOX(prhbox), edprx, FALSE, FALSE, 3); >+ > gtk_box_pack_start(GTK_BOX(vbox), unhbox, FALSE, FALSE, 3); > gtk_box_pack_start(GTK_BOX(vbox), pwhbox, FALSE, FALSE, 3); > gtk_box_pack_start(GTK_BOX(vbox), enhbox, FALSE, FALSE, 3); >- >+ gtk_box_pack_start(GTK_BOX(vbox), prhbox, FALSE, FALSE, 3); >+ >+ > hbox = gtk_hbox_new(FALSE, 0); > > btnok = gtk_button_new_with_label("OK"); >@@ -220,7 +234,7 @@ void configure_dialog(void) > > gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3); > >- frame = gtk_frame_new(" The plugin will have to be restarted for username/password changes to take effect! "); >+ frame = gtk_frame_new(" The plugin will have to be restarted for username/password and proxy changes to take effect! "); > gtk_container_add(GTK_CONTAINER(frame), vbox); > gtk_container_add(GTK_CONTAINER(cnfdlg), frame); > if ((cfgfile = xmms_cfg_open_default_file())) { >@@ -240,6 +254,13 @@ void configure_dialog(void) > g_free(entry); > } > >+ entry = NULL; >+ xmms_cfg_read_string(cfgfile, "audioscrobbler", "proxy", &entry); >+ if (entry) { >+ gtk_entry_set_text(GTK_ENTRY(edprx), entry); >+ g_free(entry); >+ } >+ > xmms_cfg_free(cfgfile); > } > >diff -urp xmms-scrobbler-0.3.8.1/scrobbler.c xmms-scrobbler-0.3.8.1-proxy/scrobbler.c >--- xmms-scrobbler-0.3.8.1/scrobbler.c 2005-02-21 06:45:05.000000000 +0600 >+++ xmms-scrobbler-0.3.8.1-proxy/scrobbler.c 2006-07-06 17:57:31.000000000 +0700 >@@ -42,6 +42,8 @@ static char *sc_submit_url, > sc_curl_errbuf[CURL_ERROR_SIZE], > *sc_major_error; > >+char* proxy_server = NULL; >+ > static void dump_queue(); > > /* Error functions */ >@@ -227,6 +229,80 @@ static void hexify(char *pass, int len) > > static int sc_handshake(void) > { >+ pdebug("Handshaking directly", DEBUG); >+ int status; >+ char buf[4096]; >+ CURL *curl; >+ >+ snprintf(buf, sizeof(buf), "%s/?hs=true&p=%s&c=%s&v=%s&u=%s", >+ SCROBBLER_HS_URL, SCROBBLER_VERSION, >+ SCROBBLER_CLI_ID, VERSION, sc_username); >+ >+ curl = curl_easy_init(); >+ curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); >+ curl_easy_setopt(curl, CURLOPT_URL, buf); >+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, >+ sc_store_res); >+ memset(sc_curl_errbuf, 0, sizeof(sc_curl_errbuf)); >+ curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, sc_curl_errbuf); >+ curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); >+ status = curl_easy_perform(curl); >+ curl_easy_cleanup(curl); >+ >+ sc_hs_timeout = time(NULL) + SCROBBLER_HS_WAIT; >+ >+ if (status) { >+ pdebug(sc_curl_errbuf, DEBUG); >+ sc_hs_errors++; >+ sc_free_res(); >+ return -1; >+ } >+ >+ if (sc_parse_hs_res()) { >+ sc_hs_errors++; >+ sc_free_res(); >+ return -1; >+ } >+ >+ if (sc_challenge_hash != NULL) { >+ md5_state_t md5state; >+ unsigned char md5pword[16]; >+ >+ md5_init(&md5state); >+ /*pdebug(fmt_vastr("Pass Hash: %s", sc_password), DEBUG);*/ >+ md5_append(&md5state, (unsigned const char *)sc_password, >+ strlen(sc_password)); >+ /*pdebug(fmt_vastr("Challenge Hash: %s", sc_challenge_hash), DEBUG);*/ >+ md5_append(&md5state, (unsigned const char *)sc_challenge_hash, >+ strlen(sc_challenge_hash)); >+ md5_finish(&md5state, md5pword); >+ hexify(md5pword, sizeof(md5pword)); >+ /*pdebug(fmt_vastr("Response Hash: %s", sc_response_hash), DEBUG);*/ >+ } >+ >+ sc_hs_errors = 0; >+ sc_hs_status = 1; >+ >+ sc_free_res(); >+ >+ pdebug(fmt_vastr("submiturl: %s - interval: %d", >+ sc_submit_url, sc_submit_interval), DEBUG); >+ >+ return 0; >+} >+ >+static int sc_handshake_proxy(void) >+{ >+ pdebug("Handshaking through proxy", DEBUG); >+ if (!proxy_server) >+ { >+ pdebug("No proxy specified", DEBUG); >+ sc_hs_errors++; >+ sc_free_res(); >+ return -1; >+ } >+ pdebug(proxy_server, DEBUG); >+ > int status; > char buf[4096]; > CURL *curl; >@@ -240,6 +316,8 @@ static int sc_handshake(void) > curl_easy_setopt(curl, CURLOPT_URL, buf); > curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, > sc_store_res); >+ curl_easy_setopt(curl, CURLOPT_PROXY, proxy_server); >+ > memset(sc_curl_errbuf, 0, sizeof(sc_curl_errbuf)); > curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, sc_curl_errbuf); > curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); >@@ -399,7 +477,7 @@ static int sc_generateentry(GString *sub > i = 0; > #ifdef ALLOW_MULTIPLE > q_peekall(1); >- while ((item = q_peekall(0)) && i < 10) { >+ while ((item = q_peekall(0)) /* && i < 10 */ ) { > #else > item = q_peek(); > #endif >@@ -427,6 +505,76 @@ static int sc_generateentry(GString *sub > > static int sc_submitentry(gchar *entry) > { >+ pdebug("Submitting directly", DEBUG); >+ CURL *curl; >+ /* struct HttpPost *post = NULL , *last = NULL; */ >+ int status; >+ GString *submission; >+ >+ curl = curl_easy_init(); >+ curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); >+ curl_easy_setopt(curl, CURLOPT_URL, sc_submit_url); >+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, >+ sc_store_res); >+ curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT); >+ curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); >+ /*cfa(&post, &last, "debug", "failed");*/ >+ >+ /*pdebug(fmt_vastr("Username: %s", sc_username), DEBUG);*/ >+ submission = g_string_new("u="); >+ g_string_append(submission,(gchar *)sc_username); >+ >+ /*pdebug(fmt_vastr("Response Hash: %s", sc_response_hash), DEBUG);*/ >+ g_string_append(submission,"&s="); >+ g_string_append(submission,(gchar *)sc_response_hash); >+ >+ g_string_append(submission, entry); >+ >+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, (char *)submission->str); >+ memset(sc_curl_errbuf, 0, sizeof(sc_curl_errbuf)); >+ curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, sc_curl_errbuf); >+ >+ /* >+ curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); >+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, SCROBBLER_SB_WAIT); >+ */ >+ >+ status = curl_easy_perform(curl); >+ >+ curl_easy_cleanup(curl); >+ >+ g_string_free(submission,TRUE); >+ >+ if (status) { >+ pdebug(sc_curl_errbuf, DEBUG); >+ sc_sb_errors++; >+ sc_free_res(); >+ return -1; >+ } >+ >+ if (sc_parse_sb_res()) { >+ sc_sb_errors++; >+ sc_free_res(); >+ pdebug(fmt_vastr("Retrying in %d secs, %d elements in queue", >+ sc_submit_interval, q_len()), DEBUG); >+ return -1; >+ } >+ sc_free_res(); >+ return 0; >+} >+ >+static int sc_submitentry_proxy(gchar *entry) >+{ >+ pdebug("Submitting through proxy", DEBUG); >+ if (!proxy_server) >+ { >+ pdebug("No proxy specified", DEBUG); >+ sc_sb_errors++; >+ sc_free_res(); >+ return -1; >+ } >+ pdebug(proxy_server, DEBUG); >+ > CURL *curl; > /* struct HttpPost *post = NULL , *last = NULL; */ > int status; >@@ -439,6 +587,7 @@ static int sc_submitentry(gchar *entry) > sc_store_res); > curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT); > curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); >+ curl_easy_setopt(curl, CURLOPT_PROXY, proxy_server); > /*cfa(&post, &last, "debug", "failed");*/ > > /*pdebug(fmt_vastr("Username: %s", sc_username), DEBUG);*/ >@@ -527,6 +676,30 @@ static void sc_handlequeue(pthread_mutex > > sc_sb_errors = 0; > } >+ else >+ { >+ if(!sc_submitentry_proxy(submitentry->str)) >+ { >+ pthread_mutex_lock(&mutex); >+ >+#ifdef ALLOW_MULTIPLE >+ q_free(); >+#else >+ q_get(); >+#endif >+ /* >+ * This should make sure that the queue doesn't >+ * get submitted multiple times on a nasty >+ * segfault... >+ */ >+ dump_queue(); >+ >+ pthread_mutex_unlock(&mutex); >+ >+ sc_sb_errors = 0; >+ } >+ >+ } > if(sc_sb_errors) > { > if(sc_sb_errors < 5) >@@ -707,7 +880,9 @@ static void sc_checkhandshake(void) > return; > if (sc_hs_timeout < time(NULL)) > { >- sc_handshake(); >+ if (sc_handshake()) >+ sc_handshake_proxy(); >+ > > if(sc_hs_errors) > { >diff -urp xmms-scrobbler-0.3.8.1/scrobbler.h xmms-scrobbler-0.3.8.1-proxy/scrobbler.h >--- xmms-scrobbler-0.3.8.1/scrobbler.h 2004-09-11 10:27:03.000000000 +0700 >+++ xmms-scrobbler-0.3.8.1-proxy/scrobbler.h 2006-07-06 17:31:42.000000000 +0700 >@@ -7,4 +7,6 @@ void sc_cleaner(void); > int sc_catch_error(void); > char *sc_fetch_error(void); > void sc_clear_error(void); >+ >+extern char* proxy_server; > #endif >diff -urp xmms-scrobbler-0.3.8.1/xmms_scrobbler.c xmms-scrobbler-0.3.8.1-proxy/xmms_scrobbler.c >--- xmms-scrobbler-0.3.8.1/xmms_scrobbler.c 2006-07-06 18:38:16.000000000 +0700 >+++ xmms-scrobbler-0.3.8.1-proxy/xmms_scrobbler.c 2006-07-06 18:17:07.000000000 +0700 >@@ -59,7 +59,7 @@ static GeneralPlugin xmms_scrobbler = > > static void init(void) > { >- char *username = NULL, *password = NULL, *encoding = NULL; >+ char *username = NULL, *password = NULL, *encoding = NULL, *proxy = NULL; > ConfigFile *cfgfile; > going = 1; > >@@ -70,6 +70,8 @@ static void init(void) > &password); > xmms_cfg_read_string(cfgfile, "audioscrobbler", "encoding", > &encoding); >+ xmms_cfg_read_string(cfgfile, "audioscrobbler", "proxy", >+ &proxy); > xmms_cfg_free(cfgfile); > } > if ((!username || !password) || (!*username || !*password)) { >@@ -82,6 +84,22 @@ static void init(void) > tags_encoding = g_strdup(encoding); > g_free(encoding); > } >+ if (proxy) { >+ proxy_server = g_strdup(proxy); >+ g_free(proxy); >+ pdebug(fmt_vastr("Got proxy %s from cfg", proxy_server), DEBUG); >+ } >+ else >+ { >+ proxy_server = getenv("HTTP_PROXY"); >+ if (proxy_server) { >+ pdebug(fmt_vastr("Got proxy %s from getenv(\"HTTP_PROXY\")", >+ proxy_server), DEBUG); >+ } else { >+ pdebug("No proxy specified", DEBUG); >+ } >+ } >+ > sc_init(username, password); > g_free(username); > g_free(password);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 14017
: 2412 |
2413