diff options
author | Sebastian Dransfeld <sd@tango.flipp.net> | 2012-10-21 04:53:23 +0000 |
---|---|---|
committer | Sebastian Dransfeld <sd@tango.flipp.net> | 2012-10-21 04:53:23 +0000 |
commit | ed5e14204e61a183272062432f5d8205b29a349b (patch) | |
tree | 3ba999096e8cc777e9657bc77b61b11f28a2a6aa /legacy/efreet | |
parent | 199bef6051fd5e35ded4b45e1f5319ad36cd1a6b (diff) |
efreet: Add dbus efreet daemon
Not working yet.
SVN revision: 78294
Diffstat (limited to 'legacy/efreet')
-rw-r--r-- | legacy/efreet/.gitignore | 3 | ||||
-rw-r--r-- | legacy/efreet/Makefile.am | 3 | ||||
-rw-r--r-- | legacy/efreet/configure.ac | 30 | ||||
-rw-r--r-- | legacy/efreet/org.enlightenment.Efreet.service.in | 3 | ||||
-rw-r--r-- | legacy/efreet/src/bin/Makefile.am | 17 | ||||
-rw-r--r-- | legacy/efreet/src/bin/efreet_desktop_cache_create.c | 1 | ||||
-rw-r--r-- | legacy/efreet/src/bin/efreet_icon_cache_create.c | 1 | ||||
-rw-r--r-- | legacy/efreet/src/bin/efreetd.c | 47 | ||||
-rw-r--r-- | legacy/efreet/src/bin/efreetd.h | 32 | ||||
-rw-r--r-- | legacy/efreet/src/bin/efreetd_cache.c | 495 | ||||
-rw-r--r-- | legacy/efreet/src/bin/efreetd_cache.h | 11 | ||||
-rw-r--r-- | legacy/efreet/src/bin/efreetd_dbus.c | 184 | ||||
-rw-r--r-- | legacy/efreet/src/bin/efreetd_dbus.h | 10 | ||||
-rw-r--r-- | legacy/efreet/src/lib/efreet_copy.h | 10 |
14 files changed, 846 insertions, 1 deletions
diff --git a/legacy/efreet/.gitignore b/legacy/efreet/.gitignore index 99c665b57e..9e19f3ead3 100644 --- a/legacy/efreet/.gitignore +++ b/legacy/efreet/.gitignore | |||
@@ -40,12 +40,14 @@ m4/lt~obsolete.m4 | |||
40 | /missing | 40 | /missing |
41 | src/bin/efreet_desktop_cache_create | 41 | src/bin/efreet_desktop_cache_create |
42 | src/bin/efreet_icon_cache_create | 42 | src/bin/efreet_icon_cache_create |
43 | src/bin/efreetd | ||
43 | src/tests/compare/efreet_alloc | 44 | src/tests/compare/efreet_alloc |
44 | src/tests/compare/efreet_menu_alloc | 45 | src/tests/compare/efreet_menu_alloc |
45 | src/tests/efreet_cache_test | 46 | src/tests/efreet_cache_test |
46 | src/tests/efreet_icon_cache_dump | 47 | src/tests/efreet_icon_cache_dump |
47 | src/tests/efreet_spec_test | 48 | src/tests/efreet_spec_test |
48 | src/tests/efreet_test | 49 | src/tests/efreet_test |
50 | src/tests/efreet_user_dir | ||
49 | /m4/codeset.m4 | 51 | /m4/codeset.m4 |
50 | /m4/gettext.m4 | 52 | /m4/gettext.m4 |
51 | /m4/glibc21.m4 | 53 | /m4/glibc21.m4 |
@@ -150,3 +152,4 @@ src/tests/efreet_test | |||
150 | /po/*.gmo | 152 | /po/*.gmo |
151 | /po/stamp-po | 153 | /po/stamp-po |
152 | /stamp-h1 | 154 | /stamp-h1 |
155 | /org.enlightenment.Efreet.service | ||
diff --git a/legacy/efreet/Makefile.am b/legacy/efreet/Makefile.am index a1590158cf..858b0bb0e6 100644 --- a/legacy/efreet/Makefile.am +++ b/legacy/efreet/Makefile.am | |||
@@ -76,6 +76,9 @@ endif | |||
76 | pkgconfigdir = $(libdir)/pkgconfig | 76 | pkgconfigdir = $(libdir)/pkgconfig |
77 | pkgconfig_DATA = efreet.pc efreet-mime.pc efreet-trash.pc | 77 | pkgconfig_DATA = efreet.pc efreet-mime.pc efreet-trash.pc |
78 | 78 | ||
79 | servicedir = $(dbusservicedir) | ||
80 | service_DATA = org.enlightenment.Efreet.service | ||
81 | |||
79 | EXTRA_DIST = \ | 82 | EXTRA_DIST = \ |
80 | AUTHORS \ | 83 | AUTHORS \ |
81 | COPYING \ | 84 | COPYING \ |
diff --git a/legacy/efreet/configure.ac b/legacy/efreet/configure.ac index 07c56a0909..fb11f00ecd 100644 --- a/legacy/efreet/configure.ac +++ b/legacy/efreet/configure.ac | |||
@@ -166,11 +166,33 @@ AC_SUBST(EFL_EFREET_BUILD) | |||
166 | AC_SUBST(EFL_EFREET_MIME_BUILD) | 166 | AC_SUBST(EFL_EFREET_MIME_BUILD) |
167 | AC_SUBST(EFL_EFREET_TRASH_BUILD) | 167 | AC_SUBST(EFL_EFREET_TRASH_BUILD) |
168 | 168 | ||
169 | service="" | ||
170 | have_efreetd="" | ||
171 | dbusservicedir="" | ||
172 | PKG_CHECK_MODULES(EFREETD, [ | ||
173 | eina >= 1.7.99 | ||
174 | ecore >= 1.7.99 | ||
175 | ecore-file >= 1.7.99 | ||
176 | edbus2 >= 1.7.99 | ||
177 | ], [ | ||
178 | have_efreetd="yes" | ||
179 | service="org.enlightenment.Efreet.service" | ||
180 | requirement_efreet="edbus2 ${requirement_efreet}" | ||
181 | dbusservicedir=${datadir}/dbus-1/services | ||
182 | AC_ARG_WITH([dbus-services], | ||
183 | AC_HELP_STRING([--with-dbus-services=DBUS_SERVICES], [specify a directory to store dbus service files.]), | ||
184 | [ dbusservicedir=$withval ] | ||
185 | ) | ||
186 | |||
187 | ], [ | ||
188 | have_efreetd="no" | ||
189 | ]) | ||
190 | AM_CONDITIONAL([HAVE_EFREETD], [test "x${have_efreetd}" = "xyes"]) | ||
191 | |||
169 | requirement_efreet="ecore-file >= 1.6.99 ecore >= 1.6.99 eet >= 1.6.99 eina >= 1.6.99 ${requirement_efreet}" | 192 | requirement_efreet="ecore-file >= 1.6.99 ecore >= 1.6.99 eet >= 1.6.99 eina >= 1.6.99 ${requirement_efreet}" |
170 | PKG_CHECK_MODULES(EFREET, [${requirement_efreet}]) | 193 | PKG_CHECK_MODULES(EFREET, [${requirement_efreet}]) |
171 | PKG_CHECK_MODULES(EINA, [eina >= 1.6.99]) | 194 | PKG_CHECK_MODULES(EINA, [eina >= 1.6.99]) |
172 | 195 | ||
173 | |||
174 | ### Checks for header files | 196 | ### Checks for header files |
175 | 197 | ||
176 | AC_CHECK_HEADERS([netinet/in.h arpa/inet.h]) | 198 | AC_CHECK_HEADERS([netinet/in.h arpa/inet.h]) |
@@ -234,6 +256,7 @@ if test "x$enable_coverage" = "xyes" ; then | |||
234 | fi | 256 | fi |
235 | 257 | ||
236 | AC_SUBST(requirement_efreet) | 258 | AC_SUBST(requirement_efreet) |
259 | AC_SUBST(dbusservicedir) | ||
237 | 260 | ||
238 | AC_OUTPUT([ | 261 | AC_OUTPUT([ |
239 | efreet.spec | 262 | efreet.spec |
@@ -251,6 +274,7 @@ src/tests/data/Makefile | |||
251 | src/tests/data/sub/Makefile | 274 | src/tests/data/sub/Makefile |
252 | src/tests/compare/Makefile | 275 | src/tests/compare/Makefile |
253 | $po_makefile_in | 276 | $po_makefile_in |
277 | $service | ||
254 | ]) | 278 | ]) |
255 | 279 | ||
256 | 280 | ||
@@ -270,6 +294,10 @@ echo " Specification compliance:" | |||
270 | echo " Strict.............: ${enable_strict_spec}" | 294 | echo " Strict.............: ${enable_strict_spec}" |
271 | echo " Sloppy.............: ${enable_sloppy_spec}" | 295 | echo " Sloppy.............: ${enable_sloppy_spec}" |
272 | echo | 296 | echo |
297 | if test "x$have_efreetd" = "xyes"; then | ||
298 | echo " DBus services dir....: ${dbusservicedir}" | ||
299 | echo | ||
300 | fi | ||
273 | echo " Tests................: ${enable_tests}" | 301 | echo " Tests................: ${enable_tests}" |
274 | echo " Coverage.............: ${enable_coverage}" | 302 | echo " Coverage.............: ${enable_coverage}" |
275 | echo | 303 | echo |
diff --git a/legacy/efreet/org.enlightenment.Efreet.service.in b/legacy/efreet/org.enlightenment.Efreet.service.in new file mode 100644 index 0000000000..94eedc87e3 --- /dev/null +++ b/legacy/efreet/org.enlightenment.Efreet.service.in | |||
@@ -0,0 +1,3 @@ | |||
1 | [D-BUS Service] | ||
2 | Name=org.enlightenment.Efreet | ||
3 | Exec=@prefix@/bin/efreetd | ||
diff --git a/legacy/efreet/src/bin/Makefile.am b/legacy/efreet/src/bin/Makefile.am index 3040a20bac..e77fd6c4a8 100644 --- a/legacy/efreet/src/bin/Makefile.am +++ b/legacy/efreet/src/bin/Makefile.am | |||
@@ -27,3 +27,20 @@ $(top_builddir)/src/lib/libefreet.la \ | |||
27 | 27 | ||
28 | efreet_icon_cache_create_SOURCES = \ | 28 | efreet_icon_cache_create_SOURCES = \ |
29 | efreet_icon_cache_create.c | 29 | efreet_icon_cache_create.c |
30 | |||
31 | if HAVE_EFREETD | ||
32 | bin_PROGRAMS = \ | ||
33 | efreetd | ||
34 | |||
35 | efreetd_LDADD = \ | ||
36 | $(top_builddir)/src/lib/libefreet.la \ | ||
37 | @EFREETD_LIBS@ | ||
38 | |||
39 | efreetd_SOURCES = \ | ||
40 | efreetd.c \ | ||
41 | efreetd_dbus.h \ | ||
42 | efreetd_dbus.c \ | ||
43 | efreetd_cache.h \ | ||
44 | efreetd_cache.c | ||
45 | endif | ||
46 | |||
diff --git a/legacy/efreet/src/bin/efreet_desktop_cache_create.c b/legacy/efreet/src/bin/efreet_desktop_cache_create.c index 3b77f8282a..2c8e330a4a 100644 --- a/legacy/efreet/src/bin/efreet_desktop_cache_create.c +++ b/legacy/efreet/src/bin/efreet_desktop_cache_create.c | |||
@@ -507,6 +507,7 @@ main(int argc, char **argv) | |||
507 | if (changed) c = 'c'; | 507 | if (changed) c = 'c'; |
508 | if (write(tmpfd, &c, 1) != 1) perror("write"); | 508 | if (write(tmpfd, &c, 1) != 1) perror("write"); |
509 | close(tmpfd); | 509 | close(tmpfd); |
510 | printf("%c\n", c); | ||
510 | } | 511 | } |
511 | 512 | ||
512 | EINA_LIST_FREE(systemdirs, dir) | 513 | EINA_LIST_FREE(systemdirs, dir) |
diff --git a/legacy/efreet/src/bin/efreet_icon_cache_create.c b/legacy/efreet/src/bin/efreet_icon_cache_create.c index e24364b6d5..0eb34b779b 100644 --- a/legacy/efreet/src/bin/efreet_icon_cache_create.c +++ b/legacy/efreet/src/bin/efreet_icon_cache_create.c | |||
@@ -1128,6 +1128,7 @@ main(int argc, char **argv) | |||
1128 | if (changed) c = 'c'; | 1128 | if (changed) c = 'c'; |
1129 | if (write(tmpfd, &c, 1) != 1) perror("write"); | 1129 | if (write(tmpfd, &c, 1) != 1) perror("write"); |
1130 | close(tmpfd); | 1130 | close(tmpfd); |
1131 | printf("%c\n", c); | ||
1131 | } | 1132 | } |
1132 | 1133 | ||
1133 | INF("done"); | 1134 | INF("done"); |
diff --git a/legacy/efreet/src/bin/efreetd.c b/legacy/efreet/src/bin/efreetd.c new file mode 100644 index 0000000000..a905664f3d --- /dev/null +++ b/legacy/efreet/src/bin/efreetd.c | |||
@@ -0,0 +1,47 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <Ecore.h> | ||
6 | |||
7 | #include "efreetd.h" | ||
8 | #include "efreetd_dbus.h" | ||
9 | #include "efreetd_cache.h" | ||
10 | |||
11 | int efreetd_log_dom = -1; | ||
12 | |||
13 | int | ||
14 | main(void) | ||
15 | { | ||
16 | if (!eina_init()) return 1; | ||
17 | efreetd_log_dom = eina_log_domain_register("efreetd", EFREETD_DEFAULT_LOG_COLOR); | ||
18 | if (efreetd_log_dom < 0) | ||
19 | { | ||
20 | EINA_LOG_ERR("Efreet: Could not create a log domain for efreetd."); | ||
21 | goto ecore_error; | ||
22 | } | ||
23 | if (!ecore_init()) goto ecore_error; | ||
24 | |||
25 | if (!dbus_init()) goto dbus_error; | ||
26 | if (!cache_init()) goto cache_error; | ||
27 | |||
28 | ecore_main_loop_begin(); | ||
29 | |||
30 | cache_shutdown(); | ||
31 | dbus_shutdown(); | ||
32 | ecore_shutdown(); | ||
33 | eina_log_domain_unregister(efreetd_log_dom); | ||
34 | efreetd_log_dom = -1; | ||
35 | eina_shutdown(); | ||
36 | return 0; | ||
37 | |||
38 | cache_error: | ||
39 | dbus_shutdown(); | ||
40 | dbus_error: | ||
41 | ecore_shutdown(); | ||
42 | ecore_error: | ||
43 | eina_log_domain_unregister(efreetd_log_dom); | ||
44 | efreetd_log_dom = -1; | ||
45 | eina_shutdown(); | ||
46 | return 1; | ||
47 | } | ||
diff --git a/legacy/efreet/src/bin/efreetd.h b/legacy/efreet/src/bin/efreetd.h new file mode 100644 index 0000000000..67097de4a5 --- /dev/null +++ b/legacy/efreet/src/bin/efreetd.h | |||
@@ -0,0 +1,32 @@ | |||
1 | #ifndef __EFREETD_H | ||
2 | #define __EFREETD_H | ||
3 | |||
4 | #ifdef EFREETD_DEFAULT_LOG_COLOR | ||
5 | #undef EFREETD_DEFAULT_LOG_COLOR | ||
6 | #endif | ||
7 | #define EFREETD_DEFAULT_LOG_COLOR "\033[36m" | ||
8 | |||
9 | extern int efreetd_log_dom; | ||
10 | |||
11 | #ifdef CRITICAL | ||
12 | #undef CRITICAL | ||
13 | #endif | ||
14 | #define CRITICAL(...) EINA_LOG_DOM_CRIT(efreetd_log_dom, __VA_ARGS__) | ||
15 | #ifdef ERR | ||
16 | #undef ERR | ||
17 | #endif | ||
18 | #define ERR(...) EINA_LOG_DOM_ERR(efreetd_log_dom, __VA_ARGS__) | ||
19 | #ifdef DBG | ||
20 | #undef DBG | ||
21 | #endif | ||
22 | #define DBG(...) EINA_LOG_DOM_DBG(efreetd_log_dom, __VA_ARGS__) | ||
23 | #ifdef INF | ||
24 | #undef INF | ||
25 | #endif | ||
26 | #define INF(...) EINA_LOG_DOM_INFO(efreetd_log_dom, __VA_ARGS__) | ||
27 | #ifdef WRN | ||
28 | #undef WRN | ||
29 | #endif | ||
30 | #define WRN(...) EINA_LOG_DOM_WARN(efreetd_log_dom, __VA_ARGS__) | ||
31 | |||
32 | #endif | ||
diff --git a/legacy/efreet/src/bin/efreetd_cache.c b/legacy/efreet/src/bin/efreetd_cache.c new file mode 100644 index 0000000000..a3a47eeaf7 --- /dev/null +++ b/legacy/efreet/src/bin/efreetd_cache.c | |||
@@ -0,0 +1,495 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <Eina.h> | ||
6 | #include <Ecore.h> | ||
7 | #include <Ecore_File.h> | ||
8 | |||
9 | #include "efreetd.h" | ||
10 | #include "efreetd_dbus.h" | ||
11 | |||
12 | #include "Efreet.h" | ||
13 | #define EFREET_MODULE_LOG_DOM efreetd_log_dom | ||
14 | #include "efreet_private.h" | ||
15 | |||
16 | static Eina_Hash *change_monitors = NULL; | ||
17 | |||
18 | static Ecore_Event_Handler *cache_exe_del_handler = NULL; | ||
19 | static Ecore_Event_Handler *cache_exe_data_handler = NULL; | ||
20 | static Ecore_Exe *icon_cache_exe = NULL; | ||
21 | static Ecore_Exe *desktop_cache_exe = NULL; | ||
22 | static Ecore_Timer *icon_cache_timer = NULL; | ||
23 | static Ecore_Timer *desktop_cache_timer = NULL; | ||
24 | |||
25 | static Eina_List *desktop_extra_dirs = NULL; | ||
26 | static Eina_List *icon_extra_dirs = NULL; | ||
27 | static Eina_List *icon_extra_exts = NULL; | ||
28 | |||
29 | static void desktop_changes_monitor_add(const char *path); | ||
30 | |||
31 | /* internal */ | ||
32 | static Eina_Bool | ||
33 | icon_cache_update_cache_cb(void *data __UNUSED__) | ||
34 | { | ||
35 | char file[PATH_MAX]; | ||
36 | int prio; | ||
37 | |||
38 | icon_cache_timer = NULL; | ||
39 | |||
40 | /* TODO: Queue if already running */ | ||
41 | prio = ecore_exe_run_priority_get(); | ||
42 | ecore_exe_run_priority_set(19); | ||
43 | eina_strlcpy(file, PACKAGE_LIB_DIR "/efreet/efreet_icon_cache_create", sizeof(file)); | ||
44 | if (icon_extra_dirs) | ||
45 | { | ||
46 | Eina_List *ll; | ||
47 | char *p; | ||
48 | |||
49 | eina_strlcat(file, " -d", sizeof(file)); | ||
50 | EINA_LIST_FOREACH(icon_extra_dirs, ll, p) | ||
51 | { | ||
52 | eina_strlcat(file, " ", sizeof(file)); | ||
53 | eina_strlcat(file, p, sizeof(file)); | ||
54 | } | ||
55 | } | ||
56 | if (icon_extra_exts) | ||
57 | { | ||
58 | Eina_List *ll; | ||
59 | char *p; | ||
60 | |||
61 | eina_strlcat(file, " -e", sizeof(file)); | ||
62 | EINA_LIST_FOREACH(icon_extra_exts, ll, p) | ||
63 | { | ||
64 | eina_strlcat(file, " ", sizeof(file)); | ||
65 | eina_strlcat(file, p, sizeof(file)); | ||
66 | } | ||
67 | } | ||
68 | icon_cache_exe = ecore_exe_run(file, NULL); | ||
69 | ecore_exe_run_priority_set(prio); | ||
70 | |||
71 | return ECORE_CALLBACK_CANCEL; | ||
72 | } | ||
73 | |||
74 | static void | ||
75 | cache_icon_update(void) | ||
76 | { | ||
77 | if (icon_cache_timer) | ||
78 | ecore_timer_del(icon_cache_timer); | ||
79 | icon_cache_timer = ecore_timer_add(0.2, icon_cache_update_cache_cb, NULL); | ||
80 | } | ||
81 | |||
82 | static Eina_Bool | ||
83 | desktop_cache_update_cache_cb(void *data __UNUSED__) | ||
84 | { | ||
85 | char file[PATH_MAX]; | ||
86 | int prio; | ||
87 | |||
88 | desktop_cache_timer = NULL; | ||
89 | |||
90 | /* TODO: Queue if already running */ | ||
91 | prio = ecore_exe_run_priority_get(); | ||
92 | ecore_exe_run_priority_set(19); | ||
93 | eina_strlcpy(file, PACKAGE_LIB_DIR "/efreet/efreet_desktop_cache_create", sizeof(file)); | ||
94 | if (desktop_extra_dirs) | ||
95 | { | ||
96 | Eina_List *ll; | ||
97 | const char *str; | ||
98 | |||
99 | eina_strlcat(file, " -d", sizeof(file)); | ||
100 | EINA_LIST_FOREACH(desktop_extra_dirs, ll, str) | ||
101 | { | ||
102 | eina_strlcat(file, " ", sizeof(file)); | ||
103 | eina_strlcat(file, str, sizeof(file)); | ||
104 | } | ||
105 | } | ||
106 | INF("Run desktop cache creation: %s", file); | ||
107 | desktop_cache_exe = ecore_exe_run(file, NULL); | ||
108 | ecore_exe_run_priority_set(prio); | ||
109 | |||
110 | return ECORE_CALLBACK_CANCEL; | ||
111 | } | ||
112 | |||
113 | static void | ||
114 | cache_desktop_update(void) | ||
115 | { | ||
116 | if (desktop_cache_timer) | ||
117 | ecore_timer_del(desktop_cache_timer); | ||
118 | desktop_cache_timer = ecore_timer_add(0.2, desktop_cache_update_cache_cb, NULL); | ||
119 | } | ||
120 | |||
121 | static Eina_Bool | ||
122 | cache_exe_data_cb(void *data __UNUSED__, int type __UNUSED__, void *event) | ||
123 | { | ||
124 | Ecore_Exe_Event_Data *ev; | ||
125 | |||
126 | ev = event; | ||
127 | if (ev->exe == desktop_cache_exe) | ||
128 | { | ||
129 | Eina_Bool update = EINA_FALSE; | ||
130 | |||
131 | if ((ev->lines) && (*ev->lines->line == 'c')) | ||
132 | update = EINA_TRUE; | ||
133 | |||
134 | send_signal_desktop_cache_update(update); | ||
135 | } | ||
136 | else if (ev->exe == icon_cache_exe) | ||
137 | { | ||
138 | Eina_Bool update = EINA_FALSE; | ||
139 | |||
140 | if ((ev->lines) && (*ev->lines->line == 'c')) | ||
141 | update = EINA_TRUE; | ||
142 | send_signal_icon_cache_update(update); | ||
143 | } | ||
144 | return ECORE_CALLBACK_RENEW; | ||
145 | } | ||
146 | |||
147 | static Eina_Bool | ||
148 | cache_exe_del_cb(void *data __UNUSED__, int type __UNUSED__, void *event) | ||
149 | { | ||
150 | Ecore_Exe_Event_Del *ev; | ||
151 | |||
152 | ev = event; | ||
153 | if (ev->exe == desktop_cache_exe) | ||
154 | { | ||
155 | desktop_cache_exe = NULL; | ||
156 | } | ||
157 | else if (ev->exe == icon_cache_exe) | ||
158 | { | ||
159 | icon_cache_exe = NULL; | ||
160 | } | ||
161 | return ECORE_CALLBACK_RENEW; | ||
162 | } | ||
163 | |||
164 | static void | ||
165 | icon_changes_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__, | ||
166 | Ecore_File_Event event, const char *path) | ||
167 | { | ||
168 | /* TODO: If we get a stale symlink, we need to rerun cache creation */ | ||
169 | switch (event) | ||
170 | { | ||
171 | case ECORE_FILE_EVENT_NONE: | ||
172 | /* noop */ | ||
173 | break; | ||
174 | |||
175 | case ECORE_FILE_EVENT_CREATED_FILE: | ||
176 | case ECORE_FILE_EVENT_DELETED_FILE: | ||
177 | case ECORE_FILE_EVENT_MODIFIED: | ||
178 | case ECORE_FILE_EVENT_CLOSED: | ||
179 | case ECORE_FILE_EVENT_DELETED_DIRECTORY: | ||
180 | case ECORE_FILE_EVENT_CREATED_DIRECTORY: | ||
181 | cache_icon_update(); | ||
182 | break; | ||
183 | |||
184 | case ECORE_FILE_EVENT_DELETED_SELF: | ||
185 | eina_hash_del_by_key(change_monitors, path); | ||
186 | cache_icon_update(); | ||
187 | break; | ||
188 | } | ||
189 | } | ||
190 | |||
191 | static void | ||
192 | icon_changes_monitor_add(const char *path) | ||
193 | { | ||
194 | Eina_Iterator *it; | ||
195 | Eina_File_Direct_Info *info; | ||
196 | |||
197 | if (!ecore_file_is_dir(path)) return; | ||
198 | if (eina_hash_find(change_monitors, path)) return; | ||
199 | eina_hash_add(change_monitors, path, | ||
200 | ecore_file_monitor_add(path, | ||
201 | icon_changes_cb, | ||
202 | NULL)); | ||
203 | |||
204 | it = eina_file_stat_ls(path); | ||
205 | if (!it) return; | ||
206 | EINA_ITERATOR_FOREACH(it, info) | ||
207 | { | ||
208 | if (info->type != EINA_FILE_DIR) continue; | ||
209 | eina_hash_add(change_monitors, info->path, | ||
210 | ecore_file_monitor_add(info->path, | ||
211 | icon_changes_cb, | ||
212 | NULL)); | ||
213 | } | ||
214 | eina_iterator_free(it); | ||
215 | } | ||
216 | |||
217 | static void | ||
218 | icon_changes_listen(void) | ||
219 | { | ||
220 | Eina_List *l; | ||
221 | Eina_List *xdg_dirs; | ||
222 | char buf[PATH_MAX]; | ||
223 | const char *dir; | ||
224 | |||
225 | icon_changes_monitor_add(efreet_icon_deprecated_user_dir_get()); | ||
226 | icon_changes_monitor_add(efreet_icon_user_dir_get()); | ||
227 | EINA_LIST_FOREACH(icon_extra_dirs, l, dir) | ||
228 | icon_changes_monitor_add(dir); | ||
229 | |||
230 | xdg_dirs = efreet_data_dirs_get(); | ||
231 | EINA_LIST_FOREACH(xdg_dirs, l, dir) | ||
232 | { | ||
233 | snprintf(buf, sizeof(buf), "%s/icons", dir); | ||
234 | icon_changes_monitor_add(buf); | ||
235 | } | ||
236 | |||
237 | #ifndef STRICT_SPEC | ||
238 | EINA_LIST_FOREACH(xdg_dirs, l, dir) | ||
239 | { | ||
240 | snprintf(buf, sizeof(buf), "%s/pixmaps", dir); | ||
241 | icon_changes_monitor_add(buf); | ||
242 | } | ||
243 | #endif | ||
244 | |||
245 | icon_changes_monitor_add("/usr/share/pixmaps"); | ||
246 | } | ||
247 | |||
248 | static void | ||
249 | desktop_changes_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__, | ||
250 | Ecore_File_Event event, const char *path) | ||
251 | { | ||
252 | const char *ext; | ||
253 | |||
254 | /* TODO: If we get a stale symlink, we need to rerun cache creation */ | ||
255 | /* TODO: Check for desktop*.cache, as this will be created when app is installed */ | ||
256 | /* TODO: Do efreet_cache_icon_update() when app is installed, as it has the same | ||
257 | * symlink problem */ | ||
258 | switch (event) | ||
259 | { | ||
260 | case ECORE_FILE_EVENT_NONE: | ||
261 | /* noop */ | ||
262 | break; | ||
263 | |||
264 | case ECORE_FILE_EVENT_CREATED_FILE: | ||
265 | case ECORE_FILE_EVENT_DELETED_FILE: | ||
266 | case ECORE_FILE_EVENT_MODIFIED: | ||
267 | case ECORE_FILE_EVENT_CLOSED: | ||
268 | ext = strrchr(path, '.'); | ||
269 | if (ext && (!strcmp(ext, ".desktop") || !strcmp(ext, ".directory"))) | ||
270 | cache_desktop_update(); | ||
271 | break; | ||
272 | |||
273 | case ECORE_FILE_EVENT_DELETED_SELF: | ||
274 | case ECORE_FILE_EVENT_DELETED_DIRECTORY: | ||
275 | eina_hash_del_by_key(change_monitors, path); | ||
276 | cache_desktop_update(); | ||
277 | break; | ||
278 | |||
279 | case ECORE_FILE_EVENT_CREATED_DIRECTORY: | ||
280 | desktop_changes_monitor_add(path); | ||
281 | cache_desktop_update(); | ||
282 | break; | ||
283 | } | ||
284 | } | ||
285 | |||
286 | static void | ||
287 | desktop_changes_monitor_add(const char *path) | ||
288 | { | ||
289 | if (eina_hash_find(change_monitors, path)) return; | ||
290 | eina_hash_add(change_monitors, path, | ||
291 | ecore_file_monitor_add(path, | ||
292 | desktop_changes_cb, | ||
293 | NULL)); | ||
294 | } | ||
295 | |||
296 | static void | ||
297 | desktop_changes_listen_recursive(const char *path) | ||
298 | { | ||
299 | Eina_Iterator *it; | ||
300 | Eina_File_Direct_Info *info; | ||
301 | |||
302 | desktop_changes_monitor_add(path); | ||
303 | |||
304 | it = eina_file_stat_ls(path); | ||
305 | if (!it) return; | ||
306 | EINA_ITERATOR_FOREACH(it, info) | ||
307 | { | ||
308 | if (info->type != EINA_FILE_DIR) continue; | ||
309 | desktop_changes_listen_recursive(info->path); | ||
310 | } | ||
311 | eina_iterator_free(it); | ||
312 | } | ||
313 | |||
314 | static void | ||
315 | desktop_changes_listen(void) | ||
316 | { | ||
317 | Eina_List *dirs, *l; | ||
318 | const char *path; | ||
319 | |||
320 | dirs = efreet_default_dirs_get(efreet_data_home_get(), | ||
321 | efreet_data_dirs_get(), "applications"); | ||
322 | |||
323 | EINA_LIST_FREE(dirs, path) | ||
324 | { | ||
325 | if (ecore_file_is_dir(path)) | ||
326 | desktop_changes_listen_recursive(path); | ||
327 | eina_stringshare_del(path); | ||
328 | } | ||
329 | |||
330 | EINA_LIST_FOREACH(desktop_extra_dirs, l, path) | ||
331 | desktop_changes_monitor_add(path); | ||
332 | } | ||
333 | |||
334 | static void | ||
335 | fill_extra(const char *file, Eina_List **l) | ||
336 | { | ||
337 | Eina_File *f = NULL; | ||
338 | Eina_Iterator *it = NULL; | ||
339 | Eina_File_Line *line = NULL; | ||
340 | char buf[PATH_MAX]; | ||
341 | |||
342 | snprintf(buf, sizeof(buf), "%s/efreet/%s", efreet_cache_home_get(), file); | ||
343 | f = eina_file_open(buf, EINA_FALSE); | ||
344 | if (!f) return; | ||
345 | it = eina_file_map_lines(f); | ||
346 | if (!it) goto error; | ||
347 | EINA_ITERATOR_FOREACH(it, line) | ||
348 | { | ||
349 | const char *end; | ||
350 | end = line->end - 1; | ||
351 | *l = eina_list_append(*l, eina_stringshare_add_length(line->start, end - line->start)); | ||
352 | printf("fill: %s\n", (const char *)(*l)->data); | ||
353 | } | ||
354 | eina_iterator_free(it); | ||
355 | error: | ||
356 | eina_file_close(f); | ||
357 | } | ||
358 | |||
359 | static void | ||
360 | read_extra(void) | ||
361 | { | ||
362 | fill_extra("extra_desktop.dirs", &desktop_extra_dirs); | ||
363 | fill_extra("extra_icon.dirs", &icon_extra_dirs); | ||
364 | fill_extra("extra_icon.exts", &icon_extra_exts); | ||
365 | } | ||
366 | |||
367 | static void | ||
368 | save_extra(const char *file, Eina_List *l) | ||
369 | { | ||
370 | FILE *f; | ||
371 | char buf[PATH_MAX]; | ||
372 | Eina_List *ll; | ||
373 | const char *path; | ||
374 | |||
375 | snprintf(buf, sizeof(buf), "%s/efreet/%s", efreet_cache_home_get(), file); | ||
376 | f = fopen("wb", buf); | ||
377 | if (!f) return; | ||
378 | EINA_LIST_FOREACH(l, ll, path) | ||
379 | fprintf(f, "%s\n", path); | ||
380 | fclose(f); | ||
381 | } | ||
382 | |||
383 | /* external */ | ||
384 | void | ||
385 | cache_desktop_dir_add(const char *dir) | ||
386 | { | ||
387 | char *san; | ||
388 | |||
389 | san = eina_file_path_sanitize(dir); | ||
390 | if (!san) return; | ||
391 | if (!eina_list_search_unsorted_list(desktop_extra_dirs, EINA_COMPARE_CB(strcmp), san)) | ||
392 | { | ||
393 | desktop_extra_dirs = eina_list_append(desktop_extra_dirs, eina_stringshare_add(san)); | ||
394 | save_extra("extra_desktop.dirs", desktop_extra_dirs); | ||
395 | cache_desktop_update(); | ||
396 | } | ||
397 | free(san); | ||
398 | } | ||
399 | |||
400 | void | ||
401 | cache_icon_dir_add(const char *dir) | ||
402 | { | ||
403 | char *san; | ||
404 | |||
405 | san = eina_file_path_sanitize(dir); | ||
406 | if (!san) return; | ||
407 | if (!eina_list_search_unsorted_list(icon_extra_dirs, EINA_COMPARE_CB(strcmp), san)) | ||
408 | { | ||
409 | icon_extra_dirs = eina_list_append(icon_extra_dirs, eina_stringshare_add(san)); | ||
410 | save_extra("extra_icon.dirs", icon_extra_dirs); | ||
411 | cache_icon_update(); | ||
412 | } | ||
413 | free(san); | ||
414 | } | ||
415 | |||
416 | void | ||
417 | cache_icon_ext_add(const char *ext) | ||
418 | { | ||
419 | if (!eina_list_search_unsorted_list(icon_extra_exts, EINA_COMPARE_CB(strcmp), ext)) | ||
420 | { | ||
421 | icon_extra_exts = eina_list_append(icon_extra_exts, eina_stringshare_add(ext)); | ||
422 | save_extra("extra_icon.exts", icon_extra_exts); | ||
423 | cache_icon_update(); | ||
424 | } | ||
425 | } | ||
426 | |||
427 | Eina_Bool | ||
428 | cache_init(void) | ||
429 | { | ||
430 | char buf[PATH_MAX]; | ||
431 | |||
432 | snprintf(buf, sizeof(buf), "%s/efreet", efreet_cache_home_get()); | ||
433 | if (!ecore_file_mkpath(buf)) | ||
434 | { | ||
435 | ERR("Failed to create directory '%s'\n", buf); | ||
436 | goto error; | ||
437 | } | ||
438 | |||
439 | cache_exe_del_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, | ||
440 | cache_exe_del_cb, NULL); | ||
441 | if (!cache_exe_del_handler) | ||
442 | { | ||
443 | ERR("Failed to add exe del handler\n"); | ||
444 | goto error; | ||
445 | } | ||
446 | cache_exe_data_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DATA, | ||
447 | cache_exe_data_cb, NULL); | ||
448 | if (!cache_exe_data_handler) | ||
449 | { | ||
450 | ERR("Failed to add exe del handler\n"); | ||
451 | goto error; | ||
452 | } | ||
453 | |||
454 | change_monitors = eina_hash_string_superfast_new(EINA_FREE_CB(ecore_file_monitor_del)); | ||
455 | |||
456 | efreet_cache_update = 0; | ||
457 | if (!efreet_init()) goto error; | ||
458 | |||
459 | read_extra(); | ||
460 | icon_changes_listen(); | ||
461 | desktop_changes_listen(); | ||
462 | cache_icon_update(); | ||
463 | cache_desktop_update(); | ||
464 | |||
465 | return EINA_TRUE; | ||
466 | error: | ||
467 | if (cache_exe_del_handler) ecore_event_handler_del(cache_exe_del_handler); | ||
468 | cache_exe_del_handler = NULL; | ||
469 | if (cache_exe_data_handler) ecore_event_handler_del(cache_exe_data_handler); | ||
470 | cache_exe_data_handler = NULL; | ||
471 | return EINA_FALSE; | ||
472 | } | ||
473 | |||
474 | Eina_Bool | ||
475 | cache_shutdown(void) | ||
476 | { | ||
477 | const char *data; | ||
478 | |||
479 | efreet_shutdown(); | ||
480 | |||
481 | if (cache_exe_del_handler) ecore_event_handler_del(cache_exe_del_handler); | ||
482 | cache_exe_del_handler = NULL; | ||
483 | if (cache_exe_data_handler) ecore_event_handler_del(cache_exe_data_handler); | ||
484 | cache_exe_data_handler = NULL; | ||
485 | |||
486 | if (change_monitors) | ||
487 | eina_hash_free(change_monitors); | ||
488 | EINA_LIST_FREE(desktop_extra_dirs, data) | ||
489 | eina_stringshare_del(data); | ||
490 | EINA_LIST_FREE(icon_extra_dirs, data) | ||
491 | eina_stringshare_del(data); | ||
492 | EINA_LIST_FREE(icon_extra_exts, data) | ||
493 | eina_stringshare_del(data); | ||
494 | return EINA_TRUE; | ||
495 | } | ||
diff --git a/legacy/efreet/src/bin/efreetd_cache.h b/legacy/efreet/src/bin/efreetd_cache.h new file mode 100644 index 0000000000..cfcadda50b --- /dev/null +++ b/legacy/efreet/src/bin/efreetd_cache.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef __EFREETD_CACHE_H | ||
2 | #define __EFREETD_CACHE_H | ||
3 | |||
4 | void cache_desktop_dir_add(const char *dir); | ||
5 | void cache_icon_dir_add(const char *dir); | ||
6 | void cache_icon_ext_add(const char *ext); | ||
7 | |||
8 | Eina_Bool cache_init(void); | ||
9 | Eina_Bool cache_shutdown(void); | ||
10 | |||
11 | #endif | ||
diff --git a/legacy/efreet/src/bin/efreetd_dbus.c b/legacy/efreet/src/bin/efreetd_dbus.c new file mode 100644 index 0000000000..1bac51875d --- /dev/null +++ b/legacy/efreet/src/bin/efreetd_dbus.c | |||
@@ -0,0 +1,184 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <EDBus.h> | ||
6 | |||
7 | #include "efreetd.h" | ||
8 | #include "efreetd_cache.h" | ||
9 | |||
10 | #define BUS "org.enlightenment" | ||
11 | #define PATH "/org/enlightenment" | ||
12 | #define INTERFACE "org.enlightenment.Efreet" | ||
13 | |||
14 | /* internal */ | ||
15 | enum | ||
16 | { | ||
17 | EFREET_SIGNAL_ICON_CACHE_UPDATE = 0, | ||
18 | EFREET_SIGNAL_DESKTOP_CACHE_UPDATE | ||
19 | }; | ||
20 | |||
21 | static EDBus_Connection *conn; | ||
22 | static EDBus_Service_Interface *iface; | ||
23 | |||
24 | static EDBus_Message * | ||
25 | ping(const EDBus_Service_Interface *ifc __UNUSED__, const EDBus_Message *message) | ||
26 | { | ||
27 | printf("ping\n"); | ||
28 | return edbus_message_method_return_new(message); | ||
29 | } | ||
30 | |||
31 | static EDBus_Message * | ||
32 | add_desktop_dirs(const EDBus_Service_Interface *ifc __UNUSED__, const EDBus_Message *message) | ||
33 | { | ||
34 | EDBus_Message_Iter *array = NULL; | ||
35 | const char *dir; | ||
36 | |||
37 | printf("Add desktop dirs\n"); | ||
38 | if (!edbus_message_arguments_get(message, "as", &array)) | ||
39 | { | ||
40 | ERR("Error getting arguments."); | ||
41 | return NULL; | ||
42 | } | ||
43 | |||
44 | while (edbus_message_iter_get_and_next(array, 's', &dir)) | ||
45 | { | ||
46 | cache_desktop_dir_add(dir); | ||
47 | } | ||
48 | |||
49 | return NULL; | ||
50 | } | ||
51 | |||
52 | static EDBus_Message * | ||
53 | add_icon_dirs(const EDBus_Service_Interface *ifc __UNUSED__, const EDBus_Message *message) | ||
54 | { | ||
55 | EDBus_Message_Iter *array = NULL; | ||
56 | const char *dir; | ||
57 | |||
58 | printf("Add icon dirs\n"); | ||
59 | if (!edbus_message_arguments_get(message, "as", &array)) | ||
60 | { | ||
61 | ERR("Error getting arguments."); | ||
62 | return NULL; | ||
63 | } | ||
64 | |||
65 | while (edbus_message_iter_get_and_next(array, 's', &dir)) | ||
66 | { | ||
67 | cache_icon_dir_add(dir); | ||
68 | } | ||
69 | |||
70 | return NULL; | ||
71 | } | ||
72 | |||
73 | static EDBus_Message * | ||
74 | add_icon_exts(const EDBus_Service_Interface *ifc __UNUSED__, const EDBus_Message *message) | ||
75 | { | ||
76 | EDBus_Message_Iter *array = NULL; | ||
77 | const char *ext; | ||
78 | |||
79 | printf("Add icon exts\n"); | ||
80 | if (!edbus_message_arguments_get(message, "as", &array)) | ||
81 | { | ||
82 | ERR("Error getting arguments."); | ||
83 | return NULL; | ||
84 | } | ||
85 | |||
86 | while (edbus_message_iter_get_and_next(array, 's', &ext)) | ||
87 | { | ||
88 | cache_icon_ext_add(ext); | ||
89 | } | ||
90 | |||
91 | return NULL; | ||
92 | } | ||
93 | |||
94 | static const EDBus_Signal signals[] = { | ||
95 | [EFREET_SIGNAL_ICON_CACHE_UPDATE] = {"IconCacheUpdate", EDBUS_ARGS({ "b", "update" }), 0}, | ||
96 | [EFREET_SIGNAL_DESKTOP_CACHE_UPDATE] = {"DesktopCacheUpdate", EDBUS_ARGS({ "b", "update" }), 0}, | ||
97 | { NULL, NULL, 0 } | ||
98 | }; | ||
99 | |||
100 | static const EDBus_Method methods[] = { | ||
101 | { | ||
102 | "Ping", NULL, NULL, | ||
103 | ping, 0 | ||
104 | }, | ||
105 | { | ||
106 | "AddDesktopDirs", NULL, EDBUS_ARGS({"as", "dirs"}), | ||
107 | add_desktop_dirs, EDBUS_METHOD_FLAG_NOREPLY | ||
108 | }, | ||
109 | { | ||
110 | "AddIconDirs", NULL, EDBUS_ARGS({"as", "dirs"}), | ||
111 | add_icon_dirs, EDBUS_METHOD_FLAG_NOREPLY | ||
112 | }, | ||
113 | { | ||
114 | "AddIconExts", NULL, EDBUS_ARGS({"as", "exts"}), | ||
115 | add_icon_exts, EDBUS_METHOD_FLAG_NOREPLY | ||
116 | }, | ||
117 | { NULL, NULL, NULL, NULL, 0 } | ||
118 | }; | ||
119 | |||
120 | static void | ||
121 | on_name_request(void *data __UNUSED__, const EDBus_Message *msg, EDBus_Pending *pending __UNUSED__) | ||
122 | { | ||
123 | unsigned int flag; | ||
124 | |||
125 | if (edbus_message_error_get(msg, NULL, NULL)) | ||
126 | { | ||
127 | ERR("error on on_name_request"); | ||
128 | return; | ||
129 | } | ||
130 | |||
131 | if (!edbus_message_arguments_get(msg, "u", &flag)) | ||
132 | { | ||
133 | ERR("error getting arguments on on_name_request"); | ||
134 | return; | ||
135 | } | ||
136 | |||
137 | if (!(flag & EDBUS_NAME_REQUEST_REPLY_PRIMARY_OWNER)) | ||
138 | { | ||
139 | ERR("error name already in use"); | ||
140 | return; | ||
141 | } | ||
142 | |||
143 | iface = edbus_service_interface_register(conn, PATH, INTERFACE, methods, | ||
144 | signals); | ||
145 | } | ||
146 | |||
147 | /* external */ | ||
148 | void | ||
149 | send_signal_icon_cache_update(Eina_Bool update) | ||
150 | { | ||
151 | edbus_service_signal_emit(iface, EFREET_SIGNAL_ICON_CACHE_UPDATE, update); | ||
152 | } | ||
153 | |||
154 | void | ||
155 | send_signal_desktop_cache_update(Eina_Bool update) | ||
156 | { | ||
157 | edbus_service_signal_emit(iface, EFREET_SIGNAL_DESKTOP_CACHE_UPDATE, update); | ||
158 | } | ||
159 | |||
160 | Eina_Bool | ||
161 | dbus_init(void) | ||
162 | { | ||
163 | if (!edbus_init()) return EINA_FALSE; | ||
164 | |||
165 | conn = edbus_connection_get(EDBUS_CONNECTION_TYPE_SESSION); | ||
166 | if (!conn) goto conn_error; | ||
167 | |||
168 | edbus_name_request(conn, BUS, EDBUS_NAME_REQUEST_FLAG_DO_NOT_QUEUE, | ||
169 | on_name_request, NULL); | ||
170 | |||
171 | return EINA_TRUE; | ||
172 | conn_error: | ||
173 | edbus_shutdown(); | ||
174 | return EINA_FALSE; | ||
175 | } | ||
176 | |||
177 | Eina_Bool | ||
178 | dbus_shutdown(void) | ||
179 | { | ||
180 | edbus_connection_unref(conn); | ||
181 | edbus_shutdown(); | ||
182 | return EINA_TRUE; | ||
183 | |||
184 | } | ||
diff --git a/legacy/efreet/src/bin/efreetd_dbus.h b/legacy/efreet/src/bin/efreetd_dbus.h new file mode 100644 index 0000000000..9e9fd70700 --- /dev/null +++ b/legacy/efreet/src/bin/efreetd_dbus.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef __EFREETD_DBUS_H | ||
2 | #define __EFREETD_DBUS_H | ||
3 | |||
4 | void send_signal_icon_cache_update(Eina_Bool update); | ||
5 | void send_signal_desktop_cache_update(Eina_Bool update); | ||
6 | |||
7 | Eina_Bool dbus_init(void); | ||
8 | Eina_Bool dbus_shutdown(void); | ||
9 | |||
10 | #endif | ||
diff --git a/legacy/efreet/src/lib/efreet_copy.h b/legacy/efreet/src/lib/efreet_copy.h new file mode 100644 index 0000000000..ccffa00bea --- /dev/null +++ b/legacy/efreet/src/lib/efreet_copy.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef __EFREET_COPY_H | ||
2 | #define __EFREET_COPY_H | ||
3 | |||
4 | /* functions copied from lib to reduce include size */ | ||
5 | |||
6 | const char *efreet_icon_deprecated_user_dir_get(void); | ||
7 | const char *efreet_icon_user_dir_get(void); | ||
8 | |||
9 | #endif | ||
10 | |||