diff options
author | Havoc Pennington <hp@redhat.com> | 2003-03-20 07:57:39 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2003-03-20 07:57:39 +0000 |
commit | 056d76d809dc341b0dce160d3f79062604565c77 (patch) | |
tree | 1c0518c56526b71f8c4e77b97bb1b6e504339b55 /dbus/dbus-message.c | |
parent | a284a148e40551a2e6e5d0e54c2e04d2b679aaad (diff) |
2003-03-20 Havoc Pennington <hp@pobox.com>
* bus/connection.c (bus_connection_send_oom_error): assert that
message has a sender
(connection_execute_transaction): ditto
(bus_connection_preallocate_oom_error): fix to set the sender, and
set recipient to the destination service, not the bus driver
* bus/policy.c: hacking
* dbus/dbus-message.c (dbus_message_service_is): new function
(dbus_message_sender_is): new
Diffstat (limited to 'dbus/dbus-message.c')
-rw-r--r-- | dbus/dbus-message.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index defa0585..6366c54e 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -1018,6 +1018,11 @@ dbus_message_get_name (DBusMessage *message) /** * Gets the destination service of a message. * + * @todo I think if we have set_sender/get_sender, + * this function might be better named set_destination/ + * get_destination for clarity, as the sender + * is also a service name. + * * @param message the message * @returns the message destination service (should not be freed) */ @@ -2326,6 +2331,62 @@ dbus_message_name_is (DBusMessage *message, return FALSE; } +/** + * Checks whether the message was sent to the given service. If the + * message has no service specified or has a different name, returns + * #FALSE. + * + * @param message the message + * @param service the service to check (must not be #NULL) + * + * @returns #TRUE if the message has the given destination service + */ +dbus_bool_t +dbus_message_service_is (DBusMessage *message, + const char *service) +{ + const char *s; + + _dbus_assert (service != NULL); + + s = dbus_message_get_service (message); + + if (s && strcmp (s, service) == 0) + return TRUE; + else + return FALSE; +} + +/** + * Checks whether the message has the given service as its sender. If + * the message has no sender specified or has a different sender, + * returns #FALSE. Note that if a peer application owns multiple + * services, its messages will have only one of those services as the + * sender (usually the base service). So you can't use this + * function to prove the sender didn't own service Foo, you can + * only use it to prove that it did. + * + * @param message the message + * @param service the service to check (must not be #NULL) + * + * @returns #TRUE if the message has the given origin service + */ +dbus_bool_t +dbus_message_sender_is (DBusMessage *message, + const char *service) +{ + const char *s; + + _dbus_assert (service != NULL); + + s = dbus_message_get_sender (message); + + if (s && strcmp (s, service) == 0) + return TRUE; + else + return FALSE; +} + /** @} */ /** |