forked from enlightenment/efl
Move all eet cache handling to efreet_cache.c
SVN revision: 56906
This commit is contained in:
parent
72ab08256a
commit
23c5801400
|
@ -66,3 +66,7 @@
|
||||||
* Remove EAPI from efreet_home_dir_get
|
* Remove EAPI from efreet_home_dir_get
|
||||||
* Make efreet_cache_icon_theme_free only used in efreet_cache.c static
|
* Make efreet_cache_icon_theme_free only used in efreet_cache.c static
|
||||||
* Move struct only used for cache to efreet_cache_private.h
|
* Move struct only used for cache to efreet_cache_private.h
|
||||||
|
|
||||||
|
2011-02-10 Sebastian Dransfeld
|
||||||
|
|
||||||
|
* Move all eet cache handling to efreet_cache.c
|
||||||
|
|
|
@ -77,11 +77,21 @@ static int desktop_cache_exe_lock = -1;
|
||||||
|
|
||||||
static Eina_List *old_desktop_caches = NULL;
|
static Eina_List *old_desktop_caches = NULL;
|
||||||
|
|
||||||
|
static const char *util_cache_file = NULL;
|
||||||
|
static Eet_File *util_cache = NULL;
|
||||||
|
static Efreet_Cache_Hash *util_cache_hash = NULL;
|
||||||
|
static const char *util_cache_hash_key = NULL;
|
||||||
|
static Efreet_Cache_Array_String *util_cache_names = NULL;
|
||||||
|
static const char *util_cache_names_key = NULL;
|
||||||
|
|
||||||
static void efreet_cache_edd_shutdown(void);
|
static void efreet_cache_edd_shutdown(void);
|
||||||
static void efreet_cache_icon_free(Efreet_Cache_Icon *icon);
|
static void efreet_cache_icon_free(Efreet_Cache_Icon *icon);
|
||||||
static void efreet_cache_icon_fallback_free(Efreet_Cache_Fallback_Icon *icon);
|
static void efreet_cache_icon_fallback_free(Efreet_Cache_Fallback_Icon *icon);
|
||||||
static void efreet_cache_icon_theme_free(Efreet_Icon_Theme *theme);
|
static void efreet_cache_icon_theme_free(Efreet_Icon_Theme *theme);
|
||||||
|
|
||||||
|
static Eina_Bool efreet_cache_check(Eet_File **ef, const char *path, int major);
|
||||||
|
static void *efreet_cache_close(Eet_File *ef);
|
||||||
|
|
||||||
static Eina_Bool cache_exe_cb(void *data, int type, void *event);
|
static Eina_Bool cache_exe_cb(void *data, int type, void *event);
|
||||||
static void cache_update_cb(void *data, Ecore_File_Monitor *em,
|
static void cache_update_cb(void *data, Ecore_File_Monitor *em,
|
||||||
Ecore_File_Event event, const char *path);
|
Ecore_File_Event event, const char *path);
|
||||||
|
@ -192,6 +202,21 @@ efreet_cache_shutdown(void)
|
||||||
free(d);
|
free(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IF_RELEASE(util_cache_names_key);
|
||||||
|
efreet_cache_array_string_free(util_cache_names);
|
||||||
|
util_cache_names = NULL;
|
||||||
|
|
||||||
|
IF_RELEASE(util_cache_hash_key);
|
||||||
|
if (util_cache_hash)
|
||||||
|
{
|
||||||
|
eina_hash_free(util_cache_hash->hash);
|
||||||
|
free(util_cache_hash);
|
||||||
|
util_cache_hash = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
util_cache = efreet_cache_close(util_cache);
|
||||||
|
IF_RELEASE(util_cache_file);
|
||||||
|
|
||||||
eina_log_domain_unregister(_efreet_cache_log_dom);
|
eina_log_domain_unregister(_efreet_cache_log_dom);
|
||||||
_efreet_cache_log_dom = -1;
|
_efreet_cache_log_dom = -1;
|
||||||
}
|
}
|
||||||
|
@ -229,6 +254,35 @@ efreet_icon_theme_cache_file(void)
|
||||||
return icon_theme_cache_file;
|
return icon_theme_cache_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Needs EAPI because of helper binaries
|
||||||
|
*/
|
||||||
|
EAPI const char *
|
||||||
|
efreet_desktop_util_cache_file(void)
|
||||||
|
{
|
||||||
|
char tmp[PATH_MAX] = { '\0' };
|
||||||
|
const char *cache_dir, *lang, *country, *modifier;
|
||||||
|
|
||||||
|
if (util_cache_file) return util_cache_file;
|
||||||
|
|
||||||
|
cache_dir = efreet_cache_home_get();
|
||||||
|
lang = efreet_lang_get();
|
||||||
|
country = efreet_lang_country_get();
|
||||||
|
modifier = efreet_lang_modifier_get();
|
||||||
|
|
||||||
|
if (lang && country && modifier)
|
||||||
|
snprintf(tmp, sizeof(tmp), "%s/efreet/desktop_util_%s_%s_%s@%s.eet", cache_dir, efreet_hostname_get(), lang, country, modifier);
|
||||||
|
else if (lang && country)
|
||||||
|
snprintf(tmp, sizeof(tmp), "%s/efreet/desktop_util_%s_%s_%s.eet", cache_dir, efreet_hostname_get(), lang, country);
|
||||||
|
else if (lang)
|
||||||
|
snprintf(tmp, sizeof(tmp), "%s/efreet/desktop_util_%s_%s.eet", cache_dir, efreet_hostname_get(), lang);
|
||||||
|
else
|
||||||
|
snprintf(tmp, sizeof(tmp), "%s/efreet/desktop_util_%s.eet", cache_dir, efreet_hostname_get());
|
||||||
|
|
||||||
|
util_cache_file = eina_stringshare_add(tmp);
|
||||||
|
return util_cache_file;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Needs EAPI because of helper binaries
|
* Needs EAPI because of helper binaries
|
||||||
*/
|
*/
|
||||||
|
@ -784,7 +838,7 @@ efreet_cache_icon_update(void)
|
||||||
icon_cache_job = ecore_job_add(icon_cache_update_cache_job, NULL);
|
icon_cache_job = ecore_job_add(icon_cache_update_cache_job, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Eina_Bool
|
static Eina_Bool
|
||||||
efreet_cache_check(Eet_File **ef, const char *path, int major)
|
efreet_cache_check(Eet_File **ef, const char *path, int major)
|
||||||
{
|
{
|
||||||
Efreet_Cache_Version *version;
|
Efreet_Cache_Version *version;
|
||||||
|
@ -811,7 +865,7 @@ efreet_cache_check(Eet_File **ef, const char *path, int major)
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
static void *
|
||||||
efreet_cache_close(Eet_File *ef)
|
efreet_cache_close(Eet_File *ef)
|
||||||
{
|
{
|
||||||
if (ef && ef != NON_EXISTING)
|
if (ef && ef != NON_EXISTING)
|
||||||
|
@ -819,6 +873,62 @@ efreet_cache_close(Eet_File *ef)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Efreet_Cache_Hash *
|
||||||
|
efreet_cache_util_hash_string(const char *key)
|
||||||
|
{
|
||||||
|
if (util_cache_hash_key && !strcmp(key, util_cache_hash_key))
|
||||||
|
return util_cache_hash;
|
||||||
|
if (!efreet_cache_check(&util_cache, efreet_desktop_util_cache_file(), EFREET_DESKTOP_UTILS_CACHE_MAJOR)) return NULL;
|
||||||
|
|
||||||
|
if (util_cache_hash)
|
||||||
|
{
|
||||||
|
/* free previous util_cache */
|
||||||
|
IF_RELEASE(util_cache_hash_key);
|
||||||
|
eina_hash_free(util_cache_hash->hash);
|
||||||
|
free(util_cache_hash);
|
||||||
|
}
|
||||||
|
util_cache_hash_key = eina_stringshare_add(key);
|
||||||
|
util_cache_hash = eet_data_read(util_cache, efreet_hash_string_edd(), key);
|
||||||
|
return util_cache_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
Efreet_Cache_Hash *
|
||||||
|
efreet_cache_util_hash_array_string(const char *key)
|
||||||
|
{
|
||||||
|
if (util_cache_hash_key && !strcmp(key, util_cache_hash_key))
|
||||||
|
return util_cache_hash;
|
||||||
|
if (!efreet_cache_check(&util_cache, efreet_desktop_util_cache_file(), EFREET_DESKTOP_UTILS_CACHE_MAJOR)) return NULL;
|
||||||
|
|
||||||
|
IF_RELEASE(util_cache_hash_key);
|
||||||
|
if (util_cache_hash)
|
||||||
|
{
|
||||||
|
/* free previous cache */
|
||||||
|
eina_hash_free(util_cache_hash->hash);
|
||||||
|
free(util_cache_hash);
|
||||||
|
}
|
||||||
|
util_cache_hash_key = eina_stringshare_add(key);
|
||||||
|
util_cache_hash = eet_data_read(util_cache, efreet_hash_array_string_edd(), key);
|
||||||
|
return util_cache_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
Efreet_Cache_Array_String *
|
||||||
|
efreet_cache_util_names(const char *key)
|
||||||
|
{
|
||||||
|
if (util_cache_names_key && !strcmp(key, util_cache_names_key))
|
||||||
|
return util_cache_names;
|
||||||
|
if (!efreet_cache_check(&util_cache, efreet_desktop_util_cache_file(), EFREET_DESKTOP_UTILS_CACHE_MAJOR)) return NULL;
|
||||||
|
|
||||||
|
if (util_cache_names)
|
||||||
|
{
|
||||||
|
/* free previous util_cache */
|
||||||
|
IF_RELEASE(util_cache_names_key);
|
||||||
|
efreet_cache_array_string_free(util_cache_names);
|
||||||
|
}
|
||||||
|
util_cache_names_key = eina_stringshare_add(key);
|
||||||
|
util_cache_names = eet_data_read(util_cache, efreet_array_string_edd(), key);
|
||||||
|
return util_cache_names;
|
||||||
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
cache_exe_cb(void *data __UNUSED__, int type __UNUSED__, void *event)
|
cache_exe_cb(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||||
{
|
{
|
||||||
|
@ -864,9 +974,12 @@ cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
|
||||||
{
|
{
|
||||||
ev = NEW(Efreet_Event_Cache_Update, 1);
|
ev = NEW(Efreet_Event_Cache_Update, 1);
|
||||||
if (!ev) goto error;
|
if (!ev) goto error;
|
||||||
|
|
||||||
|
IF_RELEASE(util_cache_names_key);
|
||||||
|
IF_RELEASE(util_cache_hash_key);
|
||||||
|
|
||||||
d = NEW(Efreet_Old_Cache, 1);
|
d = NEW(Efreet_Old_Cache, 1);
|
||||||
if (!d) goto error;
|
if (!d) goto error;
|
||||||
|
|
||||||
d->hash = efreet_desktop_cache;
|
d->hash = efreet_desktop_cache;
|
||||||
d->ef = desktop_cache;
|
d->ef = desktop_cache;
|
||||||
old_desktop_caches = eina_list_append(old_desktop_caches, d);
|
old_desktop_caches = eina_list_append(old_desktop_caches, d);
|
||||||
|
@ -874,7 +987,18 @@ cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
|
||||||
efreet_desktop_cache = eina_hash_string_superfast_new(NULL);
|
efreet_desktop_cache = eina_hash_string_superfast_new(NULL);
|
||||||
desktop_cache = NULL;
|
desktop_cache = NULL;
|
||||||
|
|
||||||
efreet_util_desktop_cache_reload();
|
efreet_cache_array_string_free(util_cache_names);
|
||||||
|
util_cache_names = NULL;
|
||||||
|
|
||||||
|
if (util_cache_hash)
|
||||||
|
{
|
||||||
|
eina_hash_free(util_cache_hash->hash);
|
||||||
|
free(util_cache_hash);
|
||||||
|
util_cache_hash = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
util_cache = efreet_cache_close(util_cache);
|
||||||
|
|
||||||
ecore_event_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE, ev, desktop_cache_update_free, d);
|
ecore_event_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE, ev, desktop_cache_update_free, d);
|
||||||
}
|
}
|
||||||
else if (!strcmp(file, "icon_data.update"))
|
else if (!strcmp(file, "icon_data.update"))
|
||||||
|
|
|
@ -1,11 +1,23 @@
|
||||||
#ifndef EFREET_CACHE_PRIVATE_H
|
#ifndef EFREET_CACHE_PRIVATE_H
|
||||||
#define EFREET_CACHE_PRIVATE_H
|
#define EFREET_CACHE_PRIVATE_H
|
||||||
|
|
||||||
|
#define EFREET_DESKTOP_CACHE_MAJOR 1
|
||||||
|
#define EFREET_DESKTOP_CACHE_MINOR 0
|
||||||
|
#define EFREET_DESKTOP_UTILS_CACHE_MAJOR 1
|
||||||
|
#define EFREET_DESKTOP_UTILS_CACHE_MINOR 0
|
||||||
|
|
||||||
|
#define EFREET_ICON_CACHE_MAJOR 1
|
||||||
|
#define EFREET_ICON_CACHE_MINOR 0
|
||||||
|
|
||||||
#define EFREET_CACHE_VERSION "__efreet//version"
|
#define EFREET_CACHE_VERSION "__efreet//version"
|
||||||
#define EFREET_CACHE_ICON_FALLBACK "__efreet_fallback"
|
#define EFREET_CACHE_ICON_FALLBACK "__efreet_fallback"
|
||||||
|
|
||||||
Eina_Bool efreet_cache_check(Eet_File **ef, const char *path, int major);
|
EAPI const char *efreet_desktop_util_cache_file(void);
|
||||||
void *efreet_cache_close(Eet_File *ef);
|
EAPI const char *efreet_desktop_cache_file(void);
|
||||||
|
EAPI const char *efreet_icon_cache_file(const char *theme);
|
||||||
|
EAPI const char *efreet_icon_theme_cache_file(void);
|
||||||
|
|
||||||
|
EAPI void efreet_cache_array_string_free(Efreet_Cache_Array_String *array);
|
||||||
|
|
||||||
EAPI Eet_Data_Descriptor *efreet_version_edd(void);
|
EAPI Eet_Data_Descriptor *efreet_version_edd(void);
|
||||||
EAPI Eet_Data_Descriptor *efreet_desktop_edd(void);
|
EAPI Eet_Data_Descriptor *efreet_desktop_edd(void);
|
||||||
|
|
|
@ -95,14 +95,6 @@
|
||||||
/* TODO: Move these to cache, make static and add accessor */
|
/* TODO: Move these to cache, make static and add accessor */
|
||||||
extern Eina_Hash *efreet_desktop_cache;
|
extern Eina_Hash *efreet_desktop_cache;
|
||||||
|
|
||||||
#define EFREET_DESKTOP_CACHE_MAJOR 1
|
|
||||||
#define EFREET_DESKTOP_CACHE_MINOR 0
|
|
||||||
#define EFREET_DESKTOP_UTILS_CACHE_MAJOR 1
|
|
||||||
#define EFREET_DESKTOP_UTILS_CACHE_MINOR 0
|
|
||||||
|
|
||||||
#define EFREET_ICON_CACHE_MAJOR 1
|
|
||||||
#define EFREET_ICON_CACHE_MINOR 0
|
|
||||||
|
|
||||||
typedef struct _Efreet_Cache_Icon Efreet_Cache_Icon;
|
typedef struct _Efreet_Cache_Icon Efreet_Cache_Icon;
|
||||||
typedef struct _Efreet_Cache_Icon_Element Efreet_Cache_Icon_Element;
|
typedef struct _Efreet_Cache_Icon_Element Efreet_Cache_Icon_Element;
|
||||||
typedef struct _Efreet_Cache_Fallback_Icon Efreet_Cache_Fallback_Icon;
|
typedef struct _Efreet_Cache_Fallback_Icon Efreet_Cache_Fallback_Icon;
|
||||||
|
@ -129,14 +121,7 @@ struct _Efreet_Cache_Icon_Element
|
||||||
|
|
||||||
struct _Efreet_Cache_Fallback_Icon
|
struct _Efreet_Cache_Fallback_Icon
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
const char *name;
|
|
||||||
#endif
|
|
||||||
const char *theme;
|
const char *theme;
|
||||||
#if 0
|
|
||||||
int context; /* the type of icon */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const char **icons;
|
const char **icons;
|
||||||
unsigned int icons_count;
|
unsigned int icons_count;
|
||||||
};
|
};
|
||||||
|
@ -195,25 +180,24 @@ size_t efreet_array_cat(char *buffer, size_t size, const char *strs[]);
|
||||||
|
|
||||||
const char *efreet_desktop_environment_get(void);
|
const char *efreet_desktop_environment_get(void);
|
||||||
|
|
||||||
void efreet_util_desktop_cache_reload(void);
|
/* TODO: Find the best placement for these */
|
||||||
EAPI const char *efreet_desktop_util_cache_file(void);
|
|
||||||
EAPI const char *efreet_desktop_cache_file(void);
|
|
||||||
EAPI const char *efreet_desktop_cache_dirs(void);
|
EAPI const char *efreet_desktop_cache_dirs(void);
|
||||||
int efreet_desktop_write_cache_dirs_file(void);
|
int efreet_desktop_write_cache_dirs_file(void);
|
||||||
|
|
||||||
void efreet_cache_desktop_update(void);
|
void efreet_cache_desktop_update(void);
|
||||||
void efreet_cache_icon_update(void);
|
void efreet_cache_icon_update(void);
|
||||||
void efreet_cache_desktop_free(Efreet_Desktop *desktop);
|
|
||||||
Efreet_Desktop *efreet_cache_desktop_find(const char *file);
|
|
||||||
|
|
||||||
EAPI const char *efreet_icon_cache_file(const char *theme);
|
Efreet_Desktop *efreet_cache_desktop_find(const char *file);
|
||||||
EAPI const char *efreet_icon_theme_cache_file(void);
|
void efreet_cache_desktop_free(Efreet_Desktop *desktop);
|
||||||
|
|
||||||
Efreet_Cache_Icon *efreet_cache_icon_find(Efreet_Icon_Theme *theme, const char *icon);
|
Efreet_Cache_Icon *efreet_cache_icon_find(Efreet_Icon_Theme *theme, const char *icon);
|
||||||
Efreet_Cache_Fallback_Icon *efreet_cache_icon_fallback_find(const char *icon);
|
Efreet_Cache_Fallback_Icon *efreet_cache_icon_fallback_find(const char *icon);
|
||||||
Efreet_Icon_Theme *efreet_cache_icon_theme_find(const char *theme);
|
Efreet_Icon_Theme *efreet_cache_icon_theme_find(const char *theme);
|
||||||
Eina_List *efreet_cache_icon_theme_list(void);
|
Eina_List *efreet_cache_icon_theme_list(void);
|
||||||
EAPI void efreet_cache_array_string_free(Efreet_Cache_Array_String *array);
|
|
||||||
|
Efreet_Cache_Hash *efreet_cache_util_hash_string(const char *key);
|
||||||
|
Efreet_Cache_Hash *efreet_cache_util_hash_array_string(const char *key);
|
||||||
|
Efreet_Cache_Array_String *efreet_cache_util_names(const char *key);
|
||||||
|
|
||||||
EAPI void efreet_hash_free(Eina_Hash *hash, Eina_Free_Cb free_cb);
|
EAPI void efreet_hash_free(Eina_Hash *hash, Eina_Free_Cb free_cb);
|
||||||
EAPI void efreet_setowner(const char *path);
|
EAPI void efreet_setowner(const char *path);
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* TODO: move eet file handling to eet_cache.c */
|
|
||||||
/* TODO: add no_display check, as we might want only displayable items */
|
/* TODO: add no_display check, as we might want only displayable items */
|
||||||
/* TODO: Consider flushing local cache after a idling a while */
|
/* TODO: Consider flushing local cache after a idling a while */
|
||||||
|
|
||||||
|
@ -31,7 +30,6 @@ void *alloca (size_t);
|
||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include <Eet.h>
|
|
||||||
#include <Ecore_File.h>
|
#include <Ecore_File.h>
|
||||||
|
|
||||||
/* define macros and variable for using the eina logging system */
|
/* define macros and variable for using the eina logging system */
|
||||||
|
@ -40,7 +38,6 @@ static int _efreet_utils_log_dom = -1;
|
||||||
|
|
||||||
#include "Efreet.h"
|
#include "Efreet.h"
|
||||||
#include "efreet_private.h"
|
#include "efreet_private.h"
|
||||||
#include "efreet_cache_private.h"
|
|
||||||
|
|
||||||
static char *efreet_util_path_in_default(const char *section, const char *path);
|
static char *efreet_util_path_in_default(const char *section, const char *path);
|
||||||
|
|
||||||
|
@ -52,17 +49,7 @@ static Efreet_Desktop *efreet_util_cache_find(const char *search, const char *wh
|
||||||
static Eina_List *efreet_util_cache_list(const char *search, const char *what);
|
static Eina_List *efreet_util_cache_list(const char *search, const char *what);
|
||||||
static Eina_List *efreet_util_cache_glob_list(const char *search, const char *what);
|
static Eina_List *efreet_util_cache_glob_list(const char *search, const char *what);
|
||||||
|
|
||||||
static Efreet_Cache_Hash *efreet_util_cache_hash(Eet_Data_Descriptor *edd, const char *key);
|
|
||||||
static Efreet_Cache_Array_String *efreet_util_cache_names(Eet_Data_Descriptor *edd, const char *key);
|
|
||||||
|
|
||||||
static Eina_Hash *file_id_by_desktop_path = NULL;
|
static Eina_Hash *file_id_by_desktop_path = NULL;
|
||||||
static const char *cache_file = NULL;
|
|
||||||
static Eet_File *cache = NULL;
|
|
||||||
|
|
||||||
static Efreet_Cache_Hash *cache_hash = NULL;
|
|
||||||
static const char *cache_hash_key = NULL;
|
|
||||||
static Efreet_Cache_Array_String *cache_names = NULL;
|
|
||||||
static const char *cache_names_key = NULL;
|
|
||||||
|
|
||||||
static int init = 0;
|
static int init = 0;
|
||||||
|
|
||||||
|
@ -92,53 +79,9 @@ efreet_util_shutdown(void)
|
||||||
_efreet_utils_log_dom = -1;
|
_efreet_utils_log_dom = -1;
|
||||||
IF_FREE_HASH(file_id_by_desktop_path);
|
IF_FREE_HASH(file_id_by_desktop_path);
|
||||||
|
|
||||||
IF_RELEASE(cache_names_key);
|
|
||||||
efreet_cache_array_string_free(cache_names);
|
|
||||||
cache_names = NULL;
|
|
||||||
|
|
||||||
IF_RELEASE(cache_hash_key);
|
|
||||||
if (cache_hash)
|
|
||||||
{
|
|
||||||
eina_hash_free(cache_hash->hash);
|
|
||||||
free(cache_hash);
|
|
||||||
cache_hash = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
cache = efreet_cache_close(cache);
|
|
||||||
IF_RELEASE(cache_file);
|
|
||||||
|
|
||||||
return init;
|
return init;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Needs EAPI because of helper binaries
|
|
||||||
*/
|
|
||||||
EAPI const char *
|
|
||||||
efreet_desktop_util_cache_file(void)
|
|
||||||
{
|
|
||||||
char tmp[PATH_MAX] = { '\0' };
|
|
||||||
const char *cache_dir, *lang, *country, *modifier;
|
|
||||||
|
|
||||||
if (cache_file) return cache_file;
|
|
||||||
|
|
||||||
cache_dir = efreet_cache_home_get();
|
|
||||||
lang = efreet_lang_get();
|
|
||||||
country = efreet_lang_country_get();
|
|
||||||
modifier = efreet_lang_modifier_get();
|
|
||||||
|
|
||||||
if (lang && country && modifier)
|
|
||||||
snprintf(tmp, sizeof(tmp), "%s/efreet/desktop_util_%s_%s_%s@%s.eet", cache_dir, efreet_hostname_get(), lang, country, modifier);
|
|
||||||
else if (lang && country)
|
|
||||||
snprintf(tmp, sizeof(tmp), "%s/efreet/desktop_util_%s_%s_%s.eet", cache_dir, efreet_hostname_get(), lang, country);
|
|
||||||
else if (lang)
|
|
||||||
snprintf(tmp, sizeof(tmp), "%s/efreet/desktop_util_%s_%s.eet", cache_dir, efreet_hostname_get(), lang);
|
|
||||||
else
|
|
||||||
snprintf(tmp, sizeof(tmp), "%s/efreet/desktop_util_%s.eet", cache_dir, efreet_hostname_get());
|
|
||||||
|
|
||||||
cache_file = eina_stringshare_add(tmp);
|
|
||||||
return cache_file;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
efreet_util_path_in_default(const char *section, const char *path)
|
efreet_util_path_in_default(const char *section, const char *path)
|
||||||
{
|
{
|
||||||
|
@ -256,9 +199,8 @@ efreet_util_desktop_file_id_find(const char *file_id)
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
if (!file_id) return NULL;
|
if (!file_id) return NULL;
|
||||||
if (!efreet_cache_check(&cache, efreet_desktop_util_cache_file(), EFREET_DESKTOP_UTILS_CACHE_MAJOR)) return NULL;
|
|
||||||
|
|
||||||
hash = efreet_util_cache_hash(efreet_hash_string_edd(), "file_id");
|
hash = efreet_cache_util_hash_string("file_id");
|
||||||
if (!hash) return NULL;
|
if (!hash) return NULL;
|
||||||
str = eina_hash_find(hash->hash, file_id);
|
str = eina_hash_find(hash->hash, file_id);
|
||||||
if (str)
|
if (str)
|
||||||
|
@ -282,10 +224,9 @@ efreet_util_desktop_exec_find(const char *exec)
|
||||||
Efreet_Cache_Array_String *names = NULL;
|
Efreet_Cache_Array_String *names = NULL;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (!efreet_cache_check(&cache, efreet_desktop_util_cache_file(), EFREET_DESKTOP_UTILS_CACHE_MAJOR)) return NULL;
|
|
||||||
if (!exec) return NULL;
|
if (!exec) return NULL;
|
||||||
|
|
||||||
names = efreet_util_cache_names(efreet_array_string_edd(), "exec_list");
|
names = efreet_cache_util_names("exec_list");
|
||||||
if (!names) return NULL;
|
if (!names) return NULL;
|
||||||
for (i = 0; i < names->array_count; i++)
|
for (i = 0; i < names->array_count; i++)
|
||||||
{
|
{
|
||||||
|
@ -306,7 +247,7 @@ efreet_util_desktop_exec_find(const char *exec)
|
||||||
free(exe);
|
free(exe);
|
||||||
|
|
||||||
if (!hash)
|
if (!hash)
|
||||||
hash = efreet_util_cache_hash(efreet_hash_array_string_edd(), "exec_hash");
|
hash = efreet_cache_util_hash_array_string("exec_hash");
|
||||||
if (!hash) return NULL;
|
if (!hash) return NULL;
|
||||||
array = eina_hash_find(hash->hash, names->array[i]);
|
array = eina_hash_find(hash->hash, names->array[i]);
|
||||||
if (!array) continue;
|
if (!array) continue;
|
||||||
|
@ -378,12 +319,11 @@ efreet_util_desktop_exec_glob_list(const char *glob)
|
||||||
Efreet_Cache_Array_String *names = NULL;
|
Efreet_Cache_Array_String *names = NULL;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (!efreet_cache_check(&cache, efreet_desktop_util_cache_file(), EFREET_DESKTOP_UTILS_CACHE_MAJOR)) return NULL;
|
|
||||||
if (!glob) return NULL;
|
if (!glob) return NULL;
|
||||||
if (!strcmp(glob, "*"))
|
if (!strcmp(glob, "*"))
|
||||||
glob = NULL;
|
glob = NULL;
|
||||||
|
|
||||||
names = efreet_util_cache_names(efreet_array_string_edd(), "exec_list");
|
names = efreet_cache_util_names("exec_list");
|
||||||
if (!names) return NULL;
|
if (!names) return NULL;
|
||||||
for (i = 0; i < names->array_count; i++)
|
for (i = 0; i < names->array_count; i++)
|
||||||
{
|
{
|
||||||
|
@ -402,7 +342,7 @@ efreet_util_desktop_exec_glob_list(const char *glob)
|
||||||
free(exe);
|
free(exe);
|
||||||
|
|
||||||
if (!hash)
|
if (!hash)
|
||||||
hash = efreet_util_cache_hash(efreet_hash_array_string_edd(), "exec_hash");
|
hash = efreet_cache_util_hash_array_string("exec_hash");
|
||||||
if (!hash) return NULL;
|
if (!hash) return NULL;
|
||||||
|
|
||||||
array = eina_hash_find(hash->hash, names->array[i]);
|
array = eina_hash_find(hash->hash, names->array[i]);
|
||||||
|
@ -458,9 +398,7 @@ efreet_util_desktop_categories_list(void)
|
||||||
Eina_List *ret = NULL;
|
Eina_List *ret = NULL;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (!efreet_cache_check(&cache, efreet_desktop_util_cache_file(), EFREET_DESKTOP_UTILS_CACHE_MAJOR)) return NULL;
|
array = efreet_cache_util_names("categories_list");
|
||||||
|
|
||||||
array = efreet_util_cache_names(efreet_array_string_edd(), "categories_list");
|
|
||||||
if (!array) return NULL;
|
if (!array) return NULL;
|
||||||
for (i = 0; i < array->array_count; i++)
|
for (i = 0; i < array->array_count; i++)
|
||||||
ret = eina_list_append(ret, array->array[i]);
|
ret = eina_list_append(ret, array->array[i]);
|
||||||
|
@ -549,11 +487,10 @@ efreet_util_cache_find(const char *search, const char *what1, const char *what2)
|
||||||
Efreet_Cache_Array_String *array = NULL;
|
Efreet_Cache_Array_String *array = NULL;
|
||||||
char key[256];
|
char key[256];
|
||||||
|
|
||||||
if (!efreet_cache_check(&cache, efreet_desktop_util_cache_file(), EFREET_DESKTOP_UTILS_CACHE_MAJOR)) return NULL;
|
|
||||||
if ((!what1) && (!what2)) return NULL;
|
if ((!what1) && (!what2)) return NULL;
|
||||||
|
|
||||||
snprintf(key, sizeof(key), "%s_hash", search);
|
snprintf(key, sizeof(key), "%s_hash", search);
|
||||||
hash = efreet_util_cache_hash(efreet_hash_array_string_edd(), key);
|
hash = efreet_cache_util_hash_array_string(key);
|
||||||
if (!hash) return NULL;
|
if (!hash) return NULL;
|
||||||
if (what1)
|
if (what1)
|
||||||
array = eina_hash_find(hash->hash, what1);
|
array = eina_hash_find(hash->hash, what1);
|
||||||
|
@ -579,11 +516,10 @@ efreet_util_cache_list(const char *search, const char *what)
|
||||||
Eina_List *ret = NULL;
|
Eina_List *ret = NULL;
|
||||||
char key[256];
|
char key[256];
|
||||||
|
|
||||||
if (!efreet_cache_check(&cache, efreet_desktop_util_cache_file(), EFREET_DESKTOP_UTILS_CACHE_MAJOR)) return NULL;
|
|
||||||
if (!what) return NULL;
|
if (!what) return NULL;
|
||||||
|
|
||||||
snprintf(key, sizeof(key), "%s_hash", search);
|
snprintf(key, sizeof(key), "%s_hash", search);
|
||||||
hash = efreet_util_cache_hash(efreet_hash_array_string_edd(), key);
|
hash = efreet_cache_util_hash_array_string(key);
|
||||||
if (!hash) return NULL;
|
if (!hash) return NULL;
|
||||||
array = eina_hash_find(hash->hash, what);
|
array = eina_hash_find(hash->hash, what);
|
||||||
if (array)
|
if (array)
|
||||||
|
@ -610,13 +546,12 @@ efreet_util_cache_glob_list(const char *search, const char *what)
|
||||||
char key[256];
|
char key[256];
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (!efreet_cache_check(&cache, efreet_desktop_util_cache_file(), EFREET_DESKTOP_UTILS_CACHE_MAJOR)) return NULL;
|
|
||||||
if (!what) return NULL;
|
if (!what) return NULL;
|
||||||
if (!strcmp(what, "*"))
|
if (!strcmp(what, "*"))
|
||||||
what = NULL;
|
what = NULL;
|
||||||
|
|
||||||
snprintf(key, sizeof(key), "%s_list", search);
|
snprintf(key, sizeof(key), "%s_list", search);
|
||||||
names = efreet_util_cache_names(efreet_array_string_edd(), key);
|
names = efreet_cache_util_names(key);
|
||||||
if (!names) return NULL;
|
if (!names) return NULL;
|
||||||
for (i = 0; i < names->array_count; i++)
|
for (i = 0; i < names->array_count; i++)
|
||||||
{
|
{
|
||||||
|
@ -629,7 +564,7 @@ efreet_util_cache_glob_list(const char *search, const char *what)
|
||||||
if (!hash)
|
if (!hash)
|
||||||
{
|
{
|
||||||
snprintf(key, sizeof(key), "%s_hash", search);
|
snprintf(key, sizeof(key), "%s_hash", search);
|
||||||
hash = efreet_util_cache_hash(efreet_hash_array_string_edd(), key);
|
hash = efreet_cache_util_hash_array_string(key);
|
||||||
}
|
}
|
||||||
if (!hash) return NULL;
|
if (!hash) return NULL;
|
||||||
|
|
||||||
|
@ -645,59 +580,6 @@ efreet_util_cache_glob_list(const char *search, const char *what)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Efreet_Cache_Hash *
|
|
||||||
efreet_util_cache_hash(Eet_Data_Descriptor *edd, const char *key)
|
|
||||||
{
|
|
||||||
if (cache_hash_key && !strcmp(key, cache_hash_key))
|
|
||||||
return cache_hash;
|
|
||||||
if (cache_hash)
|
|
||||||
{
|
|
||||||
/* free previous cache */
|
|
||||||
IF_RELEASE(cache_hash_key);
|
|
||||||
eina_hash_free(cache_hash->hash);
|
|
||||||
free(cache_hash);
|
|
||||||
}
|
|
||||||
cache_hash_key = eina_stringshare_add(key);
|
|
||||||
cache_hash = eet_data_read(cache, edd, key);
|
|
||||||
return cache_hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Efreet_Cache_Array_String *
|
|
||||||
efreet_util_cache_names(Eet_Data_Descriptor *edd, const char *key)
|
|
||||||
{
|
|
||||||
if (cache_names_key && !strcmp(key, cache_names_key))
|
|
||||||
return cache_names;
|
|
||||||
if (cache_names)
|
|
||||||
{
|
|
||||||
/* free previous cache */
|
|
||||||
IF_RELEASE(cache_names_key);
|
|
||||||
efreet_cache_array_string_free(cache_names);
|
|
||||||
}
|
|
||||||
cache_names_key = eina_stringshare_add(key);
|
|
||||||
cache_names = eet_data_read(cache, edd, key);
|
|
||||||
return cache_names;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
efreet_util_desktop_cache_reload(void)
|
|
||||||
{
|
|
||||||
if (cache_names)
|
|
||||||
{
|
|
||||||
IF_RELEASE(cache_names_key);
|
|
||||||
efreet_cache_array_string_free(cache_names);
|
|
||||||
cache_names = NULL;
|
|
||||||
}
|
|
||||||
if (cache_hash)
|
|
||||||
{
|
|
||||||
IF_RELEASE(cache_hash_key);
|
|
||||||
eina_hash_free(cache_hash->hash);
|
|
||||||
free(cache_hash);
|
|
||||||
cache_hash = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
cache = efreet_cache_close(cache);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Needs EAPI because of helper binaries
|
* Needs EAPI because of helper binaries
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue