* dbus/dbus-connection.c (_dbus_connection_peer_filter): New method
authorJohn (J5) Palmieri <johnp@redhat.com>
Wed, 15 Jun 2005 16:20:28 +0000 (16:20 +0000)
committerJohn (J5) Palmieri <johnp@redhat.com>
Wed, 15 Jun 2005 16:20:28 +0000 (16:20 +0000)
        (_dbus_connection_run_builtin_filters): New method
        (dbus_connection_dispatch): Run the builtin filters which in turn
        runs the peer filter which handles Ping messages.

        * doc/TODO:
         - Ping isn't handled: This patch fixes it

         - Add a test case for the Ping message: added TODO item

ChangeLog
dbus/dbus-connection.c
doc/TODO

index 9875c60..324f7b5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2005-06-15  John (J5) Palmieri  <johnp@redhat.com>
 
+       * dbus/dbus-connection.c (_dbus_connection_peer_filter): New method 
+       (_dbus_connection_run_builtin_filters): New method
+       (dbus_connection_dispatch): Run the builtin filters which in turn
+       runs the peer filter which handles Ping messages.
+
+       * doc/TODO: 
+        - Ping isn't handled: This patch fixes it
+        
+        - Add a test case for the Ping message: added TODO item
+
+2005-06-15  John (J5) Palmieri  <johnp@redhat.com>
+
        * dbus/dbus-message.c:
        (dbus_message_has_path): New method
        (dbus_message_has_interface): New method
index b2bc6a7..10a2d0f 100644 (file)
@@ -3362,6 +3362,53 @@ dbus_connection_get_dispatch_status (DBusConnection *connection)
 }
 
 /**
+* Filter funtion for handling the Peer standard interface
+**/
+static DBusHandlerResult
+_dbus_connection_peer_filter (DBusConnection *connection,
+                              DBusMessage    *message)
+{
+  if (dbus_message_is_method_call (message,
+                                   DBUS_INTERFACE_PEER,
+                                   "Ping"))
+    {
+      DBusMessage *ret;
+      dbus_bool_t sent;
+      
+      ret = dbus_message_new_method_return (message);
+      if (ret == NULL)
+        return DBUS_HANDLER_RESULT_NEED_MEMORY;
+      
+      sent = dbus_connection_send (connection, ret, NULL);
+      dbus_message_unref (ret);
+
+      if (!sent)
+        return DBUS_HANDLER_RESULT_NEED_MEMORY;
+      
+      return DBUS_HANDLER_RESULT_HANDLED;
+    }
+                                   
+  
+  return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+/**
+* Processes all builtin filter functions
+*
+* If the spec specifies a standard interface
+* they should be processed from this method
+**/
+static DBusHandlerResult
+_dbus_connection_run_builtin_filters (DBusConnection *connection,
+                                      DBusMessage    *message)
+{
+  /* We just run one filter for now but have the option to run more
+     if the spec calls for it in the future */
+
+  return _dbus_connection_peer_filter (connection, message);
+}
+
+/**
  * Processes data buffered while handling watches, queueing zero or
  * more incoming messages. Then pops the first-received message from
  * the current incoming message queue, runs any handlers for it, and
@@ -3469,7 +3516,11 @@ dbus_connection_dispatch (DBusConnection *connection)
       result = DBUS_HANDLER_RESULT_HANDLED;
       goto out;
     }
-  
+  result = _dbus_connection_run_builtin_filters (connection, message);
+  if (result != DBUS_HANDLER_RESULT_NOT_YET_HANDLED)
+    goto out;
   if (!_dbus_list_copy (&connection->filter_list, &filter_list_copy))
     {
       _dbus_connection_release_dispatch (connection);
index 7eedcd4..e88d78f 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -18,16 +18,13 @@ Important for 1.0
 
  - just before 1.0, try a HAVE_INT64=0 build and be sure it runs
 
- - in dbus-keyring.c, enforce that the keyring dir is not 
-   world readable/writable
-
- - Ping isn't handled
-
  - dbus-pending-call.c has some API and thread safety issues to review
 
  - Add test harness for selinux allow/deny cf. this message
    http://lists.freedesktop.org/archives/dbus/2005-April/002506.html
 
+ - Add a test case for handling the Ping message 
+
 Important for 1.0 GLib Bindings
 ===