diff --git a/data/themes/default/default.edc b/data/themes/default/default.edc index 82c3d7e..8603045 100644 --- a/data/themes/default/default.edc +++ b/data/themes/default/default.edc @@ -92,7 +92,7 @@ collections { visible: 1; } } - part { name: "entrance.login"; + part { name: "entrance.screen"; type: SWALLOW; description { state: "default" 0.0; visible: 1; @@ -196,32 +196,6 @@ collections { } } /* - part { name: "entrance.error"; - type: TEXT; - mouse_events: 0; - effect: SOFT_SHADOW; - scale: 1; - description { state: "default" 0.0; - color: 255 255 255 0; - fixed: 1 1; - rel1.to_y: "entrance.xsessions"; - rel1.relative: 0.0 1.0; - align: 0.5 0.0; - text { - text: "Error on login ! Maybe wrong password ?"; - font: "Sans"; - size: 18; - min: 1 1; - align: 0.5 0.5; - } - } - description { state: "visible" 0.0; - inherit: "default" 0.0; - rel1.offset: 0 50; - rel2.offset: 0 50; - color: 255 255 255 255; - } - } */ } programs { @@ -274,6 +248,18 @@ collections { group { name : "entrance/login"; parts { + part { + name: "error"; + type: RECT; + description { state: "default" 0.0; + color: 255 0 0 96; + visible: 0; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } part { name: "entrance.login"; type: SWALLOW; @@ -293,7 +279,6 @@ collections { name: "entrance.password"; type: SWALLOW; repeat_events: 0; - source: "entrance/entry/password"; description { state: "default" 0.0; min: 140 0; @@ -316,9 +301,39 @@ collections { visible: 1; } } + part { name: "entrance.error"; + type: TEXT; + mouse_events: 0; + effect: SOFT_SHADOW; + scale: 1; + description { state: "default" 0.0; + visible: 0; + color: 255 255 255 0; + fixed: 1 1; + rel1.to_y: "entrance.xsessions"; + rel1.relative: 0.0 1.0; + align: 0.5 0.0; + rel1.offset: 0 50; + rel2.offset: -1 51; + text { + text: "Error on login ! Maybe wrong password ?"; + font: "Sans"; + size: 18; + min: 1 1; + align: 0.5 0.5; + } + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + color: 255 255 255 255; + } + } /* + * * PROGRAMS + * */ programs { program { @@ -335,30 +350,24 @@ collections { action: STATE_SET "default" 0.0; target: "entrance.xsessions"; } - } - - /* - * - * PROGRAMS - * - - programs { program { name: "login_error"; signal: "entrance,auth,error"; source: ""; action: STATE_SET "visible" 0.0; - transition: DECELERATE 0.2; + target: "error"; target: "entrance.error"; } program { name: "login_change"; - signal: "entrance.auth.change"; + signal: "entrance,auth,changed"; source: ""; action: STATE_SET "default" 0.0; - transition: ACCELERATE 0.4; + target: "error"; target: "entrance.error"; } + } +/* program { name: "auth_enable"; @@ -389,6 +398,8 @@ collections { transition: LINEAR 0.7; target: "clip"; } + * If you want check auth, emit this signal "entrance.auth.request" "" + * Here is an example program { name: "login_valid"; signal: "mouse,down,*"; diff --git a/src/bin/entrance_client.c b/src/bin/entrance_client.c index 1d30835..a757364 100644 --- a/src/bin/entrance_client.c +++ b/src/bin/entrance_client.c @@ -60,19 +60,22 @@ main(int argc, char **argv) elm_init(argc, argv); PT("login init\n"); entrance_login_init(); - PT("client init\n"); + PT("gui init\n"); if (!entrance_gui_init(theme)) return EXIT_FAILURE; - PT("client run\n"); + PT("connect init\n"); entrance_connect_init(); elm_run(); + PT("connect shutdown\n"); entrance_connect_shutdown(); - PT("_client: client shutdown\n"); + PT("gui shutdown\n"); entrance_gui_shutdown(); + PT("login shutdown\n"); entrance_login_shutdown(); elm_shutdown(); ecore_x_shutdown(); ecore_shutdown(); eina_shutdown(); + PT("exit\n"); return EXIT_SUCCESS; } diff --git a/src/bin/entrance_connect.c b/src/bin/entrance_connect.c index 95a804f..820eec9 100644 --- a/src/bin/entrance_connect.c +++ b/src/bin/entrance_connect.c @@ -1,13 +1,19 @@ #include #include "entrance_client.h" +typedef struct +{ + Entrance_Connect_Auth_Cb func; + void *data; +} Entrance_Connect_Auth; static Eina_Bool _entrance_connect_add(void *data, int type, void *event); static Eina_Bool _entrance_connect_del(void *data, int type, void *event); static Eina_Bool _entrance_connect_data(void *data, int type, void *event); -Ecore_Con_Server *_entrance_connect; -Eina_List *_handlers; +static Ecore_Con_Server *_entrance_connect; +static Eina_List *_handlers = NULL; +static Eina_List *_auth_list = NULL; static Eina_Bool _entrance_connect_add(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__) @@ -36,6 +42,19 @@ _entrance_connect_data(void *data __UNUSED__, int type __UNUSED__, void *event) return ECORE_CALLBACK_RENEW; } +static void +_entrance_connect_auth(Eina_Bool granted) +{ + Entrance_Connect_Auth *auth; + Eina_List *l, *ll; + + EINA_LIST_FOREACH_SAFE(_auth_list, l, ll, auth) + { + if (auth->func) + auth->func(auth->data, granted); + } +} + static Eina_Bool _entrance_connect_read_cb(const void *data, size_t size EINA_UNUSED, void *user_data EINA_UNUSED) { @@ -46,15 +65,10 @@ _entrance_connect_read_cb(const void *data, size_t size EINA_UNUSED, void *user_ if (eev->type == ENTRANCE_EVENT_STATUS) { if (eev->event.status.granted) - { - PT("Auth granted :)\n"); - entrance_gui_auth_valid(); - } + PT("Auth granted :)\n"); else - { - PT("Auth error :(\n"); - entrance_gui_auth_error(); - } + PT("Auth error :(\n"); + _entrance_connect_auth(eev->event.status.granted); } else if (eev->type == ENTRANCE_EVENT_MAXTRIES) { @@ -135,6 +149,24 @@ entrance_connect_conf_send(Entrance_Conf_Gui_Event *ev) entrance_event_send(&eev); } +void * +entrance_connect_auth_cb_add(Entrance_Connect_Auth_Cb func, void *data) +{ + PT("auth handler add\n"); + Entrance_Connect_Auth *auth; + auth = malloc(sizeof(Entrance_Connect_Auth)); + auth->func = func; + auth->data = data; + _auth_list = eina_list_append(_auth_list, auth); + return auth; +} + +void +entrance_connect_auth_cb_del(void *auth) +{ + PT("auth handler remove\n"); + _auth_list = eina_list_remove(_auth_list, auth); +} void entrance_connect_init() @@ -165,7 +197,6 @@ void entrance_connect_shutdown() { Ecore_Event_Handler *h; - PT("client server shutdown\n"); EINA_LIST_FREE(_handlers, h) ecore_event_handler_del(h); entrance_event_shutdown(); diff --git a/src/bin/entrance_connect.h b/src/bin/entrance_connect.h index e12aa76..9dfed41 100644 --- a/src/bin/entrance_connect.h +++ b/src/bin/entrance_connect.h @@ -1,8 +1,13 @@ #ifndef ENTRANCE_CONNECT_ #define ENTRANCE_CONNECT_ + +typedef void (*Entrance_Connect_Auth_Cb)(void *data, Eina_Bool granted); + void entrance_connect_init(); 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_auth_cb_add(Entrance_Connect_Auth_Cb func, void *data); +void entrance_connect_auth_cb_del(void *list); void entrance_connect_shutdown(); #endif /* ENTRANCE_CONNECT_ */ diff --git a/src/bin/entrance_fill.c b/src/bin/entrance_fill.c index 2e41139..949ddf8 100644 --- a/src/bin/entrance_fill.c +++ b/src/bin/entrance_fill.c @@ -99,7 +99,7 @@ _entrance_fill_gengrid(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, ///////////////// HOVERSEL ///////////////////////////// static void -_entrance_fill_hoversell_func_cb(void *data, Evas_Object *obj, void *event_info) +_entrance_fill_hoversell_func_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info) { Entrance_Fill *ef; diff --git a/src/bin/entrance_gui.c b/src/bin/entrance_gui.c index 0b3828d..7725dc5 100644 --- a/src/bin/entrance_gui.c +++ b/src/bin/entrance_gui.c @@ -14,6 +14,7 @@ static void _entrance_gui_user_del(void *data, Evas_Object *obj); static void _entrance_gui_actions_populate(); static void _entrance_gui_conf_clicked_cb(void *data, Evas_Object *obj, void *event_info); static void _entrance_gui_update(void); +static void _entrance_gui_auth_cb(void *data, Eina_Bool granted); /* @@ -118,8 +119,8 @@ entrance_gui_init(const char *theme) fprintf(stderr, "%s\n", "entrance"); return j; } - elm_object_part_content_set(o, "entrance.login", ol); - o = entrance_login_add(ol); + elm_object_part_content_set(o, "entrance.screen", ol); + o = entrance_login_add(ol, _entrance_gui_auth_cb, screen); entrance_login_open_session_set(o, EINA_TRUE); screen->login = o; elm_object_part_content_set(ol, "entrance.login", o); @@ -245,40 +246,6 @@ entrance_gui_stringlist_free(Eina_List *list) eina_stringshare_del(s); } -void -entrance_gui_auth_valid() -{ - Eina_List *l; - Entrance_Screen *screen; - EINA_LIST_FOREACH(_gui->screens, l, screen) - { - edje_object_signal_emit(elm_layout_edje_get(screen->edj), - "entrance,auth,valid", ""); - } - /* - _gui_login_timeout = ecore_timer_add(10.0, - _entrance_gui_login_timeout, - screen); - */ -} - -void -entrance_gui_auth_error() -{ - /* - Evas_Object *o; - Eina_List *l; - Entrance_Screen *screen; - - EINA_LIST_FOREACH(_gui->screens, l, screen) - { - o = ENTRANCE_GUI_GET(screen->edj, "entrance.password"); - elm_entry_entry_set(o, ""); - edje_object_signal_emit(elm_layout_edje_get(screen->edj), - "entrance,auth,error", ""); - } - */ -} void entrance_gui_actions_set(Eina_List *actions) @@ -329,7 +296,7 @@ entrance_gui_users_set(Eina_List *users) ol = ENTRANCE_GUI_GET(screen->edj, "entrance.users"); if (!ol) continue; entrance_fill(ol, ef, users, _entrance_gui_user_sel_cb, screen->login); - edje_object_signal_emit(elm_layout_edje_get(screen->edj), + elm_object_signal_emit(screen->edj, "entrance,users,enabled", ""); } _gui->users = users; @@ -882,6 +849,32 @@ _entrance_gui_actions_populate() } //////////////////////////////////////////////////////////////////////////////// +static void +_entrance_gui_auth_cb(void *data, Eina_Bool granted) +{ + Eina_List *l; + Entrance_Screen *screen; + + EINA_LIST_FOREACH(_gui->screens, l, screen) + { + if (granted) + { + elm_object_signal_emit(screen->edj, + "entrance,auth,valid", ""); + } + else + { + elm_object_signal_emit(screen->edj, + "entrance,auth,error", ""); + } + } + /* + if (granted) + _gui_login_timeout = ecore_timer_add(10.0, + _entrance_gui_login_timeout, + data); + */ +} static Eina_Bool _entrance_gui_cb_window_property(void *data EINA_UNUSED, int type EINA_UNUSED, void *event_info) diff --git a/src/bin/entrance_login.c b/src/bin/entrance_login.c index 5ca8fe3..40a36c6 100644 --- a/src/bin/entrance_login.c +++ b/src/bin/entrance_login.c @@ -19,6 +19,7 @@ static void _login_password_focused_cb(void *data, Evas_Object *obj, void *event static void _login_password_unfocused_cb(void *data, Evas_Object *obj, void *event); static void _login_login_activated_cb(void *data, Evas_Object *obj, void *event); static char *_login_xsession_text_get(void *data, Evas_Object *obj, const char *part); +static void _login_auth_cb(void *data, Eina_Bool granted); static Entrance_Fill *_login_fill; @@ -27,9 +28,16 @@ struct Entrance_Login_ Ecore_Event_Handler *handler; char passwd[ENTRANCE_PASSWD_LEN]; Entrance_Xsession *session; + struct + { + Entrance_Login_Cb login; + void *data; + } func; + void *auth; Eina_Bool open_session : 1; Eina_Bool selected : 1; Eina_Bool catch : 1; + Eina_Bool wait : 1; }; #define LOGIN_GET(widget) \ @@ -116,6 +124,9 @@ _login_check_auth(Evas_Object *widget) o = elm_object_part_content_get(widget, "entrance.login"); host = elm_entry_markup_to_utf8(elm_object_text_get(o)); + login->wait = EINA_TRUE; + if (!login->auth) + login->auth = entrance_connect_auth_cb_add(_login_auth_cb, widget); if (login->session) entrance_connect_auth_send(host, login->passwd, login->session->name, @@ -154,6 +165,13 @@ _login_key_down_cb(void *data, int type EINA_UNUSED, void *event) LOGIN_GET(data) ECORE_CALLBACK_PASS_ON; ev = event; + + elm_object_signal_emit(data, + "entrance,auth,changed", ""); + elm_object_signal_emit(elm_object_part_content_get(data, + "entrance.password"), + "entrance,auth,changed", ""); + if (!strcmp(ev->key, "KP_Enter")) { _login_check_auth(data); @@ -215,7 +233,7 @@ _login_key_down_cb(void *data, int type EINA_UNUSED, void *event) } } } - return ECORE_CALLBACK_PASS_ON; + return ECORE_CALLBACK_PASS_ON; } static Eina_Bool @@ -276,13 +294,50 @@ _login_xsession_update(Evas_Object *obj) } static void -_login_xsession_clicked_cb(void *data, Evas_Object *obj, void *event_info) +_login_xsession_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) { LOGIN_GET(data); login->session = elm_object_item_data_get(event_info); _login_xsession_update(data); } +static void +_login_auth_cb(void *data, Eina_Bool granted) +{ + LOGIN_GET(data); + if (login->wait) + { + if (login->func.login) + login->func.login(login->func.data, granted); + login->wait = EINA_FALSE; + entrance_connect_auth_cb_del(login->auth); + login->auth = NULL; + if (!granted) + { + elm_object_signal_emit(data, + "entrance,auth,error", ""); + elm_object_signal_emit( + elm_object_part_content_get(data, "entrance.login"), + "entrance,auth,error", "login"); + elm_object_signal_emit( + elm_object_part_content_get(data, "entrance.password"), + "entrance,auth,error", "password"); + } + else + { + elm_object_signal_emit(data, + "entrance,auth,valid", ""); + elm_object_signal_emit( + elm_object_part_content_get(data, "entrance.login"), + "entrance,auth,valid", "login"); + elm_object_signal_emit( + elm_object_part_content_get(data, "entrance.password"), + "entrance,auth,valid", "password"); + } + } +} + + //////////////////////////////////////////////////////////////////////////////// void @@ -302,14 +357,16 @@ entrance_login_shutdown(void) } Evas_Object * -entrance_login_add(Evas_Object *obj) +entrance_login_add(Evas_Object *obj, Entrance_Login_Cb login_cb, void *data) { Evas_Object *o, *h, *p; Entrance_Login *login; /* layout */ - o = entrance_gui_theme_get(obj, "entrance/login"); login = calloc(1, sizeof(Entrance_Login)); + login->func.login = login_cb; + login->func.data = data; + o = entrance_gui_theme_get(obj, "entrance/login"); evas_object_data_set(o, "entrance", login); @@ -376,7 +433,6 @@ void entrance_login_session_set(Evas_Object *widget, const char *name) { Entrance_Xsession *sess; - Evas_Object *o; const Eina_List *l = NULL; LOGIN_GET(widget); if (name) @@ -392,7 +448,6 @@ entrance_login_session_set(Evas_Object *widget, const char *name) } if (l) login->session = sess; - o = elm_object_part_content_get(widget, "entrance.xsessions"); _login_xsession_update(widget); } diff --git a/src/bin/entrance_login.h b/src/bin/entrance_login.h index 9fca437..d3c2d80 100644 --- a/src/bin/entrance_login.h +++ b/src/bin/entrance_login.h @@ -5,7 +5,7 @@ typedef void (*Entrance_Login_Cb) (void *data, Eina_Bool granted); void entrance_login_init(void); void entrance_login_shutdown(void); -Evas_Object *entrance_login_add(Evas_Object *win); +Evas_Object *entrance_login_add(Evas_Object *win, Entrance_Login_Cb login_cb, void *data); void entrance_login_xsessions_populate(Evas_Object *widget, Eina_List *xsessions); void entrance_login_login_set(Evas_Object *widget, const char *user); void entrance_login_session_set(Evas_Object *widget, const char *user);