public inbox for ell@lists.linux.dev
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: ell@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH 1/2] dbus: add _dbus_object_tree_set_interface_data
Date: Wed,  7 Aug 2024 10:59:42 -0700	[thread overview]
Message-ID: <20240807175943.170002-1-prestwoj@gmail.com> (raw)

This is to prep for l_dbus_object_set_data(), i.e. modifying the
user_data of an existing dbus object.
---
 ell/dbus-private.h |  4 ++++
 ell/dbus-service.c | 33 +++++++++++++++++++++++++++++----
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/ell/dbus-private.h b/ell/dbus-private.h
index fd5d099..0c06410 100644
--- a/ell/dbus-private.h
+++ b/ell/dbus-private.h
@@ -207,6 +207,10 @@ bool _dbus_object_tree_remove_interface(struct _dbus_object_tree *tree,
 void *_dbus_object_tree_get_interface_data(struct _dbus_object_tree *tree,
 						const char *path,
 						const char *interface);
+bool _dbus_object_tree_set_interface_data(struct _dbus_object_tree *tree,
+						const char *path,
+						const char *interface,
+						void *user_data);
 
 void _dbus_object_tree_introspect(struct _dbus_object_tree *tree,
 					const char *path, struct l_string *buf);
diff --git a/ell/dbus-service.c b/ell/dbus-service.c
index d4466de..0300bfe 100644
--- a/ell/dbus-service.c
+++ b/ell/dbus-service.c
@@ -1568,25 +1568,50 @@ bool _dbus_object_tree_add_interface(struct _dbus_object_tree *tree,
 	return true;
 }
 
-void *_dbus_object_tree_get_interface_data(struct _dbus_object_tree *tree,
+static struct interface_instance *_dbus_object_tree_find_interface(
+						struct _dbus_object_tree *tree,
 						const char *path,
 						const char *interface)
 {
 	struct object_node *object;
-	struct interface_instance *instance;
 
 	object = l_hashmap_lookup(tree->objects, path);
 	if (!object)
 		return NULL;
 
-	instance = l_queue_find(object->instances, match_interface_instance,
-				(char *) interface);
+	return l_queue_find(object->instances, match_interface_instance,
+				interface);
+}
+
+void *_dbus_object_tree_get_interface_data(struct _dbus_object_tree *tree,
+						const char *path,
+						const char *interface)
+{
+	struct interface_instance *instance;
+
+	instance = _dbus_object_tree_find_interface(tree, path, interface);
 	if (!instance)
 		return NULL;
 
 	return instance->user_data;
 }
 
+bool _dbus_object_tree_set_interface_data(struct _dbus_object_tree *tree,
+						const char *path,
+						const char *interface,
+						void *user_data)
+{
+	struct interface_instance *instance;
+
+	instance = _dbus_object_tree_find_interface(tree, path, interface);
+	if (!instance)
+		return false;
+
+	instance->user_data = user_data;
+
+	return true;
+}
+
 static bool match_object_manager_path(const void *a, const void *b)
 {
 	const struct object_manager *manager = a;
-- 
2.34.1


             reply	other threads:[~2024-08-07 17:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07 17:59 James Prestwood [this message]
2024-08-07 17:59 ` [PATCH 2/2] dbus: add l_dbus_object_set_data() James Prestwood
2024-08-08 14:19   ` Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240807175943.170002-1-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=ell@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox