Mercurial > audlegacy-plugins
annotate src/scrobbler/gerpok.c @ 1982:0ea55fc6f220
scrobbler: vtable fixing
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Sun, 07 Oct 2007 01:10:41 -0500 |
parents | 5fa26178eaef |
children | 2e961ce4bfe8 |
rev | line source |
---|---|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
1 #include "settings.h" |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
2 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
3 #include <pthread.h> |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
4 #include <limits.h> |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
5 #include <stdlib.h> |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
6 #include <string.h> |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
7 #include <stdarg.h> |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
8 #include <curl/curl.h> |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
9 #include <stdio.h> |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
10 #include "fmt.h" |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
11 #include "md5.h" |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
12 #include "scrobbler.h" |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
13 #include "config.h" |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
14 #include <glib.h> |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
15 |
1982
0ea55fc6f220
scrobbler: vtable fixing
William Pitcock <nenolod@atheme.org>
parents:
1976
diff
changeset
|
16 #include <audacious/plugin.h> |
732 | 17 #include <audacious/util.h> |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
18 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
19 #define SCROBBLER_HS_URL "http://post.gerpok.com" |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
20 #define SCROBBLER_CLI_ID "aud" |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
21 #define SCROBBLER_HS_WAIT 1800 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
22 #define SCROBBLER_SB_WAIT 10 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
23 #define SCROBBLER_VERSION "1.1" |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
24 #define SCROBBLER_IMPLEMENTATION "0.1" /* This is the implementation, not the player version. */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
25 #define SCROBBLER_SB_MAXLEN 1024 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
26 #define CACHE_SIZE 1024 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
27 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
28 /* Scrobblerbackend for xmms plugin, first draft */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
29 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
30 static int gerpok_sc_hs_status, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
31 gerpok_sc_hs_timeout, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
32 gerpok_sc_hs_errors, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
33 gerpok_sc_sb_errors, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
34 gerpok_sc_bad_users, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
35 gerpok_sc_submit_interval, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
36 gerpok_sc_submit_timeout, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
37 gerpok_sc_srv_res_size, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
38 gerpok_sc_giveup, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
39 gerpok_sc_major_error_present; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
40 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
41 static char *gerpok_sc_submit_url, |
348
314b7ac7f771
[svn] - handle no account data gracefully (e.g. you only use one of the
nenolod
parents:
344
diff
changeset
|
42 *gerpok_sc_username = NULL, |
314b7ac7f771
[svn] - handle no account data gracefully (e.g. you only use one of the
nenolod
parents:
344
diff
changeset
|
43 *gerpok_sc_password = NULL, |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
44 *gerpok_sc_challenge_hash, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
45 gerpok_sc_response_hash[33], |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
46 *gerpok_sc_srv_res, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
47 gerpok_sc_curl_errbuf[CURL_ERROR_SIZE], |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
48 *gerpok_sc_major_error; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
49 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
50 static void dump_queue(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
51 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
52 /**** Queue stuff ****/ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
53 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
54 #define I_ARTIST(i) i->artist |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
55 #define I_TITLE(i) i->title |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
56 #define I_TIME(i) i->utctime |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
57 #define I_LEN(i) i->len |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
58 #define I_MB(i) i->mb |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
59 #define I_ALBUM(i) i->album |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
60 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
61 typedef struct { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
62 char *artist, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
63 *title, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
64 *mb, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
65 *album, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
66 *utctime, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
67 len[16]; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
68 int numtries; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
69 void *next; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
70 } item_t; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
71 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
72 static item_t *q_queue = NULL; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
73 static item_t *q_queue_last = NULL; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
74 static int q_nitems; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
75 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
76 static void q_item_free(item_t *item) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
77 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
78 if (item == NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
79 return; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
80 curl_free(item->artist); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
81 curl_free(item->title); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
82 curl_free(item->utctime); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
83 curl_free(item->mb); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
84 curl_free(item->album); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
85 free(item); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
86 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
87 |
1443
f4d8082668c1
scrobbler: tuple API update
William Pitcock <nenolod@atheme-project.org>
parents:
990
diff
changeset
|
88 static void q_put(Tuple *tuple, int len) |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
89 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
90 item_t *item; |
1443
f4d8082668c1
scrobbler: tuple API update
William Pitcock <nenolod@atheme-project.org>
parents:
990
diff
changeset
|
91 const gchar *album; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
92 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
93 item = malloc(sizeof(item_t)); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
94 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1687
diff
changeset
|
95 item->artist = fmt_escape(aud_tuple_get_string(tuple, FIELD_ARTIST, NULL)); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1687
diff
changeset
|
96 item->title = fmt_escape(aud_tuple_get_string(tuple, FIELD_TITLE, NULL)); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
97 item->utctime = fmt_escape(fmt_timestr(time(NULL), 1)); |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1443
diff
changeset
|
98 g_snprintf(item->len, sizeof(item->len), "%d", len); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
99 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
100 #ifdef NOTYET |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
101 if(tuple->mb == NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
102 #endif |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
103 item->mb = fmt_escape(""); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
104 #ifdef NOTYET |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
105 else |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
106 item->mb = fmt_escape((char*)tuple->mb); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
107 #endif |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
108 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1687
diff
changeset
|
109 if((album = aud_tuple_get_string(tuple, FIELD_ALBUM, NULL))) |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
110 item->album = fmt_escape(""); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
111 else |
1443
f4d8082668c1
scrobbler: tuple API update
William Pitcock <nenolod@atheme-project.org>
parents:
990
diff
changeset
|
112 item->album = fmt_escape((char*) album); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
113 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
114 q_nitems++; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
115 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
116 item->next = NULL; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
117 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
118 if(q_queue_last == NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
119 q_queue = q_queue_last = item; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
120 else |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
121 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
122 q_queue_last->next = item; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
123 q_queue_last = item; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
124 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
125 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
126 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
127 static item_t *q_put2(char *artist, char *title, char *len, char *time, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
128 char *album, char *mb) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
129 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
130 char *temp = NULL; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
131 item_t *item; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
132 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
133 item = calloc(1, sizeof(item_t)); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
134 temp = fmt_unescape(artist); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
135 item->artist = fmt_escape(temp); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
136 curl_free(temp); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
137 temp = fmt_unescape(title); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
138 item->title = fmt_escape(temp); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
139 curl_free(temp); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
140 memcpy(item->len, len, sizeof(len)); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
141 temp = fmt_unescape(time); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
142 item->utctime = fmt_escape(temp); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
143 curl_free(temp); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
144 temp = fmt_unescape(album); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
145 item->album = fmt_escape(temp); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
146 curl_free(temp); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
147 temp = fmt_unescape(mb); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
148 item->mb = fmt_escape(temp); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
149 curl_free(temp); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
150 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
151 q_nitems++; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
152 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
153 item->next = NULL; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
154 if(q_queue_last == NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
155 q_queue = q_queue_last = item; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
156 else |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
157 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
158 q_queue_last->next = item; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
159 q_queue_last = item; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
160 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
161 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
162 return item; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
163 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
164 |
990
238055a6cb8f
[svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents:
786
diff
changeset
|
165 #if 0 |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
166 static item_t *q_peek(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
167 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
168 if (q_nitems == 0) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
169 return NULL; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
170 return q_queue; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
171 } |
990
238055a6cb8f
[svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents:
786
diff
changeset
|
172 #endif |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
173 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
174 static item_t *q_peekall(int rewind) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
175 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
176 static item_t *citem = NULL; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
177 item_t *temp_item; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
178 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
179 if (rewind) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
180 citem = q_queue; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
181 return NULL; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
182 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
183 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
184 temp_item = citem; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
185 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
186 if(citem != NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
187 citem = citem->next; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
188 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
189 return temp_item; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
190 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
191 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
192 static int q_get(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
193 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
194 item_t *item; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
195 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
196 if (q_nitems == 0) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
197 return 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
198 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
199 item = q_queue; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
200 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
201 if(item == NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
202 return 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
203 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
204 q_nitems--; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
205 q_queue = q_queue->next; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
206 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
207 q_item_free(item); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
208 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
209 if (q_nitems == 0) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
210 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
211 q_queue_last = NULL; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
212 return 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
213 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
214 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
215 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
216 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
217 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
218 static void q_free(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
219 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
220 while (q_get()); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
221 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
222 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
223 static int q_len(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
224 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
225 return q_nitems; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
226 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
227 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
228 /* Error functions */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
229 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
230 static void gerpok_sc_throw_error(char *errortxt) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
231 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
232 gerpok_sc_major_error_present = 1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
233 if(gerpok_sc_major_error == NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
234 gerpok_sc_major_error = strdup(errortxt); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
235 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
236 return; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
237 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
238 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
239 int gerpok_sc_catch_error(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
240 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
241 return gerpok_sc_major_error_present; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
242 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
243 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
244 char *gerpok_sc_fetch_error(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
245 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
246 return gerpok_sc_major_error; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
247 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
248 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
249 void gerpok_sc_clear_error(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
250 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
251 gerpok_sc_major_error_present = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
252 if(gerpok_sc_major_error != NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
253 free(gerpok_sc_major_error); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
254 gerpok_sc_major_error = NULL; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
255 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
256 return; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
257 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
258 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
259 static size_t gerpok_sc_store_res(void *ptr, size_t size, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
260 size_t nmemb, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
261 void *stream __attribute__((unused))) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
262 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
263 int len = size * nmemb; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
264 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
265 gerpok_sc_srv_res = realloc(gerpok_sc_srv_res, gerpok_sc_srv_res_size + len + 1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
266 memcpy(gerpok_sc_srv_res + gerpok_sc_srv_res_size, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
267 ptr, len); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
268 gerpok_sc_srv_res_size += len; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
269 return len; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
270 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
271 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
272 static void gerpok_sc_free_res(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
273 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
274 if(gerpok_sc_srv_res != NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
275 free(gerpok_sc_srv_res); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
276 gerpok_sc_srv_res = NULL; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
277 gerpok_sc_srv_res_size = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
278 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
279 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
280 static int gerpok_sc_parse_hs_res(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
281 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
282 char *interval; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
283 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
284 if (!gerpok_sc_srv_res_size) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
285 pdebug("No reply from server", DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
286 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
287 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
288 *(gerpok_sc_srv_res + gerpok_sc_srv_res_size) = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
289 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
290 if (!strncmp(gerpok_sc_srv_res, "FAILED ", 7)) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
291 interval = strstr(gerpok_sc_srv_res, "INTERVAL"); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
292 if(!interval) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
293 pdebug("missing INTERVAL", DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
294 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
295 else |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
296 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
297 *(interval - 1) = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
298 gerpok_sc_submit_interval = strtol(interval + 8, NULL, 10); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
299 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
300 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
301 /* Throwing a major error, just in case */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
302 /* gerpok_sc_throw_error(fmt_vastr("%s", gerpok_sc_srv_res)); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
303 gerpok_sc_hs_errors++; */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
304 pdebug(fmt_vastr("error: %s", gerpok_sc_srv_res), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
305 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
306 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
307 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
308 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
309 if (!strncmp(gerpok_sc_srv_res, "UPDATE ", 7)) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
310 interval = strstr(gerpok_sc_srv_res, "INTERVAL"); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
311 if(!interval) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
312 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
313 pdebug("missing INTERVAL", DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
314 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
315 else |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
316 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
317 *(interval - 1) = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
318 gerpok_sc_submit_interval = strtol(interval + 8, NULL, 10); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
319 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
320 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
321 gerpok_sc_submit_url = strchr(strchr(gerpok_sc_srv_res, '\n') + 1, '\n') + 1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
322 *(gerpok_sc_submit_url - 1) = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
323 gerpok_sc_submit_url = strdup(gerpok_sc_submit_url); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
324 gerpok_sc_challenge_hash = strchr(gerpok_sc_srv_res, '\n') + 1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
325 *(gerpok_sc_challenge_hash - 1) = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
326 gerpok_sc_challenge_hash = strdup(gerpok_sc_challenge_hash); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
327 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
328 /* Throwing major error. Need to alert client to update. */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
329 gerpok_sc_throw_error(fmt_vastr("Please update Audacious.\n" |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
330 "Update available at: http://audacious-media-player.org")); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
331 pdebug(fmt_vastr("update client: %s", gerpok_sc_srv_res + 7), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
332 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
333 /* |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
334 * Russ isn't clear on whether we can submit with a not-updated |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
335 * client. Neither is RJ. I use what we did before. |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
336 */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
337 gerpok_sc_giveup = -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
338 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
339 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
340 if (!strncmp(gerpok_sc_srv_res, "UPTODATE\n", 9)) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
341 gerpok_sc_bad_users = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
342 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
343 interval = strstr(gerpok_sc_srv_res, "INTERVAL"); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
344 if (!interval) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
345 pdebug("missing INTERVAL", DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
346 /* |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
347 * This is probably a bad thing, but Russ seems to |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
348 * think its OK to assume that an UPTODATE response |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
349 * may not have an INTERVAL... We return -1 anyway. |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
350 */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
351 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
352 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
353 else |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
354 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
355 *(interval - 1) = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
356 gerpok_sc_submit_interval = strtol(interval + 8, NULL, 10); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
357 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
358 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
359 gerpok_sc_submit_url = strchr(strchr(gerpok_sc_srv_res, '\n') + 1, '\n') + 1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
360 *(gerpok_sc_submit_url - 1) = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
361 gerpok_sc_submit_url = strdup(gerpok_sc_submit_url); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
362 gerpok_sc_challenge_hash = strchr(gerpok_sc_srv_res, '\n') + 1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
363 *(gerpok_sc_challenge_hash - 1) = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
364 gerpok_sc_challenge_hash = strdup(gerpok_sc_challenge_hash); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
365 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
366 return 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
367 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
368 if(!strncmp(gerpok_sc_srv_res, "BADUSER", 7)) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
369 /* Throwing major error. */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
370 gerpok_sc_throw_error("Incorrect username/password.\n" |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
371 "Please fix in configuration."); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
372 pdebug("incorrect username/password", DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
373 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
374 interval = strstr(gerpok_sc_srv_res, "INTERVAL"); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
375 if(!interval) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
376 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
377 pdebug("missing INTERVAL", DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
378 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
379 else |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
380 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
381 *(interval - 1) = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
382 gerpok_sc_submit_interval = strtol(interval + 8, NULL, 10); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
383 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
384 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
385 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
386 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
387 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
388 pdebug(fmt_vastr("unknown server-reply '%s'", gerpok_sc_srv_res), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
389 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
390 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
391 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
392 static void hexify(char *pass, int len) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
393 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
394 char *bp = gerpok_sc_response_hash; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
395 char hexchars[] = "0123456789abcdef"; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
396 int i; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
397 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
398 memset(gerpok_sc_response_hash, 0, sizeof(gerpok_sc_response_hash)); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
399 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
400 for(i = 0; i < len; i++) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
401 *(bp++) = hexchars[(pass[i] >> 4) & 0x0f]; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
402 *(bp++) = hexchars[pass[i] & 0x0f]; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
403 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
404 *bp = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
405 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
406 return; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
407 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
408 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
409 static int gerpok_sc_handshake(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
410 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
411 int status; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
412 char buf[4096]; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
413 CURL *curl; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
414 |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1443
diff
changeset
|
415 g_snprintf(buf, sizeof(buf), "%s/?hs=true&p=%s&c=%s&v=%s&u=%s", |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
416 SCROBBLER_HS_URL, SCROBBLER_VERSION, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
417 SCROBBLER_CLI_ID, SCROBBLER_IMPLEMENTATION, gerpok_sc_username); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
418 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
419 curl = curl_easy_init(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
420 curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
421 curl_easy_setopt(curl, CURLOPT_URL, buf); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
422 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
423 gerpok_sc_store_res); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
424 memset(gerpok_sc_curl_errbuf, 0, sizeof(gerpok_sc_curl_errbuf)); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
425 curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, gerpok_sc_curl_errbuf); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
426 curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
401
192004e2a1b7
[svn] - add connection timeout option to curl_easy_perform(). hopefully, audacious can quit smoothly even though last.fm server goes down.
yaz
parents:
348
diff
changeset
|
427 curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); |
192004e2a1b7
[svn] - add connection timeout option to curl_easy_perform(). hopefully, audacious can quit smoothly even though last.fm server goes down.
yaz
parents:
348
diff
changeset
|
428 curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, SC_CURL_TIMEOUT); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
429 status = curl_easy_perform(curl); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
430 curl_easy_cleanup(curl); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
431 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
432 gerpok_sc_hs_timeout = time(NULL) + SCROBBLER_HS_WAIT; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
433 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
434 if (status) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
435 pdebug(gerpok_sc_curl_errbuf, DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
436 gerpok_sc_hs_errors++; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
437 gerpok_sc_free_res(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
438 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
439 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
440 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
441 if (gerpok_sc_parse_hs_res()) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
442 gerpok_sc_hs_errors++; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
443 gerpok_sc_free_res(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
444 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
445 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
446 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
447 if (gerpok_sc_challenge_hash != NULL) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
448 md5_state_t md5state; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
449 unsigned char md5pword[16]; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
450 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
451 md5_init(&md5state); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
452 /*pdebug(fmt_vastr("Pass Hash: %s", gerpok_sc_password), DEBUG);*/ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
453 md5_append(&md5state, (unsigned const char *)gerpok_sc_password, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
454 strlen(gerpok_sc_password)); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
455 /*pdebug(fmt_vastr("Challenge Hash: %s", gerpok_sc_challenge_hash), DEBUG);*/ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
456 md5_append(&md5state, (unsigned const char *)gerpok_sc_challenge_hash, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
457 strlen(gerpok_sc_challenge_hash)); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
458 md5_finish(&md5state, md5pword); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
459 hexify((char*)md5pword, sizeof(md5pword)); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
460 /*pdebug(fmt_vastr("Response Hash: %s", gerpok_sc_response_hash), DEBUG);*/ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
461 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
462 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
463 gerpok_sc_hs_errors = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
464 gerpok_sc_hs_status = 1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
465 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
466 gerpok_sc_free_res(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
467 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
468 pdebug(fmt_vastr("submiturl: %s - interval: %d", |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
469 gerpok_sc_submit_url, gerpok_sc_submit_interval), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
470 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
471 return 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
472 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
473 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
474 static int gerpok_sc_parse_sb_res(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
475 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
476 char *ch, *ch2; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
477 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
478 if (!gerpok_sc_srv_res_size) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
479 pdebug("No response from server", DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
480 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
481 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
482 *(gerpok_sc_srv_res + gerpok_sc_srv_res_size) = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
483 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
484 if (!strncmp(gerpok_sc_srv_res, "OK", 2)) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
485 if ((ch = strstr(gerpok_sc_srv_res, "INTERVAL"))) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
486 gerpok_sc_submit_interval = strtol(ch + 8, NULL, 10); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
487 pdebug(fmt_vastr("got new interval: %d", |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
488 gerpok_sc_submit_interval), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
489 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
490 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
491 pdebug(fmt_vastr("submission ok: %s", gerpok_sc_srv_res), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
492 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
493 return 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
494 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
495 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
496 if (!strncmp(gerpok_sc_srv_res, "BADAUTH", 7)) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
497 if ((ch = strstr(gerpok_sc_srv_res, "INTERVAL"))) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
498 gerpok_sc_submit_interval = strtol(ch + 8, NULL, 10); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
499 pdebug(fmt_vastr("got new interval: %d", |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
500 gerpok_sc_submit_interval), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
501 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
502 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
503 pdebug("incorrect username/password", DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
504 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
505 gerpok_sc_giveup = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
506 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
507 /* |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
508 * We obviously aren't authenticated. The server might have |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
509 * lost our handshake status though, so let's try |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
510 * re-handshaking... This might not be proper. |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
511 * (we don't give up) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
512 */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
513 gerpok_sc_hs_status = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
514 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
515 if(gerpok_sc_challenge_hash != NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
516 free(gerpok_sc_challenge_hash); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
517 if(gerpok_sc_submit_url != NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
518 free(gerpok_sc_submit_url); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
519 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
520 gerpok_sc_challenge_hash = gerpok_sc_submit_url = NULL; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
521 gerpok_sc_bad_users++; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
522 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
523 if(gerpok_sc_bad_users > 2) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
524 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
525 pdebug("3 BADAUTH returns on submission. Halting " |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
526 "submissions until login fixed.", DEBUG) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
527 gerpok_sc_throw_error("Incorrect username/password.\n" |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
528 "Please fix in configuration."); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
529 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
530 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
531 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
532 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
533 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
534 if (!strncmp(gerpok_sc_srv_res, "FAILED", 6)) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
535 if ((ch = strstr(gerpok_sc_srv_res, "INTERVAL"))) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
536 gerpok_sc_submit_interval = strtol(ch + 8, NULL, 10); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
537 pdebug(fmt_vastr("got new interval: %d", |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
538 gerpok_sc_submit_interval), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
539 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
540 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
541 /* This could be important. (Such as FAILED - Get new plugin) */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
542 /*gerpok_sc_throw_error(fmt_vastr("%s", gerpok_sc_srv_res));*/ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
543 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
544 pdebug(gerpok_sc_srv_res, DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
545 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
546 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
547 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
548 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
549 if (!strncmp(gerpok_sc_srv_res, "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">", 50)) { |
786
c23705487009
[svn] - avoid crash when error message doesn't contain <TITLE>.
yaz
parents:
733
diff
changeset
|
550 ch = strstr(gerpok_sc_srv_res, "<TITLE>"); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
551 ch2 = strstr(gerpok_sc_srv_res, "</TITLE>"); |
786
c23705487009
[svn] - avoid crash when error message doesn't contain <TITLE>.
yaz
parents:
733
diff
changeset
|
552 if (ch != NULL && ch2 != NULL) { |
c23705487009
[svn] - avoid crash when error message doesn't contain <TITLE>.
yaz
parents:
733
diff
changeset
|
553 ch += strlen("<TITLE>"); |
c23705487009
[svn] - avoid crash when error message doesn't contain <TITLE>.
yaz
parents:
733
diff
changeset
|
554 *ch2 = '\0'; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
555 |
786
c23705487009
[svn] - avoid crash when error message doesn't contain <TITLE>.
yaz
parents:
733
diff
changeset
|
556 pdebug(fmt_vastr("HTTP Error (%d): '%s'", |
c23705487009
[svn] - avoid crash when error message doesn't contain <TITLE>.
yaz
parents:
733
diff
changeset
|
557 atoi(ch), ch + 4), DEBUG); |
c23705487009
[svn] - avoid crash when error message doesn't contain <TITLE>.
yaz
parents:
733
diff
changeset
|
558 // *ch2 = '<'; // needed? --yaz |
c23705487009
[svn] - avoid crash when error message doesn't contain <TITLE>.
yaz
parents:
733
diff
changeset
|
559 } |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
560 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
561 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
562 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
563 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
564 pdebug(fmt_vastr("unknown server-reply %s", gerpok_sc_srv_res), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
565 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
566 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
567 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
568 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
569 static gchar *gerpok_sc_itemtag(char c, int n, char *str) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
570 { |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1443
diff
changeset
|
571 static char buf[SCROBBLER_SB_MAXLEN]; |
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1443
diff
changeset
|
572 g_snprintf(buf, SCROBBLER_SB_MAXLEN, "&%c[%d]=%s", c, n, str); |
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1443
diff
changeset
|
573 return buf; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
574 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
575 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
576 #define cfa(f, l, n, v) \ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
577 curl_formadd(f, l, CURLFORM_COPYNAME, n, \ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
578 CURLFORM_PTRCONTENTS, v, CURLFORM_END) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
579 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
580 static int gerpok_sc_generateentry(GString *submission) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
581 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
582 int i; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
583 item_t *item; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
584 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
585 i = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
586 #ifdef ALLOW_MULTIPLE |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
587 q_peekall(1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
588 while ((item = q_peekall(0)) && i < 10) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
589 #else |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
590 item = q_peek(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
591 #endif |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
592 if (!item) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
593 return i; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
594 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
595 g_string_append(submission,gerpok_sc_itemtag('a',i,I_ARTIST(item))); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
596 g_string_append(submission,gerpok_sc_itemtag('t',i,I_TITLE(item))); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
597 g_string_append(submission,gerpok_sc_itemtag('l',i,I_LEN(item))); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
598 g_string_append(submission,gerpok_sc_itemtag('i',i,I_TIME(item))); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
599 g_string_append(submission,gerpok_sc_itemtag('m',i,I_MB(item))); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
600 g_string_append(submission,gerpok_sc_itemtag('b',i,I_ALBUM(item))); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
601 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
602 pdebug(fmt_vastr("a[%d]=%s t[%d]=%s l[%d]=%s i[%d]=%s m[%d]=%s b[%d]=%s", |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
603 i, I_ARTIST(item), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
604 i, I_TITLE(item), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
605 i, I_LEN(item), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
606 i, I_TIME(item), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
607 i, I_MB(item), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
608 i, I_ALBUM(item)), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
609 #ifdef ALLOW_MULTIPLE |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
610 i++; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
611 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
612 #endif |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
613 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
614 return i; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
615 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
616 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
617 static int gerpok_sc_submitentry(gchar *entry) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
618 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
619 CURL *curl; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
620 /* struct HttpPost *post = NULL , *last = NULL; */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
621 int status; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
622 GString *submission; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
623 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
624 curl = curl_easy_init(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
625 curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
626 curl_easy_setopt(curl, CURLOPT_URL, gerpok_sc_submit_url); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
627 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
628 gerpok_sc_store_res); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
629 curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
630 curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
631 /*cfa(&post, &last, "debug", "failed");*/ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
632 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
633 /*pdebug(fmt_vastr("Username: %s", gerpok_sc_username), DEBUG);*/ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
634 submission = g_string_new("u="); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
635 g_string_append(submission,(gchar *)gerpok_sc_username); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
636 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
637 /*pdebug(fmt_vastr("Response Hash: %s", gerpok_sc_response_hash), DEBUG);*/ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
638 g_string_append(submission,"&s="); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
639 g_string_append(submission,(gchar *)gerpok_sc_response_hash); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
640 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
641 g_string_append(submission, entry); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
642 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
643 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, (char *)submission->str); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
644 memset(gerpok_sc_curl_errbuf, 0, sizeof(gerpok_sc_curl_errbuf)); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
645 curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, gerpok_sc_curl_errbuf); |
401
192004e2a1b7
[svn] - add connection timeout option to curl_easy_perform(). hopefully, audacious can quit smoothly even though last.fm server goes down.
yaz
parents:
348
diff
changeset
|
646 curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); |
192004e2a1b7
[svn] - add connection timeout option to curl_easy_perform(). hopefully, audacious can quit smoothly even though last.fm server goes down.
yaz
parents:
348
diff
changeset
|
647 curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, SC_CURL_TIMEOUT); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
648 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
649 /* |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
650 curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
651 curl_easy_setopt(curl, CURLOPT_TIMEOUT, SCROBBLER_SB_WAIT); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
652 */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
653 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
654 status = curl_easy_perform(curl); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
655 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
656 curl_easy_cleanup(curl); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
657 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
658 g_string_free(submission,TRUE); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
659 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
660 if (status) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
661 pdebug(gerpok_sc_curl_errbuf, DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
662 gerpok_sc_sb_errors++; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
663 gerpok_sc_free_res(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
664 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
665 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
666 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
667 if (gerpok_sc_parse_sb_res()) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
668 gerpok_sc_sb_errors++; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
669 gerpok_sc_free_res(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
670 pdebug(fmt_vastr("Retrying in %d secs, %d elements in queue", |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
671 gerpok_sc_submit_interval, q_len()), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
672 return -1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
673 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
674 gerpok_sc_free_res(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
675 return 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
676 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
677 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
678 static void gerpok_sc_handlequeue(GMutex *mutex) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
679 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
680 GString *submitentry; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
681 int nsubmit; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
682 int wait; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
683 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
684 if(gerpok_sc_submit_timeout < time(NULL) && gerpok_sc_bad_users < 3) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
685 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
686 submitentry = g_string_new(""); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
687 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
688 g_mutex_lock(mutex); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
689 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
690 nsubmit = gerpok_sc_generateentry(submitentry); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
691 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
692 g_mutex_unlock(mutex); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
693 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
694 if (nsubmit > 0) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
695 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
696 pdebug(fmt_vastr("Number submitting: %d", nsubmit), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
697 pdebug(fmt_vastr("Submission: %s", submitentry->str), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
698 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
699 if(!gerpok_sc_submitentry(submitentry->str)) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
700 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
701 g_mutex_lock(mutex); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
702 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
703 #ifdef ALLOW_MULTIPLE |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
704 q_free(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
705 #else |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
706 q_get(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
707 #endif |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
708 /* |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
709 * This should make sure that the queue doesn't |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
710 * get submitted multiple times on a nasty |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
711 * segfault... |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
712 */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
713 dump_queue(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
714 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
715 g_mutex_unlock(mutex); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
716 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
717 gerpok_sc_sb_errors = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
718 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
719 if(gerpok_sc_sb_errors) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
720 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
721 if(gerpok_sc_sb_errors < 5) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
722 /* Retry after 1 min */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
723 wait = 60; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
724 else |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
725 wait = /* gerpok_sc_submit_interval + */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
726 ( ((gerpok_sc_sb_errors - 5) < 7) ? |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
727 (60 << (gerpok_sc_sb_errors-5)) : |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
728 7200 ); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
729 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
730 gerpok_sc_submit_timeout = time(NULL) + wait; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
731 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
732 pdebug(fmt_vastr("Error while submitting. " |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
733 "Retrying after %d seconds.", wait), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
734 DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
735 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
736 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
737 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
738 g_string_free(submitentry, TRUE); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
739 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
740 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
741 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
742 static void read_cache(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
743 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
744 FILE *fd; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
745 char buf[PATH_MAX], *cache = NULL, *ptr1, *ptr2; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
746 int cachesize, written, i = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
747 item_t *item; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
748 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
749 cachesize = written = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
750 |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1443
diff
changeset
|
751 g_snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", audacious_get_localdir()); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
752 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
753 if (!(fd = fopen(buf, "r"))) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
754 return; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
755 pdebug(fmt_vastr("Opening %s", buf), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
756 while(!feof(fd)) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
757 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
758 cachesize += CACHE_SIZE; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
759 cache = realloc(cache, cachesize + 1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
760 written += fread(cache + written, 1, CACHE_SIZE, fd); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
761 cache[written] = '\0'; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
762 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
763 fclose(fd); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
764 ptr1 = cache; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
765 while(ptr1 < cache + written - 1) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
766 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
767 char *artist, *title, *len, *time, *album, *mb; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
768 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
769 pdebug("Pushed:", DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
770 ptr2 = strchr(ptr1, ' '); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
771 artist = calloc(1, ptr2 - ptr1 + 1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
772 strncpy(artist, ptr1, ptr2 - ptr1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
773 ptr1 = ptr2 + 1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
774 ptr2 = strchr(ptr1, ' '); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
775 title = calloc(1, ptr2 - ptr1 + 1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
776 strncpy(title, ptr1, ptr2 - ptr1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
777 ptr1 = ptr2 + 1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
778 ptr2 = strchr(ptr1, ' '); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
779 len = calloc(1, ptr2 - ptr1 + 1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
780 strncpy(len, ptr1, ptr2 - ptr1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
781 ptr1 = ptr2 + 1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
782 ptr2 = strchr(ptr1, ' '); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
783 time = calloc(1, ptr2 - ptr1 + 1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
784 strncpy(time, ptr1, ptr2 - ptr1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
785 ptr1 = ptr2 + 1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
786 ptr2 = strchr(ptr1, ' '); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
787 album = calloc(1, ptr2 - ptr1 + 1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
788 strncpy(album, ptr1, ptr2 - ptr1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
789 ptr1 = ptr2 + 1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
790 ptr2 = strchr(ptr1, '\n'); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
791 if(ptr2 != NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
792 *ptr2 = '\0'; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
793 mb = calloc(1, strlen(ptr1) + 1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
794 strncpy(mb, ptr1, strlen(ptr1)); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
795 if(ptr2 != NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
796 *ptr2 = '\n'; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
797 /* Why is our save printing out CR/LF? */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
798 ptr1 = ptr2 + 1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
799 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
800 item = q_put2(artist, title, len, time, album, mb); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
801 pdebug(fmt_vastr("a[%d]=%s t[%d]=%s l[%d]=%s i[%d]=%s m[%d]=%s b[%d]=%s", |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
802 i, I_ARTIST(item), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
803 i, I_TITLE(item), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
804 i, I_LEN(item), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
805 i, I_TIME(item), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
806 i, I_MB(item), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
807 i, I_ALBUM(item)), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
808 free(artist); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
809 free(title); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
810 free(len); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
811 free(time); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
812 free(album); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
813 free(mb); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
814 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
815 i++; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
816 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
817 pdebug("Done loading cache.", DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
818 free(cache); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
819 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
820 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
821 static void dump_queue(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
822 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
823 FILE *fd; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
824 item_t *item; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
825 char *home, buf[PATH_MAX]; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
826 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
827 /*pdebug("Entering dump_queue();", DEBUG);*/ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
828 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
829 if (!(home = getenv("HOME"))) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
830 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
831 pdebug("No HOME directory found. Cannot dump queue.", DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
832 return; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
833 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
834 |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1443
diff
changeset
|
835 g_snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", audacious_get_localdir()); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
836 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
837 if (!(fd = fopen(buf, "w"))) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
838 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
839 pdebug(fmt_vastr("Failure opening %s", buf), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
840 return; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
841 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
842 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
843 pdebug(fmt_vastr("Opening %s", buf), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
844 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
845 q_peekall(1); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
846 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
847 while ((item = q_peekall(0))) { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
848 fprintf(fd, "%s %s %s %s %s %s\n", |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
849 I_ARTIST(item), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
850 I_TITLE(item), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
851 I_LEN(item), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
852 I_TIME(item), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
853 I_ALBUM(item), |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
854 I_MB(item)); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
855 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
856 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
857 fclose(fd); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
858 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
859 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
860 /* This was made public */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
861 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
862 void gerpok_sc_cleaner(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
863 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
864 if(gerpok_sc_submit_url != NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
865 free(gerpok_sc_submit_url); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
866 if(gerpok_sc_username != NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
867 free(gerpok_sc_username); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
868 if(gerpok_sc_password != NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
869 free(gerpok_sc_password); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
870 if(gerpok_sc_challenge_hash != NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
871 free(gerpok_sc_challenge_hash); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
872 if(gerpok_sc_srv_res != NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
873 free(gerpok_sc_srv_res); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
874 if(gerpok_sc_major_error != NULL) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
875 free(gerpok_sc_major_error); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
876 dump_queue(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
877 q_free(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
878 pdebug("scrobbler shutting down", DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
879 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
880 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
881 static void gerpok_sc_checkhandshake(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
882 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
883 int wait; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
884 |
348
314b7ac7f771
[svn] - handle no account data gracefully (e.g. you only use one of the
nenolod
parents:
344
diff
changeset
|
885 if (!gerpok_sc_username || !gerpok_sc_password) |
314b7ac7f771
[svn] - handle no account data gracefully (e.g. you only use one of the
nenolod
parents:
344
diff
changeset
|
886 return; |
314b7ac7f771
[svn] - handle no account data gracefully (e.g. you only use one of the
nenolod
parents:
344
diff
changeset
|
887 |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
888 if (gerpok_sc_hs_status) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
889 return; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
890 if (gerpok_sc_hs_timeout < time(NULL)) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
891 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
892 gerpok_sc_handshake(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
893 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
894 if(gerpok_sc_hs_errors) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
895 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
896 if(gerpok_sc_hs_errors < 5) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
897 /* Retry after 60 seconds */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
898 wait = 60; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
899 else |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
900 wait = /* gerpok_sc_submit_interval + */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
901 ( ((gerpok_sc_hs_errors - 5) < 7) ? |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
902 (60 << (gerpok_sc_hs_errors-5)) : |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
903 7200 ); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
904 gerpok_sc_hs_timeout = time(NULL) + wait; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
905 pdebug(fmt_vastr("Error while handshaking. Retrying " |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
906 "after %d seconds.", wait), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
907 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
908 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
909 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
910 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
911 /**** Public *****/ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
912 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
913 /* Called at session startup*/ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
914 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
915 void gerpok_sc_init(char *uname, char *pwd) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
916 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
917 gerpok_sc_hs_status = gerpok_sc_hs_timeout = gerpok_sc_hs_errors = gerpok_sc_submit_timeout = |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
918 gerpok_sc_srv_res_size = gerpok_sc_giveup = gerpok_sc_major_error_present = |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
919 gerpok_sc_bad_users = gerpok_sc_sb_errors = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
920 gerpok_sc_submit_interval = 100; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
921 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
922 gerpok_sc_submit_url = gerpok_sc_username = gerpok_sc_password = gerpok_sc_srv_res = |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
923 gerpok_sc_challenge_hash = gerpok_sc_major_error = NULL; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
924 gerpok_sc_username = strdup(uname); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
925 gerpok_sc_password = strdup(pwd); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
926 read_cache(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
927 pdebug("scrobbler starting up", DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
928 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
929 |
1443
f4d8082668c1
scrobbler: tuple API update
William Pitcock <nenolod@atheme-project.org>
parents:
990
diff
changeset
|
930 void gerpok_sc_addentry(GMutex *mutex, Tuple *tuple, int len) |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
931 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
932 g_mutex_lock(mutex); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
933 q_put(tuple, len); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
934 /* |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
935 * This will help make sure the queue will be saved on a nasty |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
936 * segfault... |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
937 */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
938 dump_queue(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
939 g_mutex_unlock(mutex); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
940 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
941 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
942 /* Call periodically from the plugin */ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
943 int gerpok_sc_idle(GMutex *mutex) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
944 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
945 gerpok_sc_checkhandshake(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
946 if (gerpok_sc_hs_status) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
947 gerpok_sc_handlequeue(mutex); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
948 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
949 return gerpok_sc_giveup; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff
changeset
|
950 } |