Now plugins are loaded using eina_module.
SVN revision: 40387
This commit is contained in:
parent
ff0d4f71e2
commit
af073a4524
|
@ -55,12 +55,6 @@
|
||||||
#define WRN(...) EINA_ERROR_PWARN(__VA_ARGS__)
|
#define WRN(...) EINA_ERROR_PWARN(__VA_ARGS__)
|
||||||
#define ERR(...) EINA_ERROR_PERR(__VA_ARGS__)
|
#define ERR(...) EINA_ERROR_PERR(__VA_ARGS__)
|
||||||
|
|
||||||
struct _Ethumb_Plugin_Object
|
|
||||||
{
|
|
||||||
Ethumb_Plugin *plugin;
|
|
||||||
void *dl_handle;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int initcount = 0;
|
static int initcount = 0;
|
||||||
static const char *_home_thumb_dir = NULL;
|
static const char *_home_thumb_dir = NULL;
|
||||||
static const char *_thumb_category_normal = NULL;
|
static const char *_thumb_category_normal = NULL;
|
||||||
|
@ -70,92 +64,60 @@ static const int THUMB_SIZE_NORMAL = 128;
|
||||||
static const int THUMB_SIZE_LARGE = 256;
|
static const int THUMB_SIZE_LARGE = 256;
|
||||||
|
|
||||||
static Eina_Hash *_plugins_ext = NULL;
|
static Eina_Hash *_plugins_ext = NULL;
|
||||||
static Eina_List *_plugins = NULL;
|
static Eina_Array *_plugins = NULL;
|
||||||
|
|
||||||
static struct _Ethumb_Plugin_Object *
|
static Eina_Bool
|
||||||
_ethumb_plugin_load(const char *path)
|
_ethumb_plugin_list_cb(Eina_Module *m, void *data)
|
||||||
{
|
{
|
||||||
char *errmsg;
|
const char *file;
|
||||||
struct _Ethumb_Plugin_Object *p;
|
const char **ext;
|
||||||
Ethumb_Plugin *(*init)(void);
|
Ethumb_Plugin *plugin;
|
||||||
|
Ethumb_Plugin *(*plugin_get)(void);
|
||||||
|
|
||||||
p = calloc(1, sizeof(struct _Ethumb_Plugin_Object));
|
if (!eina_module_load(m))
|
||||||
|
return EINA_FALSE;
|
||||||
|
|
||||||
p->dl_handle = dlopen(path, RTLD_NOW | RTLD_LOCAL);
|
plugin_get = eina_module_symbol_get(m, "ethumb_plugin_get");
|
||||||
errmsg = dlerror();
|
if (!plugin_get)
|
||||||
if (errmsg)
|
|
||||||
{
|
{
|
||||||
ERR("could not dlopen() %s\n", errmsg);
|
eina_module_unload(m);
|
||||||
return NULL;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
init = dlsym(p->dl_handle, "ethumb_plugin_init");
|
file = eina_module_file_get(m);
|
||||||
errmsg = dlerror();
|
|
||||||
if (errmsg)
|
plugin = plugin_get();
|
||||||
|
if (!plugin)
|
||||||
{
|
{
|
||||||
ERR("could not find plugin entry point %s\n", errmsg);
|
ERR("plugin \"%s\" failed to init.\n", file);
|
||||||
return NULL;
|
eina_module_unload(m);
|
||||||
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
p->plugin = init();
|
for (ext = plugin->extensions; *ext; ext++)
|
||||||
if (!p->plugin)
|
eina_hash_add(_plugins_ext, *ext, plugin);
|
||||||
{
|
|
||||||
ERR("plugin \"%s\" failed to init.\n", path);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ethumb_plugins_load(void)
|
_ethumb_plugins_load(void)
|
||||||
{
|
{
|
||||||
DIR *dir;
|
|
||||||
struct dirent *de;
|
|
||||||
char plugin_path[PATH_MAX];
|
|
||||||
struct _Ethumb_Plugin_Object *p;
|
|
||||||
|
|
||||||
_plugins_ext = eina_hash_string_small_new(NULL);
|
_plugins_ext = eina_hash_string_small_new(NULL);
|
||||||
EINA_SAFETY_ON_NULL_RETURN(_plugins_ext);
|
EINA_SAFETY_ON_NULL_RETURN(_plugins_ext);
|
||||||
|
|
||||||
dir = opendir(PLUGINSDIR);
|
_plugins = eina_module_list_get(_plugins, PLUGINSDIR, 1,
|
||||||
EINA_SAFETY_ON_NULL_RETURN(dir);
|
&_ethumb_plugin_list_cb, NULL);
|
||||||
|
|
||||||
while ((de = readdir(dir)))
|
|
||||||
{
|
|
||||||
const char **ext;
|
|
||||||
if (strncmp(de->d_name + strlen(de->d_name) - 3, ".so", 3))
|
|
||||||
continue;
|
|
||||||
snprintf(plugin_path, 1024, "%s/%s", PLUGINSDIR, de->d_name);
|
|
||||||
p = _ethumb_plugin_load(plugin_path);
|
|
||||||
if (!p)
|
|
||||||
{
|
|
||||||
ERR("couldn't load plugin '%s'\n", plugin_path);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (ext = p->plugin->extensions; *ext; ext++)
|
|
||||||
eina_hash_add(_plugins_ext, *ext, p->plugin);
|
|
||||||
|
|
||||||
_plugins = eina_list_append(_plugins, p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ethumb_plugins_unload(void)
|
_ethumb_plugins_unload(void)
|
||||||
{
|
{
|
||||||
Eina_List *l;
|
|
||||||
|
|
||||||
eina_hash_free(_plugins_ext);
|
eina_hash_free(_plugins_ext);
|
||||||
_plugins_ext = NULL;
|
_plugins_ext = NULL;
|
||||||
|
eina_module_list_unload(_plugins);
|
||||||
l = _plugins;
|
eina_module_list_delete(_plugins);
|
||||||
for (l = _plugins; l; l = l->next)
|
_plugins = NULL;
|
||||||
{
|
|
||||||
struct _Ethumb_Plugin_Object *p = l->data;
|
|
||||||
p->plugin->shutdown(p->plugin);
|
|
||||||
dlclose(p->dl_handle);
|
|
||||||
free(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
|
@ -170,6 +132,7 @@ ethumb_init(void)
|
||||||
eina_stringshare_init();
|
eina_stringshare_init();
|
||||||
eina_list_init();
|
eina_list_init();
|
||||||
eina_hash_init();
|
eina_hash_init();
|
||||||
|
eina_module_init();
|
||||||
evas_init();
|
evas_init();
|
||||||
ecore_init();
|
ecore_init();
|
||||||
ecore_evas_init();
|
ecore_evas_init();
|
||||||
|
@ -199,6 +162,7 @@ ethumb_shutdown(void)
|
||||||
eina_stringshare_shutdown();
|
eina_stringshare_shutdown();
|
||||||
eina_list_shutdown();
|
eina_list_shutdown();
|
||||||
eina_hash_shutdown();
|
eina_hash_shutdown();
|
||||||
|
eina_module_shutdown();
|
||||||
evas_shutdown();
|
evas_shutdown();
|
||||||
ecore_shutdown();
|
ecore_shutdown();
|
||||||
ecore_evas_shutdown();
|
ecore_evas_shutdown();
|
||||||
|
|
|
@ -11,7 +11,6 @@ struct _Ethumb_Plugin
|
||||||
{
|
{
|
||||||
const char **extensions;
|
const char **extensions;
|
||||||
int (*generate_thumb)(Ethumb *);
|
int (*generate_thumb)(Ethumb *);
|
||||||
void (*shutdown)(Ethumb_Plugin *);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void ethumb_calculate_aspect(Ethumb *e, int iw, int ih, int *w, int *h);
|
void ethumb_calculate_aspect(Ethumb *e, int iw, int ih, int *w, int *h);
|
||||||
|
|
|
@ -5,16 +5,12 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <Eina.h>
|
||||||
#include <Evas.h>
|
#include <Evas.h>
|
||||||
#include <Emotion.h>
|
#include <Emotion.h>
|
||||||
|
|
||||||
static Evas_Object *_emotion = NULL;
|
static Evas_Object *_emotion = NULL;
|
||||||
|
|
||||||
static void
|
|
||||||
_shutdown(Ethumb_Plugin *plugin)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_frame_resized_cb(void *data, Evas_Object *o, void *event_info)
|
_frame_resized_cb(void *data, Evas_Object *o, void *event_info)
|
||||||
{
|
{
|
||||||
|
@ -66,16 +62,29 @@ _generate_thumb(Ethumb *e)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ethumb_Plugin *
|
EAPI Ethumb_Plugin *
|
||||||
ethumb_plugin_init(void)
|
ethumb_plugin_get(void)
|
||||||
{
|
{
|
||||||
static const char *extensions[] = { "avi", NULL };
|
static const char *extensions[] = { "avi", NULL };
|
||||||
static Ethumb_Plugin plugin =
|
static Ethumb_Plugin plugin =
|
||||||
{
|
{
|
||||||
extensions,
|
extensions,
|
||||||
_generate_thumb,
|
_generate_thumb,
|
||||||
_shutdown
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return &plugin;
|
return &plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Eina_Bool
|
||||||
|
_module_init(void)
|
||||||
|
{
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_module_shutdown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
EINA_MODULE_INIT(_module_init);
|
||||||
|
EINA_MODULE_SHUTDOWN(_module_shutdown);
|
||||||
|
|
|
@ -5,15 +5,10 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <Eina.h>
|
||||||
#include <Evas.h>
|
#include <Evas.h>
|
||||||
#include <Epdf.h>
|
#include <Epdf.h>
|
||||||
|
|
||||||
static void
|
|
||||||
_shutdown(Ethumb_Plugin *plugin)
|
|
||||||
{
|
|
||||||
epdf_shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_generate_thumb(Ethumb *e)
|
_generate_thumb(Ethumb *e)
|
||||||
{
|
{
|
||||||
|
@ -67,17 +62,31 @@ _generate_thumb(Ethumb *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
Ethumb_Plugin *
|
Ethumb_Plugin *
|
||||||
ethumb_plugin_init(void)
|
ethumb_plugin_get(void)
|
||||||
{
|
{
|
||||||
static const char *extensions[] = { "pdf", NULL };
|
static const char *extensions[] = { "pdf", NULL };
|
||||||
static Ethumb_Plugin plugin =
|
static Ethumb_Plugin plugin =
|
||||||
{
|
{
|
||||||
extensions,
|
extensions,
|
||||||
_generate_thumb,
|
_generate_thumb,
|
||||||
_shutdown
|
|
||||||
};
|
};
|
||||||
|
|
||||||
epdf_init();
|
|
||||||
|
|
||||||
return &plugin;
|
return &plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Eina_Bool
|
||||||
|
_module_init(void)
|
||||||
|
{
|
||||||
|
epdf_init();
|
||||||
|
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_module_shutdown(void)
|
||||||
|
{
|
||||||
|
epdf_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
EINA_MODULE_INIT(_module_init);
|
||||||
|
EINA_MODULE_SHUTDOWN(_module_shutdown);
|
||||||
|
|
Loading…
Reference in New Issue