* [PATCH 1/2] obexd: Use g_dbus_get_properties when parsing MAP-msg-listing
@ 2013-08-22 16:08 Christian Fetzer
2013-08-22 16:08 ` [PATCH 2/2] obexd: Add property changed signals for 'org.bluez.obex.Message1' Christian Fetzer
2013-08-26 12:34 ` [PATCH 1/2] obexd: Use g_dbus_get_properties when parsing MAP-msg-listing Luiz Augusto von Dentz
0 siblings, 2 replies; 6+ messages in thread
From: Christian Fetzer @ 2013-08-22 16:08 UTC (permalink / raw)
To: linux-bluetooth
From: Christian Fetzer <christian.fetzer@bmw-carit.de>
Currently the message D-Bus properties for the ListMessages response are put
together manually in the parse_* functions unsing obex_dbus_dict_append.
This patch simplifies it by calling g_dbus_get_properties for every message.
---
obexd/client/map.c | 84 ++++++++++++++----------------------------------------
1 file changed, 21 insertions(+), 63 deletions(-)
diff --git a/obexd/client/map.c b/obexd/client/map.c
index 3d8acc4..8864a54 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -790,81 +790,60 @@ static struct map_msg *map_msg_create(struct map_data *data, const char *handle)
return msg;
}
-static void parse_subject(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_subject(struct map_msg *msg, const char *value)
{
g_free(msg->subject);
msg->subject = g_strdup(value);
- obex_dbus_dict_append(iter, "Subject", DBUS_TYPE_STRING, &value);
}
-static void parse_datetime(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_datetime(struct map_msg *msg, const char *value)
{
g_free(msg->timestamp);
msg->timestamp = g_strdup(value);
- obex_dbus_dict_append(iter, "Timestamp", DBUS_TYPE_STRING, &value);
}
-static void parse_sender(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_sender(struct map_msg *msg, const char *value)
{
g_free(msg->sender);
msg->sender = g_strdup(value);
- obex_dbus_dict_append(iter, "Sender", DBUS_TYPE_STRING, &value);
}
-static void parse_sender_address(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_sender_address(struct map_msg *msg, const char *value)
{
g_free(msg->sender_address);
msg->sender_address = g_strdup(value);
- obex_dbus_dict_append(iter, "SenderAddress", DBUS_TYPE_STRING,
- &value);
}
-static void parse_replyto(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_replyto(struct map_msg *msg, const char *value)
{
g_free(msg->replyto);
msg->replyto = g_strdup(value);
- obex_dbus_dict_append(iter, "ReplyTo", DBUS_TYPE_STRING, &value);
}
-static void parse_recipient(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_recipient(struct map_msg *msg, const char *value)
{
g_free(msg->recipient);
msg->recipient = g_strdup(value);
- obex_dbus_dict_append(iter, "Recipient", DBUS_TYPE_STRING, &value);
}
-static void parse_recipient_address(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_recipient_address(struct map_msg *msg, const char *value)
{
g_free(msg->recipient_address);
msg->recipient_address = g_strdup(value);
- obex_dbus_dict_append(iter, "RecipientAddress", DBUS_TYPE_STRING,
- &value);
}
-static void parse_type(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_type(struct map_msg *msg, const char *value)
{
g_free(msg->type);
msg->type = g_strdup(value);
- obex_dbus_dict_append(iter, "Type", DBUS_TYPE_STRING, &value);
}
-static void parse_size(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_size(struct map_msg *msg, const char *value)
{
msg->size = g_ascii_strtoll(value, NULL, 10);
- obex_dbus_dict_append(iter, "Size", DBUS_TYPE_UINT64, &msg->size);
}
-static void parse_text(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_text(struct map_msg *msg, const char *value)
{
gboolean flag = strcasecmp(value, "no") != 0;
@@ -873,27 +852,20 @@ static void parse_text(struct map_msg *msg, const char *value,
else
msg->flags &= ~MAP_MSG_FLAG_TEXT;
- obex_dbus_dict_append(iter, "Text", DBUS_TYPE_BOOLEAN, &flag);
}
-static void parse_status(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_status(struct map_msg *msg, const char *value)
{
g_free(msg->status);
msg->status = g_strdup(value);
- obex_dbus_dict_append(iter, "Status", DBUS_TYPE_STRING, &value);
}
-static void parse_attachment_size(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_attachment_size(struct map_msg *msg, const char *value)
{
msg->attachment_size = g_ascii_strtoll(value, NULL, 10);
- obex_dbus_dict_append(iter, "AttachmentSize", DBUS_TYPE_UINT64,
- &msg->attachment_size);
}
-static void parse_priority(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_priority(struct map_msg *msg, const char *value)
{
gboolean flag = strcasecmp(value, "no") != 0;
@@ -902,11 +874,9 @@ static void parse_priority(struct map_msg *msg, const char *value,
else
msg->flags &= ~MAP_MSG_FLAG_PRIORITY;
- obex_dbus_dict_append(iter, "Priority", DBUS_TYPE_BOOLEAN, &flag);
}
-static void parse_read(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_read(struct map_msg *msg, const char *value)
{
gboolean flag = strcasecmp(value, "no") != 0;
@@ -915,11 +885,9 @@ static void parse_read(struct map_msg *msg, const char *value,
else
msg->flags &= ~MAP_MSG_FLAG_READ;
- obex_dbus_dict_append(iter, "Read", DBUS_TYPE_BOOLEAN, &flag);
}
-static void parse_sent(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_sent(struct map_msg *msg, const char *value)
{
gboolean flag = strcasecmp(value, "no") != 0;
@@ -928,11 +896,9 @@ static void parse_sent(struct map_msg *msg, const char *value,
else
msg->flags &= ~MAP_MSG_FLAG_SENT;
- obex_dbus_dict_append(iter, "Sent", DBUS_TYPE_BOOLEAN, &flag);
}
-static void parse_protected(struct map_msg *msg, const char *value,
- DBusMessageIter *iter)
+static void parse_protected(struct map_msg *msg, const char *value)
{
gboolean flag = strcasecmp(value, "no") != 0;
@@ -941,13 +907,11 @@ static void parse_protected(struct map_msg *msg, const char *value,
else
msg->flags &= ~MAP_MSG_FLAG_PROTECTED;
- obex_dbus_dict_append(iter, "Protected", DBUS_TYPE_BOOLEAN, &flag);
}
static struct map_msg_parser {
const char *name;
- void (*func) (struct map_msg *msg, const char *value,
- DBusMessageIter *iter);
+ void (*func) (struct map_msg *msg, const char *value);
} msg_parsers[] = {
{ "subject", parse_subject },
{ "datetime", parse_datetime },
@@ -974,7 +938,7 @@ static void msg_element(GMarkupParseContext *ctxt, const char *element,
{
struct map_parser *parser = user_data;
struct map_data *data = parser->data;
- DBusMessageIter entry, dict, *iter = parser->iter;
+ DBusMessageIter entry, *iter = parser->iter;
struct map_msg *msg;
const char *key;
int i;
@@ -1000,25 +964,19 @@ static void msg_element(GMarkupParseContext *ctxt, const char *element,
dbus_message_iter_append_basic(&entry, DBUS_TYPE_OBJECT_PATH,
&msg->path);
- dbus_message_iter_open_container(&entry, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING
- DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
- &dict);
-
for (i = 0, key = names[i]; key; key = names[++i]) {
struct map_msg_parser *parser;
for (parser = msg_parsers; parser && parser->name; parser++) {
if (strcasecmp(key, parser->name) == 0) {
- parser->func(msg, values[i], &dict);
+ parser->func(msg, values[i]);
break;
}
}
}
- dbus_message_iter_close_container(&entry, &dict);
+ g_dbus_get_properties(conn, msg->path, MAP_MSG_INTERFACE, &entry);
+
dbus_message_iter_close_container(iter, &entry);
}
--
1.8.3.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] obexd: Add property changed signals for 'org.bluez.obex.Message1'
2013-08-22 16:08 [PATCH 1/2] obexd: Use g_dbus_get_properties when parsing MAP-msg-listing Christian Fetzer
@ 2013-08-22 16:08 ` Christian Fetzer
2013-08-26 12:08 ` Luiz Augusto von Dentz
2013-08-26 12:34 ` [PATCH 1/2] obexd: Use g_dbus_get_properties when parsing MAP-msg-listing Luiz Augusto von Dentz
1 sibling, 1 reply; 6+ messages in thread
From: Christian Fetzer @ 2013-08-22 16:08 UTC (permalink / raw)
To: linux-bluetooth
From: Christian Fetzer <christian.fetzer@bmw-carit.de>
This patch adds property changed signal emissions in case message properties
change on the server.
---
obexd/client/map.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 92 insertions(+), 2 deletions(-)
diff --git a/obexd/client/map.c b/obexd/client/map.c
index 8864a54..a9a9bcd 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -792,121 +792,211 @@ static struct map_msg *map_msg_create(struct map_data *data, const char *handle)
static void parse_subject(struct map_msg *msg, const char *value)
{
+ if (g_strcmp0(msg->subject, value) == 0)
+ return;
+
g_free(msg->subject);
msg->subject = g_strdup(value);
+
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "Subject");
}
static void parse_datetime(struct map_msg *msg, const char *value)
{
+ if (g_strcmp0(msg->timestamp, value) == 0)
+ return;
+
g_free(msg->timestamp);
msg->timestamp = g_strdup(value);
+
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "Timestamp");
}
static void parse_sender(struct map_msg *msg, const char *value)
{
+ if (g_strcmp0(msg->sender, value) == 0)
+ return;
+
g_free(msg->sender);
msg->sender = g_strdup(value);
+
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "Sender");
}
static void parse_sender_address(struct map_msg *msg, const char *value)
{
+ if (g_strcmp0(msg->sender_address, value) == 0)
+ return;
+
g_free(msg->sender_address);
msg->sender_address = g_strdup(value);
+
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "SenderAddress");
}
static void parse_replyto(struct map_msg *msg, const char *value)
{
+ if (g_strcmp0(msg->replyto, value) == 0)
+ return;
+
g_free(msg->replyto);
msg->replyto = g_strdup(value);
+
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "ReplyTo");
}
static void parse_recipient(struct map_msg *msg, const char *value)
{
+ if (g_strcmp0(msg->recipient, value) == 0)
+ return;
+
g_free(msg->recipient);
msg->recipient = g_strdup(value);
+
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "Recipient");
}
static void parse_recipient_address(struct map_msg *msg, const char *value)
{
+ if (g_strcmp0(msg->recipient_address, value) == 0)
+ return;
+
g_free(msg->recipient_address);
msg->recipient_address = g_strdup(value);
+
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "RecipientAddress");
}
static void parse_type(struct map_msg *msg, const char *value)
{
+ if (g_strcmp0(msg->type, value) == 0)
+ return;
+
g_free(msg->type);
msg->type = g_strdup(value);
+
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "Type");
}
static void parse_size(struct map_msg *msg, const char *value)
{
- msg->size = g_ascii_strtoll(value, NULL, 10);
+ uint64_t size = g_ascii_strtoll(value, NULL, 10);
+
+ if (msg->size == size)
+ return;
+
+ msg->size = size;
+
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "Size");
}
static void parse_text(struct map_msg *msg, const char *value)
{
gboolean flag = strcasecmp(value, "no") != 0;
+ uint8_t oldflags = msg->flags;
if (flag)
msg->flags |= MAP_MSG_FLAG_TEXT;
else
msg->flags &= ~MAP_MSG_FLAG_TEXT;
+ if (msg->flags != oldflags)
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "Text");
}
static void parse_status(struct map_msg *msg, const char *value)
{
+ if (g_strcmp0(msg->status, value) == 0)
+ return;
+
g_free(msg->status);
msg->status = g_strdup(value);
+
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "Status");
}
static void parse_attachment_size(struct map_msg *msg, const char *value)
{
- msg->attachment_size = g_ascii_strtoll(value, NULL, 10);
+ uint64_t attachment_size = g_ascii_strtoll(value, NULL, 10);
+
+ if (msg->attachment_size == attachment_size)
+ return;
+
+ msg->attachment_size = attachment_size;
+
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "AttachmentSize");
}
static void parse_priority(struct map_msg *msg, const char *value)
{
gboolean flag = strcasecmp(value, "no") != 0;
+ uint8_t oldflags = msg->flags;
if (flag)
msg->flags |= MAP_MSG_FLAG_PRIORITY;
else
msg->flags &= ~MAP_MSG_FLAG_PRIORITY;
+ if (msg->flags != oldflags)
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "Priority");
}
static void parse_read(struct map_msg *msg, const char *value)
{
gboolean flag = strcasecmp(value, "no") != 0;
+ uint8_t oldflags = msg->flags;
if (flag)
msg->flags |= MAP_MSG_FLAG_READ;
else
msg->flags &= ~MAP_MSG_FLAG_READ;
+ if (msg->flags != oldflags)
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "Read");
}
static void parse_sent(struct map_msg *msg, const char *value)
{
gboolean flag = strcasecmp(value, "no") != 0;
+ uint8_t oldflags = msg->flags;
if (flag)
msg->flags |= MAP_MSG_FLAG_SENT;
else
msg->flags &= ~MAP_MSG_FLAG_SENT;
+ if (msg->flags != oldflags)
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "Sent");
}
static void parse_protected(struct map_msg *msg, const char *value)
{
gboolean flag = strcasecmp(value, "no") != 0;
+ uint8_t oldflags = msg->flags;
if (flag)
msg->flags |= MAP_MSG_FLAG_PROTECTED;
else
msg->flags &= ~MAP_MSG_FLAG_PROTECTED;
+ if (msg->flags != oldflags)
+ g_dbus_emit_property_changed(conn, msg->path,
+ MAP_MSG_INTERFACE, "Protected");
}
static struct map_msg_parser {
--
1.8.3.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] obexd: Add property changed signals for 'org.bluez.obex.Message1'
2013-08-22 16:08 ` [PATCH 2/2] obexd: Add property changed signals for 'org.bluez.obex.Message1' Christian Fetzer
@ 2013-08-26 12:08 ` Luiz Augusto von Dentz
2013-08-27 7:09 ` Christian Fetzer
0 siblings, 1 reply; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2013-08-26 12:08 UTC (permalink / raw)
To: Christian Fetzer; +Cc: linux-bluetooth@vger.kernel.org
Hi Christian,
On Thu, Aug 22, 2013 at 7:08 PM, Christian Fetzer
<christian.fetzer@oss.bmw-carit.de> wrote:
> From: Christian Fetzer <christian.fetzer@bmw-carit.de>
>
> This patch adds property changed signal emissions in case message properties
> change on the server.
> ---
> obexd/client/map.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 92 insertions(+), 2 deletions(-)
>
> diff --git a/obexd/client/map.c b/obexd/client/map.c
> index 8864a54..a9a9bcd 100644
> --- a/obexd/client/map.c
> +++ b/obexd/client/map.c
> @@ -792,121 +792,211 @@ static struct map_msg *map_msg_create(struct map_data *data, const char *handle)
>
> static void parse_subject(struct map_msg *msg, const char *value)
> {
> + if (g_strcmp0(msg->subject, value) == 0)
> + return;
> +
> g_free(msg->subject);
> msg->subject = g_strdup(value);
> +
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "Subject");
> }
>
> static void parse_datetime(struct map_msg *msg, const char *value)
> {
> + if (g_strcmp0(msg->timestamp, value) == 0)
> + return;
> +
> g_free(msg->timestamp);
> msg->timestamp = g_strdup(value);
> +
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "Timestamp");
> }
>
> static void parse_sender(struct map_msg *msg, const char *value)
> {
> + if (g_strcmp0(msg->sender, value) == 0)
> + return;
> +
> g_free(msg->sender);
> msg->sender = g_strdup(value);
> +
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "Sender");
> }
>
> static void parse_sender_address(struct map_msg *msg, const char *value)
> {
> + if (g_strcmp0(msg->sender_address, value) == 0)
> + return;
> +
> g_free(msg->sender_address);
> msg->sender_address = g_strdup(value);
> +
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "SenderAddress");
> }
>
> static void parse_replyto(struct map_msg *msg, const char *value)
> {
> + if (g_strcmp0(msg->replyto, value) == 0)
> + return;
> +
> g_free(msg->replyto);
> msg->replyto = g_strdup(value);
> +
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "ReplyTo");
> }
>
> static void parse_recipient(struct map_msg *msg, const char *value)
> {
> + if (g_strcmp0(msg->recipient, value) == 0)
> + return;
> +
> g_free(msg->recipient);
> msg->recipient = g_strdup(value);
> +
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "Recipient");
> }
>
> static void parse_recipient_address(struct map_msg *msg, const char *value)
> {
> + if (g_strcmp0(msg->recipient_address, value) == 0)
> + return;
> +
> g_free(msg->recipient_address);
> msg->recipient_address = g_strdup(value);
> +
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "RecipientAddress");
> }
>
> static void parse_type(struct map_msg *msg, const char *value)
> {
> + if (g_strcmp0(msg->type, value) == 0)
> + return;
> +
> g_free(msg->type);
> msg->type = g_strdup(value);
> +
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "Type");
> }
>
> static void parse_size(struct map_msg *msg, const char *value)
> {
> - msg->size = g_ascii_strtoll(value, NULL, 10);
> + uint64_t size = g_ascii_strtoll(value, NULL, 10);
> +
> + if (msg->size == size)
> + return;
> +
> + msg->size = size;
> +
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "Size");
> }
>
> static void parse_text(struct map_msg *msg, const char *value)
> {
> gboolean flag = strcasecmp(value, "no") != 0;
>
> + uint8_t oldflags = msg->flags;
> if (flag)
> msg->flags |= MAP_MSG_FLAG_TEXT;
> else
> msg->flags &= ~MAP_MSG_FLAG_TEXT;
>
> + if (msg->flags != oldflags)
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "Text");
> }
>
> static void parse_status(struct map_msg *msg, const char *value)
> {
> + if (g_strcmp0(msg->status, value) == 0)
> + return;
> +
> g_free(msg->status);
> msg->status = g_strdup(value);
> +
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "Status");
> }
>
> static void parse_attachment_size(struct map_msg *msg, const char *value)
> {
> - msg->attachment_size = g_ascii_strtoll(value, NULL, 10);
> + uint64_t attachment_size = g_ascii_strtoll(value, NULL, 10);
> +
> + if (msg->attachment_size == attachment_size)
> + return;
> +
> + msg->attachment_size = attachment_size;
> +
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "AttachmentSize");
> }
>
> static void parse_priority(struct map_msg *msg, const char *value)
> {
> gboolean flag = strcasecmp(value, "no") != 0;
>
> + uint8_t oldflags = msg->flags;
> if (flag)
> msg->flags |= MAP_MSG_FLAG_PRIORITY;
> else
> msg->flags &= ~MAP_MSG_FLAG_PRIORITY;
>
> + if (msg->flags != oldflags)
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "Priority");
> }
>
> static void parse_read(struct map_msg *msg, const char *value)
> {
> gboolean flag = strcasecmp(value, "no") != 0;
>
> + uint8_t oldflags = msg->flags;
> if (flag)
> msg->flags |= MAP_MSG_FLAG_READ;
> else
> msg->flags &= ~MAP_MSG_FLAG_READ;
>
> + if (msg->flags != oldflags)
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "Read");
> }
>
> static void parse_sent(struct map_msg *msg, const char *value)
> {
> gboolean flag = strcasecmp(value, "no") != 0;
>
> + uint8_t oldflags = msg->flags;
> if (flag)
> msg->flags |= MAP_MSG_FLAG_SENT;
> else
> msg->flags &= ~MAP_MSG_FLAG_SENT;
>
> + if (msg->flags != oldflags)
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "Sent");
> }
>
> static void parse_protected(struct map_msg *msg, const char *value)
> {
> gboolean flag = strcasecmp(value, "no") != 0;
>
> + uint8_t oldflags = msg->flags;
> if (flag)
> msg->flags |= MAP_MSG_FLAG_PROTECTED;
> else
> msg->flags &= ~MAP_MSG_FLAG_PROTECTED;
>
> + if (msg->flags != oldflags)
> + g_dbus_emit_property_changed(conn, msg->path,
> + MAP_MSG_INTERFACE, "Protected");
> }
>
> static struct map_msg_parser {
> --
> 1.8.3.4
Does this make us emit signals when creating the objects? That should
probably not be necessary, only emit signals once the value really
changes.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] obexd: Use g_dbus_get_properties when parsing MAP-msg-listing
2013-08-22 16:08 [PATCH 1/2] obexd: Use g_dbus_get_properties when parsing MAP-msg-listing Christian Fetzer
2013-08-22 16:08 ` [PATCH 2/2] obexd: Add property changed signals for 'org.bluez.obex.Message1' Christian Fetzer
@ 2013-08-26 12:34 ` Luiz Augusto von Dentz
1 sibling, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2013-08-26 12:34 UTC (permalink / raw)
To: Christian Fetzer; +Cc: linux-bluetooth@vger.kernel.org
Hi Christian,
On Thu, Aug 22, 2013 at 7:08 PM, Christian Fetzer
<christian.fetzer@oss.bmw-carit.de> wrote:
> From: Christian Fetzer <christian.fetzer@bmw-carit.de>
>
> Currently the message D-Bus properties for the ListMessages response are put
> together manually in the parse_* functions unsing obex_dbus_dict_append.
> This patch simplifies it by calling g_dbus_get_properties for every message.
> ---
> obexd/client/map.c | 84 ++++++++++++++----------------------------------------
> 1 file changed, 21 insertions(+), 63 deletions(-)
>
> diff --git a/obexd/client/map.c b/obexd/client/map.c
> index 3d8acc4..8864a54 100644
> --- a/obexd/client/map.c
> +++ b/obexd/client/map.c
> @@ -790,81 +790,60 @@ static struct map_msg *map_msg_create(struct map_data *data, const char *handle)
> return msg;
> }
>
> -static void parse_subject(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_subject(struct map_msg *msg, const char *value)
> {
> g_free(msg->subject);
> msg->subject = g_strdup(value);
> - obex_dbus_dict_append(iter, "Subject", DBUS_TYPE_STRING, &value);
> }
>
> -static void parse_datetime(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_datetime(struct map_msg *msg, const char *value)
> {
> g_free(msg->timestamp);
> msg->timestamp = g_strdup(value);
> - obex_dbus_dict_append(iter, "Timestamp", DBUS_TYPE_STRING, &value);
> }
>
> -static void parse_sender(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_sender(struct map_msg *msg, const char *value)
> {
> g_free(msg->sender);
> msg->sender = g_strdup(value);
> - obex_dbus_dict_append(iter, "Sender", DBUS_TYPE_STRING, &value);
> }
>
> -static void parse_sender_address(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_sender_address(struct map_msg *msg, const char *value)
> {
> g_free(msg->sender_address);
> msg->sender_address = g_strdup(value);
> - obex_dbus_dict_append(iter, "SenderAddress", DBUS_TYPE_STRING,
> - &value);
> }
>
> -static void parse_replyto(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_replyto(struct map_msg *msg, const char *value)
> {
> g_free(msg->replyto);
> msg->replyto = g_strdup(value);
> - obex_dbus_dict_append(iter, "ReplyTo", DBUS_TYPE_STRING, &value);
> }
>
> -static void parse_recipient(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_recipient(struct map_msg *msg, const char *value)
> {
> g_free(msg->recipient);
> msg->recipient = g_strdup(value);
> - obex_dbus_dict_append(iter, "Recipient", DBUS_TYPE_STRING, &value);
> }
>
> -static void parse_recipient_address(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_recipient_address(struct map_msg *msg, const char *value)
> {
> g_free(msg->recipient_address);
> msg->recipient_address = g_strdup(value);
> - obex_dbus_dict_append(iter, "RecipientAddress", DBUS_TYPE_STRING,
> - &value);
> }
>
> -static void parse_type(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_type(struct map_msg *msg, const char *value)
> {
> g_free(msg->type);
> msg->type = g_strdup(value);
> - obex_dbus_dict_append(iter, "Type", DBUS_TYPE_STRING, &value);
> }
>
> -static void parse_size(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_size(struct map_msg *msg, const char *value)
> {
> msg->size = g_ascii_strtoll(value, NULL, 10);
> - obex_dbus_dict_append(iter, "Size", DBUS_TYPE_UINT64, &msg->size);
> }
>
> -static void parse_text(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_text(struct map_msg *msg, const char *value)
> {
> gboolean flag = strcasecmp(value, "no") != 0;
>
> @@ -873,27 +852,20 @@ static void parse_text(struct map_msg *msg, const char *value,
> else
> msg->flags &= ~MAP_MSG_FLAG_TEXT;
>
> - obex_dbus_dict_append(iter, "Text", DBUS_TYPE_BOOLEAN, &flag);
> }
>
> -static void parse_status(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_status(struct map_msg *msg, const char *value)
> {
> g_free(msg->status);
> msg->status = g_strdup(value);
> - obex_dbus_dict_append(iter, "Status", DBUS_TYPE_STRING, &value);
> }
>
> -static void parse_attachment_size(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_attachment_size(struct map_msg *msg, const char *value)
> {
> msg->attachment_size = g_ascii_strtoll(value, NULL, 10);
> - obex_dbus_dict_append(iter, "AttachmentSize", DBUS_TYPE_UINT64,
> - &msg->attachment_size);
> }
>
> -static void parse_priority(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_priority(struct map_msg *msg, const char *value)
> {
> gboolean flag = strcasecmp(value, "no") != 0;
>
> @@ -902,11 +874,9 @@ static void parse_priority(struct map_msg *msg, const char *value,
> else
> msg->flags &= ~MAP_MSG_FLAG_PRIORITY;
>
> - obex_dbus_dict_append(iter, "Priority", DBUS_TYPE_BOOLEAN, &flag);
> }
>
> -static void parse_read(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_read(struct map_msg *msg, const char *value)
> {
> gboolean flag = strcasecmp(value, "no") != 0;
>
> @@ -915,11 +885,9 @@ static void parse_read(struct map_msg *msg, const char *value,
> else
> msg->flags &= ~MAP_MSG_FLAG_READ;
>
> - obex_dbus_dict_append(iter, "Read", DBUS_TYPE_BOOLEAN, &flag);
> }
>
> -static void parse_sent(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_sent(struct map_msg *msg, const char *value)
> {
> gboolean flag = strcasecmp(value, "no") != 0;
>
> @@ -928,11 +896,9 @@ static void parse_sent(struct map_msg *msg, const char *value,
> else
> msg->flags &= ~MAP_MSG_FLAG_SENT;
>
> - obex_dbus_dict_append(iter, "Sent", DBUS_TYPE_BOOLEAN, &flag);
> }
>
> -static void parse_protected(struct map_msg *msg, const char *value,
> - DBusMessageIter *iter)
> +static void parse_protected(struct map_msg *msg, const char *value)
> {
> gboolean flag = strcasecmp(value, "no") != 0;
>
> @@ -941,13 +907,11 @@ static void parse_protected(struct map_msg *msg, const char *value,
> else
> msg->flags &= ~MAP_MSG_FLAG_PROTECTED;
>
> - obex_dbus_dict_append(iter, "Protected", DBUS_TYPE_BOOLEAN, &flag);
> }
>
> static struct map_msg_parser {
> const char *name;
> - void (*func) (struct map_msg *msg, const char *value,
> - DBusMessageIter *iter);
> + void (*func) (struct map_msg *msg, const char *value);
> } msg_parsers[] = {
> { "subject", parse_subject },
> { "datetime", parse_datetime },
> @@ -974,7 +938,7 @@ static void msg_element(GMarkupParseContext *ctxt, const char *element,
> {
> struct map_parser *parser = user_data;
> struct map_data *data = parser->data;
> - DBusMessageIter entry, dict, *iter = parser->iter;
> + DBusMessageIter entry, *iter = parser->iter;
> struct map_msg *msg;
> const char *key;
> int i;
> @@ -1000,25 +964,19 @@ static void msg_element(GMarkupParseContext *ctxt, const char *element,
> dbus_message_iter_append_basic(&entry, DBUS_TYPE_OBJECT_PATH,
> &msg->path);
>
> - dbus_message_iter_open_container(&entry, DBUS_TYPE_ARRAY,
> - DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
> - DBUS_TYPE_STRING_AS_STRING
> - DBUS_TYPE_VARIANT_AS_STRING
> - DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
> - &dict);
> -
> for (i = 0, key = names[i]; key; key = names[++i]) {
> struct map_msg_parser *parser;
>
> for (parser = msg_parsers; parser && parser->name; parser++) {
> if (strcasecmp(key, parser->name) == 0) {
> - parser->func(msg, values[i], &dict);
> + parser->func(msg, values[i]);
> break;
> }
> }
> }
>
> - dbus_message_iter_close_container(&entry, &dict);
> + g_dbus_get_properties(conn, msg->path, MAP_MSG_INTERFACE, &entry);
> +
> dbus_message_iter_close_container(iter, &entry);
> }
>
> --
> 1.8.3.4
Patch 1/2 applied, please modify and rebase 2/2.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] obexd: Add property changed signals for 'org.bluez.obex.Message1'
2013-08-26 12:08 ` Luiz Augusto von Dentz
@ 2013-08-27 7:09 ` Christian Fetzer
2013-09-02 10:43 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 6+ messages in thread
From: Christian Fetzer @ 2013-08-27 7:09 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
Hi Luiz,
On 08/26/2013 02:08 PM, Luiz Augusto von Dentz wrote:
> Hi Christian,
>
> On Thu, Aug 22, 2013 at 7:08 PM, Christian Fetzer
> <christian.fetzer@oss.bmw-carit.de> wrote:
>> From: Christian Fetzer <christian.fetzer@bmw-carit.de>
>>
>> This patch adds property changed signal emissions in case message properties
>> change on the server.
>> ---
>> obexd/client/map.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
>> 1 file changed, 92 insertions(+), 2 deletions(-)
>>
>> diff --git a/obexd/client/map.c b/obexd/client/map.c
>> index 8864a54..a9a9bcd 100644
>> --- a/obexd/client/map.c
>> +++ b/obexd/client/map.c
>> @@ -792,121 +792,211 @@ static struct map_msg *map_msg_create(struct map_data *data, const char *handle)
>>
>> static void parse_subject(struct map_msg *msg, const char *value)
>> {
>> + if (g_strcmp0(msg->subject, value) == 0)
>> + return;
>> +
>> g_free(msg->subject);
>> msg->subject = g_strdup(value);
>> +
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "Subject");
>> }
>>
>> static void parse_datetime(struct map_msg *msg, const char *value)
>> {
>> + if (g_strcmp0(msg->timestamp, value) == 0)
>> + return;
>> +
>> g_free(msg->timestamp);
>> msg->timestamp = g_strdup(value);
>> +
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "Timestamp");
>> }
>>
>> static void parse_sender(struct map_msg *msg, const char *value)
>> {
>> + if (g_strcmp0(msg->sender, value) == 0)
>> + return;
>> +
>> g_free(msg->sender);
>> msg->sender = g_strdup(value);
>> +
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "Sender");
>> }
>>
>> static void parse_sender_address(struct map_msg *msg, const char *value)
>> {
>> + if (g_strcmp0(msg->sender_address, value) == 0)
>> + return;
>> +
>> g_free(msg->sender_address);
>> msg->sender_address = g_strdup(value);
>> +
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "SenderAddress");
>> }
>>
>> static void parse_replyto(struct map_msg *msg, const char *value)
>> {
>> + if (g_strcmp0(msg->replyto, value) == 0)
>> + return;
>> +
>> g_free(msg->replyto);
>> msg->replyto = g_strdup(value);
>> +
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "ReplyTo");
>> }
>>
>> static void parse_recipient(struct map_msg *msg, const char *value)
>> {
>> + if (g_strcmp0(msg->recipient, value) == 0)
>> + return;
>> +
>> g_free(msg->recipient);
>> msg->recipient = g_strdup(value);
>> +
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "Recipient");
>> }
>>
>> static void parse_recipient_address(struct map_msg *msg, const char *value)
>> {
>> + if (g_strcmp0(msg->recipient_address, value) == 0)
>> + return;
>> +
>> g_free(msg->recipient_address);
>> msg->recipient_address = g_strdup(value);
>> +
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "RecipientAddress");
>> }
>>
>> static void parse_type(struct map_msg *msg, const char *value)
>> {
>> + if (g_strcmp0(msg->type, value) == 0)
>> + return;
>> +
>> g_free(msg->type);
>> msg->type = g_strdup(value);
>> +
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "Type");
>> }
>>
>> static void parse_size(struct map_msg *msg, const char *value)
>> {
>> - msg->size = g_ascii_strtoll(value, NULL, 10);
>> + uint64_t size = g_ascii_strtoll(value, NULL, 10);
>> +
>> + if (msg->size == size)
>> + return;
>> +
>> + msg->size = size;
>> +
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "Size");
>> }
>>
>> static void parse_text(struct map_msg *msg, const char *value)
>> {
>> gboolean flag = strcasecmp(value, "no") != 0;
>>
>> + uint8_t oldflags = msg->flags;
>> if (flag)
>> msg->flags |= MAP_MSG_FLAG_TEXT;
>> else
>> msg->flags &= ~MAP_MSG_FLAG_TEXT;
>>
>> + if (msg->flags != oldflags)
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "Text");
>> }
>>
>> static void parse_status(struct map_msg *msg, const char *value)
>> {
>> + if (g_strcmp0(msg->status, value) == 0)
>> + return;
>> +
>> g_free(msg->status);
>> msg->status = g_strdup(value);
>> +
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "Status");
>> }
>>
>> static void parse_attachment_size(struct map_msg *msg, const char *value)
>> {
>> - msg->attachment_size = g_ascii_strtoll(value, NULL, 10);
>> + uint64_t attachment_size = g_ascii_strtoll(value, NULL, 10);
>> +
>> + if (msg->attachment_size == attachment_size)
>> + return;
>> +
>> + msg->attachment_size = attachment_size;
>> +
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "AttachmentSize");
>> }
>>
>> static void parse_priority(struct map_msg *msg, const char *value)
>> {
>> gboolean flag = strcasecmp(value, "no") != 0;
>>
>> + uint8_t oldflags = msg->flags;
>> if (flag)
>> msg->flags |= MAP_MSG_FLAG_PRIORITY;
>> else
>> msg->flags &= ~MAP_MSG_FLAG_PRIORITY;
>>
>> + if (msg->flags != oldflags)
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "Priority");
>> }
>>
>> static void parse_read(struct map_msg *msg, const char *value)
>> {
>> gboolean flag = strcasecmp(value, "no") != 0;
>>
>> + uint8_t oldflags = msg->flags;
>> if (flag)
>> msg->flags |= MAP_MSG_FLAG_READ;
>> else
>> msg->flags &= ~MAP_MSG_FLAG_READ;
>>
>> + if (msg->flags != oldflags)
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "Read");
>> }
>>
>> static void parse_sent(struct map_msg *msg, const char *value)
>> {
>> gboolean flag = strcasecmp(value, "no") != 0;
>>
>> + uint8_t oldflags = msg->flags;
>> if (flag)
>> msg->flags |= MAP_MSG_FLAG_SENT;
>> else
>> msg->flags &= ~MAP_MSG_FLAG_SENT;
>>
>> + if (msg->flags != oldflags)
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "Sent");
>> }
>>
>> static void parse_protected(struct map_msg *msg, const char *value)
>> {
>> gboolean flag = strcasecmp(value, "no") != 0;
>>
>> + uint8_t oldflags = msg->flags;
>> if (flag)
>> msg->flags |= MAP_MSG_FLAG_PROTECTED;
>> else
>> msg->flags &= ~MAP_MSG_FLAG_PROTECTED;
>>
>> + if (msg->flags != oldflags)
>> + g_dbus_emit_property_changed(conn, msg->path,
>> + MAP_MSG_INTERFACE, "Protected");
>> }
>>
>> static struct map_msg_parser {
>> --
>> 1.8.3.4
>
> Does this make us emit signals when creating the objects? That should
> probably not be necessary, only emit signals once the value really
> changes.
>
>
The property changed signals are not sent for newly created objects.
This is already ensured in g_dbus_emit_property_changed (gdbus/object.c:1709).
Do you prefer an additional check?
Thanks,
Christian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] obexd: Add property changed signals for 'org.bluez.obex.Message1'
2013-08-27 7:09 ` Christian Fetzer
@ 2013-09-02 10:43 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2013-09-02 10:43 UTC (permalink / raw)
To: Christian Fetzer; +Cc: linux-bluetooth@vger.kernel.org
Hi Christian,
On Tue, Aug 27, 2013 at 10:09 AM, Christian Fetzer
<christian.fetzer@oss.bmw-carit.de> wrote:
> Hi Luiz,
>
> On 08/26/2013 02:08 PM, Luiz Augusto von Dentz wrote:
>> Hi Christian,
>>
>> On Thu, Aug 22, 2013 at 7:08 PM, Christian Fetzer
>> <christian.fetzer@oss.bmw-carit.de> wrote:
>>> From: Christian Fetzer <christian.fetzer@bmw-carit.de>
>>>
>>> This patch adds property changed signal emissions in case message properties
>>> change on the server.
>>> ---
>>> obexd/client/map.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
>>> 1 file changed, 92 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/obexd/client/map.c b/obexd/client/map.c
>>> index 8864a54..a9a9bcd 100644
>>> --- a/obexd/client/map.c
>>> +++ b/obexd/client/map.c
>>> @@ -792,121 +792,211 @@ static struct map_msg *map_msg_create(struct map_data *data, const char *handle)
>>>
>>> static void parse_subject(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->subject, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->subject);
>>> msg->subject = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Subject");
>>> }
>>>
>>> static void parse_datetime(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->timestamp, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->timestamp);
>>> msg->timestamp = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Timestamp");
>>> }
>>>
>>> static void parse_sender(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->sender, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->sender);
>>> msg->sender = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Sender");
>>> }
>>>
>>> static void parse_sender_address(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->sender_address, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->sender_address);
>>> msg->sender_address = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "SenderAddress");
>>> }
>>>
>>> static void parse_replyto(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->replyto, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->replyto);
>>> msg->replyto = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "ReplyTo");
>>> }
>>>
>>> static void parse_recipient(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->recipient, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->recipient);
>>> msg->recipient = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Recipient");
>>> }
>>>
>>> static void parse_recipient_address(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->recipient_address, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->recipient_address);
>>> msg->recipient_address = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "RecipientAddress");
>>> }
>>>
>>> static void parse_type(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->type, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->type);
>>> msg->type = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Type");
>>> }
>>>
>>> static void parse_size(struct map_msg *msg, const char *value)
>>> {
>>> - msg->size = g_ascii_strtoll(value, NULL, 10);
>>> + uint64_t size = g_ascii_strtoll(value, NULL, 10);
>>> +
>>> + if (msg->size == size)
>>> + return;
>>> +
>>> + msg->size = size;
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Size");
>>> }
>>>
>>> static void parse_text(struct map_msg *msg, const char *value)
>>> {
>>> gboolean flag = strcasecmp(value, "no") != 0;
>>>
>>> + uint8_t oldflags = msg->flags;
>>> if (flag)
>>> msg->flags |= MAP_MSG_FLAG_TEXT;
>>> else
>>> msg->flags &= ~MAP_MSG_FLAG_TEXT;
>>>
>>> + if (msg->flags != oldflags)
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Text");
>>> }
>>>
>>> static void parse_status(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->status, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->status);
>>> msg->status = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Status");
>>> }
>>>
>>> static void parse_attachment_size(struct map_msg *msg, const char *value)
>>> {
>>> - msg->attachment_size = g_ascii_strtoll(value, NULL, 10);
>>> + uint64_t attachment_size = g_ascii_strtoll(value, NULL, 10);
>>> +
>>> + if (msg->attachment_size == attachment_size)
>>> + return;
>>> +
>>> + msg->attachment_size = attachment_size;
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "AttachmentSize");
>>> }
>>>
>>> static void parse_priority(struct map_msg *msg, const char *value)
>>> {
>>> gboolean flag = strcasecmp(value, "no") != 0;
>>>
>>> + uint8_t oldflags = msg->flags;
>>> if (flag)
>>> msg->flags |= MAP_MSG_FLAG_PRIORITY;
>>> else
>>> msg->flags &= ~MAP_MSG_FLAG_PRIORITY;
>>>
>>> + if (msg->flags != oldflags)
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Priority");
>>> }
>>>
>>> static void parse_read(struct map_msg *msg, const char *value)
>>> {
>>> gboolean flag = strcasecmp(value, "no") != 0;
>>>
>>> + uint8_t oldflags = msg->flags;
>>> if (flag)
>>> msg->flags |= MAP_MSG_FLAG_READ;
>>> else
>>> msg->flags &= ~MAP_MSG_FLAG_READ;
>>>
>>> + if (msg->flags != oldflags)
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Read");
>>> }
>>>
>>> static void parse_sent(struct map_msg *msg, const char *value)
>>> {
>>> gboolean flag = strcasecmp(value, "no") != 0;
>>>
>>> + uint8_t oldflags = msg->flags;
>>> if (flag)
>>> msg->flags |= MAP_MSG_FLAG_SENT;
>>> else
>>> msg->flags &= ~MAP_MSG_FLAG_SENT;
>>>
>>> + if (msg->flags != oldflags)
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Sent");
>>> }
>>>
>>> static void parse_protected(struct map_msg *msg, const char *value)
>>> {
>>> gboolean flag = strcasecmp(value, "no") != 0;
>>>
>>> + uint8_t oldflags = msg->flags;
>>> if (flag)
>>> msg->flags |= MAP_MSG_FLAG_PROTECTED;
>>> else
>>> msg->flags &= ~MAP_MSG_FLAG_PROTECTED;
>>>
>>> + if (msg->flags != oldflags)
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Protected");
>>> }
>>>
>>> static struct map_msg_parser {
>>> --
>>> 1.8.3.4
>>
>> Does this make us emit signals when creating the objects? That should
>> probably not be necessary, only emit signals once the value really
>> changes.
>>
>>
>
> The property changed signals are not sent for newly created objects.
> This is already ensured in g_dbus_emit_property_changed (gdbus/object.c:1709).
> Do you prefer an additional check?
Fair enough, I applied it after fixing the new line before defining
oldflags, it looks like it was a copy/paste error please make sure
this does not happen again.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-09-02 10:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-22 16:08 [PATCH 1/2] obexd: Use g_dbus_get_properties when parsing MAP-msg-listing Christian Fetzer
2013-08-22 16:08 ` [PATCH 2/2] obexd: Add property changed signals for 'org.bluez.obex.Message1' Christian Fetzer
2013-08-26 12:08 ` Luiz Augusto von Dentz
2013-08-27 7:09 ` Christian Fetzer
2013-09-02 10:43 ` Luiz Augusto von Dentz
2013-08-26 12:34 ` [PATCH 1/2] obexd: Use g_dbus_get_properties when parsing MAP-msg-listing Luiz Augusto von Dentz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).