2018-01-15 12:46:06

by ERAMOTO Masaya

[permalink] [raw]
Subject: [PATCH BlueZ v2 1/2] obexd: Emit file information for client

When running obexctl and then starting to transfer a file, it does not
retrieve the Size property correctly. Thus it prints out the huge
remaining time as below:

[NEW] Transfer /org/bluez/obex/server/session1/transfer0
[CHG] Transfer /org/bluez/obex/server/session1/transfer0 Status: active
[CHG] Transfer /org/bluez/obex/server/session1/transfer0 Transferred: 32683 (@32KB/s 4286681714:4294967273)
[CHG] Transfer /org/bluez/obex/server/session1/transfer0 Transferred: 65444 (@32KB/s 428259:59)

And the info command only prints out the Session/Status/Size/Transferred
properties and does not print out the others as below:

# info /org/bluez/obex/server/session1/transfer0
Transfer /org/bluez/obex/server/session1/transfer0
Session: /org/bluez/obex/server/session1
Status: active
Size: 18446744073709551614
Transferred: 262010
[CHG] Transfer /org/bluez/obex/server/session1/transfer0 Transferred: 294771 (@32KB/s 428259:52)

This change makes obexd emit the all properties, including the Size
property, since the first info command may not print out the all
properties if changing obexctl.
---
obexd/src/manager.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index 78b138c85..6c83479f4 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -533,10 +533,15 @@ void manager_cleanup(void)

void manager_emit_transfer_started(struct obex_transfer *transfer)
{
+ const GDBusPropertyTable *property;
+
transfer->status = TRANSFER_STATUS_ACTIVE;

- g_dbus_emit_property_changed(connection, transfer->path,
- TRANSFER_INTERFACE, "Status");
+ for (property = transfer_properties;
+ property && property->name; property++)
+ g_dbus_emit_property_changed(connection, transfer->path,
+ TRANSFER_INTERFACE,
+ property->name);
}

static void emit_transfer_completed(struct obex_transfer *transfer,
--
2.14.1



2018-01-17 07:37:04

by ERAMOTO Masaya

[permalink] [raw]
Subject: Re: [PATCH BlueZ v2 1/2] obexd: Emit file information for client

Hi Luiz,

>> And the info command only prints out the Session/Status/Size/Transferred
>> properties and does not print out the others as below:
>>
>> # info /org/bluez/obex/server/session1/transfer0
>> Transfer /org/bluez/obex/server/session1/transfer0
>> Session: /org/bluez/obex/server/session1
>> Status: active
>> Size: 18446744073709551614
>> Transferred: 262010
>> [CHG] Transfer /org/bluez/obex/server/session1/transfer0 Transferred: 294771 (@32KB/s 428259:52)
>
> I think the idea was to omit the Size in case the header has not been
> read, or is not available, though perhaps that needs fixing in both
> obexd really omit if the size is 0 and perhaps disable progress if the
> size is unknown. The documentation already indicates Size is optional
> but the implementation does not add a exists callback, but Im not sure
> why that would appear as the value above instead of 0.

It seems that the value is OBJECT_SIZE_DELETE (-2). When I tentatively
removed OBJECT_SIZE_DELETE at obex_session_start(), the info command
printed out 0 as the Size property. So I think that obexd may emit the
Size property after starting a session and before getting a file size.
I will try to dig this behavior.


Regards,
Eramoto


2018-01-16 18:16:16

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH BlueZ v2 1/2] obexd: Emit file information for client

Hi Eramoto,

On Mon, Jan 15, 2018 at 10:46 AM, ERAMOTO Masaya
<[email protected]> wrote:
> When running obexctl and then starting to transfer a file, it does not
> retrieve the Size property correctly. Thus it prints out the huge
> remaining time as below:
>
> [NEW] Transfer /org/bluez/obex/server/session1/transfer0
> [CHG] Transfer /org/bluez/obex/server/session1/transfer0 Status: active
> [CHG] Transfer /org/bluez/obex/server/session1/transfer0 Transferred: 32683 (@32KB/s 4286681714:4294967273)
> [CHG] Transfer /org/bluez/obex/server/session1/transfer0 Transferred: 65444 (@32KB/s 428259:59)
>
> And the info command only prints out the Session/Status/Size/Transferred
> properties and does not print out the others as below:
>
> # info /org/bluez/obex/server/session1/transfer0
> Transfer /org/bluez/obex/server/session1/transfer0
> Session: /org/bluez/obex/server/session1
> Status: active
> Size: 18446744073709551614
> Transferred: 262010
> [CHG] Transfer /org/bluez/obex/server/session1/transfer0 Transferred: 294771 (@32KB/s 428259:52)

I think the idea was to omit the Size in case the header has not been
read, or is not available, though perhaps that needs fixing in both
obexd really omit if the size is 0 and perhaps disable progress if the
size is unknown. The documentation already indicates Size is optional
but the implementation does not add a exists callback, but Im not sure
why that would appear as the value above instead of 0.

> This change makes obexd emit the all properties, including the Size
> property, since the first info command may not print out the all
> properties if changing obexctl.
> ---
> obexd/src/manager.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/obexd/src/manager.c b/obexd/src/manager.c
> index 78b138c85..6c83479f4 100644
> --- a/obexd/src/manager.c
> +++ b/obexd/src/manager.c
> @@ -533,10 +533,15 @@ void manager_cleanup(void)
>
> void manager_emit_transfer_started(struct obex_transfer *transfer)
> {
> + const GDBusPropertyTable *property;
> +
> transfer->status = TRANSFER_STATUS_ACTIVE;
>
> - g_dbus_emit_property_changed(connection, transfer->path,
> - TRANSFER_INTERFACE, "Status");
> + for (property = transfer_properties;
> + property && property->name; property++)
> + g_dbus_emit_property_changed(connection, transfer->path,
> + TRANSFER_INTERFACE,
> + property->name);
> }
>
> static void emit_transfer_completed(struct obex_transfer *transfer,
> --
> 2.14.1
>



--
Luiz Augusto von Dentz

2018-01-15 12:46:38

by ERAMOTO Masaya

[permalink] [raw]
Subject: [PATCH BlueZ v2 2/2] tools/obexctl: Fix display of size/bandwidth on completion

Outputs the wrong size and bandwidth on completion of transfer as below:

[CHG] Transfer /org/bluez/obex/server/session3/transfer2 Transferred: 5339965 (@32KB/s 00:01)
[CHG] Transfer /org/bluez/obex/server/session3/transfer2 Transferred: 5372726 (@32KB/s 00:00)
[CHG] Transfer /org/bluez/obex/server/session3/transfer2 Transferred: 0 (@18446744073704178KB/s 00:00)
[CHG] Transfer /org/bluez/obex/server/session3/transfer2 Status: complete
---
tools/obexctl.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/tools/obexctl.c b/tools/obexctl.c
index 05bbd3e84..ca139f050 100644
--- a/tools/obexctl.c
+++ b/tools/obexctl.c
@@ -1862,6 +1862,14 @@ static void print_transferred(struct transfer_data *data, const char *str,
int seconds, minutes;

dbus_message_iter_get_basic(iter, &valu64);
+
+ /*
+ * Use the file size to output the proper size/speed since obexd emits
+ * zero as the current transferred size on completion of transfer.
+ */
+ if (valu64 == 0)
+ valu64 = data->size;
+
speed = valu64 - data->transferred;
data->transferred = valu64;

--
2.14.1