summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2018-08-20 12:57:57 -0400
committerMike Blumenkrantz <zmike@samsung.com>2018-08-20 12:57:57 -0400
commit7968a0d0b979493774372fe07bcff0559233e8be (patch)
tree67fa9395cdafff487fd49e2d47d3671a60289bf4
parente31ce7b28711c43d37fb5d8469a236e6a17460ab (diff)
downloadefl-7968a0d0b979493774372fe07bcff0559233e8be.tar.gz
move efreet xdg envvars to eina
Summary: The contents of the XDG_ env vars are also usefull for eina subsystems, thus we should init those env vars here. Depends on D6751 Reviewers: zmike, stefan_schmidt, #committers Reviewed By: zmike, #committers Subscribers: #reviewers, cedric, #committers, zmike Tags: #efl Differential Revision: https://phab.enlightenment.org/D6744
-rw-r--r--src/Makefile_Eina.am3
-rw-r--r--src/lib/efreet/efreet.c78
-rw-r--r--src/lib/eina/eina_internal.h3
-rw-r--r--src/lib/eina/eina_vpath.c1
-rw-r--r--src/lib/eina/eina_vpath_xdg.c83
5 files changed, 89 insertions, 79 deletions
diff --git a/src/Makefile_Eina.am b/src/Makefile_Eina.am
index 997c5262dd..965bff34ae 100644
--- a/src/Makefile_Eina.am
+++ b/src/Makefile_Eina.am
@@ -185,7 +185,8 @@ lib/eina/eina_bezier.c \
lib/eina/eina_safepointer.c \
lib/eina/eina_freeq.c \
lib/eina/eina_slstr.c \
-lib/eina/eina_vpath.c
+lib/eina/eina_vpath.c \
+lib/eina/eina_vpath_xdg.c
if HAVE_WIN32
diff --git a/src/lib/efreet/efreet.c b/src/lib/efreet/efreet.c
index d17e1dabaf..091899f2b2 100644
--- a/src/lib/efreet/efreet.c
+++ b/src/lib/efreet/efreet.c
@@ -10,8 +10,6 @@
#include <Ecore.h>
#include <Ecore_File.h>
-#include "eina_internal.h"
-
/* define macros and variable for using the eina logging system */
#define EFREET_MODULE_LOG_DOM /* no logging in this file */
@@ -38,79 +36,6 @@ 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);
- ENV_HOME_SET("XDG_TMP_HOME", ".local/tmp", tmp);
- // $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 defined(HAVE_GETUID) && defined(HAVE_GETEUID)
- if ((getuid() != geteuid()) || (!(s = getenv("XDG_RUNTIME_DIR"))))
-#else
- if (!(s = getenv("XDG_RUNTIME_DIR")))
-#endif
- user.run = NULL;
- else
- user.run = s;
-
- eina_vpath_interface_user_set(&user);
-}
-
-
EAPI int
efreet_init(void)
{
@@ -145,9 +70,6 @@ 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/eina/eina_internal.h b/src/lib/eina/eina_internal.h
index 9fea25b1f0..9ae14df76b 100644
--- a/src/lib/eina/eina_internal.h
+++ b/src/lib/eina/eina_internal.h
@@ -99,6 +99,9 @@ EAPI void eina_vpath_interface_app_set(const char *app_name, Eina_Prefix *p);
*/
EAPI void eina_vpath_interface_user_set(Eina_Vpath_Interface_User *user);
+
+void eina_xdg_env_init(void);
+
#undef EAPI
#define EAPI
diff --git a/src/lib/eina/eina_vpath.c b/src/lib/eina/eina_vpath.c
index bc7c4d0045..b1b6af5284 100644
--- a/src/lib/eina/eina_vpath.c
+++ b/src/lib/eina/eina_vpath.c
@@ -175,6 +175,7 @@ eina_vpath_init(void)
vpath_data = eina_hash_string_superfast_new((Eina_Free_Cb)eina_stringshare_del);
_eina_vpath_interface_sys_init();
+ eina_xdg_env_init();
_eina_vpath_log_dom = eina_log_domain_register("vpath", "cyan");
return EINA_TRUE;
diff --git a/src/lib/eina/eina_vpath_xdg.c b/src/lib/eina/eina_vpath_xdg.c
new file mode 100644
index 0000000000..6a1d4d8248
--- /dev/null
+++ b/src/lib/eina/eina_vpath_xdg.c
@@ -0,0 +1,83 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <pwd.h>
+
+#include <Eina.h>
+
+#include "eina_internal.h"
+#include "eina_private.h"
+
+void
+eina_xdg_env_init(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);
+ ENV_HOME_SET("XDG_TMP_HOME", ".local/tmp", tmp);
+ // $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 defined(HAVE_GETUID) && defined(HAVE_GETEUID)
+ if ((getuid() != geteuid()) || (!(s = getenv("XDG_RUNTIME_DIR"))))
+#else
+ if (!(s = getenv("XDG_RUNTIME_DIR")))
+#endif
+ user.run = NULL;
+ else
+ user.run = s;
+
+ eina_vpath_interface_user_set(&user);
+}