Hi, On Mon, Sep 1, 2014 at 3:29 PM, Gowtham Anandha Babu <gowtham.ab@xxxxxxxxxxx> wrote: > The current message-dummy.c looks like, it is creating a virtual folder in the system (Ex. Home/PC-NAME/map-messages/). > So, I created the map-messages directory in home/PC-NAME/. Then I tried SETPATH (mentioned in the previous thread). > The output is... > > obexd[29146]: obexd/src/obex.c:cmd_setpath() > obexd[29146]: SETPATH(0x5), (null)(0xffffffff) > obexd[29146]: obexd/src/obex.c:parse_name() NAME: > obexd[29146]: obexd/plugins/mas.c:mas_setpath() SETPATH: name nonhdr 0x20 > obexd[29146]: SETPATH(0x5), SUCCESS(0x20) > > But When I tried to call GetFolderListing() > The output is... > > obexd[29146]: obexd/src/obex.c:cmd_get() session 0x1008c40 > obexd[29146]: GET(0x3), (null)(0xffffffff) > obexd[29146]: obexd/src/obex.c:parse_type() TYPE: x-obex/folder-listing > obexd[29146]: obexd/plugins/mas.c:mas_get() GET: name (null) type x-obex/folder-listing mas 0x1015c00 > obexd[29146]: obexd/plugins/mas.c:get_params() Error when parsing parameters! > obexd[29146]: GET(0x3), BAD_REQUEST(0x40) > > But I had few folders created inside the map-messages. Bad request is normally when there is something wrong with the command itself, the error comes from here: mas->inparams = g_obex_apparam_decode(buffer, size); if (mas->inparams == NULL) { DBG("Error when parsing parameters!"); return -EBADR; } I suspect the problem is that there is no application parameters set which is fine since all the parameters of GetFolderListing are optional, please try with the attached patch I will send it shortly as a proper patch to the mailing list. -- Luiz Augusto von Dentz
From ff67d84b6a07e0522ede32bb5c67f8ef914881cf Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx> Date: Mon, 1 Sep 2014 16:01:40 +0300 Subject: [PATCH BlueZ] obexd/mas: Fix parsing of application parameters Some commands don't have any mandatory application parameter which means inparams can be NULL which should not be treated as a bad request. --- obexd/plugins/mas.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c index 5729c22..6d7871a 100644 --- a/obexd/plugins/mas.c +++ b/obexd/plugins/mas.c @@ -84,7 +84,7 @@ static int get_params(struct obex_session *os, struct mas_session *mas) size = obex_get_apparam(os, &buffer); if (size < 0) - size = 0; + return 0; mas->inparams = g_obex_apparam_decode(buffer, size); if (mas->inparams == NULL) { @@ -249,7 +249,9 @@ static void get_messages_listing_cb(void *session, int err, uint16_t size, return; } - g_obex_apparam_get_uint16(mas->inparams, MAP_AP_MAXLISTCOUNT, &max); + if (mas->inparams) + g_obex_apparam_get_uint16(mas->inparams, MAP_AP_MAXLISTCOUNT, + &max); if (max == 0) { if (!entry) @@ -397,7 +399,9 @@ static void get_folder_listing_cb(void *session, int err, uint16_t size, return; } - g_obex_apparam_get_uint16(mas->inparams, MAP_AP_MAXLISTCOUNT, &max); + if (mas->inparams) + g_obex_apparam_get_uint16(mas->inparams, MAP_AP_MAXLISTCOUNT, + &max); if (max == 0) { if (err != -EAGAIN) @@ -493,8 +497,12 @@ static void *folder_listing_open(const char *name, int oflag, mode_t mode, DBG("name = %s", name); - g_obex_apparam_get_uint16(mas->inparams, MAP_AP_MAXLISTCOUNT, &max); - g_obex_apparam_get_uint16(mas->inparams, MAP_AP_STARTOFFSET, &offset); + if (mas->inparams) { + g_obex_apparam_get_uint16(mas->inparams, MAP_AP_MAXLISTCOUNT, + &max); + g_obex_apparam_get_uint16(mas->inparams, MAP_AP_STARTOFFSET, + &offset); + } *err = messages_get_folder_listing(mas->backend_data, name, max, offset, get_folder_listing_cb, mas); @@ -526,6 +534,9 @@ static void *msg_listing_open(const char *name, int oflag, mode_t mode, return NULL; } + if (!mas->inparams) + goto done; + g_obex_apparam_get_uint16(mas->inparams, MAP_AP_MAXLISTCOUNT, &max); g_obex_apparam_get_uint16(mas->inparams, MAP_AP_STARTOFFSET, &offset); g_obex_apparam_get_uint8(mas->inparams, MAP_AP_SUBJECTLENGTH, @@ -548,6 +559,7 @@ static void *msg_listing_open(const char *name, int oflag, mode_t mode, g_obex_apparam_get_uint8(mas->inparams, MAP_AP_FILTERPRIORITY, &filter.priority); +done: *err = messages_get_messages_listing(mas->backend_data, name, max, offset, subject_len, &filter, get_messages_listing_cb, mas); -- 1.9.3