Enlightenment CVS committal

Author  : atmosphere
Project : e17
Module  : apps/entrance

Dir     : e17/apps/entrance/src/client


Modified Files:
        entrance_config.c entrance_session.c entrance_session.h main.c 


Log Message:
* Reinstate reading of the /entrance/users/* keys to the config file
* Renamed entrance_session_reset_user to entrance_session_user_reset
* Added entrance_session_user_set function
* Fixed _entrance_session_user_load to work properly.
* Allow for absolute path names of faces/session files
* Added callbacks to main.c for Face Signal emissions



Login Faces are possible now.  Entrance will automatically fill a
container object with edjes specified in your entrance_config.db
See README.edje or data/users/default/default.edc for an example.


===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_config.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- entrance_config.c   22 Oct 2003 06:58:15 -0000      1.10
+++ entrance_config.c   22 Oct 2003 12:09:56 -0000      1.11
@@ -20,7 +20,7 @@
 entrance_config_populate(Entrance_Config e, E_DB_File * db)
 {
    char *str;
-   int i = 0, num_session = 0;
+   int i = 0, num_session = 0, num_user;
    char buf[PATH_MAX];
    int num_fonts;
 
@@ -60,32 +60,31 @@
       e->time.string = str;
    else
       e->time.string = strdup("%l:%M:%S %p");
-#if 0
    if (e_db_int_get(db, "/entrance/user/count", &num_user))
    {
+      char *user = NULL;
+      char *edje_file = NULL;
+
       for (i = 0; i < num_user; i++)
       {
-         eu = (Entrance_User *) malloc(sizeof(Entrance_User));
-         memset(eu, 0, sizeof(Entrance_User));
-         snprintf(buf, PATH_MAX, "/entrance/user/%d/name", i);
-         eu->name = e_db_str_get(db, buf);
-         snprintf(buf, PATH_MAX, "/entrance/user/%d/img", i);
-         eu->img = e_db_str_get(db, buf);
-         snprintf(buf, PATH_MAX, "/entrance/user/%d/sys", i);
-         if (!e_db_int_get(db, buf, &(eu->sys)))
-            eu->sys = 1;
-         U = evas_list_append(U, eu);
+         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)))
+            {
+               e->users.hash = evas_hash_add(e->users.hash, user, edje_file);
+               e->users.keys = evas_list_append(e->users.keys, user);
+            }
+            else
+               free(user);
+         }
       }
-
-      e->users = U;
    }
    else
    {
-      evas_list_append(e->users, NULL);
-      e->users = NULL;
       syslog(LOG_WARNING, "Warning: No users found.");
    }
-#endif
 
    /* session hash and font list */
    if (e_db_int_get(db, "/entrance/session/count", &num_session))
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_session.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- entrance_session.c  22 Oct 2003 06:58:15 -0000      1.16
+++ entrance_session.c  22 Oct 2003 12:09:57 -0000      1.17
@@ -6,6 +6,10 @@
 extern void session_item_selected_cb(void *data, Evas_Object * o,
                                      const char *emission,
                                      const char *source);
+extern void user_selected_cb(void *data, Evas_Object * o,
+                             const char *emission, const char *source);
+extern void user_unselected_cb(void *data, Evas_Object * o,
+                               const char *emission, const char *source);
 static Evas_Object *_entrance_session_icon_load(Evas_Object * o, char *file);
 static Evas_Object *_entrance_session_load_session(Entrance_Session e,
                                                    char *key);
@@ -119,13 +123,99 @@
 }
 
 /**
- * entrance_session_reset_user: forget what we know about the current user
+ * entrance_session_user_reset: forget what we know about the current user
  */
 void
