From 8ae6c5183d4cd8e23e4e1c7714ad08db9e3ac4ab Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Wed, 21 Feb 2018 10:06:02 +0100 Subject: [PATCH] move from efl.vpath to eina_vpath The usages from efl.vpath are moved to to eina_vpath --- src/lib/ecore/ecore.c | 11 ---- src/lib/ecore_wl2/ecore_wl2_buffer.c | 10 ++-- src/lib/edje/edje_edit.c | 9 +--- src/lib/edje/edje_load.c | 9 +--- src/lib/efl/interfaces/efl_file.c | 14 +---- src/lib/efreet/efreet.c | 71 +++++++++++++++++++++++++ src/lib/efreet/efreet_base.c | 8 ++- src/lib/eina/eina_vpath.c | 1 - src/lib/elementary/elm_config.c | 12 ++--- src/lib/elementary/elm_main.c | 17 +----- src/lib/emotion/emotion_smart.c | 23 +------- src/modules/ecore_buffer/shm/ecore_buffer_shm.c | 6 +-- 12 files changed, 94 insertions(+), 97 deletions(-) diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c index a7b4025..d911bc4 100644 --- a/src/lib/ecore/ecore.c +++ b/src/lib/ecore/ecore.c @@ -122,8 +122,6 @@ static void _systemd_watchdog_cb(void *data, const Efl_Event *event); static Efl_Loop_Timer *_systemd_watchdog = NULL; #endif -static Efl_Vpath *vpath = NULL; - Eina_Lock _ecore_main_loop_lock; int _ecore_main_lock_count; @@ -279,9 +277,6 @@ ecore_init(void) _ecore_main_loop_init(); if (!_ecore_event_init()) goto shutdown_event; - vpath = efl_add(EFL_VPATH_CORE_CLASS, NULL); - if (vpath) efl_vpath_manager_register(EFL_VPATH_MANAGER_CLASS, 0, vpath); - _ecore_signal_init(); #ifndef HAVE_EXOTIC _ecore_exe_init(); @@ -451,12 +446,6 @@ ecore_shutdown(void) _ecore_main_shutdown(); _ecore_signal_shutdown(); - if (vpath) - { - efl_del(vpath); - vpath = NULL; - } - _ecore_main_loop_shutdown(); #if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO) diff --git a/src/lib/ecore_wl2/ecore_wl2_buffer.c b/src/lib/ecore_wl2/ecore_wl2_buffer.c index 50dca1b..a7cb174 100644 --- a/src/lib/ecore_wl2/ecore_wl2_buffer.c +++ b/src/lib/ecore_wl2/ecore_wl2_buffer.c @@ -310,15 +310,15 @@ err: static Buffer_Handle * _wl_shm_alloc(Buffer_Manager *self EINA_UNUSED, const char *name EINA_UNUSED, int w, int h, unsigned long *stride, int32_t *fd) { - Efl_Vpath_File *file_obj; Eina_Tmpstr *fullname; size_t size = w * h * 4; void *out = NULL; + char *tmp; + + tmp = eina_vpath_resolve("(:usr.run:)/evas-wayland_shm-XXXXXX"); + *fd = eina_file_mkstemp(tmp, &fullname); + free(tmp); - file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, - "(:run:)/evas-wayland_shm-XXXXXX"); - *fd = eina_file_mkstemp(efl_vpath_file_result_get(file_obj), &fullname); - efl_del(file_obj); if (*fd < 0) return NULL; unlink(fullname); diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c index 8edde57..d8bace9 100644 --- a/src/lib/edje/edje_edit.c +++ b/src/lib/edje/edje_edit.c @@ -256,16 +256,11 @@ _edje_edit_efl_file_file_set(Eo *obj, Edje_Edit *eed, const char *file, const ch * groups). * P.S. don't forget about mmap version below */ - Efl_Vpath_File *file_obj = - efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, file); - efl_vpath_file_do(file_obj); - // XXX:FIXME: allow this to be async - efl_vpath_file_wait(file_obj); - file = efl_vpath_file_result_get(file_obj); + file = eina_vpath_resolve(file); Eina_Bool int_ret; int_ret = efl_file_set(efl_super(obj, MY_CLASS), file, group); - efl_del(file_obj); + if (!int_ret) return EINA_FALSE; diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c index 7b04f63..6b227df 100644 --- a/src/lib/edje/edje_load.c +++ b/src/lib/edje/edje_load.c @@ -264,18 +264,13 @@ edje_file_collection_list(const char *file) Eina_List *lst; if ((!file) || (!*file)) return NULL; - Efl_Vpath_File *file_obj = - efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, file); - efl_vpath_file_do(file_obj); - // XXX:FIXME: allow this to be async - efl_vpath_file_wait(file_obj); - file = efl_vpath_file_result_get(file_obj); + file = eina_vpath_resolve(file); f = eina_file_open(file, EINA_FALSE); lst = edje_mmap_collection_list(f); eina_file_close(f); - efl_del(file_obj); + free(file); return lst; } diff --git a/src/lib/efl/interfaces/efl_file.c b/src/lib/efl/interfaces/efl_file.c index 562a06b..65060d8 100644 --- a/src/lib/efl/interfaces/efl_file.c +++ b/src/lib/efl/interfaces/efl_file.c @@ -7,8 +7,6 @@ typedef struct _Efl_File_Data Efl_File_Data; struct _Efl_File_Data { - Eo *vo; - Efl_Image_Load_Error error; }; @@ -22,11 +20,7 @@ _efl_file_file_set(Eo *obj, Efl_File_Data *pd, const char *file, const char *key if (file) { - pd->vo = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, file); - efl_vpath_file_do(pd->vo); - // XXX:FIXME: allow this to be async - efl_vpath_file_wait(pd->vo); - file = efl_vpath_file_result_get(pd->vo); + file = eina_vpath_resolve(file); } if (file) @@ -41,12 +35,8 @@ _efl_file_file_set(Eo *obj, Efl_File_Data *pd, const char *file, const char *key if (f) eina_file_close(f); on_error: - if (pd->vo && (!efl_vpath_file_keep_get(pd->vo))) - { - efl_del(pd->vo); - pd->vo = NULL; - } + free(file); return r; } diff --git a/src/lib/efreet/efreet.c b/src/lib/efreet/efreet.c index 091899f..1acbdbd 100644 --- a/src/lib/efreet/efreet.c +++ b/src/lib/efreet/efreet.c @@ -36,6 +36,74 @@ static uid_t ruid; static uid_t rgid; #endif +static void +_efreet_efreet_app_interface_set(void) +{ + char buf[PATH_MAX]; + char *s; + const char *home; + Eina_Vpath_Interface_User user; + + home = eina_vpath_resolve("(:home:)/"); + + memset(&user, 0, sizeof(Eina_Vpath_Interface_User)); + +# if defined(HAVE_GETUID) && defined(HAVE_GETEUID) +# define ENV_HOME_SET(_env, _dir, _meta) \ + if ((getuid() != geteuid()) || (!(s = getenv(_env)))) { \ + snprintf(buf, sizeof(buf), "%s/"_dir, home); \ + s = buf; \ + } \ + (&user)->_meta = s; +#else +# define ENV_HOME_SET(_env, _dir, _meta) \ + if (!(s = getenv(_env))) { \ + snprintf(buf, sizeof(buf), "%s/"_dir, home); \ + s = buf; \ + } \ + (&user)->_meta = s; +#endif + // $XDG_DESKTOP_DIR="$HOME/Desktop" + ENV_HOME_SET("XDG_DESKTOP_DIR", "Desktop", desktop); + // $XDG_DOCUMENTS_DIR="$HOME/Documents" + ENV_HOME_SET("XDG_DOCUMENTS_DIR", "Documents", documents); + // $XDG_DOWNLOAD_DIR="$HOME/Downloads" + ENV_HOME_SET("XDG_DOWNLOAD_DIR", "Downloads", downloads); + // $XDG_MUSIC_DIR="$HOME/Music" + ENV_HOME_SET("XDG_MUSIC_DIR", "Music", music); + // $XDG_PICTURES_DIR="$HOME/Pictures" + ENV_HOME_SET("XDG_PICTURES_DIR", "Pictures", pictures); + // $XDG_PUBLICSHARE_DIR="$HOME/Public" + ENV_HOME_SET("XDG_PUBLIC_DIR", "Public", pub); + // $XDG_TEMPLATES_DIR="$HOME/.Templates" + ENV_HOME_SET("XDG_TEMPLATES_DIR", ".Templates", templates); + // $XDG_VIDEOS_DIR="$HOME/Videos" + ENV_HOME_SET("XDG_VIDEOS_DIR", "Videos", videos); + // $XDG_DATA_HOME defines the base directory relative to which user + // specific data files should be stored. If $XDG_DATA_HOME is either + // not set or empty, a default equal to $HOME/.local/share should be + // used. + ENV_HOME_SET("XDG_DATA_HOME", ".local/share", data); + // $XDG_CONFIG_HOME defines the base directory relative to which user + // specific configuration files should be stored. If $XDG_CONFIG_HOME + // is either not set or empty, a default equal to $HOME/.config should + // be used. + ENV_HOME_SET("XDG_CONFIG_HOME", ".config", config); + // $XDG_CACHE_HOME defines the base directory relative to which + // user specific non-essential data files should be stored. If + // $XDG_CACHE_HOME is either not set or empty, a default equal to + // $HOME/.cache should be used. + ENV_HOME_SET("XDG_CACHE_HOME", ".cache", cache); + + if ((getuid() != geteuid()) || (!(s = getenv("XDG_RUNTIME_DIR")))) + user.run = NULL; + else + user.run = s; + + eina_vpath_interface_user_set(&user); +} + + EAPI int efreet_init(void) { @@ -70,6 +138,9 @@ efreet_init(void) if (!ecore_file_init()) goto shutdown_ecore; + //this needs to be early initializied efreet itself is using vpaths + _efreet_efreet_app_interface_set(); + if (!efreet_base_init()) goto shutdown_ecore_file; diff --git a/src/lib/efreet/efreet_base.c b/src/lib/efreet/efreet_base.c index 6381031..8b35285 100644 --- a/src/lib/efreet/efreet_base.c +++ b/src/lib/efreet/efreet_base.c @@ -279,7 +279,6 @@ efreet_dirs_reset(void) static void efreet_dirs_init(void) { - Efl_Vpath_File *file_obj; char buf[PATH_MAX]; /* efreet_home_dir */ @@ -309,10 +308,9 @@ efreet_dirs_init(void) #endif /* xdg_runtime_dir */ - file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, - "(:run:)/"); - xdg_runtime_dir = eina_stringshare_add(efl_vpath_file_result_get(file_obj)); - efl_del(file_obj); + char *tmp = eina_vpath_resolve("(:usr.run:)/"); + xdg_runtime_dir = eina_stringshare_add(tmp); + free(tmp); /* hostname */ if (gethostname(buf, sizeof(buf)) < 0) diff --git a/src/lib/eina/eina_vpath.c b/src/lib/eina/eina_vpath.c index af57afa..e744265 100644 --- a/src/lib/eina/eina_vpath.c +++ b/src/lib/eina/eina_vpath.c @@ -318,7 +318,6 @@ eina_vpath_interface_app_set(const char *app_domain, Eina_Prefix *app_pfx) EAPI void eina_vpath_interface_user_set(Eina_Vpath_Interface_User *user) { - char buf[PATH_MAX]; Eina_Bool free_run = EINA_FALSE; EINA_SAFETY_ON_NULL_RETURN(user); diff --git a/src/lib/elementary/elm_config.c b/src/lib/elementary/elm_config.c index 4d0cc83..38c55dc 100644 --- a/src/lib/elementary/elm_config.c +++ b/src/lib/elementary/elm_config.c @@ -694,7 +694,7 @@ _elm_config_user_dir_snprintf(char *dst, { size_t user_dir_len = 0, off = 0; va_list ap; - Efl_Vpath_File *file_obj; + char *tmp; static int use_xdg_config = -1; /************************************************************** @@ -722,14 +722,12 @@ _elm_config_user_dir_snprintf(char *dst, } if (use_xdg_config) - file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, - "(:config:)/elementary"); + tmp = eina_vpath_resolve("(:usr.config:)/elementary"); else - file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, - "(:home:)/"ELEMENTARY_BASE_DIR); + tmp = eina_vpath_resolve("(:home:)/elementary" ELEMENTARY_BASE_DIR); - eina_strlcpy(dst, efl_vpath_file_result_get(file_obj), size); - efl_del(file_obj); + eina_strlcpy(dst, tmp, size); + free(tmp); user_dir_len = strlen(dst); off = user_dir_len + 1; diff --git a/src/lib/elementary/elm_main.c b/src/lib/elementary/elm_main.c index 38f3e36..b0fe82c 100644 --- a/src/lib/elementary/elm_main.c +++ b/src/lib/elementary/elm_main.c @@ -171,7 +171,6 @@ _prefix_check(void) const char *dirs[4] = { NULL, NULL, NULL, NULL }; char *caps = NULL, *p1, *p2; char buf[PATH_MAX]; - Efl_Vpath_Core *vpath; if (app_pfx) return; if (!app_domain) return; @@ -203,21 +202,7 @@ _prefix_check(void) app_pfx = eina_prefix_new(argv[0], app_mainfunc, caps, app_domain, app_checkfile, dirs[0], dirs[1], dirs[2], dirs[3]); - vpath = efl_vpath_core_get(EFL_VPATH_CORE_CLASS); - efl_vpath_core_meta_set(vpath, "app.dir", eina_prefix_get(app_pfx)); - efl_vpath_core_meta_set(vpath, "app.bin", eina_prefix_bin_get(app_pfx)); - efl_vpath_core_meta_set(vpath, "app.lib", eina_prefix_lib_get(app_pfx)); - efl_vpath_core_meta_set(vpath, "app.data", eina_prefix_data_get(app_pfx)); - efl_vpath_core_meta_set(vpath, "app.locale", eina_prefix_locale_get(app_pfx)); - snprintf(buf, sizeof(buf), "%s/%s", - efl_vpath_core_meta_get(vpath, "config"), app_domain); - efl_vpath_core_meta_set(vpath, "app.config", buf); - snprintf(buf, sizeof(buf), "%s/%s", - efl_vpath_core_meta_get(vpath, "cache"), app_domain); - efl_vpath_core_meta_set(vpath, "app.cache", buf); - snprintf(buf, sizeof(buf), "%s/%s", - efl_vpath_core_meta_get(vpath, "data"), app_domain); - efl_vpath_core_meta_set(vpath, "app.local", buf); + eina_vpath_interface_app_set(app_domain, app_pfx); } static void diff --git a/src/lib/emotion/emotion_smart.c b/src/lib/emotion/emotion_smart.c index abcdc82..7e33a90 100644 --- a/src/lib/emotion/emotion_smart.c +++ b/src/lib/emotion/emotion_smart.c @@ -69,7 +69,6 @@ struct _Efl_Canvas_Video_Data Ecore_Job *job; - Efl_Vpath_File *file_obj; Emotion_Xattr_Data *xattr; const char *title; @@ -372,35 +371,17 @@ _efl_canvas_video_efl_file_file_set(Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data * _emotion_image_data_zero(sd->obj); sd->open = 0; - if (sd->file_obj) - { - efl_del(sd->file_obj); - sd->file_obj = NULL; - } if (file) { - sd->file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, file); - efl_vpath_file_do(sd->file_obj); - // XXX:FIXME: allow this to be async - efl_vpath_file_wait(sd->file_obj); - file2 = efl_vpath_file_result_get(sd->file_obj); + file2 = eina_vpath_resolve(file); } if (!emotion_engine_instance_file_open(sd->engine_instance, file2)) { WRN("Couldn't open file=%s", sd->file); - if (sd->file_obj) - { - efl_del(sd->file_obj); - sd->file_obj = NULL; - } return EINA_FALSE; } - if ((sd->file_obj) && (!efl_vpath_file_keep_get(sd->file_obj))) - { - efl_del(sd->file_obj); - sd->file_obj = NULL; - } + free(file2); DBG("successfully opened file=%s", sd->file); sd->pos = 0.0; if (sd->play) emotion_engine_instance_play(sd->engine_instance, 0.0); diff --git a/src/modules/ecore_buffer/shm/ecore_buffer_shm.c b/src/modules/ecore_buffer/shm/ecore_buffer_shm.c index 298225a..2d65a20 100644 --- a/src/modules/ecore_buffer/shm/ecore_buffer_shm.c +++ b/src/modules/ecore_buffer/shm/ecore_buffer_shm.c @@ -55,7 +55,6 @@ _ecore_buffer_shm_buffer_alloc(Ecore_Buffer_Module_Data bmdata, int width, int h Ecore_Buffer_Shm_Data* b; char *name; int fd, page_size; - Efl_Vpath_File *file_obj; page_size = eina_cpu_page_size(); @@ -68,10 +67,7 @@ _ecore_buffer_shm_buffer_alloc(Ecore_Buffer_Module_Data bmdata, int width, int h b->size = page_size * (((b->stride * b->h) + (page_size - 1)) / page_size); b->am_owner = EINA_TRUE; - file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, - "(:run:)/ecore-buffer-shared-XXXXXX"); - name = strdup(efl_vpath_file_result_get(file_obj)); - efl_del(file_obj); + name = eina_vpath_resolve("(:usr.run:)/ecore-buffer-shared-XXXXXX"); if (!name) goto err; fd = mkostemp(name, O_CLOEXEC); -- 2.7.4