* [PATCH] Add send_method_call to g_dbus
@ 2010-04-20 6:51 Gustavo F. Padovan
2010-04-20 9:32 ` Kalle Valo
2010-04-27 2:33 ` Marcel Holtmann
0 siblings, 2 replies; 8+ messages in thread
From: Gustavo F. Padovan @ 2010-04-20 6:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 13001 bytes --]
Puting send_method_call and send_method_call_with_reply on g_dbus will
avoid some code duplication and will make things easier mainly for the
Bluetooth plugins (HFP, DUN, SAP) inside oFono.
---
gdbus/gdbus.h | 12 ++++
gdbus/object.c | 81 +++++++++++++++++++++++++++++
plugins/hfp.c | 154 +++++++++++++------------------------------------------
3 files changed, 130 insertions(+), 117 deletions(-)
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index 47e18cf..ac488c5 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -106,12 +106,24 @@ DBusMessage *g_dbus_create_error_valist(DBusMessage *message, const char *name,
DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...);
DBusMessage *g_dbus_create_reply_valist(DBusMessage *message,
int type, va_list args);
+DBusMessage *g_dbus_create_method_call(const char *dest, const char *path,
+ const char *interface, const char *method,
+ int type, va_list args);
gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message);
gboolean g_dbus_send_reply(DBusConnection *connection,
DBusMessage *message, int type, ...);
gboolean g_dbus_send_reply_valist(DBusConnection *connection,
DBusMessage *message, int type, va_list args);
+gboolean g_dbus_send_method_call(DBusConnection *connection, const char *dest,
+ const char *path, const char *interface,
+ const char *method, int type, ...);
+gboolean g_dbus_send_method_call_with_reply(DBusConnection *connection,
+ const char *dest, const char *path,
+ const char *interface, const char *method,
+ DBusPendingCallNotifyFunction cb,
+ void *user_data, DBusFreeFunction free_func,
+ int timeout, int type, ...);
gboolean g_dbus_emit_signal(DBusConnection *connection,
const char *path, const char *interface,
diff --git a/gdbus/object.c b/gdbus/object.c
index 8da2dab..887fc6c 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -608,6 +608,24 @@ DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...)
return reply;
}
+DBusMessage *g_dbus_create_method_call(const char *dest, const char *path,
+ const char *interface, const char *method,
+ int type, va_list args)
+{
+ DBusMessage *msg;
+
+ msg = dbus_message_new_method_call(dest, path, interface, method);
+ if (!msg)
+ return NULL;
+
+ if (!dbus_message_append_args_valist(msg, type, args)) {
+ dbus_message_unref(msg);
+ return NULL;
+ }
+
+ return msg;
+}
+
gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message)
{
dbus_bool_t result;
@@ -654,6 +672,69 @@ gboolean g_dbus_send_reply(DBusConnection *connection,
return result;
}
+gboolean g_dbus_send_method_call(DBusConnection *connection, const char *dest,
+ const char *path, const char *interface,
+ const char *method, int type, ...)
+{
+ DBusMessage *msg;
+ va_list args;
+
+ va_start(args, type);
+
+ msg = g_dbus_create_method_call(dest, path, interface, method,
+ type, args);
+
+ va_end(args);
+
+ if (!msg)
+ return FALSE;
+
+ return g_dbus_send_message(connection, msg);
+}
+
+gboolean g_dbus_send_method_call_with_reply(DBusConnection *connection,
+ 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;
+
+ va_start(args, type);
+
+ msg = g_dbus_create_method_call(dest, path, interface, method,
+ type, args);
+
+ va_end(args);
+
+ if (!msg)
+ goto fail;
+
+ if (timeout > 0)
+ timeout *= 1000;
+
+ if (!dbus_connection_send_with_reply(connection, msg, &call, timeout))
+ goto fail;
+
+ dbus_pending_call_set_notify(call, cb, user_data, free_func);
+ dbus_pending_call_unref(call);
+ dbus_message_unref(msg);
+
+ return TRUE;
+
+fail:
+ if (free_func && user_data)
+ free_func(user_data);
+
+ if (msg)
+ dbus_message_unref(msg);
+
+ return FALSE;
+}
+
gboolean g_dbus_emit_signal(DBusConnection *connection,
const char *path, const char *interface,
const char *name, int type, ...)
diff --git a/plugins/hfp.c b/plugins/hfp.c
index e37c9fc..82037e9 100644
--- a/plugins/hfp.c
+++ b/plugins/hfp.c
@@ -183,86 +183,6 @@ static void cmer_cb(gboolean ok, GAtResult *result, gpointer user_data)
sevice_level_conn_established(modem);
}
-static int send_method_call(const char *dest, const char *path,
- const char *interface, const char *method,
- int type, ...)
-{
- DBusMessage *msg;
- va_list args;
-
- msg = dbus_message_new_method_call(dest, path, interface, method);
- if (!msg) {
- ofono_error("Unable to allocate new D-Bus %s message", method);
- return -ENOMEM;
- }
-
- va_start(args, type);
-
- if (!dbus_message_append_args_valist(msg, type, args)) {
- dbus_message_unref(msg);
- va_end(args);
- return -EIO;
- }
-
- va_end(args);
-
- g_dbus_send_message(connection, msg);
- return 0;
-}
-
-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;
-}
-
typedef void (*PropertyHandler)(DBusMessageIter *iter, gpointer user_data);
struct property_handler {
@@ -753,8 +673,8 @@ static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
for (l = device_list; l; l = l->next) {
const char *device = l->data;
- send_method_call_with_reply(BLUEZ_SERVICE, device,
- BLUEZ_DEVICE_INTERFACE, "GetProperties",
+ g_dbus_send_method_call_with_reply(connection, BLUEZ_SERVICE,
+ device, BLUEZ_DEVICE_INTERFACE, "GetProperties",
device_properties_cb, g_strdup(device), g_free,
-1, DBUS_TYPE_INVALID);
}
@@ -768,17 +688,15 @@ static gboolean adapter_added(DBusConnection *connection, DBusMessage *message,
void *user_data)
{
const char *path;
- int ret;
dbus_message_get_args(message, NULL, DBUS_TYPE_OBJECT_PATH, &path,
DBUS_TYPE_INVALID);
- ret = send_method_call_with_reply(BLUEZ_SERVICE, path,
- BLUEZ_ADAPTER_INTERFACE, "GetProperties",
+ return g_dbus_send_method_call_with_reply(connection, BLUEZ_SERVICE,
+ path, BLUEZ_ADAPTER_INTERFACE, "GetProperties",
adapter_properties_cb, g_strdup(path), g_free,
-1, DBUS_TYPE_INVALID);
- return TRUE;
}
static gboolean adapter_removed(DBusConnection *connection,
@@ -829,10 +747,12 @@ static gboolean property_changed(DBusConnection *connection, DBusMessage *msg,
* refetch everything again
*/
if (have_hfp)
- send_method_call_with_reply(BLUEZ_SERVICE, path,
- BLUEZ_DEVICE_INTERFACE, "GetProperties",
- device_properties_cb, g_strdup(path), g_free,
- -1, DBUS_TYPE_INVALID);
+ g_dbus_send_method_call_with_reply(connection,
+ BLUEZ_SERVICE, path,
+ BLUEZ_DEVICE_INTERFACE,
+ "GetProperties", device_properties_cb,
+ g_strdup(path), g_free, -1,
+ DBUS_TYPE_INVALID);
} else if (g_str_equal(property, "Alias") == TRUE) {
const char *path = dbus_message_get_path(msg);
struct ofono_modem *modem =
@@ -878,8 +798,8 @@ static void parse_adapters(DBusMessageIter *array, gpointer user_data)
DBG("Calling GetProperties on %s", path);
- send_method_call_with_reply(BLUEZ_SERVICE, path,
- BLUEZ_ADAPTER_INTERFACE, "GetProperties",
+ g_dbus_send_method_call_with_reply(connection, BLUEZ_SERVICE,
+ path, BLUEZ_ADAPTER_INTERFACE, "GetProperties",
adapter_properties_cb, g_strdup(path), g_free,
-1, DBUS_TYPE_INVALID);
@@ -921,30 +841,30 @@ static void bluetooth_disconnect(DBusConnection *connection, void *user_data)
g_hash_table_foreach_remove(uuid_hash, hfp_remove_each_modem, NULL);
}
-static int hfp_register_ofono_handsfree(struct ofono_modem *modem)
+static gboolean hfp_register_ofono_handsfree(struct ofono_modem *modem)
{
const char *obj_path = ofono_modem_get_path(modem);
struct hfp_data *data = ofono_modem_get_data(modem);
DBG("Registering oFono Agent to bluetooth daemon");
- return send_method_call(BLUEZ_SERVICE, data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "RegisterAgent",
- DBUS_TYPE_OBJECT_PATH, &obj_path,
- DBUS_TYPE_INVALID);
+ return g_dbus_send_method_call(connection, BLUEZ_SERVICE,
+ data->handsfree_path, BLUEZ_GATEWAY_INTERFACE,
+ "RegisterAgent", DBUS_TYPE_OBJECT_PATH,
+ &obj_path, DBUS_TYPE_INVALID);
}
-static int hfp_unregister_ofono_handsfree(struct ofono_modem *modem)
+static gboolean hfp_unregister_ofono_handsfree(struct ofono_modem *modem)
{
const char *obj_path = ofono_modem_get_path(modem);
struct hfp_data *data = ofono_modem_get_data(modem);
DBG("Unregistering oFono Agent from bluetooth daemon");
- return send_method_call(BLUEZ_SERVICE, data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "UnregisterAgent",
- DBUS_TYPE_OBJECT_PATH, &obj_path,
- DBUS_TYPE_INVALID);
+ return g_dbus_send_method_call(connection, BLUEZ_SERVICE,
+ data->handsfree_path, BLUEZ_GATEWAY_INTERFACE,
+ "UnregisterAgent", DBUS_TYPE_OBJECT_PATH,
+ &obj_path, DBUS_TYPE_INVALID);
}
static int hfp_probe(struct ofono_modem *modem)
@@ -960,7 +880,7 @@ static int hfp_probe(struct ofono_modem *modem)
data->agent_registered = TRUE;
- if (hfp_register_ofono_handsfree(modem) != 0)
+ if (hfp_register_ofono_handsfree(modem) == FALSE)
return -EINVAL;
return 0;
@@ -989,7 +909,7 @@ static void hfp_connect_reply(DBusPendingCall *call, gpointer user_data)
struct hfp_data *data = ofono_modem_get_data(modem);
DBusError derr;
DBusMessage *reply;
- int ret;
+ gboolean ret;
reply = dbus_pending_call_steal_reply(call);
@@ -1003,10 +923,11 @@ static void hfp_connect_reply(DBusPendingCall *call, gpointer user_data)
DBG("Connect reply: %s", derr.message);
if (dbus_error_has_name(&derr, DBUS_ERROR_NO_REPLY)) {
- ret = send_method_call(BLUEZ_SERVICE, data->handsfree_path,
+ ret = g_dbus_send_method_call(connection, BLUEZ_SERVICE,
+ data->handsfree_path,
BLUEZ_GATEWAY_INTERFACE, "Disconnect",
DBUS_TYPE_INVALID);
- if (ret < 0)
+ if (!ret)
ofono_error("Disconnect failed(%d)", ret);
}
@@ -1022,17 +943,16 @@ done:
static int hfp_enable(struct ofono_modem *modem)
{
struct hfp_data *data = ofono_modem_get_data(modem);
- int status;
+ gboolean status;
DBG("%p", modem);
- status = send_method_call_with_reply(BLUEZ_SERVICE,
- data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "Connect",
- hfp_connect_reply, modem, NULL,
+ status = g_dbus_send_method_call_with_reply(connection, BLUEZ_SERVICE,
+ data->handsfree_path, BLUEZ_GATEWAY_INTERFACE,
+ "Connect", hfp_connect_reply, modem, NULL,
15, DBUS_TYPE_INVALID);
- if (status < 0)
+ if (!status)
return -EINVAL;
return -EINPROGRESS;
@@ -1062,20 +982,20 @@ done:
static int hfp_disable(struct ofono_modem *modem)
{
struct hfp_data *data = ofono_modem_get_data(modem);
- int status;
+ gboolean status;
DBG("%p", modem);
clear_data(modem);
if (data->agent_registered) {
- status = send_method_call_with_reply(BLUEZ_SERVICE,
- data->handsfree_path,
+ status = g_dbus_send_method_call_with_reply(connection,
+ BLUEZ_SERVICE, data->handsfree_path,
BLUEZ_GATEWAY_INTERFACE, "Disconnect",
hfp_power_down, modem, NULL, 15,
DBUS_TYPE_INVALID);
- if (status < 0)
+ if (!status)
return -EINVAL;
}
@@ -1156,7 +1076,7 @@ static int hfp_init()
if (err < 0)
goto remove;
- send_method_call_with_reply(BLUEZ_SERVICE, "/",
+ g_dbus_send_method_call_with_reply(connection, BLUEZ_SERVICE, "/",
BLUEZ_MANAGER_INTERFACE, "GetProperties",
manager_properties_cb, NULL, NULL, -1,
DBUS_TYPE_INVALID);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] Add send_method_call to g_dbus
2010-04-20 6:51 [PATCH] Add send_method_call to g_dbus Gustavo F. Padovan
@ 2010-04-20 9:32 ` Kalle Valo
2010-04-20 9:41 ` Zhenhua Zhang
2010-04-20 16:20 ` Denis Kenzior
2010-04-27 2:33 ` Marcel Holtmann
1 sibling, 2 replies; 8+ messages in thread
From: Kalle Valo @ 2010-04-20 9:32 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 401 bytes --]
"Gustavo F. Padovan" <gustavo@padovan.org> writes:
> Puting send_method_call and send_method_call_with_reply on g_dbus will
> avoid some code duplication and will make things easier mainly for the
> Bluetooth plugins (HFP, DUN, SAP) inside oFono.
Sorry, totally unrelated to this patch, but is there a BT DUN plugin for
ofono available somewhere? I would love to test it.
--
Kalle Valo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add send_method_call to g_dbus
2010-04-20 9:32 ` Kalle Valo
@ 2010-04-20 9:41 ` Zhenhua Zhang
2010-04-20 16:20 ` Denis Kenzior
1 sibling, 0 replies; 8+ messages in thread
From: Zhenhua Zhang @ 2010-04-20 9:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 600 bytes --]
Hi Valo,
On 04/20/2010 05:32 PM, Kalle Valo wrote:
> "Gustavo F. Padovan"<gustavo@padovan.org> writes:
>
>> Puting send_method_call and send_method_call_with_reply on g_dbus will
>> avoid some code duplication and will make things easier mainly for the
>> Bluetooth plugins (HFP, DUN, SAP) inside oFono.
>
> Sorry, totally unrelated to this patch, but is there a BT DUN plugin for
> ofono available somewhere? I would love to test it.
>
Not yet. We are working on BT DUN plugin right now. And it requires some
intergration efforts with Connman, PPP stack, etc.
Thanks.
Zhenhua
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add send_method_call to g_dbus
2010-04-20 9:32 ` Kalle Valo
2010-04-20 9:41 ` Zhenhua Zhang
@ 2010-04-20 16:20 ` Denis Kenzior
2010-04-21 6:51 ` Kalle Valo
1 sibling, 1 reply; 8+ messages in thread
From: Denis Kenzior @ 2010-04-20 16:20 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 744 bytes --]
Hi Kalle,
> "Gustavo F. Padovan" <gustavo@padovan.org> writes:
> > Puting send_method_call and send_method_call_with_reply on g_dbus will
> > avoid some code duplication and will make things easier mainly for the
> > Bluetooth plugins (HFP, DUN, SAP) inside oFono.
>
> Sorry, totally unrelated to this patch, but is there a BT DUN plugin for
> ofono available somewhere? I would love to test it.
>
There is none yet, but it is something we're planning to implement. But just
to make sure we're all talking about the same thing, what DUN profile role
(client or server?) are you actually interested in? The oFono plugin will be
for the server role, the client role will probably be a plugin in BlueZ.
Regards,
-Denis
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add send_method_call to g_dbus
2010-04-20 16:20 ` Denis Kenzior
@ 2010-04-21 6:51 ` Kalle Valo
0 siblings, 0 replies; 8+ messages in thread
From: Kalle Valo @ 2010-04-21 6:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1513 bytes --]
Denis Kenzior <denkenz@gmail.com> writes:
> Hi Kalle,
Hi Denis,
>> "Gustavo F. Padovan" <gustavo@padovan.org> writes:
>> > Puting send_method_call and send_method_call_with_reply on g_dbus will
>> > avoid some code duplication and will make things easier mainly for the
>> > Bluetooth plugins (HFP, DUN, SAP) inside oFono.
>>
>> Sorry, totally unrelated to this patch, but is there a BT DUN plugin for
>> ofono available somewhere? I would love to test it.
>>
>
> There is none yet, but it is something we're planning to implement. But just
> to make sure we're all talking about the same thing, what DUN profile role
> (client or server?) are you actually interested in?
Good point, I should be more clear here. I'm talking about the client
mode.
I would like to connect my laptop to Internet through my N900 using no
cables and I think BT DUN client mode is the easiest choise here. At
least I have BT DUN already working in N900.
> The oFono plugin will be for the server role, the client role will
> probably be a plugin in BlueZ.
But who, and how, will issue the necessary AT commands and run the PPP
stack in the BT DUN client mode? Wouldn't it be easiest if ofono would
do that? (Just asking.)
A kind request to the list maintainers: please disable the reply-to
header, it just makes things difficult. I prefer to have CCs so that I
get replies to my inbox and answer quickly. This is how all kernel
mailing lists work I know of work.
--
Kalle Valo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add send_method_call to g_dbus
2010-04-20 6:51 [PATCH] Add send_method_call to g_dbus Gustavo F. Padovan
2010-04-20 9:32 ` Kalle Valo
@ 2010-04-27 2:33 ` Marcel Holtmann
2010-04-27 11:14 ` Johan Hedberg
2010-04-30 23:40 ` Gustavo F. Padovan
1 sibling, 2 replies; 8+ messages in thread
From: Marcel Holtmann @ 2010-04-27 2:33 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2347 bytes --]
Hi Gustavo,
> Puting send_method_call and send_method_call_with_reply on g_dbus will
> avoid some code duplication and will make things easier mainly for the
> Bluetooth plugins (HFP, DUN, SAP) inside oFono.
> ---
> gdbus/gdbus.h | 12 ++++
> gdbus/object.c | 81 +++++++++++++++++++++++++++++
> plugins/hfp.c | 154 +++++++++++++------------------------------------------
> 3 files changed, 130 insertions(+), 117 deletions(-)
first of all, we don't intermix gdbus patches with other changes.
Remember that these commits have to be applied to BlueZ and ConnMan as
well.
> diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
> index 47e18cf..ac488c5 100644
> --- a/gdbus/gdbus.h
> +++ b/gdbus/gdbus.h
> @@ -106,12 +106,24 @@ DBusMessage *g_dbus_create_error_valist(DBusMessage *message, const char *name,
> DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...);
> DBusMessage *g_dbus_create_reply_valist(DBusMessage *message,
> int type, va_list args);
> +DBusMessage *g_dbus_create_method_call(const char *dest, const char *path,
> + const char *interface, const char *method,
> + int type, va_list args);
>
> gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message);
> gboolean g_dbus_send_reply(DBusConnection *connection,
> DBusMessage *message, int type, ...);
> gboolean g_dbus_send_reply_valist(DBusConnection *connection,
> DBusMessage *message, int type, va_list args);
> +gboolean g_dbus_send_method_call(DBusConnection *connection, const char *dest,
> + const char *path, const char *interface,
> + const char *method, int type, ...);
> +gboolean g_dbus_send_method_call_with_reply(DBusConnection *connection,
> + const char *dest, const char *path,
> + const char *interface, const char *method,
> + DBusPendingCallNotifyFunction cb,
> + void *user_data, DBusFreeFunction free_func,
> + int timeout, int type, ...);
Is there any real reason to export send_method_call and
create_method_call? What are these good for and what are your expected
users of these?
I think that a g_dbus_method_call which is always async and take a
pending call notifier is just enough.
All the other helpers are more for callbacks that have to respond to
messages than for client usage.
Regards
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add send_method_call to g_dbus
2010-04-27 2:33 ` Marcel Holtmann
@ 2010-04-27 11:14 ` Johan Hedberg
2010-04-30 23:40 ` Gustavo F. Padovan
1 sibling, 0 replies; 8+ messages in thread
From: Johan Hedberg @ 2010-04-27 11:14 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1059 bytes --]
Hi,
On Tue, Apr 27, 2010, Marcel Holtmann wrote:
> > +gboolean g_dbus_send_method_call(DBusConnection *connection, const char *dest,
> > + const char *path, const char *interface,
> > + const char *method, int type, ...);
> > +gboolean g_dbus_send_method_call_with_reply(DBusConnection *connection,
> > + const char *dest, const char *path,
> > + const char *interface, const char *method,
> > + DBusPendingCallNotifyFunction cb,
> > + void *user_data, DBusFreeFunction free_func,
> > + int timeout, int type, ...);
>
> Is there any real reason to export send_method_call and
> create_method_call? What are these good for and what are your expected
> users of these?
>
> I think that a g_dbus_method_call which is always async and take a
> pending call notifier is just enough.
In many cases you also want/need the ability to cancel the method call
before a reply has been received. If the DBusPendingCall object isn't
exposed to the caller then it seems canceling wouldn't be possible with
this API.
Johan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add send_method_call to g_dbus
2010-04-27 2:33 ` Marcel Holtmann
2010-04-27 11:14 ` Johan Hedberg
@ 2010-04-30 23:40 ` Gustavo F. Padovan
1 sibling, 0 replies; 8+ messages in thread
From: Gustavo F. Padovan @ 2010-04-30 23:40 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3193 bytes --]
* Marcel Holtmann <marcel@holtmann.org> [2010-04-27 04:33:36 +0200]:
> Hi Gustavo,
>
> > Puting send_method_call and send_method_call_with_reply on g_dbus will
> > avoid some code duplication and will make things easier mainly for the
> > Bluetooth plugins (HFP, DUN, SAP) inside oFono.
> > ---
> > gdbus/gdbus.h | 12 ++++
> > gdbus/object.c | 81 +++++++++++++++++++++++++++++
> > plugins/hfp.c | 154 +++++++++++++------------------------------------------
> > 3 files changed, 130 insertions(+), 117 deletions(-)
>
> first of all, we don't intermix gdbus patches with other changes.
> Remember that these commits have to be applied to BlueZ and ConnMan as
> well.
>
> > diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
> > index 47e18cf..ac488c5 100644
> > --- a/gdbus/gdbus.h
> > +++ b/gdbus/gdbus.h
> > @@ -106,12 +106,24 @@ DBusMessage *g_dbus_create_error_valist(DBusMessage *message, const char *name,
> > DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...);
> > DBusMessage *g_dbus_create_reply_valist(DBusMessage *message,
> > int type, va_list args);
> > +DBusMessage *g_dbus_create_method_call(const char *dest, const char *path,
> > + const char *interface, const char *method,
> > + int type, va_list args);
> >
> > gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message);
> > gboolean g_dbus_send_reply(DBusConnection *connection,
> > DBusMessage *message, int type, ...);
> > gboolean g_dbus_send_reply_valist(DBusConnection *connection,
> > DBusMessage *message, int type, va_list args);
> > +gboolean g_dbus_send_method_call(DBusConnection *connection, const char *dest,
> > + const char *path, const char *interface,
> > + const char *method, int type, ...);
> > +gboolean g_dbus_send_method_call_with_reply(DBusConnection *connection,
> > + const char *dest, const char *path,
> > + const char *interface, const char *method,
> > + DBusPendingCallNotifyFunction cb,
> > + void *user_data, DBusFreeFunction free_func,
> > + int timeout, int type, ...);
>
> Is there any real reason to export send_method_call and
> create_method_call? What are these good for and what are your expected
> users of these?
I'm trying to avoid call 3 functions every time I want call a dbus
method. Today we have to do:
dbus_message_new_method_call()
dbus_message_append_args()
g_dbus_send_message()
With the call I'm proposing we just call g_dbus_send_method_call() to
call a dbus method. HFP plugin (and soon the DUN plugin) will make use
of that function a lot. The same goes for
g_dbus_send_method_call_with_reply().
My idea could be wrong since I'm not a DBus expertise. ;)
>
> I think that a g_dbus_method_call which is always async and take a
> pending call notifier is just enough.
>
> All the other helpers are more for callbacks that have to respond to
> messages than for client usage.
>
> Regards
>
> Marcel
>
>
> _______________________________________________
> ofono mailing list
> ofono(a)ofono.org
> http://lists.ofono.org/listinfo/ofono
--
Gustavo F. Padovan
http://padovan.org
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-04-30 23:40 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-20 6:51 [PATCH] Add send_method_call to g_dbus Gustavo F. Padovan
2010-04-20 9:32 ` Kalle Valo
2010-04-20 9:41 ` Zhenhua Zhang
2010-04-20 16:20 ` Denis Kenzior
2010-04-21 6:51 ` Kalle Valo
2010-04-27 2:33 ` Marcel Holtmann
2010-04-27 11:14 ` Johan Hedberg
2010-04-30 23:40 ` Gustavo F. Padovan
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.