MAP: Mark filter strings const
PATCH v3 1/3 MAP: Mark filter strings const
This structure is used for giving filters as input argument to messages_get_messages_listing(). There is no need for the string members to be modifiable in this context. And making them const plays well with map_ap_get_string(), from which the values of these members are going to be retrieved.
The string pointers here are simply references to data held in map_ap_t *inparams.
---
v3: Add paragraph about pointers being references to data held in another data structure.
plugins/messages.h | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
plugins/messages.h +4 -4
@@ -111,11 +111,11 @@ struct messages_event {struct messages_filter {uint32_t parameter_mask;uint8_t type; -char *period_begin; -char *period_end; +const char *period_begin; +const char *period_end;uint8_t read_status; -char *recipient; -char *originator; +const char *recipient; +const char *originator;uint8_t priority; };
Signature · 1 line
1.7.5.1
PATCH v3 2/3 MAP: Input parameters for GetMessagesListing
This adds support for input application parameters header given in GetMessagesListing request.
--- plugins/mas.c | 27 +++++++++++++++++++++++++-- 1 files changed, 25 insertions(+), 2 deletions(-)
plugins/mas.c +25 -2
@@ -531,6 +531,9 @@ static void *msg_listing_open(const char *name, int oflag, mode_t mode, {struct mas_session *mas = driver_data;struct messages_filter filter = {0 , }; +/* 1024 is the default when there was no MaxListCount sent */ +uint16_t max =1024 ; +uint16_t offset =0 ;DBG ("" );
@@ -539,8 +542,28 @@ static void *msg_listing_open(const char *name, int oflag, mode_t mode,return NULL ; } - *err =messages_get_messages_listing (mas->backend_data, name,0xffff ,0 , - &filter, +map_ap_get_u16 (mas->inparams,MAP_AP_MAXLISTCOUNT , &max); +map_ap_get_u16 (mas->inparams,MAP_AP_STARTOFFSET , &offset); + +map_ap_get_u32 (mas->inparams,MAP_AP_PARAMETERMASK , + &filter.parameter_mask); +map_ap_get_u8 (mas->inparams,MAP_AP_FILTERMESSAGETYPE , + &filter.type); + filter.period_begin =map_ap_get_string (mas->inparams, +MAP_AP_FILTERPERIODBEGIN ); + filter.period_end =map_ap_get_string (mas->inparams, +MAP_AP_FILTERPERIODEND ); +map_ap_get_u8 (mas->inparams,MAP_AP_FILTERREADSTATUS , + &filter.read_status); + filter.recipient =map_ap_get_string (mas->inparams, +MAP_AP_FILTERRECIPIENT ); + filter.originator =map_ap_get_string (mas->inparams, +MAP_AP_FILTERORIGINATOR ); +map_ap_get_u8 (mas->inparams,MAP_AP_FILTERPRIORITY , + &filter.priority); + + *err =messages_get_messages_listing (mas->backend_data, name, max, + offset, &filter, get_messages_listing_cb, mas); mas->buffer =g_string_new ("" );
Signature · 1 line
1.7.5.1
PATCH v3 3/3 MAP: Output parameters for GetMessagesListing
In reply to Slawomir BochenskiThis sets the parameters returned from MAP backend for GetMessagesListing to be used in application parameters header sent in response.
--- plugins/mas.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-)
plugins/mas.c +17 -0
@@ -282,12 +282,22 @@ static void get_messages_listing_cb(void *session, int err, uint16_t size, void *user_data) {struct mas_session *mas = user_data; +uint16_t max =1024 ;if (err <0 && err != -EAGAIN ) {obex_object_set_io_flags (mas,G_IO_ERR , err);return ; } +map_ap_get_u16 (mas->inparams,MAP_AP_MAXLISTCOUNT , &max); + +if (max ==0 ) { +if (!entry) + mas->finished = TRUE; + + goto proceed; + } +if (!mas->nth_call) {g_string_append (mas->buffer,ML_BODY_BEGIN ); mas->nth_call = TRUE;
@@ -379,6 +389,13 @@ static void get_messages_listing_cb(void *session, int err, uint16_t size,g_string_append (mas->buffer,"/>\n" ); proceed: +if (!entry) { +map_ap_set_u16 (mas->outparams,MAP_AP_MESSAGESLISTINGSIZE , + size); +map_ap_set_u8 (mas->outparams,MAP_AP_NEWMESSAGE , + newmsg ?1 :0 ); + } +if (err != -EAGAIN )obex_object_set_io_flags (mas,G_IO_IN ,0 ); }
Signature · 1 line
1.7.5.1
Hi Slawek,
Quoted 6 lines · Slawomir Bochenski
This structure is used for giving filters as input argument to
messages_get_messages_listing(). There is no need for the string members to be modifiable in this context. And making them const plays well withmap_ap_get_string(), from which the values of these members are going to be retrieved.
Quoted 6 lines
The string pointers here are simply references to data held in
map_ap_t*inparams.
---
v3: Add paragraph about pointers being references to data held in another data structure.plugins/messages.h | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
All three patches have been applied. Thanks.
Johan