annotate src/streambrowser/streambrowser.c @ 2808:895d43620019

shoutcast.xml - i don't know how this file got here
author Calin Crisan ccrisan@gmail.com
date Sat, 12 Jul 2008 13:27:54 +0300
parents 11fb1503ee4b
children b1e4929e0990
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
15 streamdir_t *streamdir;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
16 category_t *category;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
17 streaminfo_t *streaminfo;
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
18 } update_thread_data_t;
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
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
21 static void sb_init();
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
22 static void sb_about();
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
23 static void sb_configure();
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
24 static void sb_cleanup();
2570
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
25
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
26 static void gui_init();
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
27 static void gui_done();
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
28 static void config_load();
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
29 static void config_save();
2570
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
30
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
31 static void streamdir_update(streamdir_t *streamdir, category_t *category, streaminfo_t *streaminfo);
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
32 static gpointer update_thread_core(gpointer user_data);
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
33 static void streaminfo_add_to_playlist(streaminfo_t *streaminfo);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
34 static void on_plugin_services_menu_item_click();
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
35
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
36 static GtkWidget *playlist_menu_item;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
37 static GtkWidget *main_menu_item;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
38 static GQueue *update_thread_data_queue = NULL;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
39 static GMutex *update_thread_mutex = NULL;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
40 static gint update_thread_count = 0;
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
41
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
42 streambrowser_cfg_t streambrowser_cfg;
2570
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
43
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
44 static GeneralPlugin sb_plugin =
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
45 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
46 .description = "Stream Browser",
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
47 .init = sb_init,
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
48 .about = sb_about,
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
49 .configure = sb_configure,
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
50 .cleanup = sb_cleanup
2570
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
51 };
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
52
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
53 GeneralPlugin *sb_gplist[] =
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
54 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
55 &sb_plugin,
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
56 NULL
2570
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
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
59 SIMPLE_GENERAL_PLUGIN(streambrowser, sb_gplist);
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 void debug(const char *fmt, ...)
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
63 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
64 if (streambrowser_cfg.debug) {
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
65 va_list ap;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
66 fprintf(stderr, "* streambrowser: ");
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
67 va_start(ap, fmt);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
68 vfprintf(stderr, fmt, ap);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
69 va_end(ap);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
70 }
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
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
73 void failure(const char *fmt, ...)
2570
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
74 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
75 va_list ap;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
76 fprintf(stderr, "! streambrowser: ");
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
77 va_start(ap, fmt);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
78 vfprintf(stderr, fmt, ap);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
79 va_end(ap);
2570
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
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
82 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
83 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
84 VFSFile *remote_file = aud_vfs_fopen(remote_url, "r");
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
85 if (remote_file == NULL) {
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
86 failure("failed to fetch file '%s'\n", remote_url);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
87 return FALSE;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
88 }
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
89
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
90 VFSFile *local_file = aud_vfs_fopen(local_url, "w");
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
91 if (local_file == NULL) {
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
92 aud_vfs_fclose(remote_file);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
93
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
94 failure("failed to create local file '%s'\n", local_file);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
95 return FALSE;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
96 }
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
97
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
98 unsigned char buff[DEF_BUFFER_SIZE];
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
99 int size;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
100 while (!aud_vfs_feof(remote_file)) {
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
101 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
102
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
103 // i don't know why aud_vfs_feof() doesn't ever return TRUE
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
104 // so this is a workaround to properly end the loop
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
105 if (size == 0)
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
106 break;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
107
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
108 size = aud_vfs_fwrite(buff, 1, size, local_file);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
109 if (size == 0) {
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
110 aud_vfs_fclose(local_file);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
111 aud_vfs_fclose(remote_file);
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
112
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
113 failure("failed to write to local file '%s'\n", local_file);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
114 return FALSE;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
115 }
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
116 }
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
117
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
118 aud_vfs_fclose(local_file);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
119 aud_vfs_fclose(remote_file);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
120
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
121 return TRUE;
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
122 }
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
123
2570
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
124
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
125 static void sb_init()
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
126 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
127 /* workaround to print sb_init() */
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
128 streambrowser_cfg.debug = TRUE;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
129 debug("sb_init()\n");
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
130 streambrowser_cfg.debug = FALSE;
2570
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
131
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
132 config_load();
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
133 gui_init();
2570
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
134 }
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
135
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
136 static void sb_about()
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
137 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
138 debug("sb_about()\n");
2570
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
139 }
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 static void sb_configure()
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
142 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
143 debug("sb_configure()\n");
2570
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
144 }
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 static void sb_cleanup()
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
147 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
148 debug("sb_cleanup()\n");
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
149
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
150 gui_done();
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
151 config_save();
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
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
154 static void gui_init()
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
155 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
156 /* 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
157 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
158 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(playlist_menu_item), gtk_image_new_from_file(STREAMBROWSER_ICON_SMALL));
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
159 gtk_widget_show(playlist_menu_item);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
160 g_signal_connect(G_OBJECT(playlist_menu_item), "activate", G_CALLBACK(on_plugin_services_menu_item_click), NULL);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
161 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
162
2790
c156102069ae background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents: 2788
diff changeset
163 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
164 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(main_menu_item), gtk_image_new_from_file(STREAMBROWSER_ICON_SMALL));
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
165 gtk_widget_show(main_menu_item);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
166 g_signal_connect(G_OBJECT(main_menu_item), "activate", G_CALLBACK(on_plugin_services_menu_item_click), NULL);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
167 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
168
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
169 /* main streambrowser window */
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
170 streambrowser_win_init();
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
171 streambrowser_win_set_update_function(streamdir_update);
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
172
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
173 /* others */
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
174 update_thread_mutex = g_mutex_new();
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
175 update_thread_data_queue = g_queue_new();
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
176
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
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 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
182 /* the plugin services menu */
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
183 audacious_menu_plugin_item_remove(AUDACIOUS_MENU_PLAYLIST_RCLICK, playlist_menu_item);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
184 audacious_menu_plugin_item_remove(AUDACIOUS_MENU_MAIN, main_menu_item);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
185
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
186 /* main streambrowser window */
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
187 streambrowser_win_hide();
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
188 streambrowser_win_done();
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
189
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
190 /* others */
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
191 if (update_thread_mutex)
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
192 g_mutex_free(update_thread_mutex);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
193 update_thread_mutex = NULL;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
194 if (update_thread_data_queue)
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
195 g_queue_free(update_thread_data_queue);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
196 update_thread_data_queue = NULL;
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
197
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
198 debug("gui destroyed\n");
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
199 }
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
200
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
201 static void config_load()
2570
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
202 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
203 streambrowser_cfg.debug = FALSE;
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
204
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
205 mcs_handle_t *db;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
206 if ((db = aud_cfg_db_open()) == NULL) {
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
207 failure("failed to load configuration\n");
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
208 return;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
209 }
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
210
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
211 aud_cfg_db_get_bool(db, "streambrowser", "debug", &streambrowser_cfg.debug);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
212
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
213 aud_cfg_db_close(db);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
214
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
215 debug("configuration loaded\n");
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
216 debug("debug = %d\n", streambrowser_cfg.debug);
2735
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 static void config_save()
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
220 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
221 mcs_handle_t *db;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
222 if ((db = aud_cfg_db_open()) == NULL) {
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
223 failure("failed to save configuration\n");
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
224 return;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
225 }
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
226
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
227 aud_cfg_db_set_bool(db, "streambrowser", "debug", streambrowser_cfg.debug);
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
228
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
229 aud_cfg_db_close(db);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
230
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
231 debug("configuration saved\n");
2570
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
232 }
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
233
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
234 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
235 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
236 debug("requested streamdir update (streamdir = '%s', category = '%s', streaminfo = '%s')\n",
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
237 streamdir == NULL ? "" : streamdir->name,
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
238 category == NULL ? "" : category->name,
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
239 streaminfo == NULL ? "" : streaminfo->name);
2570
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
240
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
241 if (update_thread_count >= MAX_UPDATE_THREADS) {
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
242 debug("another %d streamdir updates are pending, this request will be dropped\n", update_thread_count);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
243 }
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
244 else {
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
245 g_mutex_lock(update_thread_mutex);
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
246
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
247 /* do we have a running thread? */
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
248 if (update_thread_count > 0) {
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
249 int i;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
250 gboolean exists = FALSE;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
251 update_thread_data_t *update_thread_data;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
252
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
253 /* search for another identic update request */
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
254 for (i = 0; i < g_queue_get_length(update_thread_data_queue); i++) {
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
255 update_thread_data = g_queue_peek_nth(update_thread_data_queue, i);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
256 if (update_thread_data->streamdir == streamdir &&
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
257 update_thread_data->category == category &&
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
258 update_thread_data->streaminfo == streaminfo) {
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
259 exists = TRUE;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
260 break;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
261 }
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
262 }
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
263
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
264 /* if no other similar request exists, we enqueue it */
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
265 if (!exists) {
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
266 debug("another %d streamdir updates are pending, this request will be queued\n", update_thread_count);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
267
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
268 update_thread_data = g_malloc(sizeof(update_thread_data_t));
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
269
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
270 update_thread_data->streamdir = streamdir;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
271 update_thread_data->category = category;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
272 update_thread_data->streaminfo = streaminfo;
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
273
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
274 g_queue_push_tail(update_thread_data_queue, update_thread_data);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
275 update_thread_count++;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
276 }
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
277 else {
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
278 debug("this request is already present in the queue, dropping\n");
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
279 }
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
280 }
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
281 /* no thread is currently running, we start one */
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
282 else {
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
283 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
284
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
285 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
286
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
287 data->streamdir = streamdir;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
288 data->category = category;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
289 data->streaminfo = streaminfo;
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
290
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
291 g_queue_push_tail(update_thread_data_queue, data);
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
292 update_thread_count++;
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
293
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
294 g_thread_create((GThreadFunc) update_thread_core, NULL, FALSE, NULL);
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
295 }
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
296
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
297 g_mutex_unlock(update_thread_mutex);
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
298 }
2570
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
299 }
28498c0bde64 Initial commit for the streambrowser plugin
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
300
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
301 static gpointer update_thread_core(gpointer user_data)
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
302 {
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
303 debug("entering update thread core\n");
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
304
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
305 /* try to get the last item in the queue */
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
306 g_mutex_lock(update_thread_mutex);
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
307 update_thread_data_t *data = NULL;
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
308 if (update_thread_count > 0) {
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
309 data = g_queue_pop_head(update_thread_data_queue);
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
310 }
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
311 g_mutex_unlock(update_thread_mutex);
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
312
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
313 /* repetitively process the queue elements, until queue is empty */
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
314 while (data != NULL && update_thread_count > 0) {
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
315 /* update a streaminfo - that is - add this streaminfo to playlist */
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
316 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
317 gdk_threads_enter();
11fb1503ee4b double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents: 2795
diff changeset
318 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
319 gdk_threads_leave();
11fb1503ee4b double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents: 2795
diff changeset
320
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
321 streaminfo_add_to_playlist(data->streaminfo);
2797
11fb1503ee4b double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents: 2795
diff changeset
322
11fb1503ee4b double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents: 2795
diff changeset
323 gdk_threads_enter();
11fb1503ee4b double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents: 2795
diff changeset
324 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
325 gdk_threads_leave();
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
326 }
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
327 /* update a category */
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
328 else if (data->category != NULL) {
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
329 /* shoutcast */
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
330 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
331 gdk_threads_enter();
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
332 streambrowser_win_set_category_state(data->streamdir, data->category, TRUE);
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
333 gdk_threads_leave();
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
334
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
335 shoutcast_category_fetch(data->category);
2757
4ec0e13208de added shoutcast icon; fixed some small bugs
Calin Crisan ccrisan@gmail.com
parents: 2735
diff changeset
336
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
337 gdk_threads_enter();
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
338 streambrowser_win_set_category(data->streamdir, data->category);
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
339 streambrowser_win_set_category_state(data->streamdir, data->category, FALSE);
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
340 gdk_threads_leave();
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
341 }
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
342 }
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
343 /* update a streamdir */
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
344 else if (data->streamdir != NULL) {
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
345 /* shoutcast */
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
346 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
347 streamdir_t *streamdir = shoutcast_streamdir_fetch();
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
348 if (streamdir != NULL) {
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
349 gdk_threads_enter();
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
350 streambrowser_win_set_streamdir(streamdir, SHOUTCAST_ICON);
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
351 gdk_threads_leave();
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
352 }
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
353 }
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
354 }
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
355 /* update all streamdirs */
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
356 else {
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
357 /* shoutcast */
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
358 streamdir_t *shoutcast_streamdir = shoutcast_streamdir_fetch();
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
359 if (shoutcast_streamdir != NULL) {
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
360 gdk_threads_enter();
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
361 streambrowser_win_set_streamdir(shoutcast_streamdir, SHOUTCAST_ICON);
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
362 gdk_threads_leave();
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
363 }
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
364 }
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
365
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
366 g_free(data);
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
367
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
368 g_mutex_lock(update_thread_mutex);
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
369 update_thread_count--;
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
370
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
371 /* try to get the last item in the queue */
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
372 if (update_thread_count > 0)
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
373 data = g_queue_pop_head(update_thread_data_queue);
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
374 else
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
375 data = NULL;
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
376 g_mutex_unlock(update_thread_mutex);
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
377 }
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
378
2795
4c9db0b2194f added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents: 2791
diff changeset
379 debug("leaving update thread core\n");
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
380
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
381 return NULL;
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
382 }
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
383
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
384 static void streaminfo_add_to_playlist(streaminfo_t *streaminfo)
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
385 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
386 debug("fetching stream playlist for station '%s' from '%s'\n", streaminfo->name, streaminfo->playlist_url);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
387 if (!fetch_remote_to_local_file(streaminfo->playlist_url, PLAYLIST_TEMP_FILE)) {
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
388 failure("shoutcast: stream playlist '%s' could not be downloaded to '%s'\n", streaminfo->playlist_url, PLAYLIST_TEMP_FILE);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
389 return;
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
390 }
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
391 debug("stream playlist '%s' successfuly downloaded to '%s'\n", streaminfo->playlist_url, PLAYLIST_TEMP_FILE);
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
392
2808
895d43620019 shoutcast.xml - i don't know how this file got here
Calin Crisan ccrisan@gmail.com
parents: 2797
diff changeset
393 aud_playlist_add_url(aud_playlist_get_active(), PLAYLIST_TEMP_FILE);
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
394 }
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
395
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
396 static void on_plugin_services_menu_item_click()
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
397 {
2788
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
398 debug("on_plugin_services_menu_item_click()\n");
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
399
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
400 streambrowser_win_show();
3a615c9d2bb1 reindent
mf0102 <0102@gmx.at>
parents: 2787
diff changeset
401 streamdir_update(NULL, NULL, NULL);
2735
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
402 }
6d6a3eb67510 some work on the streambrowser
Calin Crisan ccrisan@gmail.com
parents: 2570
diff changeset
403