summaryrefslogtreecommitdiff
path: root/obexd
diff options
context:
space:
mode:
authorChristian Fetzer <christian.fetzer@bmw-carit.de>2013-09-23 11:24:27 +0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2013-09-26 15:47:30 +0300
commitf6e2691c08b3070bd33dde2006eb9d3ddde226f6 (patch)
treed686d981f96464c677f2b9d2a8cb631fa7e214f9 /obexd
parent0c254a041532435824feb39bacfa184349f79fbd (diff)
obexd: Fix setting message folder for relative folder in ListMessages
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.
Diffstat (limited to 'obexd')
-rw-r--r--obexd/client/map.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/obexd/client/map.c b/obexd/client/map.c
index 131b14058..e1f95f1ed 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,18 @@ done:
pending_request_free(request);
}
+static char *get_absolute_folder(struct map_data *map, const char *subfolder)
+{
+ const char *root = obc_session_get_folder(map->session);
+
+ 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 +1227,7 @@ 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(map, folder);
if (!obc_session_queue(map->session, transfer, message_listing_cb,
request, &err)) {