efreet.c | efreet.c | |||
---|---|---|---|---|
skipping to change at line 51 | skipping to change at line 51 | |||
EAPI int efreet_cache_update = 1; | EAPI int efreet_cache_update = 1; | |||
static int _efreet_init_count = 0; | static int _efreet_init_count = 0; | |||
static int efreet_parsed_locale = 0; | static int efreet_parsed_locale = 0; | |||
static const char *efreet_lang = NULL; | static const char *efreet_lang = NULL; | |||
static const char *efreet_lang_country = NULL; | static const char *efreet_lang_country = NULL; | |||
static const char *efreet_lang_modifier = NULL; | static const char *efreet_lang_modifier = NULL; | |||
static void efreet_parse_locale(void); | static void efreet_parse_locale(void); | |||
static int efreet_parse_locale_setting(const char *env); | static int efreet_parse_locale_setting(const char *env); | |||
#ifndef _WIN32 | ||||
static uid_t ruid; | static uid_t ruid; | |||
static uid_t rgid; | static uid_t rgid; | |||
#endif | ||||
EAPI int | EAPI int | |||
efreet_init(void) | efreet_init(void) | |||
{ | { | |||
#ifndef _WIN32 | ||||
char *tmp; | char *tmp; | |||
#endif | ||||
if (++_efreet_init_count != 1) | if (++_efreet_init_count != 1) | |||
return _efreet_init_count; | return _efreet_init_count; | |||
#ifndef _WIN32 | ||||
/* Find users real uid and gid */ | /* Find users real uid and gid */ | |||
tmp = getenv("SUDO_UID"); | tmp = getenv("SUDO_UID"); | |||
if (tmp) | if (tmp) | |||
ruid = strtoul(tmp, NULL, 10); | ruid = strtoul(tmp, NULL, 10); | |||
else | else | |||
ruid = getuid(); | ruid = getuid(); | |||
tmp = getenv("SUDO_GID"); | tmp = getenv("SUDO_GID"); | |||
if (tmp) | if (tmp) | |||
rgid = strtoul(tmp, NULL, 10); | rgid = strtoul(tmp, NULL, 10); | |||
else | else | |||
rgid = getgid(); | rgid = getgid(); | |||
#endif | ||||
if (!eina_init()) | if (!eina_init()) | |||
return --_efreet_init_count; | return --_efreet_init_count; | |||
if (!eet_init()) | if (!eet_init()) | |||
goto shutdown_eina; | goto shutdown_eina; | |||
if (!ecore_init()) | if (!ecore_init()) | |||
goto shutdown_eet; | goto shutdown_eet; | |||
if (!ecore_file_init()) | if (!ecore_file_init()) | |||
goto shutdown_ecore; | goto shutdown_ecore; | |||
skipping to change at line 108 | skipping to change at line 114 | |||
if (!efreet_desktop_init()) | if (!efreet_desktop_init()) | |||
goto shutdown_efreet_ini; | goto shutdown_efreet_ini; | |||
if (!efreet_menu_init()) | if (!efreet_menu_init()) | |||
goto shutdown_efreet_desktop; | goto shutdown_efreet_desktop; | |||
if (!efreet_util_init()) | if (!efreet_util_init()) | |||
goto shutdown_efreet_menu; | goto shutdown_efreet_menu; | |||
#ifdef ENABLE_NLS | ||||
bindtextdomain(PACKAGE, LOCALE_DIR); | ||||
bind_textdomain_codeset(PACKAGE, "UTF-8"); | ||||
#endif | ||||
return _efreet_init_count; | return _efreet_init_count; | |||
shutdown_efreet_menu: | shutdown_efreet_menu: | |||
efreet_menu_shutdown(); | efreet_menu_shutdown(); | |||
shutdown_efreet_desktop: | shutdown_efreet_desktop: | |||
efreet_desktop_shutdown(); | efreet_desktop_shutdown(); | |||
shutdown_efreet_ini: | shutdown_efreet_ini: | |||
efreet_ini_shutdown(); | efreet_ini_shutdown(); | |||
shutdown_efreet_icon: | shutdown_efreet_icon: | |||
efreet_icon_shutdown(); | efreet_icon_shutdown(); | |||
skipping to change at line 139 | skipping to change at line 150 | |||
eet_shutdown(); | eet_shutdown(); | |||
shutdown_eina: | shutdown_eina: | |||
eina_shutdown(); | eina_shutdown(); | |||
return --_efreet_init_count; | return --_efreet_init_count; | |||
} | } | |||
EAPI int | EAPI int | |||
efreet_shutdown(void) | efreet_shutdown(void) | |||
{ | { | |||
if (_efreet_init_count <= 0) | ||||
{ | ||||
EINA_LOG_ERR("Init count not greater than 0 in shutdown."); | ||||
return 0; | ||||
} | ||||
if (--_efreet_init_count != 0) | if (--_efreet_init_count != 0) | |||
return _efreet_init_count; | return _efreet_init_count; | |||
efreet_util_shutdown(); | efreet_util_shutdown(); | |||
efreet_menu_shutdown(); | efreet_menu_shutdown(); | |||
efreet_desktop_shutdown(); | efreet_desktop_shutdown(); | |||
efreet_ini_shutdown(); | efreet_ini_shutdown(); | |||
efreet_icon_shutdown(); | efreet_icon_shutdown(); | |||
efreet_xml_shutdown(); | efreet_xml_shutdown(); | |||
efreet_cache_shutdown(); | efreet_cache_shutdown(); | |||
skipping to change at line 164 | skipping to change at line 180 | |||
efreet_parsed_locale = 0; /* reset this in case they init efreet again */ | efreet_parsed_locale = 0; /* reset this in case they init efreet again */ | |||
ecore_file_shutdown(); | ecore_file_shutdown(); | |||
ecore_shutdown(); | ecore_shutdown(); | |||
eet_shutdown(); | eet_shutdown(); | |||
eina_shutdown(); | eina_shutdown(); | |||
return _efreet_init_count; | return _efreet_init_count; | |||
} | } | |||
/** | EAPI void | |||
efreet_lang_reset(void) | ||||
{ | ||||
IF_RELEASE(efreet_lang); | ||||
IF_RELEASE(efreet_lang_country); | ||||
IF_RELEASE(efreet_lang_modifier); | ||||
efreet_parsed_locale = 0; /* reset this in case they init efreet again | ||||
*/ | ||||
efreet_dirs_reset(); | ||||
efreet_cache_desktop_close(); | ||||
efreet_cache_desktop_update(); | ||||
} | ||||
/** | ||||
* @internal | * @internal | |||
* @return Returns the current users language setting or NULL if none set | * @return Returns the current users language setting or NULL if none set | |||
* @brief Retrieves the current language setting | * @brief Retrieves the current language setting | |||
*/ | */ | |||
const char * | const char * | |||
efreet_lang_get(void) | efreet_lang_get(void) | |||
{ | { | |||
if (efreet_parsed_locale) return efreet_lang; | if (efreet_parsed_locale) return efreet_lang; | |||
efreet_parse_locale(); | efreet_parse_locale(); | |||
skipping to change at line 218 | skipping to change at line 247 | |||
* @internal | * @internal | |||
* @return Returns no value | * @return Returns no value | |||
* @brief Parses out the language, country and modifer setting from the | * @brief Parses out the language, country and modifer setting from the | |||
* LC_MESSAGES environment variable | * LC_MESSAGES environment variable | |||
*/ | */ | |||
static void | static void | |||
efreet_parse_locale(void) | efreet_parse_locale(void) | |||
{ | { | |||
efreet_parsed_locale = 1; | efreet_parsed_locale = 1; | |||
if (efreet_parse_locale_setting("LC_ALL")) | if (efreet_parse_locale_setting("LANG")) | |||
return; | return; | |||
if (efreet_parse_locale_setting("LC_MESSAGES")) | if (efreet_parse_locale_setting("LC_ALL")) | |||
return; | return; | |||
efreet_parse_locale_setting("LANG"); | efreet_parse_locale_setting("LC_MESSAGES"); | |||
} | } | |||
/** | /** | |||
* @internal | * @internal | |||
* @param env The environment variable to grab | * @param env The environment variable to grab | |||
* @return Returns 1 if we parsed something of @a env, 0 otherwise | * @return Returns 1 if we parsed something of @a env, 0 otherwise | |||
* @brief Tries to parse the lang settings out of the given environment | * @brief Tries to parse the lang settings out of the given environment | |||
* variable | * variable | |||
*/ | */ | |||
static int | static int | |||
skipping to change at line 300 | skipping to change at line 329 | |||
{ | { | |||
int i; | int i; | |||
size_t n; | size_t n; | |||
for (i = 0, n = 0; n < size && strs[i]; i++) | for (i = 0, n = 0; n < size && strs[i]; i++) | |||
{ | { | |||
n += eina_strlcpy(buffer + n, strs[i], size - n); | n += eina_strlcpy(buffer + n, strs[i], size - n); | |||
} | } | |||
return n; | return n; | |||
} | } | |||
#ifndef _WIN32 | ||||
EAPI void | EAPI void | |||
efreet_fsetowner(int fd) | efreet_fsetowner(int fd) | |||
{ | { | |||
struct stat st; | struct stat st; | |||
if (fd < 0) return; | if (fd < 0) return; | |||
if (fstat(fd, &st) < 0) return; | if (fstat(fd, &st) < 0) return; | |||
if (st.st_uid == ruid) return; | if (st.st_uid == ruid) return; | |||
if (fchown(fd, ruid, rgid) != 0) return; | if (fchown(fd, ruid, rgid) != 0) return; | |||
} | } | |||
#else | ||||
EAPI void | ||||
efreet_fsetowner(int fd __UNUSED__) | ||||
{ | ||||
} | ||||
#endif | ||||
#ifndef _WIN32 | ||||
EAPI void | EAPI void | |||
efreet_setowner(const char *path) | efreet_setowner(const char *path) | |||
{ | { | |||
EINA_SAFETY_ON_NULL_RETURN(path); | ||||
int fd; | int fd; | |||
fd = open(path, O_RDONLY); | fd = open(path, O_RDONLY); | |||
if (fd < 0) return; | if (fd < 0) return; | |||
efreet_fsetowner(fd); | efreet_fsetowner(fd); | |||
close(fd); | close(fd); | |||
} | } | |||
#else | ||||
EAPI void | ||||
efreet_setowner(const char *path __UNUSED__) | ||||
{ | ||||
} | ||||
#endif | ||||
End of changes. 17 change blocks. | ||||
4 lines changed or deleted | 44 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |