Mercurial > audlegacy-plugins
annotate src/scrobbler/plugin.c @ 3191:a65f440cbed3
alsa-ng: Fix possible race conditions, sluggish pause and seek.
author | John Lindgren <john.lindgren@tds.net> |
---|---|
date | Mon, 22 Jun 2009 16:05:57 -0400 |
parents | 5a11abf0075c |
children |
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) { |
3109
5a11abf0075c
scrobbler: add support for custom audioscrobbler servers. (closes #23)
William Pitcock <nenolod@atheme.org>
parents:
2971
diff
changeset
|
102 char *username = NULL, *password = NULL, *sc_url = 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); |
3109
5a11abf0075c
scrobbler: add support for custom audioscrobbler servers. (closes #23)
William Pitcock <nenolod@atheme.org>
parents:
2971
diff
changeset
|
114 aud_cfg_db_get_string(cfgfile, "audioscrobbler", "sc_url", |
5a11abf0075c
scrobbler: add support for custom audioscrobbler servers. (closes #23)
William Pitcock <nenolod@atheme.org>
parents:
2971
diff
changeset
|
115 &sc_url); |
2124 | 116 aud_cfg_db_get_string(cfgfile, "audioscrobbler", "ge_username", |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
117 &ge_username); |
2124 | 118 aud_cfg_db_get_string(cfgfile, "audioscrobbler", "ge_password", |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
119 &ge_password); |
2124 | 120 aud_cfg_db_close(cfgfile); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
121 } |
344
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 if ((!username || !password) || (!*username || !*password)) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
124 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
125 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
|
126 DEBUG); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
127 sc_going = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
128 } |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
129 else |
364 | 130 { |
3109
5a11abf0075c
scrobbler: add support for custom audioscrobbler servers. (closes #23)
William Pitcock <nenolod@atheme.org>
parents:
2971
diff
changeset
|
131 sc_init(username, password, sc_url); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
132 |
364 | 133 g_free(username); |
134 g_free(password); | |
3109
5a11abf0075c
scrobbler: add support for custom audioscrobbler servers. (closes #23)
William Pitcock <nenolod@atheme.org>
parents:
2971
diff
changeset
|
135 g_free(sc_url); |
364 | 136 } |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
137 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
138 if ((!ge_username || !ge_password) || (!*ge_username || !*ge_password)) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
139 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
140 pdebug("username/password not found - not starting Gerpok support", |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
141 DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
142 ge_going = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
143 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
144 else |
364 | 145 { |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
146 gerpok_sc_init(ge_username, ge_password); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
147 |
364 | 148 g_free(ge_username); |
149 g_free(ge_password); | |
150 } | |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
151 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
152 m_scrobbler = g_mutex_new(); |
353 | 153 hs_mutex = g_mutex_new(); |
154 xs_mutex = g_mutex_new(); | |
155 hs_cond = g_cond_new(); | |
156 xs_cond = g_cond_new(); | |
157 | |
158 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
|
159 { |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
160 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
|
161 sc_going = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
162 ge_going = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
163 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
164 } |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
165 |
353 | 166 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
|
167 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
168 pdebug(fmt_vastr("Error creating handshake thread: %s", moo), DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
169 sc_going = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
170 ge_going = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
171 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
172 } |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
173 |
2060 | 174 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
|
175 aud_hook_associate("playback end", aud_hook_playback_end, NULL); |
1027 | 176 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
177 pdebug("plugin started", DEBUG); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
178 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
179 |
2318
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
180 void stop(void) { |
990
238055a6cb8f
[svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents:
880
diff
changeset
|
181 if (!sc_going && !ge_going) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
182 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
183 pdebug("about to lock mutex", DEBUG); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
184 g_mutex_lock(m_scrobbler); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
185 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
|
186 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
|
187 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
|
188 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
|
189 gerpok_sc_cleaner(); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
190 sc_going = 0; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
191 ge_going = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
192 g_mutex_unlock(m_scrobbler); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
193 pdebug("joining threads", DEBUG); |
353 | 194 |
195 /* wake up waiting threads */ | |
196 pdebug("send signal to xs and hs", DEBUG); | |
197 g_cond_signal(xs_cond); | |
198 g_cond_signal(hs_cond); | |
199 | |
200 pdebug("wait xs", DEBUG); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
201 g_thread_join(pt_scrobbler); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
202 |
353 | 203 pdebug("wait hs", DEBUG); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
204 g_thread_join(pt_handshake); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
205 |
353 | 206 g_cond_free(hs_cond); |
207 g_cond_free(xs_cond); | |
208 g_mutex_free(hs_mutex); | |
209 g_mutex_free(xs_mutex); | |
210 g_mutex_free(m_scrobbler); | |
211 | |
2060 | 212 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
|
213 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
|
214 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
215 |
2318
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
216 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
|
217 { |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
218 start(); |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
219 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
|
220 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
|
221 } |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
222 |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
223 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
|
224 { |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
225 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
|
226 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
|
227 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
|
228 } |
d7c321957be8
apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents:
2313
diff
changeset
|
229 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
230 static void *xs_thread(void *data __attribute__((unused))) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
231 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
232 int run = 1; |
353 | 233 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
234 while (run) { |
1443
f4d8082668c1
scrobbler: tuple API update
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
235 Tuple *tuple; |
1026
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
236 GTimeVal sleeptime; |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
237 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
238 /* Error catching */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
239 if(sc_catch_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 errorbox_show(sc_fetch_error()); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
242 sc_clear_error(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
243 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
244 |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
245 if(gerpok_sc_catch_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 errorbox_show(gerpok_sc_fetch_error()); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
248 gerpok_sc_clear_error(); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
249 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
250 |
1026
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
251 if (submit) |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
252 { |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
253 Playlist *playlist; |
553
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
254 |
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
255 pdebug("Submitting song.", DEBUG); |
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
256 |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
257 playlist = aud_playlist_get_active(); |
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
258 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
|
259 |
601 | 260 if (tuple == NULL) |
261 continue; | |
262 | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1693
diff
changeset
|
263 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
|
264 continue; |
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
265 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1693
diff
changeset
|
266 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
|
267 aud_tuple_get_string(tuple, FIELD_TITLE, NULL) != NULL) |
553
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
268 { |
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
269 pdebug(fmt_vastr( |
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
270 "submitting artist: %s, title: %s", |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1693
diff
changeset
|
271 aud_tuple_get_string(tuple, FIELD_ARTIST, NULL), |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1693
diff
changeset
|
272 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
|
273 |
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 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
|
275 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
|
276 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
|
277 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
|
278 if (!track_timeout) |
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2124
diff
changeset
|
279 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
|
280 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
281 else |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
282 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
|
283 |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
284 submit = FALSE; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
285 } |
1026
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
286 |
353 | 287 g_get_current_time(&sleeptime); |
288 sleeptime.tv_sec += XS_SLEEP; | |
289 | |
1026
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
290 g_mutex_lock(xs_mutex); |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
291 g_cond_timed_wait(xs_cond, xs_mutex, &sleeptime); |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
292 g_mutex_unlock(xs_mutex); |
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
1025
diff
changeset
|
293 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
294 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
|
295 run = (sc_going != 0 || ge_going != 0); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
296 g_mutex_unlock(m_scrobbler); |
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 pdebug("scrobbler thread: exiting", DEBUG); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
299 g_thread_exit(NULL); |
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 return NULL; |
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 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
304 static void *hs_thread(void *data __attribute__((unused))) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
305 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
306 int run = 1; |
353 | 307 GTimeVal sleeptime; |
308 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
309 while(run) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
310 { |
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
|
311 if(sc_going && sc_idle(m_scrobbler)) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
312 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
313 pdebug("Giving up due to fatal error", DEBUG); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
314 g_mutex_lock(m_scrobbler); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
315 sc_going = 0; |
353 | 316 g_mutex_unlock(m_scrobbler); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
317 } |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
318 |
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
|
319 if(ge_going && gerpok_sc_idle(m_scrobbler)) |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
320 { |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
321 pdebug("Giving up due to fatal error", DEBUG); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
322 g_mutex_lock(m_scrobbler); |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
323 ge_going = 0; |
353 | 324 g_mutex_unlock(m_scrobbler); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
325 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
326 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
327 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
|
328 run = (sc_going != 0 || ge_going != 0); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
329 g_mutex_unlock(m_scrobbler); |
353 | 330 |
331 if(run) { | |
332 g_get_current_time(&sleeptime); | |
333 sleeptime.tv_sec += HS_SLEEP; | |
334 | |
335 g_mutex_lock(hs_mutex); | |
336 g_cond_timed_wait(hs_cond, hs_mutex, &sleeptime); | |
337 g_mutex_unlock(hs_mutex); | |
338 } | |
0
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 pdebug("handshake thread: exiting", DEBUG); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
341 g_thread_exit(NULL); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
342 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
343 return NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
344 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
345 |
2904
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
346 void setup_proxy(CURL *curl) |
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 mcs_handle_t *db; |
2929
3868d67e7d19
uninitialized values are bad
Tomasz Mon <desowin@gmail.com>
parents:
2904
diff
changeset
|
349 gboolean use_proxy = FALSE; |
2904
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
350 |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
351 db = aud_cfg_db_open(); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
352 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
|
353 if (use_proxy == FALSE) |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
354 { |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
355 curl_easy_setopt(curl, CURLOPT_PROXY, ""); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
356 } |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
357 else |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
358 { |
2929
3868d67e7d19
uninitialized values are bad
Tomasz Mon <desowin@gmail.com>
parents:
2904
diff
changeset
|
359 gchar *proxy_host = NULL, *proxy_port = NULL; |
3868d67e7d19
uninitialized values are bad
Tomasz Mon <desowin@gmail.com>
parents:
2904
diff
changeset
|
360 gboolean proxy_use_auth = FALSE; |
2904
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
361 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
|
362 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
|
363 curl_easy_setopt(curl, CURLOPT_PROXY, proxy_host); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
364 curl_easy_setopt(curl, CURLOPT_PROXYPORT, proxy_port); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
365 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
|
366 if (proxy_use_auth != FALSE) |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
367 { |
2929
3868d67e7d19
uninitialized values are bad
Tomasz Mon <desowin@gmail.com>
parents:
2904
diff
changeset
|
368 gchar *userpwd = NULL, *user = NULL, *pass = NULL; |
2904
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
369 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
|
370 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
|
371 userpwd = g_strdup_printf("%s:%s", user, pass); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
372 curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
373 g_free(userpwd); |
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 } |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
376 aud_cfg_db_close(db); |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
377 } |
ff9b4776b938
now scrobbler uses proxy settings;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2576
diff
changeset
|
378 |
1066 | 379 GeneralPlugin *scrobbler_gplist[] = { &scrobbler_gp, NULL }; |
380 | |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1066
diff
changeset
|
381 DECLARE_PLUGIN(scrobbler, NULL, NULL, NULL, NULL, NULL, scrobbler_gplist, NULL, NULL); |