View | Details | Raw Unified | Return to bug 14017
Collapse All | Expand All

(-)xmms-scrobbler-0.3.8.1/gtkstuff.c (-4 / +25 lines)
Lines 19-25 Link Here
19
19
20
static GtkWidget 	*eduname,
20
static GtkWidget 	*eduname,
21
			*edpwd,
21
			*edpwd,
22
			*edenc;
22
			*edenc,
23
			*edprx;
23
static int errorbox_done;
24
static int errorbox_done;
24
void about_show(void)
25
void about_show(void)
25
{
26
{
Lines 118-123 static void saveconfig(GtkWidget *wid, g Link Here
118
	const char *pwd = gtk_entry_get_text(GTK_ENTRY(edpwd));
119
	const char *pwd = gtk_entry_get_text(GTK_ENTRY(edpwd));
119
	const char *uid = gtk_entry_get_text(GTK_ENTRY(eduname));
120
	const char *uid = gtk_entry_get_text(GTK_ENTRY(eduname));
120
	const char *enc = gtk_entry_get_text(GTK_ENTRY(edenc));
121
	const char *enc = gtk_entry_get_text(GTK_ENTRY(edenc));
122
	const char *prx = gtk_entry_get_text(GTK_ENTRY(edprx));
121
123
122
	g_free(tags_encoding);
124
	g_free(tags_encoding);
123
	tags_encoding = g_strdup(enc);
125
	tags_encoding = g_strdup(enc);
Lines 138-144 static void saveconfig(GtkWidget *wid, g Link Here
138
		}
140
		}
139
141
140
		xmms_cfg_write_string(cfgfile, "audioscrobbler", "encoding", (char *)enc);
142
		xmms_cfg_write_string(cfgfile, "audioscrobbler", "encoding", (char *)enc);
141
143
		if (strcmp(prx, ""))
144
			xmms_cfg_write_string(cfgfile, "audioscrobbler", "proxy", (char *)prx);
145
		
142
#ifdef MAKE_XMMS
146
#ifdef MAKE_XMMS
143
		xmms_cfg_write_default_file(cfgfile);
147
		xmms_cfg_write_default_file(cfgfile);
144
#endif
148
#endif
Lines 157-165 void configure_dialog(void) Link Here
157
			*unhbox,
161
			*unhbox,
158
			*pwhbox,
162
			*pwhbox,
159
			*enhbox,
163
			*enhbox,
164
			*prhbox,
160
			*lblun,
165
			*lblun,
161
			*lblpw,
166
			*lblpw,
162
			*lblen,
167
			*lblen,
168
			*lblpr,
163
			*frame;
169
			*frame;
164
			
170
			
165
	ConfigFile 	*cfgfile;
171
	ConfigFile 	*cfgfile;
Lines 202-211 void configure_dialog(void) Link Here
202
	gtk_box_pack_start(GTK_BOX(enhbox), lblen, FALSE, FALSE, 3);
208
	gtk_box_pack_start(GTK_BOX(enhbox), lblen, FALSE, FALSE, 3);
203
	gtk_box_pack_start(GTK_BOX(enhbox), edenc, FALSE, FALSE, 3);
209
	gtk_box_pack_start(GTK_BOX(enhbox), edenc, FALSE, FALSE, 3);
204
	
210
	
211
	prhbox = gtk_hbox_new(FALSE, 0);
212
	edprx = gtk_entry_new();
213
	lblpr = gtk_label_new("Proxy server");
214
	gtk_box_pack_start(GTK_BOX(prhbox), lblpr, FALSE, FALSE, 3);
215
	gtk_box_pack_start(GTK_BOX(prhbox), edprx, FALSE, FALSE, 3);
216
205
	gtk_box_pack_start(GTK_BOX(vbox), unhbox, FALSE, FALSE, 3);
217
	gtk_box_pack_start(GTK_BOX(vbox), unhbox, FALSE, FALSE, 3);
206
	gtk_box_pack_start(GTK_BOX(vbox), pwhbox, FALSE, FALSE, 3);
218
	gtk_box_pack_start(GTK_BOX(vbox), pwhbox, FALSE, FALSE, 3);
207
	gtk_box_pack_start(GTK_BOX(vbox), enhbox, FALSE, FALSE, 3);
219
	gtk_box_pack_start(GTK_BOX(vbox), enhbox, FALSE, FALSE, 3);
208
	
220
	gtk_box_pack_start(GTK_BOX(vbox), prhbox, FALSE, FALSE, 3);
221
222
209
	hbox = gtk_hbox_new(FALSE, 0);
223
	hbox = gtk_hbox_new(FALSE, 0);
210
224
211
	btnok = gtk_button_new_with_label("OK");
225
	btnok = gtk_button_new_with_label("OK");
Lines 220-226 void configure_dialog(void) Link Here
220
	
234
	
221
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);
235
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);
222
236
223
	frame = gtk_frame_new(" The plugin will have to be restarted for username/password changes to take effect! ");
237
	frame = gtk_frame_new(" The plugin will have to be restarted for username/password and proxy changes to take effect! ");
224
	gtk_container_add(GTK_CONTAINER(frame), vbox);
238
	gtk_container_add(GTK_CONTAINER(frame), vbox);
225
	gtk_container_add(GTK_CONTAINER(cnfdlg), frame);
239
	gtk_container_add(GTK_CONTAINER(cnfdlg), frame);
226
	if ((cfgfile = xmms_cfg_open_default_file())) {
240
	if ((cfgfile = xmms_cfg_open_default_file())) {
Lines 240-245 void configure_dialog(void) Link Here
240
			g_free(entry);
254
			g_free(entry);
241
		}
255
		}
242
256
257
		entry = NULL;
258
		xmms_cfg_read_string(cfgfile, "audioscrobbler", "proxy", &entry);
259
		if (entry) {
260
			gtk_entry_set_text(GTK_ENTRY(edprx), entry);
261
			g_free(entry);
262
		}
263
243
		xmms_cfg_free(cfgfile);
264
		xmms_cfg_free(cfgfile);
244
	}
265
	}
245
	
266
	
(-)xmms-scrobbler-0.3.8.1/scrobbler.c (-2 / +177 lines)
Lines 42-47 static char *sc_submit_url, Link Here
42
		sc_curl_errbuf[CURL_ERROR_SIZE],
42
		sc_curl_errbuf[CURL_ERROR_SIZE],
43
		*sc_major_error;
43
		*sc_major_error;
44
44
45
char* proxy_server = NULL;
46
45
static void dump_queue();
47
static void dump_queue();
46
48
47
/* Error functions */
49
/* Error functions */
Lines 227-232 static void hexify(char *pass, int len) Link Here
227
229
228
static int sc_handshake(void)
230
static int sc_handshake(void)
229
{
231
{
232
	pdebug("Handshaking directly", DEBUG);
233
	int status;
234
	char buf[4096];
235
	CURL *curl;
236
237
	snprintf(buf, sizeof(buf), "%s/?hs=true&p=%s&c=%s&v=%s&u=%s",
238
			SCROBBLER_HS_URL, SCROBBLER_VERSION,
239
			SCROBBLER_CLI_ID, VERSION, sc_username);
240
241
	curl = curl_easy_init();
242
	curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
243
	curl_easy_setopt(curl, CURLOPT_URL, buf);
244
	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, 
245
			sc_store_res);
246
	memset(sc_curl_errbuf, 0, sizeof(sc_curl_errbuf));
247
	curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, sc_curl_errbuf);
248
	curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
249
	status = curl_easy_perform(curl);
250
	curl_easy_cleanup(curl);
251
252
	sc_hs_timeout = time(NULL) + SCROBBLER_HS_WAIT;
253
254
	if (status) {
255
		pdebug(sc_curl_errbuf, DEBUG);
256
		sc_hs_errors++;
257
		sc_free_res();
258
		return -1;
259
	}
260
261
	if (sc_parse_hs_res()) {
262
		sc_hs_errors++;
263
		sc_free_res();
264
		return -1;
265
	}
266
267
	if (sc_challenge_hash != NULL) {
268
		md5_state_t md5state;
269
		unsigned char md5pword[16];
270
		
271
		md5_init(&md5state);
272
		/*pdebug(fmt_vastr("Pass Hash: %s", sc_password), DEBUG);*/
273
		md5_append(&md5state, (unsigned const char *)sc_password,
274
				strlen(sc_password));
275
		/*pdebug(fmt_vastr("Challenge Hash: %s", sc_challenge_hash), DEBUG);*/
276
		md5_append(&md5state, (unsigned const char *)sc_challenge_hash,
277
				strlen(sc_challenge_hash));
278
		md5_finish(&md5state, md5pword);
279
		hexify(md5pword, sizeof(md5pword));
280
		/*pdebug(fmt_vastr("Response Hash: %s", sc_response_hash), DEBUG);*/
281
	}
282
283
	sc_hs_errors = 0;
284
	sc_hs_status = 1;
285
286
	sc_free_res();
287
288
	pdebug(fmt_vastr("submiturl: %s - interval: %d", 
289
				sc_submit_url, sc_submit_interval), DEBUG);
290
291
	return 0;
292
}
293
294
static int sc_handshake_proxy(void)
295
{
296
	pdebug("Handshaking through proxy", DEBUG);
297
	if (!proxy_server)
298
	{
299
		pdebug("No proxy specified", DEBUG);
300
		sc_hs_errors++;
301
		sc_free_res();
302
		return -1;
303
	}
304
	pdebug(proxy_server, DEBUG);
305
230
	int status;
306
	int status;
231
	char buf[4096];
307
	char buf[4096];
232
	CURL *curl;
308
	CURL *curl;
Lines 240-245 static int sc_handshake(void) Link Here
240
	curl_easy_setopt(curl, CURLOPT_URL, buf);
316
	curl_easy_setopt(curl, CURLOPT_URL, buf);
241
	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, 
317
	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, 
242
			sc_store_res);
318
			sc_store_res);
319
	curl_easy_setopt(curl, CURLOPT_PROXY, proxy_server);
320
	
243
	memset(sc_curl_errbuf, 0, sizeof(sc_curl_errbuf));
321
	memset(sc_curl_errbuf, 0, sizeof(sc_curl_errbuf));
244
	curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, sc_curl_errbuf);
322
	curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, sc_curl_errbuf);
245
	curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
323
	curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
Lines 399-405 static int sc_generateentry(GString *sub Link Here
399
	i = 0;
477
	i = 0;
400
#ifdef ALLOW_MULTIPLE
478
#ifdef ALLOW_MULTIPLE
401
	q_peekall(1);
479
	q_peekall(1);
402
	while ((item = q_peekall(0)) && i < 10) {
480
	while ((item = q_peekall(0)) /* && i < 10 */ ) {
403
#else
481
#else
404
		item = q_peek();
482
		item = q_peek();
405
#endif
483
#endif
Lines 427-432 static int sc_generateentry(GString *sub Link Here
427
505
428
static int sc_submitentry(gchar *entry)
506
static int sc_submitentry(gchar *entry)
429
{
507
{
508
	pdebug("Submitting directly", DEBUG);
509
	CURL *curl;
510
	/* struct HttpPost *post = NULL , *last = NULL; */
511
	int status;
512
        GString *submission;
513
514
	curl = curl_easy_init();
515
	curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
516
	curl_easy_setopt(curl, CURLOPT_URL, sc_submit_url);
517
	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
518
			sc_store_res);
519
	curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT);
520
	curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
521
	/*cfa(&post, &last, "debug", "failed");*/
522
523
	/*pdebug(fmt_vastr("Username: %s", sc_username), DEBUG);*/
524
        submission = g_string_new("u=");
525
        g_string_append(submission,(gchar *)sc_username);
526
527
	/*pdebug(fmt_vastr("Response Hash: %s", sc_response_hash), DEBUG);*/
528
        g_string_append(submission,"&s=");
529
        g_string_append(submission,(gchar *)sc_response_hash);
530
531
	g_string_append(submission, entry);
532
533
	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, (char *)submission->str);
534
	memset(sc_curl_errbuf, 0, sizeof(sc_curl_errbuf));
535
	curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, sc_curl_errbuf);
536
537
	/*
538
	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
539
	curl_easy_setopt(curl, CURLOPT_TIMEOUT, SCROBBLER_SB_WAIT);
540
	*/
541
542
	status = curl_easy_perform(curl);
543
544
	curl_easy_cleanup(curl);
545
546
        g_string_free(submission,TRUE);
547
548
	if (status) {
549
		pdebug(sc_curl_errbuf, DEBUG);
550
		sc_sb_errors++;
551
		sc_free_res();
552
		return -1;
553
	}
554
555
	if (sc_parse_sb_res()) {
556
		sc_sb_errors++;
557
		sc_free_res();
558
		pdebug(fmt_vastr("Retrying in %d secs, %d elements in queue",
559
					sc_submit_interval, q_len()), DEBUG);
560
		return -1;
561
	}
562
	sc_free_res();
563
	return 0;
564
}
565
566
static int sc_submitentry_proxy(gchar *entry)
567
{
568
	pdebug("Submitting through proxy", DEBUG);
569
	if (!proxy_server)
570
	{
571
		pdebug("No proxy specified", DEBUG);
572
		sc_sb_errors++;
573
		sc_free_res();
574
		return -1;		
575
	}
576
	pdebug(proxy_server, DEBUG);
577
430
	CURL *curl;
578
	CURL *curl;
431
	/* struct HttpPost *post = NULL , *last = NULL; */
579
	/* struct HttpPost *post = NULL , *last = NULL; */
432
	int status;
580
	int status;
Lines 439-444 static int sc_submitentry(gchar *entry) Link Here
439
			sc_store_res);
587
			sc_store_res);
440
	curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT);
588
	curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT);
441
	curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
589
	curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
590
	curl_easy_setopt(curl, CURLOPT_PROXY, proxy_server);
442
	/*cfa(&post, &last, "debug", "failed");*/
591
	/*cfa(&post, &last, "debug", "failed");*/
443
592
444
	/*pdebug(fmt_vastr("Username: %s", sc_username), DEBUG);*/
593
	/*pdebug(fmt_vastr("Username: %s", sc_username), DEBUG);*/
Lines 527-532 static void sc_handlequeue(pthread_mutex Link Here
527
676
528
				sc_sb_errors = 0;
677
				sc_sb_errors = 0;
529
			}
678
			}
679
			else
680
			{
681
				if(!sc_submitentry_proxy(submitentry->str))
682
				{
683
					pthread_mutex_lock(&mutex);
684
	
685
#ifdef ALLOW_MULTIPLE
686
					q_free();
687
#else
688
					q_get();
689
#endif
690
					/*
691
					* This should make sure that the queue doesn't
692
					* get submitted multiple times on a nasty
693
					* segfault...
694
					*/
695
					dump_queue();
696
	
697
					pthread_mutex_unlock(&mutex);
698
	
699
					sc_sb_errors = 0;
700
				}
701
702
			}
530
			if(sc_sb_errors)
703
			if(sc_sb_errors)
531
			{
704
			{
532
				if(sc_sb_errors < 5)
705
				if(sc_sb_errors < 5)
Lines 707-713 static void sc_checkhandshake(void) Link Here
707
		return;
880
		return;
708
	if (sc_hs_timeout < time(NULL))
881
	if (sc_hs_timeout < time(NULL))
709
	{
882
	{
710
		sc_handshake();
883
		if (sc_handshake())
884
			sc_handshake_proxy();
885
		
711
886
712
		if(sc_hs_errors)
887
		if(sc_hs_errors)
713
		{
888
		{
(-)xmms-scrobbler-0.3.8.1/scrobbler.h (+2 lines)
Lines 7-10 void sc_cleaner(void); Link Here
7
int sc_catch_error(void);
7
int sc_catch_error(void);
8
char *sc_fetch_error(void);
8
char *sc_fetch_error(void);
9
void sc_clear_error(void);
9
void sc_clear_error(void);
10
11
extern char* proxy_server;
10
#endif
12
#endif
(-)xmms-scrobbler-0.3.8.1/xmms_scrobbler.c (-1 / +19 lines)
Lines 59-65 static GeneralPlugin xmms_scrobbler = Link Here
59
59
60
static void init(void)
60
static void init(void)
61
{
61
{
62
	char *username = NULL, *password = NULL, *encoding = NULL;
62
	char *username = NULL, *password = NULL, *encoding = NULL, *proxy = NULL;
63
	ConfigFile *cfgfile;
63
	ConfigFile *cfgfile;
64
	going = 1;
64
	going = 1;
65
65
Lines 70-75 static void init(void) Link Here
70
				&password);
70
				&password);
71
		xmms_cfg_read_string(cfgfile, "audioscrobbler", "encoding",
71
		xmms_cfg_read_string(cfgfile, "audioscrobbler", "encoding",
72
				&encoding);
72
				&encoding);
73
		xmms_cfg_read_string(cfgfile, "audioscrobbler", "proxy",
74
				&proxy);
73
		xmms_cfg_free(cfgfile);
75
		xmms_cfg_free(cfgfile);
74
	}
76
	}
75
	if ((!username || !password) || (!*username || !*password)) {
77
	if ((!username || !password) || (!*username || !*password)) {
Lines 82-87 static void init(void) Link Here
82
		tags_encoding = g_strdup(encoding);
84
		tags_encoding = g_strdup(encoding);
83
		g_free(encoding);
85
		g_free(encoding);
84
	}
86
	}
87
	if (proxy) {
88
		proxy_server = g_strdup(proxy);
89
		g_free(proxy);
90
		pdebug(fmt_vastr("Got proxy %s from cfg", proxy_server), DEBUG);
91
	}
92
	else
93
	{
94
		proxy_server = getenv("HTTP_PROXY");
95
		if (proxy_server) {
96
			pdebug(fmt_vastr("Got proxy %s from getenv(\"HTTP_PROXY\")", 
97
				proxy_server), DEBUG);
98
		} else {
99
			pdebug("No proxy specified", DEBUG);
100
		}
101
	}
102
	
85
	sc_init(username, password);
103
	sc_init(username, password);
86
	g_free(username);
104
	g_free(username);
87
	g_free(password);
105
	g_free(password);

Return to bug 14017