]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
2007-06-18 Havoc Pennington <hp@redhat.com>
authorHavoc Pennington <hp@redhat.com>
Mon, 18 Jun 2007 16:24:03 +0000 (16:24 +0000)
committerHavoc Pennington <hp@redhat.com>
Mon, 18 Jun 2007 16:24:03 +0000 (16:24 +0000)
* dbus/dbus-watch.c (dbus_watch_get_socket)
(dbus_watch_get_unix_fd): new API to match DBusConnection
(dbus_watch_get_fd): deprecate this

Throughout: just s/dbus_watch_get_fd/dbus_watch_get_socket/g for
now since all the transports use sockets anyway

ChangeLog
dbus/dbus-connection.c
dbus/dbus-connection.h
dbus/dbus-mainloop.c
dbus/dbus-server-socket.c
dbus/dbus-spawn.c
dbus/dbus-transport-socket.c
dbus/dbus-transport.c
dbus/dbus-watch.c

index 93982b72fc95aae2dfc3ec9f0b4e627a85fe932c..1af3af7e12142fab0cef9a80fb06feb1dd56570d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-06-18  Havoc Pennington  <hp@redhat.com>
+
+       * dbus/dbus-watch.c (dbus_watch_get_socket)
+       (dbus_watch_get_unix_fd): new API to match DBusConnection
+       (dbus_watch_get_fd): deprecate this
+
+       Throughout: just s/dbus_watch_get_fd/dbus_watch_get_socket/g for
+       now since all the transports use sockets anyway
+       
 2007-06-16  Ralf Habacker  <ralf.habacker@freenet.de>
 
        * dbus/dbus-macros.h, dbus/dbus-message.c, 
index 656f75023e1bcbdf4c2285c63e005950ec288655..484873e6918704bfb7f457df9709314f8bdd6f25 100644 (file)
@@ -4475,12 +4475,13 @@ dbus_connection_dispatch (DBusConnection *connection)
  * dbus_watch_get_enabled() every time anyway.
  * 
  * The DBusWatch can be queried for the file descriptor to watch using
- * dbus_watch_get_fd(), and for the events to watch for using
- * dbus_watch_get_flags(). The flags returned by
- * dbus_watch_get_flags() will only contain DBUS_WATCH_READABLE and
- * DBUS_WATCH_WRITABLE, never DBUS_WATCH_HANGUP or DBUS_WATCH_ERROR;
- * all watches implicitly include a watch for hangups, errors, and
- * other exceptional conditions.
+ * dbus_watch_get_unix_fd() or dbus_watch_get_socket(), and for the
+ * events to watch for using dbus_watch_get_flags(). The flags
+ * returned by dbus_watch_get_flags() will only contain
+ * DBUS_WATCH_READABLE and DBUS_WATCH_WRITABLE, never
+ * DBUS_WATCH_HANGUP or DBUS_WATCH_ERROR; all watches implicitly
+ * include a watch for hangups, errors, and other exceptional
+ * conditions.
  *
  * Once a file descriptor becomes readable or writable, or an exception
  * occurs, dbus_watch_handle() should be called to
