comparison src/scrobbler/plugin.c @ 2318:d7c321957be8

apply username/password changes 10 seconds after last keystroke in config editboxes
author Tomasz Mon <desowin@gmail.com>
date Tue, 15 Jan 2008 20:26:27 +0100
parents 3f684f1b1840
children 224727e6c73d
comparison
equal deleted inserted replaced
2317:447dce6f59f3 2318:d7c321957be8
98 g_source_remove(track_timeout); 98 g_source_remove(track_timeout);
99 track_timeout = 0; 99 track_timeout = 0;
100 } 100 }
101 } 101 }
102 102
103 static void init(void) 103 void start(void) {
104 {
105 char *username = NULL, *password = NULL; 104 char *username = NULL, *password = NULL;
106 char *ge_username = NULL, *ge_password = NULL; 105 char *ge_username = NULL, *ge_password = NULL;
107 ConfigDb *cfgfile; 106 ConfigDb *cfgfile;
108 sc_going = 1; 107 sc_going = 1;
109 ge_going = 1; 108 ge_going = 1;
110 GError **moo = NULL; 109 GError **moo = NULL;
111 cfgdlg = create_cfgdlg();
112
113 aud_prefswin_page_new(cfgdlg, "Scrobbler", DATA_DIR "/images/audioscrobbler.png");
114 110
115 if ((cfgfile = aud_cfg_db_open()) != NULL) { 111 if ((cfgfile = aud_cfg_db_open()) != NULL) {
116 aud_cfg_db_get_string(cfgfile, "audioscrobbler", "username", 112 aud_cfg_db_get_string(cfgfile, "audioscrobbler", "username",
117 &username); 113 &username);
118 aud_cfg_db_get_string(cfgfile, "audioscrobbler", "password", 114 aud_cfg_db_get_string(cfgfile, "audioscrobbler", "password",
178 aud_hook_associate("playback end", aud_hook_playback_end, NULL); 174 aud_hook_associate("playback end", aud_hook_playback_end, NULL);
179 175
180 pdebug("plugin started", DEBUG); 176 pdebug("plugin started", DEBUG);
181 } 177 }
182 178
183 static void cleanup(void) 179 void stop(void) {
184 {
185 aud_prefswin_page_destroy(cfgdlg);
186
187 if (!sc_going && !ge_going) 180 if (!sc_going && !ge_going)
188 return; 181 return;
189 pdebug("about to lock mutex", DEBUG); 182 pdebug("about to lock mutex", DEBUG);
190 g_mutex_lock(m_scrobbler); 183 g_mutex_lock(m_scrobbler);
191 pdebug("locked mutex", DEBUG); 184 pdebug("locked mutex", DEBUG);
217 210
218 aud_hook_dissociate("playback begin", aud_hook_playback_begin); 211 aud_hook_dissociate("playback begin", aud_hook_playback_begin);
219 aud_hook_dissociate("playback end", aud_hook_playback_end); 212 aud_hook_dissociate("playback end", aud_hook_playback_end);
220 } 213 }
221 214
215 static void init(void)
216 {
217 start();
218 cfgdlg = create_cfgdlg();
219 aud_prefswin_page_new(cfgdlg, "Scrobbler", DATA_DIR "/images/audioscrobbler.png");
220 }
221
222 static void cleanup(void)
223 {
224 stop();
225 aud_prefswin_page_destroy(cfgdlg);
226 }
227
222 static void *xs_thread(void *data __attribute__((unused))) 228 static void *xs_thread(void *data __attribute__((unused)))
223 { 229 {
224 int run = 1; 230 int run = 1;
225 231
226 while (run) { 232 while (run) {