2020-02-11 07:31:29

by Ajay Kishore

[permalink] [raw]
Subject: [PATCH v2 1/6] obexd: Add initial support for MAP conversations

Changes made to add a new method for MAP conversation listing i.e
"ListConversations" to handle conversation listing object
"x-bt/MAP-convo-listing".
---
obexd/client/map.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)

diff --git a/obexd/client/map.c b/obexd/client/map.c
index 550c5af..adf62d9 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -1560,6 +1560,69 @@ static DBusMessage *map_list_messages(DBusConnection *connection,
return get_message_listing(map, message, folder, apparam);
}

+static GObexApparam *parse_conversation_filters(GObexApparam *apparam,
+ DBusMessageIter *iter)
+{
+ DBusMessageIter array;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) {
+ DBG("Not of type array");
+ return NULL;
+ }
+
+ dbus_message_iter_recurse(iter, &array);
+
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
+ const char *key;
+ DBusMessageIter value, entry;
+
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &value);
+
+ /* TODO: Parse conversation filters */
+
+ dbus_message_iter_next(&array);
+ }
+ return apparam;
+}
+
+static DBusMessage *map_list_conversations(DBusConnection *connection,
+ DBusMessage *message,
+ void *user_data)
+{
+ struct map_data *map = user_data;
+ const char *folder;
+ GObexApparam *apparam;
+ DBusMessageIter args;
+
+ dbus_message_iter_init(message, &args);
+
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+ return g_dbus_create_error(message,
+ ERROR_INTERFACE ".InvalidArguments", NULL);
+
+ dbus_message_iter_get_basic(&args, &folder);
+
+ apparam = g_obex_apparam_set_uint16(NULL, MAP_AP_MAXLISTCOUNT,
+ DEFAULT_COUNT);
+ apparam = g_obex_apparam_set_uint16(apparam, MAP_AP_STARTOFFSET,
+ DEFAULT_OFFSET);
+
+ dbus_message_iter_next(&args);
+
+ if (parse_conversation_filters(apparam, &args) == NULL) {
+ g_obex_apparam_free(apparam);
+ return g_dbus_create_error(message,
+ ERROR_INTERFACE ".InvalidArguments", NULL);
+ }
+
+ /*TODO: Return conversation listing */
+ return NULL;
+}
+
static char **get_filter_strs(uint64_t filter, int *size)
{
char **list, **item;
@@ -1817,6 +1880,10 @@ static const GDBusMethodTable map_methods[] = {
GDBUS_ARGS({ "folder", "s" }, { "filter", "a{sv}" }),
GDBUS_ARGS({ "messages", "a{oa{sv}}" }),
map_list_messages) },
+ { GDBUS_ASYNC_METHOD("ListConversations",
+ GDBUS_ARGS({ "folder", "s" }, { "filter", "a{sv}" }),
+ GDBUS_ARGS({ "conversations", "a{oa{sv}}" }),
+ map_list_conversations) },
{ GDBUS_METHOD("ListFilterFields",
NULL,
GDBUS_ARGS({ "fields", "as" }),
--
2.7.4


2020-02-11 07:32:35

by Ajay Kishore

[permalink] [raw]
Subject: [PATCH v3 6/6] doc/obex-api: Update documentation

This adds documentation with the conversation listing feature
---
doc/obex-api.txt | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)

diff --git a/doc/obex-api.txt b/doc/obex-api.txt
index f39355a..ef81460 100644
--- a/doc/obex-api.txt
+++ b/doc/obex-api.txt
@@ -712,6 +712,44 @@ Methods void SetFolder(string name)
Possible errors: org.bluez.obex.Error.InvalidArguments
org.bluez.obex.Error.Failed

+ array{object, dict} ListConversations(string folder, dict filter)
+
+ Returns an array containing the conversations found in the
+ given subfolder of the current folder, or in the current
+ folder if folder is empty.
+
+ Possible Filters: MaxListCount, LastActivityBegin, LastActivityEnd,
+ ReadStatus, Recipient
+
+ Each message is represented by an object path followed
+ by a dictionary of the properties.
+
+ Properties:
+
+ string id:
+
+ Conversation unique identification
+
+ string last_activity:
+
+ Conversation timestamp for the last activity
+
+ string chat_state:
+
+ Conversation current chat state of the participants
+
+ string presence_availability:
+
+ Conversation participants availability
+
+ string presence_text:
+
+ User defined status of the conversation
+
+ Possible errors: org.bluez.obex.Error.InvalidArguments
+ org.bluez.obex.Error.Failed
+
+
void UpdateInbox(void)

Request remote to update its inbox.
@@ -799,6 +837,18 @@ Filter: uint16 Offset:
Possible values: True for high priority or False for
non-high priority

+ string LastActivityBegin:
+
+ Filter conversations by starting period.
+
+ Possible values: Date in "YYYYMMDDTHHMMSS" format.
+
+ string LastActivityEnd:
+
+ Filter conversations by ending period.
+
+ Possible values: Date in "YYYYMMDDTHHMMSS" format.
+
Message hierarchy
=================

--
2.7.4

2020-02-11 07:32:36

by Ajay Kishore

[permalink] [raw]
Subject: [PATCH v2 2/6] obexd: Add parsers for conversation filters

Changes made to add a new method to parse the map conversation filters.
Filters LastActivityBegin and LastActivityEnd is used to filter the
conversations that are returned in the Conversation-Listing object by
LastActivity.
---
obexd/client/map.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
obexd/src/map_ap.h | 3 +++
2 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/obexd/client/map.c b/obexd/client/map.c
index adf62d9..6e84a73 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -1369,6 +1369,21 @@ static GObexApparam *parse_filter_type(GObexApparam *apparam,
types);
}

