Mercurial > audlegacy-plugins
annotate src/scrobbler/plugin.c @ 3047:4434b4c4a715
ported EsounD plugin
author | Andrew O. Shadoura <bugzilla@tut.by> |
---|---|
date | Fri, 17 Apr 2009 16:17:10 +0300 |
parents | 3134a0987162 |
children | 5a11abf0075c |
rev | line source |
---|---|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
1 #include "settings.h" |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
2 #include "config.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
3 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
4 #include <glib.h> |
2971
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2929
diff
changeset
|
5 #include <audlegacy/i18n.h> |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
6 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
7 #include <gdk/gdkkeysyms.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
8 #include <gtk/gtk.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
9 |
2971
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2929
diff
changeset
|
10 #include <audlegacy/plugin.h> |
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2929
diff
changeset
|
11 #include <audlegacy/ui_preferences.h> |
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2929
diff
changeset
|
12 #include <audlegacy/hook.h> |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
13 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
14 #include <unistd.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
15 #include <stdio.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
16 #include <stdlib.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
17 #include <string.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
18 #include <ctype.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
19 #include <wchar.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
20 #include <sys/time.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
21 |
2904
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
22 #include <curl/curl.h> |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
23 |
2328
224727e6c73d
if apply_timeout hasn't passed before cleanup, save password during cleanup; minor changes to saveconfig()
Tomasz Mon <desowin@gmail.com>
parents:
2318
diff
changeset
|
24 #include "plugin.h" |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
25 #include "scrobbler.h" |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
26 #include "gerpok.h" |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
27 #include "gtkstuff.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
28 #include "config.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
29 #include "fmt.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
30 #include "configure.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
31 |
353 | 32 #define XS_SLEEP 1 |
33 #define HS_SLEEP 10 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
34 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
35 typedef struct submit_t |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
36 { |
553
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
37 int dosubmit, pos_c, len, gerpok; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
38 } submit_t; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
39 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
40 static void init(void); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
41 static void cleanup(void); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
42 static void *xs_thread(void *); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
43 static void *hs_thread(void *); |
990
238055a6cb8f
[svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents:
880
diff
changeset
|
44 static int sc_going, ge_going; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
45 static GtkWidget *cfgdlg; |
1026
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
46 static gboolean submit; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
47 |
353 | 48 static GMutex *m_scrobbler; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
49 static GThread *pt_scrobbler; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
50 static GThread *pt_handshake; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
51 |
353 | 52 static GMutex *hs_mutex, *xs_mutex; |
53 static GCond *hs_cond, *xs_cond; | |
2306
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2124
diff
changeset
|
54 guint track_timeout; |
353 | 55 |
1066 | 56 static GeneralPlugin scrobbler_gp = |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
57 { |
1635
16044c4a34d7
scrobbler: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1443
diff
changeset
|
58 .description = "Scrobbler Plugin", |
16044c4a34d7
scrobbler: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1443
diff
changeset
|
59 .init = init, |
16044c4a34d7
scrobbler: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1443
diff
changeset
|
60 .about = about_show, |
16044c4a34d7
scrobbler: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1443
diff
changeset
|
61 .cleanup = cleanup |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
62 }; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
63 |
1026
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
64 static gboolean ishttp(const char *a) |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
65 { |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
66 g_return_val_if_fail(a != NULL, FALSE); |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1976
diff
changeset
|
67 return aud_str_has_prefix_nocase(a, "http://") || aud_str_has_prefix_nocase(a, "https://"); |
1026
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
68 } |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
69 |
2060 | 70 static void aud_hook_playback_begin(gpointer aud_hook_data, gpointer user_data) |
1026
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
71 { |
2060 | 72 PlaylistEntry *entry = (PlaylistEntry *) aud_hook_data; |
1027 | 73 |
1026
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
74 g_return_if_fail(entry != NULL); |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
75 |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
76 if (entry->length < 30) |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
77 { |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
78 pdebug(" *** not submitting due to entry->length < 30", DEBUG); |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
79 return; |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
80 } |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
81 |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
82 if (ishttp(entry->filename)) |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
83 { |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
84 pdebug(" *** not submitting due to HTTP source", DEBUG); |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
85 return; |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
86 } |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
87 |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
88 /* wake up the scrobbler thread to submit or queue */ |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
89 submit = TRUE; |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
90 g_cond_signal(xs_cond); |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
91 } |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
92 |
2306
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2124
diff
changeset
|
93 static void aud_hook_playback_end(gpointer aud_hook_data, gpointer user_data) |
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2124
diff
changeset
|
94 { |
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2124
diff
changeset
|
95 if (track_timeout) { |
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2124
diff
changeset
|
96 g_source_remove(track_timeout); |
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2124
diff
changeset
|
97 track_timeout = 0; |
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2124
diff
changeset
|
98 } |
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2124
diff
changeset
|
99 } |
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2124
diff
changeset
|
100 |
2318
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
101 void start(void) { |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
102 char *username = NULL, *password = NULL; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
103 char *ge_username = NULL, *ge_password = NULL; |
2523
769e17da93dd
Replaced s/ConfigDb/mcs_handle_t/g, as per changes in the core.
Matti Hamalainen <ccr@tnsp.org>
parents:
2496
diff
changeset
|
104 mcs_handle_t *cfgfile; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
105 sc_going = 1; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
106 ge_going = 1; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
107 GError **moo = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
108 |
2124 | 109 if ((cfgfile = aud_cfg_db_open()) != NULL) { |
110 aud_cfg_db_get_string(cfgfile, "audioscrobbler", "username", | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
111 &username); |
2124 | 112 aud_cfg_db_get_string(cfgfile, "audioscrobbler", "password", |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
113 &password); |
2124 | 114 aud_cfg_db_get_string(cfgfile, "audioscrobbler", "ge_username", |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
115 &ge_username); |
2124 | 116 aud_cfg_db_get_string(cfgfile, "audioscrobbler", "ge_password", |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
117 &ge_password); |
2124 | 118 aud_cfg_db_close(cfgfile); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
119 } |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
120 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
121 if ((!username || !password) || (!*username || !*password)) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
122 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
123 pdebug("username/password not found - not starting last.fm support", |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
124 DEBUG); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
125 sc_going = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
126 } |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
127 else |
364 | 128 { |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
129 sc_init(username, password); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
130 |
364 | 131 g_free(username); |
132 g_free(password); | |
133 } | |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
134 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
135 if ((!ge_username || !ge_password) || (!*ge_username || !*ge_password)) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
136 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
137 pdebug("username/password not found - not starting Gerpok support", |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
138 DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
139 ge_going = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
140 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
141 else |
364 | 142 { |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
143 gerpok_sc_init(ge_username, ge_password); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
144 |
364 | 145 g_free(ge_username); |
146 g_free(ge_password); | |
147 } | |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
148 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
149 m_scrobbler = g_mutex_new(); |
353 | 150 hs_mutex = g_mutex_new(); |
151 xs_mutex = g_mutex_new(); | |
152 hs_cond = g_cond_new(); | |
153 xs_cond = g_cond_new(); | |
154 | |
155 if ((pt_scrobbler = g_thread_create(xs_thread, NULL, TRUE, moo)) == NULL) | |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
156 { |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
157 pdebug(fmt_vastr("Error creating scrobbler thread: %s", moo), DEBUG); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
158 sc_going = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
159 ge_going = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
160 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
161 } |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
162 |
353 | 163 if ((pt_handshake = g_thread_create(hs_thread, NULL, TRUE, moo)) == NULL) |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
164 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
165 pdebug(fmt_vastr("Error creating handshake thread: %s", moo), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
166 sc_going = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
167 ge_going = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
168 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
169 } |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
170 |
2060 | 171 aud_hook_associate("playback begin", aud_hook_playback_begin, NULL); |
2306
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2124
diff
changeset
|
172 aud_hook_associate("playback end", aud_hook_playback_end, NULL); |
1027 | 173 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
174 pdebug("plugin started", DEBUG); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
175 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
176 |
2318
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
177 void stop(void) { |
990
238055a6cb8f
[svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents:
880
diff
changeset
|
178 if (!sc_going && !ge_going) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
179 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
180 pdebug("about to lock mutex", DEBUG); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
181 g_mutex_lock(m_scrobbler); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
182 pdebug("locked mutex", DEBUG); |
2313
3f684f1b1840
don't create scrobblerqueue.txt/gerpokqueue.txt when no username nor password for last.fm/gerpok is entered
Tomasz Mon <desowin@gmail.com>
parents:
2306
diff
changeset
|
183 if (sc_going) |
3f684f1b1840
don't create scrobblerqueue.txt/gerpokqueue.txt when no username nor password for last.fm/gerpok is entered
Tomasz Mon <desowin@gmail.com>
parents:
2306
diff
changeset
|
184 sc_cleaner(); |
3f684f1b1840
don't create scrobblerqueue.txt/gerpokqueue.txt when no username nor password for last.fm/gerpok is entered
Tomasz Mon <desowin@gmail.com>
parents:
2306
diff
changeset
|
185 if (ge_going) |
3f684f1b1840
don't create scrobblerqueue.txt/gerpokqueue.txt when no username nor password for last.fm/gerpok is entered
Tomasz Mon <desowin@gmail.com>
parents:
2306
diff
changeset
|
186 gerpok_sc_cleaner(); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
187 sc_going = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
188 ge_going = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
189 g_mutex_unlock(m_scrobbler); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
190 pdebug("joining threads", DEBUG); |
353 | 191 |
192 /* wake up waiting threads */ | |
193 pdebug("send signal to xs and hs", DEBUG); | |
194 g_cond_signal(xs_cond); | |
195 g_cond_signal(hs_cond); | |
196 | |
197 pdebug("wait xs", DEBUG); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
198 g_thread_join(pt_scrobbler); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
199 |
353 | 200 pdebug("wait hs", DEBUG); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
201 g_thread_join(pt_handshake); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
202 |
353 | 203 g_cond_free(hs_cond); |
204 g_cond_free(xs_cond); | |
205 g_mutex_free(hs_mutex); | |
206 g_mutex_free(xs_mutex); | |
207 g_mutex_free(m_scrobbler); | |
208 | |
2060 | 209 aud_hook_dissociate("playback begin", aud_hook_playback_begin); |
2306
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2124
diff
changeset
|
210 aud_hook_dissociate("playback end", aud_hook_playback_end); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
211 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
212 |
2318
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
213 static void init(void) |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
214 { |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
215 start(); |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
216 cfgdlg = create_cfgdlg(); |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
217 aud_prefswin_page_new(cfgdlg, "Scrobbler", DATA_DIR "/images/audioscrobbler.png"); |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
218 } |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
219 |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
220 static void cleanup(void) |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
221 { |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
222 stop(); |
2328
224727e6c73d
if apply_timeout hasn't passed before cleanup, save password during cleanup; minor changes to saveconfig()
Tomasz Mon <desowin@gmail.com>
parents:
2318
diff
changeset
|
223 configure_cleanup(); |
2318
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
224 aud_prefswin_page_destroy(cfgdlg); |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
225 } |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
226 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
227 static void *xs_thread(void *data __attribute__((unused))) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
228 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
229 int run = 1; |
353 | 230 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
231 while (run) { |
1443
f4d8082668c1
scrobbler: tuple API update
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
232 Tuple *tuple; |
1026
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
233 GTimeVal sleeptime; |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
234 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
235 /* Error catching */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
236 if(sc_catch_error()) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
237 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
238 errorbox_show(sc_fetch_error()); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
239 sc_clear_error(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
240 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
241 |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
242 if(gerpok_sc_catch_error()) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
243 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
244 errorbox_show(gerpok_sc_fetch_error()); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
245 gerpok_sc_clear_error(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
246 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
247 |
1026
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
248 if (submit) |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
249 { |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
250 Playlist *playlist; |
553
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
251 |
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
252 pdebug("Submitting song.", DEBUG); |
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
253 |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
254 playlist = aud_playlist_get_active(); |
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
255 tuple = aud_playlist_get_tuple(playlist, aud_playlist_get_position(playlist)); |
553
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
256 |
601 | 257 if (tuple == NULL) |
258 continue; | |
259 | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1693
diff
changeset
|
260 if (ishttp(aud_tuple_get_string(tuple, FIELD_FILE_NAME, NULL))) |
553
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
261 continue; |
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
262 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1693
diff
changeset
|
263 if (aud_tuple_get_string(tuple, FIELD_ARTIST, NULL) != NULL && |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1693
diff
changeset
|
264 aud_tuple_get_string(tuple, FIELD_TITLE, NULL) != NULL) |
553
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
265 { |
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
266 pdebug(fmt_vastr( |
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
267 "submitting artist: %s, title: %s", |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1693
diff
changeset
|
268 aud_tuple_get_string(tuple, FIELD_ARTIST, NULL), |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1693
diff
changeset
|
269 aud_tuple_get_string(tuple, FIELD_TITLE, NULL)), DEBUG); |
2313
3f684f1b1840
don't create scrobblerqueue.txt/gerpokqueue.txt when no username nor password for last.fm/gerpok is entered
Tomasz Mon <desowin@gmail.com>
parents:
2306
diff
changeset
|
270 |
3f684f1b1840
don't create scrobblerqueue.txt/gerpokqueue.txt when no username nor password for last.fm/gerpok is entered
Tomasz Mon <desowin@gmail.com>
parents:
2306
diff
changeset
|
271 if (sc_going) |
3f684f1b1840
don't create scrobblerqueue.txt/gerpokqueue.txt when no username nor password for last.fm/gerpok is entered
Tomasz Mon <desowin@gmail.com>
parents:
2306
diff
changeset
|
272 sc_addentry(m_scrobbler, tuple, aud_tuple_get_int(tuple, FIELD_LENGTH, NULL) / 1000); |
3f684f1b1840
don't create scrobblerqueue.txt/gerpokqueue.txt when no username nor password for last.fm/gerpok is entered
Tomasz Mon <desowin@gmail.com>
parents:
2306
diff
changeset
|
273 if (ge_going) |
3f684f1b1840
don't create scrobblerqueue.txt/gerpokqueue.txt when no username nor password for last.fm/gerpok is entered
Tomasz Mon <desowin@gmail.com>
parents:
2306
diff
changeset
|
274 gerpok_sc_addentry(m_scrobbler, tuple, aud_tuple_get_int(tuple, FIELD_LENGTH, NULL) / 1000); |
2306
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2124
diff
changeset
|
275 if (!track_timeout) |
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2124
diff
changeset
|
276 track_timeout = g_timeout_add_seconds(1, sc_timeout, NULL); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
277 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
278 else |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
279 pdebug("tuple does not contain an artist or a title, not submitting.", DEBUG); |
1026
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
280 |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
281 submit = FALSE; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
282 } |
1026
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
283 |
353 | 284 g_get_current_time(&sleeptime); |
285 sleeptime.tv_sec += XS_SLEEP; | |
286 | |
1026
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
287 g_mutex_lock(xs_mutex); |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
288 g_cond_timed_wait(xs_cond, xs_mutex, &sleeptime); |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
289 g_mutex_unlock(xs_mutex); |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
290 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
291 g_mutex_lock(m_scrobbler); |
990
238055a6cb8f
[svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents:
880
diff
changeset
|
292 run = (sc_going != 0 || ge_going != 0); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
293 g_mutex_unlock(m_scrobbler); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
294 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
295 pdebug("scrobbler thread: exiting", DEBUG); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
296 g_thread_exit(NULL); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
297 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
298 return NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
299 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
300 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
301 static void *hs_thread(void *data __attribute__((unused))) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
302 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
303 int run = 1; |
353 | 304 GTimeVal sleeptime; |
305 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
306 while(run) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
307 { |
2313
3f684f1b1840
don't create scrobblerqueue.txt/gerpokqueue.txt when no username nor password for last.fm/gerpok is entered
Tomasz Mon <desowin@gmail.com>
parents:
2306
diff
changeset
|
308 if(sc_going && sc_idle(m_scrobbler)) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
309 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
310 pdebug("Giving up due to fatal error", DEBUG); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
311 g_mutex_lock(m_scrobbler); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
312 sc_going = 0; |
353 | 313 g_mutex_unlock(m_scrobbler); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
314 } |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
315 |
2313
3f684f1b1840
don't create scrobblerqueue.txt/gerpokqueue.txt when no username nor password for last.fm/gerpok is entered
Tomasz Mon <desowin@gmail.com>
parents:
2306
diff
changeset
|
316 if(ge_going && gerpok_sc_idle(m_scrobbler)) |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
317 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
318 pdebug("Giving up due to fatal error", DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
319 g_mutex_lock(m_scrobbler); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
320 ge_going = 0; |
353 | 321 g_mutex_unlock(m_scrobbler); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
322 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
323 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
324 g_mutex_lock(m_scrobbler); |
990
238055a6cb8f
[svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents:
880
diff
changeset
|
325 run = (sc_going != 0 || ge_going != 0); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
326 g_mutex_unlock(m_scrobbler); |
353 | 327 |
328 if(run) { | |
329 g_get_current_time(&sleeptime); | |
330 sleeptime.tv_sec += HS_SLEEP; | |
331 | |
332 g_mutex_lock(hs_mutex); | |
333 g_cond_timed_wait(hs_cond, hs_mutex, &sleeptime); | |
334 g_mutex_unlock(hs_mutex); | |
335 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
336 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
337 pdebug("handshake thread: exiting", DEBUG); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
338 g_thread_exit(NULL); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
339 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
340 return NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
341 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
342 |
2904
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
343 void setup_proxy(CURL *curl) |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
344 { |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
345 mcs_handle_t *db; |
2929
3868d67e7d19
uninitialized values are bad
Tomasz Mon <desowin@gmail.com>
parents:
2904
diff
changeset
|
346 gboolean use_proxy = FALSE; |
2904
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
347 |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
348 db = aud_cfg_db_open(); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
349 aud_cfg_db_get_bool(db, NULL, "use_proxy", &use_proxy); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
350 if (use_proxy == FALSE) |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
351 { |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
352 curl_easy_setopt(curl, CURLOPT_PROXY, ""); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
353 } |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
354 else |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
355 { |
2929
3868d67e7d19
uninitialized values are bad
Tomasz Mon <desowin@gmail.com>
parents:
2904
diff
changeset
|
356 gchar *proxy_host = NULL, *proxy_port = NULL; |
3868d67e7d19
uninitialized values are bad
Tomasz Mon <desowin@gmail.com>
parents:
2904
diff
changeset
|
357 gboolean proxy_use_auth = FALSE; |
2904
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
358 aud_cfg_db_get_string(db, NULL, "proxy_host", &proxy_host); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
359 aud_cfg_db_get_string(db, NULL, "proxy_port", &proxy_port); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
360 curl_easy_setopt(curl, CURLOPT_PROXY, proxy_host); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
361 curl_easy_setopt(curl, CURLOPT_PROXYPORT, proxy_port); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
362 aud_cfg_db_get_bool(db, NULL, "proxy_use_auth", &proxy_use_auth); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
363 if (proxy_use_auth != FALSE) |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
364 { |
2929
3868d67e7d19
uninitialized values are bad
Tomasz Mon <desowin@gmail.com>
parents:
2904
diff
changeset
|
365 gchar *userpwd = NULL, *user = NULL, *pass = NULL; |
2904
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
366 aud_cfg_db_get_string(db, NULL, "proxy_user", &user); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
367 aud_cfg_db_get_string(db, NULL, "proxy_pass", &pass); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
368 userpwd = g_strdup_printf("%s:%s", user, pass); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
369 curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
370 g_free(userpwd); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
371 } |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
372 } |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
373 aud_cfg_db_close(db); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
374 } |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
375 |
1066 | 376 GeneralPlugin *scrobbler_gplist[] = { &scrobbler_gp, NULL }; |
377 | |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1066
diff
changeset
|
378 DECLARE_PLUGIN(scrobbler, NULL, NULL, NULL, NULL, NULL, scrobbler_gplist, NULL, NULL); |