entrance: many improvment

* improve pam login
* fix some profile mistake when login an user
* use EINA_UNUSED
* code refactoring
* remove session login command
This commit is contained in:
Michael Bouchaud 2013-10-29 19:26:56 +01:00
parent 91415dbc1d
commit 539a5d93a2
26 changed files with 421 additions and 266 deletions

View File

@ -14,8 +14,6 @@ group "Entrance_Config" struct {
/* Commands executed when starting a session */
value "session_start" string: "/usr/bin/sessreg -a -l :0.0";
/* Command executed when login. Warning xsession must be set to 0 */
value "session_login" string: "/bin/bash -login";
/* Commands executed when exiting a session */
value "session_stop" string: "/usr/bin/sessreg -d -l :0.0";
@ -35,8 +33,8 @@ group "Entrance_Config" struct {
/* Enable numlock TODO support it */
value "numlock" uchar: 1;
/** Bool to determine if entrance must login user with the session_login command
* or use xdg desktop and determine the command to use
/** Bool to determine if entrance could use the xdg desktop files and
* determine the command to use
* 1 = desktop_file_cmd, 0 = session_login */
value "xsessions" uchar: 1;
@ -47,7 +45,6 @@ group "Entrance_Config" struct {
/* The name of the user to use when autologin are enabled */
value "userlogin" string: "myusername";
/* Lock file */
value "lockfile" string: "/var/run/entrance.pid";

View File

@ -413,9 +413,6 @@ collections {
group { name: "entrance/conf/login";
parts {
alias: "entrance.login" "login:entrance.login";
alias: "entrance.password" "login:entrance.password";
alias: "entrance.xsessions" "login:entrance.xsessions";
part { name: "base";
type: RECT;
description { state: "default" 0.0;
@ -439,8 +436,8 @@ collections {
visible: 0;
}
}
part { name: "login";
type: GROUP;
part { name: "entrance.login";
type: SWALLOW;
description { state: "default" 0.0;
visible: 1;
}
@ -449,6 +446,15 @@ collections {
}
}
}
programs {
program { name: "conf_enabled";
signal: "entrance,conf_user,enabled";
source: "";
action: STATE_SET "hidden" 0.0;
target: "hover";
target: "entrance.login";
}
}
}
group { name: "entrance/user";

View File

@ -22,13 +22,19 @@ typedef struct Entrance_Int_Conf_
struct
{
const char *user;
Entrance_Login *orig;
struct
{
Evas_Object *preview;
const char *path;
const char *group;
} bg;
struct
{
const char *path;
const char *group;
} image;
const char *lsess;
Eina_Bool remember_session : 1;
} user;
@ -47,8 +53,12 @@ static char *_entrance_conf_bg_text_get(void *data, Evas_Object *obj, const char
static Evas_Object *_entrance_conf_bg_content_get(void *data, Evas_Object *obj, const char *part);
static Eina_Bool _entrance_conf_bg_state_get(void *data, Evas_Object *obj, const char *part);
static void _entrance_conf_bg_sel(void *data, Evas_Object *obj, void *event_info);
static Eina_Bool _entrance_conf_bg_fill_cb(void *data, Elm_Object_Item *it);
static void _entrance_conf_user_bg_sel(void *data, Evas_Object *obj, void *event_info);
static void _entrance_conf_changed();
static void _entrance_conf_apply();
static Evas_Object *_entrance_conf_user_build(Evas_Object *obj);
static void _entrance_conf_user_build_cb(Evas_Object *t, const char *user);
static Entrance_Fill *_entrance_background_fill = NULL;
static Entrance_Int_Conf *_entrance_int_conf = NULL;
@ -101,7 +111,6 @@ _entrance_conf_bg_sel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
{
Entrance_Conf_Background *cbg;
cbg = elm_object_item_data_get(event_info);
fprintf(stderr, "%s %s\n", cbg->path, cbg->group);
if (!elm_layout_file_set(_entrance_int_conf->bg.preview,
cbg->path, cbg->group))
{
@ -113,6 +122,43 @@ _entrance_conf_bg_sel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
_entrance_conf_changed();
}
static Eina_Bool
_entrance_conf_bg_fill_cb(void *data, Elm_Object_Item *it)
{
Entrance_Conf_Background *cbg;
const char *bg_path, *bg_group;
cbg = data;
entrance_gui_background_get(&bg_path, &bg_group);
if ((cbg->path)
&& (cbg->group)
&& (bg_path)
&& (bg_group)
&& (!strcmp(cbg->path, bg_path))
&& (!strcmp(cbg->group, bg_group)))
{
elm_genlist_item_selected_set(it, EINA_TRUE);
return EINA_TRUE;
}
return EINA_FALSE;
}
static void
_entrance_conf_user_bg_sel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Entrance_Conf_Background *cbg;
cbg = elm_object_item_data_get(event_info);
if (!elm_layout_file_set(_entrance_int_conf->user.bg.preview,
cbg->path, cbg->group))
{
PT("Error on loading ");
fprintf(stderr, "%s %s\n", cbg->path, cbg->group);
}
_entrance_int_conf->user.bg.path = cbg->path;
_entrance_int_conf->user.bg.group = cbg->group;
_entrance_conf_changed();
}
/* vkbd */
static void
_entrance_conf_vkbd_changed(void *data EINA_UNUSED, Evas_Object *obj, void *event EINA_UNUSED)
@ -144,7 +190,7 @@ _entrance_conf_ok_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event
}
static void
_entrance_conf_apply_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
_entrance_conf_apply_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{
_entrance_conf_apply();
_entrance_conf_changed();
@ -187,7 +233,6 @@ _entrance_conf_backgrounds_get(Evas_Object *obj, const char *user)
entrance_gui_stringlist_free(list);
evas_object_del(o);
//TODO parse share/entrance/background
it = eina_file_ls(PACKAGE_DATA_DIR"/backgrounds");
EINA_ITERATOR_FOREACH(it, str)
{
@ -200,6 +245,7 @@ _entrance_conf_backgrounds_get(Evas_Object *obj, const char *user)
snprintf(buf, sizeof(buf),
"entrance/background/%s", str);
cbg->path = str;
/* TODO use entrance/desktop/background or e/desktop/background */
cbg->group = eina_stringshare_add("e/desktop/background");
{
char *name, *p;
@ -232,6 +278,15 @@ _entrance_conf_apply()
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())
{
elm_config_scale_set(_entrance_int_conf->scale);
elm_config_all_flush();
}
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);
}
@ -240,7 +295,7 @@ _entrance_conf_apply()
static Evas_Object *
_entrance_conf_build(Evas_Object *obj)
{
Evas_Object *t, *bx, *hbx, *o;
Evas_Object *t, *bx, *hbx, *o, *gl;
Eina_List *l;
int j = 0;
@ -262,22 +317,18 @@ _entrance_conf_build(Evas_Object *obj)
elm_table_pack(t, hbx, 0, j, 2, 3);
evas_object_size_hint_weight_set(hbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(hbx, EVAS_HINT_FILL, EVAS_HINT_FILL);
o = elm_genlist_add(hbx);
elm_scroller_bounce_set(o, EINA_FALSE, EINA_TRUE);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
l = _entrance_conf_backgrounds_get(o, NULL);
entrance_fill(o, _entrance_background_fill,
l, _entrance_conf_bg_sel, o);
eina_list_free(l);
elm_box_pack_end(hbx, o);
evas_object_show(o);
gl = elm_genlist_add(hbx);
elm_scroller_bounce_set(gl, EINA_FALSE, EINA_TRUE);
evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(hbx, gl);
evas_object_show(gl);
bx = elm_box_add(hbx);
elm_box_pack_end(hbx, bx);
evas_object_show(bx);
o = elm_layout_add(hbx);
elm_box_pack_end(bx, o);
_entrance_int_conf->bg.preview = o;
elm_box_pack_end(bx, o);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(o);
@ -288,6 +339,10 @@ _entrance_conf_build(Evas_Object *obj)
evas_object_show(o);
evas_object_show(hbx);
j += 3;
l = _entrance_conf_backgrounds_get(gl, NULL);
entrance_fill(gl, _entrance_background_fill,
l, _entrance_conf_bg_fill_cb, _entrance_conf_bg_sel, o);
eina_list_free(l);
/* Touch Screen */
o = elm_label_add(t);
@ -360,20 +415,48 @@ _entrance_conf_build(Evas_Object *obj)
return t;
}
static void
_entrance_conf_user_auth(void *data, const char *user, Eina_Bool granted)
{
Evas_Object *t;
if (granted)
{
t = elm_object_part_content_get(data, "entrance.conf");
_entrance_conf_user_build_cb(t, user);
elm_object_signal_emit(data, "entrance,conf_user,enabled", "");
}
}
static Evas_Object *
_entrance_conf_user_build(Evas_Object *obj)
{
Evas_Object *t, *bx, *o, *ly;
int j = 0;
Evas_Object *t, *o, *ly;
ly = entrance_gui_theme_get(obj, "entrance/conf/login");
evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(ly);
o = entrance_login_add(ly, _entrance_conf_user_auth, ly);
elm_object_part_content_set(ly, "entrance.login", o);
evas_object_show(o);
t = elm_table_add(obj);
elm_object_part_content_set(ly, "entrance.conf", t);
evas_object_size_hint_weight_set(t, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_table_padding_set(t, 5 , 5);
return ly;
}
static void
_entrance_conf_user_build_cb(Evas_Object *t, const char *user)
{
Evas_Object *o, *bx, *hbx;
Entrance_Login *eu;
Eina_List *l;
const Eina_List *users, *ll;
int j = 0;
/* Background */
o = elm_label_add(t);
elm_object_text_set(o, "Background");
@ -382,14 +465,39 @@ _entrance_conf_user_build(Evas_Object *obj)
elm_table_pack(t, o, 0, j, 1, 1);
evas_object_show(o);
++j;
o = elm_gengrid_add(t);
hbx = elm_box_add(t);
elm_box_horizontal_set(hbx, EINA_TRUE);
elm_table_pack(t, hbx, 0, j, 2, 1);
++j;
evas_object_size_hint_weight_set(hbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(hbx, EVAS_HINT_FILL, EVAS_HINT_FILL);
o = elm_genlist_add(hbx);
elm_scroller_bounce_set(o, EINA_FALSE, EINA_TRUE);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_table_pack(t, o, 0, j, 2, 3);
elm_gengrid_item_size_set(o, 80, 50);
elm_gengrid_align_set(o, 0.0, 0.0);
l = _entrance_conf_backgrounds_get(o, user);
entrance_fill(o, _entrance_background_fill,
l, NULL, _entrance_conf_user_bg_sel, o);
eina_list_free(l);
elm_box_pack_end(hbx, o);
evas_object_show(o);
j += 3;
bx = elm_box_add(hbx);
elm_box_pack_end(hbx, bx);
evas_object_show(bx);
o = elm_layout_add(hbx);
_entrance_int_conf->user.bg.preview = o;
elm_box_pack_end(bx, o);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(o);
o = evas_object_rectangle_add(hbx);
evas_object_color_set(o, 0, 0, 0, 0);
evas_object_size_hint_min_set(o, 256, 0);
elm_box_pack_end(bx, o);
evas_object_show(o);
evas_object_show(hbx);
/* Icon */
/* Session to autoselect */
o = elm_label_add(t);
@ -422,7 +530,20 @@ _entrance_conf_user_build(Evas_Object *obj)
evas_object_show(t);
return ly;
users = entrance_gui_users_get();
EINA_LIST_FOREACH(users, ll, eu)
{
if (!strcmp(eu->login, user))
{
_entrance_int_conf->user.orig = eu;
_entrance_int_conf->user.bg.path = eu->bg.path;
_entrance_int_conf->user.bg.group = eu->bg.group;
_entrance_int_conf->user.image.path = eu->image.path;
_entrance_int_conf->user.image.group = eu->image.group;
break;
}
}
}
static void
@ -444,12 +565,20 @@ _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())
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.path != _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))))
{
elm_object_disabled_set(_entrance_int_conf->gui.btn_ok, EINA_FALSE);
elm_object_disabled_set(_entrance_int_conf->gui.btn_apply, EINA_FALSE);
@ -523,16 +652,6 @@ entrance_conf_begin(Evas_Object *obj, Evas_Object *parent)
elm_box_pack_end(bx, nf);
evas_object_show(nf);
o = _entrance_conf_build(nf);
it = elm_naviframe_item_simple_push(nf, o);
itc = elm_segment_control_item_add(sc, NULL, "General");
elm_object_item_data_set(itc, it);
o = _entrance_conf_user_build(nf);
itu = elm_naviframe_item_simple_push(nf, o);
ituc = elm_segment_control_item_add(sc, NULL, "User");
elm_object_item_data_set(ituc, itu);
/* Ok Apply Close */
hbx = elm_box_add(bx);
elm_box_horizontal_set(hbx, EINA_TRUE);
@ -570,6 +689,20 @@ entrance_conf_begin(Evas_Object *obj, Evas_Object *parent)
elm_box_pack_end(hbx, o);
evas_object_show(o);
/* Build configuration panel */
/* main */
o = _entrance_conf_build(nf);
it = elm_naviframe_item_simple_push(nf, o);
itc = elm_segment_control_item_add(sc, NULL, "General");
elm_object_item_data_set(itc, it);
/* user */
o = _entrance_conf_user_build(nf);
itu = elm_naviframe_item_simple_push(nf, o);
ituc = elm_segment_control_item_add(sc, NULL, "User");
elm_object_item_data_set(ituc, itu);
elm_segment_control_item_selected_set(itc, EINA_TRUE);
{

View File

@ -10,20 +10,21 @@ typedef struct
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);
static void _entrance_connect_auth(const char *login, Eina_Bool granted);
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__)
_entrance_connect_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
{
PT("connected\n");
return ECORE_CALLBACK_RENEW;
}
static Eina_Bool
_entrance_connect_del(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
_entrance_connect_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
{
PT("disconnected\n");
_entrance_connect = NULL;
@ -32,7 +33,7 @@ _entrance_connect_del(void *data __UNUSED__, int type __UNUSED__, void *event __
}
static Eina_Bool
_entrance_connect_data(void *data __UNUSED__, int type __UNUSED__, void *event)
_entrance_connect_data(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{
Ecore_Con_Event_Server_Data *ev;
ev = event;
@ -43,7 +44,7 @@ _entrance_connect_data(void *data __UNUSED__, int type __UNUSED__, void *event)
}
static void
_entrance_connect_auth(Eina_Bool granted)
_entrance_connect_auth(const char *login, Eina_Bool granted)
{
Entrance_Connect_Auth *auth;
Eina_List *l, *ll;
@ -51,7 +52,7 @@ _entrance_connect_auth(Eina_Bool granted)
EINA_LIST_FOREACH_SAFE(_auth_list, l, ll, auth)
{
if (auth->func)
auth->func(auth->data, granted);
auth->func(auth->data, login, granted);
}
}
@ -68,7 +69,8 @@ _entrance_connect_read_cb(const void *data, size_t size EINA_UNUSED, void *user_
PT("Auth granted :)\n");
else
PT("Auth error :(\n");
_entrance_connect_auth(eev->event.status.granted);
_entrance_connect_auth(eev->event.status.login,
eev->event.status.granted);
}
else if (eev->type == ENTRANCE_EVENT_MAXTRIES)
{

View File

@ -1,7 +1,7 @@
#ifndef ENTRANCE_CONNECT_
#define ENTRANCE_CONNECT_
typedef void (*Entrance_Connect_Auth_Cb)(void *data, Eina_Bool granted);
typedef void (*Entrance_Connect_Auth_Cb)(void *data, const char *login, 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);

View File

@ -5,10 +5,10 @@ struct Entrance_Fill_
const char *item_style; //maybee need to be provided by theme ?
struct
{
EntranceFillTextGetFunc text_get;
EntranceFillContentGetFunc content_get;
EntranceFillStateGetFunc state_get;
EntranceFillDelFunc del;
Entrance_Fill_Text_Get_Func text_get;
Entrance_Fill_Content_Get_Func content_get;
Entrance_Fill_State_Get_Func state_get;
Entrance_Fill_Del_Func del;
Evas_Smart_Cb sel;
void *data;
} func;
@ -18,7 +18,7 @@ struct Entrance_Fill_
///////////////// LIST ///////////////////////////////
static void
_entrance_fill_list(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Evas_Smart_Cb func, void *data)
_entrance_fill_list(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Entrance_Fill_Cb_Func fill_cb, Evas_Smart_Cb func, void *data)
{
Eina_List *l;
void *content;
@ -31,13 +31,15 @@ _entrance_fill_list(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Ev
NULL, func, data);
if (it)
elm_object_item_data_set(it, content);
if (fill_cb)
fill_cb(content, it);
}
elm_list_go(obj);
}
///////////////// GENLIST /////////////////////////////
static void
_entrance_fill_genlist(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Evas_Smart_Cb func, void *data)
_entrance_fill_genlist(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Entrance_Fill_Cb_Func fill_cb, Evas_Smart_Cb func, void *data)
{
Eina_List *l;
Elm_Genlist_Item_Class *glc;
@ -64,12 +66,14 @@ _entrance_fill_genlist(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents,
content, NULL, ELM_GENLIST_ITEM_NONE,
func, data);
elm_object_item_data_set(it, content);
if (fill_cb)
fill_cb(content, it);
}
}
///////////////// GENGRID /////////////////////////////
static void
_entrance_fill_gengrid(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Evas_Smart_Cb func, void *data)
_entrance_fill_gengrid(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Entrance_Fill_Cb_Func fill_cb, Evas_Smart_Cb func, void *data)
{
Eina_List *l;
Elm_Gengrid_Item_Class *ggc;
@ -94,6 +98,8 @@ _entrance_fill_gengrid(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents,
it = elm_gengrid_item_append(obj, ggc,
content, func, data);
elm_object_item_data_set(it, content);
if (fill_cb)
fill_cb(content, it);
}
}
@ -110,7 +116,7 @@ _entrance_fill_hoversell_func_cb(void *data EINA_UNUSED, Evas_Object *obj, void
}
static void
_entrance_fill_hoversell(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Evas_Smart_Cb func, void *data)
_entrance_fill_hoversell(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Entrance_Fill_Cb_Func fill_cb, Evas_Smart_Cb func, void *data)
{
Eina_List *l;
void *content;
@ -130,6 +136,8 @@ _entrance_fill_hoversell(Evas_Object *obj, Entrance_Fill *ef, Eina_List *content
_entrance_fill_hoversell_func_cb, NULL);
elm_object_item_data_set(it, content);
evas_object_data_set(elm_object_item_widget_get(it), "fill_data", ef);
if (fill_cb)
fill_cb(content, it);
if (ic)
{
free(ic);
@ -145,7 +153,7 @@ _entrance_fill_hoversell(Evas_Object *obj, Entrance_Fill *ef, Eina_List *content
///////////////// MAIN /////////////////////////////
Entrance_Fill *
entrance_fill_new(const char *item_style, EntranceFillTextGetFunc text_get, EntranceFillContentGetFunc content_get, EntranceFillStateGetFunc state_get, EntranceFillDelFunc del_func)
entrance_fill_new(const char *item_style, Entrance_Fill_Text_Get_Func text_get, Entrance_Fill_Content_Get_Func content_get, Entrance_Fill_State_Get_Func state_get, Entrance_Fill_Del_Func del_func)
{
Entrance_Fill *ef;
ef = calloc(1, sizeof(Entrance_Fill));
@ -165,20 +173,20 @@ entrance_fill_del(Entrance_Fill *ef)
}
void
entrance_fill(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Evas_Smart_Cb func, void *data)
entrance_fill(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Entrance_Fill_Cb_Func fill_cb, Evas_Smart_Cb func, void *data)
{
const char *type;
if (!obj) return;
if ((type = elm_object_widget_type_get(obj)))
{
if (!strcmp(type, "elm_list"))
_entrance_fill_list(obj, ef, contents, func, data);
_entrance_fill_list(obj, ef, contents, fill_cb, func, data);
else if (!strcmp(type, "elm_genlist"))
_entrance_fill_genlist(obj, ef, contents, func, data);
_entrance_fill_genlist(obj, ef, contents, fill_cb, func, data);
else if (!strcmp(type, "elm_gengrid"))
_entrance_fill_gengrid(obj, ef, contents, func, data);
_entrance_fill_gengrid(obj, ef, contents, fill_cb, func, data);
else if (!strcmp(type, "elm_hoversel"))
_entrance_fill_hoversell(obj, ef, contents, func, data);
_entrance_fill_hoversell(obj, ef, contents, fill_cb, func, data);
else
{
PT("Unknow object type to fill ");

View File

@ -3,13 +3,14 @@
typedef struct Entrance_Fill_ Entrance_Fill;
typedef char *(*EntranceFillTextGetFunc) (void *data, Evas_Object *obj, const char *part);
typedef Evas_Object *(*EntranceFillContentGetFunc) (void *data, Evas_Object *obj, const char *part);
typedef Eina_Bool (*EntranceFillStateGetFunc) (void *data, Evas_Object *obj, const char *part);
typedef void (*EntranceFillDelFunc) (void *data, Evas_Object *obj);
typedef char *(*Entrance_Fill_Text_Get_Func) (void *data, Evas_Object *obj, const char *part);
typedef Evas_Object *(*Entrance_Fill_Content_Get_Func) (void *data, Evas_Object *obj, const char *part);
typedef Eina_Bool (*Entrance_Fill_State_Get_Func) (void *data, Evas_Object *obj, const char *part);
typedef void (*Entrance_Fill_Del_Func) (void *data, Evas_Object *obj);
typedef Eina_Bool (*Entrance_Fill_Cb_Func) (void *data, Elm_Object_Item *it);
Entrance_Fill *entrance_fill_new(const char *item_style, EntranceFillTextGetFunc label_get, EntranceFillContentGetFunc content_get, EntranceFillStateGetFunc state_get, EntranceFillDelFunc del_func);
void entrance_fill(Evas_Object *obj, Entrance_Fill *egf, Eina_List *contents, Evas_Smart_Cb func, void *data);
Entrance_Fill *entrance_fill_new(const char *item_style, Entrance_Fill_Text_Get_Func label_get, Entrance_Fill_Content_Get_Func content_get, Entrance_Fill_State_Get_Func state_get, Entrance_Fill_Del_Func del_func);
void entrance_fill(Evas_Object *obj, Entrance_Fill *egf, Eina_List *contents, Entrance_Fill_Cb_Func fill_cb, Evas_Smart_Cb func, void *data);
void entrance_fill_del(Entrance_Fill *ef);

View File

@ -14,7 +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);
static void _entrance_gui_auth_cb(void *data, const char *user, Eina_Bool granted);
/*
@ -295,7 +295,8 @@ 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);
entrance_fill(ol, ef, users, NULL,
_entrance_gui_user_sel_cb, screen->login);
elm_object_signal_emit(screen->edj,
"entrance,users,enabled", "");
}
@ -353,6 +354,12 @@ entrance_gui_conf_set(const Entrance_Conf_Gui_Event *conf)
_entrance_gui_update();
}
void
entrance_gui_theme_name_set(const char *theme)
{
/* TODO */
}
const char *
entrance_gui_theme_name_get(void)
{
@ -384,12 +391,12 @@ entrance_gui_vkbd_enabled_get(void)
}
/*
static void
_entrance_gui_login_activated_cb(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
_entrance_gui_login_activated_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
char *txt;
Eina_List *l, *ll;
Entrance_Xsession *xsess;
Entrance_User_Event *eu = NULL;
Entrance_Login *eu = NULL;
Entrance_Screen *screen;
PT("login activated\n");
@ -423,7 +430,7 @@ _entrance_gui_login_activated_cb(void *data __UNUSED__, Evas_Object *obj, void *
}
static void
_entrance_gui_shutdown(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
_entrance_gui_shutdown(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_exit();
PT("shutdown cb\n");
@ -431,7 +438,7 @@ _entrance_gui_shutdown(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void
static void
_entrance_gui_focus(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
_entrance_gui_focus(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Eina_List *l;
Entrance_Screen *screen;
@ -442,7 +449,7 @@ _entrance_gui_focus(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *ev
}
static void
_entrance_gui_login_cancel_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *src __UNUSED__)
_entrance_gui_login_cancel_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
{
Evas_Object *o;
Entrance_Screen *screen;
@ -461,7 +468,7 @@ _entrance_gui_login_cancel_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__
}
static Eina_Bool
_entrance_gui_login_timeout(void *data __UNUSED__)
_entrance_gui_login_timeout(void *data EINA_UNUSED)
{
Evas_Object *popup, *o, *bx;
Entrance_Screen *screen;
@ -531,20 +538,20 @@ _entrance_gui_login(Entrance_Screen *screen)
}
static void
_entrance_gui_login_request_cb(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *src __UNUSED__)
_entrance_gui_login_request_cb(void *data, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
{
_entrance_gui_login(data);
}
static void
_entrance_gui_password_activated_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
_entrance_gui_password_activated_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
PT("password activated\n");
_entrance_gui_login(data);
}
static void
_entrance_gui_xsessions_clicked_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
_entrance_gui_xsessions_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Evas_Object *icon;
Eina_List *l;
@ -632,7 +639,7 @@ _entrance_gui_sessions_populate()
}
static Eina_Bool
_entrance_gui_auth_enable(void *data __UNUSED__)
_entrance_gui_auth_enable(void *data EINA_UNUSED)
{
Evas_Object *o;
Eina_List *l;
@ -677,12 +684,17 @@ _entrance_gui_update(void)
}
if (!bg)
{
const char *path;
const char *group;
if (_gui->bg.group)
bg = entrance_gui_theme_get(screen->transition,
_gui->bg.group);
else
bg = entrance_gui_theme_get(screen->transition,
"entrance/background/default");
edje_object_file_get(elm_layout_edje_get(bg), &path, &group);
eina_stringshare_replace(&_gui->bg.path, path);
eina_stringshare_replace(&_gui->bg.group, group);
}
elm_object_part_content_set(screen->transition,
"entrance.wallpaper.default", bg);
@ -743,27 +755,27 @@ _entrance_gui_user_icon_random_get(Evas_Object *obj)
}
static void
_entrance_gui_user_sel_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info)
_entrance_gui_user_sel_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Entrance_User_Event *eu;
Entrance_Login *eu;
eu = elm_object_item_data_get(event_info);
entrance_login_login_set(data, eu->login);
entrance_login_session_set(data, eu->lsess);
}
static char *
_entrance_gui_user_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
_entrance_gui_user_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
Entrance_User_Event *eu;
Entrance_Login *eu;
eu = data;
return strdup(eu->login);
}
static Evas_Object *
_entrance_gui_user_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
_entrance_gui_user_content_get(void *data EINA_UNUSED, Evas_Object *obj, const char *part)
{
Evas_Object *ic = NULL;
Entrance_User_Event *eu;
Entrance_Login *eu;
eu = data;
if (eu && !strcmp(part, "elm.swallow.icon"))
@ -798,13 +810,13 @@ _entrance_gui_user_content_get(void *data __UNUSED__, Evas_Object *obj, const ch
}
static Eina_Bool
_entrance_gui_user_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
_entrance_gui_user_state_get(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
return EINA_FALSE;
}
static void
_entrance_gui_user_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
_entrance_gui_user_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED)
{
}
@ -813,7 +825,7 @@ _entrance_gui_user_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
///////////////////////////////////////////////////
static char *
_entrance_gui_action_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
_entrance_gui_action_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
Entrance_Action *ea;
ea = data;
@ -821,7 +833,7 @@ _entrance_gui_action_text_get(void *data, Evas_Object *obj __UNUSED__, const cha
}
static void
_entrance_gui_action_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
_entrance_gui_action_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Entrance_Action *ea;
ea = data;
@ -841,7 +853,7 @@ _entrance_gui_actions_populate()
ef = entrance_fill_new(NULL, _entrance_gui_action_text_get,
NULL, NULL, NULL);
o = ENTRANCE_GUI_GET(screen->edj, "entrance.actions");
entrance_fill(o, ef, _gui->actions,
entrance_fill(o, ef, _gui->actions, NULL,
_entrance_gui_action_clicked_cb, screen);
edje_object_signal_emit(elm_layout_edje_get(screen->edj),
"entrance,action,enabled", "");
@ -850,7 +862,7 @@ _entrance_gui_actions_populate()
////////////////////////////////////////////////////////////////////////////////
static void
_entrance_gui_auth_cb(void *data, Eina_Bool granted)
_entrance_gui_auth_cb(void *data, const char *user EINA_UNUSED, Eina_Bool granted)
{
Eina_List *l;
Entrance_Screen *screen;

View File

@ -20,6 +20,7 @@ void entrance_gui_conf_set(const Entrance_Conf_Gui_Event *conf);
Eina_List *entrance_gui_stringlist_get(const char *name);
void entrance_gui_stringlist_free(Eina_List *list);
const char *entrance_gui_theme_name_get(void);
void entrance_gui_theme_name_set(const char *theme);
void entrance_gui_background_get(const char **path, const char **group);
Eina_Bool entrance_gui_vkbd_enabled_get(void);
const char *entrance_gui_theme_path_get(void);

View File

@ -2,7 +2,7 @@
#define ENTRANCE_PASSWD_LEN 256
typedef struct Entrance_Login_ Entrance_Login;
typedef struct Entrance_Gui_Login_ Entrance_Gui_Login;
static void _login_reset(Evas_Object *widget);
static void _login_backspace(Evas_Object *widget);
@ -19,11 +19,11 @@ 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 void _login_auth_cb(void *data, const char *user, Eina_Bool granted);
static Entrance_Fill *_login_fill;
struct Entrance_Login_
struct Entrance_Gui_Login_
{
Ecore_Event_Handler *handler;
char passwd[ENTRANCE_PASSWD_LEN];
@ -41,7 +41,7 @@ struct Entrance_Login_
};
#define LOGIN_GET(widget) \
Entrance_Login *login; \
Entrance_Gui_Login *login; \
login = evas_object_data_get(widget, "entrance"); \
if (!login) return
@ -146,11 +146,13 @@ _login_password_catch(Evas_Object *widget, Eina_Bool catch)
{
if (catch)
{
PT("catch password\n");
login->handler = ecore_event_handler_add(
ECORE_EVENT_KEY_DOWN, _login_key_down_cb, widget);
}
else
{
PT("uncatch password\n");
ecore_event_handler_del(login->handler);
login->handler = NULL;
}
@ -166,10 +168,9 @@ _login_key_down_cb(void *data, int type EINA_UNUSED, void *event)
ev = event;
elm_object_signal_emit(data,
"entrance,auth,changed", "");
elm_object_signal_emit(elm_object_part_content_get(data,
"entrance.password"),
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"))
@ -199,13 +200,20 @@ _login_key_down_cb(void *data, int type EINA_UNUSED, void *event)
else
_login_delete(data);
}
else if (!strcmp(ev->key, "Tab"))
else if ((!strcmp(ev->key, "Tab"))
|| (!strcmp(ev->key, "ISO_Left_Tab")))
{
if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)
{
PT("focus previous\n");
elm_object_focus_next(data, ELM_FOCUS_PREVIOUS);
}
else
{
PT("focus next\n");
elm_object_focus_next(data, ELM_FOCUS_NEXT);
}
}
else if ((!strcmp(ev->key, "u"))
&& (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL))
{
@ -302,13 +310,13 @@ _login_xsession_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event
}
static void
_login_auth_cb(void *data, Eina_Bool granted)
_login_auth_cb(void *data, const char *user, Eina_Bool granted)
{
LOGIN_GET(data);
if (login->wait)
{
if (login->func.login)
login->func.login(login->func.data, granted);
login->func.login(login->func.data, user, granted);
login->wait = EINA_FALSE;
entrance_connect_auth_cb_del(login->auth);
login->auth = NULL;
@ -360,10 +368,10 @@ Evas_Object *
entrance_login_add(Evas_Object *obj, Entrance_Login_Cb login_cb, void *data)
{
Evas_Object *o, *h, *p;
Entrance_Login *login;
Entrance_Gui_Login *login;
/* layout */
login = calloc(1, sizeof(Entrance_Login));
login = calloc(1, sizeof(Entrance_Gui_Login));
login->func.login = login_cb;
login->func.data = data;
o = entrance_gui_theme_get(obj, "entrance/login");
@ -409,7 +417,7 @@ entrance_login_xsessions_populate(Evas_Object *widget, Eina_List *xsessions)
LOGIN_GET(widget);
o = elm_object_part_content_get(widget, "entrance.xsessions");
entrance_fill(o, _login_fill, xsessions,
entrance_fill(o, _login_fill, xsessions, NULL,
_login_xsession_clicked_cb, widget);
login->session = eina_list_data_get(xsessions);
_login_xsession_update(widget);
@ -454,9 +462,17 @@ entrance_login_session_set(Evas_Object *widget, const char *name)
void
entrance_login_open_session_set(Evas_Object *widget, Eina_Bool open_session)
{
Evas_Object *o;
LOGIN_GET(widget);
open_session = !!open_session;
if (login->open_session != open_session)
{
login->open_session = open_session;
o = elm_object_part_content_get(widget, "entrance.xsessions");
if (login->open_session)
evas_object_show(o);
else
evas_object_hide(o);
}
}

View File

@ -1,7 +1,7 @@
#ifndef ENTRANCE_LOGIN_H
#define ENTRANCE_LOGIN_H
typedef void (*Entrance_Login_Cb) (void *data, Eina_Bool granted);
typedef void (*Entrance_Login_Cb) (void *data, const char *user, Eina_Bool granted);
void entrance_login_init(void);
void entrance_login_shutdown(void);

View File

@ -19,14 +19,14 @@ _theme_get(Evas_Object *win, const char *group)
}
static void
_signal(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *sig, const char *src)
_signal(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *sig, const char *src)
{
printf("Event: %s - %s \n", sig, src);
}
static void
_shutdown(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
_shutdown(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
printf("Quit\n");
elm_exit();
@ -34,7 +34,7 @@ _shutdown(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info _
int
elm_main (int argc __UNUSED__, char **argv __UNUSED__)
elm_main (int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
Evas_Object *o, *win;
win = elm_win_add(NULL, "theme_test", ELM_WIN_BASIC);

View File

@ -36,7 +36,7 @@ _signal_cb(int sig)
}
static void
_signal_log(int sig __UNUSED__)
_signal_log(int sig EINA_UNUSED)
{
PT("reopen the log file\n");
entrance_close_log();
@ -169,7 +169,7 @@ _entrance_main(const char *dname)
}
static Eina_Bool
_entrance_client_del(void *data __UNUSED__, int type __UNUSED__, void *event)
_entrance_client_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{
Ecore_Exe_Event_Del *ev;
@ -304,9 +304,6 @@ main (int argc, char ** argv)
entrance_user = getenv("ENTRANCE_USER");
#ifdef HAVE_PAM
entrance_pam_init(PACKAGE, dname, entrance_user);
#endif
if (entrance_user)
{
char *quit;
@ -364,7 +361,7 @@ main (int argc, char ** argv)
entrance_pam_item_set(ENTRANCE_PAM_ITEM_USER, entrance_config->userlogin);
#endif
PT("login user\n");
entrance_session_login(entrance_config->command.session_login, EINA_FALSE);
entrance_session_login(NULL, EINA_FALSE);
sleep(30);
xcb_disconnect(disp);
}

View File

@ -93,7 +93,7 @@ entrance_action_run(int action)
}
static void
_entrance_action_suspend(void *data __UNUSED__)
_entrance_action_suspend(void *data EINA_UNUSED)
{
PT("Suspend");
_action_exe = NULL;
@ -101,21 +101,21 @@ _entrance_action_suspend(void *data __UNUSED__)
}
static void
_entrance_action_shutdown(void *data __UNUSED__)
_entrance_action_shutdown(void *data EINA_UNUSED)
{
PT("Shutdown");
_action_exe = ecore_exe_run(entrance_config->command.shutdown, NULL);
}
static void
_entrance_action_reboot(void *data __UNUSED__)
_entrance_action_reboot(void *data EINA_UNUSED)
{
PT("Reboot\n");
_action_exe = ecore_exe_run(entrance_config->command.reboot, NULL);
}
static Eina_Bool
_entrance_action_exe_event_del_cb(void *data __UNUSED__, int type __UNUSED__, void *event)
_entrance_action_exe_event_del_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{
Ecore_Exe_Event_Del *ev;
Eina_Bool ret = ECORE_CALLBACK_PASS_ON;

View File

@ -19,7 +19,6 @@ _defaults_set(Entrance_Config *config)
config->command.xauth_path = eina_stringshare_add("/usr/bin/xauth");
config->command.xauth_file = eina_stringshare_add("/var/run/entrance.auth");
config->command.session_start = eina_stringshare_add("/usr/bin/sessreg -a -l :0.0" );
config->command.session_login = eina_stringshare_add("exec /bin/bash -login /etc/X11/xinit/xinitrc");
config->command.session_stop = eina_stringshare_add("/usr/bin/sessreg -d -l :0.0");
config->command.shutdown = eina_stringshare_add("/usr/bin/shutdown -h now");
config->command.reboot = eina_stringshare_add("/usr/bin/shutdown -r now");
@ -124,7 +123,6 @@ _config_free(Entrance_Config *config)
eina_stringshare_del(config->command.xauth_path);
eina_stringshare_del(config->command.xauth_file);
eina_stringshare_del(config->command.session_start);
eina_stringshare_del(config->command.session_login);
eina_stringshare_del(config->command.session_stop);
eina_stringshare_del(config->command.shutdown);
eina_stringshare_del(config->command.reboot);
@ -153,7 +151,6 @@ entrance_config_init()
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Config, "xauth_path", command.xauth_path, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Config, "xauth_file", command.xauth_file, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Config, "session_start", command.session_start, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Config, "session_login", command.session_login, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Config, "session_stop", command.session_stop, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Config, "shutdown", command.shutdown, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Config, "reboot", command.reboot, EET_T_STRING);

View File

@ -15,7 +15,6 @@ struct _Entrance_Config
const char *xauth_path;
const char *xauth_file;
const char *session_start;
const char *session_login;
const char *session_stop;
const char *shutdown;
const char *reboot;

View File

@ -24,18 +24,7 @@ entrance_history_init()
// TODO screenshot a new session after 3 min
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_Login);
edd = eet_data_descriptor_stream_new(&eddc);
#define EET_LOGIN_ADD(NAME, TYPE) \
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Login, # NAME, NAME, TYPE);
EET_LOGIN_ADD(login, EET_T_STRING);
EET_LOGIN_ADD(session, EET_T_STRING);
EET_LOGIN_ADD(icon.path, EET_T_STRING);
EET_LOGIN_ADD(icon.group, EET_T_STRING);
EET_LOGIN_ADD(background.path, EET_T_STRING);
EET_LOGIN_ADD(background.group, EET_T_STRING);
EET_LOGIN_ADD(ignore_last_session, EET_T_UCHAR);
#undef EET_LOGIN_ADD
edd = entrance_event_user_dd();
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_History);
_eddh = eet_data_descriptor_stream_new(&eddc);
@ -79,7 +68,6 @@ _entrance_history_write()
Eet_File *ef;
Entrance_Login *el;
if (_history_update)
{
PT("writing history file\n");
@ -98,7 +86,11 @@ _entrance_history_write()
EINA_LIST_FREE(_entrance_history->history, el)
{
eina_stringshare_del(el->login);
eina_stringshare_del(el->session);
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);
}
}
@ -108,20 +100,22 @@ entrance_history_push(const char *login, const char *session)
Eina_List *l;
Entrance_Login *el;
PT("history push for user %s session %s\n", login, session);
EINA_LIST_FOREACH(_entrance_history->history, l, el)
{
if (!strcmp(login, el->login))
{
if (!el->ignore_last_session)
PT("History updating\n");
if (el->remember_session)
{
if (!session)
{
eina_stringshare_del(el->session);
el->session = NULL;
eina_stringshare_del(el->lsess);
el->lsess = NULL;
}
else if (el->session && strcmp(session, el->session))
else if (el->lsess && strcmp(session, el->lsess))
{
eina_stringshare_replace(&el->session, session);
eina_stringshare_replace(&el->lsess, session);
_history_update = EINA_TRUE;
}
}
@ -130,11 +124,13 @@ entrance_history_push(const char *login, const char *session)
}
if (!el)
{
PT("History create a new entry for %s\n", login);
if ((el = calloc(1, sizeof(Entrance_Login))))
{
el->login = eina_stringshare_add(login);
if (session) el->session = eina_stringshare_add(session);
else el->session = NULL;
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);
_history_update = EINA_TRUE;
@ -152,7 +148,7 @@ _entrance_history_match(const char *login)
EINA_LIST_FOREACH(_entrance_history->history, l, el)
{
if (!strcmp(el->login, login))
ret = el->session;
ret = el->lsess;
}
return ret;
}
@ -162,7 +158,7 @@ _entrance_user_init()
{
char buf[PATH_MAX];
FILE *f;
Entrance_User_Event *eu;
Entrance_Login *eu;
Eina_List *lu = NULL;
char *token;
char *user;
@ -185,7 +181,7 @@ _entrance_user_init()
}
EINA_LIST_FREE(lu, user)
{
if ((eu = (Entrance_User_Event *) calloc(1, sizeof(Entrance_User_Event))))
if ((eu = (Entrance_Login *) calloc(1, sizeof(Entrance_Login))))
{
eu->login = eina_stringshare_add(user);
snprintf(buf, sizeof(buf),
@ -193,6 +189,7 @@ _entrance_user_init()
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);
}
@ -202,7 +199,7 @@ _entrance_user_init()
static void
_entrance_user_shutdown()
{
Entrance_User_Event *eu;
Entrance_Login *eu;
EINA_LIST_FREE(_lusers, eu)
{
eina_stringshare_del(eu->login);

View File

@ -6,28 +6,7 @@ void entrance_history_shutdown();
void entrance_history_push(const char *login, const char *session);
Eina_List *entrance_history_get();
typedef struct _Entrance_Login Entrance_Login;
typedef struct _Entrance_History Entrance_History;
typedef struct _Entrance_Background Entrance_Background;
struct _Entrance_Background
{
const char *group;
const char *path;
};
struct _Entrance_Login
{
const char *login;
const char *session;
struct
{
const char *path;
const char *group;
} icon;
Entrance_Background background;
Eina_Bool ignore_last_session;
};
struct _Entrance_History
{

View File

@ -26,7 +26,7 @@
static int _entrance_pam_conv(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr);
static struct pam_conv _pam_conversation;
static pam_handle_t* _pam_handle;
static pam_handle_t* _pam_handle = NULL;
static int last_result;
static char *_login = NULL;
static char *_passwd = NULL;
@ -35,7 +35,7 @@ static char *_passwd = NULL;
static int
_entrance_pam_conv(int num_msg, const struct pam_message **msg,
struct pam_response **resp, void *appdata_ptr __UNUSED__) {
struct pam_response **resp, void *appdata_ptr EINA_UNUSED) {
int i, result = PAM_SUCCESS;
*resp = (struct pam_response *) calloc(num_msg, sizeof(struct pam_response));
for (i = 0; i < num_msg; ++i){
@ -195,11 +195,18 @@ entrance_pam_authenticate()
default:
//case PAM_NEW_AUTHTOKEN_REQD:
case PAM_ACCT_EXPIRED:
PT("PAM user acct expired error\n");
entrance_pam_end();
return 1;
case PAM_USER_UNKNOWN:
PT("PAM user unknow error\n");
entrance_pam_end();
return 1;
case PAM_AUTH_ERR:
PT("PAM auth error\n");
return 1;
case PAM_PERM_DENIED:
PT("PAM perm_denied error\n");
return 1;
case PAM_SUCCESS:
break;
@ -215,7 +222,6 @@ entrance_pam_init(const char *service, const char *display, const char *user) {
if (!service && !*service) goto pam_error;
if (!display && !*display) goto pam_error;
_pam_handle = NULL;
_pam_conversation.conv = _entrance_pam_conv;
_pam_conversation.appdata_ptr = NULL;

View File

@ -11,11 +11,9 @@ Ecore_Con_Server *_entrance_server = NULL;
Eina_List *_handlers = NULL;
static Eina_Bool
_entrance_server_add(void *data __UNUSED__, int type __UNUSED__, void *event EINA_UNUSED)
_entrance_server_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
{
//Ecore_Con_Event_Client_Add *ev;
Entrance_Event eev;
//ev = event;
PT("server client connected\n");
PT("Sending users\n");
@ -51,20 +49,15 @@ _entrance_server_add(void *data __UNUSED__, int type __UNUSED__, void *event EIN
static Eina_Bool
_entrance_server_del(void *data __UNUSED__, int type __UNUSED__, void *event EINA_UNUSED)
_entrance_server_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
{
/*
Ecore_Con_Event_Client_Del *ev;
ev = event;
*/
PT("server client disconnected\n");
return ECORE_CALLBACK_RENEW;
}
static Eina_Bool
_entrance_server_data(void *data __UNUSED__, int type __UNUSED__, void *event)
_entrance_server_data(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{
Ecore_Con_Event_Client_Data *ev;
@ -89,15 +82,20 @@ _entrance_server_read_cb(const void *data, size_t size EINA_UNUSED, void *user_d
eev->event.auth.password))
{
PT("server authenticate granted\n");
neev.event.status.login = entrance_session_login_get();
neev.event.status.granted = EINA_TRUE;
if (eev->event.auth.open_session)
{
PT("opening session now ...\n");
entrance_session_login(eev->event.auth.session, EINA_TRUE);
}
neev.event.status.granted = EINA_TRUE;
else
entrance_session_close();
}
else
{
entrance_session_close();
neev.event.status.login = NULL;
neev.event.status.granted = EINA_FALSE;
PT("server authenticate error\n");
}

View File

@ -49,19 +49,17 @@ _entrance_session_cookie_add(const char *mcookie, const char *display,
if (!xauth_cmd || !auth_file) return 1;
snprintf(buf, sizeof(buf), "%s -f %s -q", xauth_cmd, auth_file);
PT("write auth on ");
fprintf(stderr, "display %s with file %s\n", display, auth_file);
PT("write auth on display %s with file %s\n", display, auth_file);
cmd = popen(buf, "w");
if (!cmd)
{
fprintf(stderr, " fail !\n");
PT("write auth fail !\n");
return 1;
}
fprintf(cmd, "remove %s\n", display);
fprintf(cmd, "add %s . %s\n", display, mcookie);
fprintf(cmd, "exit\n");
pclose(cmd);
fprintf(stderr, " done\n");
return 0;
}
@ -186,7 +184,7 @@ _entrance_session_run(struct passwd *pwd, const char *cmd, const char *cookie)
snprintf(buf, sizeof(buf), "%s > %s/.entrance_session.log 2>&1",
cmd, pwd->pw_dir);
#endif
execle(pwd->pw_shell, pwd->pw_shell, "-c", buf, NULL, env);
execle(pwd->pw_shell, pwd->pw_shell, "--login", "-c", buf, NULL, env);
PT("The Xsessions are not launched :(\n");
}
}
@ -194,11 +192,20 @@ _entrance_session_run(struct passwd *pwd, const char *cmd, const char *cookie)
void
entrance_session_end(const char *user)
{
#ifdef HAVE_PAM
entrance_pam_init(PACKAGE, _dname, user);
#endif
char buf[PATH_MAX];
snprintf(buf, sizeof(buf),
"%s %s ", entrance_config->command.session_stop, user);
if (-1 == system(buf))
PT("Error on session stop command\n");
entrance_session_close();
}
void
entrance_session_close(void)
{
#ifdef HAVE_PAM
entrance_pam_close_session();
entrance_pam_end();
@ -275,6 +282,7 @@ entrance_session_authenticate(const char *login, const char *passwd)
Eina_Bool auth;
_login = strdup(login);
#ifdef HAVE_PAM
entrance_pam_init(PACKAGE, _dname, NULL);
auth = !!(!entrance_pam_auth_set(login, passwd)
&& !entrance_pam_authenticate());
#else
@ -359,10 +367,7 @@ _entrance_session_find_command(const char *path, const char *session)
{
if (xsession->command)
{
snprintf(buf, sizeof(buf), "%s %s",
entrance_config->command.session_login,
xsession->command);
return eina_stringshare_add(buf);
return xsession->command;
}
}
}
@ -371,25 +376,17 @@ _entrance_session_find_command(const char *path, const char *session)
path, ".xinitrc");
if (ecore_file_can_exec(buf))
{
snprintf(buf, sizeof(buf), "%s %s/%s",
entrance_config->command.session_login,
path, ".xinitrc");
return eina_stringshare_add(buf);
}
snprintf(buf, sizeof(buf), "%s/%s",
path, ".Xsession");
if (ecore_file_can_exec(buf))
{
snprintf(buf, sizeof(buf), "%s %s/%s",
entrance_config->command.session_login,
path, ".Xsession");
return eina_stringshare_add(buf);
}
if (ecore_file_exists("/etc/X11/xinit/xinitrc"))
{
snprintf(buf, sizeof(buf), "%s /etc/X11/xinit/xinitrc",
entrance_config->command.session_login);
return eina_stringshare_add(buf);
return eina_stringshare_add("/etc/X11/xinit/xinitrc");
}
return NULL;
}

View File

@ -6,6 +6,7 @@ void entrance_session_init(const char *dname);
void entrance_session_end(const char *login);
void entrance_session_shutdown();
Eina_Bool entrance_session_authenticate(const char *login, const char *pwd);
void entrance_session_close(void);
Eina_Bool entrance_session_login(const char *command, Eina_Bool push);
void entrance_session_pid_set(pid_t pid);
pid_t entrance_session_pid_get();

View File

@ -19,14 +19,14 @@ _theme_get(Evas_Object *win, const char *group)
}
static void
_signal(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *sig, const char *src)
_signal(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *sig, const char *src)
{
printf("Event: %s - %s \n", sig, src);
}
static void
_shutdown(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
_shutdown(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
printf("Quit\n");
elm_exit();
@ -34,7 +34,7 @@ _shutdown(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info _
int
elm_main (int argc __UNUSED__, char **argv __UNUSED__)
elm_main (int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
Evas_Object *o, *win;
win = elm_win_add(NULL, "theme_test", ELM_WIN_BASIC);

View File

@ -94,7 +94,7 @@ xserver_error:
}
static Eina_Bool
_xserver_started(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
_xserver_started(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
{
PT("xserver started\n");
_env_set(_xserver->dname);

View File

@ -15,10 +15,17 @@
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);
static Eet_Data_Descriptor *_entrance_event_auth_dd();
static Eet_Data_Descriptor *_entrance_event_status_dd();
static Eet_Data_Descriptor *_entrance_event_xsessions_dd();
static Eet_Data_Descriptor *_entrance_event_conf_gui_dd();
static Eet_Data_Descriptor *_entrance_event_auth_dd(void);
static Eet_Data_Descriptor *_entrance_event_status_dd(void);
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_actions_dd(void);
static Eet_Data_Descriptor *_entrance_event_action_dd(void);
static Eet_Data_Descriptor *_entrance_event_new(void);
static Eina_Bool _entrance_event_read_cb(const void *data, size_t size, void *user_data);
typedef struct _Entrance_Event_Private {
@ -94,7 +101,7 @@ _entrance_event_type_get(const void *data, Eina_Bool *unknow)
}
static Eet_Data_Descriptor *
_entrance_event_xsessions_dd()
_entrance_event_xsessions_dd(void)
{
Eet_Data_Descriptor_Class eddc, eddcl;
Eet_Data_Descriptor *edd, *eddl;
@ -114,7 +121,7 @@ _entrance_event_xsessions_dd()
}
static Eet_Data_Descriptor *
_entrance_event_auth_dd()
_entrance_event_auth_dd(void)
{
Eet_Data_Descriptor *edd;
Eet_Data_Descriptor_Class eddc;
@ -133,7 +140,7 @@ _entrance_event_auth_dd()
}
static Eet_Data_Descriptor *
_entrance_event_maxtries_dd()
_entrance_event_maxtries_dd(void)
{
Eet_Data_Descriptor *edd;
Eet_Data_Descriptor_Class eddc;
@ -145,7 +152,7 @@ _entrance_event_maxtries_dd()
}
static Eet_Data_Descriptor *
_entrance_event_conf_gui_dd()
_entrance_event_conf_gui_dd(void)
{
Eet_Data_Descriptor *edd;
Eet_Data_Descriptor_Class eddc;
@ -164,12 +171,14 @@ _entrance_event_conf_gui_dd()
}
static Eet_Data_Descriptor *
_entrance_event_status_dd()
_entrance_event_status_dd(void)
{
Eet_Data_Descriptor *edd;
Eet_Data_Descriptor_Class eddc;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_Status_Event);
edd = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Status_Event, "login",
login, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Status_Event, "granted",
granted, EET_T_INT);
return edd;
@ -177,21 +186,12 @@ _entrance_event_status_dd()
}
static Eet_Data_Descriptor *
_entrance_event_users_dd()
_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_User_Event);
edd = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_User_Event, "login",
login, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_User_Event, "image.path",
image.path, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_User_Event, "image.group",
image.group, EET_T_STRING);
// TODO screenshot
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_User_Event, "lsess",
lsess, EET_T_STRING);
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_Login);
edd = _entrance_event_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,25 +200,29 @@ _entrance_event_users_dd()
}
static Eet_Data_Descriptor *
_entrance_event_user_dd()
_entrance_event_user_dd(void)
{
Eet_Data_Descriptor *edd;
Eet_Data_Descriptor_Class eddc;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_User_Event);
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_Login);
edd = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_User_Event, "login",
login, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_User_Event, "image.path",
image.path, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_User_Event, "image.group",
image.group, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_User_Event, "lsess",
lsess, EET_T_STRING);
#define EET_LOGIN_ADD(NAME, TYPE) \
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Login, # NAME, NAME, TYPE);
EET_LOGIN_ADD(login, EET_T_STRING);
EET_LOGIN_ADD(image.path, EET_T_STRING);
EET_LOGIN_ADD(image.group, EET_T_STRING);
EET_LOGIN_ADD(bg.path, EET_T_STRING);
EET_LOGIN_ADD(bg.group, EET_T_STRING);
EET_LOGIN_ADD(lsess, EET_T_STRING);
EET_LOGIN_ADD(remember_session, EET_T_INT);
// TODO screenshot
#undef EET_LOGIN_ADD
return edd;
}
static Eet_Data_Descriptor *
_entrance_event_actions_dd()
_entrance_event_actions_dd(void)
{
Eet_Data_Descriptor *edd, *eddl;
Eet_Data_Descriptor_Class eddc, eddcl;
@ -236,7 +240,7 @@ _entrance_event_actions_dd()
}
static Eet_Data_Descriptor *
_entrance_event_action_dd()
_entrance_event_action_dd(void)
{
Eet_Data_Descriptor *edd;
Eet_Data_Descriptor_Class eddc;
@ -248,7 +252,7 @@ _entrance_event_action_dd()
}
static Eet_Data_Descriptor *
_entrance_event_new()
_entrance_event_new(void)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *edd;
@ -328,4 +332,8 @@ entrance_event_received(const void *data, size_t size)
eet_connection_received(_eep->event_connection, data, size);
}
Eet_Data_Descriptor *
entrance_event_user_dd()
{
return _entrance_event_user_dd();
}

View File

@ -42,6 +42,7 @@ typedef struct Entrance_Maxtries_Event_
typedef struct Entrance_Status_Event_
{
const char *login;
int granted;
} Entrance_Status_Event;
@ -50,22 +51,6 @@ typedef struct Entrance_Action_Event_
unsigned char action;
} Entrance_Action_Event;
typedef struct Entrance_User_Event_
{
const char *login;
const char *lsess;
struct
{
const char *path;
const char *group;
} image;
struct
{
const char *path;
const char *group;
} background;
} Entrance_User_Event;
typedef struct Entrance_Users_Event_
{
Eina_List *users;
@ -95,6 +80,20 @@ typedef struct Entrance_Conf_Gui_Event_
} Entrance_Conf_Gui_Event;
typedef struct Entrance_Background_
{
const char *group;
const char *path;
} Entrance_Background;
typedef struct Entrance_Login_
{
const char *login;
const char *lsess;
Entrance_Background bg;
Entrance_Background image;
Eina_Bool remember_session;
} Entrance_Login;
typedef struct Entrance_Event_
{
@ -106,7 +105,7 @@ typedef struct Entrance_Event_
Entrance_Maxtries_Event maxtries;
Entrance_Status_Event status;
Entrance_Users_Event users;
Entrance_User_Event user;
Entrance_Login user;
Entrance_Actions_Event actions;
Entrance_Action_Event action;
Entrance_Conf_Gui_Event conf_gui;
@ -117,4 +116,5 @@ void entrance_event_init(Eet_Read_Cb func_read_cb, Eet_Write_Cb func_write_cb, v
void entrance_event_shutdown(void);
void entrance_event_send(const Entrance_Event *data);
void entrance_event_received(const void *data, size_t size);
Eet_Data_Descriptor *entrance_event_user_dd();
#endif /* ENTRANCE_EVENT_ */