-entrance_session_reset_user(Entrance_Session e)
+entrance_session_user_reset(Entrance_Session e)
 {
-   entrance_auth_free(e->auth);
-   e->auth = entrance_auth_new();
+   Evas_Object *obj = NULL;
+
+   if (e)
+   {
+      entrance_auth_free(e->auth);
+      e->auth = entrance_auth_new();
+      if ((obj = edje_object_part_swallow_get(e->edje, "EntranceFace")))
+      {
+         edje_object_part_unswallow(e->edje, obj);
+         evas_object_del(obj);
+      }
+      edje_object_signal_emit(e->edje, "In", "EntranceUserEntry");
+   }
+}
+
+/**
+ * entrance_session_user_set: forget what we know about the current user
+ */
+void
+entrance_session_user_set(Entrance_Session e, char *key)
+{
+   int result = 0;
+   const char *file = NULL;
+   char *pass = NULL;
+   char *session = NULL;
+   Evas_Object *obj = NULL;
+
+   if (e && key)
+   {
+      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 (!entrance_auth_set_user(e->auth, key))
+         {
+            edje_object_file_get(obj, &file, NULL);
+            if ((session = edje_file_data_get(file, "session")))
+            {
+               if ((strlen(session) > 0) && (strlen(e->session) == 0))
+               {
+                  if (e->session)
+                     free(e->session);
+                  e->session = strdup(session);
+               }
+            }
+            if ((pass = edje_file_data_get(file, "password")))
+            {
+               entrance_auth_set_pass(e->auth, pass);
+               result = entrance_session_auth_user(e);
+               if (result == 0)
+               {
+                  if (edje_object_part_exists(e->edje, "EntranceFace"))
+                  {
+                     edje_object_part_swallow(e->edje, "EntranceFace", obj);
+                  }
+                  edje_object_signal_emit(e->edje, "EntranceUserAuthSuccess",
+                                          "");
+                  e->authed = 1;
+               }
+               else
+               {
+                  edje_object_signal_emit(e->edje, "EntranceUserAuthFail",
+                                          "");
+                  evas_object_del(obj);
+               }
+            }
+            else
+            {
+               if (edje_object_part_exists(e->edje, "EntranceFace"))
+               {
+                  edje_object_part_swallow(e->edje, "EntranceFace", obj);
+               }
+               edje_object_signal_emit(e->edje, "In", "EntrancePassEntry");
+               edje_object_signal_emit(e->edje, "EntranceUserAuth", "");
+               edje_object_signal_emit(e->edje, "UserSelected", "");
+            }
+         }
+         else
+         {
+            evas_object_del(obj);
+            edje_object_signal_emit(e->edje, "In", "EntrancePassEntry");
+            edje_object_signal_emit(e->edje, "EntranceUserFail", "");
+         }
+      }
+   }
 }
 
 void
@@ -310,9 +400,6 @@
          e_container_fill_policy_set(container, CONTAINER_FILL_POLICY_FILL_X);
          e_container_direction_set(container, 1);
       }
-#if 0
-      entrance_swallow_users_to_container(container, cfg);
-#endif
       for (l = e->config->users.keys; l; l = l->next)
       {
          key = (char *) l->data;
@@ -326,15 +413,6 @@
 
 }
 
-/* 
- * 
- */
-static char *
-_entrance_session_path_resolve(Entrance_Session e, char *prefix, char *key)
-{
-   return (NULL);
-}
-
 static Evas_Object *
 _entrance_session_user_load(Entrance_Session e, char *key)
 {
@@ -349,18 +427,28 @@
 
    if ((icon = evas_hash_find(e->config->users.hash, key)))
    {
-      fprintf(stderr, "%s:%s\n", key, icon);
       edje = edje_object_add(evas_object_evas_get(e->edje));
-      snprintf(buf, PATH_MAX, "%s/users/%s", PACKAGE_DATA_DIR, icon);
+      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_object_move(edje, 0, 0);
-         evas_object_resize(edje, 48, 48);
+         Evas_Coord w, h;
+
+         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, key);
+            edje_object_signal_callback_add(edje, "UserUnSelected", "",
+                                            user_unselected_cb, key);
          }
          else
          {
@@ -370,7 +458,6 @@
                evas_object_del(edje);
             edje = NULL;
          }
