summaryrefslogtreecommitdiff
path: root/obexd
diff options
context:
space:
mode:
authorChristian Fetzer <christian.fetzer@bmw-carit.de>2013-04-09 13:51:37 +0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2013-04-10 14:56:46 +0300
commit518a51ad1d20f0430ab1a06d3920921f076c6184 (patch)
tree93e0fc15a0bbc622e592639d54192be6210f3e97 /obexd
parenteecf2d8c21ef4c0eb14436d6ab95e4515885767c (diff)
downloadbluez-518a51ad1d20f0430ab1a06d3920921f076c6184.tar.gz
obexd: Automatically setup notification connection for MAP client
This automatically establishes the MNS connection when the MAS client session is started and terminates the MNS connection when the MAS client session is closed. The MAP client controls the notification channel using the SetNotificationRegistration function. The MSE will connect/disconnect the MNS connection accordingly.
Diffstat (limited to 'obexd')
-rw-r--r--obexd/client/map.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/obexd/client/map.c b/obexd/client/map.c
index 2b665ec0d..3188a0873 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -27,6 +27,7 @@
#include <errno.h>
#include <string.h>
#include <stdio.h>
+#include <stdbool.h>
#include <glib.h>
#include <gdbus/gdbus.h>
#include <gobex/gobex-apparam.h>
@@ -1690,10 +1691,39 @@ static void map_msg_remove(void *data)
g_free(path);
}
+static bool set_notification_registration(struct map_data *map, bool status)
+{
+ struct obc_transfer *transfer;
+ GError *err = NULL;
+ GObexApparam *apparam;
+ char contents[2];
+
+ contents[0] = FILLER_BYTE;
+ contents[1] = '\0';
+
+ transfer = obc_transfer_put("x-bt/MAP-NotificationRegistration", NULL,
+ NULL, contents, sizeof(contents), &err);
+
+ if (transfer == NULL)
+ return false;
+
+ apparam = g_obex_apparam_set_uint8(NULL, MAP_AP_NOTIFICATIONSTATUS,
+ status);
+
+ obc_transfer_set_apparam(transfer, apparam);
+
+ if (obc_session_queue(map->session, transfer, NULL, map, &err))
+ return true;
+
+ return false;
+}
+
static void map_free(void *data)
{
struct map_data *map = data;
+ set_notification_registration(map, false);
+
obc_session_unref(map->session);
g_hash_table_unref(map->messages);
g_free(map);
@@ -1716,6 +1746,8 @@ static int map_probe(struct obc_session *session)
map->messages = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
map_msg_remove);
+ set_notification_registration(map, true);
+
if (!g_dbus_register_interface(conn, path, MAP_INTERFACE, map_methods,
NULL, NULL, map, map_free)) {
map_free(map);