summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-11-21 11:37:19 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-11-21 11:37:19 +0100
commit08f95e176cb79eeba3f98735265f6dcf31765d49 (patch)
treeee5d23a790b70bf833bc14ec684c43ffa13fafbe
parent6a7522ed0d4b3355536432cadbda155455de0a06 (diff)
parent46742cfc009d004e71e9ef211a78e14ae23986e2 (diff)
Merge branch 'master' into guiplug
-rw-r--r--playlist.c2
-rw-r--r--plugins.c163
-rw-r--r--plugins/gtkui/callbacks.c1
-rw-r--r--plugins/vfs_curl/vfs_curl.c13
4 files changed, 109 insertions, 70 deletions
diff --git a/playlist.c b/playlist.c
index ed4293da..9d049dbe 100644
--- a/playlist.c
+++ b/playlist.c
@@ -442,7 +442,7 @@ pl_insert_pls (playItem_t *after, const char *fname, int *pabort, int (*cb)(play
}
if (sz < 30) {
vfs_fclose (fp);
- trace ("file %s is too small to be a playlist\n", fname);
+ trace ("file %s is too small to be a playlist (%d)\n", fname, sz);
return NULL;
}
vfs_rewind (fp);
diff --git a/plugins.c b/plugins.c
index 288b3d38..0d94713d 100644
--- a/plugins.c
+++ b/plugins.c
@@ -428,82 +428,117 @@ plug_load_all (void) {
mutex = mutex_create ();
const char *dirname = LIBDIR "/deadbeef";
struct dirent **namelist = NULL;
- int n = scandir (dirname, &namelist, NULL, alphasort);
- if (n < 0)
- {
- if (namelist) {
- free (namelist);
+
+ char *xdg_local_home = getenv ("XDG_LOCAL_HOME");
+ char xdg_plugin_dir[1024];
+
+ if (xdg_local_home) {
+ strcpy (xdg_plugin_dir, xdg_local_home);
+ } else {
+ char *homedir = getenv ("HOME");
+
+ if (!homedir) {
+ fprintf (stderr, "plug_load_all: warning: unable to find home directory\n");
+ xdg_plugin_dir[0] = 0;
+ }
+ else {
+ int written = snprintf (xdg_plugin_dir, sizeof (xdg_plugin_dir), "%s/.local/lib/deadbeef", homedir);
+ if (written > sizeof (xdg_plugin_dir)) {
+ fprintf (stderr, "warning: XDG_LOCAL_HOME value is too long: %s. Ignoring.", xdg_local_home);
+ xdg_plugin_dir[0] = 0;
+ }
}
- return; // not a dir or no read access
}
- else
- {
- int i;
- for (i = 0; i < n; i++)
+
+ const char *plugins_dirs[] = { dirname, xdg_plugin_dir, NULL };
+
+ int k = 0, n;
+
+ while (plugins_dirs[k]) {
+ const char *plugdir = plugins_dirs[k++];
+ if (!(*plugdir)) {
+ continue;
+ }
+ fprintf (stderr, "loading plugins from %s\n", plugdir);
+ namelist = NULL;
+ n = scandir (plugdir, &namelist, NULL, alphasort);
+ if (n < 0)
+ {
+ if (namelist) {
+ free (namelist);
+ }
+ return; // not a dir or no read access
+ }
+ else
{
- // no hidden files
- if (namelist[i]->d_name[0] != '.')
+ int i;
+ for (i = 0; i < n; i++)
{
- int l = strlen (namelist[i]->d_name);
- if (l < 3) {
- continue;
- }
- if (strcasecmp (&namelist[i]->d_name[l-3], ".so")) {
- continue;
- }
- char d_name[256];
- memcpy (d_name, namelist[i]->d_name, l+1);
- // no blacklisted
- const uint8_t *p = conf_blacklist_plugins;
- while (*p) {
- const uint8_t *e = p;
- while (*e && *e > 0x20) {
- e++;
+ // no hidden files
+ while (namelist[i]->d_name[0] != '.')
+ {
+ int l = strlen (namelist[i]->d_name);
+ if (l < 3) {
+ break;
}
- if (l-3 == e-p) {
- if (!strncmp (p, d_name, e-p)) {
- p = NULL;
- break;
+ if (strcasecmp (&namelist[i]->d_name[l-3], ".so")) {
+ break;
+ }
+ char d_name[256];
+ memcpy (d_name, namelist[i]->d_name, l+1);
+ // no blacklisted
+ const uint8_t *p = conf_blacklist_plugins;
+ while (*p) {
+ const uint8_t *e = p;
+ while (*e && *e > 0x20) {
+ e++;
+ }
+ if (l-3 == e-p) {
+ if (!strncmp (p, d_name, e-p)) {
+ p = NULL;
+ break;
+ }
+ }
+ p = e;
+ while (*p && *p <= 0x20) {
+ p++;
}
}
- p = e;
- while (*p && *p <= 0x20) {
- p++;
+ if (!p) {
+ fprintf (stderr, "plugin %s is blacklisted in config file\n", d_name);
+ break;
+ }
+ char fullname[1024];
+ strcpy (fullname, plugdir);
+ strncat (fullname, "/", 1024);
+ strncat (fullname, d_name, 1024);
+ printf ("loading plugin %s\n", d_name);
+ void *handle = dlopen (fullname, RTLD_NOW);
+ if (!handle) {
+ fprintf (stderr, "dlopen error: %s\n", dlerror ());
+ break;
}
- }
- if (!p) {
- fprintf (stderr, "plugin %s is blacklisted in config file\n", d_name);
- continue;
- }
- char fullname[1024];
- strcpy (fullname, dirname);
- strncat (fullname, "/", 1024);
- strncat (fullname, d_name, 1024);
- printf ("loading plugin %s\n", d_name);
- void *handle = dlopen (fullname, RTLD_NOW);
- if (!handle) {
- fprintf (stderr, "dlopen error: %s\n", dlerror ());
- continue;
- }
- d_name[l-3] = 0;
- printf ("module name is %s\n", d_name);
- strcat (d_name, "_load");
- DB_plugin_t *(*plug_load)(DB_functions_t *api) = dlsym (handle, d_name);
- if (!plug_load) {
- fprintf (stderr, "dlsym error: %s\n", dlerror ());
- dlclose (handle);
- continue;
- }
- if (plug_init_plugin (plug_load, handle) < 0) {
d_name[l-3] = 0;
- fprintf (stderr, "plugin %s is incompatible with current version of deadbeef, please upgrade the plugin\n", d_name);
- dlclose (handle);
- continue;
+ printf ("module name is %s\n", d_name);
+ strcat (d_name, "_load");
+ DB_plugin_t *(*plug_load)(DB_functions_t *api) = dlsym (handle, d_name);
+ if (!plug_load) {
+ fprintf (stderr, "dlsym error: %s\n", dlerror ());
+ dlclose (handle);
+ break;
+ }
+ if (plug_init_plugin (plug_load, handle) < 0) {
+ d_name[l-3] = 0;
+ fprintf (stderr, "plugin %s is incompatible with current version of deadbeef, please upgrade the plugin\n", d_name);
+ dlclose (handle);
+ break;
+ }
+ break;
}
+ free (namelist[i]);
}
- free (namelist[i]);
+ free (namelist);
}
- free (namelist);
}
// load all compiled-in modules
#define PLUG(n) extern DB_plugin_t * n##_load (DB_functions_t *api);
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c
index c7b8a18f..03ca7dc7 100644
--- a/plugins/gtkui/callbacks.c
+++ b/plugins/gtkui/callbacks.c
@@ -902,6 +902,7 @@ seekbar_draw (GtkWidget *widget) {
clearlooks_rounded_rectangle (cr, 2, widget->allocation.height/2-4, widget->allocation.width-4, 8, 4, 0xff);
theme_set_cairo_source_rgb (cr, COLO_SEEKBAR_FRONT);
cairo_stroke (cr);
+ cairo_destroy (cr);
return;
}
float pos = 0;
diff --git a/plugins/vfs_curl/vfs_curl.c b/plugins/vfs_curl/vfs_curl.c
index 42211fe3..034220e2 100644
--- a/plugins/vfs_curl/vfs_curl.c
+++ b/plugins/vfs_curl/vfs_curl.c
@@ -119,6 +119,12 @@ http_curl_write (void *ptr, size_t size, size_t nmemb, void *stream) {
fp->gotheader = 1;
}
}
+
+ deadbeef->mutex_lock (fp->mutex);
+ if (fp->status == STATUS_INITIAL && fp->gotheader) {
+ fp->status = STATUS_READING;
+ }
+ deadbeef->mutex_unlock (fp->mutex);
while (avail > 0) {
deadbeef->mutex_lock (fp->mutex);
if (fp->status == STATUS_SEEK) {
@@ -290,7 +296,7 @@ http_curl_write_abort (void *ptr, size_t size, size_t nmemb, void *stream) {
static int
http_curl_control (void *stream, double dltotal, double dlnow, double ultotal, double ulnow) {
- trace ("http_curl_control\n");
+// trace ("http_curl_control\n");
assert (stream);
HTTP_FILE *fp = (HTTP_FILE *)stream;
if (fp->status == STATUS_ABORTED) {
@@ -328,7 +334,7 @@ http_thread_func (uintptr_t ctx) {
}
#endif
#endif
- fp->status = STATUS_STARTING;
+// fp->status = STATUS_STARTING;
trace ("vfs_curl: started loading data\n");
for (;;) {
@@ -382,9 +388,6 @@ http_thread_func (uintptr_t ctx) {
#endif
curl_easy_setopt (curl, CURLOPT_PROXYTYPE, curlproxytype);
}
- deadbeef->mutex_lock (fp->mutex);
- fp->status = STATUS_READING;
- deadbeef->mutex_unlock (fp->mutex);
status = curl_easy_perform (curl);
trace ("vfs_curl: curl_easy_perform status=%d\n", status);
if (status != 0) {