annotate src/scrobbler/plugin.c @ 2507:251336bee085

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