2010-11-15 13:07:22 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2011-02-01 13:03:40 -08:00
|
|
|
/* TODO: Consider flushing local icons cache after idling.
|
|
|
|
* Icon requests will probably come in batches, f.ex. during menu
|
|
|
|
* browsing.
|
2011-02-11 05:49:25 -08:00
|
|
|
* TODO: Retry closing desktop cache on dangling references.
|
2011-02-01 13:03:40 -08:00
|
|
|
*/
|
2011-01-31 03:44:56 -08:00
|
|
|
|
2011-02-10 06:25:23 -08:00
|
|
|
#include <libgen.h>
|
2010-11-22 06:16:09 -08:00
|
|
|
#include <unistd.h>
|
2010-11-23 12:14:13 -08:00
|
|
|
#include <fcntl.h>
|
2010-11-23 18:40:54 -08:00
|
|
|
#include <sys/stat.h>
|
2010-11-22 06:16:09 -08:00
|
|
|
|
2010-11-26 09:05:16 -08:00
|
|
|
#include <Eet.h>
|
|
|
|
#include <Ecore.h>
|
2010-11-25 15:52:57 -08:00
|
|
|
#include <Ecore_File.h>
|
|
|
|
|
2011-02-05 11:05:55 -08:00
|
|
|
/* define macros and variable for using the eina logging system */
|
|
|
|
#define EFREET_MODULE_LOG_DOM _efreet_cache_log_dom
|
|
|
|
static int _efreet_cache_log_dom = -1;
|
|
|
|
|
2010-11-15 13:07:22 -08:00
|
|
|
#include "Efreet.h"
|
|
|
|
#include "efreet_private.h"
|
2010-11-27 12:15:00 -08:00
|
|
|
#include "efreet_cache_private.h"
|
2010-11-15 13:07:22 -08:00
|
|
|
|
2011-02-10 06:34:03 -08:00
|
|
|
#define NON_EXISTING (void *)-1
|
|
|
|
|
2010-11-23 12:14:13 -08:00
|
|
|
typedef struct _Efreet_Old_Cache Efreet_Old_Cache;
|
|
|
|
|
|
|
|
struct _Efreet_Old_Cache
|
|
|
|
{
|
|
|
|
Eina_Hash *hash;
|
|
|
|
Eet_File *ef;
|
|
|
|
};
|
|
|
|
|
2010-11-15 13:07:22 -08:00
|
|
|
/**
|
|
|
|
* Data for cache files
|
|
|
|
*/
|
2010-11-29 05:17:33 -08:00
|
|
|
static Eet_Data_Descriptor *directory_edd = NULL;
|
2010-12-08 13:39:43 -08:00
|
|
|
static Eet_Data_Descriptor *icon_theme_edd = NULL;
|
|
|
|
static Eet_Data_Descriptor *icon_theme_directory_edd = NULL;
|
2010-11-26 06:56:23 -08:00
|
|
|
|
2010-12-08 13:39:43 -08:00
|
|
|
static Eet_Data_Descriptor *icon_fallback_edd = NULL;
|
|
|
|
static Eet_Data_Descriptor *icon_element_pointer_edd = NULL;
|
|
|
|
static Eet_Data_Descriptor *icon_element_edd = NULL;
|
|
|
|
static Eet_Data_Descriptor *icon_edd = NULL;
|
2010-11-26 06:56:23 -08:00
|
|
|
|
2010-12-03 01:55:36 -08:00
|
|
|
static Eet_File *icon_cache = NULL;
|
2011-01-31 03:44:56 -08:00
|
|
|
static Eet_File *fallback_cache = NULL;
|
2010-12-09 00:56:56 -08:00
|
|
|
static Eet_File *icon_theme_cache = NULL;
|
2010-11-15 13:07:22 -08:00
|
|
|
|
2011-02-09 09:09:16 -08:00
|
|
|
static Eina_Hash *themes = NULL;
|
2011-02-01 13:03:40 -08:00
|
|
|
static Eina_Hash *icons = NULL;
|
|
|
|
static Eina_Hash *fallbacks = NULL;
|
|
|
|
|
2010-12-08 13:39:43 -08:00
|
|
|
static const char *icon_theme_cache_file = NULL;
|
|
|
|
|
2010-11-26 06:56:23 -08:00
|
|
|
static const char *theme_name = NULL;
|
2010-11-22 06:16:09 -08:00
|
|
|
|
2010-12-03 01:55:36 -08:00
|
|
|
static Eet_Data_Descriptor *version_edd = NULL;
|
2010-11-23 12:14:13 -08:00
|
|
|
static Eet_Data_Descriptor *desktop_edd = NULL;
|
2011-01-31 03:32:34 -08:00
|
|
|
static Eet_Data_Descriptor *hash_array_string_edd = NULL;
|
|
|
|
static Eet_Data_Descriptor *array_string_edd = NULL;
|
|
|
|
static Eet_Data_Descriptor *hash_string_edd = NULL;
|
2010-11-23 12:14:13 -08:00
|
|
|
|
2011-02-10 06:25:44 -08:00
|
|
|
static Eina_Hash *desktops = NULL;
|
2011-02-10 06:25:23 -08:00
|
|
|
static Efreet_Cache_Array_String *desktop_dirs = NULL;
|
2011-02-28 02:50:27 -08:00
|
|
|
static Eina_List *desktop_dirs_add = NULL;
|
2010-11-23 12:14:13 -08:00
|
|
|
static Eet_File *desktop_cache = NULL;
|
|
|
|
static const char *desktop_cache_file = NULL;
|
2010-11-22 06:16:09 -08:00
|
|
|
|
2010-11-23 12:14:13 -08:00
|
|
|
static Ecore_File_Monitor *cache_monitor = NULL;
|
|
|
|
|
|
|
|
static Ecore_Event_Handler *cache_exe_handler = NULL;
|
2011-02-10 06:25:33 -08:00
|
|
|
static Ecore_Timer *icon_cache_timer = NULL;
|
2010-11-22 06:16:09 -08:00
|
|
|
static Ecore_Exe *icon_cache_exe = NULL;
|
|
|
|
static int icon_cache_exe_lock = -1;
|
2011-02-10 06:25:33 -08:00
|
|
|
static Ecore_Timer *desktop_cache_timer = NULL;
|
2010-11-23 12:14:13 -08:00
|
|
|
static Ecore_Exe *desktop_cache_exe = NULL;
|
|
|
|
static int desktop_cache_exe_lock = -1;
|
|
|
|
|
|
|
|
static Eina_List *old_desktop_caches = NULL;
|
2010-11-16 13:50:53 -08:00
|
|
|
|
2011-02-10 06:24:40 -08:00
|
|
|
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;
|
|
|
|
|
2010-12-02 00:32:59 -08:00
|
|
|
static void efreet_cache_edd_shutdown(void);
|
2011-02-01 13:03:40 -08:00
|
|
|
static void efreet_cache_icon_free(Efreet_Cache_Icon *icon);
|
|
|
|
static void efreet_cache_icon_fallback_free(Efreet_Cache_Fallback_Icon *icon);
|
2011-02-10 06:24:09 -08:00
|
|
|
static void efreet_cache_icon_theme_free(Efreet_Icon_Theme *theme);
|
2010-11-22 06:16:48 -08:00
|
|
|
|
2011-02-10 06:24:40 -08:00
|
|
|
static Eina_Bool efreet_cache_check(Eet_File **ef, const char *path, int major);
|
|
|
|
static void *efreet_cache_close(Eet_File *ef);
|
|
|
|
|
2010-11-23 12:14:13 -08:00
|
|
|
static Eina_Bool cache_exe_cb(void *data, int type, void *event);
|
|
|
|
static void cache_update_cb(void *data, Ecore_File_Monitor *em,
|
2010-11-27 12:36:39 -08:00
|
|
|
Ecore_File_Event event, const char *path);
|
2010-11-22 06:16:09 -08:00
|
|
|
|
2011-02-10 06:25:33 -08:00
|
|
|
static Eina_Bool desktop_cache_update_cache_cb(void *data);
|
|
|
|
static Eina_Bool icon_cache_update_cache_cb(void *data);
|
2010-11-23 12:14:13 -08:00
|
|
|
static void desktop_cache_update_free(void *data, void *ev);
|
2010-12-11 12:37:17 -08:00
|
|
|
static void icon_cache_update_free(void *data, void *ev);
|
2010-11-23 12:14:13 -08:00
|
|
|
|
2011-02-09 09:09:38 -08:00
|
|
|
static void *hash_array_string_add(void *hash, const char *key, void *data);
|
|
|
|
|
2011-02-28 02:50:27 -08:00
|
|
|
static int strcmplen(const void *data1, const void *data2);
|
|
|
|
|
2010-11-22 06:16:09 -08:00
|
|
|
EAPI int EFREET_EVENT_ICON_CACHE_UPDATE = 0;
|
2010-11-23 12:14:13 -08:00
|
|
|
EAPI int EFREET_EVENT_DESKTOP_CACHE_UPDATE = 0;
|
2010-11-15 13:07:22 -08:00
|
|
|
|
|
|
|
int
|
|
|
|
efreet_cache_init(void)
|
|
|
|
{
|
2010-11-22 06:16:09 -08:00
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
2010-11-26 06:56:23 -08:00
|
|
|
_efreet_cache_log_dom = eina_log_domain_register("efreet_cache", EFREET_DEFAULT_LOG_COLOR);
|
|
|
|
if (_efreet_cache_log_dom < 0)
|
|
|
|
return 0;
|
2010-11-22 06:16:09 -08:00
|
|
|
|
|
|
|
EFREET_EVENT_ICON_CACHE_UPDATE = ecore_event_type_new();
|
2010-11-23 12:14:13 -08:00
|
|
|
EFREET_EVENT_DESKTOP_CACHE_UPDATE = ecore_event_type_new();
|
2010-11-22 06:16:09 -08:00
|
|
|
|
2011-02-09 09:09:16 -08:00
|
|
|
themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_theme_free));
|
2011-02-01 13:03:40 -08:00
|
|
|
icons = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_free));
|
|
|
|
fallbacks = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_fallback_free));
|
2011-02-10 06:25:44 -08:00
|
|
|
desktops = eina_hash_string_superfast_new(NULL);
|
2011-02-01 13:03:40 -08:00
|
|
|
|
2010-12-04 08:02:20 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/efreet", efreet_cache_home_get());
|
2011-02-07 13:33:33 -08:00
|
|
|
if (!ecore_file_exists(buf))
|
|
|
|
{
|
|
|
|
if (!ecore_file_mkpath(buf)) goto error;
|
|
|
|
efreet_setowner(buf);
|
|
|
|
}
|
2010-11-22 06:16:09 -08:00
|
|
|
|
|
|
|
if (efreet_cache_update)
|
|
|
|
{
|
2010-11-23 12:14:13 -08:00
|
|
|
cache_exe_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
|
2010-11-27 12:36:39 -08:00
|
|
|
cache_exe_cb, NULL);
|
2010-11-23 12:14:13 -08:00
|
|
|
if (!cache_exe_handler) goto error;
|
2010-11-22 06:16:09 -08:00
|
|
|
|
2010-11-23 12:14:13 -08:00
|
|
|
cache_monitor = ecore_file_monitor_add(buf,
|
|
|
|
cache_update_cb,
|
2010-11-22 06:16:09 -08:00
|
|
|
NULL);
|
2010-11-23 12:14:13 -08:00
|
|
|
if (!cache_monitor) goto error;
|
2010-11-22 06:16:09 -08:00
|
|
|
|
2010-11-23 12:14:13 -08:00
|
|
|
efreet_cache_icon_update();
|
|
|
|
efreet_cache_desktop_update();
|
2010-11-22 06:16:09 -08:00
|
|
|
}
|
|
|
|
|
2010-11-15 13:07:22 -08:00
|
|
|
return 1;
|
2010-11-23 12:14:13 -08:00
|
|
|
error:
|
2011-02-10 06:24:50 -08:00
|
|
|
if (themes) eina_hash_free(themes);
|
|
|
|
themes = NULL;
|
|
|
|
if (icons) eina_hash_free(icons);
|
|
|
|
icons = NULL;
|
|
|
|
if (fallbacks) eina_hash_free(fallbacks);
|
|
|
|
fallbacks = NULL;
|
2011-02-10 06:25:44 -08:00
|
|
|
if (desktops) eina_hash_free(desktops);
|
|
|
|
desktops = NULL;
|
2011-02-10 06:24:50 -08:00
|
|
|
|
2010-11-23 12:14:13 -08:00
|
|
|
if (cache_exe_handler) ecore_event_handler_del(cache_exe_handler);
|
2010-11-23 13:15:55 -08:00
|
|
|
cache_exe_handler = NULL;
|
2010-11-23 12:14:13 -08:00
|
|
|
if (cache_monitor) ecore_file_monitor_del(cache_monitor);
|
2010-11-23 13:15:55 -08:00
|
|
|
cache_monitor = NULL;
|
2010-12-02 00:32:59 -08:00
|
|
|
efreet_cache_edd_shutdown();
|
2010-11-22 06:16:09 -08:00
|
|
|
return 0;
|
2010-11-15 13:07:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
efreet_cache_shutdown(void)
|
|
|
|
{
|
2010-11-23 12:14:13 -08:00
|
|
|
Efreet_Old_Cache *d;
|
2011-02-28 02:50:27 -08:00
|
|
|
void *data;
|
2010-11-23 12:14:13 -08:00
|
|
|
|
2010-12-12 14:17:05 -08:00
|
|
|
IF_RELEASE(theme_name);
|
2010-11-26 06:56:23 -08:00
|
|
|
|
2010-12-03 01:55:36 -08:00
|
|
|
icon_cache = efreet_cache_close(icon_cache);
|
2010-12-09 00:56:56 -08:00
|
|
|
icon_theme_cache = efreet_cache_close(icon_theme_cache);
|
2010-11-26 06:56:23 -08:00
|
|
|
|
2011-02-09 09:09:16 -08:00
|
|
|
IF_FREE_HASH(themes);
|
2011-02-01 13:03:40 -08:00
|
|
|
IF_FREE_HASH(icons);
|
|
|
|
IF_FREE_HASH(fallbacks);
|
|
|
|
|
2011-02-10 06:25:44 -08:00
|
|
|
IF_FREE_HASH_CB(desktops, EINA_FREE_CB(efreet_cache_desktop_free));
|
2011-02-10 06:25:23 -08:00
|
|
|
efreet_cache_array_string_free(desktop_dirs);
|
|
|
|
desktop_dirs = NULL;
|
2011-02-28 02:50:27 -08:00
|
|
|
EINA_LIST_FREE(desktop_dirs_add, data)
|
|
|
|
eina_stringshare_del(data);
|
2010-12-02 00:34:07 -08:00
|
|
|
desktop_cache = efreet_cache_close(desktop_cache);
|
2010-11-23 12:14:13 -08:00
|
|
|
IF_RELEASE(desktop_cache_file);
|
2010-11-22 06:16:09 -08:00
|
|
|
|
2010-11-23 12:14:13 -08:00
|
|
|
if (cache_exe_handler) ecore_event_handler_del(cache_exe_handler);
|
2010-11-23 13:15:55 -08:00
|
|
|
cache_exe_handler = NULL;
|
2010-11-23 12:14:13 -08:00
|
|
|
if (cache_monitor) ecore_file_monitor_del(cache_monitor);
|
2010-11-23 13:15:55 -08:00
|
|
|
cache_monitor = NULL;
|
2010-11-26 06:56:23 -08:00
|
|
|
|
2010-12-02 00:32:59 -08:00
|
|
|
efreet_cache_edd_shutdown();
|
2011-02-10 06:25:33 -08:00
|
|
|
if (desktop_cache_timer)
|
2010-11-23 12:14:13 -08:00
|
|
|
{
|
2011-02-10 06:25:33 -08:00
|
|
|
ecore_timer_del(desktop_cache_timer);
|
|
|
|
desktop_cache_timer = NULL;
|
2010-11-23 12:14:13 -08:00
|
|
|
}
|
2010-12-08 13:39:43 -08:00
|
|
|
IF_RELEASE(icon_theme_cache_file);
|
2010-11-23 12:14:13 -08:00
|
|
|
if (icon_cache_exe_lock > 0)
|
|
|
|
{
|
|
|
|
close(icon_cache_exe_lock);
|
|
|
|
icon_cache_exe_lock = -1;
|
|
|
|
}
|
2010-11-26 06:56:23 -08:00
|
|
|
|
2010-11-23 12:14:13 -08:00
|
|
|
if (desktop_cache_exe_lock > 0)
|
|
|
|
{
|
|
|
|
close(desktop_cache_exe_lock);
|
|
|
|
desktop_cache_exe_lock = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
EINA_LIST_FREE(old_desktop_caches, d)
|
|
|
|
{
|
|
|
|
eina_hash_free(d->hash);
|
|
|
|
free(d);
|
|
|
|
}
|
2010-11-26 06:56:23 -08:00
|
|
|
|
2011-02-10 06:24:40 -08:00
|
|
|
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);
|
|
|
|
|
2010-11-26 06:56:23 -08:00
|
|
|
eina_log_domain_unregister(_efreet_cache_log_dom);
|
2011-02-05 11:06:55 -08:00
|
|
|
_efreet_cache_log_dom = -1;
|
2010-11-15 13:07:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Needs EAPI because of helper binaries
|
|
|
|
*/
|
|
|
|
EAPI const char *
|
2011-01-31 03:44:56 -08:00
|
|
|
efreet_icon_cache_file(const char *theme)
|
2010-11-15 13:07:22 -08:00
|
|
|
{
|
|
|
|
static char cache_file[PATH_MAX] = { '\0' };
|
2010-12-04 08:02:20 -08:00
|
|
|
const char *cache;
|
2010-11-15 13:07:22 -08:00
|
|
|
|
2010-12-04 08:02:20 -08:00
|
|
|
cache = efreet_cache_home_get();
|
2010-11-15 13:07:22 -08:00
|
|
|
|
2011-01-31 03:44:56 -08:00
|
|
|
snprintf(cache_file, sizeof(cache_file), "%s/efreet/icons_%s_%s.eet", cache, theme, efreet_hostname_get());
|
2010-11-15 13:07:22 -08:00
|
|
|
|
|
|
|
return cache_file;
|
|
|
|
}
|
2010-12-08 13:39:43 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Needs EAPI because of helper binaries
|
|
|
|
*/
|
|
|
|
EAPI const char *
|
|
|
|
efreet_icon_theme_cache_file(void)
|
|
|
|
{
|
2010-12-09 05:41:22 -08:00
|
|
|
char tmp[PATH_MAX] = { '\0' };
|
2010-12-08 13:39:43 -08:00
|
|
|
|
|
|
|
if (icon_theme_cache_file) return icon_theme_cache_file;
|
|
|
|
|
2010-12-09 05:41:22 -08:00
|
|
|
snprintf(tmp, sizeof(tmp), "%s/efreet/icon_themes_%s.eet",
|
2010-12-08 13:39:43 -08:00
|
|
|
efreet_cache_home_get(), efreet_hostname_get());
|
|
|
|
icon_theme_cache_file = eina_stringshare_add(tmp);
|
|
|
|
|
|
|
|
return icon_theme_cache_file;
|
|
|
|
}
|
2010-11-15 13:07:22 -08:00
|
|
|
|
2011-02-10 06:24:40 -08:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2010-12-02 02:47:34 -08:00
|
|
|
/*
|
|
|
|
* Needs EAPI because of helper binaries
|
|
|
|
*/
|
|
|
|
EAPI Eet_Data_Descriptor *
|
|
|
|
efreet_version_edd(void)
|
|
|
|
{
|
|
|
|
Eet_Data_Descriptor_Class eddc;
|
|
|
|
|
2010-12-03 01:55:36 -08:00
|
|
|
if (version_edd) return version_edd;
|
2010-12-02 02:47:34 -08:00
|
|
|
|
|
|
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Version);
|
2010-12-03 01:55:36 -08:00
|
|
|
version_edd = eet_data_descriptor_file_new(&eddc);
|
|
|
|
if (!version_edd) return NULL;
|
2010-12-02 02:47:34 -08:00
|
|
|
|
2010-12-03 01:55:36 -08:00
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(version_edd, Efreet_Cache_Version,
|
2010-12-02 02:47:34 -08:00
|
|
|
"minor", minor, EET_T_UCHAR);
|
2010-12-03 01:55:36 -08:00
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(version_edd, Efreet_Cache_Version,
|
2010-12-02 02:47:34 -08:00
|
|
|
"major", major, EET_T_UCHAR);
|
|
|
|
|
2010-12-03 01:55:36 -08:00
|
|
|
return version_edd;
|
2010-12-02 02:47:34 -08:00
|
|
|
}
|
|
|
|
|
2011-01-31 03:32:34 -08:00
|
|
|
/*
|
|
|
|
* Needs EAPI because of helper binaries
|
|
|
|
*/
|
|
|
|
EAPI Eet_Data_Descriptor *
|
|
|
|
efreet_hash_array_string_edd(void)
|
|
|
|
{
|
|
|
|
Eet_Data_Descriptor_Class eddc;
|
|
|
|
|
|
|
|
if (hash_array_string_edd) return hash_array_string_edd;
|
|
|
|
|
|
|
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Hash);
|
2011-02-09 09:09:38 -08:00
|
|
|
eddc.func.hash_add = hash_array_string_add;
|
2011-01-31 03:32:34 -08:00
|
|
|
hash_array_string_edd = eet_data_descriptor_file_new(&eddc);
|
|
|
|
if (!hash_array_string_edd) return NULL;
|
|
|
|
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_HASH(hash_array_string_edd, Efreet_Cache_Hash,
|
|
|
|
"hash", hash, efreet_array_string_edd());
|
|
|
|
|
|
|
|
return hash_array_string_edd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Needs EAPI because of helper binaries
|
|
|
|
*/
|
|
|
|
EAPI Eet_Data_Descriptor *
|
|
|
|
efreet_hash_string_edd(void)
|
|
|
|
{
|
|
|
|
Eet_Data_Descriptor_Class eddc;
|
|
|
|
|
|
|
|
if (hash_string_edd) return hash_string_edd;
|
|
|
|
|
|
|
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Hash);
|
|
|
|
hash_string_edd = eet_data_descriptor_file_new(&eddc);
|
|
|
|
if (!hash_string_edd) return NULL;
|
|
|
|
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_HASH_STRING(hash_string_edd, Efreet_Cache_Hash,
|
|
|
|
"hash", hash);
|
|
|
|
|
|
|
|
return hash_string_edd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Needs EAPI because of helper binaries
|
|
|
|
*/
|
|
|
|
EAPI Eet_Data_Descriptor *
|
|
|
|
efreet_array_string_edd(void)
|
|
|
|
{
|
|
|
|
Eet_Data_Descriptor_Class eddc;
|
|
|
|
|
|
|
|
if (array_string_edd) return array_string_edd;
|
|
|
|
|
|
|
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Array_String);
|
|
|
|
array_string_edd = eet_data_descriptor_file_new(&eddc);
|
|
|
|
if (!array_string_edd) return NULL;
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY_STRING(array_string_edd, Efreet_Cache_Array_String,
|
|
|
|
"array", array);
|
|
|
|
|
|
|
|
return array_string_edd;
|
|
|
|
}
|
|
|
|
|
2010-11-23 12:14:13 -08:00
|
|
|
/*
|
|
|
|
* Needs EAPI because of helper binaries
|
|
|
|
*/
|
|
|
|
EAPI const char *
|
|
|
|
efreet_desktop_cache_file(void)
|
|
|
|
{
|
2010-12-09 05:41:22 -08:00
|
|
|
char tmp[PATH_MAX] = { '\0' };
|
2010-12-04 08:02:20 -08:00
|
|
|
const char *cache, *lang, *country, *modifier;
|
2010-11-23 12:14:13 -08:00
|
|
|
|
|
|
|
if (desktop_cache_file) return desktop_cache_file;
|
|
|
|
|
2010-12-04 08:02:20 -08:00
|
|
|
cache = efreet_cache_home_get();
|
2010-11-23 12:14:13 -08:00
|
|
|
lang = efreet_lang_get();
|
|
|
|
country = efreet_lang_country_get();
|
|
|
|
modifier = efreet_lang_modifier_get();
|
|
|
|
|
|
|
|
if (lang && country && modifier)
|
2010-12-09 05:41:22 -08:00
|
|
|
snprintf(tmp, sizeof(tmp), "%s/efreet/desktop_%s_%s_%s@%s.eet", cache, efreet_hostname_get(), lang, country, modifier);
|
2010-11-23 12:14:13 -08:00
|
|
|
else if (lang && country)
|
2010-12-09 05:41:22 -08:00
|
|
|
snprintf(tmp, sizeof(tmp), "%s/efreet/desktop_%s_%s_%s.eet", cache, efreet_hostname_get(), lang, country);
|
2010-11-23 12:14:13 -08:00
|
|
|
else if (lang)
|
2010-12-09 05:41:22 -08:00
|
|
|
snprintf(tmp, sizeof(tmp), "%s/efreet/desktop_%s_%s.eet", cache, efreet_hostname_get(), lang);
|
2010-11-23 12:14:13 -08:00
|
|
|
else
|
2010-12-09 05:41:22 -08:00
|
|
|
snprintf(tmp, sizeof(tmp), "%s/efreet/desktop_%s.eet", cache, efreet_hostname_get());
|
2010-11-23 12:14:13 -08:00
|
|
|
|
|
|
|
desktop_cache_file = eina_stringshare_add(tmp);
|
|
|
|
return desktop_cache_file;
|
|
|
|
}
|
|
|
|
|
2010-12-02 00:32:59 -08:00
|
|
|
#define EDD_SHUTDOWN(Edd) \
|
|
|
|
if (Edd) eet_data_descriptor_free(Edd); \
|
|
|
|
Edd = NULL;
|
|
|
|
|
|
|
|
static void
|
|
|
|
efreet_cache_edd_shutdown(void)
|
|
|
|
{
|
2010-12-03 01:55:36 -08:00
|
|
|
EDD_SHUTDOWN(version_edd);
|
2010-12-02 00:32:59 -08:00
|
|
|
EDD_SHUTDOWN(desktop_edd);
|
2011-01-31 03:32:34 -08:00
|
|
|
EDD_SHUTDOWN(hash_array_string_edd);
|
|
|
|
EDD_SHUTDOWN(array_string_edd);
|
|
|
|
EDD_SHUTDOWN(hash_string_edd);
|
2010-12-08 13:39:43 -08:00
|
|
|
EDD_SHUTDOWN(icon_theme_edd);
|
|
|
|
EDD_SHUTDOWN(icon_theme_directory_edd);
|
2010-12-02 00:32:59 -08:00
|
|
|
EDD_SHUTDOWN(directory_edd);
|
2010-12-08 13:39:43 -08:00
|
|
|
EDD_SHUTDOWN(icon_fallback_edd);
|
2010-12-02 00:32:59 -08:00
|
|
|
EDD_SHUTDOWN(icon_element_pointer_edd);
|
|
|
|
EDD_SHUTDOWN(icon_element_edd);
|
|
|
|
EDD_SHUTDOWN(icon_edd);
|
|
|
|
}
|
|
|
|
|
2010-11-26 06:56:23 -08:00
|
|
|
#define EFREET_POINTER_TYPE(Edd_Dest, Edd_Source, Type) \
|
2010-11-27 12:36:39 -08:00
|
|
|
{ \
|
|
|
|
typedef struct _Efreet_##Type##_Pointer Efreet_##Type##_Pointer; \
|
|
|
|
struct _Efreet_##Type##_Pointer \
|
|
|
|
{ \
|
2010-11-26 06:56:23 -08:00
|
|
|
Efreet_##Type *pointer; \
|
2010-11-27 12:36:39 -08:00
|
|
|
}; \
|
|
|
|
\
|
|
|
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_##Type##_Pointer); \
|
|
|
|
Edd_Dest = eet_data_descriptor_file_new(&eddc); \
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_SUB(Edd_Dest, Efreet_##Type##_Pointer, \
|
|
|
|
"pointer", pointer, Edd_Source); \
|
|
|
|
}
|
2010-11-26 06:56:23 -08:00
|
|
|
|
2010-11-29 05:17:33 -08:00
|
|
|
static Eet_Data_Descriptor *
|
|
|
|
efreet_icon_directory_edd(void)
|
|
|
|
{
|
2010-12-08 13:39:43 -08:00
|
|
|
Eet_Data_Descriptor_Class eddc;
|
2010-11-29 05:17:33 -08:00
|
|
|
|
2010-12-08 13:39:43 -08:00
|
|
|
if (directory_edd) return directory_edd;
|
2010-11-29 05:17:33 -08:00
|
|
|
|
2010-12-08 13:39:43 -08:00
|
|
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Directory);
|
|
|
|
directory_edd = eet_data_descriptor_file_new(&eddc);
|
|
|
|
if (!directory_edd) return NULL;
|
2010-11-29 05:17:33 -08:00
|
|
|
|
2010-12-08 13:39:43 -08:00
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(directory_edd, Efreet_Cache_Directory,
|
|
|
|
"modified_time", modified_time, EET_T_LONG_LONG);
|
2010-11-29 05:17:33 -08:00
|
|
|
|
2010-12-08 13:39:43 -08:00
|
|
|
return directory_edd;
|
2010-11-29 05:17:33 -08:00
|
|
|
}
|
|
|
|
|
2010-11-15 13:07:22 -08:00
|
|
|
/*
|
|
|
|
* Needs EAPI because of helper binaries
|
|
|
|
*/
|
|
|
|
EAPI Eet_Data_Descriptor *
|
2011-01-31 03:44:56 -08:00
|
|
|
efreet_icon_edd(void)
|
2010-11-15 13:07:22 -08:00
|
|
|
{
|
2010-11-27 12:36:39 -08:00
|
|
|
Eet_Data_Descriptor_Class eddc;
|
|
|
|
|
2011-01-31 03:44:56 -08:00
|
|
|
if (icon_edd) return icon_edd;
|
2010-11-27 12:36:39 -08:00
|
|
|
|
|
|
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Icon_Element);
|
|
|
|
icon_element_edd = eet_data_descriptor_file_new(&eddc);
|
|
|
|
if (!icon_element_edd) return NULL;
|
|
|
|
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_element_edd, Efreet_Cache_Icon_Element,
|
|
|
|
"type", type, EET_T_USHORT);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_element_edd, Efreet_Cache_Icon_Element,
|
|
|
|
"normal", normal, EET_T_USHORT);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_element_edd, Efreet_Cache_Icon_Element,
|
|
|
|
"normal", normal, EET_T_USHORT);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_element_edd, Efreet_Cache_Icon_Element,
|
|
|
|
"min", min, EET_T_USHORT);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_element_edd, Efreet_Cache_Icon_Element,
|
|
|
|
"max", max, EET_T_USHORT);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY_STRING(icon_element_edd, Efreet_Cache_Icon_Element,
|
|
|
|
"paths", paths);
|
|
|
|
|
|
|
|
EFREET_POINTER_TYPE(icon_element_pointer_edd, icon_element_edd, Cache_Icon_Element);
|
|
|
|
|
|
|
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Icon);
|
|
|
|
icon_edd = eet_data_descriptor_file_new(&eddc);
|
|
|
|
if (!icon_edd) return NULL;
|
|
|
|
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_edd, Efreet_Cache_Icon,
|
|
|
|
"theme", theme, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(icon_edd, Efreet_Cache_Icon,
|
|
|
|
"icons", icons, icon_element_pointer_edd);
|
|
|
|
|
2011-01-31 03:44:56 -08:00
|
|
|
return icon_edd;
|
2010-11-26 06:56:23 -08:00
|
|
|
}
|
2010-11-15 13:07:22 -08:00
|
|
|
|
2010-12-08 13:39:43 -08:00
|
|
|
/*
|
|
|
|
* Needs EAPI because of helper binaries
|
|
|
|
*/
|
|
|
|
EAPI Eet_Data_Descriptor *
|
2011-01-31 03:44:24 -08:00
|
|
|
efreet_icon_theme_edd(Eina_Bool cache)
|
2010-11-26 06:56:23 -08:00
|
|
|
{
|
2010-12-08 13:39:43 -08:00
|
|
|
Eet_Data_Descriptor_Class eddc;
|
2010-11-26 06:56:23 -08:00
|
|
|
|
2010-12-08 13:39:43 -08:00
|
|
|
if (icon_theme_edd) return icon_theme_edd;
|
|
|
|
|
|
|
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Icon_Theme_Directory);
|
|
|
|
icon_theme_directory_edd = eet_data_descriptor_file_new(&eddc);
|
|
|
|
if (!icon_theme_directory_edd) return NULL;
|
|
|
|
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_theme_directory_edd, Efreet_Icon_Theme_Directory,
|
|
|
|
"name", name, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_theme_directory_edd, Efreet_Icon_Theme_Directory,
|
|
|
|
"context", context, EET_T_UCHAR);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_theme_directory_edd, Efreet_Icon_Theme_Directory,
|
|
|
|
"type", type, EET_T_UCHAR);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_theme_directory_edd, Efreet_Icon_Theme_Directory,
|
|
|
|
"size.normal", size.normal, EET_T_UINT);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_theme_directory_edd, Efreet_Icon_Theme_Directory,
|
|
|
|
"size.min", size.min, EET_T_UINT);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_theme_directory_edd, Efreet_Icon_Theme_Directory,
|
|
|
|
"size.max", size.max, EET_T_UINT);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_theme_directory_edd, Efreet_Icon_Theme_Directory,
|
|
|
|
"size.threshold", size.threshold, EET_T_UINT);
|
|
|
|
|
2011-01-31 03:44:24 -08:00
|
|
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Icon_Theme);
|
2010-12-08 13:39:43 -08:00
|
|
|
icon_theme_edd = eet_data_descriptor_file_new(&eddc);
|
|
|
|
if (!icon_theme_edd) return NULL;
|
|
|
|
|
2011-01-31 03:44:24 -08:00
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_theme_edd, Efreet_Cache_Icon_Theme,
|
|
|
|
"name.internal", theme.name.internal, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_theme_edd, Efreet_Cache_Icon_Theme,
|
|
|
|
"name.name", theme.name.name, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_theme_edd, Efreet_Cache_Icon_Theme,
|
|
|
|
"comment", theme.comment, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_theme_edd, Efreet_Cache_Icon_Theme,
|
|
|
|
"example_icon", theme.example_icon, EET_T_STRING);
|
2010-12-08 13:39:43 -08:00
|
|
|
|
|
|
|
eet_data_descriptor_element_add(icon_theme_edd, "paths", EET_T_STRING, EET_G_LIST,
|
2011-01-31 03:44:24 -08:00
|
|
|
offsetof(Efreet_Cache_Icon_Theme, theme.paths), 0, NULL, NULL);
|
2010-12-08 13:39:43 -08:00
|
|
|
eet_data_descriptor_element_add(icon_theme_edd, "inherits", EET_T_STRING, EET_G_LIST,
|
2011-01-31 03:44:24 -08:00
|
|
|
offsetof(Efreet_Cache_Icon_Theme, theme.inherits), 0, NULL, NULL);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_LIST(icon_theme_edd, Efreet_Cache_Icon_Theme,
|
|
|
|
"directories", theme.directories, icon_theme_directory_edd);
|
2010-12-08 13:39:43 -08:00
|
|
|
|
2011-01-31 03:44:24 -08:00
|
|
|
if (cache)
|
|
|
|
{
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_theme_edd, Efreet_Cache_Icon_Theme,
|
|
|
|
"last_cache_check", last_cache_check, EET_T_LONG_LONG);
|
|
|
|
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(icon_theme_edd, Efreet_Cache_Icon_Theme,
|
|
|
|
"path", path, EET_T_STRING);
|
|
|
|
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_HASH(icon_theme_edd, Efreet_Cache_Icon_Theme,
|
|
|
|
"dirs", dirs, efreet_icon_directory_edd());
|
|
|
|
}
|
2010-12-08 13:39:43 -08:00
|
|
|
|
|
|
|
return icon_theme_edd;
|
2010-11-15 13:07:22 -08:00
|
|
|
}
|
|
|
|
|
2010-11-16 02:32:21 -08:00
|
|
|
/*
|
|
|
|
* Needs EAPI because of helper binaries
|
|
|
|
*/
|
|
|
|
EAPI Eet_Data_Descriptor *
|
2011-01-31 03:44:56 -08:00
|
|
|
efreet_icon_fallback_edd(void)
|
2010-11-16 02:32:21 -08:00
|
|
|
{
|
2010-11-27 12:36:39 -08:00
|
|
|
Eet_Data_Descriptor_Class eddc;
|
2010-11-16 02:32:21 -08:00
|
|
|
|
2011-01-31 03:44:56 -08:00
|
|
|
if (icon_fallback_edd) return icon_fallback_edd;
|
2010-11-16 02:32:21 -08:00
|
|
|
|
2010-11-27 12:36:39 -08:00
|
|
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Fallback_Icon);
|
|
|
|
icon_fallback_edd = eet_data_descriptor_file_new(&eddc);
|
|
|
|
if (!icon_fallback_edd) return NULL;
|
2010-11-26 06:56:23 -08:00
|
|
|
|
2010-11-27 12:36:39 -08:00
|
|
|
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY_STRING(icon_fallback_edd,
|
|
|
|
Efreet_Cache_Fallback_Icon, "icons", icons);
|
2010-11-26 06:56:23 -08:00
|
|
|
|
2011-01-31 03:44:56 -08:00
|
|
|
return icon_fallback_edd;
|
2010-11-16 02:32:21 -08:00
|
|
|
}
|
2010-11-15 13:07:22 -08:00
|
|
|
|
2010-11-23 12:14:13 -08:00
|
|
|
/*
|
|
|
|
* Needs EAPI because of helper binaries
|
|
|
|
*/
|
|
|
|
EAPI Eet_Data_Descriptor *
|
2010-12-02 00:32:22 -08:00
|
|
|
efreet_desktop_edd(void)
|
2010-11-23 12:14:13 -08:00
|
|
|
{
|
2010-11-27 12:36:39 -08:00
|
|
|
Eet_Data_Descriptor_Class eddc;
|
|
|
|
|
|
|
|
if (desktop_edd) return desktop_edd;
|
|
|
|
|
|
|
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Desktop);
|
|
|
|
desktop_edd = eet_data_descriptor_file_new(&eddc);
|
|
|
|
if (!desktop_edd) return NULL;
|
|
|
|
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "type", type, EET_T_INT);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "version", version, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "orig_path", orig_path, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "load_time", load_time, EET_T_LONG_LONG);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "name", name, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "generic_name", generic_name, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "comment", comment, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "icon", icon, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "try_exec", try_exec, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "exec", exec, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "path", path, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "startup_wm_class", startup_wm_class, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "url", url, EET_T_STRING);
|
|
|
|
eet_data_descriptor_element_add(desktop_edd, "only_show_in", EET_T_STRING, EET_G_LIST, offsetof(Efreet_Desktop, only_show_in), 0, NULL, NULL);
|
|
|
|
eet_data_descriptor_element_add(desktop_edd, "not_show_in", EET_T_STRING, EET_G_LIST, offsetof(Efreet_Desktop, not_show_in), 0, NULL, NULL);
|
|
|
|
eet_data_descriptor_element_add(desktop_edd, "categories", EET_T_STRING, EET_G_LIST, offsetof(Efreet_Desktop, categories), 0, NULL, NULL);
|
|
|
|
eet_data_descriptor_element_add(desktop_edd, "mime_types", EET_T_STRING, EET_G_LIST, offsetof(Efreet_Desktop, mime_types), 0, NULL, NULL);
|
|
|
|
eet_data_descriptor_element_add(desktop_edd, "x", EET_T_STRING, EET_G_HASH, offsetof(Efreet_Desktop, x), 0, NULL, NULL);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "no_display", no_display, EET_T_UCHAR);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "hidden", hidden, EET_T_UCHAR);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "terminal", terminal, EET_T_UCHAR);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(desktop_edd, Efreet_Desktop, "startup_notify", startup_notify, EET_T_UCHAR);
|
|
|
|
|
|
|
|
return desktop_edd;
|
2010-11-23 12:14:13 -08:00
|
|
|
}
|
|
|
|
|
2010-11-16 13:50:53 -08:00
|
|
|
Efreet_Cache_Icon *
|
|
|
|
efreet_cache_icon_find(Efreet_Icon_Theme *theme, const char *icon)
|
|
|
|
{
|
2011-02-01 13:03:40 -08:00
|
|
|
Efreet_Cache_Icon *cache = NULL;
|
|
|
|
|
2010-11-27 12:36:39 -08:00
|
|
|
if (theme_name && strcmp(theme_name, theme->name.internal))
|
|
|
|
{
|
2010-11-26 06:56:23 -08:00
|
|
|
/* FIXME: this is bad if people have pointer to this cache, things will go wrong */
|
2011-02-05 11:07:07 -08:00
|
|
|
INF("theme_name change from `%s` to `%s`", theme_name, theme->name.internal);
|
2010-12-12 14:17:05 -08:00
|
|
|
IF_RELEASE(theme_name);
|
2011-01-31 03:44:56 -08:00
|
|
|
icon_cache = efreet_cache_close(icon_cache);
|
2011-02-01 13:03:40 -08:00
|
|
|
eina_hash_free(icons);
|
|
|
|
icons = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_free));
|
2010-11-27 12:36:39 -08:00
|
|
|
}
|
2010-11-26 06:56:23 -08:00
|
|
|
|
2011-01-31 03:44:56 -08:00
|
|
|
if (!efreet_cache_check(&icon_cache, efreet_icon_cache_file(theme->name.internal), EFREET_ICON_CACHE_MAJOR)) return NULL;
|
2010-11-27 12:36:39 -08:00
|
|
|
if (!theme_name)
|
2011-01-31 03:44:56 -08:00
|
|
|
theme_name = eina_stringshare_add(theme->name.internal);
|
2010-11-26 06:56:23 -08:00
|
|
|
|
2011-02-01 13:03:40 -08:00
|
|
|
cache = eina_hash_find(icons, icon);
|
|
|
|
if (cache == NON_EXISTING) return NULL;
|
|
|
|
if (cache) return cache;
|
|
|
|
|
|
|
|
cache = eet_data_read(icon_cache, efreet_icon_edd(), icon);
|
|
|
|
if (cache)
|
|
|
|
eina_hash_add(icons, icon, cache);
|
|
|
|
else
|
|
|
|
eina_hash_add(icons, icon, NON_EXISTING);
|
|
|
|
return cache;
|
2010-11-16 13:50:53 -08:00
|
|
|
}
|
2010-11-22 06:16:09 -08:00
|
|
|
|
2010-11-26 06:56:23 -08:00
|
|
|
Efreet_Cache_Fallback_Icon *
|
2010-11-22 12:50:46 -08:00
|
|
|
efreet_cache_icon_fallback_find(const char *icon)
|
|
|
|
{
|
2011-02-01 13:03:40 -08:00
|
|
|
Efreet_Cache_Fallback_Icon *cache;
|
|
|
|
|
2011-01-31 03:44:56 -08:00
|
|
|
if (!efreet_cache_check(&fallback_cache, efreet_icon_cache_file(EFREET_CACHE_ICON_FALLBACK), EFREET_ICON_CACHE_MAJOR)) return NULL;
|
2010-11-26 06:56:23 -08:00
|
|
|
|
2011-02-01 13:03:40 -08:00
|
|
|
cache = eina_hash_find(fallbacks, icon);
|
|
|
|
if (cache == NON_EXISTING) return NULL;
|
|
|
|
if (cache) return cache;
|
|
|
|
|
|
|
|
cache = eet_data_read(fallback_cache, efreet_icon_fallback_edd(), icon);
|
|
|
|
if (cache)
|
|
|
|
eina_hash_add(fallbacks, icon, cache);
|
|
|
|
else
|
|
|
|
eina_hash_add(fallbacks, icon, NON_EXISTING);
|
|
|
|
return cache;
|
2010-11-22 12:50:46 -08:00
|
|
|
}
|
2010-12-09 00:56:56 -08:00
|
|
|
|
|
|
|
Efreet_Icon_Theme *
|
|
|
|
efreet_cache_icon_theme_find(const char *theme)
|
|
|
|
{
|
2011-02-09 09:09:16 -08:00
|
|
|
Efreet_Cache_Icon_Theme *cache;
|
|
|
|
|
2010-12-09 00:56:56 -08:00
|
|
|
if (!efreet_cache_check(&icon_theme_cache, efreet_icon_theme_cache_file(), EFREET_ICON_CACHE_MAJOR)) return NULL;
|
2011-02-09 09:09:16 -08:00
|
|
|
|
|
|
|
cache = eina_hash_find(themes, theme);
|
|
|
|
if (cache == NON_EXISTING) return NULL;
|
|
|
|
if (cache) return &(cache->theme);
|
|
|
|
|
|
|
|
cache = eet_data_read(icon_theme_cache, efreet_icon_theme_edd(EINA_FALSE), theme);
|
|
|
|
if (cache)
|
2011-02-09 10:36:12 -08:00
|
|
|
{
|
2011-02-09 09:09:16 -08:00
|
|
|
eina_hash_add(themes, theme, cache);
|
2011-02-09 10:36:12 -08:00
|
|
|
return &(cache->theme);
|
|
|
|
}
|
2011-02-09 09:09:16 -08:00
|
|
|
else
|
|
|
|
eina_hash_add(themes, theme, NON_EXISTING);
|
2011-02-09 10:36:12 -08:00
|
|
|
return NULL;
|
2010-12-09 00:56:56 -08:00
|
|
|
}
|
|
|
|
|
2011-02-10 06:24:20 -08:00
|
|
|
static void
|
|
|
|
efreet_cache_icon_free(Efreet_Cache_Icon *icon)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (!icon) return;
|
|
|
|
if (icon == NON_EXISTING) return;
|
|
|
|
|
|
|
|
for (i = 0; i < icon->icons_count; ++i)
|
|
|
|
{
|
|
|
|
free(icon->icons[i]->paths);
|
|
|
|
free(icon->icons[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(icon->icons);
|
|
|
|
free(icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
efreet_cache_icon_fallback_free(Efreet_Cache_Fallback_Icon *icon)
|
|
|
|
{
|
|
|
|
if (!icon) return;
|
|
|
|
if (icon == NON_EXISTING) return;
|
|
|
|
|
|
|
|
free(icon->icons);
|
|
|
|
free(icon);
|
|
|
|
}
|
|
|
|
|
2011-02-10 06:24:09 -08:00
|
|
|
static void
|
2010-12-09 00:56:56 -08:00
|
|
|
efreet_cache_icon_theme_free(Efreet_Icon_Theme *theme)
|
|
|
|
{
|
|
|
|
void *data;
|
|
|
|
|
|
|
|
if (!theme) return;
|
2011-02-09 09:09:16 -08:00
|
|
|
if (theme == NON_EXISTING) return;
|
2010-12-09 00:56:56 -08:00
|
|
|
|
|
|
|
eina_list_free(theme->paths);
|
|
|
|
eina_list_free(theme->inherits);
|
|
|
|
EINA_LIST_FREE(theme->directories, data)
|
|
|
|
free(data);
|
|
|
|
|
|
|
|
free(theme);
|
|
|
|
}
|
|
|
|
|
2011-02-09 09:09:16 -08:00
|
|
|
Eina_List *
|
|
|
|
efreet_cache_icon_theme_list(void)
|
2010-12-09 00:56:56 -08:00
|
|
|
{
|
2011-02-09 09:09:16 -08:00
|
|
|
Eina_List *ret = NULL;
|
2010-12-09 00:56:56 -08:00
|
|
|
char **keys;
|
2011-02-09 09:09:16 -08:00
|
|
|
int i, num;
|
2010-12-09 00:56:56 -08:00
|
|
|
|
|
|
|
if (!efreet_cache_check(&icon_theme_cache, efreet_icon_theme_cache_file(), EFREET_ICON_CACHE_MAJOR)) return NULL;
|
2011-02-09 09:09:16 -08:00
|
|
|
keys = eet_list(icon_theme_cache, "*", &num);
|
|
|
|
for (i = 0; i < num; i++)
|
2010-12-09 00:56:56 -08:00
|
|
|
{
|
2011-02-09 09:09:16 -08:00
|
|
|
Efreet_Icon_Theme *theme;
|
|
|
|
if (!strncmp(keys[i], "__efreet", 8)) continue;
|
2011-02-10 06:26:30 -08:00
|
|
|
|
|
|
|
theme = eina_hash_find(themes, keys[i]);
|
|
|
|
if (!theme)
|
|
|
|
theme = efreet_cache_icon_theme_find(keys[i]);
|
|
|
|
if (theme && theme != NON_EXISTING)
|
|
|
|
ret = eina_list_append(ret, theme);
|
2010-12-09 00:56:56 -08:00
|
|
|
}
|
2011-02-09 09:09:16 -08:00
|
|
|
free(keys);
|
|
|
|
return ret;
|
2010-12-09 00:56:56 -08:00
|
|
|
}
|
|
|
|
|
2011-02-07 13:19:36 -08:00
|
|
|
/*
|
|
|
|
* Needs EAPI because of helper binaries
|
|
|
|
*/
|
2011-01-31 03:32:34 -08:00
|
|
|
EAPI void
|
|
|
|
efreet_cache_array_string_free(Efreet_Cache_Array_String *array)
|
|
|
|
{
|
2011-02-02 14:57:34 -08:00
|
|
|
if (!array) return;
|
2011-01-31 03:32:34 -08:00
|
|
|
free(array->array);
|
|
|
|
free(array);
|
|
|
|
}
|
|
|
|
|
2010-11-23 12:14:13 -08:00
|
|
|
Efreet_Desktop *
|
|
|
|
efreet_cache_desktop_find(const char *file)
|
|
|
|
{
|
2011-02-10 06:25:44 -08:00
|
|
|
Efreet_Desktop *cache;
|
2010-11-23 12:14:13 -08:00
|
|
|
char rp[PATH_MAX];
|
|
|
|
|
|
|
|
if (!realpath(file, rp)) return NULL;
|
|
|
|
|
2010-12-02 00:34:07 -08:00
|
|
|
if (!efreet_cache_check(&desktop_cache, efreet_desktop_cache_file(), EFREET_DESKTOP_CACHE_MAJOR)) return NULL;
|
2010-11-23 12:14:13 -08:00
|
|
|
|
2011-02-10 06:25:44 -08:00
|
|
|
cache = eina_hash_find(desktops, rp);
|
|
|
|
if (cache == NON_EXISTING) return NULL;
|
|
|
|
if (cache) return cache;
|
|
|
|
|
|
|
|
cache = eet_data_read(desktop_cache, efreet_desktop_edd(), rp);
|
|
|
|
if (cache)
|
|
|
|
{
|
|
|
|
cache->eet = 1;
|
|
|
|
eina_hash_add(desktops, cache->orig_path, cache);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
eina_hash_add(desktops, rp, NON_EXISTING);
|
|
|
|
return cache;
|
2010-11-23 12:14:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
efreet_cache_desktop_free(Efreet_Desktop *desktop)
|
|
|
|
{
|
|
|
|
Efreet_Old_Cache *d;
|
|
|
|
Efreet_Desktop *curr;
|
|
|
|
Eina_List *l;
|
|
|
|
|
2011-02-10 06:25:44 -08:00
|
|
|
if (!desktop ||
|
|
|
|
desktop == NON_EXISTING ||
|
|
|
|
!desktop->eet) return;
|
|
|
|
|
|
|
|
curr = eina_hash_find(desktops, desktop->orig_path);
|
|
|
|
if (curr == desktop)
|
|
|
|
eina_hash_del_by_key(desktops, desktop->orig_path);
|
2010-11-23 12:14:13 -08:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(old_desktop_caches, l, d)
|
|
|
|
{
|
|
|
|
curr = eina_hash_find(d->hash, desktop->orig_path);
|
|
|
|
if (curr && curr == desktop)
|
|
|
|
{
|
|
|
|
eina_hash_del_by_key(d->hash, desktop->orig_path);
|
|
|
|
if (eina_hash_population(d->hash) == 0)
|
|
|
|
{
|
|
|
|
eina_hash_free(d->hash);
|
|
|
|
d->hash = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-02-10 06:25:44 -08:00
|
|
|
|
|
|
|
eina_list_free(desktop->only_show_in);
|
|
|
|
eina_list_free(desktop->not_show_in);
|
|
|
|
eina_list_free(desktop->categories);
|
|
|
|
eina_list_free(desktop->mime_types);
|
|
|
|
IF_FREE_HASH(desktop->x);
|
|
|
|
free(desktop);
|
2010-11-23 12:14:13 -08:00
|
|
|
}
|
|
|
|
|
2011-02-10 06:25:23 -08:00
|
|
|
void
|
|
|
|
efreet_cache_desktop_add(Efreet_Desktop *desktop)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
2011-02-28 02:50:27 -08:00
|
|
|
char *dir;
|
2011-02-10 06:25:23 -08:00
|
|
|
Efreet_Cache_Array_String *arr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read file from disk, save path in cache so it will be included in next
|
|
|
|
* cache update
|
|
|
|
*/
|
|
|
|
strncpy(buf, desktop->orig_path, PATH_MAX);
|
|
|
|
buf[PATH_MAX - 1] = '\0';
|
2011-02-28 02:50:27 -08:00
|
|
|
dir = dirname(buf);
|
2011-02-10 06:25:23 -08:00
|
|
|
arr = efreet_cache_desktop_dirs();
|
|
|
|
if (arr)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < arr->array_count; i++)
|
|
|
|
{
|
|
|
|
/* Check if we already have this dir in cache */
|
2011-02-28 02:50:27 -08:00
|
|
|
if (!strncmp(dir, arr->array[i], strlen(arr->array[i])))
|
2011-02-10 06:25:23 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-02-28 02:50:27 -08:00
|
|
|
if (!eina_list_search_unsorted_list(desktop_dirs_add, strcmplen, dir))
|
|
|
|
desktop_dirs_add = eina_list_append(desktop_dirs_add, eina_stringshare_add(dir));
|
2011-02-10 06:25:23 -08:00
|
|
|
|
|
|
|
efreet_cache_desktop_update();
|
|
|
|
}
|
|
|
|
|
|
|
|
Efreet_Cache_Array_String *
|
|
|
|
efreet_cache_desktop_dirs(void)
|
|
|
|
{
|
|
|
|
if (desktop_dirs) return desktop_dirs;
|
|
|
|
|
|
|
|
if (!efreet_cache_check(&desktop_cache, efreet_desktop_cache_file(), EFREET_DESKTOP_CACHE_MAJOR)) return NULL;
|
|
|
|
|
|
|
|
desktop_dirs = eet_data_read(desktop_cache, efreet_array_string_edd(), EFREET_CACHE_DESKTOP_DIRS);
|
|
|
|
return desktop_dirs;
|
|
|
|
}
|
|
|
|
|
2011-02-10 06:24:20 -08:00
|
|
|
void
|
|
|
|
efreet_cache_desktop_update(void)
|
|
|
|
{
|
|
|
|
if (!efreet_cache_update) return;
|
|
|
|
|
2011-02-10 06:25:33 -08:00
|
|
|
if (desktop_cache_timer)
|
|
|
|
ecore_timer_delay(desktop_cache_timer, 0.2);
|
|
|
|
else
|
|
|
|
desktop_cache_timer = ecore_timer_add(0.2, desktop_cache_update_cache_cb, NULL);
|
2011-02-10 06:24:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
efreet_cache_icon_update(void)
|
|
|
|
{
|
|
|
|
if (!efreet_cache_update) return;
|
|
|
|
|
2011-02-10 06:25:33 -08:00
|
|
|
if (icon_cache_timer)
|
|
|
|
ecore_timer_delay(icon_cache_timer, 0.2);
|
|
|
|
else
|
|
|
|
icon_cache_timer = ecore_timer_add(0.2, icon_cache_update_cache_cb, NULL);
|
2011-02-10 06:24:20 -08:00
|
|
|
}
|
|
|
|
|
2011-02-10 06:24:40 -08:00
|
|
|
static Eina_Bool
|
2010-12-02 00:34:07 -08:00
|
|
|
efreet_cache_check(Eet_File **ef, const char *path, int major)
|
|
|
|
{
|
|
|
|
Efreet_Cache_Version *version;
|
|
|
|
|
|
|
|
if (*ef == NON_EXISTING) return EINA_FALSE;
|
2010-12-09 04:19:23 -08:00
|
|
|
if (*ef) return EINA_TRUE;
|
2010-12-02 00:34:07 -08:00
|
|
|
if (!*ef)
|
|
|
|
*ef = eet_open(path, EET_FILE_MODE_READ);
|
|
|
|
if (!*ef)
|
|
|
|
{
|
|
|
|
*ef = NON_EXISTING;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
version = eet_data_read(*ef, efreet_version_edd(), EFREET_CACHE_VERSION);
|
|
|
|
if ((!version) || (version->major != major))
|
|
|
|
{
|
|
|
|
IF_FREE(version);
|
|
|
|
eet_close(*ef);
|
|
|
|
*ef = NON_EXISTING;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
free(version);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2011-02-10 06:24:40 -08:00
|
|
|
static void *
|
2010-12-02 00:34:07 -08:00
|
|
|
efreet_cache_close(Eet_File *ef)
|
|
|
|
{
|
|
|
|
if (ef && ef != NON_EXISTING)
|
|
|
|
eet_close(ef);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-02-10 06:24:40 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-11-22 06:16:09 -08:00
|
|
|
static Eina_Bool
|
2010-11-23 12:14:13 -08:00
|
|
|
cache_exe_cb(void *data __UNUSED__, int type __UNUSED__, void *event)
|
2010-11-22 06:16:09 -08:00
|
|
|
{
|
|
|
|
Ecore_Exe_Event_Del *ev;
|
|
|
|
|
|
|
|
ev = event;
|
2010-11-23 12:26:50 -08:00
|
|
|
if (ev->exe == desktop_cache_exe)
|
2010-11-23 12:14:13 -08:00
|
|
|
{
|
|
|
|
if (desktop_cache_exe_lock > 0)
|
|
|
|
{
|
|
|
|
close(desktop_cache_exe_lock);
|
|
|
|
desktop_cache_exe_lock = -1;
|
|
|
|
}
|
|
|
|
desktop_cache_exe = NULL;
|
2010-11-22 06:16:09 -08:00
|
|
|
}
|
2010-11-23 12:26:50 -08:00
|
|
|
else if (ev->exe == icon_cache_exe)
|
|
|
|
{
|
|
|
|
if (icon_cache_exe_lock > 0)
|
|
|
|
{
|
|
|
|
close(icon_cache_exe_lock);
|
|
|
|
icon_cache_exe_lock = -1;
|
|
|
|
}
|
|
|
|
icon_cache_exe = NULL;
|
|
|
|
}
|
2010-11-22 06:16:09 -08:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-11-23 12:14:13 -08:00
|
|
|
cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
|
2010-11-27 12:36:39 -08:00
|
|
|
Ecore_File_Event event, const char *path)
|
2010-11-22 06:16:09 -08:00
|
|
|
{
|
2010-11-23 12:14:13 -08:00
|
|
|
const char *file;
|
2010-11-22 06:16:09 -08:00
|
|
|
Efreet_Event_Cache_Update *ev = NULL;
|
2010-11-23 12:14:13 -08:00
|
|
|
Efreet_Old_Cache *d = NULL;
|
2011-02-09 09:09:16 -08:00
|
|
|
Eina_List *l = NULL;
|
2010-11-23 12:14:13 -08:00
|
|
|
|
2011-03-08 03:40:54 -08:00
|
|
|
if (event != ECORE_FILE_EVENT_CLOSED)
|
|
|
|
return;
|
2010-11-22 06:16:09 -08:00
|
|
|
|
2010-11-23 12:14:13 -08:00
|
|
|
file = ecore_file_file_get(path);
|
|
|
|
if (!file) return;
|
2010-11-23 12:26:50 -08:00
|
|
|
if (!strcmp(file, "desktop_data.update"))
|
2010-11-23 12:14:13 -08:00
|
|
|
{
|
|
|
|
ev = NEW(Efreet_Event_Cache_Update, 1);
|
|
|
|
if (!ev) goto error;
|
2011-02-10 06:24:40 -08:00
|
|
|
|
|
|
|
IF_RELEASE(util_cache_names_key);
|
|
|
|
IF_RELEASE(util_cache_hash_key);
|
|
|
|
|
2010-11-23 12:14:13 -08:00
|
|
|
d = NEW(Efreet_Old_Cache, 1);
|
|
|
|
if (!d) goto error;
|
2011-02-10 06:25:44 -08:00
|
|
|
d->hash = desktops;
|
2010-11-23 12:14:13 -08:00
|
|
|
d->ef = desktop_cache;
|
|
|
|
old_desktop_caches = eina_list_append(old_desktop_caches, d);
|
|
|
|
|
2011-02-10 06:25:23 -08:00
|
|
|
efreet_cache_array_string_free(desktop_dirs);
|
|
|
|
desktop_dirs = NULL;
|
2011-02-10 06:25:44 -08:00
|
|
|
desktops = eina_hash_string_superfast_new(NULL);
|
2010-12-02 00:33:38 -08:00
|
|
|
desktop_cache = NULL;
|
2010-11-23 12:14:13 -08:00
|
|
|
|
2011-02-10 06:24:40 -08:00
|
|
|
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);
|
|
|
|
|
2010-11-23 12:14:13 -08:00
|
|
|
ecore_event_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE, ev, desktop_cache_update_free, d);
|
2011-02-28 02:50:27 -08:00
|
|
|
/* TODO: Check if desktop_dirs_add exists, and rebuild cache if */
|
2010-11-23 12:14:13 -08:00
|
|
|
}
|
2010-12-02 00:33:57 -08:00
|
|
|
else if (!strcmp(file, "icon_data.update"))
|
2010-11-27 12:36:39 -08:00
|
|
|
{
|
2010-12-11 12:37:17 -08:00
|
|
|
ev = NEW(Efreet_Event_Cache_Update, 1);
|
|
|
|
if (!ev) goto error;
|
2011-02-09 09:09:16 -08:00
|
|
|
|
|
|
|
IF_RELEASE(theme_name);
|
|
|
|
|
|
|
|
/* Save all old caches */
|
2010-12-11 12:37:17 -08:00
|
|
|
d = NEW(Efreet_Old_Cache, 1);
|
|
|
|
if (!d) goto error;
|
2011-02-09 09:09:16 -08:00
|
|
|
d->hash = themes;
|
|
|
|
d->ef = icon_theme_cache;
|
|
|
|
l = eina_list_append(l, d);
|
2010-12-11 12:37:17 -08:00
|
|
|
|
2011-02-09 09:09:16 -08:00
|
|
|
d = NEW(Efreet_Old_Cache, 1);
|
|
|
|
if (!d) goto error;
|
|
|
|
d->hash = icons;
|
|
|
|
d->ef = icon_cache;
|
|
|
|
l = eina_list_append(l, d);
|
2010-11-27 12:36:39 -08:00
|
|
|
|
2011-02-09 09:09:16 -08:00
|
|
|
d = NEW(Efreet_Old_Cache, 1);
|
|
|
|
if (!d) goto error;
|
|
|
|
d->hash = fallbacks;
|
|
|
|
d->ef = fallback_cache;
|
|
|
|
l = eina_list_append(l, d);
|
|
|
|
|
|
|
|
/* Create new empty caches */
|
|
|
|
themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_theme_free));
|
2011-02-01 13:03:40 -08:00
|
|
|
icons = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_free));
|
|
|
|
fallbacks = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_fallback_free));
|
|
|
|
|
2010-12-11 12:37:17 -08:00
|
|
|
icon_theme_cache = NULL;
|
2011-02-09 09:09:16 -08:00
|
|
|
icon_cache = NULL;
|
|
|
|
fallback_cache = NULL;
|
2010-12-11 12:37:17 -08:00
|
|
|
|
2011-02-09 09:09:16 -08:00
|
|
|
/* Send event */
|
|
|
|
ecore_event_add(EFREET_EVENT_ICON_CACHE_UPDATE, ev, icon_cache_update_free, l);
|
2010-11-27 12:36:39 -08:00
|
|
|
}
|
2010-11-24 03:30:12 -08:00
|
|
|
return;
|
2010-11-23 12:14:13 -08:00
|
|
|
error:
|
|
|
|
IF_FREE(ev);
|
|
|
|
IF_FREE(d);
|
2011-02-09 09:09:16 -08:00
|
|
|
EINA_LIST_FREE(l, d)
|
|
|
|
free(d);
|
2010-11-22 06:16:09 -08:00
|
|
|
}
|
|
|
|
|
2011-02-10 06:25:33 -08:00
|
|
|
static Eina_Bool
|
|
|
|
desktop_cache_update_cache_cb(void *data __UNUSED__)
|
2010-11-23 12:14:13 -08:00
|
|
|
{
|
|
|
|
char file[PATH_MAX];
|
|
|
|
struct flock fl;
|
2010-11-24 02:44:16 -08:00
|
|
|
int prio;
|
2010-11-23 12:14:13 -08:00
|
|
|
|
2011-02-10 06:25:33 -08:00
|
|
|
desktop_cache_timer = NULL;
|
2010-11-23 12:14:13 -08:00
|
|
|
|
|
|
|
/* TODO: Retry update cache later */
|
2011-02-10 06:25:33 -08:00
|
|
|
if (desktop_cache_exe_lock > 0) return ECORE_CALLBACK_CANCEL;
|
2010-11-23 12:14:13 -08:00
|
|
|
|
2010-12-04 08:02:20 -08:00
|
|
|
snprintf(file, sizeof(file), "%s/efreet/desktop_exec.lock", efreet_cache_home_get());
|
2010-11-23 12:14:13 -08:00
|
|
|
|
|
|
|
desktop_cache_exe_lock = open(file, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
|
2011-02-10 06:25:33 -08:00
|
|
|
if (desktop_cache_exe_lock < 0) goto error;
|
2011-02-07 13:33:33 -08:00
|
|
|
efreet_fsetowner(desktop_cache_exe_lock);
|
2010-11-23 12:14:13 -08:00
|
|
|
memset(&fl, 0, sizeof(struct flock));
|
|
|
|
fl.l_type = F_WRLCK;
|
|
|
|
fl.l_whence = SEEK_SET;
|
|
|
|
if (fcntl(desktop_cache_exe_lock, F_SETLK, &fl) < 0) goto error;
|
2010-11-24 02:44:16 -08:00
|
|
|
prio = ecore_exe_run_priority_get();
|
|
|
|
ecore_exe_run_priority_set(19);
|
2011-02-10 06:25:23 -08:00
|
|
|
eina_strlcpy(file, PACKAGE_LIB_DIR "/efreet/efreet_desktop_cache_create", sizeof(file));
|
2011-02-28 02:50:27 -08:00
|
|
|
if (desktop_dirs_add)
|
2011-02-10 06:25:23 -08:00
|
|
|
{
|
2011-02-28 02:50:27 -08:00
|
|
|
const char *str;
|
2011-02-10 06:25:23 -08:00
|
|
|
|
|
|
|
eina_strlcat(file, " -d", sizeof(file));
|
2011-02-28 02:50:27 -08:00
|
|
|
EINA_LIST_FREE(desktop_dirs_add, str)
|
2011-02-10 06:25:23 -08:00
|
|
|
{
|
|
|
|
eina_strlcat(file, " ", sizeof(file));
|
2011-02-28 02:50:27 -08:00
|
|
|
eina_strlcat(file, str, sizeof(file));
|
|
|
|
eina_stringshare_del(str);
|
2011-02-10 06:25:23 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("Run desktop cache creation: %s\n", file);
|
|
|
|
desktop_cache_exe = ecore_exe_run(file, NULL);
|
2010-11-24 02:44:16 -08:00
|
|
|
ecore_exe_run_priority_set(prio);
|
2010-11-23 12:14:13 -08:00
|
|
|
if (!desktop_cache_exe) goto error;
|
|
|
|
|
2011-02-10 06:25:33 -08:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2010-11-23 12:14:13 -08:00
|
|
|
error:
|
|
|
|
if (desktop_cache_exe_lock > 0)
|
|
|
|
{
|
|
|
|
close(desktop_cache_exe_lock);
|
|
|
|
desktop_cache_exe_lock = -1;
|
|
|
|
}
|
2011-02-10 06:25:33 -08:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2010-11-23 12:14:13 -08:00
|
|
|
}
|
|
|
|
|
2011-02-10 06:25:33 -08:00
|
|
|
static Eina_Bool
|
|
|
|
icon_cache_update_cache_cb(void *data __UNUSED__)
|
2010-11-23 12:14:13 -08:00
|
|
|
{
|
|
|
|
char file[PATH_MAX];
|
|
|
|
struct flock fl;
|
2010-11-24 02:44:16 -08:00
|
|
|
int prio;
|
2011-02-02 14:58:15 -08:00
|
|
|
Eina_List **l, *l2;
|
2010-11-23 12:14:13 -08:00
|
|
|
|
2011-02-10 06:25:33 -08:00
|
|
|
icon_cache_timer = NULL;
|
2010-11-23 12:14:13 -08:00
|
|
|
|
|
|
|
/* TODO: Retry update cache later */
|
2011-02-10 06:25:33 -08:00
|
|
|
if (icon_cache_exe_lock > 0) return ECORE_CALLBACK_CANCEL;
|
2010-11-23 12:14:13 -08:00
|
|
|
|
2010-12-04 08:02:20 -08:00
|
|
|
snprintf(file, sizeof(file), "%s/efreet/icon_exec.lock", efreet_cache_home_get());
|
2010-11-23 12:14:13 -08:00
|
|
|
|
|
|
|
icon_cache_exe_lock = open(file, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
|
2011-02-10 06:25:33 -08:00
|
|
|
if (icon_cache_exe_lock < 0) goto error;
|
2011-02-07 13:33:33 -08:00
|
|
|
efreet_fsetowner(icon_cache_exe_lock);
|
2010-11-23 12:14:13 -08:00
|
|
|
memset(&fl, 0, sizeof(struct flock));
|
|
|
|
fl.l_type = F_WRLCK;
|
|
|
|
fl.l_whence = SEEK_SET;
|
|
|
|
if (fcntl(icon_cache_exe_lock, F_SETLK, &fl) < 0) goto error;
|
2010-11-24 02:44:16 -08:00
|
|
|
prio = ecore_exe_run_priority_get();
|
|
|
|
ecore_exe_run_priority_set(19);
|
2011-02-02 14:58:15 -08:00
|
|
|
eina_strlcpy(file, PACKAGE_LIB_DIR "/efreet/efreet_icon_cache_create", sizeof(file));
|
|
|
|
l = efreet_icon_extra_list_get();
|
|
|
|
if (l && eina_list_count(*l) > 0)
|
|
|
|
{
|
|
|
|
Eina_List *ll;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
eina_strlcat(file, " -d", sizeof(file));
|
|
|
|
EINA_LIST_FOREACH(*l, ll, p)
|
|
|
|
{
|
|
|
|
eina_strlcat(file, " ", sizeof(file));
|
|
|
|
eina_strlcat(file, p, sizeof(file));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
l2 = efreet_icon_extensions_list_get();
|
|
|
|
if (eina_list_count(l2) > 0)
|
|
|
|
{
|
|
|
|
Eina_List *ll;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
eina_strlcat(file, " -e", sizeof(file));
|
|
|
|
EINA_LIST_FOREACH(l2, ll, p)
|
|
|
|
{
|
|
|
|
eina_strlcat(file, " ", sizeof(file));
|
|
|
|
eina_strlcat(file, p, sizeof(file));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
icon_cache_exe = ecore_exe_run(file, NULL);
|
2010-11-24 02:44:16 -08:00
|
|
|
ecore_exe_run_priority_set(prio);
|
2010-11-23 12:14:13 -08:00
|
|
|
if (!icon_cache_exe) goto error;
|
|
|
|
|
2011-02-10 06:25:33 -08:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2010-11-23 12:14:13 -08:00
|
|
|
|
|
|
|
error:
|
|
|
|
if (icon_cache_exe_lock > 0)
|
|
|
|
{
|
|
|
|
close(icon_cache_exe_lock);
|
|
|
|
icon_cache_exe_lock = -1;
|
|
|
|
}
|
2011-02-10 06:25:33 -08:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2010-11-23 12:14:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
desktop_cache_update_free(void *data, void *ev)
|
|
|
|
{
|
2010-11-27 12:36:39 -08:00
|
|
|
Efreet_Old_Cache *d;
|
|
|
|
int dangling = 0;
|
|
|
|
|
|
|
|
d = data;
|
|
|
|
/*
|
|
|
|
* All users should now had the chance to update their pointers, so we can now
|
|
|
|
* free the old cache
|
|
|
|
*/
|
|
|
|
if (d->hash)
|
|
|
|
{
|
2010-11-23 12:14:13 -08:00
|
|
|
Eina_Iterator *it;
|
|
|
|
Eina_Hash_Tuple *tuple;
|
|
|
|
|
|
|
|
it = eina_hash_iterator_tuple_new(d->hash);
|
|
|
|
EINA_ITERATOR_FOREACH(it, tuple)
|
2010-11-27 12:36:39 -08:00
|
|
|
{
|
2011-02-10 06:25:44 -08:00
|
|
|
if (tuple->data == NON_EXISTING) continue;
|
2010-11-27 12:36:39 -08:00
|
|
|
printf("Efreet: %d:%s still in cache on cache close!\n",
|
|
|
|
((Efreet_Desktop *)tuple->data)->ref, (char *)tuple->key);
|
|
|
|
dangling++;
|
|
|
|
}
|
2010-11-23 12:14:13 -08:00
|
|
|
eina_iterator_free(it);
|
|
|
|
|
|
|
|
eina_hash_free(d->hash);
|
2010-11-27 12:36:39 -08:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If there are dangling references the eet file won't be closed - to
|
|
|
|
* avoid crashes, but this will leak instead.
|
|
|
|
*/
|
|
|
|
if (dangling == 0)
|
|
|
|
{
|
2010-12-02 00:34:07 -08:00
|
|
|
efreet_cache_close(d->ef);
|
2010-11-27 12:36:39 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-19 12:54:15 -08:00
|
|
|
/* TODO: Keep in old_desktop_caches, as we might close ref later */
|
2010-11-23 12:14:13 -08:00
|
|
|
printf("Efreet: ERROR. There are still %i desktop files with old\n"
|
|
|
|
"dangling references to desktop files. This application\n"
|
|
|
|
"has not handled the EFREET_EVENT_DESKTOP_CACHE_UPDATE\n"
|
|
|
|
"fully and released its references. Please fix the application\n"
|
|
|
|
"so it does this.\n",
|
|
|
|
dangling);
|
2010-11-27 12:36:39 -08:00
|
|
|
}
|
|
|
|
old_desktop_caches = eina_list_remove(old_desktop_caches, d);
|
|
|
|
free(d);
|
|
|
|
free(ev);
|
2010-11-23 12:14:13 -08:00
|
|
|
}
|
|
|
|
|
2010-12-11 12:37:17 -08:00
|
|
|
static void
|
|
|
|
icon_cache_update_free(void *data, void *ev)
|
|
|
|
{
|
|
|
|
Efreet_Old_Cache *d;
|
2011-02-09 09:09:16 -08:00
|
|
|
Eina_List *l;
|
2010-12-11 12:37:17 -08:00
|
|
|
|
2011-02-09 09:09:16 -08:00
|
|
|
l = data;
|
|
|
|
EINA_LIST_FREE(l, d)
|
|
|
|
{
|
|
|
|
if (d->hash)
|
|
|
|
eina_hash_free(d->hash);
|
|
|
|
efreet_cache_close(d->ef);
|
|
|
|
free(d);
|
|
|
|
}
|
2010-12-11 12:37:17 -08:00
|
|
|
free(ev);
|
|
|
|
}
|
2011-02-09 09:09:38 -08:00
|
|
|
|
|
|
|
static void *
|
|
|
|
hash_array_string_add(void *hash, const char *key, void *data)
|
|
|
|
{
|
|
|
|
if (!hash)
|
|
|
|
hash = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free));
|
|
|
|
if (!hash)
|
|
|
|
return NULL;
|
|
|
|
eina_hash_add(hash, key, data);
|
|
|
|
return hash;
|
|
|
|
}
|
2011-02-28 02:50:27 -08:00
|
|
|
|
|
|
|
static int
|
|
|
|
strcmplen(const void *data1, const void *data2)
|
|
|
|
{
|
|
|
|
return strncmp(data1, data2, strlen(data1));
|
|
|
|
}
|
|
|
|
|