[PATCH v2 2/4] obexd: Fix setting message folder for relative folder in ListMessages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Christian Fetzer <christian.fetzer@xxxxxxxxxxxx>

The method ListMessages allows to specify a relative subfolder.
This subfolder needs to be added to the current path when registering
a new message interface.
---
 obexd/client/map.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/obexd/client/map.c b/obexd/client/map.c
index 131b140..45b4ef1 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -103,6 +103,7 @@ struct map_data {
 struct pending_request {
 	struct map_data *map;
 	DBusMessage *msg;
+	char *folder;
 };
 
 #define MAP_MSG_FLAG_PRIORITY	0x01
@@ -154,6 +155,7 @@ static void pending_request_free(struct pending_request *p)
 {
 	dbus_message_unref(p->msg);
 
+	g_free(p->folder);
 	g_free(p);
 }
 
@@ -1098,8 +1100,7 @@ static void msg_element(GMarkupParseContext *ctxt, const char *element,
 
 	msg = g_hash_table_lookup(data->messages, values[i]);
 	if (msg == NULL) {
-		msg = map_msg_create(data, values[i],
-					obc_session_get_folder(data->session));
+		msg = map_msg_create(data, values[i], parser->request->folder);
 		if (msg == NULL)
 			return;
 	}
@@ -1195,6 +1196,17 @@ done:
 	pending_request_free(request);
 }
 
+static char *get_absolute_folder(const char *root, const char *subfolder)
+{
+	if (!subfolder || strlen(subfolder) == 0)
+		return g_strdup(root);
+	else
+		if (g_str_has_suffix(root, "/"))
+			return g_strconcat(root, subfolder, NULL);
+		else
+			return g_strconcat(root, "/", subfolder, NULL);
+}
+
 static DBusMessage *get_message_listing(struct map_data *map,
 							DBusMessage *message,
 							const char *folder,
@@ -1214,6 +1226,8 @@ static DBusMessage *get_message_listing(struct map_data *map,
 	obc_transfer_set_apparam(transfer, apparam);
 
 	request = pending_request_new(map, message);
+	request->folder = get_absolute_folder(obc_session_get_folder(
+							map->session), folder);
 
 	if (!obc_session_queue(map->session, transfer, message_listing_cb,
 							request, &err)) {
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux