efreet_desktop_cache_create.c | efreet_desktop_cache_create.c | |||
---|---|---|---|---|
#ifdef HAVE_CONFIG_H | #ifdef HAVE_CONFIG_H | |||
# include <config.h> | # include <config.h> | |||
#endif | #endif | |||
#include <sys/stat.h> | #include <sys/stat.h> | |||
#include <fcntl.h> | #include <fcntl.h> | |||
#include <unistd.h> | #include <unistd.h> | |||
#include <errno.h> | ||||
#include <Eina.h> | #include <Eina.h> | |||
#include <Eet.h> | #include <Eet.h> | |||
#include <Ecore.h> | #include <Ecore.h> | |||
#include <Ecore_File.h> | #include <Ecore_File.h> | |||
#define EFREET_MODULE_LOG_DOM _efreet_desktop_cache_log_dom | #define EFREET_MODULE_LOG_DOM _efreet_desktop_cache_log_dom | |||
static int _efreet_desktop_cache_log_dom = -1; | static int _efreet_desktop_cache_log_dom = -1; | |||
#include "Efreet.h" | #include "Efreet.h" | |||
#include "efreet_private.h" | #include "efreet_private.h" | |||
#include "efreet_cache_private.h" | #include "efreet_cache_private.h" | |||
static Eet_Data_Descriptor *edd = NULL; | static Eet_Data_Descriptor *edd = NULL; | |||
static Eet_File *ef = NULL; | static Eet_File *ef = NULL; | |||
static Eet_File *util_ef = NULL; | static Eet_File *util_ef = NULL; | |||
static Eina_Hash *desktops = NULL; | static Eina_Hash *desktops = NULL; | |||
static Eina_Hash *file_ids = NULL; | static Eina_Hash *file_ids = NULL; | |||
static Eina_Hash *paths = NULL; | static Efreet_Cache_Hash *old_file_ids = NULL; | |||
static Eina_Hash *paths = NULL; | ||||
static Eina_Hash *mime_types = NULL; | static Eina_Hash *mime_types = NULL; | |||
static Eina_Hash *categories = NULL; | static Eina_Hash *categories = NULL; | |||
static Eina_Hash *startup_wm_class = NULL; | static Eina_Hash *startup_wm_class = NULL; | |||
static Eina_Hash *name = NULL; | static Eina_Hash *name = NULL; | |||
static Eina_Hash *generic_name = NULL; | static Eina_Hash *generic_name = NULL; | |||
static Eina_Hash *comment = NULL; | static Eina_Hash *comment = NULL; | |||
static Eina_Hash *exec = NULL; | static Eina_Hash *exec = NULL; | |||
static int | static int | |||
skipping to change at line 72 | skipping to change at line 74 | |||
} | } | |||
else if (ecore_file_mod_time(desk->orig_path) != desk->load_time) | else if (ecore_file_mod_time(desk->orig_path) != desk->load_time) | |||
{ | { | |||
efreet_desktop_free(desk); | efreet_desktop_free(desk); | |||
*changed = 1; | *changed = 1; | |||
desk = efreet_desktop_uncached_new(path); | desk = efreet_desktop_uncached_new(path); | |||
if (desk) INF(" CHANGED"); | if (desk) INF(" CHANGED"); | |||
else INF(" NO UNCACHED"); | else INF(" NO UNCACHED"); | |||
} | } | |||
if (!desk) return 1; | if (!desk) return 1; | |||
if (file_id && old_file_ids && !eina_hash_find(old_file_ids->hash, file | ||||
_id)) | ||||
{ | ||||
*changed = 1; | ||||
INF(" NOT IN UTILS"); | ||||
} | ||||
if (!eina_hash_find(paths, desk->orig_path)) | if (!eina_hash_find(paths, desk->orig_path)) | |||
{ | { | |||
if (!eet_data_write(ef, edd, desk->orig_path, desk, 0)) | if (!eet_data_write(ef, edd, desk->orig_path, desk, 0)) | |||
return 0; | return 0; | |||
eina_hash_add(paths, desk->orig_path, (void *)1); | eina_hash_add(paths, desk->orig_path, (void *)1); | |||
} | } | |||
/* TODO: We should check priority, and not just hope we search in right order */ | /* TODO: We should check priority, and not just hope we search in right order */ | |||
/* TODO: We need to find out if prioritized file id has changed because of | /* TODO: We need to find out if prioritized file id has changed because of | |||
* changed search order. */ | * changed search order. */ | |||
if (!desk->hidden && desk->type == EFREET_DESKTOP_TYPE_APPLICATION && | if (!desk->hidden && desk->type == EFREET_DESKTOP_TYPE_APPLICATION && | |||
skipping to change at line 283 | skipping to change at line 290 | |||
if (!edd) goto edd_error; | if (!edd) goto edd_error; | |||
/* read user dirs from old cache */ | /* read user dirs from old cache */ | |||
ef = eet_open(efreet_desktop_cache_file(), EET_FILE_MODE_READ); | ef = eet_open(efreet_desktop_cache_file(), EET_FILE_MODE_READ); | |||
if (ef) | if (ef) | |||
{ | { | |||
user_dirs = eet_data_read(ef, efreet_array_string_edd(), EFREET_CAC HE_DESKTOP_DIRS); | user_dirs = eet_data_read(ef, efreet_array_string_edd(), EFREET_CAC HE_DESKTOP_DIRS); | |||
eet_close(ef); | eet_close(ef); | |||
} | } | |||
ef = eet_open(efreet_desktop_util_cache_file(), EET_FILE_MODE_READ); | ||||
if (ef) | ||||
{ | ||||
old_file_ids = eet_data_read(ef, efreet_hash_string_edd(), "file_id | ||||
"); | ||||
eet_close(ef); | ||||
} | ||||
/* create cache */ | /* create cache */ | |||
snprintf(file, sizeof(file), "%s.XXXXXX", efreet_desktop_cache_file()); | snprintf(file, sizeof(file), "%s.XXXXXX", efreet_desktop_cache_file()); | |||
tmpfd = mkstemp(file); | tmpfd = mkstemp(file); | |||
if (tmpfd < 0) goto error; | if (tmpfd < 0) goto error; | |||
close(tmpfd); | close(tmpfd); | |||
ef = eet_open(file, EET_FILE_MODE_READ_WRITE); | ef = eet_open(file, EET_FILE_MODE_READ_WRITE); | |||
if (!ef) goto error; | if (!ef) goto error; | |||
snprintf(util_file, sizeof(util_file), "%s.XXXXXX", efreet_desktop_util _cache_file()); | snprintf(util_file, sizeof(util_file), "%s.XXXXXX", efreet_desktop_util _cache_file()); | |||
tmpfd = mkstemp(util_file); | tmpfd = mkstemp(util_file); | |||
skipping to change at line 369 | skipping to change at line 383 | |||
/* If we scan a passed dir, we must have changed */ | /* If we scan a passed dir, we must have changed */ | |||
changed = 1; | changed = 1; | |||
if (!cache_scan(path, NULL, priority, 0, &changed)) goto error; | if (!cache_scan(path, NULL, priority, 0, &changed)) goto error; | |||
store_dirs = eina_list_append(store_dirs, path); | store_dirs = eina_list_append(store_dirs, path); | |||
} | } | |||
store_dirs = eina_list_sort(store_dirs, -1, EINA_COMPARE_CB(strcmp) ); | store_dirs = eina_list_sort(store_dirs, -1, EINA_COMPARE_CB(strcmp) ); | |||
} | } | |||
if (user_dirs) | if (user_dirs) | |||
{ | efreet_cache_array_string_free(user_dirs); | |||
IF_FREE(user_dirs->array); | ||||
free(user_dirs); | ||||
} | ||||
/* store user dirs */ | /* store user dirs */ | |||
if (store_dirs) | if (store_dirs) | |||
{ | { | |||
Eina_List *l; | Eina_List *l; | |||
user_dirs = NEW(Efreet_Cache_Array_String, 1); | user_dirs = NEW(Efreet_Cache_Array_String, 1); | |||
user_dirs->array = NEW(char *, eina_list_count(store_dirs)); | user_dirs->array = NEW(char *, eina_list_count(store_dirs)); | |||
user_dirs->array_count = 0; | user_dirs->array_count = 0; | |||
EINA_LIST_FOREACH(store_dirs, l, path) | EINA_LIST_FOREACH(store_dirs, l, path) | |||
skipping to change at line 430 | skipping to change at line 441 | |||
} | } | |||
eina_hash_free(mime_types); | eina_hash_free(mime_types); | |||
eina_hash_free(categories); | eina_hash_free(categories); | |||
eina_hash_free(startup_wm_class); | eina_hash_free(startup_wm_class); | |||
eina_hash_free(name); | eina_hash_free(name); | |||
eina_hash_free(generic_name); | eina_hash_free(generic_name); | |||
eina_hash_free(comment); | eina_hash_free(comment); | |||
eina_hash_free(exec); | eina_hash_free(exec); | |||
if (old_file_ids) | ||||
{ | ||||
eina_hash_free(old_file_ids->hash); | ||||
free(old_file_ids); | ||||
} | ||||
eina_hash_free(file_ids); | eina_hash_free(file_ids); | |||
eina_hash_free(paths); | eina_hash_free(paths); | |||
eina_hash_free(desktops); | eina_hash_free(desktops); | |||
/* check if old and new caches contain the same number of entries */ | /* check if old and new caches contain the same number of entries */ | |||
if (!changed) | if (!changed) | |||
{ | { | |||
Eet_File *old; | Eet_File *old; | |||
skipping to change at line 503 | skipping to change at line 520 | |||
ecore_shutdown(); | ecore_shutdown(); | |||
eet_shutdown(); | eet_shutdown(); | |||
eina_log_domain_unregister(_efreet_desktop_cache_log_dom); | eina_log_domain_unregister(_efreet_desktop_cache_log_dom); | |||
eina_shutdown(); | eina_shutdown(); | |||
close(lockfd); | close(lockfd); | |||
return 0; | return 0; | |||
error: | error: | |||
IF_FREE(dir); | IF_FREE(dir); | |||
edd_error: | edd_error: | |||
if (user_dirs) efreet_cache_array_string_free(user_dirs); | if (user_dirs) efreet_cache_array_string_free(user_dirs); | |||
if (old_file_ids) | ||||
{ | ||||
eina_hash_free(old_file_ids->hash); | ||||
free(old_file_ids); | ||||
} | ||||
efreet_shutdown(); | efreet_shutdown(); | |||
efreet_error: | efreet_error: | |||
ecore_shutdown(); | ecore_shutdown(); | |||
ecore_error: | ecore_error: | |||
eet_shutdown(); | eet_shutdown(); | |||
eet_error: | eet_error: | |||
EINA_LIST_FREE(systemdirs, dir) | EINA_LIST_FREE(systemdirs, dir) | |||
eina_stringshare_del(dir); | eina_stringshare_del(dir); | |||
eina_list_free(extra_dirs); | eina_list_free(extra_dirs); | |||
eina_list_free(store_dirs); | eina_list_free(store_dirs); | |||
End of changes. 7 change blocks. | ||||
6 lines changed or deleted | 30 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/ |