2018-01-26 08:14:43

by ERAMOTO Masaya

[permalink] [raw]
Subject: [PATCH BlueZ 1/2] tools/obexctl: Retrieve updated Size property once

Since obexd may have updated the Size property, obexctl retrieves it
once so that it can output more proper transfer information.
---
tools/obexctl.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/tools/obexctl.c b/tools/obexctl.c
index 05bbd3e84..777221d2f 100644
--- a/tools/obexctl.c
+++ b/tools/obexctl.c
@@ -1888,6 +1888,13 @@ static void transfer_property_changed(GDBusProxy *proxy, const char *name,
str = proxy_description(proxy, "Transfer", COLORED_CHG);

if (strcmp(name, "Transferred") == 0) {
+ /*
+ * Since the Size property may have been updated at the start
+ * of the transfer, it is retrieved so that the transfer
+ * information can be output more proper.
+ */
+ if (data->transferred == 0)
+ g_dbus_proxy_refresh_property(proxy, "Size");
print_transferred(data, str, iter);
goto done;
}
--
2.14.1



2018-01-31 11:35:53

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH BlueZ 1/2] tools/obexctl: Retrieve updated Size property once

Hi Eramoto,

On Fri, Jan 26, 2018 at 6:14 AM, ERAMOTO Masaya
<[email protected]> wrote:
> Since obexd may have updated the Size property, obexctl retrieves it
> once so that it can output more proper transfer information.
> ---
> tools/obexctl.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/tools/obexctl.c b/tools/obexctl.c
> index 05bbd3e84..777221d2f 100644
> --- a/tools/obexctl.c
> +++ b/tools/obexctl.c
> @@ -1888,6 +1888,13 @@ static void transfer_property_changed(GDBusProxy *proxy, const char *name,
> str = proxy_description(proxy, "Transfer", COLORED_CHG);
>
> if (strcmp(name, "Transferred") == 0) {
> + /*
> + * Since the Size property may have been updated at the start
> + * of the transfer, it is retrieved so that the transfer
> + * information can be output more proper.
> + */
> + if (data->transferred == 0)
> + g_dbus_proxy_refresh_property(proxy, "Size");

Usually we don't have to refresh property manually like this, so I
wonder if there is something else going on, perhaps the daemon is not
emitting PropertiesChanged when it should.

> print_transferred(data, str, iter);
> goto done;
> }
> --
> 2.14.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html



--
Luiz Augusto von Dentz

2018-01-26 08:15:54

by ERAMOTO Masaya

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

Outputs zero as the transferred size 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 777221d2f..e4c337488 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 resets
+ * the current transferred size to zero on completion of transfer.
+ */
+ if (valu64 == 0)
+ valu64 = data->size;
+
speed = valu64 - data->transferred;
data->transferred = valu64;

--
2.14.1


2018-02-01 02:59:07

by ERAMOTO Masaya

[permalink] [raw]
Subject: Re: [PATCH BlueZ 1/2] tools/obexctl: Retrieve updated Size property once

Hi Luiz,

On 01/31/2018 08:35 PM, Luiz Augusto von Dentz wrote:
> Hi Eramoto,
>
> On Fri, Jan 26, 2018 at 6:14 AM, ERAMOTO Masaya
> <[email protected]> wrote:
>> Since obexd may have updated the Size property, obexctl retrieves it
>> once so that it can output more proper transfer information.
>> ---
>> tools/obexctl.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/tools/obexctl.c b/tools/obexctl.c
>> index 05bbd3e84..777221d2f 100644
>> --- a/tools/obexctl.c
>> +++ b/tools/obexctl.c
>> @@ -1888,6 +1888,13 @@ static void transfer_property_changed(GDBusProxy *proxy, const char *name,
>> str = proxy_description(proxy, "Transfer", COLORED_CHG);
>>
>> if (strcmp(name, "Transferred") == 0) {
>> + /*
>> + * Since the Size property may have been updated at the start
>> + * of the transfer, it is retrieved so that the transfer
>> + * information can be output more proper.
>> + */
>> + if (data->transferred == 0)
>> + g_dbus_proxy_refresh_property(proxy, "Size");
>
> Usually we don't have to refresh property manually like this, so I
> wonder if there is something else going on, perhaps the daemon is not
> emitting PropertiesChanged when it should.
>

The Size property is "optional" in doc/obex-api.txt, so I thought:
* obexd daemon can choose whether or not to emit the property,
* and an app (e.g. obexctl) needs to refresh it if wants to
retrieve it.
Are the above things mistake?

Does "optional" mean that:
* obexd daemon can choose whether or not to provide the property,
* and obexd daemon should emit the property with a proper/valid
value if it exists (i.e. if obexd daemon provides it)?


Regards,
Eramoto

>> print_transferred(data, str, iter);
>> goto done;
>> }
>> --
>> 2.14.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
>