summaryrefslogtreecommitdiff
path: root/src/lib/efreet
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel@osg.samsung.com>2018-02-21 10:06:02 +0100
committerMarcel Hollerbach <marcel@osg.samsung.com>2018-02-22 09:26:55 +0100
commitc4f33c67a8d75888b21a0f464b0b1c82bd55bd0b (patch)
tree2835fab56c775b14bca1ff1b0af859542557f4c9 /src/lib/efreet
parent7165003bc60177818a491db0d6a557dd0767554b (diff)
move from efl.vpath to eina_vpath
The usages from efl.vpath are moved to to eina_vpath
Diffstat (limited to 'src/lib/efreet')
-rw-r--r--src/lib/efreet/efreet.c71
-rw-r--r--src/lib/efreet/efreet_base.c8
2 files changed, 74 insertions, 5 deletions
diff --git a/src/lib/efreet/efreet.c b/src/lib/efreet/efreet.c
index 091899f2b2..1acbdbd8d7 100644
--- a/src/lib/efreet/efreet.c
+++ b/src/lib/efreet/efreet.c
@@ -36,6 +36,74 @@ static uid_t ruid;
36static uid_t rgid; 36static uid_t rgid;
37#endif 37#endif
38 38
39static void
40_efreet_efreet_app_interface_set(void)
41{
42 char buf[PATH_MAX];
43 char *s;
44 const char *home;
45 Eina_Vpath_Interface_User user;
46
47 home = eina_vpath_resolve("(:home:)/");
48
49 memset(&user, 0, sizeof(Eina_Vpath_Interface_User));
50
51# if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
52# define ENV_HOME_SET(_env, _dir, _meta) \
53 if ((getuid() != geteuid()) || (!(s = getenv(_env)))) { \
54 snprintf(buf, sizeof(buf), "%s/"_dir, home); \
55 s = buf; \
56 } \
57 (&user)->_meta = s;
58#else
59# define ENV_HOME_SET(_env, _dir, _meta) \
60 if (!(s = getenv(_env))) { \
61 snprintf(buf, sizeof(buf), "%s/"_dir, home); \
62 s = buf; \
63 } \
64 (&user)->_meta = s;
65#endif
66 // $XDG_DESKTOP_DIR="$HOME/Desktop"
67 ENV_HOME_SET("XDG_DESKTOP_DIR", "Desktop", desktop);
68 // $XDG_DOCUMENTS_DIR="$HOME/Documents"
69 ENV_HOME_SET("XDG_DOCUMENTS_DIR", "Documents", documents);
70 // $XDG_DOWNLOAD_DIR="$HOME/Downloads"
71 ENV_HOME_SET("XDG_DOWNLOAD_DIR", "Downloads", downloads);
72 // $XDG_MUSIC_DIR="$HOME/Music"
73 ENV_HOME_SET("XDG_MUSIC_DIR", "Music", music);
74 // $XDG_PICTURES_DIR="$HOME/Pictures"
75 ENV_HOME_SET("XDG_PICTURES_DIR", "Pictures", pictures);
76 // $XDG_PUBLICSHARE_DIR="$HOME/Public"
77 ENV_HOME_SET("XDG_PUBLIC_DIR", "Public", pub);
78 // $XDG_TEMPLATES_DIR="$HOME/.Templates"
79 ENV_HOME_SET("XDG_TEMPLATES_DIR", ".Templates", templates);
80 // $XDG_VIDEOS_DIR="$HOME/Videos"
81 ENV_HOME_SET("XDG_VIDEOS_DIR", "Videos", videos);
82 // $XDG_DATA_HOME defines the base directory relative to which user
83 // specific data files should be stored. If $XDG_DATA_HOME is either
84 // not set or empty, a default equal to $HOME/.local/share should be
85 // used.
86 ENV_HOME_SET("XDG_DATA_HOME", ".local/share", data);
87 // $XDG_CONFIG_HOME defines the base directory relative to which user
88 // specific configuration files should be stored. If $XDG_CONFIG_HOME
89 // is either not set or empty, a default equal to $HOME/.config should
90 // be used.
91 ENV_HOME_SET("XDG_CONFIG_HOME", ".config", config);
92 // $XDG_CACHE_HOME defines the base directory relative to which
93 // user specific non-essential data files should be stored. If
94 // $XDG_CACHE_HOME is either not set or empty, a default equal to
95 // $HOME/.cache should be used.
96 ENV_HOME_SET("XDG_CACHE_HOME", ".cache", cache);
97
98 if ((getuid() != geteuid()) || (!(s = getenv("XDG_RUNTIME_DIR"))))
99 user.run = NULL;
100 else
101 user.run = s;
102
103 eina_vpath_interface_user_set(&user);
104}
105
106
39EAPI int 107EAPI int
40efreet_init(void) 108efreet_init(void)
41{ 109{
@@ -70,6 +138,9 @@ efreet_init(void)
70 if (!ecore_file_init()) 138 if (!ecore_file_init())
71 goto shutdown_ecore; 139 goto shutdown_ecore;
72 140
141 //this needs to be early initializied efreet itself is using vpaths
142 _efreet_efreet_app_interface_set();
143
73 if (!efreet_base_init()) 144 if (!efreet_base_init())
74 goto shutdown_ecore_file; 145 goto shutdown_ecore_file;
75 146
diff --git a/src/lib/efreet/efreet_base.c b/src/lib/efreet/efreet_base.c
index 63810318f8..8b35285148 100644
--- a/src/lib/efreet/efreet_base.c
+++ b/src/lib/efreet/efreet_base.c
@@ -279,7 +279,6 @@ efreet_dirs_reset(void)
279static void 279static void
280efreet_dirs_init(void) 280efreet_dirs_init(void)
281{ 281{
282 Efl_Vpath_File *file_obj;
283 char buf[PATH_MAX]; 282 char buf[PATH_MAX];
284 283
285 /* efreet_home_dir */ 284 /* efreet_home_dir */
@@ -309,10 +308,9 @@ efreet_dirs_init(void)
309#endif 308#endif
310 309
311 /* xdg_runtime_dir */ 310 /* xdg_runtime_dir */
312 file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, 311 char *tmp = eina_vpath_resolve("(:usr.run:)/");
313 "(:run:)/"); 312 xdg_runtime_dir = eina_stringshare_add(tmp);
314 xdg_runtime_dir = eina_stringshare_add(efl_vpath_file_result_get(file_obj)); 313 free(tmp);
315 efl_del(file_obj);
316 314
317 /* hostname */ 315 /* hostname */
318 if (gethostname(buf, sizeof(buf)) < 0) 316 if (gethostname(buf, sizeof(buf)) < 0)