Mercurial > audlegacy-plugins
annotate src/streambrowser/streambrowser.c @ 2735:6d6a3eb67510
some work on the streambrowser
author | Calin Crisan ccrisan@gmail.com |
---|---|
date | Tue, 01 Jul 2008 02:05:25 +0300 |
parents | 28498c0bde64 |
children | 4ec0e13208de |
rev | line source |
---|---|
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
1 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
2 #include <stdlib.h> |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
3 #include <gtk/gtk.h> |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
4 #include <audacious/plugin.h> |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
5 #include <audacious/ui_plugin_menu.h> |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
6 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
7 #include "streambrowser.h" |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
8 #include "streamdir.h" |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
9 #include "shoutcast.h" |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
10 #include "gui/streambrowser_win.h" |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
11 #include "gui/about_win.h" |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
12 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
13 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
14 typedef struct { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
15 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
16 streamdir_t* streamdir; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
17 category_t* category; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
18 streaminfo_t* streaminfo; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
19 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
20 } update_thread_data_t; |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
21 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
22 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
23 static void sb_init(); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
24 static void sb_about(); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
25 static void sb_configure(); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
26 static void sb_cleanup(); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
27 |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
28 static void gui_init(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
29 static void gui_done(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
30 static void config_load(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
31 static void config_save(); |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
32 |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
33 static void streamdir_update(streamdir_t *streamdir, category_t *category, streaminfo_t *streaminfo); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
34 static gpointer update_thread_core(update_thread_data_t *data); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
35 static void streaminfo_add_to_playlist(streaminfo_t *streaminfo); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
36 static void on_plugin_services_menu_item_click(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
37 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
38 static GtkWidget* playlist_menu_item; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
39 static GtkWidget* main_menu_item; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
40 static update_thread_data_t update_thread_data_queue[MAX_UPDATE_THREADS]; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
41 static gint update_thread_count = 0; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
42 static GMutex* update_thread_mutex; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
43 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
44 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
45 streambrowser_cfg_t streambrowser_cfg; |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
46 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
47 static GeneralPlugin sb_plugin = |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
48 { |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
49 .description = "Stream Browser", |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
50 .init = sb_init, |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
51 .about = sb_about, |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
52 .configure = sb_configure, |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
53 .cleanup = sb_cleanup |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
54 }; |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
55 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
56 GeneralPlugin *sb_gplist[] = |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
57 { |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
58 &sb_plugin, |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
59 NULL |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
60 }; |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
61 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
62 SIMPLE_GENERAL_PLUGIN(streambrowser, sb_gplist); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
63 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
64 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
65 void debug(const char *fmt, ...) |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
66 { |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
67 if (streambrowser_cfg.debug) { |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
68 va_list ap; |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
69 fprintf(stderr, "* streambrowser: "); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
70 va_start(ap, fmt); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
71 vfprintf(stderr, fmt, ap); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
72 va_end(ap); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
73 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
74 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
75 |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
76 void failure(const char *fmt, ...) |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
77 { |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
78 va_list ap; |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
79 fprintf(stderr, "! streambrowser: "); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
80 va_start(ap, fmt); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
81 vfprintf(stderr, fmt, ap); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
82 va_end(ap); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
83 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
84 |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
85 gboolean fetch_remote_to_local_file(gchar *remote_url, gchar *local_url) |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
86 { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
87 VFSFile *remote_file = aud_vfs_fopen(remote_url, "r"); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
88 if (remote_file == NULL) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
89 failure("failed to fetch file '%s'\n", remote_url); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
90 return FALSE; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
91 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
92 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
93 VFSFile *local_file = aud_vfs_fopen(local_url, "w"); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
94 if (local_file == NULL) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
95 aud_vfs_fclose(remote_file); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
96 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
97 failure("failed to create local file '%s'\n", local_file); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
98 return FALSE; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
99 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
100 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
101 unsigned char buff[DEF_BUFFER_SIZE]; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
102 int size; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
103 while (!aud_vfs_feof(remote_file)) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
104 size = aud_vfs_fread(buff, 1, DEF_BUFFER_SIZE, remote_file); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
105 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
106 // i don't know why aud_vfs_feof() doesn't ever return TRUE |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
107 // so this is a workaround to properly end the loop |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
108 if (size == 0) |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
109 break; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
110 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
111 size = aud_vfs_fwrite(buff, 1, size, local_file); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
112 if (size == 0) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
113 aud_vfs_fclose(local_file); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
114 aud_vfs_fclose(remote_file); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
115 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
116 failure("failed to write to local file '%s'\n", local_file); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
117 return FALSE; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
118 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
119 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
120 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
121 aud_vfs_fclose(local_file); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
122 aud_vfs_fclose(remote_file); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
123 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
124 return TRUE; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
125 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
126 |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
127 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
128 static void sb_init() |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
129 { |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
130 /* workaround to print sb_init() */ |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
131 streambrowser_cfg.debug = TRUE; |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
132 debug("sb_init()\n"); |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
133 streambrowser_cfg.debug = FALSE; |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
134 |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
135 config_load(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
136 gui_init(); |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
137 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
138 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
139 static void sb_about() |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
140 { |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
141 debug("sb_about()\n"); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
142 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
143 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
144 static void sb_configure() |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
145 { |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
146 debug("sb_configure()\n"); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
147 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
148 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
149 static void sb_cleanup() |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
150 { |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
151 debug("sb_cleanup()\n"); |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
152 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
153 gui_done(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
154 config_save(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
155 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
156 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
157 static void gui_init() |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
158 { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
159 /* the plugin services menu */ |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
160 playlist_menu_item = gtk_image_menu_item_new_with_label("Streambrowser"); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
161 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(playlist_menu_item), gtk_image_new_from_stock(GTK_STOCK_CDROM, GTK_ICON_SIZE_MENU)); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
162 gtk_widget_show(playlist_menu_item); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
163 g_signal_connect(G_OBJECT(playlist_menu_item), "activate", G_CALLBACK(on_plugin_services_menu_item_click), NULL); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
164 audacious_menu_plugin_item_add(AUDACIOUS_MENU_PLAYLIST_RCLICK, playlist_menu_item); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
165 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
166 main_menu_item = gtk_image_menu_item_new_with_label("Streambrowser"); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
167 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(main_menu_item), gtk_image_new_from_stock(GTK_STOCK_CDROM, GTK_ICON_SIZE_MENU)); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
168 gtk_widget_show(main_menu_item); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
169 g_signal_connect(G_OBJECT(main_menu_item), "activate", G_CALLBACK(on_plugin_services_menu_item_click), NULL); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
170 audacious_menu_plugin_item_add(AUDACIOUS_MENU_MAIN, main_menu_item); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
171 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
172 /* main streambrowser window */ |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
173 streambrowser_win_init(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
174 streambrowser_win_set_update_function(streamdir_update); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
175 update_thread_mutex = g_mutex_new(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
176 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
177 debug("gui initialized\n"); |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
178 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
179 |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
180 static void gui_done() |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
181 { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
182 /* the plugin services menu */ |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
183 audacious_menu_plugin_item_remove(AUDACIOUS_MENU_PLAYLIST_RCLICK, playlist_menu_item); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
184 audacious_menu_plugin_item_remove(AUDACIOUS_MENU_MAIN, main_menu_item); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
185 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
186 /* main streambrowser window */ |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
187 streambrowser_win_hide(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
188 streambrowser_win_done(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
189 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
190 debug("gui destroied\n"); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
191 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
192 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
193 static void config_load() |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
194 { |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
195 streambrowser_cfg.debug = FALSE; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
196 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
197 mcs_handle_t *db; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
198 if ((db = aud_cfg_db_open()) == NULL) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
199 failure("failed to load configuration\n"); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
200 return; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
201 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
202 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
203 aud_cfg_db_get_bool(db, "streambrowser", "debug", &streambrowser_cfg.debug); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
204 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
205 aud_cfg_db_close(db); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
206 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
207 debug("configuration loaded\n"); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
208 debug("debug = %d\n", streambrowser_cfg.debug); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
209 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
210 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
211 static void config_save() |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
212 { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
213 mcs_handle_t *db; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
214 if ((db = aud_cfg_db_open()) == NULL) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
215 failure("failed to save configuration\n"); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
216 return; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
217 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
218 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
219 aud_cfg_db_set_bool(db, "streambrowser", "debug", streambrowser_cfg.debug); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
220 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
221 aud_cfg_db_close(db); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
222 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
223 debug("configuration saved\n"); |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
224 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
225 |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
226 static void streamdir_update(streamdir_t *streamdir, category_t *category, streaminfo_t *streaminfo) |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
227 { |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
228 debug("requested streamdir update (streamdir = '%s', category = '%s', streaminfo = '%s')\n", |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
229 streamdir == NULL ? "" : streamdir->name, |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
230 category == NULL ? "" : category->name, |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
231 streaminfo == NULL ? "" : streaminfo->name); |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
232 |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
233 if (update_thread_count >= MAX_UPDATE_THREADS) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
234 debug("another %d streamdir updates are pending, this request will be dropped\n", update_thread_count); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
235 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
236 else |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
237 if (update_thread_count > 0) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
238 debug("another %d streamdir updates are pending, this request will be queued\n", update_thread_count); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
239 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
240 g_mutex_lock(update_thread_mutex); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
241 update_thread_data_queue[update_thread_count].streamdir = streamdir; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
242 update_thread_data_queue[update_thread_count].category = category; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
243 update_thread_data_queue[update_thread_count].streaminfo = streaminfo; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
244 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
245 update_thread_count++; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
246 g_mutex_unlock(update_thread_mutex); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
247 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
248 else { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
249 update_thread_data_t *data = g_malloc(sizeof(update_thread_data_t)); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
250 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
251 data->streamdir = streamdir; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
252 data->category = category; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
253 data->streaminfo = streaminfo; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
254 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
255 g_thread_create((GThreadFunc) update_thread_core, data, TRUE, NULL); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
256 } |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
257 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
258 |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
259 static gpointer update_thread_core(update_thread_data_t *data) |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
260 { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
261 /* update a streaminfo - that is - add this streaminfo to playlist */ |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
262 if (data->streaminfo != NULL) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
263 streaminfo_add_to_playlist(data->streaminfo); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
264 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
265 /* update a category */ |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
266 else if (data->category != NULL) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
267 /* shoutcast */ |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
268 if (strncmp(data->streamdir->name, SHOUTCAST_NAME, strlen(SHOUTCAST_NAME)) == 0) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
269 shoutcast_category_fetch(data->category); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
270 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
271 gdk_threads_enter(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
272 streambrowser_win_set_category(data->streamdir, data->category); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
273 gdk_threads_leave(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
274 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
275 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
276 /* update a streamdir */ |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
277 else if (data->streamdir != NULL) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
278 /* shoutcast */ |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
279 if (strncmp(data->streamdir->name, SHOUTCAST_NAME, strlen(SHOUTCAST_NAME)) == 0) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
280 streamdir_t *streamdir = shoutcast_streamdir_fetch(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
281 if (streamdir != NULL) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
282 gdk_threads_enter(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
283 streambrowser_win_set_streamdir(streamdir, SHOUTCAST_ICON); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
284 gdk_threads_leave(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
285 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
286 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
287 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
288 /* update all streamdirs */ |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
289 else { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
290 /* shoutcast */ |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
291 streamdir_t *shoutcast_streamdir = shoutcast_streamdir_fetch(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
292 if (shoutcast_streamdir != NULL) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
293 gdk_threads_enter(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
294 streambrowser_win_set_streamdir(shoutcast_streamdir, SHOUTCAST_ICON); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
295 gdk_threads_leave(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
296 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
297 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
298 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
299 g_free(data); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
300 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
301 /* check to see if there are pending update requests */ |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
302 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
303 data = NULL; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
304 g_mutex_lock(update_thread_mutex); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
305 if (update_thread_count > 0) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
306 data = g_malloc(sizeof(update_thread_data_t)); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
307 data->streamdir = update_thread_data_queue[0].streamdir; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
308 data->category = update_thread_data_queue[0].category; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
309 data->streaminfo = update_thread_data_queue[0].streaminfo; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
310 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
311 int i; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
312 for (i = 0; i < update_thread_count; i++) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
313 update_thread_data_queue[i].streamdir = update_thread_data_queue[i + 1].streamdir; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
314 update_thread_data_queue[i].category = update_thread_data_queue[i + 1].category; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
315 update_thread_data_queue[i].streaminfo = update_thread_data_queue[i + 1].streaminfo; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
316 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
317 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
318 update_thread_count--; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
319 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
320 g_mutex_unlock(update_thread_mutex); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
321 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
322 if (data != NULL) |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
323 update_thread_core(data); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
324 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
325 return NULL; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
326 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
327 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
328 static void streaminfo_add_to_playlist(streaminfo_t *streaminfo) |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
329 { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
330 debug("fetching stream playlist for station '%s' from '%s'\n", streaminfo->name, streaminfo->playlist_url); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
331 if (!fetch_remote_to_local_file(streaminfo->playlist_url, PLAYLIST_TEMP_FILE)) { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
332 failure("shoutcast: stream playlist '%s' could not be downloaded to '%s'\n", streaminfo->playlist_url, PLAYLIST_TEMP_FILE); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
333 return; |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
334 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
335 debug("stream playlist '%s' successfuly downloaded to '%s'\n", streaminfo->playlist_url, PLAYLIST_TEMP_FILE); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
336 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
337 aud_playlist_add(aud_playlist_get_active(), PLAYLIST_TEMP_FILE); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
338 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
339 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
340 static void on_plugin_services_menu_item_click() |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
341 { |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
342 debug("on_plugin_services_menu_item_click()\n"); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
343 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
344 streambrowser_win_show(); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
345 streamdir_update(NULL, NULL, NULL); |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
346 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
347 |