diff --git a/configure.ac b/configure.ac index a471960..cdbefb6 100644 --- a/configure.ac +++ b/configure.ac @@ -47,21 +47,32 @@ AC_MSG_RESULT([${enable_pam}]) # Grub2 AC_ARG_ENABLE([grub2], - [AC_HELP_STRING([--enable-grub2], [enable grub2 support. @<:@default=disabled@:>@])], + [AC_HELP_STRING([--disable-grub2], [disable grub2 support. @<:@default=enabled@:>@])], [ - if test "x${enableval}" = "xyes" ; then - enable_grub2="yes" - else + if test "x${disableval}" = "xyes" ; then enable_grub2="no" + else + enable_grub2="yes" fi ], - [enable_grub2="no"]) + [enable_grub2="yes"]) AC_MSG_CHECKING([whether to support grub2 reboot features]) AC_MSG_RESULT([${enable_grub2}]) -if test "x${enable_grub2}" = "xyes" ; then - AC_DEFINE([HAVE_GRUB2], [1], [Set to 1 if grub is enabled.]) -fi + +# Ekbd +AC_ARG_ENABLE([ekbd], + [AC_HELP_STRING([--disable-ekbd], [disable virtual keyboard. @<:@default=enabled@:>@])], + [ + if test "x${disableval}" = "xyes" ; then + enable_ekbd="no" + else + enable_ekbd="yes" + fi + ], + [enable_ekbd="yes"]) +AC_MSG_CHECKING([whether to support virtual keyboard features]) +AC_MSG_RESULT([${enable_grub2}]) # consolekit AC_ARG_ENABLE([consolekit], @@ -105,6 +116,21 @@ AC_C___ATTRIBUTE__ PKG_CHECK_MODULES([ENTRANCE], [efreet >= 1.0.0 eina >= 1.0.0 eet >= 1.4.0 ecore-con >= 1.0.0 ecore >= 1.0.0 ecore-file >= 1.0.0 xcb >= 1.0.0]) PKG_CHECK_MODULES([ENTRANCE_CLIENT], [eet >= 1.4.0 edje >= 1.0.0 elementary >= 0.5.0.0 ecore-evas >= 1.0.0 evas >= 1.0.0 ecore-con >= 1.0.0 ecore >= 1.0.0 ecore-x >= 1.0.0 eina >= 1.0.0]) +# Grub2 +if test "x${enable_grub2}" = "xyes" ; then + AC_DEFINE([HAVE_GRUB2], [1], [Set to 1 if grub is enabled.]) +fi + +# Ekbd +if test "x${enable_consolekit}" = "xyes" ; then + PKG_CHECK_MODULES([ENTRANCE_EKBD], [ekbd], [enable_ekbd="yes"], [enable_ekbd="no"]) +fi + +AM_CONDITIONAL(HAVE_CONSOLEKIT, [test "x${enable_ekbd}" = "xyes"]) +if test "x${enable_ekbd}" = "xyes" ; then + AC_DEFINE([HAVE_EKBD], [1], [Set to 1 if ekbd is enabled.]) +fi + # Consolekit if test "x${enable_consolekit}" = "xyes" ; then PKG_CHECK_MODULES([ENTRANCE_CK], [dbus-1 ck-connector], [enable_consolekit="yes"], [enable_consolekit="no"]) @@ -161,8 +187,10 @@ src/bin/Makefile src/daemon/Makefile data/Makefile data/themes/Makefile -data/themes/old/Makefile data/themes/beaumonts/Makefile +data/themes/default/Makefile +data/themes/fade/Makefile +data/themes/old/Makefile ]) @@ -180,6 +208,7 @@ echo "Configuration Options Summary:" echo echo " pam..................: ${have_pam}" echo " grub2................: ${enable_grub2}" +echo " ekbd.................: ${enable_ekbd}" echo " consolekit...........: ${enable_consolekit}" echo echo " edje_cc..............: ${edje_cc}" diff --git a/data/entrance.conf b/data/entrance.conf index 6a4d155..1223de8 100644 --- a/data/entrance.conf +++ b/data/entrance.conf @@ -32,7 +32,7 @@ group "Entrance_Config" struct { * 1 = True, 0 = False */ value "daemonize" uchar: 1; - /* Enable numlock */ + /* Enable numlock TODO support it */ value "numlock" uchar: 1; /** Bool to determine if entrance must login user with the session_login command @@ -54,6 +54,20 @@ group "Entrance_Config" struct { /* Log file */ value "logfile" string: "/var/log/entrance.log"; - /* Theme to use */ + /* Theme to use. This one could be overided if you permit setting below */ value "theme" string: "default"; + + /* Allow settings in gui, who overides this one until it's updated */ + value "custom_conf" uchar: 1; + + /* background */ + value "background_path" string: ""; + /* if it's an edj file */ + value "background_group" string: ""; + + /* Elementary profile */ + value "elementary_profile" string: "default"; + + /* Use a virtual keyboard */ + value "virtual_keyboard" uchar: 0; } diff --git a/data/themes/Makefile.am b/data/themes/Makefile.am index ca8d44b..31a2b40 100644 --- a/data/themes/Makefile.am +++ b/data/themes/Makefile.am @@ -1,4 +1,4 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = beaumonts old +SUBDIRS = default diff --git a/data/themes/default/Makefile.am b/data/themes/default/Makefile.am new file mode 100644 index 0000000..955167a --- /dev/null +++ b/data/themes/default/Makefile.am @@ -0,0 +1,20 @@ +AUTOMAKE_OPTIONS = 1.4 foreign +MAINTAINERCLEANFILES = Makefile.in + +EDJE_CC = @edje_cc@ +EDJE_FLAGS = -v -id $(top_srcdir)/data/themes/default/images -fd $(top_srcdir)/data/themes/default/fonts + +filesdir = $(datadir)/entrance/themes/ +files_DATA = default.edj + +EXTRA_DIST = default.edc + + +default.edj: Makefile $(EXTRA_DIST) + $(EDJE_CC) $(EDJE_FLAGS) \ + $(top_srcdir)/data/themes/default/default.edc \ + $(top_builddir)/data/themes/default/default.edj + +clean-local: + rm -f *.edj + diff --git a/data/themes/default/default.edc b/data/themes/default/default.edc new file mode 100644 index 0000000..82c3d7e --- /dev/null +++ b/data/themes/default/default.edc @@ -0,0 +1,499 @@ +/* + * Default theme for Entrance + * By Michael Bouchaud + * Licence CC-By-Sa + * Photo by Philippe Caseiro + * Licence CC-By-Sa + */ + +externals { + external: "elm"; +} + +collections { + group { + name: "entrance/background/default"; + images { + image: "entrance_background.jpg" LOSSY 90; + } + parts { + part { name: "base"; + type: IMAGE; + description { state: "default" 0.0; + image { + normal: "entrance_background.jpg"; + scale_hint: STATIC; + } + } + } + } + } + + group { + name: "entrance/background"; + data.item: "items" "default"; + } + + group { + name: "entrance/wallpaper/default"; + parts { + part { name: "base"; + type: RECT; + description { state: "default" 0.0; + color: 255 255 255 0; + } + } + part { name: "clip1"; + type: RECT; + description { state: "default" 0.0; + visible: 1; + color: 255 255 255 255; + rel2 { + to: "cur"; + relative: 0.0 1.0; + } + } + } + part { name: "clip2"; + type: RECT; + description { state: "default" 0.0; + visible: 1; + color: 255 255 255 255; + rel1 { + to: "cur"; + relative: 1.0 0.0; + } + } + } + part { name: "cur"; + type: RECT; + description { state: "default" 0.0; + min: 1 0; + max: 1 99999; + visible: 0; + align: 1.0 0.5; + } + description { state: "user" 0.0; + inherit: "default" 0.0; + align: 0.0 0.5; + } + } + part { name: "entrance.wallpaper.default"; + clip_to: "clip1"; + type: SWALLOW; + description { state: "default" 0.0; + visible: 1; + } + } + part { name: "entrance.wallpaper.user"; + clip_to: "clip2"; + type: SWALLOW; + description { state: "default" 0.0; + visible: 1; + } + } + part { name: "entrance.login"; + type: SWALLOW; + description { state: "default" 0.0; + visible: 1; + } + } + } + programs { + program { name: "wallpaper_user"; + signal: "entrance,wallpaper,user"; + source: ""; + action: STATE_SET "user" 0.0; + target: "cur"; + } + program { name: "wallpaper_default"; + signal: "entrance,wallpaper,default"; + source: ""; + action: STATE_SET "default" 0.0; + target: "cur"; + } + } + } + + group { + name : "entrance"; + + images { + } + + parts { + part { name: "clip"; + type: RECT; + description { state: "default" 0.0; + color: 255 255 255 255; + //color: 255 255 255 0; + } + description { state: "show" 0.0; + color: 255 255 255 255; + } + } + part { name: "entrance.login"; + clip_to: "clip"; + type: SWALLOW; + description { state: "default" 0.0; + visible: 1; + max: 0 0; + } + } + part { name: "entrance.users"; + type: EXTERNAL; +// source: "elm/list"; +// source: "elm/genlist"; + source: "elm/gengrid"; + description { state: "default" 0.0; + rel1.relative: 0.0 0.2; + rel2.relative: 0.0 0.8; + rel2.to_x: "entrance.login"; + visible: 1; + params { + bool: "horizontal" 0; + double: "vertical page relative" 0.0; + int: "horizontal item size" 96; + int: "vertical item size" 120; + } + } + } + + part { name: "entrance.actions"; + type: EXTERNAL; + source: "elm/hoversel"; + description { state: "default" 0.0; + fixed: 1 1; + visible: 0; + max: 0 0; + align: 1.0 1.0; + params { + string: "label" "action"; + } + } + description { state: "enabled" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { name: "entrance.conf"; + type: EXTERNAL; + source: "elm/button"; + description { state: "default" 0.0; + fixed: 1 1; + visible: 1; + max: 0 0; + align: 1.0 1.0; + rel2.to_x: "entrance.actions"; + rel2.relative: 0.0 1.0; + params { + string: "label" "Settings"; + } + } + description { state: "enabled" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } +/* + 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 { + program { + name: "action_enabled"; + signal: "entrance,action,enabled"; + source: ""; + action: STATE_SET "enabled" 0.0; + target: "entrance.actions"; + } + program { + name: "action_disabled"; + signal: "entrance,action,disabled"; + source: ""; + action: STATE_SET "default" 0.0; + target: "entrance.actions"; + } + program { + name: "user_enabled"; + signal: "entrance,users,enabled"; + source: ""; + action: STATE_SET "enabled" 0.0; + target: "entrance.users"; + } + program { + name: "user_disabled"; + signal: "entrance,users,disabled"; + source: ""; + action: STATE_SET "default" 0.0; + target: "entrance.users"; + } + program { + name: "conf_enabled"; + signal: "entrance,custom_conf,enabled"; + source: ""; + action: STATE_SET "enabled" 0.0; + target: "entrance.conf"; + } + program { + name: "conf_disabled"; + signal: "entrance,custom_conf,disabled"; + source: ""; + action: STATE_SET "default" 0.0; + target: "entrance.conf"; + } + } + } + + + group { + name : "entrance/login"; + parts { + part { + name: "entrance.login"; + type: SWALLOW; + repeat_events: 0; + description { + state: "default" 0.0; + min: 140 0; + max: 0 0; + align: 0.5 1.0; + rel2.to_y: "entrance.password"; + rel2.relative: 1.0 0.0; + visible: 1; + } + } + + part { + name: "entrance.password"; + type: SWALLOW; + repeat_events: 0; + source: "entrance/entry/password"; + description { + state: "default" 0.0; + min: 140 0; + max: 0 0; + align: 0.5 0.5; + visible: 1; + } + } + part { name: "entrance.xsessions"; + type: SWALLOW; + description { state: "default" 0.0; + max: 0 0; + rel1.to_y: "entrance.password"; + rel1.relative: 0.0 1.0; + align: 0.5 0.0; + //visible: 0; + } + description { state: "enabled" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + + /* + * PROGRAMS + */ + programs { + program { + name: "xsession_enabled"; + signal: "entrance,xsession,enabled"; + source: ""; + action: STATE_SET "enabled" 0.0; + target: "entrance.xsessions"; + } + program { + name: "xsession_disabled"; + signal: "entrance,xsession,disabled"; + source: ""; + 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: "entrance.error"; + } + program { + name: "login_change"; + signal: "entrance.auth.change"; + source: ""; + action: STATE_SET "default" 0.0; + transition: ACCELERATE 0.4; + target: "entrance.error"; + } + + program { + name: "auth_enable"; + signal: "entrance.auth.enable"; + source: ""; + action: STATE_SET "auth" 0.0; + transition: ACCELERATE 0.8; + target: "entrance.users"; + target: "entrance.password"; + target: "entrance.xsessions"; + } + + program { + name: "auth_disable"; + signal: "entrance.auth.disable"; + source: ""; + action: STATE_SET "default" 0.0; + transition: LINEAR 0.5; + target: "entrance.users"; + target: "entrance.password"; + target: "entrance.xsessions"; + } + program { + name: "login"; + signal: "entrance.auth.valid"; + source: ""; + action: STATE_SET "default" 0.0; + transition: LINEAR 0.7; + target: "clip"; + } + program { + name: "login_valid"; + signal: "mouse,down,*"; + source: "valid"; + action: SIGNAL_EMIT "entrance.auth.request" ""; + } + +*/ + } + } + + 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; + visible: 0; + } + } + part { name: "entrance.conf"; + type: SWALLOW; + description { state: "default" 0.0; + visible: 1; + } + } + part { name: "hover"; + type: RECT; + mouse_events: 1; + repeat_events: 0; + description { state: "default" 0.0; + color: 0 0 0 196; + } + description { state: "hidden" 0.0; + visible: 0; + } + } + part { name: "login"; + type: GROUP; + description { state: "default" 0.0; + visible: 1; + } + description { state: "hidden" 0.0; + visible: 0; + } + } + } + } + + group { name: "entrance/user"; + data.item: "items" "adrielhernandez-cmyk-tux brunocb-tux-1-euro cisoun-tux-coup-de-soleil eliaden-tux-marin fcys14-tux-breton fcys14-tux-croco fcys14-tux-pompier fcys14-yoshi-tux m4r10-tux-crema mybob-calimetux overlord59-astro-tux overlord59-dj-tux-mix-platine overlord59-magic-tux overlord59-tux-pianiste touko-tux-pirate"; + parts { + part { + name: "entrance.icon"; + type: SWALLOW; + mouse_events: 0; + description { state: "default" 0.0; + min: 96 96; + visible: 1; + //aspect : 1.0 1.0; + //aspect_preference : BOTH; + } + } + } + } + +#define ADD_USER_ICON(NAME) \ + group { name: "entrance/user/"NAME; \ + images { \ + image: NAME".png" COMP; \ + } \ + parts { \ + part { name: "base"; \ + type: RECT; \ + description { state: "default" 0.0; \ + visible: 0; \ + } \ + } \ + part { name: "icon"; \ + type: IMAGE; \ + description { \ + image { \ + normal: NAME".png"; \ + scale_hint: STATIC; \ + } \ + } \ + } \ + } \ + } + ADD_USER_ICON("adrielhernandez-cmyk-tux") + ADD_USER_ICON("brunocb-tux-1-euro") + ADD_USER_ICON("cisoun-tux-coup-de-soleil") + ADD_USER_ICON("eliaden-tux-marin") + ADD_USER_ICON("fcys14-tux-breton") + ADD_USER_ICON("fcys14-tux-croco") + ADD_USER_ICON("fcys14-tux-pompier") + ADD_USER_ICON("fcys14-yoshi-tux") + ADD_USER_ICON("m4r10-tux-crema") + ADD_USER_ICON("mybob-calimetux") + ADD_USER_ICON("overlord59-astro-tux") + ADD_USER_ICON("overlord59-dj-tux-mix-platine") + ADD_USER_ICON("overlord59-magic-tux") + ADD_USER_ICON("overlord59-tux-pianiste") + ADD_USER_ICON("touko-tux-pirate") +} + diff --git a/data/themes/default/images/adrielhernandez-cmyk-tux.png b/data/themes/default/images/adrielhernandez-cmyk-tux.png new file mode 100644 index 0000000..311e73c Binary files /dev/null and b/data/themes/default/images/adrielhernandez-cmyk-tux.png differ diff --git a/data/themes/default/images/arrow_left.png b/data/themes/default/images/arrow_left.png new file mode 100644 index 0000000..fbe0795eaa Binary files /dev/null and b/data/themes/default/images/arrow_left.png differ diff --git a/data/themes/default/images/box_login.png b/data/themes/default/images/box_login.png new file mode 100644 index 0000000..e1fbb28 Binary files /dev/null and b/data/themes/default/images/box_login.png differ diff --git a/data/themes/default/images/box_login_shine.png b/data/themes/default/images/box_login_shine.png new file mode 100644 index 0000000..db66166 Binary files /dev/null and b/data/themes/default/images/box_login_shine.png differ diff --git a/data/themes/default/images/brunocb-tux-1-euro.png b/data/themes/default/images/brunocb-tux-1-euro.png new file mode 100644 index 0000000..fc2f715 Binary files /dev/null and b/data/themes/default/images/brunocb-tux-1-euro.png differ diff --git a/data/themes/default/images/bt_sm_base2.png b/data/themes/default/images/bt_sm_base2.png new file mode 100644 index 0000000..f159648 Binary files /dev/null and b/data/themes/default/images/bt_sm_base2.png differ diff --git a/data/themes/default/images/bt_sm_hilight.png b/data/themes/default/images/bt_sm_hilight.png new file mode 100644 index 0000000..63899ca Binary files /dev/null and b/data/themes/default/images/bt_sm_hilight.png differ diff --git a/data/themes/default/images/bt_sm_shine.png b/data/themes/default/images/bt_sm_shine.png new file mode 100644 index 0000000..23bf311 Binary files /dev/null and b/data/themes/default/images/bt_sm_shine.png differ diff --git a/data/themes/default/images/check.png b/data/themes/default/images/check.png new file mode 100644 index 0000000..7d58e85 Binary files /dev/null and b/data/themes/default/images/check.png differ diff --git a/data/themes/default/images/cisoun-tux-coup-de-soleil.png b/data/themes/default/images/cisoun-tux-coup-de-soleil.png new file mode 100644 index 0000000..8a15e8f Binary files /dev/null and b/data/themes/default/images/cisoun-tux-coup-de-soleil.png differ diff --git a/data/themes/default/images/cur_box.png b/data/themes/default/images/cur_box.png new file mode 100644 index 0000000..136b8c8 Binary files /dev/null and b/data/themes/default/images/cur_box.png differ diff --git a/data/themes/default/images/cur_glow.png b/data/themes/default/images/cur_glow.png new file mode 100644 index 0000000..fd922bd Binary files /dev/null and b/data/themes/default/images/cur_glow.png differ diff --git a/data/themes/default/images/cur_hi.png b/data/themes/default/images/cur_hi.png new file mode 100644 index 0000000..cbafef8 Binary files /dev/null and b/data/themes/default/images/cur_hi.png differ diff --git a/data/themes/default/images/cur_shad.png b/data/themes/default/images/cur_shad.png new file mode 100644 index 0000000..3e899de Binary files /dev/null and b/data/themes/default/images/cur_shad.png differ diff --git a/data/themes/default/images/cur_shine.png b/data/themes/default/images/cur_shine.png new file mode 100644 index 0000000..6df5a6d Binary files /dev/null and b/data/themes/default/images/cur_shine.png differ diff --git a/data/themes/default/images/eliaden-tux-marin.png b/data/themes/default/images/eliaden-tux-marin.png new file mode 100644 index 0000000..b7a4cc2 Binary files /dev/null and b/data/themes/default/images/eliaden-tux-marin.png differ diff --git a/data/themes/default/images/entrance_foreground.png b/data/themes/default/images/entrance_foreground.png new file mode 100644 index 0000000..5470e0c Binary files /dev/null and b/data/themes/default/images/entrance_foreground.png differ diff --git a/data/themes/default/images/fcys14-tux-breton.png b/data/themes/default/images/fcys14-tux-breton.png new file mode 100644 index 0000000..16e001b Binary files /dev/null and b/data/themes/default/images/fcys14-tux-breton.png differ diff --git a/data/themes/default/images/fcys14-tux-croco.png b/data/themes/default/images/fcys14-tux-croco.png new file mode 100644 index 0000000..36d0ee4 Binary files /dev/null and b/data/themes/default/images/fcys14-tux-croco.png differ diff --git a/data/themes/default/images/fcys14-tux-pompier.png b/data/themes/default/images/fcys14-tux-pompier.png new file mode 100644 index 0000000..74d966b Binary files /dev/null and b/data/themes/default/images/fcys14-tux-pompier.png differ diff --git a/data/themes/default/images/fcys14-yoshi-tux.png b/data/themes/default/images/fcys14-yoshi-tux.png new file mode 100644 index 0000000..a18ab42 Binary files /dev/null and b/data/themes/default/images/fcys14-yoshi-tux.png differ diff --git a/data/themes/default/images/login_box.png b/data/themes/default/images/login_box.png new file mode 100644 index 0000000..69a3b53 Binary files /dev/null and b/data/themes/default/images/login_box.png differ diff --git a/data/themes/default/images/logo_b.png b/data/themes/default/images/logo_b.png new file mode 100644 index 0000000..0b79b69 Binary files /dev/null and b/data/themes/default/images/logo_b.png differ diff --git a/data/themes/default/images/logo_w.png b/data/themes/default/images/logo_w.png new file mode 100644 index 0000000..9f0c7a7 Binary files /dev/null and b/data/themes/default/images/logo_w.png differ diff --git a/data/themes/default/images/m4r10-tux-crema.png b/data/themes/default/images/m4r10-tux-crema.png new file mode 100644 index 0000000..3817100 Binary files /dev/null and b/data/themes/default/images/m4r10-tux-crema.png differ diff --git a/data/themes/default/images/moon.png b/data/themes/default/images/moon.png new file mode 100644 index 0000000..0ac9eb4 Binary files /dev/null and b/data/themes/default/images/moon.png differ diff --git a/data/themes/default/images/mybob-calimetux.png b/data/themes/default/images/mybob-calimetux.png new file mode 100644 index 0000000..f23bbf0 Binary files /dev/null and b/data/themes/default/images/mybob-calimetux.png differ diff --git a/data/themes/default/images/overlord59-astro-tux.png b/data/themes/default/images/overlord59-astro-tux.png new file mode 100644 index 0000000..f6c3f2e Binary files /dev/null and b/data/themes/default/images/overlord59-astro-tux.png differ diff --git a/data/themes/default/images/overlord59-dj-tux-mix-platine.png b/data/themes/default/images/overlord59-dj-tux-mix-platine.png new file mode 100644 index 0000000..53b89bd Binary files /dev/null and b/data/themes/default/images/overlord59-dj-tux-mix-platine.png differ diff --git a/data/themes/default/images/overlord59-magic-tux.png b/data/themes/default/images/overlord59-magic-tux.png new file mode 100644 index 0000000..1562fab Binary files /dev/null and b/data/themes/default/images/overlord59-magic-tux.png differ diff --git a/data/themes/default/images/overlord59-tux-pianiste.png b/data/themes/default/images/overlord59-tux-pianiste.png new file mode 100644 index 0000000..059f644 Binary files /dev/null and b/data/themes/default/images/overlord59-tux-pianiste.png differ diff --git a/data/themes/default/images/password.png b/data/themes/default/images/password.png new file mode 100644 index 0000000..13348fa Binary files /dev/null and b/data/themes/default/images/password.png differ diff --git a/data/themes/default/images/shelf_inset.png b/data/themes/default/images/shelf_inset.png new file mode 100644 index 0000000..bb1989d Binary files /dev/null and b/data/themes/default/images/shelf_inset.png differ diff --git a/data/themes/default/images/silhouette.png b/data/themes/default/images/silhouette.png new file mode 100644 index 0000000..cdc95b7 Binary files /dev/null and b/data/themes/default/images/silhouette.png differ diff --git a/data/themes/default/images/sl_bt2_2.png b/data/themes/default/images/sl_bt2_2.png new file mode 100644 index 0000000..061ac29 Binary files /dev/null and b/data/themes/default/images/sl_bt2_2.png differ diff --git a/data/themes/default/images/star.png b/data/themes/default/images/star.png new file mode 100644 index 0000000..d16ce3f Binary files /dev/null and b/data/themes/default/images/star.png differ diff --git a/data/themes/default/images/touko-tux-pirate.png b/data/themes/default/images/touko-tux-pirate.png new file mode 100644 index 0000000..a1b678f Binary files /dev/null and b/data/themes/default/images/touko-tux-pirate.png differ diff --git a/data/themes/default/images/user.png b/data/themes/default/images/user.png new file mode 100644 index 0000000..0586b78 Binary files /dev/null and b/data/themes/default/images/user.png differ diff --git a/data/themes/default/images/xsession.png b/data/themes/default/images/xsession.png new file mode 100644 index 0000000..e1b23b2 Binary files /dev/null and b/data/themes/default/images/xsession.png differ diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 5675b1c..195d93a 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -16,10 +16,14 @@ entrance_client_SOURCES = \ ../event/entrance_event.c \ entrance_client.h \ entrance_client.c \ +entrance_conf.h \ +entrance_conf.c \ entrance_connect.h \ entrance_connect.c \ entrance_fill.h \ entrance_fill.c \ +entrance_login.h \ +entrance_login.c \ entrance_gui.h \ entrance_gui.c diff --git a/src/bin/entrance_client.c b/src/bin/entrance_client.c index 50ee5de..1d30835 100644 --- a/src/bin/entrance_client.c +++ b/src/bin/entrance_client.c @@ -27,20 +27,6 @@ static const Ecore_Getopt options = } }; -int -entrance_client_main(const char *theme) -{ - PT("client init\n"); - if (entrance_gui_init(theme)) return EXIT_FAILURE; - PT("client run\n"); - entrance_connect_init(); - elm_run(); - entrance_connect_shutdown(); - PT("_client: client shutdown\n"); - entrance_gui_shutdown(); - return EXIT_SUCCESS; -} - int main(int argc, char **argv) { @@ -70,12 +56,23 @@ main(int argc, char **argv) } eina_init(); ecore_init(); - ecore_x_init(NULL); + ecore_x_init(display); elm_init(argc, argv); - entrance_client_main(theme); + PT("login init\n"); + entrance_login_init(); + PT("client init\n"); + if (!entrance_gui_init(theme)) return EXIT_FAILURE; + PT("client run\n"); + entrance_connect_init(); + elm_run(); + entrance_connect_shutdown(); + PT("_client: client shutdown\n"); + entrance_gui_shutdown(); + entrance_login_shutdown(); elm_shutdown(); ecore_x_shutdown(); ecore_shutdown(); eina_shutdown(); return EXIT_SUCCESS; } + diff --git a/src/bin/entrance_client.h b/src/bin/entrance_client.h index 11c90a6..bf71924 100644 --- a/src/bin/entrance_client.h +++ b/src/bin/entrance_client.h @@ -9,14 +9,16 @@ #include +#include "../event/entrance_event.h" #include "entrance_gui.h" +#include "entrance_conf.h" #include "entrance_connect.h" #include "entrance_client.h" #include "entrance_gui.h" #include "entrance_fill.h" -#include "../event/entrance_event.h" +#include "entrance_login.h" -#define PT(x) \ +#define PT(f, x...) \ do \ { \ current_time = time(NULL); \ @@ -24,7 +26,7 @@ do \ memset(entrance_time_d, 0, sizeof(entrance_time_d)); \ strftime(entrance_time_d, sizeof(entrance_time_d), \ "%b %_2d %T", local_time); \ - fprintf(stderr, "(%s) "PACKAGE"_client: %s", entrance_time_d, x); \ + fprintf(stderr, "(%s) "PACKAGE"_client: "f, entrance_time_d, ##x); \ } while (0) extern time_t current_time; diff --git a/src/bin/entrance_conf.c b/src/bin/entrance_conf.c new file mode 100644 index 0000000..05fdf98 --- /dev/null +++ b/src/bin/entrance_conf.c @@ -0,0 +1,591 @@ +#include "entrance_client.h" + +typedef struct Entrance_Conf_Background_ +{ + const char *path; + const char *group; + const char *name; +} Entrance_Conf_Background; + +typedef struct Entrance_Int_Conf_ +{ + struct + { + Evas_Object *preview; + const char *path; + const char *group; + } bg; + const char *theme; + const char *elm_profile; + Eina_Bool vkbd_enabled : 1; + double scale; + + struct + { + const char *user; + struct + { + Evas_Object *preview; + const char *path; + const char *group; + } bg; + Eina_Bool remember_session : 1; + } user; + + struct + { + Evas_Object *btn_ok; + Evas_Object *btn_apply; + } gui; + +} Entrance_Int_Conf; + + +static void _entrance_conf_init(void); +static void _entrance_conf_shutdown(void); +static char *_entrance_conf_bg_text_get(void *data, Evas_Object *obj, const char *part); +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 void _entrance_conf_changed(); +static void _entrance_conf_apply(); + +static Entrance_Fill *_entrance_background_fill = NULL; +static Entrance_Int_Conf *_entrance_int_conf = NULL; + +static char * +_entrance_conf_bg_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED) +{ + Entrance_Conf_Background *cbg; + cbg = data; + return strdup(cbg->name); +} + +static Evas_Object * +_entrance_conf_bg_content_get(void *data, Evas_Object *obj, const char *part) +{ + Entrance_Conf_Background *cbg; + Evas_Object *o = NULL; + cbg = data; + if (part && !strcmp("elm.swallow.icon", part)) + { + o = elm_image_add(obj); + elm_image_file_set(o, cbg->path, cbg->group); + elm_image_smooth_set(o, EINA_FALSE); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_show(o); + } + return o; +} + +static Eina_Bool +_entrance_conf_bg_state_get(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED) +{ + return EINA_FALSE; +} + +static void +_entrance_conf_bg_del(void *data, Evas_Object *obj EINA_UNUSED) +{ + Entrance_Conf_Background *cbg; + cbg = data; + eina_stringshare_del(cbg->name); + eina_stringshare_del(cbg->path); + eina_stringshare_del(cbg->group); + free(cbg); +} + +static void +_entrance_conf_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); + fprintf(stderr, "%s %s\n", cbg->path, cbg->group); + if (!elm_layout_file_set(_entrance_int_conf->bg.preview, + cbg->path, cbg->group)) + { + PT("Error on loading "); + fprintf(stderr, "%s %s\n", cbg->path, cbg->group); + } + _entrance_int_conf->bg.path = cbg->path; + _entrance_int_conf->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) +{ + Elm_Actionslider_Pos p; + + PT("User change vkbd state\n"); + + p = elm_actionslider_indicator_pos_get(obj); + _entrance_int_conf->vkbd_enabled = !!(p == ELM_ACTIONSLIDER_RIGHT); + _entrance_conf_changed(); +} + +/* scale */ +static void +_entrance_conf_scale_changed(void *data EINA_UNUSED, Evas_Object *obj, void *event EINA_UNUSED) +{ + _entrance_int_conf->scale = elm_spinner_value_get(obj); + _entrance_conf_changed(); +} + +/* Buttons Cb */ +static void +_entrance_conf_ok_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) +{ + _entrance_conf_apply(); + evas_object_del(data); + _entrance_conf_shutdown(); +} + +static void +_entrance_conf_apply_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) +{ + _entrance_conf_apply(); + _entrance_conf_changed(); +} + +static void +_entrance_conf_close_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) +{ + evas_object_del(data); + _entrance_conf_shutdown(); +} + + +static Eina_List * +_entrance_conf_backgrounds_get(Evas_Object *obj, const char *user) +{ + Evas_Object *o, *edj; + Eina_List *list, *l, *nl = NULL; + Entrance_Conf_Background *cbg; + const char *str; + const char *path; + char buf[PATH_MAX]; + Eina_Iterator *it; + + o = entrance_gui_theme_get(obj, "entrance/background"); + edj = elm_layout_edje_get(o); + edje_object_file_get(edj, &path, NULL); + list = entrance_gui_stringlist_get(edje_object_data_get(edj, "items")); + EINA_LIST_FOREACH(list, l, str) + { + cbg = calloc(1, sizeof(Entrance_Conf_Background)); + snprintf(buf, sizeof(buf), + "entrance/background/%s", str); + + cbg->path = eina_stringshare_add(path); + cbg->group = eina_stringshare_add(buf); + cbg->name = eina_stringshare_add(str); + nl = eina_list_append(nl, cbg); + } + 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) + { + int len; + len = strlen(str); + if (len < 4) continue; + if (!strcmp(&str[len-4], ".edj")) + { + cbg = calloc(1, sizeof(Entrance_Conf_Background)); + snprintf(buf, sizeof(buf), + "entrance/background/%s", str); + cbg->path = str; + cbg->group = eina_stringshare_add("e/desktop/background"); + { + char *name, *p; + name = strrchr(str, '/'); + if (name) + { + name++; + name = strdupa(name); + p = strrchr(name, '.'); + if (p) *p = '\0'; + } + cbg->name = eina_stringshare_add(name); + } + nl = eina_list_append(nl, cbg); + } + else + eina_stringshare_del(str); + } + eina_iterator_free(it); + + return nl; +} + +static void +_entrance_conf_apply() +{ + Entrance_Conf_Gui_Event conf; + + conf.bg.path = _entrance_int_conf->bg.path; + conf.bg.group = _entrance_int_conf->bg.group; + conf.vkbd_enabled = _entrance_int_conf->vkbd_enabled; + + entrance_gui_conf_set(&conf); + entrance_connect_conf_send(&conf); +} + +/* Build it */ +static Evas_Object * +_entrance_conf_build(Evas_Object *obj) +{ + Evas_Object *t, *bx, *hbx, *o; + Eina_List *l; + int j = 0; + + t = elm_table_add(obj); + elm_table_padding_set(t, 5 , 5); + evas_object_size_hint_weight_set(t, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + /* Background */ + o = elm_label_add(t); + elm_object_text_set(o, "Background"); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_table_pack(t, o, 0, j, 1, 1); + evas_object_show(o); + ++j; + + hbx = elm_box_add(t); + elm_box_horizontal_set(hbx, EINA_TRUE); + 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); + 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; + 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); + j += 3; + + /* Touch Screen */ + o = elm_label_add(t); + elm_object_text_set(o, "Use a virtual keyboard"); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_table_pack(t, o, 0, j, 1, 1); + evas_object_show(o); + o = elm_actionslider_add(t); + elm_object_style_set(o, "bar"); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_part_text_set(o, "left", "Disabled"); + elm_object_part_text_set(o, "right", "Enabled"); + + elm_actionslider_magnet_pos_set(o, ELM_ACTIONSLIDER_LEFT); + elm_actionslider_enabled_pos_set(o, ELM_ACTIONSLIDER_LEFT | + ELM_ACTIONSLIDER_RIGHT); + evas_object_smart_callback_add(o, "selected", + _entrance_conf_vkbd_changed, NULL); + if (_entrance_int_conf->vkbd_enabled) + elm_actionslider_indicator_pos_set(o, ELM_ACTIONSLIDER_RIGHT); + else + elm_actionslider_indicator_pos_set(o, ELM_ACTIONSLIDER_LEFT); + elm_table_pack(t, o, 1, j, 1, 1); + evas_object_show(o); + ++j; + + /* Elementary Profile */ + o = elm_label_add(t); + elm_object_text_set(o, "elementary profile"); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_table_pack(t, o, 0, j, 1, 1); + evas_object_show(o); + o = elm_button_add(t); + elm_object_text_set(o, _entrance_int_conf->elm_profile); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_table_pack(t, o, 1, j, 1, 1); + evas_object_show(o); + ++j; + + /* Scaling */ + o = elm_label_add(t); + elm_object_text_set(o, "Scaling"); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_table_pack(t, o, 0, j, 1, 1); + evas_object_show(o); + o = elm_spinner_add(t); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_smart_callback_add(o, "changed", + _entrance_conf_scale_changed, NULL); + elm_spinner_value_set(o, _entrance_int_conf->scale); + elm_spinner_min_max_set(o, 0.25, 5.0); + elm_spinner_step_set(o, 0.15); + elm_spinner_label_format_set(o, "%.2f"); + + elm_table_pack(t, o, 1, j, 1, 1); + evas_object_show(o); + ++j; + + o = evas_object_rectangle_add(o); + evas_object_color_set(o, 0, 0, 0, 0); + evas_object_size_hint_min_set(o, 128, 0); + elm_table_pack(t, o, 1, j, 1, 1); + + evas_object_show(t); + return t; +} + +static Evas_Object * +_entrance_conf_user_build(Evas_Object *obj) +{ + Evas_Object *t, *bx, *o, *ly; + int j = 0; + + 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); + + t = elm_table_add(obj); + elm_object_part_content_set(ly, "entrance.conf", t); + elm_table_padding_set(t, 5 , 5); + + /* Background */ + o = elm_label_add(t); + elm_object_text_set(o, "Background"); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_table_pack(t, o, 0, j, 1, 1); + evas_object_show(o); + ++j; + o = elm_gengrid_add(t); + 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); + evas_object_show(o); + j += 3; + + /* Session to autoselect */ + o = elm_label_add(t); + elm_object_text_set(o, "Session to use"); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_table_pack(t, o, 0, j, 1, 1); + evas_object_show(o); + o = elm_hoversel_add(t); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(o, "Session"); + elm_table_pack(t, o, 1, j, 1, 1); + evas_object_show(o); + ++j; + + /* Remember last session */ + o = elm_label_add(t); + elm_object_text_set(o, "Remember last session"); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_table_pack(t, o, 0, j, 1, 1); + evas_object_show(o); + o = elm_actionslider_add(t); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_part_text_set(o, "left", "Enabled"); + elm_object_part_text_set(o, "right", "Disabled"); + elm_table_pack(t, o, 1, j, 1, 1); + evas_object_show(o); + ++j; + + evas_object_show(t); + + return ly; +} + +static void +_entrance_conf_control_changed(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event) +{ + Elm_Object_Item *it; + it = event; + elm_naviframe_item_promote(elm_object_item_data_get(it)); +} + + +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +static void +_entrance_conf_changed(void) +{ + const char *bg_path; + 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())) + { + elm_object_disabled_set(_entrance_int_conf->gui.btn_ok, EINA_FALSE); + elm_object_disabled_set(_entrance_int_conf->gui.btn_apply, EINA_FALSE); + } + else + { + elm_object_disabled_set(_entrance_int_conf->gui.btn_ok, EINA_TRUE); + elm_object_disabled_set(_entrance_int_conf->gui.btn_apply, EINA_TRUE); + } +} + + +static void +_entrance_conf_init(void) +{ + PT("conf init\n"); + _entrance_background_fill = + entrance_fill_new("default", + _entrance_conf_bg_text_get, + _entrance_conf_bg_content_get, + _entrance_conf_bg_state_get, + _entrance_conf_bg_del); + _entrance_int_conf = calloc(1, sizeof(Entrance_Int_Conf)); + _entrance_int_conf->theme = entrance_gui_theme_name_get(); + entrance_gui_background_get(&(_entrance_int_conf->bg.path), + &(_entrance_int_conf->bg.group)); + _entrance_int_conf->vkbd_enabled = entrance_gui_vkbd_enabled_get(); + _entrance_int_conf->scale = elm_config_scale_get(); + _entrance_int_conf->elm_profile = elm_config_profile_get(); +} + +static void +_entrance_conf_shutdown(void) +{ + PT("conf shutdown\n"); + entrance_fill_del(_entrance_background_fill); + free(_entrance_int_conf); +} + + +void +entrance_conf_begin(Evas_Object *obj, Evas_Object *parent) +{ + PT("Build config panel\n"); + Evas_Object *win, *bg, *bx, *hbx, *sc, *nf, *o; + Elm_Object_Item *it, *itc; + Elm_Object_Item *itu, *ituc; + + _entrance_conf_init(); + + win = elm_hover_add(obj); + elm_hover_parent_set(win, parent); +// win = elm_popup_add(obj); + bg = elm_bg_add(win); + bx = elm_box_add(win); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_content_set(win, bx); + + sc = elm_segment_control_add(bx); + evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, 0); + evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(bx, sc); + evas_object_smart_callback_add(sc, "changed", + _entrance_conf_control_changed, NULL); + evas_object_show(sc); + + nf = elm_naviframe_add(bx); + evas_object_size_hint_weight_set(nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(nf, EVAS_HINT_FILL, EVAS_HINT_FILL); + 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); + elm_box_homogeneous_set(hbx, EINA_TRUE); + evas_object_size_hint_weight_set(hbx, EVAS_HINT_EXPAND, 0); + evas_object_size_hint_align_set(hbx, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(bx, hbx); + evas_object_show(hbx); + + o = elm_button_add(hbx); + elm_object_text_set(o, "Ok"); + elm_object_disabled_set(o, EINA_TRUE); + evas_object_smart_callback_add(o, "clicked", + _entrance_conf_ok_clicked, win); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(hbx, o); + _entrance_int_conf->gui.btn_ok = o; + evas_object_show(o); + + o = elm_button_add(hbx); + elm_object_text_set(o, "Apply"); + elm_object_disabled_set(o, EINA_TRUE); + evas_object_smart_callback_add(o, "clicked", + _entrance_conf_apply_clicked, NULL); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(hbx, o); + _entrance_int_conf->gui.btn_apply = o; + evas_object_show(o); + + o = elm_button_add(hbx); + elm_object_text_set(o, "Close"); + evas_object_smart_callback_add(o, "clicked", + _entrance_conf_close_clicked, win); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(hbx, o); + evas_object_show(o); + + elm_segment_control_item_selected_set(itc, EINA_TRUE); + + { + Evas_Coord xx, yy, ww, hh, x, y, w, h; + evas_object_geometry_get(obj, &x, &y, &w, &h); + evas_object_geometry_get(bx, NULL, NULL, &ww, &hh); + xx = 50;//x + (w / 2) - (ww / 2); + yy = 50;//y + (y / 2) - (hh / 2); + evas_object_move(bg, xx, yy); + evas_object_resize(bg, w - 100, h - 100); + evas_object_move(bx, xx, yy); + evas_object_resize(bx, w - 100, h - 100); + } + evas_object_show(bg); + evas_object_show(bx); + evas_object_show(win); + evas_object_freeze_events_set(win, EINA_TRUE); +} + diff --git a/src/bin/entrance_conf.h b/src/bin/entrance_conf.h new file mode 100644 index 0000000..802b800 --- /dev/null +++ b/src/bin/entrance_conf.h @@ -0,0 +1,6 @@ +#ifndef ENTRANCE_CONFIG_H +#define ENTRANCE_CONFIG_H + +void entrance_conf_begin(Evas_Object *obj, Evas_Object *parent); + +#endif /* ENTRANCE_CONFIG_H */ diff --git a/src/bin/entrance_connect.c b/src/bin/entrance_connect.c index 78aee8c..95a804f 100644 --- a/src/bin/entrance_connect.c +++ b/src/bin/entrance_connect.c @@ -1,20 +1,18 @@ #include #include "entrance_client.h" -Ecore_Con_Server *_entrance_connect; -Eina_List *_handlers; 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 Eina_Bool _entrance_connect_add(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__) { PT("connected\n"); - return ECORE_CALLBACK_RENEW; } @@ -31,68 +29,123 @@ static Eina_Bool _entrance_connect_data(void *data __UNUSED__, int type __UNUSED__, void *event) { Ecore_Con_Event_Server_Data *ev; - Entrance_Event *eev; ev = event; - eev = entrance_event_decode(ev->data, ev->size); + entrance_event_received(ev->data, ev->size); + + return ECORE_CALLBACK_RENEW; +} + +static Eina_Bool +_entrance_connect_read_cb(const void *data, size_t size EINA_UNUSED, void *user_data EINA_UNUSED) +{ + const Entrance_Event *eev; + eev = data; if (eev) { if (eev->type == ENTRANCE_EVENT_STATUS) { if (eev->event.status.granted) - entrance_gui_auth_valid(); + { + PT("Auth granted :)\n"); + entrance_gui_auth_valid(); + } else - entrance_gui_auth_error(); + { + PT("Auth error :(\n"); + entrance_gui_auth_error(); + } } else if (eev->type == ENTRANCE_EVENT_MAXTRIES) - entrance_gui_auth_wait(); + { + PT("Max tries !\n"); + entrance_gui_auth_max_tries(); + } else if (eev->type == ENTRANCE_EVENT_XSESSIONS) - entrance_gui_xsession_set(eev->event.xsessions.xsessions); + { + PT("Xsession received\n"); + entrance_gui_xsessions_set(eev->event.xsessions.xsessions); + } else if (eev->type == ENTRANCE_EVENT_USERS) - entrance_gui_users_set(eev->event.users.users); + { + PT("Users received\n"); + entrance_gui_users_set(eev->event.users.users); + } else if (eev->type == ENTRANCE_EVENT_ACTIONS) - entrance_gui_actions_set(eev->event.actions.actions); + { + PT("Action received\n"); + entrance_gui_actions_set(eev->event.actions.actions); + } + else if (eev->type == ENTRANCE_EVENT_CONF_GUI) + { + PT("Gui conf received\n"); + entrance_gui_conf_set(&(eev->event.conf_gui)); + } else - PT("unknow signal\n"); + { + PT("UNKNOW signal "); + fprintf(stderr, "%d\n", eev->type); + } + //free(eev); } return ECORE_CALLBACK_RENEW; } +static Eina_Bool +_entrance_connect_write_cb(const void *data, size_t size, void *user_data EINA_UNUSED) +{ + ecore_con_server_send(_entrance_connect, data, size); + return ECORE_CALLBACK_RENEW; +} + void -entrance_connect_auth_send(const char *login, const char *password, const char *session) +entrance_connect_auth_send(const char *login, const char *password, const char *session, Eina_Bool open_session) { Entrance_Event eev; - void *data; - int size; + PT("Request auth\n"); eev.event.auth.login = login; eev.event.auth.password = password; eev.event.auth.session = session; + eev.event.auth.open_session = open_session; eev.type = ENTRANCE_EVENT_AUTH; - data = entrance_event_encode(&eev, &size); - ecore_con_server_send(_entrance_connect, data, size); + entrance_event_send(&eev); } void -entrance_connect_action_send(int id) +entrance_connect_action_send(unsigned char id) { Entrance_Event eev; - void *data; - int size; + PT("Request action %d\n", id); eev.event.action.action = id; eev.type = ENTRANCE_EVENT_ACTION; - data = entrance_event_encode(&eev, &size); - ecore_con_server_send(_entrance_connect, data, size); + entrance_event_send(&eev); } +void +entrance_connect_conf_send(Entrance_Conf_Gui_Event *ev) +{ + Entrance_Event eev; + PT("Send config\n"); + eev.event.conf_gui.bg.path = ev->bg.path; + eev.event.conf_gui.bg.group = ev->bg.group; + + eev.type = ENTRANCE_EVENT_CONF_GUI; + entrance_event_send(&eev); +} + + void entrance_connect_init() { Ecore_Event_Handler *h; ecore_con_init(); + entrance_event_init(_entrance_connect_read_cb, + _entrance_connect_write_cb, + NULL); _entrance_connect = ecore_con_server_connect(ECORE_CON_LOCAL_SYSTEM, - "entrance", 42, NULL); + "entrance", 42, NULL); if (_entrance_connect) PT("client server init ok\n"); else @@ -115,6 +168,7 @@ entrance_connect_shutdown() PT("client server shutdown\n"); EINA_LIST_FREE(_handlers, h) ecore_event_handler_del(h); + entrance_event_shutdown(); ecore_con_shutdown(); } diff --git a/src/bin/entrance_connect.h b/src/bin/entrance_connect.h index 2fc5c51..e12aa76 100644 --- a/src/bin/entrance_connect.h +++ b/src/bin/entrance_connect.h @@ -1,7 +1,8 @@ #ifndef ENTRANCE_CONNECT_ #define ENTRANCE_CONNECT_ void entrance_connect_init(); -void entrance_connect_auth_send(const char *login, const char *password, const char *session); -void entrance_connect_action_send(int id); +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_shutdown(); #endif /* ENTRANCE_CONNECT_ */ diff --git a/src/bin/entrance_fill.c b/src/bin/entrance_fill.c index cb9c92c..2e41139 100644 --- a/src/bin/entrance_fill.c +++ b/src/bin/entrance_fill.c @@ -5,10 +5,12 @@ struct Entrance_Fill_ const char *item_style; //maybee need to be provided by theme ? struct { - EntranceFillTextGetFunc text_get; + EntranceFillTextGetFunc text_get; EntranceFillContentGetFunc content_get; - EntranceFillStateGetFunc state_get; - EntranceFillDelFunc del; + EntranceFillStateGetFunc state_get; + EntranceFillDelFunc del; + Evas_Smart_Cb sel; + void *data; } func; Elm_Genlist_Item_Class *glc; Elm_Gengrid_Item_Class *ggc; @@ -16,23 +18,26 @@ struct Entrance_Fill_ ///////////////// LIST /////////////////////////////// static void -_entrance_fill_list(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Evas_Smart_Cb func) +_entrance_fill_list(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Evas_Smart_Cb func, void *data) { Eina_List *l; void *content; EINA_LIST_FOREACH(contents, l, content) { + Elm_Object_Item *it = NULL; if (ef->func.text_get) - elm_list_item_append(obj, ef->func.text_get(content, NULL, NULL), NULL, - NULL, func, content); + it = elm_list_item_append(obj, ef->func.text_get(content, NULL, NULL), NULL, + NULL, func, data); + if (it) + elm_object_item_data_set(it, content); } elm_list_go(obj); } ///////////////// GENLIST ///////////////////////////// static void -_entrance_fill_genlist(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Evas_Smart_Cb func) +_entrance_fill_genlist(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Evas_Smart_Cb func, void *data) { Eina_List *l; Elm_Genlist_Item_Class *glc; @@ -53,14 +58,18 @@ _entrance_fill_genlist(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, EINA_LIST_FOREACH(contents, l, content) - elm_genlist_item_append(obj, glc, - content, NULL, ELM_GENLIST_ITEM_NONE, - func, content); + { + Elm_Object_Item *it; + it = elm_genlist_item_append(obj, glc, + content, NULL, ELM_GENLIST_ITEM_NONE, + func, data); + elm_object_item_data_set(it, content); + } } ///////////////// GENGRID ///////////////////////////// static void -_entrance_fill_gengrid(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Evas_Smart_Cb func) +_entrance_fill_gengrid(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Evas_Smart_Cb func, void *data) { Eina_List *l; Elm_Gengrid_Item_Class *ggc; @@ -80,28 +89,61 @@ _entrance_fill_gengrid(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, ggc->func.del = ef->func.del; EINA_LIST_FOREACH(contents, l, content) - elm_gengrid_item_append(obj, ggc, - content, func, content); + { + Elm_Object_Item *it; + it = elm_gengrid_item_append(obj, ggc, + content, func, data); + elm_object_item_data_set(it, content); + } } ///////////////// HOVERSEL ///////////////////////////// static void -_entrance_fill_hoversell(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Evas_Smart_Cb func) +_entrance_fill_hoversell_func_cb(void *data, Evas_Object *obj, void *event_info) +{ + Entrance_Fill *ef; + + ef = evas_object_data_get(obj, "fill_data"); + if (!ef) return; + if (ef->func.sel) + ef->func.sel(ef->func.data, obj, event_info); +} + +static void +_entrance_fill_hoversell(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Evas_Smart_Cb func, void *data) { Eina_List *l; - char *str = NULL; void *content; + char *str = NULL; + char *ic = NULL; + if (!ef->func.text_get) return; + ef->func.sel = func; + ef->func.data = data; EINA_LIST_FOREACH(contents, l, content) { - if (ef->func.text_get) - str = ef->func.text_get(content, obj, NULL); - elm_hoversel_item_add(obj, str, NULL, - ELM_ICON_FILE, func, content); - free(str); + Elm_Object_Item *it; + str = ef->func.text_get(content, obj, NULL); + ic = ef->func.text_get(content, obj, "icon"); + it = elm_hoversel_item_add(obj, str, ic, + ELM_ICON_FILE, + _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 (ic) + { + free(ic); + ic = NULL; + } + if (str) + { + free(str); + str = NULL; + } } } +///////////////// MAIN ///////////////////////////// Entrance_Fill * entrance_fill_new(const char *item_style, EntranceFillTextGetFunc text_get, EntranceFillContentGetFunc content_get, EntranceFillStateGetFunc state_get, EntranceFillDelFunc del_func) { @@ -123,20 +165,25 @@ entrance_fill_del(Entrance_Fill *ef) } void -entrance_fill(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, Evas_Smart_Cb func) +entrance_fill(Evas_Object *obj, Entrance_Fill *ef, Eina_List *contents, 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); + _entrance_fill_list(obj, ef, contents, func, data); else if (!strcmp(type, "elm_genlist")) - _entrance_fill_genlist(obj, ef, contents, func); + _entrance_fill_genlist(obj, ef, contents, func, data); else if (!strcmp(type, "elm_gengrid")) - _entrance_fill_gengrid(obj, ef, contents, func); + _entrance_fill_gengrid(obj, ef, contents, func, data); else if (!strcmp(type, "elm_hoversel")) - _entrance_fill_hoversell(obj, ef, contents, func); + _entrance_fill_hoversell(obj, ef, contents, func, data); + else + { + PT("Unknow object type to fill "); + fprintf(stderr, "%s\n", type); + } } } diff --git a/src/bin/entrance_fill.h b/src/bin/entrance_fill.h index 7f0b771..b3ca3e2 100644 --- a/src/bin/entrance_fill.h +++ b/src/bin/entrance_fill.h @@ -9,7 +9,7 @@ typedef Eina_Bool (*EntranceFillStateGetFunc) (void *data, Evas_Object *obj, con typedef void (*EntranceFillDelFunc) (void *data, Evas_Object *obj); 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 entrance_fill(Evas_Object *obj, Entrance_Fill *egf, Eina_List *contents, Evas_Smart_Cb func, void *data); void entrance_fill_del(Entrance_Fill *ef); diff --git a/src/bin/entrance_gui.c b/src/bin/entrance_gui.c index 3d80202..0b3828d 100644 --- a/src/bin/entrance_gui.c +++ b/src/bin/entrance_gui.c @@ -1,13 +1,45 @@ #include "entrance_client.h" #include "Ecore_X.h" -#define ENTRANCE_GUI_GET(edj, name) edje_object_part_external_object_get(elm_layout_edje_get(edj), name) typedef struct Entrance_Gui_ Entrance_Gui; typedef struct Entrance_Screen_ Entrance_Screen; +static Eina_Bool _entrance_gui_cb_window_property(void *data, int type, void *event_info); +static void _entrance_gui_user_sel_cb(void *data, Evas_Object *obj, void *event_info); +static char *_entrance_gui_user_text_get(void *data, Evas_Object *obj, const char *part); +static Evas_Object *_entrance_gui_user_content_get(void *data, Evas_Object *obj, const char *part); +static Eina_Bool _entrance_gui_user_state_get(void *data, Evas_Object *obj, const char *part); +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_session_update(Entrance_Xsession *xsession); +static void _entrance_gui_login_activated_cb(void *data, Evas_Object *obj, void *event_info); +static void _entrance_gui_password_activated_cb(void *data, Evas_Object *obj, void *event_info); +static void _entrance_gui_shutdown(void *data, Evas_Object *obj, void *event_info); +static void _entrance_gui_focus(void *data, Evas_Object *obj, void *event_info); +static void _entrance_gui_session_update(Entrance_Xsession *xsession); +static Eina_Bool _entrance_gui_auth_enable(void *data); +static void _entrance_gui_action_clicked_cb(void *data, Evas_Object *obj, void *event_info); +static Ecore_Timer *_gui_login_timeout; +*/ +static Entrance_Gui *_gui; + +enum { + ENTRANCE_CONF_NONE = 0, + ENTRANCE_CONF_STATE = (1 << 0), + ENTRANCE_CONF_WALLPAPER = (1 << 1), + ENTRANCE_CONF_VKBD = (1 << 2) +}; + + struct Entrance_Gui_ { + Evas_Object *win; Eina_List *screens; Eina_List *xsessions; Eina_List *users; @@ -15,55 +47,162 @@ struct Entrance_Gui_ Eina_List *handlers; Entrance_Xsession *selected_session; const char *theme; + struct + { + const char *path; + const char *group; + } bg; + unsigned char changed; + Eina_Bool conf_enabled : 1; + Eina_Bool vkbd_enabled : 1; }; struct Entrance_Screen_ { - Evas_Object *win; - Evas_Object *bg; Evas_Object *edj; + Evas_Object *background; + Evas_Object *transition; + Evas_Object *login; + Eina_Bool focused:1; Eina_Bool managed:1; }; -static Evas_Object *_entrance_gui_theme_get(Evas_Object *win, const char *group, const char *theme); -static void _entrance_gui_hostname_activated_cb(void *data, Evas_Object *obj, void *event_info); -static void _entrance_gui_password_activated_cb(void *data, Evas_Object *obj, void *event_info); -static void _entrance_gui_shutdown(void *data, Evas_Object *obj, void *event_info); -static void _entrance_gui_focus(void *data, Evas_Object *obj, void *event_info); -static void _entrance_gui_session_update(Entrance_Xsession *xsession); - -static void _entrance_gui_actions_populate(); - -static void _entrance_gui_user_sel_cb(void *data, Evas_Object *obj, void *event_info); -static void _entrance_gui_user_sel(Entrance_User *ou); -static char *_entrance_gui_user_text_get(void *data, Evas_Object *obj, const char *part); -static Evas_Object *_entrance_gui_user_content_get(void *data, Evas_Object *obj, const char *part); -static Eina_Bool _entrance_gui_user_state_get(void *data, Evas_Object *obj, const char *part); -static void _entrance_gui_user_del(void *data, Evas_Object *obj); - -static Eina_Bool _entrance_gui_auth_enable(void *data); - -static Eina_Bool _entrance_gui_cb_window_property(void *data, int type, void *event_info); - -static void _entrance_gui_action_clicked_cb(void *data, Evas_Object *obj, void *event_info); -static Entrance_Gui *_gui; -static Ecore_Timer *_gui_login_timeout; - -static Evas_Object * -_entrance_gui_theme_get (Evas_Object *win, const char *group, const char *theme) +int +entrance_gui_init(const char *theme) { - Evas_Object *edje = NULL; + + Ecore_X_Window xw; + Entrance_Screen *screen; + int i, j; + int x, y, w, h; + int ww = 0, hh = 0; + + PT("Gui init: "); + fprintf(stderr, "%s\n", theme); + _gui = calloc(1, sizeof(Entrance_Gui)); + if (!_gui) + { + PT("Not Enough memory\n"); + return 1; + } + _gui->theme = eina_stringshare_add(theme); + +#ifdef XNEST_DEBUG + char *tmp = getenv("DISPLAY"); + if (tmp && *tmp) + { + PT("client Using display name"); + fprintf(stderr, " %s\n", tmp); + } +#endif + + i = ecore_x_xinerama_screen_count_get(); + if (i < 1) i = 1; + _gui->win = elm_win_add(NULL, "main", ELM_WIN_BASIC); + elm_win_fullscreen_set(_gui->win, EINA_TRUE); + elm_win_title_set(_gui->win, PACKAGE); + for(j = 0; j < i; ++j) + { + Evas_Object *o, *ol; + screen = calloc(1, sizeof(Entrance_Screen)); + if (!screen) return 1; + + /* layout */ + o = entrance_gui_theme_get(_gui->win, "entrance/wallpaper/default"); + screen->transition = o; + ol = entrance_gui_theme_get(_gui->win, "entrance"); + screen->edj = ol; + if (!ol) + { + PT("Tut Tut Tut no theme"); + fprintf(stderr, "%s\n", "entrance"); + return j; + } + elm_object_part_content_set(o, "entrance.login", ol); + o = entrance_login_add(ol); + entrance_login_open_session_set(o, EINA_TRUE); + screen->login = o; + elm_object_part_content_set(ol, "entrance.login", o); + evas_object_smart_callback_add( + ENTRANCE_GUI_GET(ol, "entrance.conf"), + "clicked", + _entrance_gui_conf_clicked_cb, + screen->transition); + evas_object_show(screen->transition); + evas_object_show(screen->edj); + evas_object_show(screen->login); + + _gui->screens = eina_list_append(_gui->screens, screen); + ecore_x_xinerama_screen_geometry_get(j, &x, &y, &w, &h); + evas_object_move(screen->transition, x, y); + evas_object_resize(screen->transition, w, h); + if ((x + w) > ww) ww = x + w; + if ((y + h) > hh) hh = y + h; + } + _entrance_gui_update(); + _gui->handlers = + eina_list_append(_gui->handlers, + ecore_event_handler_add( + ECORE_X_EVENT_WINDOW_PROPERTY, + _entrance_gui_cb_window_property, + NULL)); + xw = elm_win_xwindow_get(_gui->win); + ecore_x_window_move(xw, 0, 0); + evas_object_resize(_gui->win, ww, hh); + evas_object_show(_gui->win); + { + /* tricky situation. we are not normally running with a wm and thus + * have to set focus to our window so things work right */ + screen = _gui->screens->data; + ecore_evas_focus_set + (ecore_evas_ecore_evas_get(evas_object_evas_get(_gui->win)), 1); + /* need to hide and show the cursor */ + ecore_x_window_cursor_show(elm_win_xwindow_get(_gui->win), + EINA_FALSE); + ecore_x_window_cursor_show(elm_win_xwindow_get(_gui->win), + EINA_TRUE); + } + return j; +} + +void +entrance_gui_shutdown() +{ + Entrance_Screen *screen; + Entrance_Xsession *xsession; + Ecore_Event_Handler *h; + PT("Gui shutdown\n"); + evas_object_del(_gui->win); + EINA_LIST_FREE(_gui->screens, screen) + { + free(screen); + } + eina_stringshare_del(_gui->theme); + EINA_LIST_FREE(_gui->xsessions, xsession) + { + eina_stringshare_del(xsession->name); + eina_stringshare_del(xsession->command); + eina_stringshare_del(xsession->icon); + } + EINA_LIST_FREE(_gui->handlers, h) + ecore_event_handler_del(h); + if (_gui) free(_gui); +} + +Evas_Object * +entrance_gui_theme_get (Evas_Object *win, const char *group) +{ + Evas_Object *edje; edje = elm_layout_add(win); - if (theme) + if (_gui->theme) { char buf[PATH_MAX]; - snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR"/themes/%s.edj", theme); + snprintf(buf, sizeof(buf), + PACKAGE_DATA_DIR"/themes/%s.edj", _gui->theme); if (!elm_layout_file_set(edje, buf, group)) { - snprintf(buf, sizeof(buf), - "can't load %s theme fallback to default\n", theme); - PT(buf); + PT("Can't load %s theme fallback to default\n", _gui->theme); elm_layout_file_set(edje, PACKAGE_DATA_DIR"/themes/default.edj", group); } @@ -73,15 +212,220 @@ _entrance_gui_theme_get (Evas_Object *win, const char *group, const char *theme) return edje; } +Eina_List * +entrance_gui_stringlist_get(const char *str) +{ + Eina_List *list = NULL; + const char *s, *b; + if (!str) return NULL; + for (b = s = str; 1; s++) + { + if ((*s == ' ') || (!*s)) + { + char *t = malloc(s - b + 1); + if (t) + { + strncpy(t, b, s - b); + t[s - b] = 0; + list = eina_list_append(list, eina_stringshare_add(t)); + free(t); + } + b = s + 1; + } + if (!*s) break; + } + return list; +} + +void +entrance_gui_stringlist_free(Eina_List *list) +{ + const char *s; + EINA_LIST_FREE(list, s) + 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) +{ + if (!actions) return; + PT("Actions set\n"); + _gui->actions = actions; + _entrance_gui_actions_populate(); +} + +void +entrance_gui_auth_max_tries(void) +{ + /* + Evas_Object *o; + Eina_List *l; + Entrance_Screen *screen; + + EINA_LIST_FOREACH(_gui->screens, l, screen) + { + o = ENTRANCE_GUI_GET(screen->edj, "entrance.login"); + elm_entry_entry_set(o, ""); + elm_object_disabled_set(o, EINA_TRUE); + o = ENTRANCE_GUI_GET(screen->edj, "entrance.password"); + elm_entry_entry_set(o, ""); + elm_object_disabled_set(o, EINA_TRUE); + } + ecore_timer_add(5.0, _entrance_gui_auth_enable, NULL); + */ +} + +void +entrance_gui_users_set(Eina_List *users) +{ + Evas_Object *ol; + Entrance_Screen *screen; + Eina_List *l; + Entrance_Fill *ef; + + PT("Add users list\n"); + ef = entrance_fill_new("default", + _entrance_gui_user_text_get, + _entrance_gui_user_content_get, + _entrance_gui_user_state_get, + _entrance_gui_user_del); + EINA_LIST_FOREACH(_gui->screens, l, screen) + { + 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), + "entrance,users,enabled", ""); + } + _gui->users = users; +} + +const Eina_List * +entrance_gui_users_get(void) +{ + return _gui->users; +} + +void +entrance_gui_xsessions_set(Eina_List *xsessions) +{ + Entrance_Screen *screen; + Eina_List *l; + + EINA_LIST_FOREACH(_gui->screens, l, screen) + { + entrance_login_xsessions_populate(screen->login, xsessions); + } + _gui->xsessions = xsessions; +} + +const Eina_List * +entrance_gui_xsessions_get(void) +{ + return _gui->xsessions; +} + +void +entrance_gui_conf_set(const Entrance_Conf_Gui_Event *conf) +{ + if ((conf->bg.path) && (*conf->bg.path) + && (_gui->bg.path != conf->bg.path)) + { + eina_stringshare_replace(&_gui->bg.path, conf->bg.path); + _gui->changed &= ENTRANCE_CONF_WALLPAPER; + } + if ((conf->bg.group) && (*conf->bg.group) + && (_gui->bg.group != conf->bg.group)) + { + eina_stringshare_replace(&_gui->bg.group, conf->bg.group); + _gui->changed &= ENTRANCE_CONF_WALLPAPER; + } + + if (_gui->vkbd_enabled != conf->vkbd_enabled) + { + _gui->vkbd_enabled = conf->vkbd_enabled; + _gui->changed &= ENTRANCE_CONF_VKBD; + } + + _gui->changed = ~(ENTRANCE_CONF_NONE); + _entrance_gui_update(); +} + +const char * +entrance_gui_theme_name_get(void) +{ + return _gui->theme; +} + +const char * +entrance_gui_theme_path_get(void) +{ + char buf[PATH_MAX]; + snprintf(buf, sizeof(buf), + PACKAGE_DATA_DIR"/themes/%s.edj", _gui->theme); + return eina_stringshare_add(buf); +} + +void +entrance_gui_background_get(const char **path, const char **group) +{ + if (path) + *path = _gui->bg.path; + if (group) + *group = _gui->bg.group; +} + +Eina_Bool +entrance_gui_vkbd_enabled_get(void) +{ + return _gui->vkbd_enabled; +} +/* static void -_entrance_gui_hostname_activated_cb(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) +_entrance_gui_login_activated_cb(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) { char *txt; Eina_List *l, *ll; Entrance_Xsession *xsess; - Entrance_User *eu = NULL; + Entrance_User_Event *eu = NULL; Entrance_Screen *screen; + PT("login activated\n"); txt = elm_entry_markup_to_utf8(elm_entry_entry_get(obj)); if (!txt || !strcmp(txt, "")) { @@ -108,7 +452,7 @@ _entrance_gui_hostname_activated_cb(void *data __UNUSED__, Evas_Object *obj, voi elm_object_focus_set(data, EINA_TRUE); EINA_LIST_FOREACH(_gui->screens, l, screen) edje_object_signal_emit(elm_layout_edje_get(screen->edj), - "entrance.auth.enable", ""); + "entrance,auth,enable", ""); } static void @@ -118,22 +462,6 @@ _entrance_gui_shutdown(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void PT("shutdown cb\n"); } -static Eina_Bool -_entrance_gui_cb_window_property(void *data, int type __UNUSED__, void *event_info) -{ - Entrance_Screen *screen; - Ecore_X_Event_Window_Property *ev; - Eina_List *l; - ev = event_info; - screen = data; - if (ev->atom == ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK) - screen->managed = EINA_TRUE; - EINA_LIST_FOREACH(_gui->screens, l, screen) - if (!screen->managed) - return ECORE_CALLBACK_PASS_ON; - elm_exit(); - return ECORE_CALLBACK_PASS_ON; -} static void _entrance_gui_focus(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) @@ -142,7 +470,8 @@ _entrance_gui_focus(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *ev Entrance_Screen *screen; EINA_LIST_FOREACH(_gui->screens, l, screen) - elm_object_focus_set(ENTRANCE_GUI_GET(screen->edj, "hostname"), EINA_TRUE); + elm_object_focus_set(ENTRANCE_GUI_GET(screen->edj, "entrance.login"), + EINA_TRUE); } static void @@ -154,13 +483,13 @@ _entrance_gui_login_cancel_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__ EINA_LIST_FOREACH(_gui->screens, l, screen) { - o = ENTRANCE_GUI_GET(screen->edj, "hostname"); + o = ENTRANCE_GUI_GET(screen->edj, "entrance.login"); elm_entry_entry_set(o, ""); elm_object_focus_set(o, EINA_TRUE); - o = ENTRANCE_GUI_GET(screen->edj, "password"); + 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.disable", ""); + "entrance,auth,disable", ""); } } @@ -228,9 +557,9 @@ _entrance_gui_login(Entrance_Screen *screen) free(s); EINA_LIST_FOREACH(_gui->screens, l, screen) { - elm_object_focus_set(ENTRANCE_GUI_GET(screen->edj, "password"), EINA_TRUE); + elm_object_focus_set(ENTRANCE_GUI_GET(screen->edj, "entrance.password"), EINA_TRUE); edje_object_signal_emit(elm_layout_edje_get(screen->edj), - "entrance.auth.enable", ""); + "entrance,auth,enable", ""); } } @@ -243,6 +572,7 @@ _entrance_gui_login_request_cb(void *data, Evas_Object *obj __UNUSED__, const ch static void _entrance_gui_password_activated_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { + PT("password activated\n"); _entrance_gui_login(data); } @@ -264,13 +594,6 @@ _entrance_gui_xsessions_clicked_cb(void *data, Evas_Object *obj, void *event_inf } } -static void -_entrance_gui_action_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - Entrance_Action *ea; - ea = data; - if (ea) entrance_connect_action_send(ea->id); -} @@ -286,12 +609,8 @@ _entrance_gui_callback_add(Entrance_Screen *screen) _entrance_gui_focus, NULL); edj = elm_layout_edje_get(screen->edj); - host = ENTRANCE_GUI_GET(screen->edj, "hostname"); - pwd = ENTRANCE_GUI_GET(screen->edj, "password"); - evas_object_smart_callback_add(host, "activated", - _entrance_gui_hostname_activated_cb, pwd); - evas_object_smart_callback_add(pwd, "activated", - _entrance_gui_password_activated_cb, screen); + host = ENTRANCE_GUI_GET(screen->edj, "entrance.login"); + pwd = ENTRANCE_GUI_GET(screen->edj, "entrance.password"); edje_object_signal_callback_add(edj, "entrance.auth.cancel", "", _entrance_gui_login_cancel_cb, NULL); edje_object_signal_callback_add(edj, "entrance.auth.request", "", @@ -311,7 +630,7 @@ _entrance_gui_session_update(Entrance_Xsession *xsession) _gui->selected_session = xsession; EINA_LIST_FOREACH(_gui->screens, l, screen) { - o = ENTRANCE_GUI_GET(screen->edj, "xsessions"); + o = ENTRANCE_GUI_GET(screen->edj, "entrance.xsessions"); elm_object_text_set(o, _gui->selected_session->name); icon = elm_icon_add(screen->win); elm_image_file_set(icon, _gui->selected_session->icon, NULL); @@ -330,7 +649,7 @@ _entrance_gui_sessions_populate() EINA_LIST_FOREACH(_gui->screens, ll, screen) { - o = ENTRANCE_GUI_GET(screen->edj, "xsessions"); + o = ENTRANCE_GUI_GET(screen->edj, "entrance.xsessions"); EINA_LIST_FOREACH(_gui->xsessions, l, xsession) { @@ -339,7 +658,7 @@ _entrance_gui_sessions_populate() _entrance_gui_xsessions_clicked_cb, xsession); } edje_object_signal_emit(elm_layout_edje_get(screen->edj), - "entrance.xsession.enabled", ""); + "entrance,xsession,enabled", ""); } if (_gui->xsessions) _entrance_gui_session_update(_gui->xsessions->data); @@ -354,268 +673,121 @@ _entrance_gui_auth_enable(void *data __UNUSED__) EINA_LIST_FOREACH(_gui->screens, l, screen) { - o = ENTRANCE_GUI_GET(screen->edj, "hostname"); + o = ENTRANCE_GUI_GET(screen->edj, "entrance.login"); elm_object_disabled_set(o, EINA_FALSE); - o = ENTRANCE_GUI_GET(screen->edj, "password"); + o = ENTRANCE_GUI_GET(screen->edj, "entrance.password"); elm_object_disabled_set(o, EINA_FALSE); } return ECORE_CALLBACK_CANCEL; } - -void -entrance_gui_xsession_set(Eina_List *xsessions) +*/ +static void +_entrance_gui_update(void) { - if (!xsessions) return; - _gui->xsessions = xsessions; - _entrance_gui_sessions_populate(); -} - -void -entrance_gui_actions_set(Eina_List *actions) -{ - if (!actions) return; - PT("Action set\n"); - _gui->actions = actions; - _entrance_gui_actions_populate(); -} - -int -entrance_gui_init(const char *theme) -{ - - Ecore_X_Window xw; + Eina_List *l; Entrance_Screen *screen; - int ii, i; - int x, y, w, h; - PT("Gui init\n"); - _gui = calloc(1, sizeof(Entrance_Gui)); - if (!_gui) + EINA_LIST_FOREACH(_gui->screens, l, screen) { - PT("Not Enough memory\n"); - return 1; - } - -#ifdef XNEST_DEBUG - char *tmp = getenv("DISPLAY"); - if (tmp && *tmp) - { - PT("client Using display name"); - fprintf(stderr, " %s\n", tmp); - } -#endif - - - i = ecore_x_xinerama_screen_count_get(); - if (i < 1) i = 1; - for(ii = 0; ii < i; ++ii) - { - screen = calloc(1, sizeof(Entrance_Screen)); - if (!screen) return 1; - - _gui->screens = eina_list_append(_gui->screens, screen); - ecore_x_xinerama_screen_geometry_get(ii, &x, &y, &w, &h); - screen->win = elm_win_add(NULL, "main", ELM_WIN_BASIC); - elm_win_fullscreen_set(screen->win, EINA_TRUE); - elm_win_title_set(screen->win, PACKAGE); - - _gui->theme = eina_stringshare_add(theme); - screen->edj = _entrance_gui_theme_get(screen->win, "entrance", theme); - - if (!screen->edj) + Evas_Object *bg = NULL; + if (_gui->changed & ENTRANCE_CONF_WALLPAPER) { - PT("Tut Tut Tut no theme\n"); - return 2; + PT("Set background %s - %s\n", _gui->bg.path, _gui->bg.group); + if (_gui->bg.path) + { + if (_gui->bg.group) + { + bg = elm_layout_add(screen->transition); + elm_layout_file_set(bg, _gui->bg.path, _gui->bg.group); + } + else + { + bg = elm_layout_add(screen->transition); + elm_layout_file_set(bg, _gui->bg.path, + "entrance/background/default"); + } + } + if (!bg) + { + 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"); + } + elm_object_part_content_set(screen->transition, + "entrance.wallpaper.default", bg); + evas_object_del(screen->background); + screen->background = bg; } - evas_object_size_hint_weight_set(screen->edj, - EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - elm_win_resize_object_add(screen->win, screen->edj); - _entrance_gui_callback_add(screen); - evas_object_show(screen->edj); - - xw = elm_win_xwindow_get(screen->win); - evas_object_resize(screen->win, w, h); - ecore_x_window_move(xw, x, y); - evas_object_show(screen->win); - _gui->handlers = - eina_list_append(_gui->handlers, - ecore_event_handler_add( - ECORE_X_EVENT_WINDOW_PROPERTY, - _entrance_gui_cb_window_property, - screen)); + if (_gui->conf_enabled) + { + elm_object_signal_emit(screen->edj, + "entrance,custom_config.enabled", ""); + } + else + elm_object_signal_emit(screen->edj, + "entrance,custom_config.disabled", ""); } - if (_gui->screens) - { - /* tricky situation. we are not normally running with a wm and thus - * have to set focus to our window so things work right */ - screen = _gui->screens->data; - ecore_evas_focus_set - (ecore_evas_ecore_evas_get(evas_object_evas_get(screen->win)), 1); - } - return 0; + _gui->changed = 0; } -void -entrance_gui_shutdown() +static void +_entrance_gui_conf_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) { - Entrance_Xsession *xsession; - Entrance_Screen *screen; - Ecore_Event_Handler *h; - PT("Gui shutdown\n"); - EINA_LIST_FREE(_gui->screens, screen) - { - evas_object_del(screen->win); - free(screen); - } - eina_stringshare_del(_gui->theme); - EINA_LIST_FREE(_gui->xsessions, xsession) - { - eina_stringshare_del(xsession->name); - eina_stringshare_del(xsession->command); - if (xsession->icon) eina_stringshare_del(xsession->icon); - } - EINA_LIST_FREE(_gui->handlers, h) - ecore_event_handler_del(h); - if (_gui) free(_gui); + entrance_conf_begin(data, _gui->win); } - -char * -entrance_gui_user_get(Entrance_Screen *screen) -{ - Evas_Object *o; - o = ENTRANCE_GUI_GET(screen->edj, "hostname"); - if (o) return elm_entry_markup_to_utf8(elm_entry_entry_get(o)); - return NULL; -} - -char * -entrance_gui_password_get(Entrance_Screen *screen) -{ - Evas_Object *o; - o = ENTRANCE_GUI_GET(screen->edj, "password"); - if (o) return elm_entry_markup_to_utf8(elm_entry_entry_get(o)); - return NULL; -} - -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, "password"); - elm_entry_entry_set(o, ""); - edje_object_signal_emit(elm_layout_edje_get(screen->edj), - "entrance.auth.error", ""); - } -} - -void -entrance_gui_auth_wait() -{ - Evas_Object *o; - Eina_List *l; - Entrance_Screen *screen; - - EINA_LIST_FOREACH(_gui->screens, l, screen) - { - o = ENTRANCE_GUI_GET(screen->edj, "hostname"); - elm_entry_entry_set(o, ""); - elm_object_disabled_set(o, EINA_TRUE); - o = ENTRANCE_GUI_GET(screen->edj, "password"); - elm_entry_entry_set(o, ""); - elm_object_disabled_set(o, EINA_TRUE); - } - ecore_timer_add(5.0, _entrance_gui_auth_enable, NULL); -} - -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); -} - /////////////////////////////////////////////////// ///////////////// USER //////////////////////////// /////////////////////////////////////////////////// -void -entrance_gui_users_set(Eina_List *users) -{ - Evas_Object *ol; - Entrance_Screen *screen; - Eina_List *l; - EINA_LIST_FOREACH(_gui->screens, l, screen) + +static Evas_Object * +_entrance_gui_user_icon_random_get(Evas_Object *obj) +{ + Evas_Object *ic, *o, *r; + Eina_List *icons; + unsigned char i; + const char *icon; + char buf[PATH_MAX]; + + ic = entrance_gui_theme_get(obj, "entrance/user"); + if (!ic) return NULL; + o = elm_layout_edje_get(ic); + if (!o) return NULL; + icons = entrance_gui_stringlist_get(edje_object_data_get(o, "items")); + if (icons) { - Entrance_Fill *ef; - ol = ENTRANCE_GUI_GET(screen->edj, "entrance_users"); - ef = entrance_fill_new("default", - _entrance_gui_user_text_get, - _entrance_gui_user_content_get, - _entrance_gui_user_state_get, - _entrance_gui_user_del); - entrance_fill(ol, ef, users, _entrance_gui_user_sel_cb); - edje_object_signal_emit(elm_layout_edje_get(screen->edj), - "entrance.users.enabled", ""); - _gui->users = users; + srand(time(NULL)); + i = (unsigned char) ((eina_list_count(icons) * (double)rand()) + / (RAND_MAX + 1.0)); + icon = eina_list_nth(icons, i); + snprintf(buf, sizeof(buf), + "entrance/user/%s", icon); + entrance_gui_stringlist_free(icons); + r = entrance_gui_theme_get(obj, buf); + elm_object_part_content_set(ic, "entrance.icon", r); + evas_object_show(r); } + + return ic; } static void -_entrance_gui_user_sel(Entrance_User *eu) +_entrance_gui_user_sel_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info) { - Evas_Object *o; - Entrance_Xsession *xsess; - Eina_List *l; - Entrance_Screen *screen; - - EINA_LIST_FOREACH(_gui->screens, l, screen) - { - o = ENTRANCE_GUI_GET(screen->edj, "hostname"); - elm_entry_entry_set(o, eu->login); - elm_object_focus_set(ENTRANCE_GUI_GET(screen->edj, "password"), EINA_TRUE); - edje_object_signal_emit(elm_layout_edje_get(screen->edj), - "entrance.auth.enable", ""); - } - if (eu->lsess) - { - EINA_LIST_FOREACH(_gui->xsessions, l, xsess) - { - if (!strcmp(xsess->name, eu->lsess)) - { - _entrance_gui_session_update(xsess); - break; - } - } - } - else if (_gui->xsessions) - _entrance_gui_session_update(_gui->xsessions->data); -} - -static void -_entrance_gui_user_sel_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - _entrance_gui_user_sel(data); + Entrance_User_Event *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_User *eu; + Entrance_User_Event *eu; eu = data; return strdup(eu->login); } @@ -624,20 +796,33 @@ static Evas_Object * _entrance_gui_user_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part) { Evas_Object *ic = NULL; - Entrance_User *eu; + Entrance_User_Event *eu; eu = data; if (eu && !strcmp(part, "elm.swallow.icon")) { - if (eu->image) + if ((eu->image.path) && (*eu->image.path == '/') && (!eu->image.group)) { ic = elm_icon_add(obj); - elm_image_file_set(ic, eu->image, "entrance/user/icon"); + elm_image_file_set(ic, eu->image.path, "entrance/user/icon"); + eu->image.group = eina_stringshare_add("entrance/user/icon"); + } else { - ic = _entrance_gui_theme_get(obj, "entrance/user/default", - _gui->theme); + if (eu->image.group) + { + ic = elm_icon_add(obj); + elm_image_file_set(ic, eu->image.path, eu->image.group); + } + else + { + const char *path, *group; + ic = _entrance_gui_user_icon_random_get(obj); + edje_object_file_get(elm_layout_edje_get(ic), &path, &group); + eu->image.path = eina_stringshare_add(path); + eu->image.group = eina_stringshare_add(group); + } } evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(ic); @@ -668,6 +853,14 @@ _entrance_gui_action_text_get(void *data, Evas_Object *obj __UNUSED__, const cha return strdup(ea->label); } +static void +_entrance_gui_action_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Entrance_Action *ea; + ea = data; + if (ea) entrance_connect_action_send(ea->id); +} + static void _entrance_gui_actions_populate() { @@ -680,10 +873,28 @@ _entrance_gui_actions_populate() Entrance_Fill *ef; ef = entrance_fill_new(NULL, _entrance_gui_action_text_get, NULL, NULL, NULL); - o = ENTRANCE_GUI_GET(screen->edj, "actions"); - entrance_fill(o, ef, _gui->actions, _entrance_gui_action_clicked_cb); + o = ENTRANCE_GUI_GET(screen->edj, "entrance.actions"); + entrance_fill(o, ef, _gui->actions, + _entrance_gui_action_clicked_cb, screen); edje_object_signal_emit(elm_layout_edje_get(screen->edj), - "entrance.action.enabled", ""); + "entrance,action,enabled", ""); } } +//////////////////////////////////////////////////////////////////////////////// + +static Eina_Bool +_entrance_gui_cb_window_property(void *data EINA_UNUSED, int type EINA_UNUSED, void *event_info) +{ + Ecore_X_Event_Window_Property *ev; + + ev = event_info; + if (ev->atom == ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK) + { + PT("screen managed\n"); + elm_exit(); + } + return ECORE_CALLBACK_DONE; +} + + diff --git a/src/bin/entrance_gui.h b/src/bin/entrance_gui.h index f4e5d6a..8631bbc 100644 --- a/src/bin/entrance_gui.h +++ b/src/bin/entrance_gui.h @@ -1,17 +1,33 @@ #ifndef ENTRANCE_GUI_H_ #define ENTRANCE_GUI_H_ +#define ENTRANCE_GUI_GET(edj, name) edje_object_part_external_object_get(elm_layout_edje_get(edj), name) + int entrance_gui_init(const char *theme); -void entrance_gui_run(); -void entrance_gui_shutdown(); +void entrance_gui_shutdown(void); +void entrance_gui_run(void); +Evas_Object *entrance_gui_theme_get (Evas_Object *win, const char *group); +void entrance_gui_auth_valid(void); +void entrance_gui_auth_error(void); +void entrance_gui_auth_max_tries(void); +void entrance_gui_xsession_set(Eina_List *xsessions); +void entrance_gui_actions_set(Eina_List *actions); +void entrance_gui_users_set(Eina_List *users); +const Eina_List *entrance_gui_users_get(void); +void entrance_gui_xsessions_set(Eina_List *users); +const Eina_List *entrance_gui_xsessions_get(void); +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_background_get(const char **path, const char **group); +Eina_Bool entrance_gui_vkbd_enabled_get(void); +const char *entrance_gui_theme_path_get(void); + +/* char *entrance_gui_user_get(); char *entrance_gui_password_get(); -void entrance_gui_auth_error(); -void entrance_gui_auth_valid(); -void entrance_gui_auth_wait(); char *entrance_gui_login_command_get(); -void entrance_gui_xsession_set(Eina_List *xsessions); -void entrance_gui_users_set(Eina_List *users); -void entrance_gui_actions_set(Eina_List *actions); +*/ #endif /* ENTRANCE_GUI_H_ */ diff --git a/src/bin/entrance_login.c b/src/bin/entrance_login.c new file mode 100644 index 0000000..5ca8fe3 --- /dev/null +++ b/src/bin/entrance_login.c @@ -0,0 +1,407 @@ +#include "entrance_client.h" + +#define ENTRANCE_PASSWD_LEN 256 + +typedef struct Entrance_Login_ Entrance_Login; + +static void _login_reset(Evas_Object *widget); +static void _login_backspace(Evas_Object *widget); +static void _login_delete(Evas_Object *widget); +static void _login_select(Evas_Object *widget); +static void _login_update(Evas_Object *widget); +static void _login_check_auth(Evas_Object *widget); +static void _login_password_catch(Evas_Object *widget, Eina_Bool catch); +static Eina_Bool _login_key_down_cb(void *data, int type, void *event); +static void _login_xsession_update(Evas_Object *obj); +static void _login_xsession_clicked_cb(void *data, Evas_Object *obj, void *event_info); +static Eina_Bool _login_input_event_cb(void *data EINA_UNUSED, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info); +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 Entrance_Fill *_login_fill; + +struct Entrance_Login_ +{ + Ecore_Event_Handler *handler; + char passwd[ENTRANCE_PASSWD_LEN]; + Entrance_Xsession *session; + Eina_Bool open_session : 1; + Eina_Bool selected : 1; + Eina_Bool catch : 1; +}; + +#define LOGIN_GET(widget) \ + Entrance_Login *login; \ + login = evas_object_data_get(widget, "entrance"); \ + if (!login) return + +static void +_login_reset(Evas_Object *widget) +{ + LOGIN_GET(widget); + memset(login->passwd, 0, sizeof(char) * ENTRANCE_PASSWD_LEN); + _login_update(widget); +} + +static void +_login_backspace(Evas_Object *widget) +{ + int len, val, pos; + + LOGIN_GET(widget); + len = strlen(login->passwd); + if (len > 0) + { + pos = evas_string_char_prev_get(login->passwd, len, &val); + if ((pos < len) && (pos >= 0)) + { + login->passwd[pos] = '\0'; + _login_update(widget); + } + } +} + +static void +_login_delete(Evas_Object *widget) +{ + _login_backspace(widget); +} + +static void +_login_select(Evas_Object *widget) +{ + LOGIN_GET(widget); + Evas_Object *o; + o = elm_object_part_content_get(widget, "entrance.password"); + elm_entry_select_all(o); + login->selected = EINA_TRUE; +} + +static void +_login_unselect(Evas_Object *widget) +{ + Evas_Object *o; + LOGIN_GET(widget); + o = elm_object_part_content_get(widget, "entrance.password"); + elm_entry_select_none(o); + login->selected = EINA_FALSE; +} + +static void +_login_update(Evas_Object *widget) +{ + Evas_Object *o; + char str[ENTRANCE_PASSWD_LEN]; + int len; + LOGIN_GET(widget); + + len = eina_unicode_utf8_get_len(login->passwd); + + memset(str, '*', sizeof(char) * len); + str[len] = '\0'; + + o = elm_object_part_content_get(widget, "entrance.password"); + elm_object_text_set(o, str); + elm_entry_cursor_end_set(o); +} + +static void +_login_check_auth(Evas_Object *widget) +{ + Evas_Object *o; + const char *host; + LOGIN_GET(widget); + + o = elm_object_part_content_get(widget, "entrance.login"); + host = elm_entry_markup_to_utf8(elm_object_text_get(o)); + if (login->session) + entrance_connect_auth_send(host, login->passwd, + login->session->name, + login->open_session); + else + entrance_connect_auth_send(host, login->passwd, + NULL, login->open_session); + + _login_reset(widget); +} + +static void +_login_password_catch(Evas_Object *widget, Eina_Bool catch) +{ + LOGIN_GET(widget); + if (login->catch != catch) + { + if (catch) + { + login->handler = ecore_event_handler_add( + ECORE_EVENT_KEY_DOWN, _login_key_down_cb, widget); + } + else + { + ecore_event_handler_del(login->handler); + login->handler = NULL; + } + } + login->catch = catch; +} + +static Eina_Bool +_login_key_down_cb(void *data, int type EINA_UNUSED, void *event) +{ + Ecore_Event_Key *ev; + LOGIN_GET(data) ECORE_CALLBACK_PASS_ON; + ev = event; + + if (!strcmp(ev->key, "KP_Enter")) + { + _login_check_auth(data); + } + else if (!strcmp(ev->key, "Return")) + { + _login_check_auth(data); + } + else if (!strcmp(ev->key, "BackSpace")) + { + if (login->selected) + { + _login_reset(data); + _login_unselect(data); + } + else + _login_backspace(data); + } + else if (!strcmp(ev->key, "Delete")) + { + if (login->selected) + { + _login_reset(data); + } + else + _login_delete(data); + } + else if (!strcmp(ev->key, "Tab")) + { + if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT) + elm_object_focus_next(data, ELM_FOCUS_PREVIOUS); + else + elm_object_focus_next(data, ELM_FOCUS_NEXT); + } + else if ((!strcmp(ev->key, "u")) + && (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL)) + { + _login_reset(data); + } + else if ((!strcmp(ev->key, "a")) + && (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL)) + { + _login_select(data); + } + else + { + if (ev->compose) + { + if (login->selected) + { + _login_reset(data); + _login_unselect(data); + } + if (strlen(login->passwd) < + (ENTRANCE_PASSWD_LEN - strlen(ev->compose))) + { + strcat(login->passwd, ev->compose); + _login_update(data); + } + } + } + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_login_input_event_cb(void *data, Evas_Object *obj EINA_UNUSED, Evas_Object *src EINA_UNUSED, Evas_Callback_Type type, void *event_info EINA_UNUSED) +{ + LOGIN_GET(data) EINA_FALSE; + return (login->catch + && ((type == EVAS_CALLBACK_KEY_UP) + || (type == EVAS_CALLBACK_KEY_DOWN))); +} + +static void +_login_password_focused_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) +{ + _login_password_catch(data, EINA_TRUE); +} + +static void +_login_password_unfocused_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) +{ + _login_password_catch(data, EINA_FALSE); +} +static void +_login_login_activated_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) +{ + elm_object_focus_set(data, EINA_TRUE); + edje_object_signal_emit(data, + "entrance,auth,enable", ""); +} + +static char * +_login_xsession_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part) +{ + Entrance_Xsession *xsession; + xsession = data; + if ((part) && (!strcmp(part, "icon"))) + { + if (xsession->icon) + return strdup(xsession->icon); + else + return NULL; + } + return strdup(xsession->name); + +} + +static void +_login_xsession_update(Evas_Object *obj) +{ + Evas_Object *o, *icon; + LOGIN_GET(obj); + o = elm_object_part_content_get(obj, "entrance.xsessions"); + if (!login->session) return; + icon = elm_icon_add(o); + elm_object_text_set(o, login->session->name); + elm_image_file_set(o, login->session->icon, NULL); + elm_object_content_set(o, icon); +} + +static void +_login_xsession_clicked_cb(void *data, Evas_Object *obj, void *event_info) +{ + LOGIN_GET(data); + login->session = elm_object_item_data_get(event_info); + _login_xsession_update(data); +} + +//////////////////////////////////////////////////////////////////////////////// + +void +entrance_login_init(void) +{ + _login_fill = entrance_fill_new(NULL, _login_xsession_text_get, + NULL, NULL, NULL); +} + +void +entrance_login_shutdown(void) +{ + // TODO callback_del on widget + //_login_password_catch(NULL, EINA_FALSE); + //free(_login); + entrance_fill_del(_login_fill); +} + +Evas_Object * +entrance_login_add(Evas_Object *obj) +{ + Evas_Object *o, *h, *p; + Entrance_Login *login; + + /* layout */ + o = entrance_gui_theme_get(obj, "entrance/login"); + login = calloc(1, sizeof(Entrance_Login)); + evas_object_data_set(o, "entrance", login); + + + /* login */ + h = elm_entry_add(o); + elm_entry_single_line_set(h, EINA_TRUE); + elm_entry_scrollable_set(h, EINA_TRUE); + elm_object_part_content_set(o, "entrance.login", h); + elm_object_focus_set(h, EINA_TRUE); + evas_object_show(h); + + /* password */ + p = elm_entry_add(o); + elm_entry_single_line_set(p, EINA_TRUE); + elm_entry_scrollable_set(p, EINA_TRUE); + elm_object_part_content_set(o, "entrance.password", p); + evas_object_show(p); + + /* callbacks */ + elm_object_event_callback_add(o, _login_input_event_cb, o); + evas_object_smart_callback_add(h, "activated", + _login_login_activated_cb, p); + evas_object_smart_callback_add(p, "focused", + _login_password_focused_cb, o); + evas_object_smart_callback_add(p, "unfocused", + _login_password_unfocused_cb, o); + h = elm_hoversel_add(o); + elm_hoversel_hover_parent_set(h, obj); + evas_object_data_set(o, "entrance", login); + elm_object_part_content_set(o, "entrance.xsessions", h); + _login_xsession_update(o); + return o; +} + +void +entrance_login_xsessions_populate(Evas_Object *widget, Eina_List *xsessions) +{ + PT("Session set\n"); + Evas_Object *o; + LOGIN_GET(widget); + + o = elm_object_part_content_get(widget, "entrance.xsessions"); + entrance_fill(o, _login_fill, xsessions, + _login_xsession_clicked_cb, widget); + login->session = eina_list_data_get(xsessions); + _login_xsession_update(widget); + edje_object_signal_emit(widget, + "entrance,xsession,enabled", ""); +} + +void +entrance_login_login_set(Evas_Object *widget, const char *user) +{ + Evas_Object *o; + o = elm_object_part_content_get(widget, "entrance.login"); + elm_object_text_set(o, user); + elm_object_signal_emit(widget, + "entrance,auth,enable", ""); + o = elm_object_part_content_get(widget, "entrance.password"); + elm_object_focus_set(o, EINA_TRUE); +} + +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) + { + EINA_LIST_FOREACH(entrance_gui_xsessions_get(), l, sess) + { + if ((sess->name) && + (!strcmp(sess->name, name))) + { + break; + } + } + } + if (l) + login->session = sess; + o = elm_object_part_content_get(widget, "entrance.xsessions"); + _login_xsession_update(widget); +} + +void +entrance_login_open_session_set(Evas_Object *widget, Eina_Bool open_session) +{ + LOGIN_GET(widget); + open_session = !!open_session; + if (login->open_session != open_session) + login->open_session = open_session; +} + diff --git a/src/bin/entrance_login.h b/src/bin/entrance_login.h new file mode 100644 index 0000000..9fca437 --- /dev/null +++ b/src/bin/entrance_login.h @@ -0,0 +1,15 @@ +#ifndef ENTRANCE_LOGIN_H +#define ENTRANCE_LOGIN_H + +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); +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); +void entrance_login_open_session_set(Evas_Object *obj, Eina_Bool open_session); +void entrance_login_callback_set(Entrance_Login_Cb greater_cb, void *data); + +#endif diff --git a/src/bin/entrance_vkbd.c b/src/bin/entrance_vkbd.c new file mode 100644 index 0000000..6fa284c --- /dev/null +++ b/src/bin/entrance_vkbd.c @@ -0,0 +1,16 @@ +#include "entrance_client.h" + +void +entrance_vkbd_init(void) +{ + ekbd_init(); + + +} + +void +entrance_vkbd_shutdown(void) +{ + ekbd_shutdown(); + +} diff --git a/src/daemon/entrance.c b/src/daemon/entrance.c index c4a3628..52cd74c 100644 --- a/src/daemon/entrance.c +++ b/src/daemon/entrance.c @@ -6,12 +6,13 @@ #include #define ENTRANCE_DISPLAY ":0.0" +#define ENTRANCE_XEPHYR ":1.0" time_t current_time; struct tm *local_time; char entrance_time_d[4096]; static Eina_Bool _open_log(); -static int _entrance_main(const char *dname); +static Eina_Bool _entrance_main(const char *dname); static void _remove_lock(); static void _signal_cb(int sig); static void _signal_log(int sig); @@ -26,16 +27,12 @@ static Ecore_Exe *_entrance_client = NULL; static void _signal_cb(int sig) { - char buf[1024]; - snprintf(buf, sizeof(buf), "signal %d received\n", sig); - PT(buf); + PT("signal %d received\n", sig); //FIXME if I don't have main loop at this time ? - if (_entrance_client) ecore_exe_terminate(_entrance_client); - /* - entrance_session_shutdown(); - entrance_xserver_shutdown(); - exit(1); - */ + if (_entrance_client) + ecore_exe_terminate(_entrance_client); + else + ecore_main_loop_quit(); } static void @@ -145,9 +142,10 @@ _entrance_wait() _exit(1); } -static int +static Eina_Bool _entrance_main(const char *dname) { + PT("starting...\n"); if (!entrance_config->autologin) { if (!_entrance_client) @@ -155,16 +153,18 @@ _entrance_main(const char *dname) char buf[PATH_MAX]; ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _entrance_client_del, NULL); - PT("Exec entrance_client\n"); + PT("Exec entrance_client: "); snprintf(buf, sizeof(buf), PACKAGE_BIN_DIR"/entrance_client -d %s -t %s", dname, entrance_config->theme); + printf("%s\n", buf); + _entrance_client = ecore_exe_run(buf, NULL); } } else ecore_main_loop_quit(); - return 0; + return ECORE_CALLBACK_CANCEL; } static Eina_Bool @@ -175,9 +175,9 @@ _entrance_client_del(void *data __UNUSED__, int type __UNUSED__, void *event) ev = event; if (ev->exe != _entrance_client) return ECORE_CALLBACK_PASS_ON; + PT("client have terminated\n"); ecore_main_loop_quit(); _entrance_client = NULL; - PT("client have terminated\n"); return ECORE_CALLBACK_DONE; } @@ -208,8 +208,8 @@ int main (int argc, char ** argv) { int args; - int pid; - char *dname = strdup(ENTRANCE_DISPLAY); + int pid = -1; + char *dname; char *entrance_user = NULL; unsigned char nodaemon = 0; unsigned char quit_option = 0; @@ -238,15 +238,36 @@ main (int argc, char ** argv) if (getuid() != 0) { - fprintf(stderr, "Only root can run this program\n"); + fprintf(stderr, "Sorry, only root can run this program!\n"); return 1; } + if (!_xephyr && getenv("ENTRANCE_XEPHYR")) + _xephyr = EINA_TRUE; + + if (_xephyr) + { + _testing = EINA_TRUE; + dname = strdup(ENTRANCE_XEPHYR); + putenv(strdup("ENTRANCE_XEPHYR=1")); + } + else + dname = strdup(ENTRANCE_DISPLAY); + if (!_testing && getenv("ENTRANCE_TESTING")) + _testing = EINA_TRUE; if (_testing) - nodaemon = EINA_TRUE; + { + putenv(strdup("ENTRANCE_TESTING=1")); + nodaemon = EINA_TRUE; + } eet_init(); entrance_config_init(); + if (!entrance_config) + { + PT("No config loaded, sorry must quit ..."); + exit(1); + } if (!_testing && !_get_lock()) { exit(1); @@ -273,7 +294,7 @@ main (int argc, char ** argv) entrance_config_shutdown(); exit(1); } - if (!_open_log()) + if (!_testing && !_open_log()) { PT("Can't open log file !!!!\n"); entrance_config_shutdown(); @@ -297,7 +318,7 @@ main (int argc, char ** argv) unsetenv("ENTRANCE_QUIT"); _remove_lock(); entrance_config_shutdown(); - PT("Good bye\n"); + PT("Bye, see you.\n\n"); entrance_close_log(); exit(0); } @@ -320,9 +341,14 @@ main (int argc, char ** argv) signal(SIGUSR2, _signal_log); PT("session init\n"); - entrance_session_init(entrance_config->command.xauth_file); - PT("xserver init\n"); - pid = entrance_xserver_init(_entrance_main, dname); + entrance_session_init(dname); + if (!_xephyr) + { + PT("xserver init\n"); + pid = entrance_xserver_init(_entrance_main, dname); + } + else + _entrance_main(dname); PT("history init\n"); entrance_history_init(); if (entrance_config->autologin && !entrance_user) @@ -357,40 +383,46 @@ main (int argc, char ** argv) } entrance_history_shutdown(); PT("history shutdown\n"); - entrance_xserver_shutdown(); - PT("xserver shutdown\n"); + if (_xephyr) + { + //ecore_exe_terminate(xephyr); + PT("Xephyr shutdown\n"); + } + else + { + entrance_xserver_shutdown(); + PT("xserver shutdown\n"); + } #ifdef HAVE_PAM entrance_pam_shutdown(); PT("pam shutdown\n"); #endif efreet_shutdown(); - ecore_shutdown(); PT("ecore shutdown\n"); + ecore_shutdown(); + PT("session shutdown\n"); + entrance_session_shutdown(); + free(dname); if (entrance_session_logged_get()) { - entrance_config_shutdown(); - PT("config shutdown\n"); - entrance_session_shutdown(); - PT("session shutdown\n"); - eet_shutdown(); - PT("eet shutdown\n"); - free(dname); - PT("Bye user logged, see you.\n"); - entrance_close_log(); + PT("user logged, waiting...\n"); _entrance_wait(); + /* no more running here */ } _remove_lock(); - entrance_config_shutdown(); PT("config shutdown\n"); - entrance_session_shutdown(); - PT("session shutdown\n"); - eet_shutdown(); + entrance_config_shutdown(); PT("eet shutdown\n"); + eet_shutdown(); free(dname); - PT("ending xserver\n"); - kill(pid, SIGTERM); - entrance_xserver_end(); - PT("Bye, see you.\n\n"); + if (!_xephyr) + { + PT("ending xserver\n"); + kill(pid, SIGTERM); + entrance_xserver_end(); + } + else + PT("No session to wait, exiting\n"); entrance_close_log(); return 0; } diff --git a/src/daemon/entrance.h b/src/daemon/entrance.h index 9d48d16..193cd10 100644 --- a/src/daemon/entrance.h +++ b/src/daemon/entrance.h @@ -17,22 +17,22 @@ #ifdef HAVE_PAM #include "entrance_pam.h" #endif +#include "../event/entrance_event.h" #include "entrance_config.h" #include "entrance_xserver.h" #include "entrance_server.h" #include "entrance_history.h" #include "entrance_action.h" -#include "../event/entrance_event.h" -#define PT(x) \ -do \ -{ \ - current_time = time(NULL); \ - local_time = localtime(¤t_time); \ - memset(entrance_time_d, 0, sizeof(entrance_time_d)); \ - strftime(entrance_time_d, sizeof(entrance_time_d), \ - "%b %_2d %T", local_time); \ - fprintf(stderr, "(%s) "PACKAGE": %s", entrance_time_d, x); \ +#define PT(f, x...) \ +do \ +{ \ + current_time = time(NULL); \ + local_time = localtime(¤t_time); \ + memset(entrance_time_d, 0, sizeof(entrance_time_d)); \ + strftime(entrance_time_d, sizeof(entrance_time_d), \ + "%b %_2d %T", local_time); \ + fprintf(stderr, "(%s) "PACKAGE": "f, entrance_time_d, ##x); \ } while (0) extern time_t current_time; diff --git a/src/daemon/entrance_action.c b/src/daemon/entrance_action.c index b4a5128..dac945b 100644 --- a/src/daemon/entrance_action.c +++ b/src/daemon/entrance_action.c @@ -16,14 +16,13 @@ static Eina_List *_entrance_actions = NULL; typedef struct Entrance_Action_Data__ { - int id; + unsigned char id; const char *label; Entrance_Action_Cb func; void *data; } Entrance_Action_Data; static Ecore_Exe *_action_exe = NULL; -static Ecore_Event_Handler *_handle = NULL; static Entrance_Action_Data * _entrance_action_add(const char *label, Entrance_Action_Cb func, void *data) @@ -33,9 +32,9 @@ _entrance_action_add(const char *label, Entrance_Action_Cb func, void *data) ead->label = eina_stringshare_add(label); ead->func = func; ead->data = data; - ead->id = _entrance_actions ? (eina_list_count(_entrance_actions)) : 0; - _handle = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, - _entrance_action_exe_event_del_cb, NULL); + ead->id = (unsigned char)eina_list_count(_entrance_actions); + ecore_event_handler_add(ECORE_EXE_EVENT_DEL, + _entrance_action_exe_event_del_cb, NULL); return ead; } @@ -96,6 +95,7 @@ entrance_action_run(int action) static void _entrance_action_suspend(void *data __UNUSED__) { + PT("Suspend"); _action_exe = NULL; ecore_exe_run(entrance_config->command.suspend, NULL); } @@ -103,12 +103,14 @@ _entrance_action_suspend(void *data __UNUSED__) static void _entrance_action_shutdown(void *data __UNUSED__) { + PT("Shutdown"); _action_exe = ecore_exe_run(entrance_config->command.shutdown, NULL); } static void _entrance_action_reboot(void *data __UNUSED__) { + PT("Reboot\n"); _action_exe = ecore_exe_run(entrance_config->command.reboot, NULL); } @@ -118,8 +120,10 @@ _entrance_action_exe_event_del_cb(void *data __UNUSED__, int type __UNUSED__, vo Ecore_Exe_Event_Del *ev; Eina_Bool ret = ECORE_CALLBACK_PASS_ON; ev = event; + if (!ev->exe) return ret; if (ev->exe == _action_exe) { + PT("action quit requested by user\n"); ecore_main_loop_quit(); ret = ECORE_CALLBACK_DONE; } @@ -131,12 +135,12 @@ _entrance_action_exe_event_del_cb(void *data __UNUSED__, int type __UNUSED__, vo static void _entrance_action_grub2(void *data) { - intptr_t i = 0; + size_t i = 0; char buf[PATH_MAX]; - i = (intptr_t)data; + i = (size_t)data; snprintf(buf, sizeof(buf), - "grub-reboot %ld && %s", i, entrance_config->command.reboot); + "grub-reboot %d && %s", i, entrance_config->command.reboot); _action_exe = ecore_exe_run(buf, NULL); } @@ -166,7 +170,7 @@ _entrance_action_grub2_get(void) { Eina_File *f; unsigned char grub2_ok = 0; - intptr_t menuentry = 0; + size_t menuentry = 0; char *data; char *r, *r2; char *s; @@ -238,11 +242,8 @@ _entrance_action_grub2_get(void) action = malloc((tmp - r2 + 1 + 11) * sizeof (char)); if (!action) goto end_line; - buf = alloca((tmp - r2 + 1 + 11 + 10) * sizeof (char)); - sprintf(action, "Reboot on %s", local); - sprintf(buf, "GRUB2 '%s'\n", action); - PT(buf); + PT("GRUB2 '%s'\n", action); _entrance_actions = eina_list_append(_entrance_actions, _entrance_action_add(action, diff --git a/src/daemon/entrance_config.c b/src/daemon/entrance_config.c index 077aa18..2ebd99e 100644 --- a/src/daemon/entrance_config.c +++ b/src/daemon/entrance_config.c @@ -6,7 +6,9 @@ static void _defaults_set(Entrance_Config *config); static void _users_get(); static void _config_free(Entrance_Config *config); -static Entrance_Config *_cache_get(Eet_Data_Descriptor *edd); +static Entrance_Config *_cache_get(); + +static Eet_Data_Descriptor *_entrance_config_descriptor; static void _defaults_set(Entrance_Config *config) @@ -26,6 +28,7 @@ _defaults_set(Entrance_Config *config) config->numlock = EINA_FALSE; config->xsessions = EINA_FALSE; config->autologin = EINA_FALSE; + config->custom_conf = EINA_FALSE; config->userlogin = eina_stringshare_add("mylogintouse"); config->lockfile = eina_stringshare_add("/var/run/entrance.pid"); config->logfile = eina_stringshare_add("/var/log/entrance.log"); @@ -83,21 +86,25 @@ _users_get() } static Entrance_Config * -_cache_get(Eet_Data_Descriptor *edd) +_cache_get() { Entrance_Config *config = NULL; Eet_File *file; - if (!ecore_file_is_dir("/var/cache/"PACKAGE)) - ecore_file_mkdir("/var/cache/"PACKAGE); file = eet_open("/var/cache/"PACKAGE"/"ENTRANCE_CONFIG_FILE, EET_FILE_MODE_READ); + if (!file) + { + PT("Error!!! On read /var/cache"PACKAGE"/"ENTRANCE_CONFIG_FILE); + return NULL; + } - config = eet_data_read(file, edd, ENTRANCE_CONFIG_KEY); + config = eet_data_read(file, _entrance_config_descriptor, + ENTRANCE_CONFIG_KEY); if (!config) { - fprintf(stderr, PACKAGE": Warning no configuration found! This must \ - not append, we will go back to default configuration\n"); + PT(": Warning no configuration found! This must " + "not append, we will go back to default configuration\n"); config = (Entrance_Config *) calloc(1, sizeof(Entrance_Config)); _defaults_set(config); } @@ -110,6 +117,7 @@ _cache_get(Eet_Data_Descriptor *edd) static void _config_free(Entrance_Config *config) { + PT("Config free\n"); eina_stringshare_del(config->session_path); eina_stringshare_del(config->command.xinit_path); eina_stringshare_del(config->command.xinit_args); @@ -158,6 +166,12 @@ entrance_config_init() EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Config, "lockfile", lockfile, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Config, "logfile", logfile, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Config, "theme", theme, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Config, "background_path", bg.path, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Config, "background_group", bg.group, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Config, "elementary_profile", elm_profile, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Config, "virtual_keyboard", vkbd_enabled, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Config, "custom_conf", custom_conf, EET_T_UCHAR); + _entrance_config_descriptor = edd; if (stat( "/var/cache/"PACKAGE"/"ENTRANCE_CONFIG_FILE, &cache) == -1) { @@ -171,8 +185,7 @@ entrance_config_init() _users_get(); } } - entrance_config = _cache_get(edd); - eet_data_descriptor_free(edd); + entrance_config = _cache_get(); } @@ -180,5 +193,56 @@ void entrance_config_shutdown() { _config_free(entrance_config); + eet_data_descriptor_free(_entrance_config_descriptor); +} + +void +entrance_config_set(const Entrance_Conf_Gui_Event *conf) +{ + Eet_File *file; + Eina_Bool update = EINA_FALSE; + if (conf->bg.path && conf->bg.path != entrance_config->bg.path) + { + if (entrance_config->bg.path) + eina_stringshare_replace(&entrance_config->bg.path, conf->bg.path); + else + entrance_config->bg.path = eina_stringshare_add(conf->bg.path); + update = EINA_TRUE; + } + if (conf->bg.group && conf->bg.group != entrance_config->bg.group) + { + if (entrance_config->bg.group) + eina_stringshare_replace(&entrance_config->bg.group, conf->bg.group); + else + entrance_config->bg.group = eina_stringshare_add(conf->bg.group); + if (!update) + update = EINA_TRUE; + } + if (conf->vkbd_enabled != entrance_config->vkbd_enabled) + { + entrance_config->vkbd_enabled = conf->vkbd_enabled; + if (!update) + update = EINA_TRUE; + } + + if (update) + { + PT("Config save\n"); + if (!ecore_file_is_dir("/var/cache/"PACKAGE)) + ecore_file_mkdir("/var/cache/"PACKAGE); + file = eet_open("/var/cache/"PACKAGE"/"ENTRANCE_CONFIG_FILE, + EET_FILE_MODE_READ_WRITE); + if (!file) + file = eet_open("/var/cache/"PACKAGE"/"ENTRANCE_CONFIG_FILE, + EET_FILE_MODE_WRITE); + if (!file) + { + PT("Warning can't open /var/cache/"PACKAGE"/"ENTRANCE_CONFIG_FILE); + return; + } + eet_data_write(file, _entrance_config_descriptor, ENTRANCE_CONFIG_KEY, + entrance_config, 1); + eet_close(file); + } } diff --git a/src/daemon/entrance_config.h b/src/daemon/entrance_config.h index d5c426a..e03b0d5 100644 --- a/src/daemon/entrance_config.h +++ b/src/daemon/entrance_config.h @@ -21,18 +21,27 @@ struct _Entrance_Config const char *reboot; const char *suspend; } command; - Eina_Bool daemonize;// :1; - Eina_Bool numlock;// :1; - Eina_Bool xsessions; - Eina_Bool autologin; const char *userlogin; const char *lockfile; const char *logfile; const char *theme; + const char *elm_profile; + struct + { + const char *path; + const char *group; + } bg; + Eina_Bool daemonize; + Eina_Bool numlock; + Eina_Bool xsessions; + Eina_Bool autologin; + Eina_Bool custom_conf; + Eina_Bool vkbd_enabled; }; void entrance_config_init(); void entrance_config_shutdown(); +void entrance_config_set(const Entrance_Conf_Gui_Event *conf); Entrance_Config *entrance_config; diff --git a/src/daemon/entrance_history.c b/src/daemon/entrance_history.c index 7e2251f..19aaf51 100644 --- a/src/daemon/entrance_history.c +++ b/src/daemon/entrance_history.c @@ -19,23 +19,32 @@ void entrance_history_init() { Eet_Data_Descriptor *edd; - Eet_Data_Descriptor_Class eddc, eddcl; + Eet_Data_Descriptor_Class eddc; // TODO add idler to load history and thread stuff + // 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); - EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Login, "login", login, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Login, "session", session, 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(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); +#undef EET_LOGIN_ADD - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddcl, Entrance_History); - _eddh = eet_data_descriptor_stream_new(&eddcl); + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_History); + _eddh = eet_data_descriptor_stream_new(&eddc); EET_DATA_DESCRIPTOR_ADD_LIST(_eddh, Entrance_History, "history", history, edd); _entrance_history_read(); _entrance_user_init(); } -Eina_List *entrance_history_get() +Eina_List +*entrance_history_get() { return _lusers; } @@ -78,7 +87,8 @@ _entrance_history_write() ef = eet_open("/var/cache/"PACKAGE"/"ENTRANCE_HISTORY_FILE, EET_FILE_MODE_WRITE); - if (!eet_data_write(ef, _eddh, ENTRANCE_SESSION_KEY, _entrance_history, 1)) + if (!eet_data_write(ef, _eddh, ENTRANCE_SESSION_KEY, + _entrance_history, 1)) PT("Error on updating last session login\n"); eet_close(ef); @@ -100,7 +110,12 @@ entrance_history_push(const char *login, const char *session) { if (!strcmp(login, el->login)) { - if (el->session && strcmp(session, el->session)) + if (!session) + { + eina_stringshare_del(el->session); + el->session = NULL; + } + else if (el->session && strcmp(session, el->session)) { eina_stringshare_replace(&el->session, session); _history_update = EINA_TRUE; @@ -110,7 +125,7 @@ entrance_history_push(const char *login, const char *session) } if (!el) { - if ((el = (Entrance_Login *) malloc(sizeof(Entrance_Login)))) + if (el = calloc(1, sizeof(Entrance_Login))) { el->login = eina_stringshare_add(login); el->session = eina_stringshare_add(session); @@ -141,12 +156,13 @@ _entrance_user_init() { char buf[PATH_MAX]; FILE *f; - Entrance_User *eu; + Entrance_User_Event *eu; Eina_List *lu = NULL; char *token; char *user; int uid; + PT("scan for users\n"); f = fopen("/etc/passwd", "r"); if (f) { @@ -156,22 +172,20 @@ _entrance_user_init() strtok(NULL, ":"); token = strtok(NULL, ":"); uid = atoi(token); - if (uid > 500 && uid < 3000) + if (uid > 999 && uid < 3000) lu = eina_list_append(lu, eina_stringshare_add(user)); } fclose(f); } EINA_LIST_FREE(lu, user) { - if ((eu = (Entrance_User *) malloc(sizeof(Entrance_User)))) + if ((eu = (Entrance_User_Event *) calloc(1, sizeof(Entrance_User_Event)))) { eu->login = eina_stringshare_add(user); snprintf(buf, sizeof(buf), "/var/cache/"PACKAGE"/users/%s.edj", user); if (ecore_file_exists(buf)) - eu->image = eina_stringshare_add(buf); - else - eu->image = NULL; + eu->image.path = eina_stringshare_add(buf); eu->lsess = _entrance_history_match(user); eina_stringshare_del(user); _lusers = eina_list_append(_lusers, eu); @@ -182,7 +196,7 @@ _entrance_user_init() static void _entrance_user_shutdown() { - Entrance_User *eu; + Entrance_User_Event *eu; EINA_LIST_FREE(_lusers, eu) { eina_stringshare_del(eu->login); diff --git a/src/daemon/entrance_history.h b/src/daemon/entrance_history.h index cc000b2..34237d6 100644 --- a/src/daemon/entrance_history.h +++ b/src/daemon/entrance_history.h @@ -8,15 +8,31 @@ 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; }; struct _Entrance_History { + const char *theme; + Eina_Bool vkbdscreen; + Entrance_Background background; Eina_List *history; }; diff --git a/src/daemon/entrance_pam.c b/src/daemon/entrance_pam.c index b0e7109..77a524e 100644 --- a/src/daemon/entrance_pam.c +++ b/src/daemon/entrance_pam.c @@ -239,15 +239,12 @@ pam_error: int entrance_pam_item_set(ENTRANCE_PAM_ITEM_TYPE type, const void *value) { - char buf[4096]; - last_result = pam_set_item(_pam_handle, type, value); if (last_result == PAM_SUCCESS) { return 0; } - snprintf(buf, sizeof(buf), "PAM error: %d on %d", last_result, type); - PT(buf); + PT("PAM error: %d on %d", last_result, type); return 1; } diff --git a/src/daemon/entrance_server.c b/src/daemon/entrance_server.c index 2dbe064..e68585f 100644 --- a/src/daemon/entrance_server.c +++ b/src/daemon/entrance_server.c @@ -10,73 +10,54 @@ static Eina_Bool _entrance_server_data(void *data, int type, void *event); Ecore_Con_Server *_entrance_server = NULL; Eina_List *_handlers = NULL; - static Eina_Bool -_my_hack2(void *data) +_entrance_server_add(void *data __UNUSED__, int type __UNUSED__, void *event EINA_UNUSED) { + //Ecore_Con_Event_Client_Add *ev; Entrance_Event eev; - void *enc; - int size; - eev.type = ENTRANCE_EVENT_ACTIONS; - eev.event.actions.actions = entrance_action_get(); - enc = entrance_event_encode(&eev, &size); - ecore_con_client_send(data, enc, size); - return ECORE_CALLBACK_CANCEL; -} - -static Eina_Bool -_my_hack(void *data) -{ - Entrance_Event eev; - void *enc; - int size; - - eev.type = ENTRANCE_EVENT_XSESSIONS; - if (entrance_config->xsessions) - { - eev.event.xsessions.xsessions = entrance_session_list_get(); - enc = entrance_event_encode(&eev, &size); - ecore_con_client_send(data, enc, size); - } - ecore_timer_add(0.5, _my_hack2, data); - return ECORE_CALLBACK_CANCEL; -} - - -static Eina_Bool -_entrance_server_add(void *data __UNUSED__, int type __UNUSED__, void *event) -{ - Ecore_Con_Event_Client_Add *ev; - Entrance_Event eeu; - ev = event; - void *enc; - int size; + //ev = event; PT("server client connected\n"); - eeu.type = ENTRANCE_EVENT_USERS; - eeu.event.users.users = entrance_history_get(); - enc = entrance_event_encode(&eeu, &size); - ecore_con_client_send(ev->client, enc, size); -// ecore_con_client_flush(ev->client); - ecore_timer_add(0.5, _my_hack, ev->client); - /* - eev.type = ENTRANCE_EVENT_XSESSIONS; + PT("Sending users\n"); + eev.type = ENTRANCE_EVENT_USERS; + eev.event.users.users = entrance_history_get(); + entrance_event_send(&eev); + + PT("Sending actions\n"); + eev.type = ENTRANCE_EVENT_ACTIONS; + eev.event.actions.actions = entrance_action_get(); + entrance_event_send(&eev); if (entrance_config->xsessions) { + PT("Sending xsessions\n"); + eev.type = ENTRANCE_EVENT_XSESSIONS; eev.event.xsessions.xsessions = entrance_session_list_get(); - enc = entrance_event_encode(&eev, &size); - ecore_con_client_send(data, enc, size); + entrance_event_send(&eev); + } + if (entrance_config->custom_conf) + { + PT("Sending custom settings is enabled\n"); + eev.type = ENTRANCE_EVENT_CONF_GUI; + 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; } static Eina_Bool -_entrance_server_del(void *data __UNUSED__, int type __UNUSED__, void *event) +_entrance_server_del(void *data __UNUSED__, int type __UNUSED__, void *event EINA_UNUSED) { + /* + Ecore_Con_Event_Client_Del *ev; ev = event; + */ PT("server client disconnected\n"); return ECORE_CALLBACK_RENEW; @@ -87,36 +68,66 @@ _entrance_server_data(void *data __UNUSED__, int type __UNUSED__, void *event) { Ecore_Con_Event_Client_Data *ev; - Entrance_Event *eev, neev; - int size; - void *enc; ev = event; - eev = entrance_event_decode(ev->data, ev->size); + entrance_event_received(ev->data, ev->size); + + return ECORE_CALLBACK_RENEW; +} + + +static Eina_Bool +_entrance_server_read_cb(const void *data, size_t size EINA_UNUSED, void *user_data EINA_UNUSED) +{ + const Entrance_Event *eev; + Entrance_Event neev; + eev = data; if (eev->type == ENTRANCE_EVENT_AUTH) { neev.type = ENTRANCE_EVENT_STATUS; if (entrance_session_authenticate(eev->event.auth.login, - eev->event.auth.password)) + eev->event.auth.password)) { - entrance_session_login(eev->event.auth.session, EINA_TRUE); - neev.event.status.granted = EINA_TRUE; PT("server authenticate granted\n"); + 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 { neev.event.status.granted = EINA_FALSE; PT("server authenticate error\n"); } - enc = entrance_event_encode(&neev, &size); - ecore_con_client_send(ev->client, enc, size); + entrance_event_send(&neev); + } else if (eev->type == ENTRANCE_EVENT_ACTION) - entrance_action_run(eev->event.action.action); + { + PT("Action received\n"); + entrance_action_run(eev->event.action.action); + } + else if (eev->type == ENTRANCE_EVENT_CONF_GUI) + { + PT("Conf Gui received\n"); + entrance_config_set(&eev->event.conf_gui); + } else PT("UNKNOW signal server\n"); + return EINA_TRUE; +} - return ECORE_CALLBACK_RENEW; +static Eina_Bool +_entrance_server_write_cb(const void *data, size_t size, void *user_data EINA_UNUSED) +{ + const Eina_List *l; + Ecore_Con_Client *ecc; + EINA_LIST_FOREACH(ecore_con_server_clients_get(_entrance_server), l, ecc) + ecore_con_client_send(ecc, data, size); + + return EINA_TRUE; } void @@ -124,6 +135,10 @@ entrance_server_init() { Ecore_Event_Handler *h; ecore_con_init(); + entrance_event_init(_entrance_server_read_cb, + _entrance_server_write_cb, + NULL); + _entrance_server = ecore_con_server_add(ECORE_CON_LOCAL_SYSTEM, "entrance", 42, NULL); if (!_entrance_server) @@ -148,21 +163,16 @@ entrance_server_shutdown() ecore_con_server_del(_entrance_server); EINA_LIST_FREE(_handlers, h) ecore_event_handler_del(h); + entrance_event_shutdown(); ecore_con_shutdown(); } void entrance_server_client_wait() { - const Eina_List *l; Entrance_Event eev; - Ecore_Con_Client *ecc; - void *enc; - int size; eev.type = ENTRANCE_EVENT_MAXTRIES; eev.event.maxtries.maxtries = EINA_TRUE; - enc = entrance_event_encode(&eev, &size); - EINA_LIST_FOREACH(ecore_con_server_clients_get(_entrance_server), l, ecc) - ecore_con_client_send(ecc, enc, size); + entrance_event_send(&eev); } diff --git a/src/daemon/entrance_session.c b/src/daemon/entrance_session.c index aca2314..798636c 100644 --- a/src/daemon/entrance_session.c +++ b/src/daemon/entrance_session.c @@ -10,7 +10,8 @@ #define HAVE_SHADOW 1 -static char *_mcookie; +static char *_mcookie = NULL; +static const char *_dname = NULL; static char **env; static char *_login = NULL; static unsigned char _logged = 0; @@ -48,7 +49,8 @@ _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"); + PT("write auth on "); + fprintf(stderr, "display %s with file %s\n", display, auth_file); cmd = popen(buf, "w"); if (!cmd) { @@ -110,7 +112,7 @@ _entrance_session_begin(struct passwd *pwd, const char *cookie) entrance_pam_env_set("USER", pwd->pw_name); entrance_pam_env_set("LOGNAME", pwd->pw_name); entrance_pam_env_set("PATH", entrance_config->session_path); - entrance_pam_env_set("DISPLAY", ":0.0"); + entrance_pam_env_set("DISPLAY", _dname);//":0.0"); entrance_pam_env_set("MAIL", ""); entrance_pam_env_set("XAUTHORITY", cookie); entrance_pam_env_set("XDG_SESSION_CLASS", "greeter"); @@ -151,7 +153,7 @@ _entrance_session_run(struct passwd *pwd, const char *cmd, const char *cookie) env[n++]=strdup(buf); snprintf(buf, sizeof(buf), "PATH=%s", entrance_config->session_path); env[n++]=strdup(buf); - snprintf(buf, sizeof(buf), "DISPLAY=%s", ":0.0"); + snprintf(buf, sizeof(buf), "DISPLAY=%s", _dname);//":0.0"); env[n++]=strdup(buf); snprintf(buf, sizeof(buf), "MAIL="); env[n++]=strdup(buf); @@ -166,7 +168,7 @@ _entrance_session_run(struct passwd *pwd, const char *cmd, const char *cookie) if (-1 == system(buf)) PT("Error on session start command\n"); if(_entrance_session_userid_set(pwd)) return; - _entrance_session_cookie_add(_mcookie, ":0", + _entrance_session_cookie_add(_mcookie, _dname,//":0", entrance_config->command.xauth_path, cookie); if (chdir(pwd->pw_dir)) { @@ -220,15 +222,13 @@ entrance_session_pid_get() static const char *dig = "0123456789abcdef"; void -entrance_session_init(const char *file) +entrance_session_init(const char *dname) { uint16_t word; uint8_t hi, lo; int i; char buf[PATH_MAX]; - PT("Session init\n"); - _mcookie = calloc(33, sizeof(char)); _mcookie[0] = 'a'; @@ -244,12 +244,15 @@ entrance_session_init(const char *file) _mcookie[i+3] = dig[hi >> 4]; } // remove(file); - snprintf(buf, sizeof(buf), "XAUTHORITY=%s", file); + snprintf(buf, sizeof(buf), "XAUTHORITY=%s", + entrance_config->command.xauth_file); putenv(strdup(buf)); //PT("cookie %s \n", _mcookie); - _entrance_session_cookie_add(_mcookie, ":0", - entrance_config->command.xauth_path, file); + _entrance_session_cookie_add(_mcookie, dname, + entrance_config->command.xauth_path, + entrance_config->command.xauth_file); _entrance_session_desktops_init(); + _dname = dname; } void @@ -269,10 +272,11 @@ entrance_session_shutdown() Eina_Bool entrance_session_authenticate(const char *login, const char *passwd) { + Eina_Bool auth; _login = strdup(login); #ifdef HAVE_PAM - return (!entrance_pam_auth_set(login, passwd) - && !entrance_pam_authenticate()); + auth = !!(!entrance_pam_auth_set(login, passwd) + && !entrance_pam_authenticate()); #else char *enc, *v; struct passwd *pwd; @@ -293,8 +297,11 @@ entrance_session_authenticate(const char *login, const char *passwd) if(!v || *v == '\0') return EINA_TRUE; enc = crypt(passwd, v); - return !strcmp(enc, v); + auth = !strcmp(enc, v); #endif + eina_stringshare_del(passwd); + memset((char *)passwd, 0, strlen(passwd)); + return auth; } static struct passwd * @@ -328,8 +335,8 @@ entrance_session_login(const char *session, Eina_Bool push) } if (push) entrance_history_push(pwd->pw_name, session); cmd = _entrance_session_find_command(pwd->pw_dir, session); - PT("launching session for user "); - fprintf(stderr, "%s\n", _login); + PT("launching session "); + fprintf(stderr, "%s for user %s\n", session, _login); _entrance_session_run(pwd, cmd, buf); return ECORE_CALLBACK_CANCEL; } @@ -391,9 +398,8 @@ _entrance_session_desktops_init() efreet_desktop_type_alias(EFREET_DESKTOP_TYPE_APPLICATION, "XSession"); PT("scanning directory: "); - /* Maybee need to scan other directories ? - * _entrance_session_desktops_scan("/etc/share/xsessions"); - */ + /* Maybee need to scan other directories ? */ + _entrance_session_desktops_scan("/etc/share/xsessions"); _entrance_session_desktops_scan("/etc/X11/dm/Sessions"); snprintf(buf, sizeof(buf), "%s/xsessions", efreet_data_home_get()); _entrance_session_desktops_scan(buf); @@ -416,7 +422,7 @@ _entrance_session_desktops_scan(const char *dir) if (ecore_file_is_dir(dir)) { - fprintf(stderr, "%s", dir); + fprintf(stderr, " %s", dir); files = ecore_file_ls(dir); EINA_LIST_FREE(files, filename) { diff --git a/src/daemon/entrance_session.h b/src/daemon/entrance_session.h index e73bf38..8a15c29 100644 --- a/src/daemon/entrance_session.h +++ b/src/daemon/entrance_session.h @@ -2,7 +2,7 @@ #define ENTRANCE_SESSION_H_ #include -void entrance_session_init(const char *file); +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); diff --git a/src/daemon/entrance_xserver.c b/src/daemon/entrance_xserver.c index 87c4f61..1f22f9f 100644 --- a/src/daemon/entrance_xserver.c +++ b/src/daemon/entrance_xserver.c @@ -35,6 +35,7 @@ _xserver_start() char **args = NULL; pid_t pid; + PT("Launching xserver\n"); pid = fork(); if (!pid) { @@ -109,13 +110,13 @@ entrance_xserver_init(Entrance_X_Cb start, const char *dname) sigset_t newset; sigemptyset(&newset); - PT("xserver init\n"); _xserver = calloc(1, sizeof(Entrance_Xserver)); _xserver->dname = eina_stringshare_add(dname); _xserver->start = start; pid = _xserver_start(); snprintf(buf, sizeof(buf), "ENTRANCE_XPID=%d", pid); putenv(strdup(buf)); + PT("xserver adding signal user handler\n"); _handler_start = ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, _xserver_started, NULL); diff --git a/src/daemon/entrance_xserver.h b/src/daemon/entrance_xserver.h index 5d075ad..22f49c8 100644 --- a/src/daemon/entrance_xserver.h +++ b/src/daemon/entrance_xserver.h @@ -1,6 +1,6 @@ #ifndef ENTRANCE_XLIB_H_ #define ENTRANCE_XLIB_H_ -typedef int (*Entrance_X_Cb)(const char *data); +typedef Eina_Bool (*Entrance_X_Cb)(const char *data); int entrance_xserver_init(Entrance_X_Cb start, const char *dname); void entrance_xserver_wait(); void entrance_xserver_end(); diff --git a/src/event/entrance_event.c b/src/event/entrance_event.c index 25aeb74..77417e6 100644 --- a/src/event/entrance_event.c +++ b/src/event/entrance_event.c @@ -2,20 +2,32 @@ #include #include "entrance_event.h" + #define ENTRANCE_EVENT_AUTH_NAME "EntranceEventAuth" #define ENTRANCE_EVENT_MAXTRIES_NAME "EntranceEventMaxtries" #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" 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(); + + +typedef struct _Entrance_Event_Private { + Eet_Data_Descriptor *event_descriptor; + Eet_Connection *event_connection; + Eet_Read_Cb *func_read_cb; +} Entrance_Event_Private; + +static Entrance_Event_Private *_eep = NULL; static Eina_Bool _entrance_event_type_set(const char *type, void *data, Eina_Bool unknow) @@ -33,10 +45,14 @@ _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_ACTIONS_NAME)) *ev = ENTRANCE_EVENT_ACTIONS; else if (!strcmp(type, ENTRANCE_EVENT_ACTION_NAME)) *ev = ENTRANCE_EVENT_ACTION; + else if (!strcmp(type, ENTRANCE_EVENT_CONF_GUI_NAME)) + *ev = ENTRANCE_EVENT_CONF_GUI; else { printf("error on type set\n"); @@ -60,14 +76,19 @@ _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_ACTIONS) return ENTRANCE_EVENT_ACTIONS_NAME; else if (*ev == ENTRANCE_EVENT_ACTION) return ENTRANCE_EVENT_ACTION_NAME; - if (*unknow) + else if (*ev == ENTRANCE_EVENT_CONF_GUI) + return ENTRANCE_EVENT_CONF_GUI_NAME; + else { printf("error on type get\n"); - *unknow = EINA_TRUE; + if (unknow) + *unknow = EINA_TRUE; } return NULL; } @@ -87,7 +108,8 @@ _entrance_event_xsessions_dd() EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddcl, Entrance_Xsessions_Event); eddl = eet_data_descriptor_stream_new(&eddcl); - EET_DATA_DESCRIPTOR_ADD_LIST(eddl, Entrance_Xsessions_Event, "xsessions", xsessions, edd); + EET_DATA_DESCRIPTOR_ADD_LIST(eddl, Entrance_Xsessions_Event, "xsessions", + xsessions, edd); return eddl; } @@ -104,6 +126,8 @@ _entrance_event_auth_dd() password, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Auth_Event, "session", session, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Auth_Event, "open_session", + open_session, EET_T_UCHAR); return edd; } @@ -120,6 +144,25 @@ _entrance_event_maxtries_dd() return edd; } +static Eet_Data_Descriptor * +_entrance_event_conf_gui_dd() +{ + Eet_Data_Descriptor *edd; + Eet_Data_Descriptor_Class eddc; + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, + Entrance_Conf_Gui_Event); + edd = eet_data_descriptor_stream_new(&eddc); + 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", + bg.path, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Conf_Gui_Event, "bg.group", + bg.group, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Conf_Gui_Event, "vkbd_enabled", + vkbd_enabled, EET_T_UCHAR); + return edd; +} + static Eet_Data_Descriptor * _entrance_event_status_dd() { @@ -138,20 +181,42 @@ _entrance_event_users_dd() { Eet_Data_Descriptor *edd, *eddl; Eet_Data_Descriptor_Class eddc, eddcl; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_User); + 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, "login", + EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_User_Event, "login", login, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_User, "image", - image, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_User, "lsess", + 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(&eddcl, Entrance_Users_Event); eddl = eet_data_descriptor_stream_new(&eddcl); - EET_DATA_DESCRIPTOR_ADD_LIST(eddl, Entrance_Users_Event, "users", users, edd); + EET_DATA_DESCRIPTOR_ADD_LIST(eddl, Entrance_Users_Event, "users", + users, edd); return eddl; } +static Eet_Data_Descriptor * +_entrance_event_user_dd() +{ + Eet_Data_Descriptor *edd; + Eet_Data_Descriptor_Class eddc; + 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); + EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_User_Event, "lsess", + lsess, EET_T_STRING); + return edd; +} + static Eet_Data_Descriptor * _entrance_event_actions_dd() { @@ -162,10 +227,11 @@ _entrance_event_actions_dd() EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Action, "label", label, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Action, "id", - id, EET_T_INT); + id, EET_T_UCHAR); EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddcl, Entrance_Actions_Event); eddl = eet_data_descriptor_stream_new(&eddcl); - EET_DATA_DESCRIPTOR_ADD_LIST(eddl, Entrance_Actions_Event, "actions", actions, edd); + EET_DATA_DESCRIPTOR_ADD_LIST(eddl, Entrance_Actions_Event, "actions", + actions, edd); return eddl; } @@ -177,7 +243,7 @@ _entrance_event_action_dd() 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_Action_Event, "action", - action, EET_T_INT); + action, EET_T_UCHAR); return edd; } @@ -196,35 +262,70 @@ _entrance_event_new() eddc.func.type_set = _entrance_event_type_set; unified = eet_data_descriptor_stream_new(&eddc); - EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_XSESSIONS_NAME, _entrance_event_xsessions_dd()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_AUTH_NAME, _entrance_event_auth_dd()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_MAXTRIES_NAME, _entrance_event_maxtries_dd()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_STATUS_NAME, _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_ACTIONS_NAME, _entrance_event_actions_dd()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_ACTION_NAME, _entrance_event_action_dd()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_XSESSIONS_NAME, + _entrance_event_xsessions_dd()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_AUTH_NAME, + _entrance_event_auth_dd()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_MAXTRIES_NAME, + _entrance_event_maxtries_dd()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_STATUS_NAME, + _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_ACTIONS_NAME, + _entrance_event_actions_dd()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_ACTION_NAME, + _entrance_event_action_dd()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_CONF_GUI_NAME, + _entrance_event_conf_gui_dd()); - EET_DATA_DESCRIPTOR_ADD_UNION(edd, Entrance_Event, "event", event, type, unified); + EET_DATA_DESCRIPTOR_ADD_UNION(edd, Entrance_Event, "event", + event, type, unified); return edd; } -void * -entrance_event_encode(Entrance_Event *eev, int *size) +static Eina_Bool +_entrance_event_read_cb(const void *data, size_t size, void *user_data EINA_UNUSED) { - Eet_Data_Descriptor *edd; - - edd = _entrance_event_new(); - - return eet_data_descriptor_encode(edd, eev, size); + void *ev; + ev = eet_data_descriptor_decode(_eep->event_descriptor, data, size); + if (_eep->func_read_cb) + _eep->func_read_cb(ev, size, user_data); + return EINA_TRUE; } -Entrance_Event * -entrance_event_decode(void *data, int size) +void +entrance_event_init(Eet_Read_Cb func_read_cb, Eet_Write_Cb func_write_cb, void *func_data) { - Eet_Data_Descriptor *edd; - - edd = _entrance_event_new(); - - return eet_data_descriptor_decode(edd, data, size); + _eep = calloc(1, sizeof(Entrance_Event_Private)); + _eep->func_read_cb = func_read_cb; + _eep->event_descriptor = _entrance_event_new(); + _eep->event_connection = eet_connection_new(_entrance_event_read_cb, + func_write_cb, + func_data); } +void +entrance_event_shutdown(void) +{ + eet_connection_close(_eep->event_connection, NULL); + eet_data_descriptor_free(_eep->event_descriptor); + free(_eep); +} + +void +entrance_event_send(const Entrance_Event *data) +{ + eet_connection_send(_eep->event_connection, _eep->event_descriptor, + data, NULL); +} + +void +entrance_event_received(const void *data, size_t size) +{ + eet_connection_received(_eep->event_connection, data, size); +} + + diff --git a/src/event/entrance_event.h b/src/event/entrance_event.h index 510e9da..b0948dd 100644 --- a/src/event/entrance_event.h +++ b/src/event/entrance_event.h @@ -8,9 +8,11 @@ typedef enum Entrance_Event_Type_ ENTRANCE_EVENT_STATUS, ENTRANCE_EVENT_XSESSIONS, ENTRANCE_EVENT_USERS, + ENTRANCE_EVENT_USER, ENTRANCE_EVENT_ACTIONS, ENTRANCE_EVENT_ACTION, - ENTRANCE_EVENT_MAXTRIES + ENTRANCE_EVENT_MAXTRIES, + ENTRANCE_EVENT_CONF_GUI, } Entrance_Event_Type; typedef struct Entrance_Xsession_ @@ -30,6 +32,7 @@ typedef struct Entrance_Auth_Event_ const char *login; const char *password; const char *session; + Eina_Bool open_session; } Entrance_Auth_Event; typedef struct Entrance_Maxtries_Event_ @@ -44,16 +47,24 @@ typedef struct Entrance_Status_Event_ typedef struct Entrance_Action_Event_ { - int action; + unsigned char action; } Entrance_Action_Event; -typedef struct Entrance_User_ +typedef struct Entrance_User_Event_ { const char *login; - const char *image; const char *lsess; -} Entrance_User; - + struct + { + const char *path; + const char *group; + } image; + struct + { + const char *path; + const char *group; + } background; +} Entrance_User_Event; typedef struct Entrance_Users_Event_ { @@ -62,7 +73,7 @@ typedef struct Entrance_Users_Event_ typedef struct Entrance_Action_ { - int id; + unsigned char id; const char *label; } Entrance_Action; @@ -71,6 +82,20 @@ typedef struct Entrance_Actions_Event_ Eina_List *actions; } Entrance_Actions_Event; +typedef struct Entrance_Conf_Gui_Event_ +{ + Eina_Bool enabled; + const char *theme; + struct + { + const char *group; + const char *path; + } bg; + Eina_Bool vkbd_enabled; +} Entrance_Conf_Gui_Event; + + + typedef struct Entrance_Event_ { Entrance_Event_Type type; @@ -81,11 +106,15 @@ typedef struct Entrance_Event_ Entrance_Maxtries_Event maxtries; Entrance_Status_Event status; Entrance_Users_Event users; + Entrance_User_Event user; Entrance_Actions_Event actions; Entrance_Action_Event action; + Entrance_Conf_Gui_Event conf_gui; } event; } Entrance_Event; -void *entrance_event_encode(Entrance_Event *ev, int *size); -Entrance_Event *entrance_event_decode(void *data, int size); +void entrance_event_init(Eet_Read_Cb func_read_cb, Eet_Write_Cb func_write_cb, void *func_data); +void entrance_event_shutdown(void); +void entrance_event_send(const Entrance_Event *data); +void entrance_event_received(const void *data, size_t size); #endif /* ENTRANCE_EVENT_ */