+static GObexApparam *parse_la_begin(GObexApparam *apparam,
+ DBusMessageIter *iter)
+{
+ const char *string;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+ return NULL;
+
+ dbus_message_iter_get_basic(iter, &string);
+
+ return g_obex_apparam_set_string(apparam,
+ MAP_AP_FILTERLASTACTIVITYBEGIN,
+ string);
+}
+
static GObexApparam *parse_period_begin(GObexApparam *apparam,
DBusMessageIter *iter)
{
@@ -1397,6 +1412,20 @@ static GObexApparam *parse_period_end(GObexApparam *apparam,
string);
}

+static GObexApparam *parse_la_end(GObexApparam *apparam,
+ DBusMessageIter *iter)
+{
+ const char *string;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+ return NULL;
+
+ dbus_message_iter_get_basic(iter, &string);
+
+ return g_obex_apparam_set_string(apparam, MAP_AP_FILTERLASTACTIVITYEND,
+ string);
+}
+
static GObexApparam *parse_filter_read(GObexApparam *apparam,
DBusMessageIter *iter)
{
@@ -1560,6 +1589,19 @@ static DBusMessage *map_list_messages(DBusConnection *connection,
return get_message_listing(map, message, folder, apparam);
}

+static GObexApparam *parse_filter_conv_id(GObexApparam *apparam,
+ DBusMessageIter *iter)
+{
+ guint8 id;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_BYTE)
+ return NULL;
+
+ dbus_message_iter_get_basic(iter, &id);
+
+ return g_obex_apparam_set_uint8(apparam, MAP_AP_CONVERSATIONID, id);
+}
+
static GObexApparam *parse_conversation_filters(GObexApparam *apparam,
DBusMessageIter *iter)
{
@@ -1582,8 +1624,28 @@ static GObexApparam *parse_conversation_filters(GObexApparam *apparam,
dbus_message_iter_next(&entry);
dbus_message_iter_recurse(&entry, &value);

- /* TODO: Parse conversation filters */
-
+ if (strcasecmp(key, "Offset") == 0) {
+ if (parse_offset(apparam, &value) == NULL)
+ return NULL;
+ } else if (strcasecmp(key, "MaxCount") == 0) {
+ if (parse_max_count(apparam, &value) == NULL)
+ return NULL;
+ } else if (strcasecmp(key, "LastActivityBegin") == 0) {
+ if (parse_la_begin(apparam, &value) == NULL)
+ return NULL;
+ } else if (strcasecmp(key, "FilterLastActivityEnd") == 0) {
+ if (parse_la_end(apparam, &value) == NULL)
+ return NULL;
+ } else if (strcasecmp(key, "Read") == 0) {
+ if (parse_filter_read(apparam, &value) == NULL)
+ return NULL;
+ } else if (strcasecmp(key, "Recipient") == 0) {
+ if (parse_filter_recipient(apparam, &value) == NULL)
+ return NULL;
+ } else if (strcasecmp(key, "ConversationId") == 0) {
+ if (parse_filter_conv_id(apparam, &value) == NULL)
+ return NULL;
+ }
dbus_message_iter_next(&array);
}
return apparam;
diff --git a/obexd/src/map_ap.h b/obexd/src/map_ap.h
index da108fe..3773859 100644
--- a/obexd/src/map_ap.h
+++ b/obexd/src/map_ap.h
@@ -31,6 +31,8 @@ enum map_ap_tag {
MAP_AP_FILTERREADSTATUS = 0x06, /* uint8_t */
MAP_AP_FILTERRECIPIENT = 0x07, /* char * */
MAP_AP_FILTERORIGINATOR = 0x08, /* char * */
+ MAP_AP_FILTERLASTACTIVITYBEGIN = 0x08, /* char * */
+ MAP_AP_FILTERLASTACTIVITYEND = 0x09, /* char * */
MAP_AP_FILTERPRIORITY = 0x09, /* uint8_t */
MAP_AP_ATTACHMENT = 0x0A, /* uint8_t */
MAP_AP_TRANSPARENT = 0x0B, /* uint8_t */
@@ -48,4 +50,5 @@ enum map_ap_tag {
MAP_AP_STATUSINDICATOR = 0x17, /* uint8_t */
MAP_AP_STATUSVALUE = 0x18, /* uint8_t */
MAP_AP_MSETIME = 0x19, /* char * */
+ MAP_AP_CONVERSATIONID = 0x1C, /* uint32_t */
};
--
2.7.4

2020-02-11 21:40:34

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH v2 1/6] obexd: Add initial support for MAP conversations

Hi Ajay,

On Mon, Feb 10, 2020 at 11:32 PM Ajay Kishore <[email protected]> wrote:
>
> Changes made to add a new method for MAP conversation listing i.e
> "ListConversations" to handle conversation listing object
> "x-bt/MAP-convo-listing".
> ---
> obexd/client/map.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 67 insertions(+)
>
> diff --git a/obexd/client/map.c b/obexd/client/map.c
> index 550c5af..adf62d9 100644
> --- a/obexd/client/map.c
> +++ b/obexd/client/map.c
> @@ -1560,6 +1560,69 @@ static DBusMessage *map_list_messages(DBusConnection *connection,
> return get_message_listing(map, message, folder, apparam);
> }
>
> +static GObexApparam *parse_conversation_filters(GObexApparam *apparam,
> + DBusMessageIter *iter)
> +{
> + DBusMessageIter array;
> +
> + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) {
> + DBG("Not of type array");
> + return NULL;
> + }
> +
> + dbus_message_iter_recurse(iter, &array);
> +
> + while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
> + const char *key;
> + DBusMessageIter value, entry;
> +
> + dbus_message_iter_recurse(&array, &entry);
> + dbus_message_iter_get_basic(&entry, &key);
> +
> + dbus_message_iter_next(&entry);
> + dbus_message_iter_recurse(&entry, &value);
> +
> + /* TODO: Parse conversation filters */
> +
> + dbus_message_iter_next(&array);
> + }
> + return apparam;
> +}
> +
> +static DBusMessage *map_list_conversations(DBusConnection *connection,
> + DBusMessage *message,
> + void *user_data)
> +{
> + struct map_data *map = user_data;
> + const char *folder;
> + GObexApparam *apparam;
> + DBusMessageIter args;
> +
> + dbus_message_iter_init(message, &args);
> +
> + if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
> + return g_dbus_create_error(message,
> + ERROR_INTERFACE ".InvalidArguments", NULL);
> +
> + dbus_message_iter_get_basic(&args, &folder);
> +
> + apparam = g_obex_apparam_set_uint16(NULL, MAP_AP_MAXLISTCOUNT,
> + DEFAULT_COUNT);
> + apparam = g_obex_apparam_set_uint16(apparam, MAP_AP_STARTOFFSET,
> + DEFAULT_OFFSET);
> +
> + dbus_message_iter_next(&args);
> +
> + if (parse_conversation_filters(apparam, &args) == NULL) {
> + g_obex_apparam_free(apparam);
> + return g_dbus_create_error(message,
> + ERROR_INTERFACE ".InvalidArguments", NULL);
> + }
> +
> + /*TODO: Return conversation listing */
> + return NULL;
> +}
> +
> static char **get_filter_strs(uint64_t filter, int *size)
> {
> char **list, **item;
> @@ -1817,6 +1880,10 @@ static const GDBusMethodTable map_methods[] = {
> GDBUS_ARGS({ "folder", "s" }, { "filter", "a{sv}" }),
> GDBUS_ARGS({ "messages", "a{oa{sv}}" }),
> map_list_messages) },
> + { GDBUS_ASYNC_METHOD("ListConversations",
> + GDBUS_ARGS({ "folder", "s" }, { "filter", "a{sv}" }),
> + GDBUS_ARGS({ "conversations", "a{oa{sv}}" }),
> + map_list_conversations) },
> { GDBUS_METHOD("ListFilterFields",
> NULL,
> GDBUS_ARGS({ "fields", "as" }),
> --
> 2.7.4

I see some mix of v2 and v3 patches, I recommend updating the whole
set to v3 to make easier to review.


--
Luiz Augusto von Dentz

2020-03-05 09:20:28

by Ajay Kishore

[permalink] [raw]
Subject: RE: [PATCH v2 1/6] obexd: Add initial support for MAP conversations

Hi Luiz,

> -----Original Message-----
> From: [email protected] <linux-bluetooth-
> [email protected]> On Behalf Of Luiz Augusto von Dentz
> Sent: Wednesday, February 12, 2020 12:58 AM
> To: Kishore, Ajay <[email protected]>
> Cc: [email protected]
> Subject: Re: [PATCH v2 1/6] obexd: Add initial support for MAP conversations
>
> Hi Ajay,
>
> On Mon, Feb 10, 2020 at 11:32 PM Ajay Kishore <[email protected]>
> wrote:
> >
> > Changes made to add a new method for MAP conversation listing i.e
> > "ListConversations" to handle conversation listing object
> > "x-bt/MAP-convo-listing".
> > ---
> > obexd/client/map.c | 67
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 67 insertions(+)
> >
> > diff --git a/obexd/client/map.c b/obexd/client/map.c index
> > 550c5af..adf62d9 100644
> > --- a/obexd/client/map.c
> > +++ b/obexd/client/map.c
> > @@ -1560,6 +1560,69 @@ static DBusMessage
> *map_list_messages(DBusConnection *connection,
> > return get_message_listing(map, message, folder, apparam); }
> >
> > +static GObexApparam *parse_conversation_filters(GObexApparam
> *apparam,
> > +
> > +DBusMessageIter *iter) {
> > + DBusMessageIter array;
> > +
> > + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) {
> > + DBG("Not of type array");
> > + return NULL;
> > + }
> > +
> > + dbus_message_iter_recurse(iter, &array);
> > +
> > + while (dbus_message_iter_get_arg_type(&array) ==
> DBUS_TYPE_DICT_ENTRY) {
> > + const char *key;
> > + DBusMessageIter value, entry;
> > +
> > + dbus_message_iter_recurse(&array, &entry);
> > + dbus_message_iter_get_basic(&entry, &key);
> > +
> > + dbus_message_iter_next(&entry);
> > + dbus_message_iter_recurse(&entry, &value);
> > +
> > + /* TODO: Parse conversation filters */
> > +
> > + dbus_message_iter_next(&array);
> > + }
> > + return apparam;
> > +}
> > +
> > +static DBusMessage *map_list_conversations(DBusConnection *connection,
> > + DBusMessage *message,
> > + void *user_data) {
> > + struct map_data *map = user_data;
> > + const char *folder;
> > + GObexApparam *apparam;
> > + DBusMessageIter args;
> > +
> > + dbus_message_iter_init(message, &args);
> > +
> > + if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
> > + return g_dbus_create_error(message,
> > + ERROR_INTERFACE ".InvalidArguments", NULL);
> > +
> > + dbus_message_iter_get_basic(&args, &folder);
> > +
> > + apparam = g_obex_apparam_set_uint16(NULL,
> MAP_AP_MAXLISTCOUNT,
> > + DEFAULT_COUNT);
> > + apparam = g_obex_apparam_set_uint16(apparam,
> MAP_AP_STARTOFFSET,
> > +
> > + DEFAULT_OFFSET);
> > +
> > + dbus_message_iter_next(&args);
> > +
> > + if (parse_conversation_filters(apparam, &args) == NULL) {
> > + g_obex_apparam_free(apparam);
> > + return g_dbus_create_error(message,
> > + ERROR_INTERFACE ".InvalidArguments", NULL);
> > + }
> > +
> > + /*TODO: Return conversation listing */
> > + return NULL;
> > +}
> > +
> > static char **get_filter_strs(uint64_t filter, int *size) {
> > char **list, **item;
> > @@ -1817,6 +1880,10 @@ static const GDBusMethodTable map_methods[] =
> {
> > GDBUS_ARGS({ "folder", "s" }, { "filter", "a{sv}" }),
> > GDBUS_ARGS({ "messages", "a{oa{sv}}" }),
> > map_list_messages) },
> > + { GDBUS_ASYNC_METHOD("ListConversations",
> > + GDBUS_ARGS({ "folder", "s" }, { "filter", "a{sv}" }),
> > + GDBUS_ARGS({ "conversations", "a{oa{sv}}" }),
> > + map_list_conversations) },
> > { GDBUS_METHOD("ListFilterFields",
> > NULL,
> > GDBUS_ARGS({ "fields", "as" }),
> > --
> > 2.7.4
>
> I see some mix of v2 and v3 patches, I recommend updating the whole set to v3
> to make easier to review.
Done.
>
>
> --
> Luiz Augusto von Dentz

Thanks.
Ajay