diff --git a/src/bin/entrance_conf.c b/src/bin/entrance_conf.c index 1d23821..e3f400d 100644 --- a/src/bin/entrance_conf.c +++ b/src/bin/entrance_conf.c @@ -19,6 +19,7 @@ typedef struct Entrance_Int_Conf_ const char *elm_profile; Eina_Bool vkbd_enabled : 1; double scale; + Eina_Bool update : 1; struct { @@ -36,6 +37,7 @@ typedef struct Entrance_Int_Conf_ } image; const char *lsess; Eina_Bool remember_session : 1; + Eina_Bool update : 1; } user; struct @@ -43,7 +45,6 @@ typedef struct Entrance_Int_Conf_ Evas_Object *btn_ok; Evas_Object *btn_apply; } gui; - } Entrance_Int_Conf; @@ -324,20 +325,23 @@ _entrance_conf_apply(void) conf.bg.group = _entrance_int_conf->bg.group; conf.vkbd_enabled = _entrance_int_conf->vkbd_enabled; - if (_entrance_int_conf->scale != elm_config_scale_get()) + if (_entrance_int_conf->update) { - elm_config_scale_set(_entrance_int_conf->scale); - elm_config_all_flush(); - elm_config_save(); + if (_entrance_int_conf->scale != elm_config_scale_get()) + { + elm_config_scale_set(_entrance_int_conf->scale); + elm_config_all_flush(); + elm_config_save(); + } + if (_entrance_int_conf->theme != entrance_gui_theme_name_get()) + { + entrance_gui_theme_name_set(_entrance_int_conf->theme); + } + entrance_gui_conf_set(&conf); + entrance_connect_conf_gui_send(&conf); } - if (_entrance_int_conf->theme != entrance_gui_theme_name_get()) - { - entrance_gui_theme_name_set(_entrance_int_conf->theme); - } - entrance_gui_conf_set(&conf); - entrance_connect_conf_send(&conf); - if (_entrance_int_conf->user.orig) + if (_entrance_int_conf->user.update) { Entrance_Login *eu; eu = _entrance_int_conf->user.orig; @@ -357,6 +361,7 @@ _entrance_conf_apply(void) eu->remember_session = _entrance_int_conf->user.remember_session; if (eu->lsess != _entrance_int_conf->user.lsess) eina_stringshare_replace(&eu->lsess, _entrance_int_conf->user.lsess); + entrance_connect_conf_user_send(eu); /* printf("%s | %s\n%s | %s\n%s | %s\n%s | %s\n%d | %d\n%s | %s\n", eu->bg.path, _entrance_int_conf->user.bg.path, @@ -657,20 +662,23 @@ _entrance_conf_changed(void) const char *bg_group; entrance_gui_background_get(&bg_path, &bg_group); - if (((_entrance_int_conf->theme != entrance_gui_theme_name_get()) - || (_entrance_int_conf->bg.path != bg_path) - || (_entrance_int_conf->bg.group != bg_group) - || (_entrance_int_conf->scale != elm_config_scale_get()) - || (_entrance_int_conf->elm_profile != elm_config_profile_get()) - || (_entrance_int_conf->vkbd_enabled != entrance_gui_vkbd_enabled_get())) - || ((_entrance_int_conf->user.orig) && - ((_entrance_int_conf->user.orig->bg.path != _entrance_int_conf->user.bg.path) - || (_entrance_int_conf->user.orig->bg.group != _entrance_int_conf->user.bg.group) - || (_entrance_int_conf->user.orig->image.path != _entrance_int_conf->user.image.path) - || (_entrance_int_conf->user.orig->image.group != _entrance_int_conf->user.image.group) - || (_entrance_int_conf->user.orig->remember_session != _entrance_int_conf->user.remember_session) - || (_entrance_int_conf->user.orig->lsess != _entrance_int_conf->user.lsess)))) + _entrance_int_conf->update = + !!((_entrance_int_conf->theme != entrance_gui_theme_name_get()) + || (_entrance_int_conf->bg.path != bg_path) + || (_entrance_int_conf->bg.group != bg_group) + || (_entrance_int_conf->scale != elm_config_scale_get()) + || (_entrance_int_conf->elm_profile != elm_config_profile_get()) + || (_entrance_int_conf->vkbd_enabled != entrance_gui_vkbd_enabled_get())); + if (_entrance_int_conf->user.orig) + _entrance_int_conf->user.update = + !!((_entrance_int_conf->user.orig->bg.path != _entrance_int_conf->user.bg.path) + || (_entrance_int_conf->user.orig->bg.group != _entrance_int_conf->user.bg.group) + || (_entrance_int_conf->user.orig->image.path != _entrance_int_conf->user.image.path) + || (_entrance_int_conf->user.orig->image.group != _entrance_int_conf->user.image.group) + || (_entrance_int_conf->user.orig->remember_session != _entrance_int_conf->user.remember_session) + || (_entrance_int_conf->user.orig->lsess != _entrance_int_conf->user.lsess)); + if (_entrance_int_conf->update || _entrance_int_conf->user.update) { elm_object_disabled_set(_entrance_int_conf->gui.btn_ok, EINA_FALSE); elm_object_disabled_set(_entrance_int_conf->gui.btn_apply, EINA_FALSE); diff --git a/src/bin/entrance_connect.c b/src/bin/entrance_connect.c index f05eefb..8b48973 100644 --- a/src/bin/entrance_connect.c +++ b/src/bin/entrance_connect.c @@ -140,10 +140,10 @@ entrance_connect_action_send(unsigned char id) } void -entrance_connect_conf_send(Entrance_Conf_Gui_Event *ev) +entrance_connect_conf_gui_send(Entrance_Conf_Gui_Event *ev) { Entrance_Event eev; - PT("Send config\n"); + PT("Send gui config\n"); eev.event.conf_gui.bg.path = ev->bg.path; eev.event.conf_gui.bg.group = ev->bg.group; @@ -151,6 +151,22 @@ entrance_connect_conf_send(Entrance_Conf_Gui_Event *ev) entrance_event_send(&eev); } +void +entrance_connect_conf_user_send(Entrance_Login *el) +{ + Entrance_Event eev; + PT("Send user config\n"); + eev.event.conf_user.login = el->login; + eev.event.conf_user.lsess = el->lsess; + eev.event.conf_user.image.group = el->image.group; + eev.event.conf_user.image.path = el->image.path; + 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.type = ENTRANCE_EVENT_CONF_USER; + entrance_event_send(&eev); +} + void * entrance_connect_auth_cb_add(Entrance_Connect_Auth_Cb func, void *data) { diff --git a/src/bin/entrance_connect.h b/src/bin/entrance_connect.h index 97def20..c07b170 100644 --- a/src/bin/entrance_connect.h +++ b/src/bin/entrance_connect.h @@ -6,7 +6,8 @@ typedef void (*Entrance_Connect_Auth_Cb)(void *data, const char *login, Eina_Boo void entrance_connect_init(void); void entrance_connect_auth_send(const char *login, const char *password, const char *session, Eina_Bool open_session); void entrance_connect_action_send(unsigned char id); -void entrance_connect_conf_send(Entrance_Conf_Gui_Event *conf); +void entrance_connect_conf_gui_send(Entrance_Conf_Gui_Event *conf); +void entrance_connect_conf_user_send(Entrance_Login *el); void *entrance_connect_auth_cb_add(Entrance_Connect_Auth_Cb func, void *data); void entrance_connect_auth_cb_del(void *list); void entrance_connect_shutdown(void); diff --git a/src/bin/entrance_gui.c b/src/bin/entrance_gui.c index cebc8df..3a8a410 100644 --- a/src/bin/entrance_gui.c +++ b/src/bin/entrance_gui.c @@ -549,7 +549,10 @@ _entrance_gui_user_content_get(void *data EINA_UNUSED, Evas_Object *obj, const c { const char *path, *group; ic = _entrance_gui_user_icon_random_get(obj); - edje_object_file_get(elm_layout_edje_get(ic), &path, &group); + edje_object_file_get( + elm_layout_edje_get( + elm_object_part_content_get(ic, "entrance.icon")), + &path, &group); eu->image.path = eina_stringshare_add(path); eu->image.group = eina_stringshare_add(group); } diff --git a/src/daemon/entrance_history.c b/src/daemon/entrance_history.c index 066acb9..45b0c02 100644 --- a/src/daemon/entrance_history.c +++ b/src/daemon/entrance_history.c @@ -7,7 +7,8 @@ static void _entrance_history_read(void); static void _entrance_history_write(void); static void _entrance_user_init(void); static void _entrance_user_shutdown(void); -const char *_entrance_history_match(const char *login); +Entrance_Login *_entrance_history_match(const char *login); +static void _entrance_history_user_set(Entrance_Login *el, const Entrance_Login *eu); static Eet_Data_Descriptor *_eddh; @@ -43,8 +44,20 @@ Eina_List void entrance_history_shutdown(void) { + Entrance_Login *el; + _entrance_history_write(); _entrance_user_shutdown(); + EINA_LIST_FREE(_entrance_history->history, el) + { + eina_stringshare_del(el->login); + eina_stringshare_del(el->image.path); + eina_stringshare_del(el->image.group); + eina_stringshare_del(el->bg.path); + eina_stringshare_del(el->bg.group); + eina_stringshare_del(el->lsess); + } + free(_entrance_history); } static void @@ -54,7 +67,8 @@ _entrance_history_read(void) ef = eet_open("/var/cache/"PACKAGE"/"ENTRANCE_HISTORY_FILE, EET_FILE_MODE_READ_WRITE); - if (!(ef) || !(_entrance_history = eet_data_read(ef, _eddh, ENTRANCE_SESSION_KEY))) + if (!(ef) + || !(_entrance_history = eet_data_read(ef, _eddh, ENTRANCE_SESSION_KEY))) { PT("Error on reading last session login\n"); _entrance_history = calloc(1, sizeof(Entrance_History)); @@ -66,7 +80,6 @@ static void _entrance_history_write(void) { Eet_File *ef; - Entrance_Login *el; if (_history_update) { @@ -83,15 +96,6 @@ _entrance_history_write(void) eet_close(ef); } - EINA_LIST_FREE(_entrance_history->history, el) - { - eina_stringshare_del(el->login); - eina_stringshare_del(el->image.path); - eina_stringshare_del(el->image.group); - eina_stringshare_del(el->bg.path); - eina_stringshare_del(el->bg.group); - eina_stringshare_del(el->lsess); - } } void @@ -129,7 +133,6 @@ entrance_history_push(const char *login, const char *session) { el->login = eina_stringshare_add(login); if (session) el->lsess = eina_stringshare_add(session); - else el->lsess = NULL; el->remember_session = EINA_TRUE; _entrance_history->history = eina_list_append(_entrance_history->history, el); @@ -138,19 +141,68 @@ entrance_history_push(const char *login, const char *session) } } +static void +_entrance_history_user_set(Entrance_Login *el, const Entrance_Login *eu) +{ + if (eu->lsess != el->lsess) + eina_stringshare_replace(&el->lsess, eu->lsess); + if (eu->image.path != el->image.path) + eina_stringshare_replace(&el->image.path, eu->image.path); + if (eu->image.group != el->image.group) + eina_stringshare_replace(&el->image.group, eu->image.group); + if (eu->bg.path != el->bg.path) + eina_stringshare_replace(&el->bg.path, eu->bg.path); + if (eu->bg.group != el->bg.group) + eina_stringshare_replace(&el->bg.group, eu->bg.group); + if (eu->remember_session != el->remember_session) + el->remember_session = eu->remember_session; +} -const char * -_entrance_history_match(const char *login) +void +entrance_history_user_update(const Entrance_Login *eu) { Eina_List *l; Entrance_Login *el; - const char *ret = NULL; + + PT("Updating user info\n"); + + EINA_LIST_FOREACH(_entrance_history->history, l, el) + { + if (!strcmp(eu->login, el->login)) + { + PT("Find user in history\n"); + _entrance_history_user_set(el, eu); + break; + } + } + if (!l) + { + EINA_LIST_FOREACH(_lusers, l, el) + { + if (!strcmp(eu->login, el->login)) + { + PT("Append user in history\n"); + _entrance_history_user_set(el, eu); + break; + } + } + } + _history_update = !!l; + _entrance_history_write(); +} + +Entrance_Login * +_entrance_history_match(const char *login) +{ + Eina_List *l; + Entrance_Login *el = NULL; + EINA_LIST_FOREACH(_entrance_history->history, l, el) { if (!strcmp(el->login, login)) - ret = el->lsess; + break; } - return ret; + return el; } static void @@ -181,18 +233,21 @@ _entrance_user_init(void) } EINA_LIST_FREE(lu, user) { - if ((eu = (Entrance_Login *) calloc(1, sizeof(Entrance_Login)))) + eu = _entrance_history_match(user); + if (!eu) { - eu->login = eina_stringshare_add(user); - snprintf(buf, sizeof(buf), - "/var/cache/"PACKAGE"/users/%s.edj", user); - if (ecore_file_exists(buf)) - eu->image.path = eina_stringshare_add(buf); - eu->lsess = _entrance_history_match(user); - eu->remember_session = EINA_TRUE; - eina_stringshare_del(user); - _lusers = eina_list_append(_lusers, eu); + if ((eu = (Entrance_Login *) calloc(1, sizeof(Entrance_Login)))) + { + eu->login = eina_stringshare_add(user); + snprintf(buf, sizeof(buf), + "/var/cache/"PACKAGE"/users/%s.edj", user); + if (ecore_file_exists(buf)) + eu->image.path = eina_stringshare_add(buf); + eu->remember_session = EINA_TRUE; + } } + eina_stringshare_del(user); + _lusers = eina_list_append(_lusers, eu); } } @@ -203,8 +258,12 @@ _entrance_user_shutdown(void) EINA_LIST_FREE(_lusers, eu) { eina_stringshare_del(eu->login); + eina_stringshare_del(eu->lsess); + eina_stringshare_del(eu->image.path); + eina_stringshare_del(eu->image.group); + eina_stringshare_del(eu->bg.path); + eina_stringshare_del(eu->bg.group); free(eu); } - free(_entrance_history); } diff --git a/src/daemon/entrance_history.h b/src/daemon/entrance_history.h index b5de67a..8ebbc62 100644 --- a/src/daemon/entrance_history.h +++ b/src/daemon/entrance_history.h @@ -5,6 +5,7 @@ void entrance_history_init(void); void entrance_history_shutdown(void); void entrance_history_push(const char *login, const char *session); Eina_List *entrance_history_get(void); +void entrance_history_user_update(const Entrance_Login *el); typedef struct _Entrance_History Entrance_History; diff --git a/src/daemon/entrance_server.c b/src/daemon/entrance_server.c index 9ae3331..21c95ba 100644 --- a/src/daemon/entrance_server.c +++ b/src/daemon/entrance_server.c @@ -39,9 +39,6 @@ _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; - - printf("sending %s %s\n", entrance_config->bg.path, - entrance_config->bg.group); entrance_event_send(&eev); } return ECORE_CALLBACK_RENEW; @@ -112,6 +109,11 @@ _entrance_server_read_cb(const void *data, size_t size EINA_UNUSED, void *user_d PT("Conf Gui received\n"); entrance_config_set(&eev->event.conf_gui); } + else if (eev->type == ENTRANCE_EVENT_CONF_USER) + { + PT("Conf user received\n"); + entrance_history_user_update(&eev->event.conf_user); + } else PT("UNKNOW signal server\n"); return EINA_TRUE; diff --git a/src/event/entrance_event.c b/src/event/entrance_event.c index 5e19101..4eef956 100644 --- a/src/event/entrance_event.c +++ b/src/event/entrance_event.c @@ -8,10 +8,10 @@ #define ENTRANCE_EVENT_XSESSIONS_NAME "EntranceEventSession" #define ENTRANCE_EVENT_STATUS_NAME "EntranceEventStatus" #define ENTRANCE_EVENT_USERS_NAME "EntranceEventUsers" -#define ENTRANCE_EVENT_USER_NAME "EntranceEventUser" #define ENTRANCE_EVENT_ACTIONS_NAME "EntranceEventActions" #define ENTRANCE_EVENT_ACTION_NAME "EntranceEventAction" #define ENTRANCE_EVENT_CONF_GUI_NAME "EntranceEventConfGui" +#define ENTRANCE_EVENT_CONF_USER_NAME "EntranceEventConfUser" 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); @@ -21,7 +21,7 @@ static Eet_Data_Descriptor *_entrance_event_xsessions_dd(void); static Eet_Data_Descriptor *_entrance_event_conf_gui_dd(void); static Eet_Data_Descriptor *_entrance_event_maxtries_dd(void); static Eet_Data_Descriptor *_entrance_event_users_dd(void); -static Eet_Data_Descriptor *_entrance_event_user_dd(void); +static Eet_Data_Descriptor *_entrance_event_conf_user_dd(void); static Eet_Data_Descriptor *_entrance_event_actions_dd(void); static Eet_Data_Descriptor *_entrance_event_action_dd(void); static Eet_Data_Descriptor *_entrance_event_new(void); @@ -52,8 +52,8 @@ _entrance_event_type_set(const char *type, void *data, Eina_Bool unknow) *ev = ENTRANCE_EVENT_XSESSIONS; else if (!strcmp(type, ENTRANCE_EVENT_USERS_NAME)) *ev = ENTRANCE_EVENT_USERS; - else if (!strcmp(type, ENTRANCE_EVENT_USER_NAME)) - *ev = ENTRANCE_EVENT_USER; + else if (!strcmp(type, ENTRANCE_EVENT_CONF_USER_NAME)) + *ev = ENTRANCE_EVENT_CONF_USER; else if (!strcmp(type, ENTRANCE_EVENT_ACTIONS_NAME)) *ev = ENTRANCE_EVENT_ACTIONS; else if (!strcmp(type, ENTRANCE_EVENT_ACTION_NAME)) @@ -62,7 +62,7 @@ _entrance_event_type_set(const char *type, void *data, Eina_Bool unknow) *ev = ENTRANCE_EVENT_CONF_GUI; else { - printf("error on type set\n"); + printf("error on type set %s\n", type); *ev = ENTRANCE_EVENT_UNKNOWN; return EINA_FALSE; } @@ -83,8 +83,8 @@ _entrance_event_type_get(const void *data, Eina_Bool *unknow) return ENTRANCE_EVENT_XSESSIONS_NAME; else if (*ev == ENTRANCE_EVENT_USERS) return ENTRANCE_EVENT_USERS_NAME; - else if (*ev == ENTRANCE_EVENT_USER) - return ENTRANCE_EVENT_USER_NAME; + else if (*ev == ENTRANCE_EVENT_CONF_USER) + return ENTRANCE_EVENT_CONF_USER_NAME; else if (*ev == ENTRANCE_EVENT_ACTIONS) return ENTRANCE_EVENT_ACTIONS_NAME; else if (*ev == ENTRANCE_EVENT_ACTION) @@ -93,7 +93,7 @@ _entrance_event_type_get(const void *data, Eina_Bool *unknow) return ENTRANCE_EVENT_CONF_GUI_NAME; else { - printf("error on type get\n"); + printf("error on type get %d\n", *ev); if (unknow) *unknow = EINA_TRUE; } @@ -191,7 +191,7 @@ _entrance_event_users_dd(void) Eet_Data_Descriptor *edd, *eddl; Eet_Data_Descriptor_Class eddc, eddcl; EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_Login); - edd = _entrance_event_user_dd(); + edd = _entrance_event_conf_user_dd(); EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddcl, Entrance_Users_Event); eddl = eet_data_descriptor_stream_new(&eddcl); EET_DATA_DESCRIPTOR_ADD_LIST(eddl, Entrance_Users_Event, "users", @@ -200,7 +200,7 @@ _entrance_event_users_dd(void) } static Eet_Data_Descriptor * -_entrance_event_user_dd(void) +_entrance_event_conf_user_dd(void) { Eet_Data_Descriptor *edd; Eet_Data_Descriptor_Class eddc; @@ -276,8 +276,8 @@ _entrance_event_new(void) _entrance_event_status_dd()); EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_USERS_NAME, _entrance_event_users_dd()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_USER_NAME, - _entrance_event_user_dd()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_CONF_USER_NAME, + _entrance_event_conf_user_dd()); EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_ACTIONS_NAME, _entrance_event_actions_dd()); EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_ACTION_NAME, @@ -335,5 +335,5 @@ entrance_event_received(const void *data, size_t size) Eet_Data_Descriptor * entrance_event_user_dd(void) { - return _entrance_event_user_dd(); + return _entrance_event_conf_user_dd(); } diff --git a/src/event/entrance_event.h b/src/event/entrance_event.h index e1a0399..187ab48 100644 --- a/src/event/entrance_event.h +++ b/src/event/entrance_event.h @@ -8,7 +8,7 @@ typedef enum Entrance_Event_Type_ ENTRANCE_EVENT_STATUS, ENTRANCE_EVENT_XSESSIONS, ENTRANCE_EVENT_USERS, - ENTRANCE_EVENT_USER, + ENTRANCE_EVENT_CONF_USER, ENTRANCE_EVENT_ACTIONS, ENTRANCE_EVENT_ACTION, ENTRANCE_EVENT_MAXTRIES, @@ -105,7 +105,7 @@ typedef struct Entrance_Event_ Entrance_Maxtries_Event maxtries; Entrance_Status_Event status; Entrance_Users_Event users; - Entrance_Login user; + Entrance_Login conf_user; Entrance_Actions_Event actions; Entrance_Action_Event action; Entrance_Conf_Gui_Event conf_gui;