summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Friloux <kuri@efl.so>2014-01-02 22:10:18 +0100
committerGuillaume Friloux <kuri@efl.so>2014-01-02 22:10:18 +0100
commit64f06a459a73f9d627ee86fbfb04a3f4dcc7d335 (patch)
tree3298a5322f4a2ee4b5f8c5ce533ca6455f2f3b6f
parent8a7aa63f2cc46fe350082da007ba83c2c9f79409 (diff)
Vog can now list desktop files.
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac6
-rw-r--r--src/bin/Makefile.mk12
-rw-r--r--src/bin/launcher.h22
-rw-r--r--src/bin/main.c40
-rw-r--r--src/include/Vog.h10
-rw-r--r--src/lib/vog_event.c41
-rw-r--r--src/lib/vog_main.c13
8 files changed, 134 insertions, 12 deletions
diff --git a/Makefile.am b/Makefile.am
index 8df19c0..e7ac373 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -57,7 +57,7 @@ EXTRA_CPPFLAGS = \
57-I$(top_srcdir) \ 57-I$(top_srcdir) \
58-I$(top_srcdir)/src/include/ \ 58-I$(top_srcdir)/src/include/ \
59-I$(top_srcdir)/src/include/extras \ 59-I$(top_srcdir)/src/include/extras \
60-DPKG_DATA_DIR=\"$(datadir)\" 60-DPKG_DATA_DIR=\"$(datadir)/vog\"
61 61
62include src/lib/Makefile.mk 62include src/lib/Makefile.mk
63include src/bin/Makefile.mk 63include src/bin/Makefile.mk
diff --git a/configure.ac b/configure.ac
index 4d3dbf8..923d4ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,15 +53,11 @@ PKG_CHECK_MODULES(LIBS, [$LIBS_REQUIRES], [build_libs=yes], [build_libs=no])
53build_vog= 53build_vog=
54if test "x${build_libs}" = "xyes"; then 54if test "x${build_libs}" = "xyes"; then
55 BIN_REQUIRES="${LIBS_REQUIRES}" 55 BIN_REQUIRES="${LIBS_REQUIRES}"
56 PKG_CHECK_MODULES(BIN, [$BIN_REQUIRES], [build_smman=yes], [build_smman=no]) 56 PKG_CHECK_MODULES(BIN, [$BIN_REQUIRES], [build_vog=yes], [build_vog=no])
57else 57else
58 build_vog=no 58 build_vog=no
59fi 59fi
60 60
61AC_DEFINE(_LARGEFILE64_SOURCE, 1, "Needed for 64 bit on 32")
62AC_DEFINE(_LARGEFILE_SOURCE, 1, "Needed for 64 bit on 32")
63AC_DEFINE(_FILE_OFFSET_BITS, 64, "Needed for 64 bit on 32")
64
65AM_CONDITIONAL(ENABLE_TESTS, [test "x${enable_tests}" = "xyes"]) 61AM_CONDITIONAL(ENABLE_TESTS, [test "x${enable_tests}" = "xyes"])
66 62
67AC_CONFIG_HEADER([config.h]) 63AC_CONFIG_HEADER([config.h])
diff --git a/src/bin/Makefile.mk b/src/bin/Makefile.mk
index e69de29..a2ac1f0 100644
--- a/src/bin/Makefile.mk
+++ b/src/bin/Makefile.mk
@@ -0,0 +1,12 @@
1MAINTAINERCLEANFILES += \
2src/bin/*.gc{no,da}
3
4bin_PROGRAMS += \
5src/bin/vog
6
7src_bin_vog_SOURCES = \
8src/bin/main.c
9src_bin_vog_CPPFLAGS = @BIN_CFLAGS@ $(EXTRA_CPPFLAGS)
10src_bin_vog_LDFLAGS = @BIN_LIBS@
11src_bin_vog_LDADD = \
12src/lib/libvog.la
diff --git a/src/bin/launcher.h b/src/bin/launcher.h
new file mode 100644
index 0000000..f36f010
--- /dev/null
+++ b/src/bin/launcher.h
@@ -0,0 +1,22 @@
1#include <Eina.h>
2#include <Ecore.h>
3#include <Vog.h>
4
5typedef struct _Launcher
6{
7 Vog *vog;
8
9 struct
10 {
11 Ecore_Event_Handler *vega; /* VOG_EVENT_GAME_ADD */
12 } ev;
13} Launcher;
14
15int l_log_dom_global;
16
17#define ERR(...) EINA_LOG_DOM_ERR(l_log_dom_global, __VA_ARGS__)
18#define DBG(...) EINA_LOG_DOM_DBG(l_log_dom_global, __VA_ARGS__)
19#define NFO(...) EINA_LOG_DOM_INFO(l_log_dom_global, __VA_ARGS__)
20#define WRN(...) EINA_LOG_DOM_WARN(l_log_dom_global, __VA_ARGS__)
21#define CRI(...) EINA_LOG_DOM_CRIT(l_log_dom_global, __VA_ARGS__)
22
diff --git a/src/bin/main.c b/src/bin/main.c
new file mode 100644
index 0000000..814c0ad
--- /dev/null
+++ b/src/bin/main.c
@@ -0,0 +1,40 @@
1#include "launcher.h"
2
3Eina_Bool
4launcher_game_add(void *data,
5 int type EINA_UNUSED,
6 void *event)
7{
8 Launcher *launcher;
9 Vog_Game *va;
10
11 launcher = data;
12 va = event;
13
14 DBG("launcher[%p] va[%p][%s]", launcher, va, va->name);
15
16 return EINA_TRUE;
17}
18
19int main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
20{
21 Launcher *launcher;
22
23 eina_init();
24 ecore_init();
25 vog_init();
26
27 l_log_dom_global = eina_log_domain_register("vog", EINA_COLOR_YELLOW);
28
29 launcher = calloc(1, sizeof(Launcher));
30 launcher->vog = vog_new();
31 launcher->ev.vega = ecore_event_handler_add(VOG_EVENT_GAME_ADD,
32 launcher_game_add,
33 launcher);
34 ecore_main_loop_begin();
35
36 vog_shutdown();
37 ecore_shutdown();
38 eina_shutdown();
39 return 0;
40}
diff --git a/src/include/Vog.h b/src/include/Vog.h
index cecbdf6..37b3695 100644
--- a/src/include/Vog.h
+++ b/src/include/Vog.h
@@ -11,6 +11,16 @@ extern int VOG_EVENT_GAME_UPD;
11 11
12typedef struct _Vog Vog; 12typedef struct _Vog Vog;
13 13
14typedef struct _Vog_Game
15{
16 const char *name,
17 *genre,
18 *description;
19 unsigned int year;
20
21 Efreet_Desktop *ed;
22} Vog_Game;
23
14int vog_init(void); 24int vog_init(void);
15int vog_shutdown(void); 25int vog_shutdown(void);
16 26
diff --git a/src/lib/vog_event.c b/src/lib/vog_event.c
index 541c913..603556a 100644
--- a/src/lib/vog_event.c
+++ b/src/lib/vog_event.c
@@ -1,5 +1,10 @@
1#include "vog_private.h" 1#include "vog_private.h"
2#include <string.h>
2 3
4void
5_vog_event_game_free(void *d1 EINA_UNUSED,
6 void *d2 EINA_UNUSED)
7{}
3 8
4Eina_Bool 9Eina_Bool
5vog_event_filter_cb(void *data EINA_UNUSED, 10vog_event_filter_cb(void *data EINA_UNUSED,
@@ -15,6 +20,7 @@ vog_event_main_cb(void *data,
15 const Eina_File_Direct_Info *info) 20 const Eina_File_Direct_Info *info)
16{ 21{
17 Vog *vog; 22 Vog *vog;
23 Vog_Game *vg;
18 Efreet_Desktop *ed; 24 Efreet_Desktop *ed;
19 25
20 vog = data; 26 vog = data;
@@ -28,22 +34,51 @@ vog_event_main_cb(void *data,
28 return; 34 return;
29 } 35 }
30 36
37 vg = calloc(1, sizeof(Vog_Game));
38 if (!vg)
39 {
40 ERR("Failed to allocate Vog_Game structure");
41 goto ed_free;
42 }
43
44 vg->ed = ed;
45 vg->name = strdup(ed->name);
46 if (!vg->name)
47 {
48 ERR("Failed to allocate vg->name");
49 goto vg_free;
50 }
51
52 ecore_event_add(VOG_EVENT_GAME_ADD, vg, _vog_event_game_free, NULL);
53
31 return; 54 return;
55
56vg_free:
57 free(vg);
58ed_free:
59 efreet_desktop_free(ed);
32} 60}
33 61
34void 62void
35vog_event_done_cb(void *data EINA_UNUSED, 63vog_event_done_cb(void *data,
36 Eio_File *handler EINA_UNUSED) 64 Eio_File *handler EINA_UNUSED)
37{ 65{
66 Vog *vog;
38 67
68 vog = data;
69
70 DBG("vog[%p]", vog);
39} 71}
40 72
41void 73void
42vog_event_error_cb(void *data EINA_UNUSED, 74vog_event_error_cb(void *data,
43 Eio_File *handler EINA_UNUSED, 75 Eio_File *handler EINA_UNUSED,
44 int error EINA_UNUSED) 76 int error)
45{ 77{
78 Vog *vog;
46 79
80 vog = data;
81 ERR("vog[%p] : Failed to load desktop directory : %s", vog, strerror(error));
47} 82}
48 83
49Eina_Bool 84Eina_Bool
diff --git a/src/lib/vog_main.c b/src/lib/vog_main.c
index f184ba8..2326f2e 100644
--- a/src/lib/vog_main.c
+++ b/src/lib/vog_main.c
@@ -90,7 +90,7 @@ vog_init(void)
90 return --_vog_init_count; 90 return --_vog_init_count;
91 } 91 }
92 92
93 _vog_log_dom_global = eina_log_domain_register("vog", EINA_COLOR_RED); 93 _vog_log_dom_global = eina_log_domain_register("libvog", EINA_COLOR_RED);
94 if (_vog_log_dom_global < 0) 94 if (_vog_log_dom_global < 0)
95 { 95 {
96 EINA_LOG_ERR("Vog can not create a general log domain"); 96 EINA_LOG_ERR("Vog can not create a general log domain");
@@ -103,10 +103,16 @@ vog_init(void)
103 goto unregister_log_domain; 103 goto unregister_log_domain;
104 } 104 }
105 105
106 if (!eio_init())
107 {
108 ERR("Can not initialize Eio");
109 goto shutdown_ecore;
110 }
111
106 if (!efreet_init()) 112 if (!efreet_init())
107 { 113 {
108 ERR("Can not initialize Efreet"); 114 ERR("Can not initialize Efreet");
109 goto shutdown_ecore; 115 goto shutdown_eio;
110 } 116 }
111 117
112 VOG_EVENT_GAME_ADD = ecore_event_type_new(); 118 VOG_EVENT_GAME_ADD = ecore_event_type_new();
@@ -114,7 +120,8 @@ vog_init(void)
114 VOG_EVENT_GAME_UPD = ecore_event_type_new(); 120 VOG_EVENT_GAME_UPD = ecore_event_type_new();
115 121
116 return _vog_init_count; 122 return _vog_init_count;
117 123shutdown_eio:
124 eio_shutdown();
118shutdown_ecore: 125shutdown_ecore:
119 ecore_shutdown(); 126 ecore_shutdown();
120unregister_log_domain: 127unregister_log_domain: