All of lore.kernel.org
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@codecoup.pl>
To: ell@lists.01.org
Subject: [PATCH 5/6] dbus: Add convenient API for calling method on proxy interface
Date: Fri, 01 Dec 2017 16:06:09 +0100	[thread overview]
Message-ID: <20171201150610.9696-6-szymon.janc@codecoup.pl> (raw)
In-Reply-To: <20171201150610.9696-1-szymon.janc@codecoup.pl>

[-- Attachment #1: Type: text/plain, Size: 2116 bytes --]

This is wrapper around l_dbus_method_call that allows to cancel call
both by removed proxy and caller.
---
 ell/dbus-client.c | 31 +++++++++++++++++++++++++++++++
 ell/dbus-client.h |  8 ++++++++
 2 files changed, 39 insertions(+)

diff --git a/ell/dbus-client.c b/ell/dbus-client.c
index 0d69e4b..5a48e52 100644
--- a/ell/dbus-client.c
+++ b/ell/dbus-client.c
@@ -280,6 +280,37 @@ LIB_EXPORT bool l_dbus_proxy_set_property(struct l_dbus_proxy *proxy,
 	return true;
 }
 
+LIB_EXPORT uint32_t l_dbus_proxy_method_call(struct l_dbus_proxy *proxy,
+					const char *method,
+					l_dbus_message_func_t setup,
+					l_dbus_client_proxy_result_func_t reply,
+					void *user_data,
+					l_dbus_destroy_func_t destroy)
+{
+	struct method_call_request *req;
+
+	req = l_new(struct method_call_request, 1);
+	req->proxy = proxy;
+	req->result = reply;
+	req->user_data = user_data;
+	req->destroy = destroy;
+
+	req->call_id = l_dbus_method_call(proxy->client->dbus,
+						proxy->client->service,
+						proxy->path, proxy->interface,
+						method, setup,
+						method_call_reply, req,
+						method_call_request_free);
+	if (!req->call_id) {
+		l_free(req);
+		return 0;
+	}
+
+	l_queue_push_tail(proxy->pending_calls, L_UINT_TO_PTR(req->call_id));
+
+	return req->call_id;
+}
+
 static void proxy_update_property(struct l_dbus_proxy *proxy,
 					const char *name,
 					struct l_dbus_message_iter *property)
diff --git a/ell/dbus-client.h b/ell/dbus-client.h
index 928dcec..699d824 100644
--- a/ell/dbus-client.h
+++ b/ell/dbus-client.h
@@ -83,6 +83,14 @@ bool l_dbus_proxy_set_property(struct l_dbus_proxy *proxy,
 				l_dbus_client_proxy_result_func_t result,
 				void *user_data, l_dbus_destroy_func_t destroy,
 				const char *name, const char *signature, ...);
+
+uint32_t l_dbus_proxy_method_call(struct l_dbus_proxy *proxy,
+					const char *method,
+					l_dbus_message_func_t setup,
+					l_dbus_client_proxy_result_func_t reply,
+					void *user_data,
+					l_dbus_destroy_func_t destroy);
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.14.3


  parent reply	other threads:[~2017-12-01 15:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-01 15:06 [PATCH 0/6] D-Bus client and proxy API Szymon Janc
2017-12-01 15:06 ` [PATCH 1/6] dbus: Add l_dbus_message_builder_append_from_valist Szymon Janc
2017-12-04 18:25   ` Denis Kenzior
2017-12-01 15:06 ` [PATCH 2/6] dbus: Use l_dbus_message_builder_append_from_valist in append_arguments Szymon Janc
2017-12-04 18:25   ` Denis Kenzior
2017-12-01 15:06 ` [PATCH 3/6] dbus: Add support for proxy interface Szymon Janc
2017-12-04 18:40   ` Denis Kenzior
2017-12-05 17:05     ` Szymon Janc
2017-12-01 15:06 ` [PATCH 4/6] dbus: Add support for setting properties on D-Bus " Szymon Janc
2017-12-01 15:06 ` Szymon Janc [this message]
2017-12-01 15:06 ` [PATCH 6/6] examples: Extend dbus-client example Szymon Janc

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=20171201150610.9696-6-szymon.janc@codecoup.pl \
    --to=szymon.janc@codecoup.pl \
    --cc=ell@lists.01.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.