Diff between 9e8e5065019ba8a0f04330daa604257e97348825 and b5d625fea3734bf7030fcc6169227416f5a759be

Changed Files

File Additions Deletions Status
obexd/plugins/mas.c +31 -0 modified

Full Patch

diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c
index 23b1823..8eefe5f 100644
--- a/obexd/plugins/mas.c
+++ b/obexd/plugins/mas.c
@@ -38,6 +38,7 @@
 #include "mimetype.h"
 #include "filesystem.h"
 #include "manager.h"
+#include "map_ap.h"
 
 #include "messages.h"
 
@@ -108,12 +109,31 @@ struct mas_session {
 	gboolean finished;
 	gboolean nth_call;
 	GString *buffer;
+	map_ap_t *inparams;
 };
 
 static const uint8_t MAS_TARGET[TARGET_SIZE] = {
 			0xbb, 0x58, 0x2b, 0x40, 0x42, 0x0c, 0x11, 0xdb,
 			0xb0, 0xde, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66  };
 
+static int get_params(struct obex_session *os, struct mas_session *mas)
+{
+	const uint8_t *buffer;
+	ssize_t size;
+
+	size = obex_get_apparam(os, &buffer);
+	if (size < 0)
+		size = 0;
+
+	mas->inparams = map_ap_decode(buffer, size);
+	if (mas->inparams == NULL) {
+		DBG("Error when parsing parameters!");
+		return -EBADR;
+	}
+
+	return 0;
+}
+
 static void reset_request(struct mas_session *mas)
 {
 	if (mas->buffer) {
@@ -121,6 +141,9 @@ static void reset_request(struct mas_session *mas)
 		mas->buffer = NULL;
 	}
 
+	map_ap_free(mas->inparams);
+	mas->inparams = NULL;
+
 	mas->nth_call = FALSE;
 	mas->finished = FALSE;
 }
@@ -178,6 +201,10 @@ static int mas_get(struct obex_session *os, void *user_data)
 	if (type == NULL)
 		return -EBADR;
 
+	ret = get_params(os, mas);
+	if (ret < 0)
+		goto failed;
+
 	ret = obex_get_stream_start(os, name);
 	if (ret < 0)
 		goto failed;
@@ -202,6 +229,10 @@ static int mas_put(struct obex_session *os, void *user_data)
 	if (type == NULL)
 		return -EBADR;
 
+	ret = get_params(os, mas);
+	if (ret < 0)
+		goto failed;
+
 	ret = obex_put_stream_start(os, name);
 	if (ret < 0)
 		goto failed;