5 * Copyright (C) 2010-2011 Nokia Corporation
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 /* List of OBEX application parameters tags as per MAP specification. */
29 MAP_AP_MAXLISTCOUNT = 0x01, /* uint16_t */
30 MAP_AP_STARTOFFSET = 0x02, /* uint16_t */
31 MAP_AP_FILTERMESSAGETYPE = 0x03, /* uint8_t */
32 MAP_AP_FILTERPERIODBEGIN = 0x04, /* char * */
33 MAP_AP_FILTERPERIODEND = 0x05, /* char * */
34 MAP_AP_FILTERREADSTATUS = 0x06, /* uint8_t */
35 MAP_AP_FILTERRECIPIENT = 0x07, /* char * */
36 MAP_AP_FILTERORIGINATOR = 0x08, /* char * */
37 MAP_AP_FILTERPRIORITY = 0x09, /* uint8_t */
38 MAP_AP_ATTACHMENT = 0x0A, /* uint8_t */
39 MAP_AP_TRANSPARENT = 0x0B, /* uint8_t */
40 MAP_AP_RETRY = 0x0C, /* uint8_t */
41 MAP_AP_NEWMESSAGE = 0x0D, /* uint8_t */
42 MAP_AP_NOTIFICATIONSTATUS = 0x0E, /* uint8_t */
43 MAP_AP_MASINSTANCEID = 0x0F, /* uint8_t */
44 MAP_AP_PARAMETERMASK = 0x10, /* uint32_t */
45 MAP_AP_FOLDERLISTINGSIZE = 0x11, /* uint16_t */
46 MAP_AP_MESSAGESLISTINGSIZE = 0x12, /* uint16_t */
47 MAP_AP_SUBJECTLENGTH = 0x13, /* uint8_t */
48 MAP_AP_CHARSET = 0x14, /* uint8_t */
49 MAP_AP_FRACTIONREQUEST = 0x15, /* uint8_t */
50 MAP_AP_FRACTIONDELIVER = 0x16, /* uint8_t */
51 MAP_AP_STATUSINDICATOR = 0x17, /* uint8_t */
52 MAP_AP_STATUSVALUE = 0x18, /* uint8_t */
53 MAP_AP_MSETIME = 0x19, /* char * */
54 #ifndef OPENSOURCE_PATCH
55 MAP_AP_INVALID = 0x100,
59 /* Data type representing MAP application parameters. Consider opaque. */
60 typedef GHashTable map_ap_t;
62 /* Creates a new empty MAP application parameters object. */
63 map_ap_t *map_ap_new(void);
65 /* Frees all the memory used by MAP application parameters object. */
66 void map_ap_free(map_ap_t *ap);
68 /* Parses given buffer that is a payload of OBEX application parameter header
69 * with a given length. Returned value can be used in calls to map_ap_get_*()
70 * and map_ap_set_*(). It has to be freed using map_ap_free(). It also takes
71 * care of converting all the data to host byte order, so this is the byte
72 * order used in map_ap_get_*()/map_ap_set_*().
74 * Returns NULL in case of failure.
76 map_ap_t *map_ap_decode(const uint8_t *buffer, size_t length);
78 /* Takes all parameters currently set and packs them into a buffer with OBEX
79 * application parameters header payload format.
81 * Returns newly allocated buffer of size 'length'. Free with g_free().
83 uint8_t *map_ap_encode(map_ap_t *ap, size_t *length);
85 /* Following family of functions reads value of MAP parameter with given tag.
86 * Use the one with appropriate type for a given tag, as noted above in
87 * map_ap_tag declaration comments.
89 * Returns TRUE when value is present. FALSE if it is not or the function is
90 * used get a parameter of a different type. When FALSE is returned, variable
91 * pointed by 'val' is left intact.
93 gboolean map_ap_get_u8(map_ap_t *ap, enum map_ap_tag tag, uint8_t *val);
94 gboolean map_ap_get_u16(map_ap_t *ap, enum map_ap_tag tag, uint16_t *val);
95 gboolean map_ap_get_u32(map_ap_t *ap, enum map_ap_tag tag, uint32_t *val);
97 /* Reads value of MAP parameter with given tag that is of a string type.
99 * Returns NULL if parameter is not present in ap or given tag is not of a
102 const char *map_ap_get_string(map_ap_t *ap, enum map_ap_tag tag);
104 /* Following family of functions sets the value of MAP parameter with given
105 * tag. Use the one with appropriate type for a given tag, as noted above in
106 * map_ap_tag declaration comments.
108 * If there is already a parameter with given tag present, it will be
109 * replaced. map_ap_set_string() makes its own copy of given string.
111 * Returns TRUE on success (the tag is known and the function chosen matches
114 gboolean map_ap_set_u8(map_ap_t *ap, enum map_ap_tag tag, uint8_t val);
115 gboolean map_ap_set_u16(map_ap_t *ap, enum map_ap_tag tag, uint16_t val);
116 gboolean map_ap_set_u32(map_ap_t *ap, enum map_ap_tag tag, uint32_t val);
117 gboolean map_ap_set_string(map_ap_t *ap, enum map_ap_tag tag, const char *val);