All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ell@lists.01.org
Subject: Re: [PATCH 18/20] dbus: Classic dbus driver->name_acquire and public API.
Date: Mon, 14 Mar 2016 14:18:02 -0500	[thread overview]
Message-ID: <56E70E6A.7050508@gmail.com> (raw)
In-Reply-To: <1457926896-9843-18-git-send-email-andrew.zaborowski@intel.com>

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

Hi Andrew,

On 03/13/2016 10:41 PM, Andrew Zaborowski wrote:
> ---
>   ell/dbus.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>   ell/dbus.h |  5 ++++
>   2 files changed, 94 insertions(+)

I'd reflow this patch and one preceding it like this:

1. kdbus name_acquire variant
2. dbus1 name acquire variant
3. public API + driver method definitions

>
> diff --git a/ell/dbus.c b/ell/dbus.c
> index c5cc1fc..6c267ae 100644
> --- a/ell/dbus.c
> +++ b/ell/dbus.c
> @@ -822,6 +822,84 @@ static bool classic_get_name_owner(struct l_dbus *bus, const char *name)
>   	return true;
>   }
>
> +struct name_request {
> +	l_dbus_name_acquire_func_t callback;
> +	void *user_data;
> +	struct l_dbus *dbus;
> +};
> +
> +enum dbus_name_flag {
> +	DBUS_NAME_FLAG_ALLOW_REPLACEMENT	= 0x1,
> +	DBUS_NAME_FLAG_REPLACE_EXISTING		= 0x2,
> +	DBUS_NAME_FLAG_DO_NOT_QUEUE		= 0x4,
> +};
> +
> +enum dbus_name_reply {
> +	DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER	= 1,
> +	DBUS_REQUEST_NAME_REPLY_IN_QUEUE	= 2,
> +	DBUS_REQUEST_NAME_REPLY_EXISTS		= 3,
> +	DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER	= 4,
> +};
> +
> +static void request_name_reply_cb(struct l_dbus_message *reply, void *user_data)
> +{
> +	struct name_request *req = user_data;
> +	bool success = false, queued = false;
> +	uint32_t retval;
> +
> +	if (!req->callback)
> +		return;
> +
> +	/* No name owner yet */
> +	if (l_dbus_message_is_error(reply))
> +		goto call_back;
> +
> +	/* Shouldn't happen */
> +	if (!l_dbus_message_get_arguments(reply, "u", &retval))
> +		goto call_back;
> +
> +	success = (retval == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) ||
> +		(retval == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER) ||
> +		(retval == DBUS_REQUEST_NAME_REPLY_IN_QUEUE);
> +	queued = (retval == DBUS_REQUEST_NAME_REPLY_IN_QUEUE);
> +
> +call_back:
> +	req->callback(req->dbus, success, queued, req->user_data);
> +}
> +
> +static uint32_t classic_name_acquire(struct l_dbus *dbus, const char *name,
> +					bool allow_replacement,
> +					bool replace_existing, bool queue,
> +					l_dbus_name_acquire_func_t callback,
> +					void *user_data)
> +{
> +	struct name_request *req;
> +	struct l_dbus_message *message;
> +	uint32_t flags = 0;
> +
> +	req = l_new(struct name_request, 1);
> +	req->dbus = dbus;
> +	req->user_data = user_data;
> +	req->callback = callback;
> +
> +	message = l_dbus_message_new_method_call(dbus, DBUS_SERVICE_DBUS,
> +							DBUS_PATH_DBUS,
> +							L_DBUS_INTERFACE_DBUS,
> +							"RequestName");
> +
> +	if (allow_replacement)
> +		flags |= DBUS_NAME_FLAG_ALLOW_REPLACEMENT;
> +	if (replace_existing)
> +		flags |= DBUS_NAME_FLAG_REPLACE_EXISTING;
> +	if (!queue)
> +		flags |= DBUS_NAME_FLAG_DO_NOT_QUEUE;
> +
> +	l_dbus_message_set_arguments(message, "su", name, flags);
> +
> +	return send_message(dbus, false, message, request_name_reply_cb,
> +				req, free);
> +}
> +
>   static const struct l_dbus_ops classic_ops = {
>   	.version = 1,
>   	.send_message = classic_send_message,
> @@ -833,6 +911,7 @@ static const struct l_dbus_ops classic_ops = {
>   		.remove_match = classic_remove_match,
>   		.get_name_owner = classic_get_name_owner,
>   	},
> +	.name_acquire = classic_name_acquire,
>   };
>
>   static void name_owner_changed_cb(struct l_dbus_message *message,
> @@ -2048,3 +2127,13 @@ LIB_EXPORT bool l_dbus_remove_signal_watch(struct l_dbus *dbus, unsigned int id)
>   {
>   	return _dbus_filter_remove_rule(dbus->filter, id);
>   }
> +
> +LIB_EXPORT uint32_t l_dbus_name_acquire(struct l_dbus *dbus, const char *name,
> +				bool allow_replacement, bool replace_existing,
> +				bool queue, l_dbus_name_acquire_func_t callback,
> +				void *user_data)
> +{
> +	return dbus->driver->name_acquire(dbus, name, allow_replacement,
> +						replace_existing, queue,
> +						callback, user_data);
> +}
> diff --git a/ell/dbus.h b/ell/dbus.h
> index 0b82899..f4b2527 100644
> --- a/ell/dbus.h
> +++ b/ell/dbus.h
> @@ -256,6 +256,11 @@ unsigned int l_dbus_add_signal_watch(struct l_dbus *dbus,
>   					const char *member, ...);
>   bool l_dbus_remove_signal_watch(struct l_dbus *dbus, unsigned int id);
>
> +uint32_t l_dbus_name_acquire(struct l_dbus *dbus, const char *name,
> +				bool allow_replacement, bool replace_existing,
> +				bool queue, l_dbus_name_acquire_func_t callback,
> +				void *user_data);
> +

What's the uint32_t return for?

>   #ifdef __cplusplus
>   }
>   #endif
>


  reply	other threads:[~2016-03-14 19:18 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-14  3:41 [PATCH 01/20] dbus: Add _dbus1_message_iter_skip_entry and gvariant variant Andrew Zaborowski
2016-03-14  3:41 ` [PATCH 02/20] dbus: Add _dbus_message_get_nth_string_argument Andrew Zaborowski
2016-03-14  3:41 ` [PATCH 03/20] dbus: Support 2+ arguments in l_dbus_message_get_error Andrew Zaborowski
2016-03-14  3:41 ` [PATCH 04/20] dbus: Fix _dbus_kernel_calculate_bloom for multiple arguments Andrew Zaborowski
2016-03-14 16:49   ` Denis Kenzior
2016-03-14 22:11     ` Andrzej Zaborowski
2016-03-15 16:27       ` Denis Kenzior
2016-03-15 22:08         ` Andrzej Zaborowski
2016-03-16  2:06           ` Denis Kenzior
2016-03-14  3:41 ` [PATCH 05/20] dbus: Add message filter logic in dbus-filter.c Andrew Zaborowski
2016-03-14 17:37   ` Denis Kenzior
2016-03-14 22:25     ` Andrzej Zaborowski
2016-03-14  3:41 ` [PATCH 06/20] unit: Add dbus message filter tests Andrew Zaborowski
2016-03-14  3:41 ` [PATCH 07/20] dbus-filter: Name owner change tracking support Andrew Zaborowski
2016-03-14 18:03   ` Denis Kenzior
2016-03-14 22:32     ` Andrzej Zaborowski
2016-03-14  3:41 ` [PATCH 08/20] dbus: Classic dbus filter_ops implementation Andrew Zaborowski
2016-03-14 18:18   ` Denis Kenzior
2016-03-14 22:36     ` Andrzej Zaborowski
2016-03-15 16:32       ` Denis Kenzior
2016-03-14  3:41 ` [PATCH 09/20] dbus: kdbus " Andrew Zaborowski
2016-03-14  3:41 ` [PATCH 10/20] linux: Update kdbus.h to current github version Andrew Zaborowski
2016-03-14  3:41 ` [PATCH 11/20] dbus-kernel: Update with kdbus API changes Andrew Zaborowski
2016-03-14  3:41 ` [PATCH 12/20] dbus: Add message filter public API Andrew Zaborowski
2016-03-14  3:41 ` [PATCH 13/20] unit: Use the message filter API in dbus tests Andrew Zaborowski
2016-03-14  3:41 ` [PATCH 14/20] dbus: Don't send replies to messages with no reply flag Andrew Zaborowski
2016-03-14 17:11   ` Denis Kenzior
2016-03-14 22:15     ` Andrzej Zaborowski
2016-03-15 16:35       ` Denis Kenzior
2016-03-14  3:41 ` [PATCH 15/20] dbus: Rewrite service/disconnect watch APIs on top of filter API Andrew Zaborowski
2016-03-14  3:41 ` [PATCH 16/20] dbus: Remove now unused filter functions Andrew Zaborowski
2016-03-14 19:12   ` Denis Kenzior
2016-03-14  3:41 ` [PATCH 17/20] dbus: kdbus driver->name_acquire implementation Andrew Zaborowski
2016-03-14  3:41 ` [PATCH 18/20] dbus: Classic dbus driver->name_acquire and public API Andrew Zaborowski
2016-03-14 19:18   ` Denis Kenzior [this message]
2016-03-14 22:39     ` Andrzej Zaborowski
2016-03-15 16:38       ` Denis Kenzior
2016-03-14  3:41 ` [PATCH 19/20] unit: Use l_dbus_name_acquire to acquire well-known name Andrew Zaborowski
2016-03-14  3:41 ` [PATCH 20/20] examples: " Andrew Zaborowski
2016-03-14 16:50 ` [PATCH 01/20] dbus: Add _dbus1_message_iter_skip_entry and gvariant variant 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=56E70E6A.7050508@gmail.com \
    --to=denkenz@gmail.com \
    --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.