From a93f9c04acedc37277ef60dc7225464b8b62f0ee Mon Sep 17 00:00:00 2001 From: "John (J5) Palmieri" Date: Wed, 15 Jun 2005 15:59:57 +0000 Subject: * dbus/dbus-message.c: (dbus_message_has_path): New method (dbus_message_has_interface): New method (dbus_message_has_member): New method * dbus/dbus/dbus-sysdeps.c (_dbus_check_dir_is_private_to_user): New method * dbus/dbus-keyring.c (_dbus_keyring_reload): Check to see that the keyring directory is private to the user * doc/TODO: - The convenience functions in dbus-bus.h should perhaps have the signatures that they would have if they were autogenerated stubs. e.g. the acquire service function. We should also evaluate which of these functions to include, in light of the fact that GLib/Qt native stubs will probably also exist.: Punted - add dbus_message_has_path(), maybe has_member/interface: fixed in this patch - in dbus-keyring.c, enforce that the keyring dir is not world readable/writable: Fixed in this patch --- dbus/dbus-message.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 'dbus/dbus-message.c') diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index cdfdf5f3..983eea93 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -2430,6 +2430,36 @@ dbus_message_get_path (DBusMessage *message) return v; } +/** + * Checks if the message has a path + * + * @param message the message + * @returns #TRUE if there is a path field in the header + */ +dbus_bool_t +dbus_message_has_path (DBusMessage *message, + const char *path) +{ + const char *msg_path; + msg_path = dbus_message_get_path (message); + + if (msg_path == NULL) + { + if (path == NULL) + return TRUE; + else + return FALSE; + } + + if (path == NULL) + return FALSE; + + if (strcmp (msg_path, path) == 0) + return TRUE; + + return FALSE; +} + /** * Gets the object path this message is being sent to * (for DBUS_MESSAGE_TYPE_METHOD_CALL) or being emitted @@ -2520,6 +2550,37 @@ dbus_message_get_interface (DBusMessage *message) return v; } +/** + * Checks if the message has an interface + * + * @param message the message + * @returns #TRUE if there is a interface field in the header + */ +dbus_bool_t +dbus_message_has_interface (DBusMessage *message, + const char *interface) +{ + const char *msg_interface; + msg_interface = dbus_message_get_interface (message); + + if (msg_interface == NULL) + { + if (interface == NULL) + return TRUE; + else + return FALSE; + } + + if (interface == NULL) + return FALSE; + + if (strcmp (msg_interface, interface) == 0) + return TRUE; + + return FALSE; + +} + /** * Sets the interface member being invoked * (DBUS_MESSAGE_TYPE_METHOD_CALL) or emitted @@ -2569,6 +2630,37 @@ dbus_message_get_member (DBusMessage *message) return v; } +/** + * Checks if the message has an interface member + * + * @param message the message + * @returns #TRUE if there is a member field in the header + */ +dbus_bool_t +dbus_message_has_member (DBusMessage *message, + const char *member) +{ + const char *msg_member; + msg_member = dbus_message_get_member (message); + + if (msg_member == NULL) + { + if (member == NULL) + return TRUE; + else + return FALSE; + } + + if (member == NULL) + return FALSE; + + if (strcmp (msg_member, member) == 0) + return TRUE; + + return FALSE; + +} + /** * Sets the name of the error (DBUS_MESSAGE_TYPE_ERROR). * The name is fully-qualified (namespaced). -- cgit