From: barbieri Date: Thu, 1 Sep 2011 23:45:18 +0000 (+0000) Subject: emotion: use eina_prefix to determine player location. X-Git-Tag: 2.0_alpha~128 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=974697054af53b51372049daf8863a3b24dc66ac;p=framework%2Fuifw%2Femotion.git emotion: use eina_prefix to determine player location. Move players from $bindir to $libdir/emotion/utils and find them with eina_prefix. I was willing to play with this prefix thing, quite nice ;-) git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/emotion@63077 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/generic_players/vlc/Makefile.am b/src/generic_players/vlc/Makefile.am index 4089b11..c32906e 100644 --- a/src/generic_players/vlc/Makefile.am +++ b/src/generic_players/vlc/Makefile.am @@ -10,9 +10,8 @@ AM_CPPFLAGS = \ -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ @VLC_CFLAGS@ -pkgdir = $(libdir)/emotion/generic_players/$(MODULE_ARCH) - -bin_PROGRAMS = em_generic_vlc +internal_bindir = $(libdir)/emotion/utils +internal_bin_PROGRAMS = em_generic_vlc em_generic_vlc_SOURCES = emotion_generic_vlc.c em_generic_vlc_DEPENDENCIES = $(top_srcdir)/src/modules/generic/Emotion_Generic_Plugin.h diff --git a/src/modules/generic/emotion_generic.c b/src/modules/generic/emotion_generic.c index ef6b9eb..56f0c4f 100644 --- a/src/modules/generic/emotion_generic.c +++ b/src/modules/generic/emotion_generic.c @@ -14,6 +14,8 @@ #include "emotion_private.h" #include "emotion_generic.h" +static Eina_Prefix *pfx = NULL; + struct _default_players { const char *name; const char *cmdline; @@ -29,18 +31,60 @@ static struct _default_players players[] = { static const char * _get_player(const char *name) { + const char *selected_name = NULL; + const char *libdir = eina_prefix_lib_get(pfx); + static char buf[PATH_MAX]; int i; - if (!name) - return players[0].cmdline; + if (name) + { + for (i = 0; players[i].name; i++) + { + if (!strcmp(players[i].name, name)) + { + selected_name = players[i].cmdline; + break; + } + } + } + + if ((!selected_name) && (name)) + selected_name = name; + + if (selected_name) + { + const char *cmd; + + if (selected_name[0] == '/') cmd = selected_name; + else + { + snprintf(buf, sizeof(buf), "%s/emotion/utils/%s", + libdir, selected_name); + cmd = buf; + } + + DBG("Try generic player '%s'", cmd); + if (access(cmd, R_OK | X_OK) == 0) + { + INF("Using generic player '%s'", cmd); + return cmd; + } + } for (i = 0; players[i].name; i++) { - if (!strcmp(players[i].name, name)) - return players[i].cmdline; + snprintf(buf, sizeof(buf), "%s/emotion/utils/%s", + libdir, players[i].cmdline); + DBG("Try generic player '%s'", buf); + if (access(buf, R_OK | X_OK) == 0) + { + INF("Using fallback player '%s'", buf); + return buf; + } } - return name; + ERR("no generic player found, given name='%s'", name ? name : ""); + return NULL; } static void @@ -500,8 +544,11 @@ static unsigned char em_init(Evas_Object *obj, void **emotion_video, Emotion_Module_Options *opt) { Emotion_Generic_Video *ev; + const char *player; if (!emotion_video) return 0; + player = _get_player(opt ? opt->player : NULL); + if (!player) return 0; ev = (Emotion_Generic_Video *)calloc(1, sizeof(*ev)); if (!ev) return 0; @@ -511,7 +558,7 @@ em_init(Evas_Object *obj, void **emotion_video, Emotion_Module_Options *opt) ev->audio_mute = EINA_FALSE; ev->obj = obj; - ev->cmdline = eina_stringshare_add(_get_player(opt->player)); + ev->cmdline = eina_stringshare_add(player); *emotion_video = ev; return _fork_and_exec(obj, ev); @@ -1105,12 +1152,27 @@ static void module_close(Emotion_Video_Module *module, void *video) Eina_Bool generic_module_init(void) { + if (!pfx) + { + pfx = eina_prefix_new(NULL, emotion_object_add, + "EMOTION", "emotion", "AUTHORS", + PACKAGE_BIN_DIR, + PACKAGE_LIB_DIR, + PACKAGE_DATA_DIR, + ""); + if (!pfx) return EINA_FALSE; + } return _emotion_module_register("generic", module_open, module_close); } void generic_module_shutdown(void) { + if (pfx) + { + eina_prefix_free(pfx); + pfx = NULL; + } _emotion_module_unregister("generic"); }