2013-09-24 07:37:30

by Zheng, Wu

[permalink] [raw]
Subject: [PATCH 2/2] obexd:Add get_address property to transfer properties

Sometime, address is needed by the Bluetooth OBEX APP.
Therefore, add the property to transfer properties
---
obexd/src/manager.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index 96976ec..b338a72 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -551,6 +551,41 @@ static gboolean transfer_get_operation(const GDBusPropertyTable *property,
return TRUE;
}

+static gboolean transfer_address_exists(const GDBusPropertyTable *property,
+ void *data)
+{
+ struct obex_transfer *transfer = data;
+ struct obex_session *session = transfer->session;
+ char *address;
+ int err;
+
+ err = obex_getpeername(session, &address);
+ if (err < 0)
+ return FALSE;
+
+ g_free(address);
+
+ return TRUE;
+}
+
+static gboolean transfer_get_address(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct obex_transfer *transfer = data;
+ struct obex_session *session = transfer->session;
+ char *address;
+ int err;
+
+ err = obex_getpeername(session, &address);
+ if (err < 0)
+ return FALSE;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &address);
+ g_free(address);
+
+ return TRUE;
+}
+
static gboolean transfer_get_transferred(const GDBusPropertyTable *property,
DBusMessageIter *iter, void *data)
{
@@ -587,6 +622,8 @@ static const GDBusPropertyTable transfer_properties[] = {
transfer_filename_exists },
{ "Operation", "s", transfer_get_operation, NULL,
transfer_operation_exists },
+ { "Address", "s", transfer_get_address, NULL,
+ transfer_address_exists },
{ "Transferred", "t", transfer_get_transferred },
{ }
};
--
1.7.7



2013-09-29 08:40:38

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH 2/2] obexd:Add get_address property to transfer properties

Hi,

On Tue, Sep 24, 2013 at 10:37 AM, Wu Zheng <[email protected]> wrote:
> Sometime, address is needed by the Bluetooth OBEX APP.
> Therefore, add the property to transfer properties
> ---
> obexd/src/manager.c | 37 +++++++++++++++++++++++++++++++++++++
> 1 files changed, 37 insertions(+), 0 deletions(-)
>
> diff --git a/obexd/src/manager.c b/obexd/src/manager.c
> index 96976ec..b338a72 100644
> --- a/obexd/src/manager.c
> +++ b/obexd/src/manager.c
> @@ -551,6 +551,41 @@ static gboolean transfer_get_operation(const GDBusPropertyTable *property,
> return TRUE;
> }
>
> +static gboolean transfer_address_exists(const GDBusPropertyTable *property,
> + void *data)
> +{
> + struct obex_transfer *transfer = data;
> + struct obex_session *session = transfer->session;
> + char *address;
> + int err;
> +
> + err = obex_getpeername(session, &address);
> + if (err < 0)
> + return FALSE;
> +
> + g_free(address);
> +
> + return TRUE;
> +}
> +
> +static gboolean transfer_get_address(const GDBusPropertyTable *property,
> + DBusMessageIter *iter, void *data)
> +{
> + struct obex_transfer *transfer = data;
> + struct obex_session *session = transfer->session;
> + char *address;
> + int err;
> +
> + err = obex_getpeername(session, &address);
> + if (err < 0)
> + return FALSE;
> +
> + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &address);
> + g_free(address);
> +
> + return TRUE;
> +}
> +
> static gboolean transfer_get_transferred(const GDBusPropertyTable *property,
> DBusMessageIter *iter, void *data)
> {
> @@ -587,6 +622,8 @@ static const GDBusPropertyTable transfer_properties[] = {
> transfer_filename_exists },
> { "Operation", "s", transfer_get_operation, NULL,
> transfer_operation_exists },
> + { "Address", "s", transfer_get_address, NULL,
> + transfer_address_exists },
> { "Transferred", "t", transfer_get_transferred },
> { }
> };
> --
> 1.7.7

Nack, you can already access the Address via Session interface.


--
Luiz Augusto von Dentz