linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH obexd v2 1/4] MAP: Implementation of MAP AP core functions
@ 2012-01-13 13:33 Slawomir Bochenski
  2012-01-13 13:33 ` [PATCH obexd v2 2/4] map_ap.c: Add implementation for map_ap_set_* Slawomir Bochenski
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Slawomir Bochenski @ 2012-01-13 13:33 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Slawomir Bochenski

This adds implementation for creation and destruction of map_ap_t and
the definitions of MAP supported application parameters.
---
 src/map_ap.c |  107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 106 insertions(+), 1 deletions(-)

diff --git a/src/map_ap.c b/src/map_ap.c
index 9d13adf..8040b6d 100644
--- a/src/map_ap.c
+++ b/src/map_ap.c
@@ -27,13 +27,118 @@
 
 #include "map_ap.h"
 
+enum ap_type {
+	APT_UINT8,
+	APT_UINT16,
+	APT_UINT32,
+	APT_STR
+};
+
+static const struct ap_def {
+	enum map_ap_tag tag;
+	const char *name;
+	enum ap_type type;
+} ap_defs[] = {
+	{ MAP_AP_MAXLISTCOUNT,		"MAXLISTCOUNT",
+		APT_UINT16					},
+	{ MAP_AP_STARTOFFSET,		"STARTOFFSET",
+		APT_UINT16					},
+	{ MAP_AP_FILTERMESSAGETYPE,	"FILTERMESSAGETYPE",
+		APT_UINT8					},
+	{ MAP_AP_FILTERPERIODBEGIN,	"FILTERPERIODBEGIN",
+		APT_STR						},
+	{ MAP_AP_FILTERPERIODEND,	"FILTERPERIODEND",
+		APT_STR						},
+	{ MAP_AP_FILTERREADSTATUS,	"FILTERREADSTATUS",
+		APT_UINT8					},
+	{ MAP_AP_FILTERRECIPIENT,	"FILTERRECIPIENT",
+		APT_STR						},
+	{ MAP_AP_FILTERORIGINATOR,	"FILTERORIGINATOR",
+		APT_STR						},
+	{ MAP_AP_FILTERPRIORITY,	"FILTERPRIORITY",
+		APT_UINT8					},
+	{ MAP_AP_ATTACHMENT,		"ATTACHMENT",
+		APT_UINT8					},
+	{ MAP_AP_TRANSPARENT,		"TRANSPARENT",
+		APT_UINT8					},
+	{ MAP_AP_RETRY,			"RETRY",
+		APT_UINT8					},
+	{ MAP_AP_NEWMESSAGE,		"NEWMESSAGE",
+		APT_UINT8					},
+	{ MAP_AP_NOTIFICATIONSTATUS,	"NOTIFICATIONSTATUS",
+		APT_UINT8					},
+	{ MAP_AP_MASINSTANCEID,		"MASINSTANCEID",
+		APT_UINT8					},
+	{ MAP_AP_PARAMETERMASK,		"PARAMETERMASK",
+		APT_UINT32					},
+	{ MAP_AP_FOLDERLISTINGSIZE,	"FOLDERLISTINGSIZE",
+		APT_UINT16					},
+	{ MAP_AP_MESSAGESLISTINGSIZE,	"MESSAGESLISTINGSIZE",
+		APT_UINT16					},
+	{ MAP_AP_SUBJECTLENGTH,		"SUBJECTLENGTH",
+		APT_UINT8					},
+	{ MAP_AP_CHARSET,		"CHARSET",
+		APT_UINT8					},
+	{ MAP_AP_FRACTIONREQUEST,	"FRACTIONREQUEST",
+		APT_UINT8					},
+	{ MAP_AP_FRACTIONDELIVER,	"FRACTIONDELIVER",
+		APT_UINT8					},
+	{ MAP_AP_STATUSINDICATOR,	"STATUSINDICATOR",
+		APT_UINT8					},
+	{ MAP_AP_STATUSVALUE,		"STATUSVALUE",
+		APT_UINT8					},
+	{ MAP_AP_MSETIME,		"MSETIME",
+		APT_STR						},
+	{ MAP_AP_INVALID,		NULL,
+		0						},
+};
+
+struct ap_entry {
+	enum map_ap_tag tag;
+	union {
+		uint32_t val32u;
+		uint16_t val16u;
+		uint8_t val8u;
+		char *valstr;
+	};
+};
+
+static int find_ap_def(uint8_t tag)
+{
+	int i;
+
+	for (i = 0; ap_defs[i].tag != MAP_AP_INVALID; ++i)
+		if (ap_defs[i].tag == tag)
+			return i;
+
+	return -1;
+}
+
+static void ap_entry_free(gpointer val)
+{
+	struct ap_entry *entry = val;
+	int tago;
+
+	tago = find_ap_def(entry->tag);
+
+	if (tago >= 0 && ap_defs[tago].type == APT_STR)
+		g_free(entry->valstr);
+
+	g_free(entry);
+}
+
 map_ap_t *map_ap_new(void)
 {
-	return NULL;
+	return g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
+								ap_entry_free);
 }
 
 void map_ap_free(map_ap_t *ap)
 {
+	if (!ap)
+		return;
+
+	g_hash_table_destroy(ap);
 }
 
 map_ap_t *map_ap_decode(const uint8_t *buffer, size_t length)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-01-18 12:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-13 13:33 [PATCH obexd v2 1/4] MAP: Implementation of MAP AP core functions Slawomir Bochenski
2012-01-13 13:33 ` [PATCH obexd v2 2/4] map_ap.c: Add implementation for map_ap_set_* Slawomir Bochenski
2012-01-13 13:33 ` [PATCH obexd v2 3/4] map_ap.c: Add implementation for map_ap_decode() Slawomir Bochenski
2012-01-13 13:33 ` [PATCH obexd v2 4/4] map_ap.c: Add dumping of map_ap_t after decoding Slawomir Bochenski
2012-01-18 12:13 ` [PATCH obexd v2 1/4] MAP: Implementation of MAP AP core functions Johan Hedberg

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).