Enlightenment CVS committal

Author  : rephorm
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore_con


Modified Files:
        Ecore_Con.h ecore_con.c ecore_con_private.h 


Log Message:

Add abstract socket namespace support to ecore_con.
Lots of work on ecore_dbus
Hilights:
  - get the socket address for system/session/startup busses from the 
environment
  - can request/release a bus name
  - receive method calls (we need to add a way to register callbacks for 
specific methods)
  - send signals and method replies (untested)

*** API BREAKAGE ***
ecore_dbus_message_new_method_call() - the 'destination' param has moved to 
after the 'method' param to keep things consistent with newly supported message 
types and the param ordering in the spec.

===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_con/Ecore_Con.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- Ecore_Con.h 30 Mar 2006 06:48:45 -0000      1.18
+++ Ecore_Con.h 24 Sep 2006 07:24:52 -0000      1.19
@@ -1,3 +1,6 @@
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
 #ifndef _ECORE_CON_H
 #define _ECORE_CON_H
 
@@ -69,9 +72,14 @@
    typedef enum _Ecore_Con_Type
      {
        ECORE_CON_LOCAL_USER,
-         ECORE_CON_LOCAL_SYSTEM,
-         ECORE_CON_REMOTE_SYSTEM,
-         ECORE_CON_USE_SSL = 16
+       ECORE_CON_LOCAL_SYSTEM,
+#ifdef HAVE_ABSTRACT_SOCKETS
+       ECORE_CON_LOCAL_ABSTRACT,
+#endif
+       ECORE_CON_REMOTE_SYSTEM
+#ifdef USE_OPENSSL
+       ,ECORE_CON_USE_SSL = 16
+#endif
      } Ecore_Con_Type;
    
 #endif
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_con/ecore_con.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -3 -r1.78 -r1.79
--- ecore_con.c 20 Jul 2006 16:47:02 -0000      1.78
+++ ecore_con.c 24 Sep 2006 07:24:52 -0000      1.79
@@ -53,6 +53,7 @@
 static int ssl_init_count = 0;
 
 #define LENGTH_OF_SOCKADDR_UN(s) (strlen((s)->sun_path) + (size_t)(((struct 
sockaddr_un *)NULL)->sun_path))
+#define LENGTH_OF_ABSTRACT_SOCKADDR_UN(s, path) (strlen(path) + 1 + 
(size_t)(((struct sockaddr_un *)NULL)->sun_path))
 
 /**
  * @defgroup Ecore_Con_Lib_Group Ecore Connection Library Functions
@@ -168,18 +169,24 @@
    /* unset the SSL flag for the following checks */
    type &= ~ECORE_CON_USE_SSL;
 #endif
-   
+  
    if ((type == ECORE_CON_LOCAL_USER) ||
-       (type == ECORE_CON_LOCAL_SYSTEM))
+       (type == ECORE_CON_LOCAL_SYSTEM)
+#ifdef HAVE_ABSTRACT_SOCKETS
+       || (type == ECORE_CON_LOCAL_ABSTRACT)
+#endif
+       )
      {
        const char *homedir;
        struct stat st;
        mode_t pmode, mask;
+       int socket_unix_len;
        
        if (!name) goto error;
        mask =
          S_IRGRP | S_IWGRP | S_IXGRP |
          S_IROTH | S_IWOTH | S_IXOTH;
+
        if (type == ECORE_CON_LOCAL_USER)
          {
             homedir = getenv("HOME");
@@ -229,11 +236,28 @@
             goto error;
          }
        socket_unix.sun_family = AF_UNIX;
-       strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
-       if (bind(svr->fd, (struct sockaddr *)&socket_unix, 
LENGTH_OF_SOCKADDR_UN(&socket_unix)) < 0)
+#ifdef HAVE_ABSTRACT_SOCKET
+       if (type == ECORE_CON_LOCAL_ABSTRACT)
+         {
+            /* . is a placeholder */
+            snprintf(socket_unix.sun_path, sizeof(socket_unix.sun_path), 
".%s", name);
+            /* first char null indicates abstract namespace */
+            socket_unix.sun_path[0] = '\0'; 
+            socket_unix_len = LENGTH_OF_ABSTRACT_SOCKADDR_UN(&socket_unix, 
name);
+         }
+       else
+         {
+            strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
+            socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix);
+         }
+#else
+        strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
+        socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix);
+#endif
+       if (bind(svr->fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0)
          {
             if (connect(svr->fd, (struct sockaddr *)&socket_unix, 
-                        LENGTH_OF_SOCKADDR_UN(&socket_unix)) < 0)
+                        socket_unix_len) < 0)
               {
                  if ((type == ECORE_CON_LOCAL_USER) ||
                      (type == ECORE_CON_LOCAL_SYSTEM))
@@ -401,9 +425,14 @@
    if ((type == ECORE_CON_REMOTE_SYSTEM) && (port < 0)) return NULL;
 
    if ((type == ECORE_CON_LOCAL_USER) ||
-       (type == ECORE_CON_LOCAL_SYSTEM))
+       (type == ECORE_CON_LOCAL_SYSTEM)
+#ifdef HAVE_ABSTRACT_SOCKETS
+       || (type == ECORE_CON_LOCAL_ABSTRACT)
+#endif
+       )
      {
        const char *homedir;
+       int socket_unix_len;
        
        if (type == ECORE_CON_LOCAL_USER)
          {
@@ -435,8 +464,26 @@
        if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0) goto error;
        if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, &curstate, 
sizeof(curstate)) < 0) goto error;
        socket_unix.sun_family = AF_UNIX;
-       strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
-       if (connect(svr->fd, (struct sockaddr *)&socket_unix, 
LENGTH_OF_SOCKADDR_UN(&socket_unix)) < 0) goto error;
+
+#ifdef HAVE_ABSTRACT_SOCKETS
+       if (type == ECORE_CON_LOCAL_ABSTRACT)
+         {
+            /* copy name insto sun_path, prefixed by null to indicate abstract 
namespace */
+            snprintf(socket_unix.sun_path, sizeof(socket_unix.sun_path), 
".%s", name);
+            socket_unix.sun_path[0] = '\0';
+            socket_unix_len = LENGTH_OF_ABSTRACT_SOCKADDR_UN(&socket_unix, 
name);
+         }
+       else
+         {
+            strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
+            socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix);
+         }
+#else
+        strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
+        socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix);
+#endif
+
+       if (connect(svr->fd, (struct sockaddr *)&socket_unix, socket_unix_len) 
< 0) goto error;
        svr->path = strdup(buf);
        if (!svr->path) goto error;
        svr->fd_handler = ecore_main_fd_handler_add(svr->fd,
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_con/ecore_con_private.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- ecore_con_private.h 20 Mar 2006 07:45:58 -0000      1.14
+++ ecore_con_private.h 24 Sep 2006 07:24:52 -0000      1.15
@@ -27,6 +27,9 @@
 {
    ECORE_CON_LOCAL_USER,
    ECORE_CON_LOCAL_SYSTEM,
+#ifdef HAVE_ABSTRACT_SOCKETS
+   ECORE_CON_LOCAL_ABSTRACT,
+#endif
    ECORE_CON_REMOTE_SYSTEM
 #if USE_OPENSSL
   ,ECORE_CON_USE_SSL = 16



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to