annotate src/scrobbler/plugin.c @ 2678:59af999361d8

oops
author Tomasz Mon <desowin@gmail.com>
date Sun, 01 Jun 2008 17:01:47 +0200
parents bd3a24b39058
children ff9b4776b938
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 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>
527
d124034ebea3 [svn] - glib/gi18n.h -> audacious/i18n.h for automatic dgettext support
nenolod
parents: 402
diff changeset
5 #include <audacious/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
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
10 #include <audacious/plugin.h>
402
1d50eb0b5a0a [svn] - chase prefswin -> ui_preferences in audacious core
nenolod
parents: 364
diff changeset
11 #include <audacious/ui_preferences.h>
1027
ef86db6345e4 [svn] - some more work here
nenolod
parents: 1026
diff changeset
12 #include <audacious/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
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
22 #include "plugin.h"
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
23 #include "scrobbler.h"
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
24 #include "gerpok.h"
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
25 #include "gtkstuff.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
26 #include "config.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
27 #include "fmt.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
28 #include "configure.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
29
353
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
30 #define XS_SLEEP 1
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
31 #define HS_SLEEP 10
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
32
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
33 typedef struct submit_t
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
34 {
553
269841b8fb31 [svn] - submit gerpok tracks on immediate playback begin
nenolod
parents: 527
diff changeset
35 int dosubmit, pos_c, len, gerpok;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
36 } submit_t;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
37
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
38 static void init(void);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
39 static void cleanup(void);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
40 static void *xs_thread(void *);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
41 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
42 static int sc_going, ge_going;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
43 static GtkWidget *cfgdlg;
1026
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
44 static gboolean submit;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
45
353
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
46 static GMutex *m_scrobbler;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
47 static GThread *pt_scrobbler;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
48 static GThread *pt_handshake;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
49
353
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
50 static GMutex *hs_mutex, *xs_mutex;
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
51 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
52 guint track_timeout;
353
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
53
1066
d1f8b0594f37 [svn] - convert scrobbler to plugin API v2
nenolod
parents: 1060
diff changeset
54 static GeneralPlugin scrobbler_gp =
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
55 {
1635
16044c4a34d7 scrobbler: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1443
diff changeset
56 .description = "Scrobbler Plugin",
16044c4a34d7 scrobbler: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1443
diff changeset
57 .init = init,
16044c4a34d7 scrobbler: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1443
diff changeset
58 .about = about_show,
16044c4a34d7 scrobbler: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1443
diff changeset
59 .cleanup = cleanup
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
60 };
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
61
1026
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
62 static gboolean ishttp(const char *a)
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
63 {
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
64 g_return_val_if_fail(a != NULL, FALSE);
2050
2ffc6a69fcd1 string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
65 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
66 }
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
67
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2057
diff changeset
68 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
69 {
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2057
diff changeset
70 PlaylistEntry *entry = (PlaylistEntry *) aud_hook_data;
1027
ef86db6345e4 [svn] - some more work here
nenolod
parents: 1026
diff changeset
71
1026
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
72 g_return_if_fail(entry != NULL);
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
73
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
74 if (entry->length < 30)
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 pdebug(" *** not submitting due to entry->length < 30", DEBUG);
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
77 return;
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
78 }
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
79
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
80 if (ishttp(entry->filename))
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 pdebug(" *** not submitting due to HTTP source", DEBUG);
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
83 return;
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
84 }
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
85
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
86 /* wake up the scrobbler thread to submit or queue */
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
87 submit = TRUE;
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
88 g_cond_signal(xs_cond);
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
89 }
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
90
2306
dd78327f5747 keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents: 2124
diff changeset
91 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
92 {
dd78327f5747 keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents: 2124
diff changeset
93 if (track_timeout) {
dd78327f5747 keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents: 2124
diff changeset
94 g_source_remove(track_timeout);
dd78327f5747 keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents: 2124
diff changeset
95 track_timeout = 0;
dd78327f5747 keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents: 2124
diff changeset
96 }
dd78327f5747 keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents: 2124
diff changeset
97 }
dd78327f5747 keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents: 2124
diff changeset
98
2318
d7c321957be8 apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents: 2313
diff changeset
99 void start(void) {
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
100 char *username = NULL, *password = NULL;
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
101 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
102 mcs_handle_t *cfgfile;
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
103 sc_going = 1;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
104 ge_going = 1;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
105 GError **moo = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
106
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2071
diff changeset
107 if ((cfgfile = aud_cfg_db_open()) != NULL) {
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2071
diff changeset
108 aud_cfg_db_get_string(cfgfile, "audioscrobbler", "username",
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
109 &username);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2071
diff changeset
110 aud_cfg_db_get_string(cfgfile, "audioscrobbler", "password",
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
111 &password);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2071
diff changeset
112 aud_cfg_db_get_string(cfgfile, "audioscrobbler", "ge_username",
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
113 &ge_username);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2071
diff changeset
114 aud_cfg_db_get_string(cfgfile, "audioscrobbler", "ge_password",
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
115 &ge_password);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2071
diff changeset
116 aud_cfg_db_close(cfgfile);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
117 }
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
118
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
119 if ((!username || !password) || (!*username || !*password))
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 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
122 DEBUG);
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
123 sc_going = 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
124 }
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
125 else
364
50347c06ec68 [svn] - make scrobbler behave better
nenolod
parents: 363
diff changeset
126 {
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
127 sc_init(username, password);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
128
364
50347c06ec68 [svn] - make scrobbler behave better
nenolod
parents: 363
diff changeset
129 g_free(username);
50347c06ec68 [svn] - make scrobbler behave better
nenolod
parents: 363
diff changeset
130 g_free(password);
50347c06ec68 [svn] - make scrobbler behave better
nenolod
parents: 363
diff changeset
131 }
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
132
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
133 if ((!ge_username || !ge_password) || (!*ge_username || !*ge_password))
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 pdebug("username/password not found - not starting Gerpok support",
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
136 DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
137 ge_going = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
138 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
139 else
364
50347c06ec68 [svn] - make scrobbler behave better
nenolod
parents: 363
diff changeset
140 {
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
141 gerpok_sc_init(ge_username, ge_password);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
142
364
50347c06ec68 [svn] - make scrobbler behave better
nenolod
parents: 363
diff changeset
143 g_free(ge_username);
50347c06ec68 [svn] - make scrobbler behave better
nenolod
parents: 363
diff changeset
144 g_free(ge_password);
50347c06ec68 [svn] - make scrobbler behave better
nenolod
parents: 363
diff changeset
145 }
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
146
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
147 m_scrobbler = g_mutex_new();
353
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
148 hs_mutex = g_mutex_new();
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
149 xs_mutex = g_mutex_new();
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
150 hs_cond = g_cond_new();
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
151 xs_cond = g_cond_new();
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
152
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
153 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
154 {
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
155 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
156 sc_going = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
157 ge_going = 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
158 return;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
159 }
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
160
353
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
161 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
162 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
163 pdebug(fmt_vastr("Error creating handshake thread: %s", moo), DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
164 sc_going = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
165 ge_going = 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
166 return;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
167 }
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
168
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2057
diff changeset
169 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
170 aud_hook_associate("playback end", aud_hook_playback_end, NULL);
1027
ef86db6345e4 [svn] - some more work here
nenolod
parents: 1026
diff changeset
171
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
172 pdebug("plugin started", DEBUG);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
173 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
174
2318
d7c321957be8 apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents: 2313
diff changeset
175 void stop(void) {
990
238055a6cb8f [svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents: 880
diff changeset
176 if (!sc_going && !ge_going)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
177 return;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
178 pdebug("about to lock mutex", DEBUG);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
179 g_mutex_lock(m_scrobbler);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
180 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
181 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
182 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
183 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
184 gerpok_sc_cleaner();
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
185 sc_going = 0;
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
186 ge_going = 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
187 g_mutex_unlock(m_scrobbler);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
188 pdebug("joining threads", DEBUG);
353
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
189
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
190 /* wake up waiting threads */
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
191 pdebug("send signal to xs and hs", DEBUG);
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
192 g_cond_signal(xs_cond);
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
193 g_cond_signal(hs_cond);
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
194
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
195 pdebug("wait xs", DEBUG);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
196 g_thread_join(pt_scrobbler);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
197
353
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
198 pdebug("wait hs", DEBUG);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
199 g_thread_join(pt_handshake);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
200
353
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
201 g_cond_free(hs_cond);
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
202 g_cond_free(xs_cond);
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
203 g_mutex_free(hs_mutex);
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
204 g_mutex_free(xs_mutex);
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
205 g_mutex_free(m_scrobbler);
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
206
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2057
diff changeset
207 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
208 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
209 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
210
2318
d7c321957be8 apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents: 2313
diff changeset
211 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
212 {
d7c321957be8 apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents: 2313
diff changeset
213 start();
d7c321957be8 apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents: 2313
diff changeset
214 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
215 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
216 }
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 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
219 {
d7c321957be8 apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents: 2313
diff changeset
220 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
221 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
222 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
223 }
d7c321957be8 apply username/password changes 10 seconds after last keystroke in config editboxes
Tomasz Mon <desowin@gmail.com>
parents: 2313
diff changeset
224
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
225 static void *xs_thread(void *data __attribute__((unused)))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
226 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
227 int run = 1;
353
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
228
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
229 while (run) {
1443
f4d8082668c1 scrobbler: tuple API update
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
230 Tuple *tuple;
1026
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
231 GTimeVal sleeptime;
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
232
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
233 /* Error catching */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
234 if(sc_catch_error())
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
235 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
236 errorbox_show(sc_fetch_error());
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
237 sc_clear_error();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
238 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
239
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
240 if(gerpok_sc_catch_error())
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
241 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
242 errorbox_show(gerpok_sc_fetch_error());
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
243 gerpok_sc_clear_error();
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
244 }
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
245
1026
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
246 if (submit)
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
247 {
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
248 Playlist *playlist;
553
269841b8fb31 [svn] - submit gerpok tracks on immediate playback begin
nenolod
parents: 527
diff changeset
249
269841b8fb31 [svn] - submit gerpok tracks on immediate playback begin
nenolod
parents: 527
diff changeset
250 pdebug("Submitting song.", DEBUG);
269841b8fb31 [svn] - submit gerpok tracks on immediate playback begin
nenolod
parents: 527
diff changeset
251
2057
cf4fa45ffd80 playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents: 2050
diff changeset
252 playlist = aud_playlist_get_active();
cf4fa45ffd80 playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents: 2050
diff changeset
253 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
254
601
45c9130027d9 [svn] - handle unavailable tuples better
nenolod
parents: 554
diff changeset
255 if (tuple == NULL)
45c9130027d9 [svn] - handle unavailable tuples better
nenolod
parents: 554
diff changeset
256 continue;
45c9130027d9 [svn] - handle unavailable tuples better
nenolod
parents: 554
diff changeset
257
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1693
diff changeset
258 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
259 continue;
269841b8fb31 [svn] - submit gerpok tracks on immediate playback begin
nenolod
parents: 527
diff changeset
260
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1693
diff changeset
261 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
262 aud_tuple_get_string(tuple, FIELD_TITLE, NULL) != NULL)
553
269841b8fb31 [svn] - submit gerpok tracks on immediate playback begin
nenolod
parents: 527
diff changeset
263 {
269841b8fb31 [svn] - submit gerpok tracks on immediate playback begin
nenolod
parents: 527
diff changeset
264 pdebug(fmt_vastr(
269841b8fb31 [svn] - submit gerpok tracks on immediate playback begin
nenolod
parents: 527
diff changeset
265 "submitting artist: %s, title: %s",
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1693
diff changeset
266 aud_tuple_get_string(tuple, FIELD_ARTIST, 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)), 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
268
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
269 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
270 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
271 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
272 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
273 if (!track_timeout)
dd78327f5747 keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents: 2124
diff changeset
274 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
275 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
276 else
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
277 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
278
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
279 submit = FALSE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
280 }
1026
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
281
353
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
282 g_get_current_time(&sleeptime);
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
283 sleeptime.tv_sec += XS_SLEEP;
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
284
1026
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
285 g_mutex_lock(xs_mutex);
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
286 g_cond_timed_wait(xs_cond, xs_mutex, &sleeptime);
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
287 g_mutex_unlock(xs_mutex);
ff0487e9d00d [svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents: 1025
diff changeset
288
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
289 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
290 run = (sc_going != 0 || ge_going != 0);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
291 g_mutex_unlock(m_scrobbler);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
292 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
293 pdebug("scrobbler thread: exiting", DEBUG);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
294 g_thread_exit(NULL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
295
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
296 return 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
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
299 static void *hs_thread(void *data __attribute__((unused)))
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 int run = 1;
353
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
302 GTimeVal sleeptime;
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
303
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
304 while(run)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
305 {
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
306 if(sc_going && sc_idle(m_scrobbler))
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
307 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
308 pdebug("Giving up due to fatal error", DEBUG);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
309 g_mutex_lock(m_scrobbler);
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
310 sc_going = 0;
353
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
311 g_mutex_unlock(m_scrobbler);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
312 }
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
313
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
314 if(ge_going && gerpok_sc_idle(m_scrobbler))
344
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
315 {
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
316 pdebug("Giving up due to fatal error", DEBUG);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
317 g_mutex_lock(m_scrobbler);
03c1ae10bc8d [svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents: 108
diff changeset
318 ge_going = 0;
353
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
319 g_mutex_unlock(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
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
322 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
323 run = (sc_going != 0 || ge_going != 0);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
324 g_mutex_unlock(m_scrobbler);
353
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
325
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
326 if(run) {
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
327 g_get_current_time(&sleeptime);
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
328 sleeptime.tv_sec += HS_SLEEP;
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
329
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
330 g_mutex_lock(hs_mutex);
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
331 g_cond_timed_wait(hs_cond, hs_mutex, &sleeptime);
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
332 g_mutex_unlock(hs_mutex);
1bd205b6e83d [svn] - replace g_usleep() with g_cond_timed_wait()
yaz
parents: 350
diff changeset
333 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
334 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
335 pdebug("handshake thread: exiting", DEBUG);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
336 g_thread_exit(NULL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
337
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
338 return 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
1066
d1f8b0594f37 [svn] - convert scrobbler to plugin API v2
nenolod
parents: 1060
diff changeset
341 GeneralPlugin *scrobbler_gplist[] = { &scrobbler_gp, NULL };
d1f8b0594f37 [svn] - convert scrobbler to plugin API v2
nenolod
parents: 1060
diff changeset
342
1395
761e17b23e0c added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents: 1066
diff changeset
343 DECLARE_PLUGIN(scrobbler, NULL, NULL, NULL, NULL, NULL, scrobbler_gplist, NULL, NULL);