traces of it, I'll find them. Everything complies and I've been running this version. I still feel there are some bugs out there that where hidden by the existance of the cache. Time to stomp those before hiding them again with the new cache code. SVN revision: 25838devs/princeamd/enlightenment-0.17-elive
parent
2a879e5d20
commit
ab40044e0e
6 changed files with 0 additions and 662 deletions
@ -1,198 +0,0 @@ |
||||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 |
||||
*/ |
||||
#include "e.h" |
||||
|
||||
#define NEWD(str, typ) \ |
||||
{ eddc.name = str; eddc.size = sizeof(typ); } |
||||
|
||||
#define FREED(eed) \ |
||||
if (eed) \
|
||||
{ \
|
||||
eet_data_descriptor_free((eed)); \
|
||||
(eed) = NULL; \
|
||||
} |
||||
#define NEWI(str, it, type) \ |
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_e_app_cache_edd, E_App_Cache, str, it, type) |
||||
#define NEWL(str, it, type) \ |
||||
EET_DATA_DESCRIPTOR_ADD_LIST(_e_app_cache_edd, E_App_Cache, str, it, type) |
||||
|
||||
static void _e_eapp_cache_fill(E_App_Cache *ac, E_App *a); |
||||
|
||||
static Eet_Data_Descriptor *_e_app_cache_edd = NULL; |
||||
|
||||
EAPI int |
||||
e_app_cache_init(void) |
||||
{ |
||||
Eet_Data_Descriptor_Class eddc; |
||||
|
||||
eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION; |
||||
eddc.func.mem_alloc = NULL; |
||||
eddc.func.mem_free = NULL; |
||||
eddc.func.str_alloc = (char *(*)(const char *)) evas_stringshare_add; |
||||
eddc.func.str_free = (void (*)(const char *)) evas_stringshare_del; |
||||
eddc.func.list_next = (void *(*)(void *)) evas_list_next; |
||||
eddc.func.list_append = (void *(*)(void *l, void *d)) evas_list_append; |
||||
eddc.func.list_data = (void *(*)(void *)) evas_list_data; |
||||
eddc.func.list_free = (void *(*)(void *)) evas_list_free; |
||||
eddc.func.hash_foreach =
|
||||
(void (*) (void *, int (*) (void *, const char *, void *, void *), void *))
|
||||
evas_hash_foreach; |
||||
eddc.func.hash_add = (void *(*) (void *, const char *, void *)) evas_hash_add; |
||||
eddc.func.hash_free = (void (*) (void *)) evas_hash_free; |
||||
|
||||
NEWD("E_App_Cache", E_App_Cache); |
||||
_e_app_cache_edd = eet_data_descriptor2_new(&eddc); |
||||
|
||||
NEWI("nm", name, EET_T_STRING); |
||||
NEWI("gn", generic, EET_T_STRING); |
||||
NEWI("cm", comment, EET_T_STRING); |
||||
NEWI("ex", exe, EET_T_STRING); |
||||
NEWI("fl", file, EET_T_STRING); |
||||
NEWI("fm", file_mod_time, EET_T_ULONG_LONG); |
||||
NEWI("wn", win_name, EET_T_STRING); |
||||
NEWI("wc", win_class, EET_T_STRING); |
||||
NEWI("wt", win_title, EET_T_STRING); |
||||
NEWI("wr", win_role, EET_T_STRING); |
||||
NEWI("ic", icon_class, EET_T_STRING); |
||||
NEWI("ip", icon_path, EET_T_STRING); |
||||
NEWL("ap", subapps, _e_app_cache_edd); |
||||
NEWI("sn", startup_notify, EET_T_UCHAR); |
||||
NEWI("wx", wait_exit, EET_T_UCHAR); |
||||
NEWI("il", is_link, EET_T_UCHAR); |
||||
NEWI("id", is_dir, EET_T_UCHAR); |
||||
return 1; |
||||
} |
||||
|
||||
EAPI int |
||||
e_app_cache_shutdown(void) |
||||
{ |
||||
FREED(_e_app_cache_edd); |
||||
return 1; |
||||
} |
||||
|
||||
EAPI E_App_Cache * |
||||
e_app_cache_load(const char *path) |
||||
{ |
||||
Eet_File *ef; |
||||
char buf[PATH_MAX]; |
||||
E_App_Cache *ac; |
||||
|
||||
if (!path) return NULL; |
||||
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", path); |
||||
ef = eet_open(buf, EET_FILE_MODE_READ); |
||||
if (!ef) return NULL; |
||||
ac = eet_data_read(ef, _e_app_cache_edd, "cache"); |
||||
eet_close(ef); |
||||
if (ac) |
||||
{ |
||||
Evas_List *l; |
||||
|
||||
for (l = ac->subapps; l; l = l->next) |
||||
{ |
||||
E_App_Cache *ac2; |
||||
|
||||
ac2 = l->data; |
||||
ac->subapps_hash = evas_hash_add(ac->subapps_hash, ac2->file, ac2); |
||||
} |
||||
} |
||||
return ac; |
||||
} |
||||
|
||||
EAPI E_App_Cache * |
||||
e_app_cache_generate(E_App *a) |
||||
{ |
||||
E_App_Cache *ac; |
||||
Evas_List *l; |
||||
char buf[PATH_MAX]; |
||||
|
||||
if (!a) return NULL; |
||||
ac = calloc(1, sizeof(E_App_Cache)); |
||||
if (!ac) return NULL; |
||||
_e_eapp_cache_fill(ac, a); |
||||
for (l = a->subapps; l; l = l->next) |
||||
{ |
||||
E_App *a2; |
||||
E_App_Cache *ac2; |
||||
|
||||
a2 = l->data; |
||||
ac2 = calloc(1, sizeof(E_App_Cache)); |
||||
if (ac2) |
||||
{ |
||||
_e_eapp_cache_fill(ac2, a2); |
||||
ac2->is_dir = ecore_file_is_dir(a2->path); |
||||
snprintf(buf, sizeof(buf), "%s/%s", a->path, ecore_file_get_file(a2->path)); |
||||
if (a2->orig) ac2->is_link = 1; |
||||
if ((!ac2->is_link) && (!ac2->is_dir)) |
||||
ac2->file_mod_time = ecore_file_mod_time(buf); |
||||
ac->subapps = evas_list_append(ac->subapps, ac2); |
||||
ac->subapps_hash = evas_hash_direct_add(ac->subapps_hash, ac2->file, ac2); |
||||
} |
||||
} |
||||
return ac; |
||||
} |
||||
|
||||
EAPI void |
||||
e_app_cache_free(E_App_Cache *ac) |
||||
{ |
||||
if (!ac) return; |
||||
if (ac->name) evas_stringshare_del(ac->name); |
||||
if (ac->generic) evas_stringshare_del(ac->generic); |
||||
if (ac->comment) evas_stringshare_del(ac->comment); |
||||
if (ac->exe) evas_stringshare_del(ac->exe); |
||||
if (ac->file) evas_stringshare_del(ac->file); |
||||
if (ac->win_name) evas_stringshare_del(ac->win_name); |
||||
if (ac->win_class) evas_stringshare_del(ac->win_class); |
||||
if (ac->win_title) evas_stringshare_del(ac->win_title); |
||||
if (ac->win_role) evas_stringshare_del(ac->win_role); |
||||
if (ac->icon_class) evas_stringshare_del(ac->icon_class); |
||||
if (ac->icon_path) evas_stringshare_del(ac->icon_path); |
||||
while (ac->subapps) |
||||
{ |
||||
E_App_Cache *ac2; |
||||
|
||||
ac2 = ac->subapps->data; |
||||
ac->subapps = evas_list_remove_list(ac->subapps, ac->subapps); |
||||
e_app_cache_free(ac2); |
||||
} |
||||
evas_hash_free(ac->subapps_hash); |
||||
free(ac); |
||||
} |
||||
|
||||
EAPI int |
||||
e_app_cache_save(E_App_Cache *ac, const char *path) |
||||
{ |
||||
Eet_File *ef; |
||||
char buf[4096]; |
||||
int ret; |
||||
Eet_Error err; |
||||
|
||||
if ((!ac) || (!path)) return 0; |
||||
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", path); |
||||
ef = eet_open(buf, EET_FILE_MODE_WRITE); |
||||
if (!ef) return 0; |
||||
ret = eet_data_write(ef, _e_app_cache_edd, "cache", ac, 1); |
||||
err = eet_close(ef); |
||||
if (err != EET_ERROR_NONE) |
||||
ecore_file_unlink(buf); |
||||
return ret; |
||||
} |
||||
|
||||
static void |
||||
_e_eapp_cache_fill(E_App_Cache *ac, E_App *a) |
||||
{ |
||||
#define IF_DUP(x) if (a->x) ac->x = evas_stringshare_add(a->x) |
||||
IF_DUP(name); |
||||
IF_DUP(generic); |
||||
IF_DUP(comment); |
||||
IF_DUP(exe); |
||||
ac->file = evas_stringshare_add(ecore_file_get_file(a->path)); |
||||
IF_DUP(win_name); |
||||
IF_DUP(win_class); |
||||
IF_DUP(win_title); |
||||
IF_DUP(win_role); |
||||
IF_DUP(icon_class); |
||||
IF_DUP(icon_path); |
||||
ac->startup_notify = a->startup_notify; |
||||
ac->wait_exit = a->wait_exit; |
||||
} |
@ -1,51 +0,0 @@ |
||||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 |
||||
*/ |
||||
#ifdef E_TYPEDEFS |
||||
|
||||
typedef struct _E_App_Cache E_App_Cache; |
||||
|
||||
#else |
||||
#ifndef E_APPS_CACHE_H |
||||
#define E_APPS_CACHE_H |
||||
|
||||
struct _E_App_Cache |
||||
{ |
||||
const char *name; /* app name */ |
||||
const char *generic; /* generic app name */ |
||||
const char *comment; /* a longer description */ |
||||
const char *exe; /* command to execute, NULL if directory */ |
||||
|
||||
const char *file; /* the .eap filename */ |
||||
unsigned long long file_mod_time; /* the last modified time of the file */ |
||||
|
||||
const char *win_name; /* window name */ |
||||
const char *win_class; /* window class */ |
||||
const char *win_title; /* window title */ |
||||
const char *win_role; /* window role */ |
||||
|
||||
const char *icon_class; /* icon_class */ |
||||
const char *icon_path; /* FDO icon path */ |
||||
|
||||
Evas_List *subapps; /* if this a directory, a list of more E_App's */ |
||||
|
||||
unsigned char startup_notify; /* disable while starting etc. */ |
||||
unsigned char wait_exit; /* wait for app to exit before execing next */ |
||||
|
||||
unsigned char is_link; /* cached .order logic info */ |
||||
unsigned char is_dir; /* cached stat info */ |
||||
|
||||
/* these are generated post-load */ |
||||
Evas_Hash *subapps_hash; /* a quick lookup hash */ |
||||
}; |
||||
|
||||
EAPI int e_app_cache_init(void); |
||||
EAPI int e_app_cache_shutdown(void); |
||||
|
||||
EAPI E_App_Cache *e_app_cache_load(const char *path); |
||||
EAPI E_App_Cache *e_app_cache_generate(E_App *a); |
||||
EAPI void e_app_cache_free(E_App_Cache *ac); |
||||
EAPI int e_app_cache_save(E_App_Cache *ac, const char *path); |
||||
|
||||
#endif |
||||
#endif |
@ -1,128 +0,0 @@ |
||||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 |
||||
*/ |
||||
#include "e.h" |
||||
|
||||
static void _e_gen_cache(char *path, int recurse); |
||||
static int _e_cb_signal_exit(void *data, int ev_type, void *ev); |
||||
static void _e_help(void); |
||||
|
||||
/* local subsystem globals */ |
||||
|
||||
int |
||||
main(int argc, char **argv) |
||||
{ |
||||
int i; |
||||
char *dir = NULL; |
||||
int recurse = 0; |
||||
|
||||
for (i = 1; i < argc; i++) |
||||
{ |
||||
if ((!strcmp(argv[i], "-h")) || |
||||
(!strcmp(argv[i], "-help")) || |
||||
(!strcmp(argv[i], "--h")) || |
||||
(!strcmp(argv[i], "--help"))) |
||||
{ |
||||
_e_help(); |
||||
exit(0); |
||||
} |
||||
else if (!strcmp(argv[i], "-r")) |
||||
{ |
||||
recurse = 1; |
||||
} |
||||
else |
||||
{ |
||||
dir = argv[i]; |
||||
} |
||||
} |
||||
if (!dir) |
||||
{ |
||||
printf("ERROR: No directory specified!\n"); |
||||
_e_help(); |
||||
exit(0); |
||||
} |
||||
|
||||
/* basic ecore init */ |
||||
if (!ecore_init()) |
||||
{ |
||||
printf("ERROR: Enlightenment_eapp_cache_gen cannot Initialize Ecore!\n" |
||||
"Perhaps you are out of memory?\n"); |
||||
exit(-1); |
||||
} |
||||
ecore_app_args_set((int)argc, (const char **)argv); |
||||
/* setup a handler for when e is asked to exit via a system signal */ |
||||
if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _e_cb_signal_exit, NULL)) |
||||
{ |
||||
printf("ERROR: Enlightenment_eapp_cache_gen cannot set up an exit signal handler.\n" |
||||
"Perhaps you are out of memory?\n"); |
||||
exit(-1); |
||||
} |
||||
|
||||
e_app_init(); |
||||
_e_gen_cache(dir, recurse); |
||||
e_app_shutdown(); |
||||
|
||||
ecore_shutdown(); |
||||
/* just return 0 to keep the compiler quiet */ |
||||
return 0; |
||||
} |
||||
|
||||
static void |
||||
_e_gen_cache(char *path, int recurse) |
||||
{ |
||||
E_App_Cache *ac; |
||||
E_App *a; |
||||
char buf[PATH_MAX], *file; |
||||
|
||||
a = e_app_new(path, recurse); |
||||
if (!a) return; |
||||
ac = e_app_cache_generate(a); |
||||
if (!ac) return; |
||||
e_app_cache_save(ac, path); |
||||
e_app_cache_free(ac); |
||||
if (recurse) |
||||
{ |
||||
Ecore_List *files; |
||||
|
||||
files = ecore_file_ls(path); |
||||
if (files) |
||||
{ |
||||
ecore_list_goto_first(files); |
||||
while ((file = ecore_list_next(files))) |
||||
{ |
||||
if (file[0] != '.') |
||||
{ |
||||
snprintf(buf, sizeof(buf), "%s/%s", path, file); |
||||
if (ecore_file_is_dir(buf)) _e_gen_cache(buf, recurse); |
||||
} |
||||
} |
||||
ecore_list_destroy(files); |
||||
} |
||||
} |
||||
return; |
||||
} |
||||
|
||||
/* local subsystem functions */ |
||||
static int |
||||
_e_cb_signal_exit(void *data, int ev_type, void *ev) |
||||
{ |
||||
/* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */ |
||||
exit(-1); |
||||
return 1; |
||||
} |
||||
|
||||
static void |
||||
_e_help(void) |
||||
{ |
||||
printf("enlightenment_eapp_cache_gen [directory] [OPTIONS]\n" |
||||
"\n" |
||||
"OPTIONS:\n" |
||||
" -h This help\n" |
||||
" -help This help\n" |
||||
" --help This help\n" |
||||
" --h This help\n" |
||||
" -r Recursively generate caches for all subdirectories too\n" |
||||
); |
||||
} |
||||
|
||||
|
Loading…
Reference in new issue