annotate src/scrobbler/gerpok.c @ 2952:63bf9d97ce65

- now cuesheet plugin calculates duration of subtune correctly even if pregap information is not available. - made cache_cue_file() not be called too frequently. - fixed handling for fraction in index calculation. - tweaked debug messages.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 14 Oct 2008 22:28:14 +0900
parents ff9b4776b938
children 3134a0987162
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 <stdio.h>
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
9 #include "fmt.h"
2904
ff9b4776b938 now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents: 2599
diff changeset
10 #include "plugin.h"
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
11 #include "scrobbler.h"
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
12 #include "config.h"
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
13 #include <glib.h>
1982
0ea55fc6f220 scrobbler: vtable fixing
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
14 #include <audacious/plugin.h>
2599
19fb7d7dcf4e Use the md5 routines in libaudutil.
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
15 #include <audacious/audutil.h>
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
16
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
17 #define SCROBBLER_HS_URL "http://post.gerpok.com"
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
18 #define SCROBBLER_CLI_ID "aud"
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
19 #define SCROBBLER_HS_WAIT 1800
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
20 #define SCROBBLER_SB_WAIT 10
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
21 #define SCROBBLER_VERSION "1.1"
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
22 #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
23 #define SCROBBLER_SB_MAXLEN 1024
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
24 #define CACHE_SIZE 1024
2441
166397a7efe1 Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents: 2267
diff changeset
25 #define ALLOW_MULTIPLE
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
26
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
27 /* Scrobblerbackend for xmms plugin, first draft */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
28
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
29 static int gerpok_sc_hs_status,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
30 gerpok_sc_hs_timeout,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
31 gerpok_sc_hs_errors,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
32 gerpok_sc_sb_errors,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
33 gerpok_sc_bad_users,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
34 gerpok_sc_submit_interval,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
35 gerpok_sc_submit_timeout,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
36 gerpok_sc_srv_res_size,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
37 gerpok_sc_giveup,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
38 gerpok_sc_major_error_present;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
39
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
40 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
41 *gerpok_sc_username = NULL,
314b7ac7f771 [svn] - handle no account data gracefully (e.g. you only use one of the
nenolod
parents: 344
diff changeset
42 *gerpok_sc_password = NULL,
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
43 *gerpok_sc_challenge_hash,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
44 gerpok_sc_response_hash[33],
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
45 *gerpok_sc_srv_res,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
46 gerpok_sc_curl_errbuf[CURL_ERROR_SIZE],
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
47 *gerpok_sc_major_error;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
48
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
49 static void dump_queue();
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
50
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
51 /**** Queue stuff ****/
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
52
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
53 #define I_ARTIST(i) i->artist
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
54 #define I_TITLE(i) i->title
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
55 #define I_TIME(i) i->utctime
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
56 #define I_LEN(i) i->len
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
57 #define I_MB(i) i->mb
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
58 #define I_ALBUM(i) i->album
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
59
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
60 typedef struct {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
61 char *artist,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
62 *title,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
63 *mb,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
64 *album,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
65 *utctime,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
66 len[16];
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
67 int numtries;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
68 void *next;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
69 } item_t;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
70
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
71 static item_t *q_queue = NULL;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
72 static item_t *q_queue_last = NULL;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
73 static int q_nitems;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
74
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
75 static void q_item_free(item_t *item)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
76 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
77 if (item == NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
78 return;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
79 curl_free(item->artist);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
80 curl_free(item->title);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
81 curl_free(item->utctime);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
82 curl_free(item->mb);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
83 curl_free(item->album);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
84 free(item);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
85 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
86
1443
f4d8082668c1 scrobbler: tuple API update
William Pitcock <nenolod@atheme-project.org>
parents: 990
diff changeset
87 static void q_put(Tuple *tuple, int len)
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
88 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
89 item_t *item;
1443
f4d8082668c1 scrobbler: tuple API update
William Pitcock <nenolod@atheme-project.org>
parents: 990
diff changeset
90 const gchar *album;
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
91
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
92 item = malloc(sizeof(item_t));
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
93
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
94 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
95 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
96 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
97 g_snprintf(item->len, sizeof(item->len), "%d", len);
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
98
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
99 #ifdef NOTYET
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
100 if(tuple->mb == NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
101 #endif
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
102 item->mb = fmt_escape("");
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
103 #ifdef NOTYET
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
104 else
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
105 item->mb = fmt_escape((char*)tuple->mb);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
106 #endif
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
107
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
108 if((album = aud_tuple_get_string(tuple, FIELD_ALBUM, NULL)))
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
109 item->album = fmt_escape("");
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
110 else
1443
f4d8082668c1 scrobbler: tuple API update
William Pitcock <nenolod@atheme-project.org>
parents: 990
diff changeset
111 item->album = fmt_escape((char*) album);
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
112
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
113 q_nitems++;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
114
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
115 item->next = NULL;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
116
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
117 if(q_queue_last == NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
118 q_queue = q_queue_last = item;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
119 else
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
120 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
121 q_queue_last->next = item;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
122 q_queue_last = item;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
123 }
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 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
127 char *album, char *mb)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
128 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
129 char *temp = NULL;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
130 item_t *item;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
131
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
132 item = calloc(1, sizeof(item_t));
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
133 temp = fmt_unescape(artist);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
134 item->artist = fmt_escape(temp);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
135 curl_free(temp);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
136 temp = fmt_unescape(title);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
137 item->title = fmt_escape(temp);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
138 curl_free(temp);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
139 memcpy(item->len, len, sizeof(len));
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
140 temp = fmt_unescape(time);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
141 item->utctime = fmt_escape(temp);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
142 curl_free(temp);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
143 temp = fmt_unescape(album);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
144 item->album = fmt_escape(temp);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
145 curl_free(temp);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
146 temp = fmt_unescape(mb);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
147 item->mb = fmt_escape(temp);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
148 curl_free(temp);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
149
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
150 q_nitems++;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
151
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
152 item->next = NULL;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
153 if(q_queue_last == NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
154 q_queue = q_queue_last = item;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
155 else
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
156 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
157 q_queue_last->next = item;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
158 q_queue_last = item;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
159 }
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 return item;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
162 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
163
990
238055a6cb8f [svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents: 786
diff changeset
164 #if 0
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
165 static item_t *q_peek(void)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
166 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
167 if (q_nitems == 0)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
168 return NULL;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
169 return q_queue;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
170 }
990
238055a6cb8f [svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents: 786
diff changeset
171 #endif
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
172
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
173 static item_t *q_peekall(int rewind)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
174 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
175 static item_t *citem = NULL;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
176 item_t *temp_item;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
177
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
178 if (rewind) {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
179 citem = q_queue;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
180 return NULL;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
181 }
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 temp_item = citem;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
184
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
185 if(citem != NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
186 citem = citem->next;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
187
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
188 return temp_item;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
189 }
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 static int q_get(void)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
192 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
193 item_t *item;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
194
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
195 if (q_nitems == 0)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
196 return 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
197
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
198 item = q_queue;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
199
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
200 if(item == NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
201 return 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
202
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
203 q_nitems--;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
204 q_queue = q_queue->next;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
205
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
206 q_item_free(item);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
207
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
208 if (q_nitems == 0)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
209 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
210 q_queue_last = NULL;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
211 return 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
212 }
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 return -1;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
215 }
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 static void q_free(void)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
218 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
219 while (q_get());
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
220 }
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 static int q_len(void)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
223 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
224 return q_nitems;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
225 }
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 /* Error functions */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
228
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
229 static void gerpok_sc_throw_error(char *errortxt)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
230 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
231 gerpok_sc_major_error_present = 1;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
232 if(gerpok_sc_major_error == NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
233 gerpok_sc_major_error = strdup(errortxt);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
234
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
235 return;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
236 }
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 int gerpok_sc_catch_error(void)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
239 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
240 return gerpok_sc_major_error_present;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
241 }
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 char *gerpok_sc_fetch_error(void)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
244 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
245 return gerpok_sc_major_error;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
246 }
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 void gerpok_sc_clear_error(void)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
249 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
250 gerpok_sc_major_error_present = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
251 if(gerpok_sc_major_error != NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
252 free(gerpok_sc_major_error);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
253 gerpok_sc_major_error = NULL;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
254
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
255 return;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
256 }
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 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
259 size_t nmemb,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
260 void *stream __attribute__((unused)))
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
261 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
262 int len = size * nmemb;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
263
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
264 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
265 memcpy(gerpok_sc_srv_res + gerpok_sc_srv_res_size,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
266 ptr, len);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
267 gerpok_sc_srv_res_size += len;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
268 return len;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
269 }
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 static void gerpok_sc_free_res(void)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
272 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
273 if(gerpok_sc_srv_res != NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
274 free(gerpok_sc_srv_res);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
275 gerpok_sc_srv_res = NULL;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
276 gerpok_sc_srv_res_size = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
277 }
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 static int gerpok_sc_parse_hs_res(void)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
280 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
281 char *interval;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
282
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
283 if (!gerpok_sc_srv_res_size) {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
284 pdebug("No reply from server", DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
285 return -1;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
286 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
287 *(gerpok_sc_srv_res + gerpok_sc_srv_res_size) = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
288
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
289 if (!strncmp(gerpok_sc_srv_res, "FAILED ", 7)) {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
290 interval = strstr(gerpok_sc_srv_res, "INTERVAL");
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
291 if(!interval) {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
292 pdebug("missing INTERVAL", DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
293 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
294 else
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
295 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
296 *(interval - 1) = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
297 gerpok_sc_submit_interval = strtol(interval + 8, NULL, 10);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
298 }
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 /* Throwing a major error, just in case */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
301 /* gerpok_sc_throw_error(fmt_vastr("%s", gerpok_sc_srv_res));
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
302 gerpok_sc_hs_errors++; */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
303 pdebug(fmt_vastr("error: %s", gerpok_sc_srv_res), DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
304
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
305 return -1;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
306 }
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 if (!strncmp(gerpok_sc_srv_res, "UPDATE ", 7)) {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
309 interval = strstr(gerpok_sc_srv_res, "INTERVAL");
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
310 if(!interval)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
311 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
312 pdebug("missing INTERVAL", DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
313 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
314 else
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
315 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
316 *(interval - 1) = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
317 gerpok_sc_submit_interval = strtol(interval + 8, NULL, 10);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
318 }
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 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
321 *(gerpok_sc_submit_url - 1) = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
322 gerpok_sc_submit_url = strdup(gerpok_sc_submit_url);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
323 gerpok_sc_challenge_hash = strchr(gerpok_sc_srv_res, '\n') + 1;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
324 *(gerpok_sc_challenge_hash - 1) = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
325 gerpok_sc_challenge_hash = strdup(gerpok_sc_challenge_hash);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
326
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
327 /* Throwing major error. Need to alert client to update. */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
328 gerpok_sc_throw_error(fmt_vastr("Please update Audacious.\n"
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
329 "Update available at: http://audacious-media-player.org"));
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
330 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
331
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 * 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
334 * client. Neither is RJ. I use what we did before.
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
335 */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
336 gerpok_sc_giveup = -1;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
337 return -1;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
338 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
339 if (!strncmp(gerpok_sc_srv_res, "UPTODATE\n", 9)) {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
340 gerpok_sc_bad_users = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
341
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
342 interval = strstr(gerpok_sc_srv_res, "INTERVAL");
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
343 if (!interval) {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
344 pdebug("missing INTERVAL", DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
345 /*
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
346 * This is probably a bad thing, but Russ seems to
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
347 * think its OK to assume that an UPTODATE response
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
348 * may not have an INTERVAL... We return -1 anyway.
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
349 */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
350 return -1;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
351 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
352 else
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
353 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
354 *(interval - 1) = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
355 gerpok_sc_submit_interval = strtol(interval + 8, NULL, 10);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
356 }
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 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
359 *(gerpok_sc_submit_url - 1) = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
360 gerpok_sc_submit_url = strdup(gerpok_sc_submit_url);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
361 gerpok_sc_challenge_hash = strchr(gerpok_sc_srv_res, '\n') + 1;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
362 *(gerpok_sc_challenge_hash - 1) = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
363 gerpok_sc_challenge_hash = strdup(gerpok_sc_challenge_hash);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
364
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
365 return 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
366 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
367 if(!strncmp(gerpok_sc_srv_res, "BADUSER", 7)) {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
368 /* Throwing major error. */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
369 gerpok_sc_throw_error("Incorrect username/password.\n"
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
370 "Please fix in configuration.");
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
371 pdebug("incorrect username/password", DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
372
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
373 interval = strstr(gerpok_sc_srv_res, "INTERVAL");
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
374 if(!interval)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
375 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
376 pdebug("missing INTERVAL", DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
377 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
378 else
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
379 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
380 *(interval - 1) = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
381 gerpok_sc_submit_interval = strtol(interval + 8, NULL, 10);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
382 }
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 return -1;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
385 }
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 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
388 return -1;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
389 }
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 static void hexify(char *pass, int len)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
392 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
393 char *bp = gerpok_sc_response_hash;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
394 char hexchars[] = "0123456789abcdef";
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
395 int i;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
396
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
397 memset(gerpok_sc_response_hash, 0, sizeof(gerpok_sc_response_hash));
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
398
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
399 for(i = 0; i < len; i++) {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
400 *(bp++) = hexchars[(pass[i] >> 4) & 0x0f];
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
401 *(bp++) = hexchars[pass[i] & 0x0f];
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
402 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
403 *bp = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
404
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
405 return;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
406 }
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 static int gerpok_sc_handshake(void)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
409 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
410 int status;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
411 char buf[4096];
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
412 CURL *curl;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
413
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1443
diff changeset
414 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
415 SCROBBLER_HS_URL, SCROBBLER_VERSION,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
416 SCROBBLER_CLI_ID, SCROBBLER_IMPLEMENTATION, gerpok_sc_username);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
417
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
418 curl = curl_easy_init();
2904
ff9b4776b938 now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents: 2599
diff changeset
419 setup_proxy(curl);
344
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) {
2599
19fb7d7dcf4e Use the md5 routines in libaudutil.
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
448 aud_md5state_t md5state;
344
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
2599
19fb7d7dcf4e Use the md5 routines in libaudutil.
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
451 aud_md5_init(&md5state);
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
452 /*pdebug(fmt_vastr("Pass Hash: %s", gerpok_sc_password), DEBUG);*/
2599
19fb7d7dcf4e Use the md5 routines in libaudutil.
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
453 aud_md5_append(&md5state, (unsigned const char *)gerpok_sc_password,
344
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);*/
2599
19fb7d7dcf4e Use the md5 routines in libaudutil.
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
456 aud_md5_append(&md5state, (unsigned const char *)gerpok_sc_challenge_hash,
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
457 strlen(gerpok_sc_challenge_hash));
2599
19fb7d7dcf4e Use the md5 routines in libaudutil.
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
458 aud_md5_finish(&md5state, md5pword);
344
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();
2904
ff9b4776b938 now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents: 2599
diff changeset
625 setup_proxy(curl);
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
626 curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
627 curl_easy_setopt(curl, CURLOPT_URL, gerpok_sc_submit_url);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
628 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
629 gerpok_sc_store_res);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
630 curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
631 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
632 /*cfa(&post, &last, "debug", "failed");*/
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
633
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
634 /*pdebug(fmt_vastr("Username: %s", gerpok_sc_username), DEBUG);*/
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
635 submission = g_string_new("u=");
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
636 g_string_append(submission,(gchar *)gerpok_sc_username);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
637
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
638 /*pdebug(fmt_vastr("Response Hash: %s", gerpok_sc_response_hash), DEBUG);*/
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
639 g_string_append(submission,"&s=");
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
640 g_string_append(submission,(gchar *)gerpok_sc_response_hash);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
641
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
642 g_string_append(submission, entry);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
643
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
644 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, (char *)submission->str);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
645 memset(gerpok_sc_curl_errbuf, 0, sizeof(gerpok_sc_curl_errbuf));
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
646 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
647 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
648 curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, SC_CURL_TIMEOUT);
344
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 /*
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
651 curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
652 curl_easy_setopt(curl, CURLOPT_TIMEOUT, SCROBBLER_SB_WAIT);
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
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
655 status = curl_easy_perform(curl);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
656
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
657 curl_easy_cleanup(curl);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
658
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
659 g_string_free(submission,TRUE);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
660
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
661 if (status) {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
662 pdebug(gerpok_sc_curl_errbuf, DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
663 gerpok_sc_sb_errors++;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
664 gerpok_sc_free_res();
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
665 return -1;
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
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
668 if (gerpok_sc_parse_sb_res()) {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
669 gerpok_sc_sb_errors++;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
670 gerpok_sc_free_res();
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
671 pdebug(fmt_vastr("Retrying in %d secs, %d elements in queue",
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
672 gerpok_sc_submit_interval, q_len()), DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
673 return -1;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
674 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
675 gerpok_sc_free_res();
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
676 return 0;
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
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
679 static void gerpok_sc_handlequeue(GMutex *mutex)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
680 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
681 GString *submitentry;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
682 int nsubmit;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
683 int wait;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
684
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
685 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
686 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
687 submitentry = g_string_new("");
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
688
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
689 g_mutex_lock(mutex);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
690
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
691 nsubmit = gerpok_sc_generateentry(submitentry);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
692
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
693 g_mutex_unlock(mutex);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
694
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
695 if (nsubmit > 0)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
696 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
697 pdebug(fmt_vastr("Number submitting: %d", nsubmit), DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
698 pdebug(fmt_vastr("Submission: %s", submitentry->str), DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
699
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
700 if(!gerpok_sc_submitentry(submitentry->str))
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
701 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
702 g_mutex_lock(mutex);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
703
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
704 #ifdef ALLOW_MULTIPLE
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
705 q_free();
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
706 #else
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
707 q_get();
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
708 #endif
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
709 /*
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
710 * This should make sure that the queue doesn't
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
711 * get submitted multiple times on a nasty
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
712 * segfault...
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
713 */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
714 dump_queue();
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
715
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
716 g_mutex_unlock(mutex);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
717
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
718 gerpok_sc_sb_errors = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
719 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
720 if(gerpok_sc_sb_errors)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
721 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
722 if(gerpok_sc_sb_errors < 5)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
723 /* Retry after 1 min */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
724 wait = 60;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
725 else
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
726 wait = /* gerpok_sc_submit_interval + */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
727 ( ((gerpok_sc_sb_errors - 5) < 7) ?
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
728 (60 << (gerpok_sc_sb_errors-5)) :
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
729 7200 );
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
730
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
731 gerpok_sc_submit_timeout = time(NULL) + wait;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
732
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
733 pdebug(fmt_vastr("Error while submitting. "
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
734 "Retrying after %d seconds.", wait),
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
735 DEBUG);
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
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
739 g_string_free(submitentry, TRUE);
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
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
743 static void read_cache(void)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
744 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
745 FILE *fd;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
746 char buf[PATH_MAX], *cache = NULL, *ptr1, *ptr2;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
747 int cachesize, written, i = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
748 item_t *item;
2267
2e961ce4bfe8 Fixes memory leaks that are visible during startup in scrobbler plugin (Bugzilla #26)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 1982
diff changeset
749 gchar* config_datadir;
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
750
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
751 cachesize = written = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
752
2267
2e961ce4bfe8 Fixes memory leaks that are visible during startup in scrobbler plugin (Bugzilla #26)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 1982
diff changeset
753 config_datadir = audacious_get_localdir();
2e961ce4bfe8 Fixes memory leaks that are visible during startup in scrobbler plugin (Bugzilla #26)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 1982
diff changeset
754 g_snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", config_datadir);
2e961ce4bfe8 Fixes memory leaks that are visible during startup in scrobbler plugin (Bugzilla #26)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 1982
diff changeset
755 g_free(config_datadir);
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
756
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
757 if (!(fd = fopen(buf, "r")))
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
758 return;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
759 pdebug(fmt_vastr("Opening %s", buf), DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
760 while(!feof(fd))
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
761 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
762 cachesize += CACHE_SIZE;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
763 cache = realloc(cache, cachesize + 1);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
764 written += fread(cache + written, 1, CACHE_SIZE, fd);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
765 cache[written] = '\0';
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 fclose(fd);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
768 ptr1 = cache;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
769 while(ptr1 < cache + written - 1)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
770 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
771 char *artist, *title, *len, *time, *album, *mb;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
772
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
773 pdebug("Pushed:", DEBUG);
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 artist = calloc(1, ptr2 - ptr1 + 1);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
776 strncpy(artist, 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 title = calloc(1, ptr2 - ptr1 + 1);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
780 strncpy(title, 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 len = calloc(1, ptr2 - ptr1 + 1);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
784 strncpy(len, 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 time = calloc(1, ptr2 - ptr1 + 1);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
788 strncpy(time, 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, ' ');
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
791 album = calloc(1, ptr2 - ptr1 + 1);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
792 strncpy(album, ptr1, ptr2 - ptr1);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
793 ptr1 = ptr2 + 1;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
794 ptr2 = strchr(ptr1, '\n');
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 = '\0';
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
797 mb = calloc(1, strlen(ptr1) + 1);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
798 strncpy(mb, ptr1, strlen(ptr1));
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
799 if(ptr2 != NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
800 *ptr2 = '\n';
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
801 /* Why is our save printing out CR/LF? */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
802 ptr1 = ptr2 + 1;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
803
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
804 item = q_put2(artist, title, len, time, album, mb);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
805 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
806 i, I_ARTIST(item),
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
807 i, I_TITLE(item),
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
808 i, I_LEN(item),
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
809 i, I_TIME(item),
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
810 i, I_MB(item),
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
811 i, I_ALBUM(item)), DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
812 free(artist);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
813 free(title);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
814 free(len);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
815 free(time);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
816 free(album);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
817 free(mb);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
818
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
819 i++;
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 pdebug("Done loading cache.", DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
822 free(cache);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
823 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
824
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
825 static void dump_queue(void)
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 FILE *fd;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
828 item_t *item;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
829 char *home, buf[PATH_MAX];
2267
2e961ce4bfe8 Fixes memory leaks that are visible during startup in scrobbler plugin (Bugzilla #26)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 1982
diff changeset
830 gchar* config_datadir;
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
831
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
832 /*pdebug("Entering dump_queue();", DEBUG);*/
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 if (!(home = getenv("HOME")))
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
835 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
836 pdebug("No HOME directory found. Cannot dump queue.", DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
837 return;
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
2267
2e961ce4bfe8 Fixes memory leaks that are visible during startup in scrobbler plugin (Bugzilla #26)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 1982
diff changeset
840 config_datadir = audacious_get_localdir();
2e961ce4bfe8 Fixes memory leaks that are visible during startup in scrobbler plugin (Bugzilla #26)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 1982
diff changeset
841 g_snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", config_datadir);
2e961ce4bfe8 Fixes memory leaks that are visible during startup in scrobbler plugin (Bugzilla #26)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 1982
diff changeset
842 g_free(config_datadir);
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
843
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
844 if (!(fd = fopen(buf, "w")))
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
845 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
846 pdebug(fmt_vastr("Failure opening %s", buf), DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
847 return;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
848 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
849
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
850 pdebug(fmt_vastr("Opening %s", buf), DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
851
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
852 q_peekall(1);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
853
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
854 while ((item = q_peekall(0))) {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
855 fprintf(fd, "%s %s %s %s %s %s\n",
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
856 I_ARTIST(item),
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
857 I_TITLE(item),
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
858 I_LEN(item),
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
859 I_TIME(item),
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
860 I_ALBUM(item),
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
861 I_MB(item));
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
862 }
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 fclose(fd);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
865 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
866
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
867 /* This was made public */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
868
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
869 void gerpok_sc_cleaner(void)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
870 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
871 if(gerpok_sc_submit_url != NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
872 free(gerpok_sc_submit_url);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
873 if(gerpok_sc_username != NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
874 free(gerpok_sc_username);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
875 if(gerpok_sc_password != NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
876 free(gerpok_sc_password);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
877 if(gerpok_sc_challenge_hash != NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
878 free(gerpok_sc_challenge_hash);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
879 if(gerpok_sc_srv_res != NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
880 free(gerpok_sc_srv_res);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
881 if(gerpok_sc_major_error != NULL)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
882 free(gerpok_sc_major_error);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
883 dump_queue();
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
884 q_free();
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
885 pdebug("scrobbler shutting down", DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
886 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
887
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
888 static void gerpok_sc_checkhandshake(void)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
889 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
890 int wait;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
891
348
314b7ac7f771 [svn] - handle no account data gracefully (e.g. you only use one of the
nenolod
parents: 344
diff changeset
892 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
893 return;
314b7ac7f771 [svn] - handle no account data gracefully (e.g. you only use one of the
nenolod
parents: 344
diff changeset
894
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
895 if (gerpok_sc_hs_status)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
896 return;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
897 if (gerpok_sc_hs_timeout < time(NULL))
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
898 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
899 gerpok_sc_handshake();
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
900
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
901 if(gerpok_sc_hs_errors)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
902 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
903 if(gerpok_sc_hs_errors < 5)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
904 /* Retry after 60 seconds */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
905 wait = 60;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
906 else
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
907 wait = /* gerpok_sc_submit_interval + */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
908 ( ((gerpok_sc_hs_errors - 5) < 7) ?
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
909 (60 << (gerpok_sc_hs_errors-5)) :
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
910 7200 );
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
911 gerpok_sc_hs_timeout = time(NULL) + wait;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
912 pdebug(fmt_vastr("Error while handshaking. Retrying "
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
913 "after %d seconds.", wait), DEBUG);
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 }
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
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
918 /**** Public *****/
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
919
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
920 /* Called at session startup*/
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 void gerpok_sc_init(char *uname, char *pwd)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
923 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
924 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
925 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
926 gerpok_sc_bad_users = gerpok_sc_sb_errors = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
927 gerpok_sc_submit_interval = 100;
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 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
930 gerpok_sc_challenge_hash = gerpok_sc_major_error = NULL;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
931 gerpok_sc_username = strdup(uname);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
932 gerpok_sc_password = strdup(pwd);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
933 read_cache();
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
934 pdebug("scrobbler starting up", DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
935 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
936
1443
f4d8082668c1 scrobbler: tuple API update
William Pitcock <nenolod@atheme-project.org>
parents: 990
diff changeset
937 void gerpok_sc_addentry(GMutex *mutex, Tuple *tuple, int len)
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
938 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
939 g_mutex_lock(mutex);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
940 q_put(tuple, len);
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 * 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
943 * segfault...
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 dump_queue();
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
946 g_mutex_unlock(mutex);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
947 }
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 /* Call periodically from the plugin */
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
950 int gerpok_sc_idle(GMutex *mutex)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
951 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
952 gerpok_sc_checkhandshake();
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
953 if (gerpok_sc_hs_status)
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
954 gerpok_sc_handlequeue(mutex);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
955
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
956 return gerpok_sc_giveup;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
diff changeset
957 }