Enlightenment CVS committal
Author : atmosphere
Project : e17
Module : apps/entrance
Dir : e17/apps/entrance/src/client
Modified Files:
Makefile.am entrance_config.c entrance_config.h
entrance_session.c entrance_session.h main.c
Log Message:
incoming! ignore this for now, it's incoming user code. It works, just needs a little
more tidying up, hopefully I'll get to it all this afternoon :)
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/Makefile.am,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- Makefile.am 3 Jan 2004 04:54:57 -0000 1.6
+++ Makefile.am 3 Mar 2004 15:08:54 -0000 1.7
@@ -9,6 +9,7 @@
entrance_auth.c entrance_auth.h \
entrance_session.c entrance_session.h \
entrance_config.c entrance_config.h \
+ entrance_user.c entrance_user.h \
EvasTextEntry.c EvasTextEntry.h \
util.c util.h \
main.c
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_config.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- entrance_config.c 2 Jan 2004 16:35:15 -0000 1.14
+++ entrance_config.c 3 Mar 2004 15:09:03 -0000 1.15
@@ -1,5 +1,7 @@
#include "entrance.h"
#include "entrance_config.h"
+#include "entrance_user.h"
+
/**
@file entrance_config.c
@brief System-wide configuration options for various settings in Entrance
@@ -72,24 +74,37 @@
e->time.string = strdup("%l:%M:%S %p");
if (e_db_int_get(db, "/entrance/user/count", &num_user))
{
+ Entrance_User *eu = NULL;
char *user = NULL;
- char *edje_file = NULL;
+ char *icon = NULL;
+ char *session = NULL;
for (i = 0; i < num_user; i++)
{
snprintf(buf, PATH_MAX, "/entrance/user/%d/user", i);
if ((user = e_db_str_get(db, buf)))
{
- snprintf(buf, PATH_MAX, "/entrance/user/%d/edje", i);
- if ((edje_file = e_db_str_get(db, buf)))
+ snprintf(buf, PATH_MAX, "/entrance/user/%d/icon", i);
+ icon = e_db_str_get(db, buf);
+ snprintf(buf, PATH_MAX, "/entrance/user/%d/session", i);
+ session = e_db_str_get(db, buf);
+
+ if ((eu = entrance_user_new(user, icon, session)))
{
- e->users.hash = evas_hash_add(e->users.hash, user, edje_file);
- e->users.keys = evas_list_append(e->users.keys, user);
+ e->users.hash = evas_hash_add(e->users.hash, user, eu);
+ e->users.keys = evas_list_append(e->users.keys, eu);
}
else
+ {
free(user);
+ if (icon)
+ free(icon);
+ if (session)
+ free(session);
+ }
}
}
+ /* FIXME syslog(LOG_NORMAL, "Loaded %d users", num_user) */
}
else
{
@@ -236,6 +251,55 @@
}
}
+/**
+ *
+ */
+void
+entrance_config_user_list_write(Entrance_Config * e)
+{
+ int i = 0;
+ Evas_List *l = NULL;
+ E_DB_File *db = NULL;
+ Entrance_User *eu = NULL;
+ char file[PATH_MAX], buf[PATH_MAX];
+
+ snprintf(file, PATH_MAX, "%s/entrance_config.db", PACKAGE_CFG_DIR);
+ if ((db = e_db_open(file)))
+ {
+ for (l = e->users.keys; l; l = l->next, i++)
+ {
+ if ((eu = (Entrance_User *) l->data))
+ {
+ if (eu->name)
+ {
+ snprintf(buf, PATH_MAX, "/entrance/user/%d/user", i);
+ e_db_str_set(db, buf, eu->name);
+ }
+ if (eu->session)
+ {
+ snprintf(buf, PATH_MAX, "/entrance/user/%d/session", i);
+ e_db_str_set(db, buf, eu->session);
+ }
+ if (eu->icon)
+ {
+ snprintf(buf, PATH_MAX, "/entrance/user/%d/icon", i);
+ e_db_str_set(db, buf, eu->icon);
+ }
+ }
+ else
+ i--;
+ }
+ snprintf(buf, PATH_MAX, "/entrance/user/count");
+ e_db_int_set(db, buf, i);
+ e_db_close(db);
+ e_db_flush();
+ }
+ else
+ {
+ fprintf(stderr, "Unable to open %s, sure you're root?", file);
+ }
+}
+
#if 0
int
main(int argc, char *argv[])
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_config.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- entrance_config.h 31 Oct 2003 04:39:52 -0000 1.9
+++ entrance_config.h 3 Mar 2004 15:09:03 -0000 1.10
@@ -94,5 +94,6 @@
void entrance_config_print(Entrance_Config * e);
void entrance_config_free(Entrance_Config * e);
void entrance_config_prepend_recent_user(Entrance_Config * e, char *str);
+void entrance_config_user_list_write(Entrance_Config * e);
#endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_session.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -3 -r1.31 -r1.32
--- entrance_session.c 16 Feb 2004 01:04:06 -0000 1.31
+++ entrance_session.c 3 Mar 2004 15:09:03 -0000 1.32
@@ -5,6 +5,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
+#include "entrance_user.h"
/**
@file entrance_session.c
@@ -23,8 +24,9 @@
const char *file);
static Evas_Object *_entrance_session_load_session(Entrance_Session * e,
const char *key);
-static Evas_Object *_entrance_session_user_load(Entrance_Session * e,
- const char *key);
+static void _entrance_session_user_list_fix(Entrance_Session * e);
+static void entrance_session_xsession_load(Entrance_Session * e,
+ const char *key);
extern int _entrance_test_en;
@@ -111,14 +113,6 @@
}
}
-#if 0
-static void
-init_user_edje(Entrance_Session e, char *user)
-{
- fprintf(stderr, "I should load /home/%s/.entrance.eet\n", user);
-}
-#endif
-
/**
* entrance_session_run: Be a login dm
* @e - the Entrance_Session to be run
@@ -166,35 +160,32 @@
* entrance_session_user_set: forget what we know about the current user
*/
void
-entrance_session_user_set(Entrance_Session * e, char *key)
+entrance_session_user_set(Entrance_Session * e, Entrance_User * eu)
{
- int result = 0;
- const char *file = NULL;
- char *pass = NULL;
- char *session = NULL;
Evas_Object *obj = NULL;
- if (e && key)
+ if (e && eu)
{
if ((obj = edje_object_part_swallow_get(e->edje, "EntranceFace")))
{
edje_object_part_unswallow(e->edje, obj);
evas_object_del(obj);
}
- if ((obj = _entrance_session_user_load(e, key)))
+ if ((obj = entrance_user_edje_get(eu, e->edje)))
{
- if (!entrance_auth_set_user(e->auth, key))
+ if (!entrance_auth_set_user(e->auth, eu->name))
{
- edje_object_file_get(obj, &file, NULL);
- if ((session = edje_file_data_get(file, "session")))
+ if ((eu->session) && (strlen(eu->session) > 0))
{
- if ((strlen(session) > 0) && (strlen(e->session) == 0))
- {
- if (e->session)
- free(e->session);
- e->session = strdup(session);
- }
+ if (e->session)
+ free(e->session);
+ e->session = strdup(eu->session);
+ entrance_session_xsession_load(e, eu->session);
+
+ /* FIXME: Should this be optional ? */
+
}
+#if 0
if ((pass = edje_file_data_get(file, "password")))
{
entrance_auth_set_pass(e->auth, pass);
@@ -218,6 +209,7 @@
}
else
{
+#endif
if (edje_object_part_exists(e->edje, "EntranceFace"))
{
edje_object_part_swallow(e->edje, "EntranceFace", obj);
@@ -225,7 +217,9 @@
edje_object_signal_emit(e->edje, "In", "EntrancePassEntry");
edje_object_signal_emit(e->edje, "EntranceUserAuth", "");
edje_object_signal_emit(e->edje, "UserSelected", "");
+#if 0
}
+#endif
}
else
{
@@ -236,6 +230,21 @@
}
}
}
+void
+entrance_session_user_session_default_set(Entrance_Session * e)
+{
+ if (e && e->config && e->auth && e->auth->user && e->session)
+ {
+ Entrance_User *eu = NULL;
+
+ if ((eu = evas_hash_find(e->config->users.hash, e->auth->user)))
+ {
+ if (eu->session)
+ free(eu->session);
+ eu->session = strdup(e->session);
+ }
+ }
+}
void
entrance_session_start_user_session(Entrance_Session * e)
@@ -270,8 +279,8 @@
syslog(LOG_CRIT, "Executing %s", buf);
ecore_evas_free(e->ee);
- ecore_evas_shutdown();
e->ee = NULL;
+ ecore_evas_shutdown();
ecore_x_sync();
syslog(LOG_NOTICE, "Starting session for user \"%s\".", e->auth->user);
@@ -309,6 +318,7 @@
default:
break;
}
+ _entrance_session_user_list_fix(e);
/* clear users's password out of memory */
entrance_auth_clear_pass(e->auth);
/* this bypasses a race condition where entrance loses its x connection */
@@ -326,20 +336,26 @@
{
if (e && e->edje)
{
+ char *str = NULL;
Evas_Object *o = NULL, *old_o = NULL;
if ((o = _entrance_session_load_session(e, key)))
{
- if (e->session)
- free(e->session);
- e->session = strdup(key);
- old_o = edje_object_part_swallow_get(e->edje, "EntranceSession");
- if (old_o)
+ if ((str = evas_hash_find(e->config->sessions.hash, key)))
{
- edje_object_part_unswallow(e->edje, old_o);
- evas_object_del(old_o);
+ if (e->session)
+ free(e->session);
+ e->session = strdup(key);
+
+ old_o = edje_object_part_swallow_get(e->edje, "EntranceSession");
+ if (old_o)
+ {
+ edje_object_part_unswallow(e->edje, old_o);
+ evas_object_del(old_o);
+ }
+ edje_object_part_swallow(e->edje, "EntranceSession", o);
+ edje_object_signal_emit(e->edje, "SessionDefaultChanged", "");
}
- edje_object_part_swallow(e->edje, "EntranceSession", o);
}
}
}
@@ -356,7 +372,7 @@
if ((str = evas_hash_find(e->config->sessions.hash, key)))
{
snprintf(buf, PATH_MAX, "%s", key);
- if (strcmp(key, e->session))
+ if (strcmp(str, e->session))
{
entrance_session_xsession_load(e, key);
}
@@ -364,7 +380,7 @@
}
else
{
- fprintf(stderr, "Unable to find %s\n", key);
+ fprintf(stderr, "Unable to find session %s\n", key);
}
}
@@ -423,7 +439,7 @@
entrance_session_user_list_add(Entrance_Session * e)
{
Evas_Coord w, h;
- char *key = NULL;
+ Entrance_User *key = NULL;
Evas_List *l = NULL;
Evas_Object *container = NULL, *edje;
@@ -448,8 +464,8 @@
}
for (l = e->config->users.keys; l; l = l->next)
{
- key = (char *) l->data;
- if ((edje = _entrance_session_user_load(e, key)))
+ key = (Entrance_User *) l->data;
+ if ((edje = entrance_user_edje_get(key, e->edje)))
{
e_container_element_append(container, edje);
}
@@ -474,63 +490,7 @@
}
return (result);
}
-static Evas_Object *
-_entrance_session_user_load(Entrance_Session * e, const char *key)
-{
- int result = 0;
- char *icon = NULL;
- char buf[PATH_MAX];
- Evas_Object *o = NULL;
- Evas_Object *edje = NULL;
- if (!e || !e->edje || !key)
- return (NULL);
-
- if ((icon = evas_hash_find(e->config->users.hash, key)))
- {
- edje = edje_object_add(evas_object_evas_get(e->edje));
- if (icon[0] == '/') /* absolute path */
- snprintf(buf, PATH_MAX, "%s", icon);
- else
- snprintf(buf, PATH_MAX, "%s/users/%s", PACKAGE_DATA_DIR, icon);
- if ((result = edje_object_file_set(edje, buf, "User")) > 0)
- {
- Evas_Coord w = 48, h = 48;
-
- /* edje_object_size_min_get(edje, &w, &h); */
- evas_object_move(edje, -w, -h);
- evas_object_resize(edje, w, h);
- evas_object_layer_set(edje, 0);
-
- if (edje_object_part_exists(edje, "EntranceUser"))
- {
- edje_object_part_text_set(edje, "EntranceUser", key);
- evas_object_show(edje);
- edje_object_signal_callback_add(edje, "UserSelected", "",
- user_selected_cb, (char *) key);
- edje_object_signal_callback_add(edje, "UserUnSelected", "",
- user_unselected_cb, (char *) key);
- }
- else
- {
- if (o)
- evas_object_del(o);
- if (edje)
- evas_object_del(edje);
- edje = NULL;
- }
- }
- else
- {
- fprintf(stderr, "Failed on: %s(%d)\n", key, result);
- evas_object_del(edje);
- evas_object_del(o);
- edje = NULL;
- }
- }
- return (edje);
-
-}
static Evas_Object *
_entrance_session_icon_load(Evas_Object * o, const char *file)
{
@@ -542,7 +502,7 @@
result = edje_object_add(evas_object_evas_get(o));
snprintf(buf, PATH_MAX, "%s/images/sessions/%s", PACKAGE_DATA_DIR, file);
- if (!edje_object_file_set(result, buf, "Icon") > 0)
+ if (!edje_object_file_set(result, buf, "Icon"))
{
evas_object_del(result);
result = evas_object_image_add(evas_object_evas_get(o));
@@ -599,16 +559,18 @@
if (edje_object_part_exists(edje, "EntranceSessionIcon"))
{
icon = (char *) evas_hash_find(e->config->sessions.icons, key);
- o = _entrance_session_icon_load(e->edje, icon);
- if (!strcmp(evas_object_type_get(o), "image"))
+ if ((o = _entrance_session_icon_load(e->edje, icon)))
{
- Evas_Coord w, h;
+ if (!strcmp(evas_object_type_get(o), "image"))
+ {
+ Evas_Coord w, h;
- edje_object_part_geometry_get(edje, "EntranceSessionIcon", NULL,
- NULL, &w, &h);
- evas_object_image_fill_set(o, 0.0, 0.0, w, h);
+ edje_object_part_geometry_get(edje, "EntranceSessionIcon",
+ NULL, NULL, &w, &h);
+ evas_object_image_fill_set(o, 0.0, 0.0, w, h);
+ }
+ edje_object_part_swallow(edje, "EntranceSessionIcon", o);
}
- edje_object_part_swallow(edje, "EntranceSessionIcon", o);
}
if (edje_object_part_exists(edje, "EntranceSessionTitle"))
{
@@ -627,3 +589,36 @@
}
return (edje);
}
+
+static void
+_entrance_session_user_list_fix(Entrance_Session * e)
+{
+ char buf[PATH_MAX];
+ Evas_List *l = NULL;
+ Entrance_User *eu = NULL;
+
+ if (!e)
+ return;
+
+ if (e->auth && e->auth->user && e->config)
+ {
+ for (l = e->config->users.keys; l; l = l->next)
+ {
+ if (!strcmp(e->auth->user, ((Entrance_User *) l->data)->name))
+ {
+ if ((eu = evas_hash_find(e->config->users.hash, e->auth->user)))
+ {
+ e->config->users.keys =
+ evas_list_prepend(evas_list_remove
+ (e->config->users.keys, eu), eu);
+ entrance_config_user_list_write(e->config);
+ return;
+ }
+ }
+ }
+ snprintf(buf, PATH_MAX, "default.eet");
+ eu = entrance_user_new(e->auth->user, buf, e->session);
+ e->config->users.keys = evas_list_prepend(e->config->users.keys, eu);
+ entrance_config_user_list_write(e->config);
+ }
+}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_session.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- entrance_session.h 16 Feb 2004 01:04:06 -0000 1.12
+++ entrance_session.h 3 Mar 2004 15:09:03 -0000 1.13
@@ -14,6 +14,7 @@
#include "entrance_auth.h"
#include "entrance_config.h"
+#include "entrance_user.h"
struct _Entrance_Session
{
@@ -34,7 +35,8 @@
void entrance_session_run(Entrance_Session * e);
int entrance_session_auth_user(Entrance_Session * e);
void entrance_session_user_reset(Entrance_Session * e);
-void entrance_session_user_set(Entrance_Session * e, char *user);
+void entrance_session_user_set(Entrance_Session * e, Entrance_User * user);
+void entrance_session_user_session_default_set(Entrance_Session * e);
void entrance_session_start_user_session(Entrance_Session * e);
void entrance_session_xsession_set(Entrance_Session * e,
const char *xsession);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/main.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -3 -r1.33 -r1.34
--- main.c 16 Feb 2004 01:04:06 -0000 1.33
+++ main.c 3 Mar 2004 15:09:03 -0000 1.34
@@ -326,7 +326,7 @@
{
if (session && data)
{
- entrance_session_user_set(session, (char *) data);
+ entrance_session_user_set(session, (Entrance_User *) data);
}
}
@@ -431,7 +431,17 @@
}
}
}
+static void
+_session_set(void *data, Evas_Object * o, const char *emission,
+ const char *source)
+{
+ Entrance_Session *e = NULL;
+ if ((e = (Entrance_Session *) data))
+ {
+ entrance_session_user_session_default_set(e);
+ }
+}
static void
entrance_help(char **argv)
{
@@ -439,12 +449,10 @@
printf("Usage: %s [OPTION]...\n\n", argv[0]);
printf
("---------------------------------------------------------------------------\n");
- printf
- (" -c, --config=CONFIG Specify a custom config file\n");
+ printf(" -c, --config=CONFIG Specify a custom config file\n");
printf
(" -d, --display=DISPLAY Specify which display Entrance should use\n");
- printf
- (" -h, --help Display this help message\n");
+ printf(" -h, --help Display this help message\n");
printf
(" -g, --geometry=WIDTHxHEIGHT Specify the size of the Entrance window.\n");
printf
@@ -455,8 +463,7 @@
(" either the name of an installed theme, or
an\n");
printf
(" arbitrary path to an eet file (use ./ for\n");
- printf
- (" the current directory).\n");
+ printf(" the current directory).\n");
printf
(" -T, --test Enable testing mode. This will cause xterm\n");
printf
@@ -471,8 +478,7 @@
("Note: To automatically launch an X server that will be managed, please
use\n");
printf
(" entranced instead of entrance. Entrance requires an existing X
server\n");
- printf
- (" to run. Run entranced --help for more information.\n\n");
+ printf(" to run. Run entranced --help for more information.\n\n");
exit(0);
}
@@ -756,6 +762,8 @@
reboot_cb, e);
edje_object_signal_callback_add(edje, "EntranceSystemHalt", "",
shutdown_cb, e);
+ edje_object_signal_callback_add(edje, "SessionDefaultSet", "",
+ _session_set, session);
/*
* It's useful to delay showing of your edje till all your
* callbacks have been added, otherwise show might not trigger all
@@ -778,8 +786,8 @@
if (session->authed)
entrance_session_start_user_session(session);
-
- ecore_evas_shutdown();
+ else
+ ecore_evas_shutdown();
entrance_session_free(session);
edje_shutdown();
ecore_x_shutdown();
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs