summaryrefslogtreecommitdiff
path: root/src/lib/edje/edje_load.c
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@samsung.com>2013-11-01 10:58:33 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-11-01 11:01:18 +0900
commitcf452cc419b5c4449d0538a9638f79b898f10025 (patch)
treea64da8df69eed2a96e9684c944df43ce078918e3 /src/lib/edje/edje_load.c
parent8447e652c7db74c14b26486e5f222c420337cd2f (diff)
edje: make it possible for all upper layer function to query the exact same file.
With Eina_File we now can pass an efficient handler accross library boundary. Edje and all underlayer already use it to avoid race condition when setting an Edje object. Elementary and Enlightenment are still exposed to some potential race condition when an Edje file is modified underneath there feet. With the following set of function it should now be possible to avoid those race condition to: edje_mmap_data_get edje_mmap_collection_list edje_mmap_collection_list_free edje_mmap_group_exists
Diffstat (limited to '')
-rw-r--r--src/lib/edje/edje_load.c100
1 files changed, 70 insertions, 30 deletions
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index f69b59e829..d78fa68ad7 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -156,17 +156,13 @@ edje_load_error_str(Edje_Load_Error error)
156 } 156 }
157} 157}
158 158
159
160EAPI Eina_List * 159EAPI Eina_List *
161edje_file_collection_list(const char *file) 160edje_mmap_collection_list(Eina_File *f)
162{ 161{
163 Eina_List *lst = NULL; 162 Eina_List *lst = NULL;
164 Eina_File *f;
165 Edje_File *edf; 163 Edje_File *edf;
166 int error_ret = 0; 164 int error_ret = 0;
167 165
168 if ((!file) || (!*file)) return NULL;
169 f = eina_file_open(file, EINA_FALSE);
170 if (!f) return NULL; 166 if (!f) return NULL;
171 edf = _edje_cache_file_coll_open(f, NULL, &error_ret, NULL, NULL); 167 edf = _edje_cache_file_coll_open(f, NULL, &error_ret, NULL, NULL);
172 if (edf) 168 if (edf)
@@ -183,6 +179,21 @@ edje_file_collection_list(const char *file)
183 179
184 _edje_cache_file_unref(edf); 180 _edje_cache_file_unref(edf);
185 } 181 }
182
183 return lst;
184}
185
186EAPI Eina_List *
187edje_file_collection_list(const char *file)
188{
189 Eina_File *f;
190 Eina_List *lst;
191
192 if ((!file) || (!*file)) return NULL;
193 f = eina_file_open(file, EINA_FALSE);
194
195 lst = edje_mmap_collection_list(f);
196
186 eina_file_close(f); 197 eina_file_close(f);
187 return lst; 198 return lst;
188} 199}
@@ -197,24 +208,26 @@ edje_file_collection_list_free(Eina_List *lst)
197 } 208 }
198} 209}
199 210
211EAPI void
212edje_mmap_collection_list_free(Eina_List *lst)
213{
214 edje_file_collection_list_free(lst);
215}
216
200EAPI Eina_Bool 217EAPI Eina_Bool
201edje_file_group_exists(const char *file, const char *glob) 218edje_mmap_group_exists(Eina_File *f, const char *glob)
202{ 219{
203 Edje_File *edf; 220 Edje_File *edf;
204 Eina_File *f;
205 int error_ret = 0; 221 int error_ret = 0;
206 Eina_Bool succeed = EINA_FALSE; 222 Eina_Bool succeed = EINA_FALSE;
207 Eina_Bool is_glob = EINA_FALSE; 223 Eina_Bool is_glob = EINA_FALSE;
208 const char *p; 224 const char *p;
209 225
210 if ((!file) || (!*file) || (!glob)) 226 if ((!f) || (!glob))
211 return EINA_FALSE; 227 return EINA_FALSE;
212 228
213 f = eina_file_open(file, EINA_FALSE);
214 if (!f) return EINA_FALSE;
215
216 edf = _edje_cache_file_coll_open(f, NULL, &error_ret, NULL, NULL); 229 edf = _edje_cache_file_coll_open(f, NULL, &error_ret, NULL, NULL);
217 if (!edf) goto on_error; 230 if (!edf) return EINA_FALSE;
218 231
219 for (p = glob; *p; p++) 232 for (p = glob; *p; p++)
220 { 233 {
@@ -257,39 +270,66 @@ edje_file_group_exists(const char *file, const char *glob)
257 } 270 }
258 _edje_cache_file_unref(edf); 271 _edje_cache_file_unref(edf);
259 272
260 DBG("edje_file_group_exists: '%s', '%s': %i.", file, glob, succeed); 273 DBG("edje_file_group_exists: '%s', '%s': %i.", eina_file_filename_get(f), glob, succeed);
261 274
262 on_error:
263 eina_file_close(f);
264 return succeed; 275 return succeed;
265} 276}
266 277
278EAPI Eina_Bool
279edje_file_group_exists(const char *file, const char *glob)
280{
281 Eina_File *f;
282 Eina_Bool result;
283
284 if ((!file) || (!*file) || (!glob))
285 return EINA_FALSE;
286
287 f = eina_file_open(file, EINA_FALSE);
288 if (!f) return EINA_FALSE;
289
290 result = edje_mmap_group_exists(f, glob);
291
292 eina_file_close(f);
293
294 return result;
295}
267 296
268EAPI char * 297EAPI char *
269edje_file_data_get(const char *file, const char *key) 298edje_mmap_data_get(Eina_File *f, const char *key)
270{ 299{
271 Edje_File *edf; 300 Edje_File *edf;
272 Eina_File *f;
273 char *str = NULL; 301 char *str = NULL;
274 int error_ret = 0; 302 int error_ret = 0;
275 303
276 if (key) 304 if (!key) return NULL;
305
306 edf = _edje_cache_file_coll_open(f, NULL, &error_ret, NULL, NULL);
307 if (edf)
277 { 308 {
278 f = eina_file_open(file, EINA_FALSE); 309 str = (char*) edje_string_get(eina_hash_find(edf->data, key));
279 if (!f) return NULL;
280 310
281 edf = _edje_cache_file_coll_open(f, NULL, &error_ret, NULL, NULL); 311 if (str) str = strdup(str);
282 if (edf)
283 {
284 str = (char*) edje_string_get(eina_hash_find(edf->data, key));
285 312
286 if (str) str = strdup(str); 313 _edje_cache_file_unref(edf);
314 }
315 return str;
316}
287 317
288 _edje_cache_file_unref(edf); 318EAPI char *
289 } 319edje_file_data_get(const char *file, const char *key)
320{
321 Eina_File *f;
322 char *str;
323
324 if (!key) return NULL;
325
326 f = eina_file_open(file, EINA_FALSE);
327 if (!f) return NULL;
328
329 str = edje_mmap_data_get(f, key);
330
331 eina_file_close(f);
290 332
291 eina_file_close(f);
292 }
293 return str; 333 return str;
294} 334}
295 335