forked from enlightenment/enlightenment
Eap caching code really removed this time. There may still be some
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: 25838
This commit is contained in:
parent
2a879e5d20
commit
ab40044e0e
|
@ -17,7 +17,6 @@ bin_PROGRAMS = \
|
|||
enlightenment \
|
||||
enlightenment_remote \
|
||||
enlightenment_eapp \
|
||||
enlightenment_eapp_cache_gen \
|
||||
enlightenment_imc \
|
||||
enlightenment_start \
|
||||
enlightenment_thumb \
|
||||
|
@ -84,7 +83,6 @@ e_pan.h \
|
|||
e_dialog.h \
|
||||
e_about.h \
|
||||
e_theme_about.h \
|
||||
e_apps_cache.h \
|
||||
e_editable.h \
|
||||
e_entry.h \
|
||||
e_widget.h \
|
||||
|
@ -230,7 +228,6 @@ e_pan.c \
|
|||
e_dialog.c \
|
||||
e_about.c \
|
||||
e_theme_about.c \
|
||||
e_apps_cache.c \
|
||||
e_editable.c \
|
||||
e_entry.c \
|
||||
e_widget.c \
|
||||
|
@ -340,12 +337,6 @@ e_eapp_main.c
|
|||
|
||||
enlightenment_eapp_LDFLAGS = @e_libs@ @dlopen_libs@
|
||||
|
||||
enlightenment_eapp_cache_gen_SOURCES = \
|
||||
e_eapp_cache_gen_main.c \
|
||||
$(enlightenment_src)
|
||||
|
||||
enlightenment_eapp_cache_gen_LDFLAGS = @e_libs@ @dlopen_libs@
|
||||
|
||||
enlightenment_imc_SOURCES = \
|
||||
e.h \
|
||||
e_imc_main.c \
|
||||
|
|
275
src/bin/e_apps.c
275
src/bin/e_apps.c
|
@ -14,13 +14,9 @@
|
|||
*/
|
||||
|
||||
#define DEBUG 0
|
||||
#define APP_CACHE 0
|
||||
/* local subsystem functions */
|
||||
typedef struct _E_App_Change_Info E_App_Change_Info;
|
||||
typedef struct _E_App_Callback E_App_Callback;
|
||||
#if APP_CACHE
|
||||
typedef struct _E_App_Scan_Cache E_App_Scan_Cache;
|
||||
#endif
|
||||
|
||||
struct _E_App_Change_Info
|
||||
{
|
||||
|
@ -35,17 +31,6 @@ struct _E_App_Callback
|
|||
unsigned char delete_me : 1;
|
||||
};
|
||||
|
||||
#if APP_CACHE
|
||||
struct _E_App_Scan_Cache
|
||||
{
|
||||
const char *path;
|
||||
E_App_Cache *cache;
|
||||
E_App *app;
|
||||
Ecore_List *files;
|
||||
Ecore_Timer *timer;
|
||||
unsigned char need_rewrite : 1;
|
||||
};
|
||||
#endif
|
||||
|
||||
static void _e_app_free (E_App *a);
|
||||
static E_App *_e_app_subapp_file_find (E_App *a, const char *file);
|
||||
|
@ -59,11 +44,6 @@ static int _e_app_copy (E_App *dst, E_App *src);
|
|||
static void _e_app_save_order (E_App *app);
|
||||
static int _e_app_cb_event_border_add(void *data, int type, void *event);
|
||||
static int _e_app_cb_expire_timer (void *data);
|
||||
#if APP_CACHE
|
||||
static void _e_app_cache_copy (E_App_Cache *ac, E_App *a);
|
||||
static int _e_app_cb_scan_cache_timer(void *data);
|
||||
static E_App *_e_app_cache_new (E_App_Cache *ac, const char *path, int scan_subdirs);
|
||||
#endif
|
||||
static int _e_app_exe_valid_get (const char *exe);
|
||||
static char *_e_app_localized_val_get (Eet_File *ef, const char *lang, const char *field, int *size);
|
||||
#if DEBUG
|
||||
|
@ -74,9 +54,6 @@ static int _e_app_order_contains(E_App *a, const char *file);
|
|||
static void _e_app_resolve_file_name(char *buf, size_t size, const char *path, const char *file);
|
||||
|
||||
/* local subsystem globals */
|
||||
#if APP_CACHE
|
||||
static Evas_Hash *_e_apps = NULL;
|
||||
#endif
|
||||
static Evas_List *_e_apps_list = NULL;
|
||||
static int _e_apps_callbacks_walking = 0;
|
||||
static int _e_apps_callbacks_delete_me = 0;
|
||||
|
@ -140,9 +117,6 @@ e_app_init(void)
|
|||
char *home;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
#if APP_CACHE
|
||||
e_app_cache_init();
|
||||
#endif
|
||||
home = e_user_homedir_get();
|
||||
snprintf(buf, sizeof(buf), "%s/.e/e/applications/trash", home);
|
||||
_e_apps_path_trash = evas_stringshare_add(buf);
|
||||
|
@ -191,9 +165,6 @@ e_app_shutdown(void)
|
|||
printf("BUG: References %d %s\n", E_OBJECT(a)->references, a->path);
|
||||
}
|
||||
}
|
||||
#if APP_CACHE
|
||||
e_app_cache_shutdown();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -224,57 +195,14 @@ e_app_raw_new(void)
|
|||
return a;
|
||||
}
|
||||
|
||||
#if APP_CACHE
|
||||
Evas_Bool
|
||||
_e_app_cb_scan_hash_foreach(Evas_Hash *hash, const char *key, void *data, void *fdata)
|
||||
{
|
||||
E_App_Scan_Cache *sc;
|
||||
E_App_Cache *ac;
|
||||
|
||||
sc = fdata;
|
||||
ac = data;
|
||||
/* file "s" has been deleted */
|
||||
printf("Cache %s - DELETED\n", key);
|
||||
sc->need_rewrite = 1;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
EAPI E_App *
|
||||
e_app_new(const char *path, int scan_subdirs)
|
||||
{
|
||||
E_App *a;
|
||||
char buf[PATH_MAX];
|
||||
#if APP_CACHE
|
||||
E_App_Cache *ac;
|
||||
#endif
|
||||
|
||||
if (!path) return NULL;
|
||||
|
||||
#if APP_CACHE
|
||||
a = evas_hash_find(_e_apps, path);
|
||||
if (a)
|
||||
{
|
||||
if (a->deleted)
|
||||
return NULL;
|
||||
e_object_ref(E_OBJECT(a));
|
||||
return a;
|
||||
}
|
||||
|
||||
ac = e_app_cache_load(path);
|
||||
if (ac)
|
||||
{
|
||||
a = _e_app_cache_new(ac, path, scan_subdirs);
|
||||
if (a)
|
||||
{
|
||||
_e_apps = evas_hash_add(_e_apps, a->path, a);
|
||||
_e_apps_list = evas_list_prepend(_e_apps_list, a);
|
||||
a->scanned = 1;
|
||||
}
|
||||
// e_app_cache_free(ac);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (ecore_file_exists(path))
|
||||
{
|
||||
|
@ -313,16 +241,7 @@ e_app_new(const char *path, int scan_subdirs)
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
#if APP_CACHE
|
||||
_e_apps = evas_hash_add(_e_apps, a->path, a);
|
||||
#endif
|
||||
_e_apps_list = evas_list_prepend(_e_apps_list, a);
|
||||
|
||||
#if APP_CACHE
|
||||
ac = e_app_cache_generate(a);
|
||||
e_app_cache_save(ac, a->path);
|
||||
e_app_cache_free(ac);
|
||||
#endif
|
||||
}
|
||||
return a;
|
||||
|
||||
|
@ -391,9 +310,6 @@ e_app_subdir_scan(E_App *a, int scan_subdirs)
|
|||
Ecore_List *files;
|
||||
char *s;
|
||||
char buf[PATH_MAX];
|
||||
#if APP_CACHE
|
||||
E_App_Cache *ac;
|
||||
#endif
|
||||
|
||||
E_OBJECT_CHECK(a);
|
||||
E_OBJECT_TYPE_CHECK(a, E_APP_TYPE);
|
||||
|
@ -460,11 +376,6 @@ e_app_subdir_scan(E_App *a, int scan_subdirs)
|
|||
ecore_list_destroy(files);
|
||||
}
|
||||
|
||||
#if APP_CACHE
|
||||
ac = e_app_cache_generate(a);
|
||||
e_app_cache_save(ac, a->path);
|
||||
e_app_cache_free(ac);
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI int
|
||||
|
@ -1888,9 +1799,6 @@ _e_app_free(E_App *a)
|
|||
a->parent->subapps = evas_list_remove(a->parent->subapps, a);
|
||||
if (a->monitor)
|
||||
ecore_file_monitor_del(a->monitor);
|
||||
#if APP_CACHE
|
||||
_e_apps = evas_hash_del(_e_apps, a->path, a);
|
||||
#endif
|
||||
_e_apps_list = evas_list_remove(_e_apps_list, a);
|
||||
e_app_fields_empty(a);
|
||||
if (a->path) evas_stringshare_del(a->path);
|
||||
|
@ -2238,16 +2146,6 @@ _e_app_subdir_rescan(E_App *app)
|
|||
e_object_unref(E_OBJECT(ch->app));
|
||||
free(ch);
|
||||
}
|
||||
#if APP_CACHE
|
||||
if (changes)
|
||||
{
|
||||
E_App_Cache *ac;
|
||||
|
||||
ac = e_app_cache_generate(app);
|
||||
e_app_cache_save(ac, app->path);
|
||||
e_app_cache_free(ac);
|
||||
}
|
||||
#endif
|
||||
evas_list_free(changes);
|
||||
}
|
||||
|
||||
|
@ -2477,179 +2375,6 @@ _e_app_cb_expire_timer(void *data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if APP_CACHE
|
||||
static void
|
||||
_e_app_cache_copy(E_App_Cache *ac, E_App *a)
|
||||
{
|
||||
#define IF_DUP(x) if ((ac->x) && (ac->x[0] != 0)) a->x = evas_stringshare_add(ac->x)
|
||||
IF_DUP(name);
|
||||
IF_DUP(generic);
|
||||
IF_DUP(comment);
|
||||
IF_DUP(exe);
|
||||
IF_DUP(win_name);
|
||||
IF_DUP(win_class);
|
||||
IF_DUP(win_title);
|
||||
IF_DUP(win_role);
|
||||
IF_DUP(icon_class);
|
||||
IF_DUP(icon_path);
|
||||
a->startup_notify = ac->startup_notify;
|
||||
a->wait_exit = ac->wait_exit;
|
||||
}
|
||||
|
||||
static int
|
||||
_e_app_cb_scan_cache_timer(void *data)
|
||||
{
|
||||
E_App_Scan_Cache *sc;
|
||||
char *s;
|
||||
char buf[4096];
|
||||
E_App_Cache *ac;
|
||||
int is_dir = 0;
|
||||
|
||||
sc = data;
|
||||
s = ecore_list_next(sc->files);
|
||||
if (!s)
|
||||
{
|
||||
evas_hash_foreach(sc->cache->subapps_hash, _e_app_cb_scan_hash_foreach, sc);
|
||||
if (sc->need_rewrite)
|
||||
_e_app_subdir_rescan(sc->app);
|
||||
sc->app->monitor = ecore_file_monitor_add(sc->app->path, _e_app_cb_monitor, sc->app);
|
||||
e_object_unref(E_OBJECT(sc->app));
|
||||
ecore_list_destroy(sc->files);
|
||||
e_app_cache_free(sc->cache);
|
||||
ecore_timer_del(sc->timer);
|
||||
evas_stringshare_del(sc->path);
|
||||
free(sc);
|
||||
// printf("Cache scan finish.\n");
|
||||
return 0;
|
||||
}
|
||||
_e_app_resolve_file_name(buf, sizeof(buf), sc->path, s);
|
||||
is_dir = ecore_file_is_dir(buf);
|
||||
if (_e_app_is_eapp(s) || is_dir)
|
||||
{
|
||||
ac = evas_hash_find(sc->cache->subapps_hash, s);
|
||||
if (ac)
|
||||
{
|
||||
if (is_dir != ac->is_dir)
|
||||
{
|
||||
printf("Cache %s - CHANGED TYPE\n", s);
|
||||
sc->need_rewrite = 1;
|
||||
}
|
||||
else if (!is_dir)
|
||||
{
|
||||
unsigned long long mtime;
|
||||
|
||||
mtime = ecore_file_mod_time(buf);
|
||||
if (mtime != ac->file_mod_time)
|
||||
{
|
||||
/* file "s" has changed */
|
||||
printf("Cache %s - MODIFIED\n", s);
|
||||
sc->need_rewrite = 1;
|
||||
}
|
||||
}
|
||||
sc->cache->subapps_hash = evas_hash_del(sc->cache->subapps_hash, s, ac);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* file "s" has been added */
|
||||
printf("Cache %s - MODIFIED\n", s);
|
||||
sc->need_rewrite = 1;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static E_App *
|
||||
_e_app_cache_new(E_App_Cache *ac, const char *path, int scan_subdirs)
|
||||
{
|
||||
Evas_List *l;
|
||||
E_App *a;
|
||||
char buf[PATH_MAX];
|
||||
E_App_Scan_Cache *sc;
|
||||
|
||||
a = E_OBJECT_ALLOC(E_App, E_APP_TYPE, _e_app_free);
|
||||
_e_app_cache_copy(ac, a);
|
||||
a->path = evas_stringshare_add(path);
|
||||
a->scanned = 1;
|
||||
for (l = ac->subapps; l; l = l->next)
|
||||
{
|
||||
E_App_Cache *ac2;
|
||||
E_App *a2;
|
||||
|
||||
ac2 = l->data;
|
||||
_e_app_resolve_file_name(buf, sizeof(buf), path, ac2->file);
|
||||
if ((ac2->is_dir) && (scan_subdirs))
|
||||
{
|
||||
a2 = e_app_new(buf, scan_subdirs);
|
||||
if (a2)
|
||||
{
|
||||
a2->parent = a;
|
||||
a->subapps = evas_list_append(a->subapps, a2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ac2->is_link)
|
||||
{
|
||||
a2 = E_OBJECT_ALLOC(E_App, E_APP_TYPE, _e_app_free);
|
||||
_e_app_cache_copy(ac2, a2);
|
||||
if (ac2->is_dir)
|
||||
{
|
||||
if (a2->exe) evas_stringshare_del(a2->exe);
|
||||
}
|
||||
a2->parent = a;
|
||||
a2->path = evas_stringshare_add(buf);
|
||||
a->subapps = evas_list_append(a->subapps, a2);
|
||||
_e_apps = evas_hash_add(_e_apps, a2->path, a2);
|
||||
_e_apps_list = evas_list_prepend(_e_apps_list, a2);
|
||||
}
|
||||
else
|
||||
{
|
||||
E_App *a3;
|
||||
Evas_List *pl;
|
||||
|
||||
pl = _e_apps_repositories;
|
||||
a2 = NULL;
|
||||
while ((!a2) && (pl))
|
||||
{
|
||||
_e_app_resolve_file_name(buf, sizeof(buf), (char *)pl->data, ac2->file);
|
||||
a2 = e_app_new(buf, scan_subdirs);
|
||||
pl = pl->next;
|
||||
}
|
||||
if (a2)
|
||||
{
|
||||
a3 = E_OBJECT_ALLOC(E_App, E_APP_TYPE, _e_app_free);
|
||||
if (a3)
|
||||
{
|
||||
if (_e_app_copy(a3, a2))
|
||||
{
|
||||
a3->parent = a;
|
||||
a->subapps = evas_list_append(a->subapps, a3);
|
||||
a2->references = evas_list_append(a2->references, a3);
|
||||
_e_apps_list = evas_list_prepend(_e_apps_list, a3);
|
||||
}
|
||||
else
|
||||
e_object_del(E_OBJECT(a3));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sc = E_NEW(E_App_Scan_Cache, 1);
|
||||
if (sc)
|
||||
{
|
||||
sc->path = evas_stringshare_add(path);
|
||||
sc->cache = ac;
|
||||
sc->app = a;
|
||||
sc->files = e_app_dir_file_list_get(a);
|
||||
sc->timer = ecore_timer_add(0.500, _e_app_cb_scan_cache_timer, sc);
|
||||
e_object_ref(E_OBJECT(sc->app));
|
||||
}
|
||||
else
|
||||
e_app_cache_free(ac);
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
_e_app_exe_valid_get(const char *exe)
|
||||
|
|
|
@ -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"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +60,6 @@
|
|||
#include "e_configure.h"
|
||||
#include "e_about.h"
|
||||
#include "e_theme_about.h"
|
||||
#include "e_apps_cache.h"
|
||||
#include "e_widget.h"
|
||||
#include "e_widget_check.h"
|
||||
#include "e_widget_radio.h"
|
||||
|
|
Loading…
Reference in New Issue