Open Source Telephony
 help / color / mirror / Atom feed
From: Gustavo F. Padovan <gustavo@padovan.org>
To: ofono@ofono.org
Subject: Re: [PATCH 2/5] Move bluetooth utils from hfp.c to bluetooth.c
Date: Sat, 12 Jun 2010 00:53:05 -0300	[thread overview]
Message-ID: <20100612035202.GA32159@vigoh> (raw)
In-Reply-To: <201006101617.12795.denkenz@gmail.com>

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

Hi Denis,

* Denis Kenzior <denkenz@gmail.com> [2010-06-10 16:17:12 -0500]:

> Hi Gustavo,
> 
> Please break this patch up more.  You're moving functions but also modifying 
> them in between.  I'm getting lost.
> 
> > +static int send_method_call_with_reply(const char *dest, const char *path,
> > +				const char *interface, const char *method,
> > +				DBusPendingCallNotifyFunction cb,
> > +				void *user_data, DBusFreeFunction free_func,
> > +				int timeout, int type, ...)
> > +{
> > +	DBusMessage *msg;
> > +	DBusPendingCall *call;
> > +	va_list args;
> > +	int err;
> > +
> > +	msg = dbus_message_new_method_call(dest, path, interface, method);
> > +	if (!msg) {
> > +		ofono_error("Unable to allocate new D-Bus %s message", method);
> > +		err = -ENOMEM;
> > +		goto fail;
> > +	}
> > +
> > +	va_start(args, type);
> > +
> > +	if (!dbus_message_append_args_valist(msg, type, args)) {
> > +		va_end(args);
> > +		err = -EIO;
> > +		goto fail;
> > +	}
> > +
> > +	va_end(args);
> > +
> > +	if (timeout > 0)
> > +		timeout *= 1000;
> > +
> > +	if (!dbus_connection_send_with_reply(connection, msg, &call, timeout)) {
> > +		ofono_error("Sending %s failed", method);
> > +		err = -EIO;
> > +		goto fail;
> > +	}
> > +
> > +	dbus_pending_call_set_notify(call, cb, user_data, free_func);
> > +	dbus_pending_call_unref(call);
> > +	dbus_message_unref(msg);
> > +
> > +	return 0;
> > +
> > +fail:
> > +	if (free_func && user_data)
> > +		free_func(user_data);
> > +
> > +	if (msg)
> > +		dbus_message_unref(msg);
> > +
> > +	return err;
> > +}
> 
> So this should be in a separate patch...

If I put this in a separate patch, it won't compile because no one is
using send_method_call_with_reply.

> 
> > +
> > +typedef void (*PropertyHandler)(DBusMessageIter *iter, gpointer
> >  user_data); +
> > +struct property_handler {
> > +	const char *property;
> > +	PropertyHandler callback;
> > +	gpointer user_data;
> > +};
> > +
> > +static gint property_handler_compare(gconstpointer a, gconstpointer b)
> > +{
> > +	const struct property_handler *handler = a;
> > +	const char *property = b;
> > +
> > +	return strcmp(handler->property, property);
> > +}
> > +
> > +static void parse_properties_reply(DBusMessage *reply,
> > +					const char *property, ...)
> > +{
> > +	va_list args;
> > +	GSList *prop_handlers = NULL;
> > +	DBusMessageIter array, dict;
> > +
> > +	va_start(args, property);
> > +
> > +	while (property != NULL) {
> > +		struct property_handler *handler =
> > +					g_new0(struct property_handler, 1);
> > +
> > +		handler->property = property;
> > +		handler->callback = va_arg(args, PropertyHandler);
> > +		handler->user_data = va_arg(args, gpointer);
> > +
> > +		property = va_arg(args, const char *);
> > +
> > +		prop_handlers = g_slist_prepend(prop_handlers, handler);
> > +	}
> > +
> > +	va_end(args);
> > +
> > +	if (dbus_message_iter_init(reply, &array) == FALSE)
> > +		goto done;
> > +
> > +	if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
> > +		goto done;
> > +
> > +	dbus_message_iter_recurse(&array, &dict);
> > +
> > +	while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
> > +		DBusMessageIter entry, value;
> > +		const char *key;
> > +		GSList *l;
> > +
> > +		dbus_message_iter_recurse(&dict, &entry);
> > +
> > +		if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING)
> > +			goto done;
> > +
> > +		dbus_message_iter_get_basic(&entry, &key);
> > +
> > +		dbus_message_iter_next(&entry);
> > +
> > +		if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT)
> > +			goto done;
> > +
> > +		dbus_message_iter_recurse(&entry, &value);
> > +
> > +		l = g_slist_find_custom(prop_handlers, key,
> > +					property_handler_compare);
> > +
> > +		if (l) {
> > +			struct property_handler *handler = l->data;
> > +
> > +			handler->callback(&value, handler->user_data);
> > +		}
> > +
> > +		dbus_message_iter_next(&dict);
> > +	}
> > +
> > +done:
> > +	g_slist_foreach(prop_handlers, (GFunc)g_free, NULL);
> > +	g_slist_free(prop_handlers);
> > +}
> 
> And this one too...

Same here.

-- 
Gustavo F. Padovan
http://padovan.org

  reply	other threads:[~2010-06-12  3:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-08  7:43 [PATCH 1/5] Add bluetooth plugin skeleton Gustavo F. Padovan
2010-06-08  7:43 ` [PATCH 2/5] Move bluetooth utils from hfp.c to bluetooth.c Gustavo F. Padovan
2010-06-08  7:43   ` [PATCH 3/5] Remove send_method_call from hfp.c Gustavo F. Padovan
2010-06-08  7:43     ` [PATCH 4/5] Move create_path() to bluetooth plugin Gustavo F. Padovan
2010-06-08  7:44       ` [PATCH 5/5] Remove hfpmodem's header guard Gustavo F. Padovan
2010-06-10 21:19         ` Denis Kenzior
2010-06-10 21:17   ` [PATCH 2/5] Move bluetooth utils from hfp.c to bluetooth.c Denis Kenzior
2010-06-12  3:53     ` Gustavo F. Padovan [this message]
2010-06-12  4:09       ` Denis Kenzior
2010-06-12  5:13         ` Gustavo F. Padovan
2010-06-10 21:13 ` [PATCH 1/5] Add bluetooth plugin skeleton Denis Kenzior
  -- strict thread matches above, loose matches on Subject: below --
2010-06-05  2:40 Gustavo F. Padovan
2010-06-05  2:40 ` [PATCH 2/5] Move bluetooth utils from hfp.c to bluetooth.c Gustavo F. Padovan

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=20100612035202.GA32159@vigoh \
    --to=gustavo@padovan.org \
    --cc=ofono@ofono.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox