From 9a0b0d75adcaa6eed57cea7959c4974e060052f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Bouchaud=20=28yoz=29?= Date: Wed, 14 May 2014 10:11:59 +0200 Subject: [PATCH] Revert "entrance: pools are now sent seperated from the config" This reverts commit a69be8076212ceaf4516f7f7e76180fe1f697ac3. --- src/bin/entrance_conf_main.c | 2 + src/bin/entrance_conf_user.c | 4 +- src/bin/entrance_connect.c | 9 ++-- src/bin/entrance_gui.c | 88 ++++++++++++----------------------- src/bin/entrance_gui.h | 4 -- src/daemon/entrance_history.c | 11 +++++ src/daemon/entrance_image.c | 43 ----------------- src/daemon/entrance_image.h | 3 +- src/daemon/entrance_server.c | 22 ++++++--- src/event/entrance_event.c | 60 +++++++----------------- src/event/entrance_event.h | 20 ++------ 11 files changed, 84 insertions(+), 182 deletions(-) diff --git a/src/bin/entrance_conf_main.c b/src/bin/entrance_conf_main.c index c98586f..3c545cf 100644 --- a/src/bin/entrance_conf_main.c +++ b/src/bin/entrance_conf_main.c @@ -313,6 +313,8 @@ _entrance_conf_main_apply(void) conf.bg.path = _entrance_int_conf_main->bg.path; conf.bg.group = _entrance_int_conf_main->bg.group; + conf.background_pool = NULL; + conf.icon_pool = NULL; conf.vkbd_enabled = _entrance_int_conf_main->vkbd_enabled; if (_entrance_int_conf_main->scale != elm_config_scale_get()) diff --git a/src/bin/entrance_conf_user.c b/src/bin/entrance_conf_user.c index 6bf0829..5f6afdb 100644 --- a/src/bin/entrance_conf_user.c +++ b/src/bin/entrance_conf_user.c @@ -345,7 +345,7 @@ _entrance_conf_user_build_cb(Evas_Object *t, Entrance_Login *eu) IMG_LIST_FORK(entrance_gui_background_pool_get(), l); IMG_LIST_FORK(entrance_gui_background_pool_get(), l); IMG_LIST_FORK(entrance_gui_theme_backgrounds(), l); - IMG_LIST_FORK(entrance_gui_user_background_pool_get(eu->login), l); + IMG_LIST_FORK(eu->background_pool, l); entrance_fill(gl, entrance_conf_background_fill_get(), l, _entrance_conf_user_bg_fill_cb, _entrance_conf_user_bg_sel, o); @@ -383,7 +383,7 @@ _entrance_conf_user_build_cb(Evas_Object *t, Entrance_Login *eu) l = eina_list_append(NULL, img); IMG_LIST_FORK(entrance_gui_icon_pool_get(), l); IMG_LIST_FORK(entrance_gui_theme_icons(), l); - IMG_LIST_FORK(entrance_gui_user_icon_pool_get(eu->login), l); + IMG_LIST_FORK(eu->icon_pool, l); entrance_fill(gl, entrance_conf_background_fill_get(), l, _entrance_conf_user_icon_fill_cb, _entrance_conf_user_icon_sel, o); diff --git a/src/bin/entrance_connect.c b/src/bin/entrance_connect.c index ede55c7..04055ac 100644 --- a/src/bin/entrance_connect.c +++ b/src/bin/entrance_connect.c @@ -97,11 +97,6 @@ _entrance_connect_read_cb(const void *data, size_t size EINA_UNUSED, void *user_ PT("Gui conf received\n"); entrance_gui_conf_set(&(eev->event.conf_gui)); } - else if (eev->type == ENTRANCE_EVENT_POOLS) - { - PT("Pools received\n"); - entrance_gui_pools_set(&(eev->event.pools)); - } else { PT("UNKNOW signal "); @@ -151,6 +146,8 @@ entrance_connect_conf_gui_send(Entrance_Conf_Gui_Event *ev) PT("Send gui config\n"); eev.event.conf_gui.bg.path = ev->bg.path; eev.event.conf_gui.bg.group = ev->bg.group; + eev.event.conf_gui.background_pool = NULL; + eev.event.conf_gui.icon_pool = NULL; eev.type = ENTRANCE_EVENT_CONF_GUI; entrance_event_send(&eev); @@ -168,6 +165,8 @@ entrance_connect_conf_user_send(Entrance_Login *el) eev.event.conf_user.bg.path = el->bg.path; eev.event.conf_user.bg.group = el->bg.group; eev.event.conf_user.remember_session = el->remember_session; + eev.event.conf_user.icon_pool = NULL; + eev.event.conf_user.background_pool = NULL; eev.type = ENTRANCE_EVENT_CONF_USER; entrance_event_send(&eev); } diff --git a/src/bin/entrance_gui.c b/src/bin/entrance_gui.c index fa42125..fd55745 100644 --- a/src/bin/entrance_gui.c +++ b/src/bin/entrance_gui.c @@ -38,7 +38,6 @@ struct Entrance_Gui_ Eina_List *actions; Eina_List *background_pool; Eina_List *icon_pool; - Eina_List *user_pools; Eina_List *theme_background_pool; Eina_List *theme_icon_pool; Entrance_Xsession *selected_session; @@ -459,6 +458,30 @@ entrance_gui_xsessions_get(void) void entrance_gui_conf_set(const Entrance_Conf_Gui_Event *conf) { + Entrance_Image *img; + + if (conf->background_pool) + { + EINA_LIST_FREE(_gui->background_pool, img) + { + eina_stringshare_del(img->path); + eina_stringshare_del(img->group); + free(img); + } + _gui->background_pool = conf->background_pool; + } + + if (conf->icon_pool) + { + EINA_LIST_FREE(_gui->icon_pool, img) + { + eina_stringshare_del(img->path); + eina_stringshare_del(img->group); + free(img); + } + _gui->icon_pool = conf->icon_pool; + } + if (_gui->bg.path != conf->bg.path) { if ((conf->bg.path) && (*conf->bg.path)) @@ -491,62 +514,6 @@ entrance_gui_conf_set(const Entrance_Conf_Gui_Event *conf) _gui->changed = ~(ENTRANCE_CONF_NONE); _entrance_gui_update(); } -static Entrance_User_Pool* -_entrance_gui_user_pool_get(const char *name) -{ - Eina_List *node; - Entrance_User_Pool *pool; - EINA_LIST_FOREACH(_gui->user_pools, node, pool) - { - if (!strcmp(pool->name, name)) - { - return pool; - } - } - return NULL; -} - -Eina_List* -entrance_gui_user_icon_pool_get(const char *name) -{ - return _entrance_gui_user_pool_get(name)->icon_pool; -} - -Eina_List* -entrance_gui_user_background_pool_get(const char *name) -{ - return _entrance_gui_user_pool_get(name)->background_pool; -} - -void -entrance_gui_pools_set(const Entrance_Pools *pool) -{ - Entrance_Image *img; - EINA_LIST_FREE(_gui->background_pool, img) - { - eina_stringshare_del(img->path); - eina_stringshare_del(img->group); - free(img); - } - _gui->background_pool = pool->background_pool; - - EINA_LIST_FREE(_gui->icon_pool, img) - { - eina_stringshare_del(img->path); - eina_stringshare_del(img->group); - free(img); - } - _gui->icon_pool = pool->icon_pool; - - EINA_LIST_FREE(_gui->user_pools, img) - { - eina_stringshare_del(img->path); - eina_stringshare_del(img->group); - free(img); - } - _gui->user_pools = pool->user_pools; - -} void entrance_gui_theme_name_set(const char *theme) @@ -724,16 +691,19 @@ _entrance_gui_user_icon_random_get(Evas_Object *obj, const char *username) unsigned int rnd = 0; Evas_Object *o = NULL; Entrance_Image *img; + const Entrance_Login *el; Eina_List *user_icons = NULL, *sys_icons = NULL, *theme_icons = NULL; - user_icons = entrance_gui_user_icon_pool_get(username); + el = entrance_gui_user_get(username); + if (el) + user_icons = el->icon_pool; sys_icons = entrance_gui_icon_pool_get(); theme_icons = entrance_gui_theme_icons(); srand(time(NULL)); rnd = (((eina_list_count(user_icons) + eina_list_count(sys_icons) + eina_list_count(theme_icons)) * (double)rand()) / (RAND_MAX + 1.0)); - if ((rnd < eina_list_count(user_icons))) + if ((el) && (rnd < eina_list_count(user_icons))) { o = elm_icon_add(obj); img = eina_list_nth(user_icons, rnd); diff --git a/src/bin/entrance_gui.h b/src/bin/entrance_gui.h index 75d2e23..331a3e9 100644 --- a/src/bin/entrance_gui.h +++ b/src/bin/entrance_gui.h @@ -30,10 +30,6 @@ const char *entrance_gui_theme_path_get(void); void entrance_gui_user_bg_set(const char *path, const char *group); Eina_List* entrance_gui_background_pool_get(void); Eina_List* entrance_gui_icon_pool_get(void); -void entrance_gui_pools_set(const Entrance_Pools *pool); -Eina_List* entrance_gui_user_icon_pool_get(const char *name); -Eina_List* entrance_gui_user_background_pool_get(const char *name); - /* char *entrance_gui_user_get(); char *entrance_gui_password_get(); diff --git a/src/daemon/entrance_history.c b/src/daemon/entrance_history.c index cf3aa4c..b958121 100644 --- a/src/daemon/entrance_history.c +++ b/src/daemon/entrance_history.c @@ -245,6 +245,8 @@ _entrance_user_init(void) } } eina_stringshare_del(user); + eu->icon_pool = entrance_image_user_icons(eu->login); + eu->background_pool = entrance_image_user_backgrounds(eu->login); _lusers = eina_list_append(_lusers, eu); } } @@ -253,6 +255,7 @@ static void _entrance_user_shutdown(void) { Entrance_Login *eu; + char *buf; EINA_LIST_FREE(_lusers, eu) { if (!_entrance_history_match(eu->login)) @@ -263,6 +266,14 @@ _entrance_user_shutdown(void) eina_stringshare_del(eu->image.group); eina_stringshare_del(eu->bg.path); eina_stringshare_del(eu->bg.group); + EINA_LIST_FREE(eu->background_pool, buf) + { + eina_stringshare_del(buf); + } + EINA_LIST_FREE(eu->icon_pool, buf) + { + eina_stringshare_del(buf); + } free(eu); } } diff --git a/src/daemon/entrance_image.c b/src/daemon/entrance_image.c index 816f0a9..8700622 100644 --- a/src/daemon/entrance_image.c +++ b/src/daemon/entrance_image.c @@ -108,46 +108,3 @@ entrance_image_user_backgrounds(const char *username) snprintf(path, sizeof(path),"%s/.config/entrance/images/backgrounds/", homedir); return _entrance_image_get(_entrance_image_readdir(path), NULL, NULL); } - -Eina_List* -entrance_image_user_pool_get(Eina_List *users) -{ - Eina_List *node, *result = NULL; - Entrance_Login *eu; - Entrance_User_Pool *pool; - - EINA_LIST_FOREACH(users, node, eu) - { - pool = calloc(1, sizeof(Entrance_User_Pool)); - pool->name = eina_stringshare_add(eu->login); - pool->icon_pool = entrance_image_user_icons(pool->name); - pool->background_pool = entrance_image_user_backgrounds(pool->name); - result = eina_list_append(result, pool); - } - return result; -} - -void -entrance_image_user_pool_free(Eina_List *user_pool) -{ - Entrance_User_Pool *pool; - Entrance_Image *img; - - EINA_LIST_FREE(user_pool, pool) - { - eina_stringshare_del(pool->name); - EINA_LIST_FREE(pool->icon_pool, img) - { - eina_stringshare_del(img->path); - eina_stringshare_del(img->group); - free(img); - } - EINA_LIST_FREE(pool->background_pool, img) - { - eina_stringshare_del(img->path); - eina_stringshare_del(img->group); - free(img); - } - free(pool); - } -} diff --git a/src/daemon/entrance_image.h b/src/daemon/entrance_image.h index 0445bbb..425efd3 100644 --- a/src/daemon/entrance_image.h +++ b/src/daemon/entrance_image.h @@ -5,7 +5,6 @@ Eina_List* entrance_image_system_icons(); Eina_List* entrance_image_system_backgrounds(); Eina_List* entrance_image_user_icons(const char *username); Eina_List* entrance_image_user_backgrounds(const char *username); -Eina_List* entrance_image_user_pool_get(Eina_List *users); -void entrance_image_user_pool_free(Eina_List *user_pool); + #endif /* ENTRANCE_H_ */ diff --git a/src/daemon/entrance_server.c b/src/daemon/entrance_server.c index a0c45a9..2fec79a 100644 --- a/src/daemon/entrance_server.c +++ b/src/daemon/entrance_server.c @@ -14,6 +14,7 @@ static Eina_Bool _entrance_server_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED) { Entrance_Event eev; + Entrance_Image *img; PT("server client connected\n"); PT("Sending users\n"); @@ -39,15 +40,22 @@ _entrance_server_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event E eev.event.conf_gui.enabled = EINA_TRUE; eev.event.conf_gui.bg.path = entrance_config->bg.path; eev.event.conf_gui.bg.group = entrance_config->bg.group; + eev.event.conf_gui.background_pool = entrance_image_system_backgrounds(); + eev.event.conf_gui.icon_pool = entrance_image_system_icons(); entrance_event_send(&eev); + EINA_LIST_FREE(eev.event.conf_gui.background_pool, img) + { + eina_stringshare_del(img->path); + eina_stringshare_del(img->group); + free(img); + } + EINA_LIST_FREE(eev.event.conf_gui.icon_pool, img) + { + eina_stringshare_del(img->path); + eina_stringshare_del(img->group); + free(img); + } } - PT("Sending pools\n"); - eev.type = ENTRANCE_EVENT_POOLS; - eev.event.pools.icon_pool = entrance_image_system_icons(); - eev.event.pools.background_pool = entrance_image_system_backgrounds(); - eev.event.pools.user_pools = entrance_image_user_pool_get(entrance_history_get()); - entrance_event_send(&eev); - entrance_image_user_pool_free(eev.event.pools.user_pools); return ECORE_CALLBACK_RENEW; } diff --git a/src/event/entrance_event.c b/src/event/entrance_event.c index cf26747..3cd4b7b 100644 --- a/src/event/entrance_event.c +++ b/src/event/entrance_event.c @@ -12,7 +12,6 @@ #define ENTRANCE_EVENT_ACTION_NAME "EntranceEventAction" #define ENTRANCE_EVENT_CONF_GUI_NAME "EntranceEventConfGui" #define ENTRANCE_EVENT_CONF_USER_NAME "EntranceEventConfUser" -#define ENTRANCE_EVENT_POOLS_NAME "EntranceEventPools" static Eina_Bool _entrance_event_type_set(const char *type, void *data, Eina_Bool unknow); static const char *_entrance_event_type_get(const void *data, Eina_Bool *unknow); @@ -62,8 +61,6 @@ _entrance_event_type_set(const char *type, void *data, Eina_Bool unknow) *ev = ENTRANCE_EVENT_ACTION; else if (!strcmp(type, ENTRANCE_EVENT_CONF_GUI_NAME)) *ev = ENTRANCE_EVENT_CONF_GUI; - else if (!strcmp(type, ENTRANCE_EVENT_POOLS_NAME)) - *ev = ENTRANCE_EVENT_POOLS; else { printf("error on type set %s\n", type); @@ -95,8 +92,6 @@ _entrance_event_type_get(const void *data, Eina_Bool *unknow) return ENTRANCE_EVENT_ACTION_NAME; else if (*ev == ENTRANCE_EVENT_CONF_GUI) return ENTRANCE_EVENT_CONF_GUI_NAME; - else if (*ev == ENTRANCE_EVENT_POOLS) - return ENTRANCE_EVENT_POOLS_NAME; else { printf("error on type get %d\n", *ev); @@ -160,11 +155,12 @@ _entrance_event_maxtries_dd(void) static Eet_Data_Descriptor * _entrance_event_conf_gui_dd(void) { - Eet_Data_Descriptor *edd; + Eet_Data_Descriptor *edd, *eddi; Eet_Data_Descriptor_Class eddc; EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_Conf_Gui_Event); edd = eet_data_descriptor_stream_new(&eddc); + eddi = _entrance_event_image_dd(); EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Conf_Gui_Event, "enabled", enabled, EET_T_UCHAR); EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Conf_Gui_Event, "bg.path", @@ -173,6 +169,10 @@ _entrance_event_conf_gui_dd(void) bg.group, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Conf_Gui_Event, "vkbd_enabled", vkbd_enabled, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_Conf_Gui_Event, "icon_pool", + icon_pool, eddi); + EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_Conf_Gui_Event, "background_pool", + background_pool, eddi); return edd; } @@ -223,8 +223,9 @@ _entrance_event_users_dd(void) static Eet_Data_Descriptor * _entrance_event_conf_user_dd(void) { - Eet_Data_Descriptor *edd; + Eet_Data_Descriptor *edd, *eddi; Eet_Data_Descriptor_Class eddc; + eddi = _entrance_event_image_dd(); EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_Login); edd = eet_data_descriptor_stream_new(&eddc); #define EET_LOGIN_ADD(NAME, TYPE) \ @@ -237,6 +238,14 @@ _entrance_event_conf_user_dd(void) EET_LOGIN_ADD(lsess, EET_T_STRING); EET_LOGIN_ADD(remember_session, EET_T_INT); // TODO screenshot + + if (stream) + { + EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_Login, "icon_pool", + icon_pool, eddi); + EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_Login, "background_pool", + background_pool, eddi); + } #undef EET_LOGIN_ADD return edd; } @@ -270,41 +279,6 @@ _entrance_event_action_dd(void) action, EET_T_UCHAR); return edd; } -static Eet_Data_Descriptor * -_entrance_event_user_pool_dd(void) -{ - Eet_Data_Descriptor *edd, *eddi; - Eet_Data_Descriptor_Class eddc; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_User_Pool); - edd = eet_data_descriptor_stream_new(&eddc); - eddi = _entrance_event_image_dd(); - EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_User_Pool, "name", - name, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_User_Pool, "icon_pool", - icon_pool, eddi); - EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_User_Pool, "background_pool", - background_pool, eddi); - return edd; -} -static Eet_Data_Descriptor * -_entrance_event_pools_dd(void) -{ - Eet_Data_Descriptor *edd, *eddi, *eddup; - Eet_Data_Descriptor_Class eddc; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_Pools); - edd = eet_data_descriptor_stream_new(&eddc); - eddi = _entrance_event_image_dd(); - eddup = _entrance_event_user_pool_dd(); - - EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_Pools, "icon_pool", - icon_pool, eddi); - EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_Pools, "background_pool", - background_pool, eddi); - EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_Pools, "user_pools", - user_pools, eddup); - return edd; -} - static Eet_Data_Descriptor * _entrance_event_new(void) @@ -339,8 +313,6 @@ _entrance_event_new(void) _entrance_event_action_dd()); EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_CONF_GUI_NAME, _entrance_event_conf_gui_dd()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_POOLS_NAME, - _entrance_event_pools_dd()); EET_DATA_DESCRIPTOR_ADD_UNION(edd, Entrance_Event, "event", event, type, unified); diff --git a/src/event/entrance_event.h b/src/event/entrance_event.h index 3b7341b..eb6e4ee 100644 --- a/src/event/entrance_event.h +++ b/src/event/entrance_event.h @@ -13,7 +13,6 @@ typedef enum Entrance_Event_Type_ ENTRANCE_EVENT_ACTION, ENTRANCE_EVENT_MAXTRIES, ENTRANCE_EVENT_CONF_GUI, - ENTRANCE_EVENT_POOLS } Entrance_Event_Type; typedef struct Entrance_Xsession_ @@ -78,6 +77,8 @@ typedef struct Entrance_Conf_Gui_Event_ const char *path; } bg; Eina_Bool vkbd_enabled; + Eina_List *background_pool; + Eina_List *icon_pool; } Entrance_Conf_Gui_Event; @@ -94,22 +95,10 @@ typedef struct Entrance_Login_ Entrance_Image bg; Entrance_Image image; Eina_Bool remember_session; + Eina_List *icon_pool; + Eina_List *background_pool; } Entrance_Login; -typedef struct Entrance_User_Pool_ -{ - const char *name; - Eina_List *icon_pool; - Eina_List *background_pool; -} Entrance_User_Pool; - -typedef struct Entrance_Pools_ -{ - Eina_List *icon_pool; - Eina_List *background_pool; - Eina_List *user_pools; -} Entrance_Pools; - typedef struct Entrance_Event_ { Entrance_Event_Type type; @@ -124,7 +113,6 @@ typedef struct Entrance_Event_ Entrance_Actions_Event actions; Entrance_Action_Event action; Entrance_Conf_Gui_Event conf_gui; - Entrance_Pools pools; } event; } Entrance_Event;