Merge "Optional autogen.sh flag --enable-kdbus-transport added allowing to compile...
[platform/upstream/dbus.git] / dbus / dbus-transport-socket.c
index adebbf9..bd19f9b 100644 (file)
@@ -29,7 +29,6 @@
 #include "dbus-transport-protected.h"
 #include "dbus-watch.h"
 #include "dbus-credentials.h"
-#include <stdio.h>  //todo to remove
 
 /**
  * @defgroup DBusTransportSocket DBusTransport implementations for sockets
@@ -136,7 +135,7 @@ check_write_watch (DBusTransport *transport)
   
   _dbus_transport_ref (transport);
 
-  if (_dbus_transport_get_is_authenticated (transport))
+  if (_dbus_transport_try_to_authenticate (transport))
     needed = _dbus_connection_has_messages_to_send_unlocked (transport->connection);
   else
     {
@@ -191,7 +190,7 @@ check_read_watch (DBusTransport *transport)
   
   _dbus_transport_ref (transport);
 
-  if (_dbus_transport_get_is_authenticated (transport))
+  if (_dbus_transport_try_to_authenticate (transport))
     need_read_watch =
       (_dbus_counter_get_size_value (transport->live_messages) < transport->max_live_messages_size) &&
       (_dbus_counter_get_unix_fd_value (transport->live_messages) < transport->max_live_messages_unix_fds);
@@ -405,7 +404,7 @@ do_authentication (DBusTransport *transport,
 
   oom = FALSE;
   
-  orig_auth_state = _dbus_transport_get_is_authenticated (transport);
+  orig_auth_state = _dbus_transport_try_to_authenticate (transport);
 
   /* This is essential to avoid the check_write_watch() at the end,
    * we don't want to add a write watch in do_iteration before
@@ -420,7 +419,7 @@ do_authentication (DBusTransport *transport,
   
   _dbus_transport_ref (transport);
   
-  while (!_dbus_transport_get_is_authenticated (transport) &&
+  while (!_dbus_transport_try_to_authenticate (transport) &&
          _dbus_transport_get_is_connected (transport))
     {      
       if (!exchange_credentials (transport, do_reading, do_writing))
@@ -478,7 +477,7 @@ do_authentication (DBusTransport *transport,
 
  out:
   if (auth_completed)
-    *auth_completed = (orig_auth_state != _dbus_transport_get_is_authenticated (transport));
+    *auth_completed = (orig_auth_state != _dbus_transport_try_to_authenticate (transport));
   
   check_read_watch (transport);
   check_write_watch (transport);
@@ -499,7 +498,7 @@ do_writing (DBusTransport *transport)
   dbus_bool_t oom;
   
   /* No messages without authentication! */
-  if (!_dbus_transport_get_is_authenticated (transport))
+  if (!_dbus_transport_try_to_authenticate (transport))
     {
       _dbus_verbose ("Not authenticated, not writing anything\n");
       return TRUE;
@@ -530,8 +529,6 @@ do_writing (DBusTransport *transport)
       int header_len, body_len;
       int total_bytes_to_write;
       
-//      int i;
-
       if (total > socket_transport->max_bytes_written_per_iteration)
         {
           _dbus_verbose ("%d bytes exceeds %d bytes written per iteration, returning\n",
@@ -553,32 +550,6 @@ do_writing (DBusTransport *transport)
       header_len = _dbus_string_get_length (header);
       body_len = _dbus_string_get_length (body);
 
-  /*    fprintf (stderr, "\nheader:\n");  //todo for test - to remove together wit int i declaration above
-      for(i=0; i < header_len; i++)
-      {
-       fprintf (stderr, "%02x", _dbus_string_get_byte(header,i));
-      }
-      fprintf (stderr,"\n");
-      for(i=0; i < header_len; i++)
-      {
-       fprintf (stderr, "%c", _dbus_string_get_byte(header,i));
-      }
-      fprintf (stderr, "\nret size: %u, i: %u\n", header_len, i);
-
-
-      fprintf (stderr, "\nbody:\n");
-      for(i=0; i < body_len; i++)
-      {
-       fprintf (stderr, "%02x", _dbus_string_get_byte(body,i));
-      }
-      fprintf (stderr, "\nret size: %u, i: %u\n", body_len, i);
-      fprintf (stderr,"\n");
-      for(i=0; i < body_len; i++)
-      {
-       fprintf (stderr, "%c", _dbus_string_get_byte(body,i));
-      }
-      fprintf (stderr, "\nret size: %u, i: %u\n", body_len, i);*/
-
       if (_dbus_auth_needs_encoding (transport->auth))
         {
           /* Does fd passing even make sense with encoded data? */
@@ -732,7 +703,7 @@ do_reading (DBusTransport *transport)
   _dbus_verbose ("fd = %d\n",socket_transport->fd);
   
   /* No messages without authentication! */
-  if (!_dbus_transport_get_is_authenticated (transport))
+  if (!_dbus_transport_try_to_authenticate (transport))
     return TRUE;
 
   oom = FALSE;
@@ -1084,7 +1055,7 @@ socket_do_iteration (DBusTransport *transport,
   poll_fd.fd = socket_transport->fd;
   poll_fd.events = 0;
   
-  if (_dbus_transport_get_is_authenticated (transport))
+  if (_dbus_transport_try_to_authenticate (transport))
     {
       /* This is kind of a hack; if we have stuff to write, then try
        * to avoid the poll. This is probably about a 5% speedup on an
@@ -1328,7 +1299,7 @@ _dbus_transport_new_for_socket (int               fd,
  * @param host the host to connect to
  * @param port the port to connect to
  * @param family the address family to connect to
- * @param path to nonce file
+ * @param noncefile path to nonce file
  * @param error location to store reason for failure.
  * @returns a new transport, or #NULL on failure.
  */