chiark / gitweb /
timedated: use libsystemd-bus instead of libdbus for bus communication
[elogind.git] / src / libsystemd-bus / bus-control.c
index ae0d7f97674bfc3de9b3fd1e1d61fc0edf87f115..836570d41e0b178b5ff0212070cd066b6a2ba3e4 100644 (file)
@@ -33,6 +33,7 @@
 #include "bus-message.h"
 #include "bus-control.h"
 #include "bus-bloom.h"
+#include "bus-util.h"
 
 int sd_bus_get_unique_name(sd_bus *bus, const char **unique) {
         int r;
@@ -75,7 +76,7 @@ int sd_bus_request_name(sd_bus *bus, const char *name, int flags) {
                 l = strlen(name);
                 n = alloca0(offsetof(struct kdbus_cmd_name, name) + l + 1);
                 n->size = offsetof(struct kdbus_cmd_name, name) + l + 1;
-                n->name_flags = flags;
+                n->flags = flags;
                 memcpy(n->name, name, l+1);
 
 #ifdef HAVE_VALGRIND_MEMCHECK_H
@@ -86,7 +87,7 @@ int sd_bus_request_name(sd_bus *bus, const char *name, int flags) {
                 if (r < 0)
                         return -errno;
 
-                return n->name_flags;
+                return n->flags;
         } else {
                 r = sd_bus_call_method(
                                 bus,
@@ -142,7 +143,7 @@ int sd_bus_release_name(sd_bus *bus, const char *name) {
                 if (r < 0)
                         return -errno;
 
-                return n->name_flags;
+                return n->flags;
         } else {
                 r = sd_bus_call_method(
                                 bus,
@@ -385,12 +386,9 @@ int bus_add_match_internal(
 
                                 break;
 
-                        case BUS_MATCH_DESTINATION:
-                                /* The bloom filter does not include
-                                   the destination, since it is only
-                                   available for broadcast messages
-                                   which do not carry a destination
-                                   since they are undirected. */
+                        case BUS_MATCH_MESSAGE_TYPE:
+                                bloom_add_pair(bloom, "message-type", bus_message_type_to_string(c->value_u8));
+                                using_bloom = true;
                                 break;
 
                         case BUS_MATCH_INTERFACE:
@@ -409,15 +407,45 @@ int bus_add_match_internal(
                                 break;
 
                         case BUS_MATCH_PATH_NAMESPACE:
-                                bloom_add_pair(bloom, "path-slash-prefix", c->value_str);
+                                if (!streq(c->value_str, "/")) {
+                                        bloom_add_pair(bloom, "path-slash-prefix", c->value_str);
+                                        using_bloom = true;
+                                }
+                                break;
+
+                        case BUS_MATCH_ARG...BUS_MATCH_ARG_LAST: {
+                                char buf[sizeof("arg")-1 + 2 + 1];
+
+                                snprintf(buf, sizeof(buf), "arg%u", c->type - BUS_MATCH_ARG);
+                                bloom_add_pair(bloom, buf, c->value_str);
                                 using_bloom = true;
                                 break;
+                        }
 
-                        case BUS_MATCH_ARG...BUS_MATCH_ARG_LAST:
-                        case BUS_MATCH_ARG_PATH...BUS_MATCH_ARG_PATH_LAST:
-                        case BUS_MATCH_ARG_NAMESPACE...BUS_MATCH_ARG_NAMESPACE_LAST:
-                        case BUS_MATCH_MESSAGE_TYPE:
-                                assert_not_reached("FIXME!");
+                        case BUS_MATCH_ARG_PATH...BUS_MATCH_ARG_PATH_LAST: {
+                                char buf[sizeof("arg")-1 + 2 + sizeof("-slash-prefix")];
+
+                                snprintf(buf, sizeof(buf), "arg%u-slash-prefix", c->type - BUS_MATCH_ARG_PATH);
+                                bloom_add_pair(bloom, buf, c->value_str);
+                                using_bloom = true;
+                                break;
+                        }
+
+                        case BUS_MATCH_ARG_NAMESPACE...BUS_MATCH_ARG_NAMESPACE_LAST: {
+                                char buf[sizeof("arg")-1 + 2 + sizeof("-dot-prefix")];
+
+                                snprintf(buf, sizeof(buf), "arg%u-dot-prefix", c->type - BUS_MATCH_ARG_NAMESPACE);
+                                bloom_add_pair(bloom, buf, c->value_str);
+                                using_bloom = true;
+                                break;
+                        }
+
+                        case BUS_MATCH_DESTINATION:
+                                /* The bloom filter does not include
+                                   the destination, since it is only
+                                   available for broadcast messages
+                                   which do not carry a destination
+                                   since they are undirected. */
                                 break;
 
                         case BUS_MATCH_ROOT: