* Ibukun Olumuyiwa ([EMAIL PROTECTED]) wrote:
> On Thu 25 Mar 2004, Corey Donohoe wrote:
> > All of these diff's looked pretty good, but ... :)
> > 
> > You don't ever seem to close the connection when you successfully
> > authenticate, so the removed entrance_ipc_shutdown() in
> > entrance_session.c should probably go back in.  
> 
> Ah, right...that shutdown doesn't happen. Will fix.
Would it be better to return the pointer to the server, and keep it
encapsulated in the Entrance_Session?  That way we can shutdown the ipc
when we cleanup the session.  hmm...
> 
> > What's the purpose of the static _session variable that was added in
> > entrance_ipc.c ?  Would it be better handled as the data variables to
> > the different IPC_EVENT types ?  I'm assuming this is just something
> > that isn't being used yet, but probably is there for checking things
> > when the callbacks roll in.
> >     
> > ecore_event_handler_add(ECORE_IPC_EVENT .., _entrance_ipc..., session);
> > 
> 
> At the time of entrance_ipc_init(), the session has not yet been
> initialized ... can't pass an empty pointer. So I have to manually set it
> afterwards using ipc_session_set(). This approach is still OK since we're
> using a static variable. That approach was what I wanted to use at first.
How about keeping the session_set function, and assigning the callbacks
at that point.  Or have the entrance_ipc_init() function also take an
Entrance_Session parameter?  See the attached diff.

__
Corey Donohoe
atmos.org
Index: entrance_ipc.c
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_ipc.c,v
retrieving revision 1.3
diff -u -r1.3 entrance_ipc.c
--- entrance_ipc.c      25 Mar 2004 06:44:52 -0000      1.3
+++ entrance_ipc.c      25 Mar 2004 15:04:16 -0000
@@ -3,11 +3,12 @@
  *========================================================================*/
 #include "entrance_ipc.h"
 
+#define TRUE 1
+#define FALSE 0
+
 #define IPC_TITLE "entrance_ipc"
 static Ecore_Ipc_Server *server = NULL;
 
-static Entrance_Session *_session = NULL;
-
 /**
  * _entrance_ipc_server_add - when we connect to the ipc daemon
  * @data -
@@ -51,7 +52,7 @@
 {
    Ecore_Ipc_Event_Server_Data *e;
 
-   if ((e = (Ecore_Ipc_Event_Server_Data *) event) && _session)
+   if ((e = (Ecore_Ipc_Event_Server_Data *) event) && data)
    {
       printf("_entrance_ipc_server_data: Received [%i] [%i] (%i) \"%s\"\n",
              e->major, e->minor, e->size, (char *) e->data);
@@ -138,7 +139,7 @@
  * itself as the server and the app should then start up.
  */
 int
-entrance_ipc_init(int argc, const char **argv)
+entrance_ipc_init(int argc, const char **argv, Entrance_Session *e)
 {
    /* we definitely fail if we can't connect to ecore_ipc */
    if (ecore_ipc_init() < 1)
@@ -148,22 +149,22 @@
         ecore_ipc_server_connect(ECORE_IPC_LOCAL_USER, IPC_TITLE, 0, NULL)))
    {
       ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, 
-                              _entrance_ipc_client_add, NULL);
+                              _entrance_ipc_client_add, e);
       
       ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL,
-                              _entrance_ipc_client_del, NULL);
+                              _entrance_ipc_client_del, e);
       
       ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA,
-                              _entrance_ipc_client_data, NULL);
+                              _entrance_ipc_client_data, e);
       
       ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA,
-                              _entrance_ipc_server_data, NULL);
+                              _entrance_ipc_server_data, e);
       
       ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD,
-                              _entrance_ipc_server_add, NULL);
+                              _entrance_ipc_server_add, e);
       
       ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DEL,
-                              _entrance_ipc_server_del, NULL);
+                              _entrance_ipc_server_del, e);
       
       
       fprintf(stderr, "entrance_ipc_init: Success\n");
@@ -191,12 +192,6 @@
 }
 
 void
-entrance_ipc_session_set(Entrance_Session *session)
-{
-   _session = session;
-}
-
-void
 entrance_ipc_request_xauth(char *homedir, uid_t uid, gid_t gid)
 {
    ecore_ipc_server_send(server, E_XAUTH_REQ, E_UID, 0, 0, (int) uid, "", 0);
Index: entrance_ipc.h
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_ipc.h,v
retrieving revision 1.3
diff -u -r1.3 entrance_ipc.h
--- entrance_ipc.h      25 Mar 2004 06:46:02 -0000      1.3
+++ entrance_ipc.h      25 Mar 2004 15:04:16 -0000
@@ -13,9 +13,8 @@
 #include "entrance_session.h"
 
 void entrance_ipc_shutdown(void);
-int  entrance_ipc_init(int argc, const char **argv);
+int  entrance_ipc_init(int argc, const char **argv, Entrance_Session *session);
 int  entrance_ipc_connected_get(void);
-void entrance_ipc_session_set(Entrance_Session *session);
 void entrance_ipc_request_xauth(char *homedir, uid_t uid, gid_t gid);
 
 #endif
Index: main.c
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/main.c,v
retrieving revision 1.47
diff -u -r1.47 main.c
--- main.c      25 Mar 2004 06:44:52 -0000      1.47
+++ main.c      25 Mar 2004 15:04:17 -0000
@@ -588,9 +588,6 @@
       return (-1);
    ecore_app_args_set(argc, (const char **) argv);
 
-   if (!entrance_ipc_init(argc, (const char **) argv))
-      return (-1);
-
    /* Parse command-line options */
    while (1)
    {
@@ -659,6 +656,9 @@
    }
 
    session = entrance_session_new(config);
+   if (!entrance_ipc_init(argc, (const char **) argv, session))
+      return (-1);
+
    if (config)
       free(config);
 
@@ -852,7 +852,6 @@
 #endif
 
       entrance_session_ecore_evas_set(session, e);
-      entrance_ipc_session_set(session);
       entrance_session_run(session);
 
       if (session->authed)

Reply via email to