@@ -4732,7 +4733,7 @@ dbus_connection_set_dispatch_status_function (DBusConnection             *connec
  * example. DO NOT read or write to the file descriptor, or try to
  * select() on it; use DBusWatch for main loop integration. Not all
  * connections will have a file descriptor. So for adding descriptors
- * to the main loop, use dbus_watch_get_fd() and so forth.
+ * to the main loop, use dbus_watch_get_unix_fd() and so forth.
  *
  * If the connection is socket-based, you can also use
  * dbus_connection_get_socket(), which will work on Windows too.
@@ -4765,7 +4766,7 @@ dbus_connection_get_unix_fd (DBusConnection *connection,
  * of the connection, if any. DO NOT read or write to the file descriptor, or try to
  * select() on it; use DBusWatch for main loop integration. Not all
  * connections will have a socket. So for adding descriptors
- * to the main loop, use dbus_watch_get_fd() and so forth.
+ * to the main loop, use dbus_watch_get_socket() and so forth.
  *
  * If the connection is not socket-based, this function will return FALSE,
  * even if the connection does have a file descriptor of some kind.
index 533ac98d148a39a0be940cbb142cb8c173fb3422..ec227604d1c4fe6e087e543386931e8fa8f2687f 100644 (file)
@@ -352,7 +352,12 @@ dbus_bool_t dbus_connection_get_socket             (DBusConnection
  * @{
  */
 
-int          dbus_watch_get_fd      (DBusWatch        *watch);
+#ifndef DBUS_DISABLE_DEPRECATED
+DBUS_DEPRECATED int dbus_watch_get_fd      (DBusWatch        *watch);
+#endif
+
+int          dbus_watch_get_unix_fd (DBusWatch        *watch);
+int          dbus_watch_get_socket  (DBusWatch        *watch);
 unsigned int dbus_watch_get_flags   (DBusWatch        *watch);
 void*        dbus_watch_get_data    (DBusWatch        *watch);
 void         dbus_watch_set_data    (DBusWatch        *watch,
index 682844747f2f32386307853217f3df22e3478704..73d411e015bb418368b232e38531b559c5850238 100644 (file)
@@ -598,7 +598,7 @@ _dbus_loop_iterate (DBusLoop     *loop,
 
 #if MAINLOOP_SPEW
               _dbus_verbose ("  skipping watch on fd %d as it was out of memory last time\n",
-                             dbus_watch_get_fd (wcb->watch));
+                             dbus_watch_get_socket (wcb->watch));
 #endif
             }
           else if (dbus_watch_get_enabled (wcb->watch))
@@ -609,7 +609,7 @@ _dbus_loop_iterate (DBusLoop     *loop,
                   
               flags = dbus_watch_get_flags (wcb->watch);
                   
-              fds[n_fds].fd = dbus_watch_get_fd (wcb->watch);
+              fds[n_fds].fd = dbus_watch_get_socket (wcb->watch);
               fds[n_fds].revents = 0;
               fds[n_fds].events = 0;
               if (flags & DBUS_WATCH_READABLE)
@@ -628,7 +628,7 @@ _dbus_loop_iterate (DBusLoop     *loop,
             {
 #if MAINLOOP_SPEW
               _dbus_verbose ("  skipping disabled watch on fd %d  %s\n",
-                             dbus_watch_get_fd (wcb->watch),
+                             dbus_watch_get_socket (wcb->watch),
                              watch_flags_to_string (dbus_watch_get_flags (wcb->watch)));
 #endif
             }
index 3897f0db52a93971d692b3f672828a86240971ec..1840e49fc7c93c64588d34bb8956f1a9fd34f7cc 100644 (file)
@@ -161,7 +161,7 @@ socket_handle_watch (DBusWatch    *watch,
       int client_fd;
       int listen_fd;
       
-      listen_fd = dbus_watch_get_fd (watch);
+      listen_fd = dbus_watch_get_socket (watch);
 
       client_fd = _dbus_accept (listen_fd);
       
index 74358185383a590bdc7ad40df8d20cb7de0e06e9..2c901c126ebd757a256dc8e4c26ad4397607122a 100644 (file)
@@ -722,7 +722,7 @@ handle_watch (DBusWatch       *watch,
   if (condition & DBUS_WATCH_HANGUP)
     revents |= _DBUS_POLLHUP;
 
-  fd = dbus_watch_get_fd (watch);
+  fd = dbus_watch_get_socket (watch);
 
   if (fd == sitter->error_pipe_from_child)
     handle_error_pipe (sitter, revents);
index 31a41e1fb8e5ba46a5389534e90e605f443c9e27..5ef4e8bf6f1f68e403ad470b3726af17a79d4c79 100644 (file)
@@ -880,7 +880,7 @@ socket_handle_watch (DBusTransport *transport,
                        flags);
       else
         _dbus_verbose ("asked to handle watch %p on fd %d that we don't recognize\n",
-                       watch, dbus_watch_get_fd (watch));
+                       watch, dbus_watch_get_socket (watch));
     }
 #endif /* DBUS_ENABLE_VERBOSE_MODE */
 
index 0e27dd13e6e4277a19dac6590c59086e36b95b1f..3edef9374d5acc4d96578e9abc26c86dc73777b3 100644 (file)
@@ -812,7 +812,7 @@ _dbus_transport_handle_watch (DBusTransport           *transport,
   if (transport->disconnected)
     return TRUE;
 
-  if (dbus_watch_get_fd (watch) < 0)
+  if (dbus_watch_get_socket (watch) < 0)
     {
       _dbus_warn_check_failed ("Tried to handle an invalidated watch; this watch should have been removed\n");
       return TRUE;
index f2691c8251883e7b5a01147fe0d556be7b13e94d..7ec0661cb268b83ebb8a64dedb241f1eb2f7f065 100644 (file)
@@ -286,7 +286,7 @@ _dbus_watch_list_set_functions (DBusWatchList           *watch_list,
             
             _dbus_verbose ("Adding a %s watch on fd %d using newly-set add watch function\n",
                            watch_type,
-                           dbus_watch_get_fd (link->data));
+                           dbus_watch_get_socket (link->data));
           }
 #endif /* DBUS_ENABLE_VERBOSE_MODE */
           
@@ -302,7 +302,7 @@ _dbus_watch_list_set_functions (DBusWatchList           *watch_list,
                                                              link2);
                   
                   _dbus_verbose ("Removing watch on fd %d using newly-set remove function because initial add failed\n",
-                                 dbus_watch_get_fd (link2->data));
+                                 dbus_watch_get_socket (link2->data));
                   
                   (* remove_function) (link2->data, data);
                   
@@ -359,7 +359,7 @@ _dbus_watch_list_add_watch (DBusWatchList *watch_list,
   if (watch_list->add_watch_function != NULL)
     {
       _dbus_verbose ("Adding watch on fd %d\n",
-                     dbus_watch_get_fd (watch));
+                     dbus_watch_get_socket (watch));
       
       if (!(* watch_list->add_watch_function) (watch,
                                                watch_list->watch_data))
@@ -390,7 +390,7 @@ _dbus_watch_list_remove_watch  (DBusWatchList *watch_list,
   if (watch_list->remove_watch_function != NULL)
     {
       _dbus_verbose ("Removing watch on fd %d\n",
-                     dbus_watch_get_fd (watch));
+                     dbus_watch_get_socket (watch));
       
       (* watch_list->remove_watch_function) (watch,
                                              watch_list->watch_data);
@@ -422,7 +422,7 @@ _dbus_watch_list_toggle_watch (DBusWatchList           *watch_list,
   if (watch_list->watch_toggled_function != NULL)
     {
       _dbus_verbose ("Toggling watch %p on fd %d to %d\n",
-                     watch, dbus_watch_get_fd (watch), watch->enabled);
+                     watch, dbus_watch_get_socket (watch), watch->enabled);
       
       (* watch_list->watch_toggled_function) (watch,
                                               watch_list->watch_data);
@@ -481,16 +481,59 @@ _dbus_watch_set_handler (DBusWatch        *watch,
  */
 
 /**
- * Gets the file descriptor that should be watched.
- *
- * On Windows, this will be a socket. On UNIX right now it will be a
- * socket but in principle it could be something else.
+ * Deprecated former name of dbus_watch_get_unix_fd().
  * 
  * @param watch the DBusWatch object.
  * @returns the file descriptor to watch.
  */
 int
 dbus_watch_get_fd (DBusWatch *watch)
+{
+  return dbus_watch_get_unix_fd (watch);
+}
+
+/**
+ * Returns a UNIX file descriptor to be watched,
+ * which may be a pipe, socket, or other type of
+ * descriptor. On UNIX this is preferred to
+ * dbus_watch_get_socket() since it works with
+ * more kinds of #DBusWatch.
+ *
+ * Always returns -1 on Windows. On Windows you use
+ * dbus_watch_get_socket() to get a Winsock socket to watch.
+ * 
+ * @param watch the DBusWatch object.
+ * @returns the file descriptor to watch.
+ */
+int
+dbus_watch_get_unix_fd (DBusWatch *watch)
+{
+  /* FIXME remove #ifdef and do this on a lower level
+   * (watch should have set_socket and set_unix_fd and track
+   * which it has, and the transport should provide the
+   * appropriate watch type)
+   */
+#ifdef DBUS_UNIX
+  return watch->fd;
+#else
+  return -1;
+#endif
+}
+
+/**
+ * Returns a socket to be watched, on UNIX this will return -1 if our
+ * transport is not socket-based so dbus_watch_get_unix_fd() is
+ * preferred.
+ *
+ * On Windows, dbus_watch_get_unix_fd() returns -1 but this function
+ * returns a Winsock socket (assuming the transport is socket-based,
+ * as it always is for now).
+ * 
+ * @param watch the DBusWatch object.
+ * @returns the socket to watch.
+ */
+int
+dbus_watch_get_socket (DBusWatch *watch)
 {
   return watch->fd;
 }
@@ -546,7 +589,7 @@ dbus_watch_set_data (DBusWatch        *watch,
                      DBusFreeFunction  free_data_function)
 {
   _dbus_verbose ("Setting watch fd %d data to data = %p function = %p from data = %p function = %p\n",
-                 dbus_watch_get_fd (watch),
+                 dbus_watch_get_socket (watch),
                  data, free_data_function, watch->data, watch->free_data_function);
   
   if (watch->free_data_function != NULL)