-         evas_object_show(edje);
       }
       else
       {
@@ -427,8 +514,13 @@
       return (NULL);
 
    edje = edje_object_add(evas_object_evas_get(e->edje));
-   snprintf(buf, PATH_MAX, "%s/themes/%s", PACKAGE_DATA_DIR,
-            e->config->theme);
+   if (e->config->theme && e->config->theme[0] == '/') /* abs 
+          path 
+        */
+      snprintf(buf, PATH_MAX, "%s", e->config->theme);
+   else
+      snprintf(buf, PATH_MAX, "%s/themes/%s", PACKAGE_DATA_DIR,
+               e->config->theme);
    if ((result = edje_object_file_set(edje, buf, "Session")) > 0)
    {
       evas_object_move(edje, 0, 0);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_session.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- entrance_session.h  21 Oct 2003 22:36:06 -0000      1.6
+++ entrance_session.h  22 Oct 2003 12:09:57 -0000      1.7
@@ -35,10 +35,12 @@
 void entrance_session_free(Entrance_Session e);
 void entrance_session_run(Entrance_Session e);
 int entrance_session_auth_user(Entrance_Session e);
-void entrance_session_reset_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_start_user_session(Entrance_Session e);
 void entrance_session_xsession_set(Entrance_Session e, char *xsession);
 void entrance_session_edje_object_set(Entrance_Session e, Evas_Object * obj);
 void entrance_session_list_add(Entrance_Session e);
+void entrance_session_user_list_add(Entrance_Session e);
 
 #endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/main.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- main.c      22 Oct 2003 06:58:15 -0000      1.14
+++ main.c      22 Oct 2003 12:09:57 -0000      1.15
@@ -224,7 +224,7 @@
          else
          {
             evas_text_entry_text_set(o, "");
-            entrance_session_reset_user(session);
+            entrance_session_user_reset(session);
             edje_object_signal_emit(e->edje.o, "EntranceUserFail", "");
             focus_swap(o, 1);
          }
@@ -233,17 +233,7 @@
       {
          if (session->auth->user && strlen(session->auth->user) > 0)
          {
-            const char *sessionname = NULL;
-
             entrance_auth_set_pass(session->auth, str);
-            if (edje_object_part_exists(e->edje.o, "EntranceSession"))
-            {
-               sessionname =
-                  edje_object_part_text_get(e->edje.o, "EntranceSession");
-               if (session->session)
-                  free(session->session);
-               session->session = strdup(sessionname);
-            }
             if (!entrance_session_auth_user(session))
             {
                edje_object_signal_emit(e->edje.o, "EntranceUserAuthSuccess",
@@ -252,7 +242,7 @@
             }
             else
             {
-               entrance_session_reset_user(session);
+               entrance_session_user_reset(session);
                edje_object_signal_emit(e->edje.o, "EntranceUserAuthFail", "");
                focus_swap(o, 0);
             }
@@ -391,6 +381,46 @@
 }
 
 /**
+ * session_item_selected_cb - Executed when a Session is selected
+ * @data - the data passed when the callback was added
+ * @o - the evas object(Edje) that created the signal
+ * @emission - the signal "type" that was emitted
+ * @source - the signal originated from this "part"
+ * Attempt to set the Part named "EntranceTime" to the results of
+ * localtime.  This way the interval is configurable via a program in
+ * the theme and not statically bound to a value.  
+ */
+void
+user_selected_cb(void *data, Evas_Object * o, const char *emission,
+                 const char *source)
+{
+   if (session && data)
+   {
+      entrance_session_user_set(session, (char *) data);
+   }
+}
+
+/**
+ * session_item_selected_cb - Executed when a Session is selected
+ * @data - the data passed when the callback was added
+ * @o - the evas object(Edje) that created the signal
+ * @emission - the signal "type" that was emitted
+ * @source - the signal originated from this "part"
+ * Attempt to set the Part named "EntranceTime" to the results of
+ * localtime.  This way the interval is configurable via a program in
+ * the theme and not statically bound to a value.  
+ */
+void
+user_unselected_cb(void *data, Evas_Object * o, const char *emission,
+                   const char *source)
+{
+   if (session && data)
+   {
+      entrance_session_user_reset(session);
+   }
+}
+
+/**
  * reboot_cb - Executed when an EntranceSystemReboot signal is emitted
  * @data - the data passed when the callback was added
  * @o - the evas object(Edje) that created the signal
@@ -599,7 +629,7 @@
       }
       if (edje_object_part_exists(edje, "EntranceSession"))
       {
-         entrance_session_xsession_set(session, "Enlightenment");
+         entrance_session_xsession_set(session, "Default");
       }
       if (edje_object_part_exists(edje, "EntranceSessionList"))
       {
@@ -617,7 +647,7 @@
                                       shutdown_cb, e);
       /* 
        * It's useful to delay showing of your edje till all your
-       * callbacks have been added, otherwise show might trigger all
+       * callbacks have been added, otherwise show might not trigger all
        * the desired events 
        */
       evas_object_show(edje);




-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations
Here's your chance to show off your extensive product knowledge
We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to