summaryrefslogtreecommitdiffstats
path: root/dbus
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-10-10 02:42:21 +0000
committerHavoc Pennington <hp@redhat.com>2003-10-10 02:42:21 +0000
commit6a65f4802e95ba442c520f8e225da837e0a9f73b (patch)
tree734e69da90869b3788d381e75911d720ad8cfd0f /dbus
parent79d03f94fec278d270a33792aeffb33ba239bb01 (diff)
2003-10-09 Havoc Pennington <hp@redhat.com>
Make matching rules theoretically work (add parser). * bus/bus.c (bus_context_check_security_policy): fix up to handle the case where destination is explicitly specified as bus driver and someone else is eavesdropping. * bus/policy.c (bus_client_policy_check_can_receive): fix up definition of eavesdropping and assertion * tools/dbus-send.c (main): use dbus_message_type_from_string * bus/signals.c (bus_match_rule_parse): implement * dbus/dbus-message.c (dbus_message_type_from_string): new * dbus/dbus-errors.h (DBUS_ERROR_MATCH_RULE_INVALID): add
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-errors.h1
-rw-r--r--dbus/dbus-message.c28
-rw-r--r--dbus/dbus-message.h2
3 files changed, 31 insertions, 0 deletions
diff --git a/dbus/dbus-errors.h b/dbus/dbus-errors.h
index f229188a..b7b601bf 100644
--- a/dbus/dbus-errors.h
+++ b/dbus/dbus-errors.h
@@ -73,6 +73,7 @@ struct DBusError
#define DBUS_ERROR_UNKNOWN_METHOD "org.freedesktop.DBus.Error.UnknownMethod"
#define DBUS_ERROR_TIMED_OUT "org.freedesktop.DBus.Error.TimedOut"
#define DBUS_ERROR_MATCH_RULE_NOT_FOUND "org.freedesktop.DBus.Error.MatchRuleNotFound"
+#define DBUS_ERROR_MATCH_RULE_INVALID "org.freedesktop.DBus.Error.MatchRuleInvalid"
#define DBUS_ERROR_SPAWN_EXEC_FAILED "org.freedesktop.DBus.Error.Spawn.ExecFailed"
#define DBUS_ERROR_SPAWN_FORK_FAILED "org.freedesktop.DBus.Error.Spawn.ForkFailed"
#define DBUS_ERROR_SPAWN_CHILD_EXITED "org.freedesktop.DBus.Error.Spawn.ChildExited"
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c
index 19457468..38fd3790 100644
--- a/dbus/dbus-message.c
+++ b/dbus/dbus-message.c
@@ -5416,6 +5416,34 @@ dbus_message_get_data (DBusMessage *message,
return res;
}
+/**
+ * Utility function to convert a machine-readable (not translated)
+ * string into a D-BUS message type.
+ *
+ * @code
+ * "method_call" -> DBUS_MESSAGE_TYPE_METHOD_CALL
+ * "method_return" -> DBUS_MESSAGE_TYPE_METHOD_RETURN
+ * "signal" -> DBUS_MESSAGE_TYPE_SIGNAL
+ * "error" -> DBUS_MESSAGE_TYPE_ERROR
+ * anything else -> DBUS_MESSAGE_TYPE_INVALID
+ * @endcode
+ *
+ */
+int
+dbus_message_type_from_string (const char *type_str)
+{
+ if (strcmp (type_str, "method_call") == 0)
+ return DBUS_MESSAGE_TYPE_METHOD_CALL;
+ if (strcmp (type_str, "method_return") == 0)
+ return DBUS_MESSAGE_TYPE_METHOD_RETURN;
+ else if (strcmp (type_str, "signal") == 0)
+ return DBUS_MESSAGE_TYPE_SIGNAL;
+ else if (strcmp (type_str, "error") == 0)
+ return DBUS_MESSAGE_TYPE_ERROR;
+ else
+ return DBUS_MESSAGE_TYPE_INVALID;
+}
+
/** @} */
#ifdef DBUS_BUILD_TESTS
#include "dbus-test.h"
diff --git a/dbus/dbus-message.h b/dbus/dbus-message.h
index 888fe862..bfaf2f0d 100644
--- a/dbus/dbus-message.h
+++ b/dbus/dbus-message.h
@@ -275,6 +275,8 @@ dbus_bool_t dbus_message_set_data (DBusMessage *message,
void* dbus_message_get_data (DBusMessage *message,
dbus_int32_t slot);
+int dbus_message_type_from_string (const char *type_str);
+
DBUS_END_DECLS;
#endif /* DBUS_MESSAGE_H */