Mercurial > audlegacy-plugins
annotate src/streambrowser/streambrowser.c @ 3150:062f42c3737e
Fix possible crash in scrobbler plugin
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Tue, 12 May 2009 08:30:43 +0200 |
parents | 3134a0987162 |
children |
rev | line source |
---|---|
2811 | 1 /* |
2 * Audacious Streambrowser Plugin | |
3 * | |
4 * Copyright (c) 2008 Calin Crisan <ccrisan@gmail.com> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; under version 3 of the License. | |
9 * | |
10 * This program is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License | |
16 * along with this program. If not, see <http://www.gnu.org/licenses>. | |
17 */ | |
18 | |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
19 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
20 #include <stdlib.h> |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
21 #include <gtk/gtk.h> |
2891 | 22 #include <glib.h> |
2971
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2915
diff
changeset
|
23 #include <audlegacy/plugin.h> |
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2915
diff
changeset
|
24 #include <audlegacy/ui_plugin_menu.h> |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
25 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
26 #include "streambrowser.h" |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
27 #include "streamdir.h" |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
28 #include "shoutcast.h" |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
29 #include "xiph.h" |
2891 | 30 #include "bookmarks.h" |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
31 #include "gui/streambrowser_win.h" |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
32 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
33 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
34 typedef struct { |
2891 | 35 |
36 gboolean debug; | |
37 bookmark_t *bookmarks; | |
38 int bookmarks_count; | |
39 | |
40 } streambrowser_cfg_t; | |
41 | |
42 typedef struct { | |
43 | |
2788 | 44 streamdir_t *streamdir; |
45 category_t *category; | |
46 streaminfo_t *streaminfo; | |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
47 gboolean add_to_playlist; |
2891 | 48 |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
49 } update_thread_data_t; |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
50 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
51 |
2788 | 52 static void sb_init(); |
53 static void sb_about(); | |
54 static void sb_configure(); | |
55 static void sb_cleanup(); | |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
56 |
2788 | 57 static void gui_init(); |
58 static void gui_done(); | |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
59 |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
60 static void streamdir_update(streamdir_t *streamdir, category_t *category, streaminfo_t *streaminfo, gboolean add_to_playlist); |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
61 static gpointer update_thread_core(gpointer user_data); |
2788 | 62 static void streaminfo_add_to_playlist(streaminfo_t *streaminfo); |
63 static void on_plugin_services_menu_item_click(); | |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
64 |
2788 | 65 static GtkWidget *playlist_menu_item; |
66 static GtkWidget *main_menu_item; | |
67 static GQueue *update_thread_data_queue = NULL; | |
68 static GMutex *update_thread_mutex = NULL; | |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
69 |
2788 | 70 streambrowser_cfg_t streambrowser_cfg; |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
71 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
72 static GeneralPlugin sb_plugin = |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
73 { |
2788 | 74 .description = "Stream Browser", |
75 .init = sb_init, | |
76 .about = sb_about, | |
77 .configure = sb_configure, | |
78 .cleanup = sb_cleanup | |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
79 }; |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
80 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
81 GeneralPlugin *sb_gplist[] = |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
82 { |
2788 | 83 &sb_plugin, |
84 NULL | |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
85 }; |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
86 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
87 SIMPLE_GENERAL_PLUGIN(streambrowser, sb_gplist); |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
88 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
89 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
90 void debug(const char *fmt, ...) |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
91 { |
2788 | 92 if (streambrowser_cfg.debug) { |
93 va_list ap; | |
94 fprintf(stderr, "* streambrowser: "); | |
95 va_start(ap, fmt); | |
96 vfprintf(stderr, fmt, ap); | |
97 va_end(ap); | |
98 } | |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
99 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
100 |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
101 void failure(const char *fmt, ...) |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
102 { |
2788 | 103 va_list ap; |
104 fprintf(stderr, "! streambrowser: "); | |
105 va_start(ap, fmt); | |
106 vfprintf(stderr, fmt, ap); | |
107 va_end(ap); | |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
108 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
109 |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
110 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
|
111 { |
2788 | 112 VFSFile *remote_file = aud_vfs_fopen(remote_url, "r"); |
113 if (remote_file == NULL) { | |
114 failure("failed to fetch file '%s'\n", remote_url); | |
115 return FALSE; | |
116 } | |
117 | |
118 VFSFile *local_file = aud_vfs_fopen(local_url, "w"); | |
119 if (local_file == NULL) { | |
120 aud_vfs_fclose(remote_file); | |
121 | |
122 failure("failed to create local file '%s'\n", local_file); | |
123 return FALSE; | |
124 } | |
125 | |
126 unsigned char buff[DEF_BUFFER_SIZE]; | |
127 int size; | |
128 while (!aud_vfs_feof(remote_file)) { | |
129 size = aud_vfs_fread(buff, 1, DEF_BUFFER_SIZE, remote_file); | |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
130 |
2788 | 131 // i don't know why aud_vfs_feof() doesn't ever return TRUE |
132 // so this is a workaround to properly end the loop | |
133 if (size == 0) | |
134 break; | |
135 | |
136 size = aud_vfs_fwrite(buff, 1, size, local_file); | |
137 if (size == 0) { | |
138 aud_vfs_fclose(local_file); | |
139 aud_vfs_fclose(remote_file); | |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
140 |
2788 | 141 failure("failed to write to local file '%s'\n", local_file); |
142 return FALSE; | |
143 } | |
144 } | |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
145 |
2788 | 146 aud_vfs_fclose(local_file); |
147 aud_vfs_fclose(remote_file); | |
148 | |
149 return TRUE; | |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
150 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
151 |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
152 void config_load() |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
153 { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
154 streambrowser_cfg.debug = FALSE; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
155 streambrowser_cfg.bookmarks = NULL; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
156 streambrowser_cfg.bookmarks_count = 0; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
157 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
158 mcs_handle_t *db; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
159 if ((db = aud_cfg_db_open()) == NULL) { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
160 failure("failed to load configuration\n"); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
161 return; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
162 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
163 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
164 aud_cfg_db_get_bool(db, "streambrowser", "debug", &streambrowser_cfg.debug); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
165 aud_cfg_db_get_int(db, "streambrowser", "bookmarks_count", &streambrowser_cfg.bookmarks_count); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
166 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
167 debug("debug = %d\n", streambrowser_cfg.debug); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
168 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
169 if (streambrowser_cfg.bookmarks_count == 0) |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
170 streambrowser_cfg.bookmarks = NULL; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
171 else |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
172 streambrowser_cfg.bookmarks = g_malloc(sizeof(bookmark_t) * streambrowser_cfg.bookmarks_count); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
173 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
174 int i; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
175 gchar item[DEF_STRING_LEN]; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
176 gchar *value; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
177 for (i = 0; i < streambrowser_cfg.bookmarks_count; i++) { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
178 g_snprintf(item, DEF_STRING_LEN, "bookmark%d_streamdir_name", i); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
179 if (aud_cfg_db_get_string(db, "streambrowser", item, &value)) { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
180 strncpy(streambrowser_cfg.bookmarks[i].streamdir_name, value, DEF_STRING_LEN); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
181 g_free(value); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
182 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
183 else |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
184 streambrowser_cfg.bookmarks[i].streamdir_name[0] = '\0'; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
185 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
186 g_snprintf(item, DEF_STRING_LEN, "bookmark%d_name", i); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
187 if (aud_cfg_db_get_string(db, "streambrowser", item, &value)) { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
188 strncpy(streambrowser_cfg.bookmarks[i].name, value, DEF_STRING_LEN); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
189 g_free(value); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
190 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
191 else |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
192 streambrowser_cfg.bookmarks[i].name[0] = '\0'; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
193 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
194 g_snprintf(item, DEF_STRING_LEN, "bookmark%d_playlist_url", i); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
195 if (aud_cfg_db_get_string(db, "streambrowser", item, &value)) { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
196 strncpy(streambrowser_cfg.bookmarks[i].playlist_url, value, DEF_STRING_LEN); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
197 g_free(value); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
198 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
199 else |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
200 streambrowser_cfg.bookmarks[i].playlist_url[0] = '\0'; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
201 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
202 g_snprintf(item, DEF_STRING_LEN, "bookmark%d_url", i); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
203 if (aud_cfg_db_get_string(db, "streambrowser", item, &value)) { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
204 strncpy(streambrowser_cfg.bookmarks[i].url, value, DEF_STRING_LEN); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
205 g_free(value); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
206 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
207 else |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
208 streambrowser_cfg.bookmarks[i].url[0] = '\0'; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
209 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
210 debug("loaded a bookmark with streamdir_name = '%s', name = '%s', playlist_url = '%s', url = '%s'\n", |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
211 streambrowser_cfg.bookmarks[i].streamdir_name, |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
212 streambrowser_cfg.bookmarks[i].name, |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
213 streambrowser_cfg.bookmarks[i].playlist_url, |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
214 streambrowser_cfg.bookmarks[i].url); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
215 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
216 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
217 debug("loaded %d bookmarks\n", streambrowser_cfg.bookmarks_count); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
218 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
219 aud_cfg_db_close(db); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
220 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
221 debug("configuration loaded\n"); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
222 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
223 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
224 void config_save() |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
225 { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
226 mcs_handle_t *db; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
227 if ((db = aud_cfg_db_open()) == NULL) { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
228 failure("failed to save configuration\n"); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
229 return; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
230 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
231 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
232 aud_cfg_db_set_bool(db, "streambrowser", "debug", streambrowser_cfg.debug); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
233 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
234 int old_bookmarks_count, i; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
235 gchar item[DEF_STRING_LEN]; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
236 aud_cfg_db_get_int(db, "streambrowser", "bookmarks_count", &old_bookmarks_count); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
237 aud_cfg_db_set_int(db, "streambrowser", "bookmarks_count", streambrowser_cfg.bookmarks_count); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
238 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
239 for (i = 0; i < streambrowser_cfg.bookmarks_count; i++) { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
240 debug("saving bookmark with streamdir_name = '%s', name = '%s', playlist_url = '%s', url = '%s'\n", |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
241 streambrowser_cfg.bookmarks[i].streamdir_name, |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
242 streambrowser_cfg.bookmarks[i].name, |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
243 streambrowser_cfg.bookmarks[i].playlist_url, |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
244 streambrowser_cfg.bookmarks[i].url); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
245 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
246 g_snprintf(item, DEF_STRING_LEN, "bookmark%d_streamdir_name", i); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
247 aud_cfg_db_set_string(db, "streambrowser", item, streambrowser_cfg.bookmarks[i].streamdir_name); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
248 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
249 g_snprintf(item, DEF_STRING_LEN, "bookmark%d_name", i); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
250 aud_cfg_db_set_string(db, "streambrowser", item, streambrowser_cfg.bookmarks[i].name); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
251 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
252 g_snprintf(item, DEF_STRING_LEN, "bookmark%d_playlist_url", i); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
253 aud_cfg_db_set_string(db, "streambrowser", item, streambrowser_cfg.bookmarks[i].playlist_url); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
254 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
255 g_snprintf(item, DEF_STRING_LEN, "bookmark%d_url", i); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
256 aud_cfg_db_set_string(db, "streambrowser", item, streambrowser_cfg.bookmarks[i].url); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
257 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
258 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
259 for (i = streambrowser_cfg.bookmarks_count; i < old_bookmarks_count; i++) { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
260 g_snprintf(item, DEF_STRING_LEN, "bookmark%d_streamdir_name", i); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
261 aud_cfg_db_unset_key(db, "streambrowser", item); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
262 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
263 g_snprintf(item, DEF_STRING_LEN, "bookmark%d_name", i); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
264 aud_cfg_db_unset_key(db, "streambrowser", item); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
265 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
266 g_snprintf(item, DEF_STRING_LEN, "bookmark%d_playlist_url", i); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
267 aud_cfg_db_unset_key(db, "streambrowser", item); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
268 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
269 g_snprintf(item, DEF_STRING_LEN, "bookmark%d_url", i); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
270 aud_cfg_db_unset_key(db, "streambrowser", item); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
271 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
272 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
273 aud_cfg_db_close(db); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
274 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
275 debug("configuration saved\n"); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
276 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
277 |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
278 gboolean mystrcasestr(const char *haystack, const char *needle) |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
279 { |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
280 int len_h = strlen(haystack) + 1; |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
281 int len_n = strlen(needle) + 1; |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
282 int i; |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
283 |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
284 char *upper_h = malloc(len_h); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
285 char *upper_n = malloc(len_n); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
286 |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
287 for (i = 0; i < len_h; i++) |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
288 upper_h[i] = toupper(haystack[i]); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
289 for (i = 0; i < len_n; i++) |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
290 upper_n[i] = toupper(needle[i]); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
291 |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
292 char *p = strstr(upper_h, upper_n); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
293 |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
294 free(upper_h); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
295 free(upper_n); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
296 |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
297 return (gboolean) p; |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
298 } |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
299 |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
300 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
301 static void sb_init() |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
302 { |
2788 | 303 /* workaround to print sb_init() */ |
304 streambrowser_cfg.debug = TRUE; | |
305 debug("sb_init()\n"); | |
306 streambrowser_cfg.debug = FALSE; | |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
307 |
2788 | 308 config_load(); |
309 gui_init(); | |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
310 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
311 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
312 static void sb_about() |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
313 { |
2788 | 314 debug("sb_about()\n"); |
2915 | 315 |
316 static GtkWidget* about_window = NULL; | |
317 | |
318 if (about_window != NULL) { | |
319 gtk_window_present(GTK_WINDOW(about_window)); | |
320 } | |
321 else { | |
322 about_window = audacious_info_dialog(_("About Stream Browser"), | |
323 _("Copyright (c) 2008, by Calin Crisan <ccrisan@gmail.com> and The Audacious Team.\n\n" | |
324 "This is a simple stream browser that includes the most popular streaming directories.\n" | |
325 "Many thanks to the Streamtuner developers <http://www.nongnu.org/streamtuner>,\n" | |
326 "\tand of course to the whole Audacious community.\n\n" | |
327 "Also thank you Tony Vroon for mentoring & guiding me, again.\n\n" | |
328 "This was a Google Summer of Code 2008 project."), _("OK"), FALSE, NULL, NULL); | |
329 | |
330 g_signal_connect(G_OBJECT(about_window), "destroy", G_CALLBACK(gtk_widget_destroyed), &about_window); | |
331 } | |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
332 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
333 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
334 static void sb_configure() |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
335 { |
2788 | 336 debug("sb_configure()\n"); |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
337 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
338 |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
339 static void sb_cleanup() |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
340 { |
2788 | 341 debug("sb_cleanup()\n"); |
342 | |
343 gui_done(); | |
344 config_save(); | |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
345 } |
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 static void gui_init() |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
348 { |
2788 | 349 /* the plugin services menu */ |
2790
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2788
diff
changeset
|
350 playlist_menu_item = gtk_image_menu_item_new_with_label(_("Streambrowser")); |
2791
f9c6a9cb442e
streambrowser has now an icon
Calin Crisan ccrisan@gmail.com
parents:
2790
diff
changeset
|
351 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(playlist_menu_item), gtk_image_new_from_file(STREAMBROWSER_ICON_SMALL)); |
2788 | 352 gtk_widget_show(playlist_menu_item); |
353 g_signal_connect(G_OBJECT(playlist_menu_item), "activate", G_CALLBACK(on_plugin_services_menu_item_click), NULL); | |
354 audacious_menu_plugin_item_add(AUDACIOUS_MENU_PLAYLIST_RCLICK, playlist_menu_item); | |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
355 |
2790
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2788
diff
changeset
|
356 main_menu_item = gtk_image_menu_item_new_with_label(_("Streambrowser")); |
2791
f9c6a9cb442e
streambrowser has now an icon
Calin Crisan ccrisan@gmail.com
parents:
2790
diff
changeset
|
357 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(main_menu_item), gtk_image_new_from_file(STREAMBROWSER_ICON_SMALL)); |
2788 | 358 gtk_widget_show(main_menu_item); |
359 g_signal_connect(G_OBJECT(main_menu_item), "activate", G_CALLBACK(on_plugin_services_menu_item_click), NULL); | |
360 audacious_menu_plugin_item_add(AUDACIOUS_MENU_MAIN, main_menu_item); | |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
361 |
2788 | 362 /* main streambrowser window */ |
363 streambrowser_win_init(); | |
364 streambrowser_win_set_update_function(streamdir_update); | |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
365 |
2788 | 366 /* others */ |
367 update_thread_mutex = g_mutex_new(); | |
368 update_thread_data_queue = g_queue_new(); | |
369 | |
370 debug("gui initialized\n"); | |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
371 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
372 |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
373 static void gui_done() |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
374 { |
2788 | 375 /* the plugin services menu */ |
376 audacious_menu_plugin_item_remove(AUDACIOUS_MENU_PLAYLIST_RCLICK, playlist_menu_item); | |
377 audacious_menu_plugin_item_remove(AUDACIOUS_MENU_MAIN, main_menu_item); | |
378 | |
379 /* main streambrowser window */ | |
380 streambrowser_win_hide(); | |
381 streambrowser_win_done(); | |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
382 |
2788 | 383 /* others */ |
384 if (update_thread_mutex) | |
385 g_mutex_free(update_thread_mutex); | |
386 update_thread_mutex = NULL; | |
387 if (update_thread_data_queue) | |
388 g_queue_free(update_thread_data_queue); | |
389 update_thread_data_queue = NULL; | |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
390 |
2788 | 391 debug("gui destroyed\n"); |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
392 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
393 |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
394 static void streamdir_update(streamdir_t *streamdir, category_t *category, streaminfo_t *streaminfo, gboolean add_to_playlist) |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
395 { |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
396 debug("requested streamdir update (streamdir = '%s', category = '%s', streaminfo = '%s', add_to_playlist = %d)\n", |
2788 | 397 streamdir == NULL ? "" : streamdir->name, |
398 category == NULL ? "" : category->name, | |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
399 streaminfo == NULL ? "" : streaminfo->name, |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
400 add_to_playlist); |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
401 |
2817
779125caa3ac
added xiph icon; smaller icons for streamdirs; fetch queue fix; up/down keys in tree view no longer focus the search entry
Calin Crisan ccrisan@gmail.com
parents:
2815
diff
changeset
|
402 if (g_queue_get_length(update_thread_data_queue) >= MAX_UPDATE_THREADS) { |
779125caa3ac
added xiph icon; smaller icons for streamdirs; fetch queue fix; up/down keys in tree view no longer focus the search entry
Calin Crisan ccrisan@gmail.com
parents:
2815
diff
changeset
|
403 debug("another %d streamdir updates are pending, this request will be dropped\n", g_queue_get_length(update_thread_data_queue)); |
2788 | 404 } |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
405 else { |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
406 g_mutex_lock(update_thread_mutex); |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
407 |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
408 /* do we have a running thread? */ |
2817
779125caa3ac
added xiph icon; smaller icons for streamdirs; fetch queue fix; up/down keys in tree view no longer focus the search entry
Calin Crisan ccrisan@gmail.com
parents:
2815
diff
changeset
|
409 if (g_queue_get_length(update_thread_data_queue) > 0) { |
2788 | 410 int i; |
411 gboolean exists = FALSE; | |
412 update_thread_data_t *update_thread_data; | |
413 | |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
414 /* search for another identic update request */ |
2788 | 415 for (i = 0; i < g_queue_get_length(update_thread_data_queue); i++) { |
416 update_thread_data = g_queue_peek_nth(update_thread_data_queue, i); | |
417 if (update_thread_data->streamdir == streamdir && | |
418 update_thread_data->category == category && | |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
419 update_thread_data->streaminfo == streaminfo && |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
420 update_thread_data->add_to_playlist == add_to_playlist) { |
2788 | 421 exists = TRUE; |
422 break; | |
423 } | |
424 } | |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
425 |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
426 /* if no other similar request exists, we enqueue it */ |
2788 | 427 if (!exists) { |
2817
779125caa3ac
added xiph icon; smaller icons for streamdirs; fetch queue fix; up/down keys in tree view no longer focus the search entry
Calin Crisan ccrisan@gmail.com
parents:
2815
diff
changeset
|
428 debug("another %d streamdir updates are pending, this request will be queued\n", g_queue_get_length(update_thread_data_queue)); |
2788 | 429 |
430 update_thread_data = g_malloc(sizeof(update_thread_data_t)); | |
431 | |
432 update_thread_data->streamdir = streamdir; | |
433 update_thread_data->category = category; | |
434 update_thread_data->streaminfo = streaminfo; | |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
435 update_thread_data->add_to_playlist = add_to_playlist; |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
436 |
2788 | 437 g_queue_push_tail(update_thread_data_queue, update_thread_data); |
438 } | |
439 else { | |
440 debug("this request is already present in the queue, dropping\n"); | |
441 } | |
442 } | |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
443 /* no thread is currently running, we start one */ |
2788 | 444 else { |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
445 debug("no other streamdir updates are pending, starting to process this request immediately\n"); |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
446 |
2788 | 447 update_thread_data_t *data = g_malloc(sizeof(update_thread_data_t)); |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
448 |
2788 | 449 data->streamdir = streamdir; |
450 data->category = category; | |
451 data->streaminfo = streaminfo; | |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
452 data->add_to_playlist = add_to_playlist; |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
453 |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
454 g_queue_push_tail(update_thread_data_queue, data); |
2788 | 455 |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
456 g_thread_create((GThreadFunc) update_thread_core, NULL, FALSE, NULL); |
2788 | 457 } |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
458 |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
459 g_mutex_unlock(update_thread_mutex); |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
460 } |
2570
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
461 } |
28498c0bde64
Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff
changeset
|
462 |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
463 static gpointer update_thread_core(gpointer user_data) |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
464 { |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
465 debug("entering update thread core\n"); |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
466 |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
467 /* try to get the last item in the queue, but don't remove it */ |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
468 g_mutex_lock(update_thread_mutex); |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
469 update_thread_data_t *data = NULL; |
2817
779125caa3ac
added xiph icon; smaller icons for streamdirs; fetch queue fix; up/down keys in tree view no longer focus the search entry
Calin Crisan ccrisan@gmail.com
parents:
2815
diff
changeset
|
470 if (g_queue_get_length(update_thread_data_queue) > 0) { |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
471 data = g_queue_peek_head(update_thread_data_queue); |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
472 } |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
473 g_mutex_unlock(update_thread_mutex); |
2788 | 474 |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
475 /* repetitively process the queue elements, until queue is empty */ |
2817
779125caa3ac
added xiph icon; smaller icons for streamdirs; fetch queue fix; up/down keys in tree view no longer focus the search entry
Calin Crisan ccrisan@gmail.com
parents:
2815
diff
changeset
|
476 while (data != NULL && g_queue_get_length(update_thread_data_queue) > 0) { |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
477 /* update a streaminfo */ |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
478 if (data->streaminfo != NULL) { |
2797
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
479 gdk_threads_enter(); |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
480 streambrowser_win_set_streaminfo_state(data->streamdir, data->category, data->streaminfo, TRUE); |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
481 gdk_threads_leave(); |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
482 |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
483 if (data->add_to_playlist) |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
484 streaminfo_add_to_playlist(data->streaminfo); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
485 else { |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
486 /* shoutcast */ |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
487 if (strncmp(data->streamdir->name, SHOUTCAST_NAME, strlen(SHOUTCAST_NAME)) == 0) { |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
488 shoutcast_streaminfo_fetch(data->category, data->streaminfo); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
489 } |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
490 /* xiph */ |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
491 else if (strncmp(data->streamdir->name, XIPH_NAME, strlen(XIPH_NAME)) == 0) { |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
492 xiph_streaminfo_fetch(data->category, data->streaminfo); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
493 } |
2891 | 494 /* bookmarks */ |
495 else if (strncmp(data->streamdir->name, BOOKMARKS_NAME, strlen(BOOKMARKS_NAME)) == 0) { | |
496 bookmarks_streaminfo_fetch(data->category, data->streaminfo); | |
497 } | |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
498 } |
2797
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
499 |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
500 gdk_threads_enter(); |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
501 if (!data->add_to_playlist) |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
502 streambrowser_win_set_streaminfo(data->streamdir, data->category, data->streaminfo); |
2797
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
503 streambrowser_win_set_streaminfo_state(data->streamdir, data->category, data->streaminfo, FALSE); |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
504 gdk_threads_leave(); |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
505 } |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
506 /* update a category */ |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
507 else if (data->category != NULL) { |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
508 gdk_threads_enter(); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
509 streambrowser_win_set_category_state(data->streamdir, data->category, TRUE); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
510 gdk_threads_leave(); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
511 |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
512 /* shoutcast */ |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
513 if (strncmp(data->streamdir->name, SHOUTCAST_NAME, strlen(SHOUTCAST_NAME)) == 0) { |
2891 | 514 shoutcast_category_fetch(data->streamdir, data->category); |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
515 } |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
516 /* xiph */ |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
517 else if (strncmp(data->streamdir->name, XIPH_NAME, strlen(XIPH_NAME)) == 0) { |
2891 | 518 xiph_category_fetch(data->streamdir, data->category); |
519 } | |
520 /* bookmarks */ | |
521 else if (strncmp(data->streamdir->name, BOOKMARKS_NAME, strlen(BOOKMARKS_NAME)) == 0) { | |
522 bookmarks_category_fetch(data->streamdir, data->category); | |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
523 } |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
524 |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
525 gdk_threads_enter(); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
526 streambrowser_win_set_category(data->streamdir, data->category); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
527 streambrowser_win_set_category_state(data->streamdir, data->category, FALSE); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
528 gdk_threads_leave(); |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
529 } |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
530 /* update a streamdir */ |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
531 else if (data->streamdir != NULL) { |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
532 /* shoutcast */ |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
533 if (strncmp(data->streamdir->name, SHOUTCAST_NAME, strlen(SHOUTCAST_NAME)) == 0) { |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
534 streamdir_t *streamdir = shoutcast_streamdir_fetch(); |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
535 if (streamdir != NULL) { |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
536 gdk_threads_enter(); |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
537 streambrowser_win_set_streamdir(streamdir, SHOUTCAST_ICON); |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
538 gdk_threads_leave(); |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
539 } |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
540 } |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
541 /* xiph */ |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
542 else if (strncmp(data->streamdir->name, XIPH_NAME, strlen(XIPH_NAME)) == 0) { |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
543 streamdir_t *streamdir = xiph_streamdir_fetch(); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
544 if (streamdir != NULL) { |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
545 gdk_threads_enter(); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
546 streambrowser_win_set_streamdir(streamdir, XIPH_ICON); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
547 gdk_threads_leave(); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
548 } |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
549 } |
2891 | 550 /* bookmarks */ |
551 else if (strncmp(data->streamdir->name, BOOKMARKS_NAME, strlen(BOOKMARKS_NAME)) == 0) { | |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
552 streamdir_t *streamdir = bookmarks_streamdir_fetch(&streambrowser_cfg.bookmarks, &streambrowser_cfg.bookmarks_count); |
2891 | 553 if (streamdir != NULL) { |
554 gdk_threads_enter(); | |
555 streambrowser_win_set_streamdir(streamdir, BOOKMARKS_ICON); | |
556 gdk_threads_leave(); | |
557 } | |
558 } | |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
559 } |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
560 /* update all streamdirs */ |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
561 else { |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
562 /* shoutcast */ |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
563 streamdir_t *streamdir = shoutcast_streamdir_fetch(); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
564 if (streamdir != NULL) { |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
565 gdk_threads_enter(); |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
566 streambrowser_win_set_streamdir(streamdir, SHOUTCAST_ICON); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
567 gdk_threads_leave(); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
568 } |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
569 /* xiph */ |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
570 streamdir = xiph_streamdir_fetch(); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
571 if (streamdir != NULL) { |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
572 gdk_threads_enter(); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
573 streambrowser_win_set_streamdir(streamdir, XIPH_ICON); |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
574 gdk_threads_leave(); |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
575 } |
2891 | 576 /* bookmarks */ |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
577 streamdir = bookmarks_streamdir_fetch(&streambrowser_cfg.bookmarks, &streambrowser_cfg.bookmarks_count); |
2891 | 578 if (streamdir != NULL) { |
579 gdk_threads_enter(); | |
580 streambrowser_win_set_streamdir(streamdir, BOOKMARKS_ICON); | |
581 gdk_threads_leave(); | |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
582 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
583 int i; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
584 for (i = 0; i < category_get_count(streamdir); i++) |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
585 streamdir_update(streamdir, category_get_by_index(streamdir, i), NULL, FALSE); |
2891 | 586 } |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
587 } |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
588 |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
589 g_free(data); |
2788 | 590 |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
591 g_mutex_lock(update_thread_mutex); |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
592 |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
593 /* remove the just processed data from the queue */ |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
594 g_queue_pop_head(update_thread_data_queue); |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
595 |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
596 /* try to get the last item in the queue */ |
2817
779125caa3ac
added xiph icon; smaller icons for streamdirs; fetch queue fix; up/down keys in tree view no longer focus the search entry
Calin Crisan ccrisan@gmail.com
parents:
2815
diff
changeset
|
597 if (g_queue_get_length(update_thread_data_queue) > 0) |
779125caa3ac
added xiph icon; smaller icons for streamdirs; fetch queue fix; up/down keys in tree view no longer focus the search entry
Calin Crisan ccrisan@gmail.com
parents:
2815
diff
changeset
|
598 data = g_queue_peek_head(update_thread_data_queue); |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
599 else |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
600 data = NULL; |
2817
779125caa3ac
added xiph icon; smaller icons for streamdirs; fetch queue fix; up/down keys in tree view no longer focus the search entry
Calin Crisan ccrisan@gmail.com
parents:
2815
diff
changeset
|
601 |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
602 g_mutex_unlock(update_thread_mutex); |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
603 } |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
604 |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
605 debug("leaving update thread core\n"); |
2788 | 606 |
607 return NULL; | |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
608 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
609 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
610 static void streaminfo_add_to_playlist(streaminfo_t *streaminfo) |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
611 { |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
612 if (strlen(streaminfo->playlist_url) > 0) { |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
613 debug("fetching stream playlist for station '%s' from '%s'\n", streaminfo->name, streaminfo->playlist_url); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
614 if (!fetch_remote_to_local_file(streaminfo->playlist_url, PLAYLIST_TEMP_FILE)) { |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
615 failure("shoutcast: stream playlist '%s' could not be downloaded to '%s'\n", streaminfo->playlist_url, PLAYLIST_TEMP_FILE); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
616 return; |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
617 } |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
618 debug("stream playlist '%s' successfuly downloaded to '%s'\n", streaminfo->playlist_url, PLAYLIST_TEMP_FILE); |
2788 | 619 |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
620 aud_playlist_add(aud_playlist_get_active(), PLAYLIST_TEMP_FILE); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
621 debug("stream playlist '%s' added\n", streaminfo->playlist_url); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
622 } |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
623 |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
624 if (strlen(streaminfo->url) > 0) { |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2817
diff
changeset
|
625 aud_playlist_add(aud_playlist_get_active(), streaminfo->url); |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
626 debug("stream '%s' added\n", streaminfo->url); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2811
diff
changeset
|
627 } |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
628 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
629 |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
630 static void on_plugin_services_menu_item_click() |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
631 { |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
632 debug("on_plugin_services_menu_item_click()\n"); |
2788 | 633 |
634 streambrowser_win_show(); | |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2891
diff
changeset
|
635 streamdir_update(NULL, NULL, NULL, FALSE); |
2735
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
636 } |
6d6a3eb67510
some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents:
2570
diff
changeset
|
637 |