Merge "Optional autogen.sh flag --enable-kdbus-transport added allowing to compile...
[platform/upstream/dbus.git] / dbus / dbus-transport.c
index e68a9f0..6b50372 100644 (file)
@@ -2,6 +2,7 @@
 /* dbus-transport.c DBusTransport object (internal to D-Bus implementation)
  *
  * Copyright (C) 2002, 2003  Red Hat Inc.
+ * Copyright (C) 2013  Samsung Electronics
  *
  * Licensed under the Academic Free License version 2.1
  * 
@@ -21,7 +22,8 @@
  *
  */
 
-#include <config.h>
+
+#include <../config.h>
 #include "dbus-transport-protected.h"
 #include "dbus-transport-unix.h"
 #include "dbus-transport-socket.h"
@@ -32,6 +34,9 @@
 #include "dbus-credentials.h"
 #include "dbus-mainloop.h"
 #include "dbus-message.h"
+#ifdef ENABLE_KDBUS_TRANSPORT
+#include "dbus-transport-kdbus.h"
+#endif
 #ifdef DBUS_ENABLE_EMBEDDED_TESTS
 #include "dbus-server-debug-pipe.h"
 #endif
@@ -117,7 +122,21 @@ _dbus_transport_init_base (DBusTransport             *transport,
   if (server_guid)
     auth = _dbus_auth_server_new (server_guid);
   else
-    auth = _dbus_auth_client_new ();
+  {
+         _dbus_assert (address != NULL);
+         if (!_dbus_string_copy_data (address, &address_copy))
+        {
+          _dbus_message_loader_unref (loader);
+          return FALSE;
+        }
+#ifdef ENABLE_KDBUS_TRANSPORT
+      if(address_copy == strstr(address_copy, "kdbus:path="))
+         auth = _dbus_auth_client_new_kdbus();
+         else
+#endif
+                 auth = _dbus_auth_client_new ();
+  }
+
   if (auth == NULL)
     {
       _dbus_message_loader_unref (loader);
@@ -146,19 +165,6 @@ _dbus_transport_init_base (DBusTransport             *transport,
       _dbus_assert (address == NULL);
       address_copy = NULL;
     }
-  else
-    {
-      _dbus_assert (address != NULL);
-
-      if (!_dbus_string_copy_data (address, &address_copy))
-        {
-          _dbus_credentials_unref (creds);
-          _dbus_counter_unref (counter);
-          _dbus_auth_unref (auth);
-          _dbus_message_loader_unref (loader);
-          return FALSE;
-        }
-    }
   
   transport->refcount = 1;
   transport->vtable = vtable;
@@ -347,6 +353,9 @@ static const struct {
                                     DBusTransport   **transport_p,
                                     DBusError        *error);
 } open_funcs[] = {
+#ifdef ENABLE_KDBUS_TRANSPORT
+  { _dbus_transport_open_kdbus },
+#endif
   { _dbus_transport_open_socket },
   { _dbus_transport_open_platform_specific },
   { _dbus_transport_open_autolaunch }
@@ -1014,7 +1023,7 @@ recover_unused_bytes (DBusTransport *transport)
       const DBusString *encoded;
       DBusString *buffer;
       int orig_len;
-      
+
       if (!_dbus_string_init (&plaintext))
         goto nomem;
       
@@ -1027,12 +1036,12 @@ recover_unused_bytes (DBusTransport *transport)
           _dbus_string_free (&plaintext);
           goto nomem;
         }
-      
+
       _dbus_message_loader_get_buffer (transport->loader,
                                        &buffer);
       
       orig_len = _dbus_string_get_length (buffer);
-      
+
       if (!_dbus_string_move (&plaintext, 0, buffer,
                               orig_len))
         {
@@ -1064,7 +1073,7 @@ recover_unused_bytes (DBusTransport *transport)
                                        &buffer);
                 
       orig_len = _dbus_string_get_length (buffer);
-                
+
       _dbus_auth_get_unused_bytes (transport->auth,
                                    &bytes);