summaryrefslogtreecommitdiff
path: root/src/lib/emotion/emotion_modules.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-10 22:11:07 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-10 22:11:07 +0000
commit8a4248732aa6896122db2bd18c6c0698c7802241 (patch)
treedc35c3cf0634b84e4ee45f06c308d98ed6c5a844 /src/lib/emotion/emotion_modules.c
parentd1341cc826481f6c17ce82bf251e9a2a1b75ea8b (diff)
efl/emotion: move module stuff.
* do not abuse emotion_private.h by using that in modules * split emotion_module.c to allow more changes later. SVN revision: 82592
Diffstat (limited to 'src/lib/emotion/emotion_modules.c')
-rw-r--r--src/lib/emotion/emotion_modules.c126
1 files changed, 126 insertions, 0 deletions
diff --git a/src/lib/emotion/emotion_modules.c b/src/lib/emotion/emotion_modules.c
new file mode 100644
index 0000000000..bf5b787d82
--- /dev/null
+++ b/src/lib/emotion/emotion_modules.c
@@ -0,0 +1,126 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include "emotion_private.h"
6
7#ifdef EMOTION_STATIC_BUILD_XINE
8Eina_Bool xine_module_init(void);
9void xine_module_shutdown(void);
10#endif
11#ifdef EMOTION_STATIC_BUILD_GSTREAMER
12Eina_Bool gstreamer_module_init(void);
13void gstreamer_module_shutdown(void);
14#endif
15#ifdef EMOTION_STATIC_BUILD_GENERIC
16Eina_Bool generic_module_init(void);
17void generic_module_shutdown(void);
18#endif
19
20Eina_Hash *_emotion_backends = NULL;
21Eina_Array *_emotion_modules = NULL;
22
23static void
24_emotion_modules_load(void)
25{
26 char buf[PATH_MAX];
27 char *path;
28
29 if (getenv("EFL_RUN_IN_TREE"))
30 {
31 struct stat st;
32 snprintf(buf, sizeof(buf), "%s/src/modules/emotion",
33 PACKAGE_BUILD_DIR);
34 if (stat(buf, &st) == 0)
35 {
36 const char *built_modules[] = {
37#ifdef EMOTION_BUILD_GSTREAMER
38 "gstreamer",
39#endif
40#ifdef EMOTION_BUILD_XINE
41 "xine",
42#endif
43 NULL
44 };
45 const char **itr;
46 for (itr = built_modules; *itr != NULL; itr++)
47 {
48 snprintf(buf, sizeof(buf),
49 "%s/src/modules/emotion/%s/.libs",
50 PACKAGE_BUILD_DIR, *itr);
51 _emotion_modules = eina_module_list_get(_emotion_modules, buf,
52 EINA_FALSE, NULL, NULL);
53 }
54
55 return;
56 }
57 }
58
59 path = eina_module_environment_path_get("EMOTION_MODULES_DIR",
60 "/emotion/modules");
61 if (path)
62 {
63 _emotion_modules = eina_module_arch_list_get(_emotion_modules, path, MODULE_ARCH);
64 free(path);
65 }
66
67 path = eina_module_environment_path_get("HOME", "/.emotion");
68 if (path)
69 {
70 _emotion_modules = eina_module_arch_list_get(_emotion_modules, path, MODULE_ARCH);
71 free(path);
72 }
73
74 snprintf(buf, sizeof(buf), "%s/emotion/modules", eina_prefix_lib_get(_emotion_pfx));
75 _emotion_modules = eina_module_arch_list_get(_emotion_modules, buf, MODULE_ARCH);
76}
77
78Eina_Bool
79emotion_modules_init(void)
80{
81 int static_modules = 0;
82
83 _emotion_modules_load();
84
85 /* Init static module */
86#ifdef EMOTION_STATIC_BUILD_XINE
87 static_modules += xine_module_init();
88#endif
89#ifdef EMOTION_STATIC_BUILD_GSTREAMER
90 static_modules += gstreamer_module_init();
91#endif
92#ifdef EMOTION_STATIC_BUILD_GENERIC
93 static_modules += generic_module_init();
94#endif
95
96 if ((!_emotion_modules) && (!static_modules))
97 WRN("No emotion modules found!");
98 else if (_emotion_modules)
99 eina_module_list_load(_emotion_modules);
100
101 return EINA_TRUE;
102}
103
104void
105emotion_modules_shutdown(void)
106{
107#ifdef EMOTION_STATIC_BUILD_XINE
108 xine_module_shutdown();
109#endif
110#ifdef EMOTION_STATIC_BUILD_GSTREAMER
111 gstreamer_module_shutdown();
112#endif
113#ifdef EMOTION_STATIC_BUILD_GENERIC
114 generic_module_shutdown();
115#endif
116
117 if (_emotion_modules)
118 {
119 eina_module_list_free(_emotion_modules);
120 eina_array_free(_emotion_modules);
121 _emotion_modules = NULL;
122 }
123
124 eina_hash_free(_emotion_backends);
125 _emotion_backends = NULL;
126}