[gnome-keyring/dbus-api] DBus messages can be hanlded without a response.



commit ff101ebe9350417addeba00b41377125486c957a
Author: Stef Walter <stef memberwebs com>
Date:   Sat Oct 24 01:55:38 2009 +0000

    DBus messages can be hanlded without a response.

 daemon/dbus/gkd-dbus-util.c       |   22 ++++++++++++++++++++++
 daemon/dbus/gkd-dbus-util.h       |    4 ++++
 daemon/dbus/gkd-secrets-service.c |   12 +++++++-----
 3 files changed, 33 insertions(+), 5 deletions(-)
---
diff --git a/daemon/dbus/gkd-dbus-util.c b/daemon/dbus/gkd-dbus-util.c
index 6f16446..a92157b 100644
--- a/daemon/dbus/gkd-dbus-util.c
+++ b/daemon/dbus/gkd-dbus-util.c
@@ -84,3 +84,25 @@ gkd_dbus_introspect_handle (DBusMessage *message, const gchar *type)
 
 	return NULL;
 }
+
+static dbus_int32_t handled_slot = -1;
+
+void
+gkd_dbus_message_mark_handled (DBusMessage *message)
+{
+	g_return_if_fail (message);
+	if (handled_slot == -1) {
+		if (!dbus_message_allocate_data_slot (&handled_slot))
+			g_assert_not_reached ();
+	}
+	dbus_message_set_data (message, handled_slot, "TRUE", NULL);
+}
+
+gboolean
+gkd_dbus_message_is_handled (DBusMessage *message)
+{
+	g_return_val_if_fail (message, FALSE);
+	if (handled_slot == -1)
+		return FALSE;
+	return dbus_message_get_data (message, handled_slot) ? TRUE : FALSE;
+}
diff --git a/daemon/dbus/gkd-dbus-util.h b/daemon/dbus/gkd-dbus-util.h
index 0bc0702..5b90de0 100644
--- a/daemon/dbus/gkd-dbus-util.h
+++ b/daemon/dbus/gkd-dbus-util.h
@@ -36,4 +36,8 @@ gboolean      gkd_dbus_interface_match                    (const gchar *interfac
 
 DBusMessage*  gkd_dbus_introspect_handle                  (DBusMessage *message, const gchar *type);
 
+void          gkd_dbus_message_mark_handled               (DBusMessage *message);
+
+gboolean      gkd_dbus_message_is_handled                 (DBusMessage *message);
+
 #endif /* GKD_DBUS_H */
diff --git a/daemon/dbus/gkd-secrets-service.c b/daemon/dbus/gkd-secrets-service.c
index 5282dea..b27d0e3 100644
--- a/daemon/dbus/gkd-secrets-service.c
+++ b/daemon/dbus/gkd-secrets-service.c
@@ -465,11 +465,13 @@ service_dispatch_message (GkdSecretsService *self, DBusMessage *message)
 
 	/* Should we send an error? */
 	if (!reply && dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_CALL) {
-		reply = dbus_message_new_error_printf (message, DBUS_ERROR_UNKNOWN_METHOD, 
-		                                       "Method \"%s\" with signature \"%s\" on interface \"%s\" doesn't exist\n",
-		                                       dbus_message_get_member (message),
-		                                       dbus_message_get_signature (message),
-		                                       dbus_message_get_interface (message));
+		if (!dbus_message_get_no_reply (message) && !gkd_dbus_message_is_handled (message)) {
+			reply = dbus_message_new_error_printf (message, DBUS_ERROR_UNKNOWN_METHOD, 
+			                                       "Method \"%s\" with signature \"%s\" on interface \"%s\" doesn't exist\n",
+			                                       dbus_message_get_member (message),
+			                                       dbus_message_get_signature (message),
+			                                       dbus_message_get_interface (message));
+		}
 	}
 
 	if (reply) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]