From: Piotr Dabrowski
Date: Mon, 17 Oct 2016 08:25:12 +0000 (+0200)
Subject: initial MAP stub implementation
X-Git-Tag: accepted/tizen/3.0/common/20161209.094745~17
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cd5393e86343b7d29b8d7c8820775096bf12854f;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git
initial MAP stub implementation
Change-Id: Ic23c297cb65b69d05b2ec63ef3db414504ec3014
---
diff --git a/bt-api/CMakeLists.txt b/bt-api/CMakeLists.txt
index d2805d0..f649697 100644
--- a/bt-api/CMakeLists.txt
+++ b/bt-api/CMakeLists.txt
@@ -14,6 +14,7 @@ bt-hdp.c
bt-avrcp.c
bt-telephony.c
bt-opp-client.c
+bt-map-client.c
bt-obex-server.c
bt-rfcomm-client.c
bt-rfcomm-server.c
diff --git a/bt-api/bt-dpm.c b/bt-api/bt-dpm.c
index bbf4d6c..3c78062 100644
--- a/bt-api/bt-dpm.c
+++ b/bt-api/bt-dpm.c
@@ -154,6 +154,7 @@ static bt_dpm_status_e _bt_check_dpm_blacklist_uuid(char *uuid)
bluetooth_dpm_get_data_transfer_state(&dpm_status);
return (dpm_status == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
}
+ /* TODO: MAP? see above */
/* ++ check MDM profile restriction ++ */
if (g_strcmp0(BT_A2DP_UUID, uuid) == 0)
@@ -182,6 +183,7 @@ static bt_dpm_status_e _bt_check_dpm_transfer_restriction(void)
bt_dpm_status_t dpm_value = BLUETOOTH_DPM_ALLOWED;
dpm_status = _bt_check_dpm_blacklist_uuid(BT_OPP_UUID);
+ /* TODO: MAP? see above */
if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
return dpm_status;
@@ -273,6 +275,7 @@ int _bt_check_dpm(int service, void *param)
case BT_DPM_OPP:
status = _bt_check_dpm_transfer_restriction();
break;
+ /* TODO: MAP? see above */
case BT_DPM_HSP:
status = _bt_check_dpm_hsp_restriction();
break;
diff --git a/bt-api/bt-event-handler.c b/bt-api/bt-event-handler.c
index b861402..4d0d21a 100644
--- a/bt-api/bt-event-handler.c
+++ b/bt-api/bt-event-handler.c
@@ -1975,6 +1975,77 @@ void __bt_opp_server_event_filter(GDBusConnection *connection,
}
}
+void __bt_map_client_event_filter(GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ bt_event_info_t *event_info;
+ int result = BLUETOOTH_ERROR_NONE;
+ event_info = (bt_event_info_t *)user_data;
+ ret_if(event_info == NULL);
+
+ if (strcasecmp(object_path, BT_MAP_CLIENT_PATH) != 0)
+ return;
+ if (strcasecmp(interface_name, BT_EVENT_SERVICE) != 0)
+ return;
+
+ ret_if(signal_name == NULL);
+
+ if (strcasecmp(signal_name, BT_MAP_CONNECTED) == 0) {
+ const char *address = NULL;
+ int request_id = 0;
+ bluetooth_device_address_t dev_address = { {0} };
+
+ g_variant_get(parameters, "(i&si)", &result,
+ &address, &request_id);
+
+ if (__bt_is_request_id_exist(request_id) == FALSE) {
+ BT_ERR("Different request id!");
+ return;
+ }
+
+ _bt_convert_addr_string_to_type(dev_address.addr,
+ address);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_MAP_CONNECTED,
+ result, &dev_address,
+ event_info->cb, event_info->user_data);
+
+ if (result != BLUETOOTH_ERROR_NONE) {
+ __bt_remove_push_request_id(request_id);
+ }
+ } else if (strcasecmp(signal_name, BT_MAP_DISCONNECTED) == 0) {
+ const char *address = NULL;
+ int request_id = 0;
+ bluetooth_device_address_t dev_address = { {0} };
+
+ g_variant_get(parameters, "(i&si)", &result, &address,
+ &request_id);
+
+ if (__bt_is_request_id_exist(request_id) == FALSE) {
+ BT_ERR("Different request id!");
+ return;
+ }
+
+ _bt_convert_addr_string_to_type(dev_address.addr,
+ address);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_MAP_DISCONNECTED,
+ result, &dev_address,
+ event_info->cb, event_info->user_data);
+
+ __bt_remove_push_request_id(request_id);
+ } else if (strcasecmp(signal_name, BT_MAP_OP_COMPLETE) == 0) {
+
+ /* TODO: MAP, see __bt_opp_client_event_filter above */
+
+ }
+}
+
void __bt_pbap_client_event_filter(GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
@@ -2730,6 +2801,10 @@ int _bt_register_event(int event_type, void *event_cb, void *user_data)
event_func = __bt_opp_server_event_filter;
path = BT_OPP_SERVER_PATH;
break;
+ case BT_MAP_CLIENT_EVENT:
+ event_func = __bt_map_client_event_filter;
+ path = BT_MAP_CLIENT_PATH;
+ break;
case BT_PBAP_CLIENT_EVENT:
event_func = __bt_pbap_client_event_filter;
path = BT_PBAP_CLIENT_PATH;
diff --git a/bt-api/bt-map-client.c b/bt-api/bt-map-client.c
new file mode 100644
index 0000000..32bfebe
--- /dev/null
+++ b/bt-api/bt-map-client.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include
+
+#include "bluetooth-api.h"
+#include "bt-internal-types.h"
+
+#include "bt-common.h"
+#include "bt-request-sender.h"
+#include "bt-event-handler.h"
+
+#ifdef TIZEN_DPM_ENABLE
+#include "bt-dpm.h"
+#endif
+
+BT_EXPORT_API int bluetooth_map_init(void)
+{
+ bt_user_info_t *user_info;
+
+ user_info = _bt_get_user_data(BT_COMMON);
+ retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ return _bt_register_event(BT_MAP_CLIENT_EVENT, user_info->cb, user_info->user_data);
+}
+
+BT_EXPORT_API int bluetooth_map_deinit(void)
+{
+ return _bt_unregister_event(BT_MAP_CLIENT_EVENT);
+}
+
+/* TODO: MAP API */
diff --git a/bt-api/bt-request-sender.c b/bt-api/bt-request-sender.c
index 5f1ace5..df4812c 100644
--- a/bt-api/bt-request-sender.c
+++ b/bt-api/bt-request-sender.c
@@ -316,6 +316,9 @@ static void __send_request_cb(GDBusProxy *proxy,
BT_DBG("request_id : %d", request_id);
_bt_add_push_request_id(request_id);
}
+ if (cb_data->service_function == BT_MAP_111) {
+ /* TODO: MAP service functions */
+ }
goto done;
}
diff --git a/bt-api/include/bt-common.h b/bt-api/include/bt-common.h
index b863d34..6f476a7 100644
--- a/bt-api/include/bt-common.h
+++ b/bt-api/include/bt-common.h
@@ -274,6 +274,9 @@ void _bt_avrcp_event_cb(int event, int result, void *param,
void _bt_opp_client_event_cb(int event, int result, void *param,
void *callback, void *user_data);
+void _bt_map_client_event_cb(int event, int result, void *param,
+ void *callback, void *user_data);
+
void _bt_divide_device_class(bluetooth_device_class_t *device_class,
unsigned int cod);
diff --git a/bt-api/include/bt-dpm.h b/bt-api/include/bt-dpm.h
index ae64f97..6750506 100644
--- a/bt-api/include/bt-dpm.h
+++ b/bt-api/include/bt-dpm.h
@@ -45,6 +45,7 @@ typedef enum {
BT_DPM_A2DP,
BT_DPM_AVRCP,
BT_DPM_SPP,
+ /* TODO: MAP? see above */
} bt_dpm_service_e;
int _bt_check_dpm(int service, void *param);
diff --git a/bt-service-emul/CMakeLists.txt b/bt-service-emul/CMakeLists.txt
index e4f7299..8bcfd8b 100644
--- a/bt-service-emul/CMakeLists.txt
+++ b/bt-service-emul/CMakeLists.txt
@@ -16,6 +16,7 @@ bt-service-network.c
bt-service-audio.c
bt-service-oob.c
bt-service-opp-client.c
+bt-service-map-client.c
bt-service-obex-server.c
bt-service-rfcomm-client.c
bt-service-rfcomm-server.c
diff --git a/bt-service-emul/bt-request-handler.c b/bt-service-emul/bt-request-handler.c
index 9b2443d..27fac6c 100644
--- a/bt-service-emul/bt-request-handler.c
+++ b/bt-service-emul/bt-request-handler.c
@@ -36,6 +36,7 @@
#include "bt-service-avrcp.h"
#include "bt-service-avrcp-controller.h"
#include "bt-service-opp-client.h"
+#include "bt-service-map-client.h"
#include "bt-service-obex-server.h"
#include "bt-service-rfcomm-client.h"
#include "bt-service-rfcomm-server.h"
@@ -260,6 +261,7 @@ static void __bt_service_method(GDBusConnection *connection,
out_param1 = NULL;
}
}
+ /* TODO: MAP? see the if{}else{} above */
g_variant_unref(param1);
g_variant_unref(param2);
@@ -2029,6 +2031,7 @@ int __bt_obexd_request(int function_name,
sizeof(gboolean));
break;
}
+ /* TODO: MAP? MAP functions, see above */
case BT_OBEX_SERVER_ALLOCATE: {
int app_pid;
gboolean is_native;
@@ -2467,6 +2470,7 @@ gboolean __bt_service_check_privilege(int function_name,
case BT_OPP_PUSH_FILES:
case BT_OPP_CANCEL_PUSH:
+ /* TODO: MAP? MAP functions, see above */
case BT_OBEX_SERVER_ACCEPT_CONNECTION:
case BT_OBEX_SERVER_REJECT_CONNECTION:
diff --git a/bt-service-emul/bt-service-event-sender.c b/bt-service-emul/bt-service-event-sender.c
index 101f8ac..582f9ff 100644
--- a/bt-service-emul/bt-service-event-sender.c
+++ b/bt-service-emul/bt-service-event-sender.c
@@ -68,6 +68,9 @@ int _bt_send_event(int event_type, int event, GVariant *param)
case BT_OPP_SERVER_EVENT:
path = BT_OPP_SERVER_PATH;
break;
+ case BT_MAP_CLIENT_EVENT:
+ path = BT_MAP_CLIENT_PATH;
+ break;
case BT_PBAP_CLIENT_EVENT:
path = BT_PBAP_CLIENT_PATH;
break;
@@ -264,6 +267,14 @@ int _bt_send_event(int event_type, int event, GVariant *param)
signal = BT_OPP_DISCONNECTED;
BT_INFO_C("Disconnected [OPP]");
break;
+ case BLUETOOTH_EVENT_MAP_CONNECTED:
+ signal = BT_MAP_CONNECTED;
+ BT_INFO_C("Connected [MAP]");
+ break;
+ case BLUETOOTH_EVENT_MAP_DISCONNECTED:
+ signal = BT_MAP_DISCONNECTED;
+ BT_INFO_C("Disconnected [MAP]");
+ break;
case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED:
signal = BT_TRANSFER_CONNECTED;
break;
diff --git a/bt-service-emul/include/bt-service-common.h b/bt-service-emul/include/bt-service-common.h
index 4cc3b73..2e197e6 100644
--- a/bt-service-emul/include/bt-service-common.h
+++ b/bt-service-emul/include/bt-service-common.h
@@ -219,6 +219,7 @@ extern "C" {
#define PBAP_UUID "0000112f-0000-1000-8000-00805f9b34fb"
#define OBEX_OPP_UUID "00001105-0000-1000-8000-00805f9b34fb"
+#define OBEX_MAP_UUID "00001134-0000-1000-8000-00805f9b34fb"
#define OBEX_PSE_UUID "0000112f-0000-1000-8000-00805f9b34fb"
#define GATT_UUID "00001801-0000-1000-8000-00805f9b34fb"
diff --git a/bt-service/CMakeLists.txt b/bt-service/CMakeLists.txt
index c0f0abc..8318ee8 100644
--- a/bt-service/CMakeLists.txt
+++ b/bt-service/CMakeLists.txt
@@ -18,6 +18,7 @@ bt-service-audio.c
bt-service-oob.c
bt-service-obex-agent.c
bt-service-opp-client.c
+bt-service-map-client.c
bt-service-obex-server.c
bt-service-rfcomm-client.c
bt-service-rfcomm-server.c
diff --git a/bt-service/bt-request-handler.c b/bt-service/bt-request-handler.c
index 90d706b..026fea6 100644
--- a/bt-service/bt-request-handler.c
+++ b/bt-service/bt-request-handler.c
@@ -36,6 +36,7 @@
#include "bt-service-avrcp.h"
#include "bt-service-avrcp-controller.h"
#include "bt-service-opp-client.h"
+#include "bt-service-map-client.h"
#include "bt-service-obex-server.h"
#include "bt-service-rfcomm-client.h"
#include "bt-service-rfcomm-server.h"
@@ -263,6 +264,7 @@ static void __bt_service_method(GDBusConnection *connection,
out_param1 = NULL;
}
}
+ /* TODO: MAP? see the if{}else{} above */
g_variant_unref(param1);
g_variant_unref(param2);
@@ -2257,6 +2259,7 @@ int __bt_obexd_request(int function_name,
break;
}
+ /* TODO: MAP? MAP functions, see above */
case BT_OBEX_SERVER_ALLOCATE: {
int app_pid;
gboolean is_native;
@@ -2697,6 +2700,7 @@ gboolean __bt_service_check_privilege(int function_name,
case BT_OPP_PUSH_FILES:
case BT_OPP_CANCEL_PUSH:
+ /* TODO: MAP? MAP functions, see above */
case BT_OBEX_SERVER_ACCEPT_CONNECTION:
case BT_OBEX_SERVER_REJECT_CONNECTION:
diff --git a/bt-service/bt-service-adapter.c b/bt-service/bt-service-adapter.c
index 0b752d6..27300e0 100644
--- a/bt-service/bt-service-adapter.c
+++ b/bt-service/bt-service-adapter.c
@@ -37,6 +37,7 @@
#include "bt-service-network.h"
#include "bt-service-obex-server.h"
#include "bt-service-opp-client.h"
+#include "bt-service-map-client.h"
#include "bt-service-agent.h"
#include "bt-service-main.h"
#include "bt-service-avrcp.h"
diff --git a/bt-service/bt-service-agent.c b/bt-service/bt-service-agent.c
index c7f181b..b3cb43a 100644
--- a/bt-service/bt-service-agent.c
+++ b/bt-service/bt-service-agent.c
@@ -717,6 +717,7 @@ fail:
goto done;
}
+ /* TODO: MAP? see above */
if (_gap_agent_exist_osp_server(agent, BT_RFCOMM_SERVER,
(char *)uuid) == TRUE) {
@@ -740,6 +741,7 @@ fail:
request_type = BT_AGENT_EVENT_PBAP_REQUEST;
else if (!strcasecmp(uuid, MAP_UUID))
request_type = BT_AGENT_EVENT_MAP_REQUEST;
+ /* TODO: MAP is already here */
if (trust) {
BT_INFO("Trusted device, so authorize\n");
diff --git a/bt-service/bt-service-event-receiver.c b/bt-service/bt-service-event-receiver.c
index 374585d..ccad244 100644
--- a/bt-service/bt-service-event-receiver.c
+++ b/bt-service/bt-service-event-receiver.c
@@ -42,6 +42,7 @@
#include "bt-service-proximity.h"
#include "bt-service-opp-client.h"
+#include "bt-service-map-client.h"
#ifdef TIZEN_FEATURE_BT_DPM
#include "bt-service-dpm.h"
@@ -51,6 +52,7 @@
static GDBusConnection *manager_conn;
static GDBusConnection *obexd_conn;
static GDBusConnection *opc_obexd_conn;
+static GDBusConnection *map_obexd_conn;
static GList *p_cache_list = NULL;
@@ -77,13 +79,16 @@ typedef enum {
OBEX_PCSUITE = (1 << 6),
OBEX_SYNCEVOLUTION = (1 << 7),
OBEX_MAS = (1 << 8),
+ OBEX_MAP = (1 << 9),
} bluetooth_obex_connection_type_t;
void _bt_handle_property_changed_event(GVariant *msg, const char *object_path);
void _bt_opc_property_changed_event(GVariant *msg, char *path);
+void _bt_map_property_changed_event(GVariant *msg, char *path); /* TODO: MAP, do we need this? */
int _bt_register_service_event(GDBusConnection *g_conn, int event_type);
void _bt_unregister_service_event(GDBusConnection *g_conn, int event_type);
void _bt_opp_client_event_deinit(void);
+void _bt_map_client_event_deinit(void);
void _bt_handle_network_client_event(GVariant *msg_iter,
const char *path);
void __bt_gatt_char_property_changed_event(GVariant *msg_iter,
@@ -889,6 +894,7 @@ static void __bt_obex_property_changed_event(GVariant *msg, const char *path)
_bt_obex_transfer_progress(path, transferred);
}
+ /* TODO: MAP, "Complete"? see above */
g_free(property);
g_variant_unref(val);
g_variant_unref(child);
@@ -1458,6 +1464,18 @@ void _bt_opc_property_changed_event(GVariant *msg, char *path)
}
+void __bt_map_property_changed_event(GVariant *msg,
+ const char *path)
+{
+ /* TODO: MAP, do we need this? see above */
+}
+
+void _bt_map_property_changed_event(GVariant *msg, char *path)
+{
+ /* TODO: MAP, do we need this? see above */
+}
+
+
void _bt_handle_input_event(GVariant *msg, const char *path)
{
int result = BLUETOOTH_ERROR_NONE;
@@ -1923,6 +1941,7 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
_bt_opp_client_is_sending(&sending);
if (sending == TRUE)
_bt_opp_client_check_pending_transfer(address);
+ /* TODO: MAP? see above */
}
param = g_variant_new("(isy)", result, address, addr_type);
_bt_send_event(BT_DEVICE_EVENT,
@@ -2557,6 +2576,7 @@ void _bt_handle_agent_event(GVariant *msg, const char *member)
_bt_send_event(BT_OPP_SERVER_EVENT,
BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE,
param);
+ /* TODO: MAP? see above */
g_free(address);
g_free(name);
} else if (strcasecmp(member, "RfcommAuthorize") == 0) {
@@ -2896,6 +2916,7 @@ static void __bt_obexd_event_filter(GDBusConnection *connection,
BT_INFO("object_path = [%s]", obj_path);
/*Handle OPP_SERVER_CONNECTED_EVENT here */
+ /* TODO: MAP? see above */
if (strncmp(obj_path, BT_SESSION_BASEPATH_SERVER,
strlen(BT_SESSION_BASEPATH_SERVER)) != 0) {
g_free(obj_path);
@@ -2909,6 +2930,7 @@ static void __bt_obexd_event_filter(GDBusConnection *connection,
g_free(obj_path);
} else if (strcasecmp(member, "InterfacesRemoved") == 0) {
/*Handle OPP_SERVER_DISCONNECTED_EVENT here */
+ /* TODO: MAP? see above */
if (__bt_get_object_path(parameters, &obj_path)) {
BT_ERR("Fail to get the path");
return;
@@ -3059,6 +3081,53 @@ void _bt_opp_client_event_deinit(void)
}
}
+static void __bt_map_event_filter(GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ /* TODO: MAP, do we need this here? see above */
+}
+
+int _bt_map_client_event_init(void)
+{
+ GError *error = NULL;
+
+ if (map_obexd_conn == NULL) {
+ map_obexd_conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
+
+ if (!map_obexd_conn) {
+ if (error) {
+ BT_ERR("Unable to connect to dbus: %s", error->message);
+ g_clear_error(&error);
+ }
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+ }
+
+ if (_bt_register_service_event(map_obexd_conn,
+ BT_MAP_CLIENT_EVENT) != BLUETOOTH_ERROR_NONE) {
+ g_object_unref(map_obexd_conn);
+ map_obexd_conn = NULL;
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+void _bt_map_client_event_deinit(void)
+{
+ if (map_obexd_conn) {
+ _bt_unregister_service_event(map_obexd_conn,
+ BT_MAP_CLIENT_EVENT);
+ g_object_unref(map_obexd_conn);
+ map_obexd_conn = NULL;
+ }
+}
+
int _bt_register_manager_subscribe_signal(GDBusConnection *conn,
int subscribe)
{
@@ -3384,6 +3453,59 @@ int _bt_register_opp_client_subscribe_signal(GDBusConnection *conn,
return 0;
}
+int _bt_register_map_client_subscribe_signal(GDBusConnection *conn,
+ int subscribe)
+{
+ if (conn == NULL)
+ return -1;
+
+ static int subs_map_client_interface_added_id = -1;
+ static int subs_map_client_interface_removed_id = -1;
+ static int subs_map_client_property_id = -1;
+
+
+ if (subscribe) {
+ if (subs_map_client_interface_added_id == -1) {
+ subs_map_client_interface_added_id = g_dbus_connection_signal_subscribe(conn,
+ NULL, BT_MANAGER_INTERFACE,
+ BT_INTERFACES_ADDED, NULL, NULL, 0,
+ __bt_map_event_filter,
+ NULL, NULL);
+ }
+ if (subs_map_client_interface_removed_id == -1) {
+ subs_map_client_interface_removed_id = g_dbus_connection_signal_subscribe(conn,
+ NULL, BT_MANAGER_INTERFACE,
+ BT_INTERFACES_REMOVED, NULL, NULL, 0,
+ __bt_map_event_filter,
+ NULL, NULL);
+ }
+ if (subs_map_client_property_id == -1) {
+ subs_map_client_property_id = g_dbus_connection_signal_subscribe(conn,
+ NULL, BT_PROPERTIES_INTERFACE,
+ BT_PROPERTIES_CHANGED, NULL, NULL, 0,
+ __bt_map_event_filter,
+ NULL, NULL);
+ }
+ } else {
+ if (subs_map_client_interface_added_id != -1) {
+ g_dbus_connection_signal_unsubscribe(conn,
+ subs_map_client_interface_added_id);
+ subs_map_client_interface_added_id = -1;
+ }
+ if (subs_map_client_interface_removed_id != -1) {
+ g_dbus_connection_signal_unsubscribe(conn,
+ subs_map_client_interface_removed_id);
+ subs_map_client_interface_removed_id = -1;
+ }
+ if (subs_map_client_property_id != -1) {
+ g_dbus_connection_signal_unsubscribe(conn,
+ subs_map_client_property_id);
+ subs_map_client_property_id = -1;
+ }
+ }
+ return 0;
+}
+
int _bt_register_a2dp_subscribe_signal(GDBusConnection *conn,
int subscribe)
{
@@ -3491,6 +3613,10 @@ int _bt_register_service_event(GDBusConnection *g_conn, int event_type)
BT_ERR("BT_OPP_CLIENT_EVENT: register service event");
_bt_register_opp_client_subscribe_signal(g_conn, TRUE);
break;
+ case BT_MAP_CLIENT_EVENT:
+ BT_ERR("BT_MAP_CLIENT_EVENT: register service event");
+ _bt_register_map_client_subscribe_signal(g_conn, TRUE);
+ break;
case BT_A2DP_SOURCE_EVENT:
BT_INFO("A2dp Source event");
_bt_register_a2dp_subscribe_signal(g_conn, TRUE);
@@ -3523,6 +3649,9 @@ void _bt_unregister_service_event(GDBusConnection *g_conn, int event_type)
case BT_OPP_CLIENT_EVENT:
_bt_register_opp_client_subscribe_signal(g_conn, FALSE);
break;
+ case BT_MAP_CLIENT_EVENT:
+ _bt_register_map_client_subscribe_signal(g_conn, FALSE);
+ break;
default:
BT_ERR("Unknown event");
return;
diff --git a/bt-service/bt-service-event-sender.c b/bt-service/bt-service-event-sender.c
index 089d174..de9b216 100644
--- a/bt-service/bt-service-event-sender.c
+++ b/bt-service/bt-service-event-sender.c
@@ -100,6 +100,9 @@ int _bt_send_event(int event_type, int event, GVariant *param)
case BT_OPP_SERVER_EVENT:
path = BT_OPP_SERVER_PATH;
break;
+ case BT_MAP_CLIENT_EVENT:
+ path = BT_MAP_CLIENT_PATH;
+ break;
case BT_PBAP_CLIENT_EVENT:
path = BT_PBAP_CLIENT_PATH;
break;
@@ -317,6 +320,14 @@ int _bt_send_event(int event_type, int event, GVariant *param)
signal = BT_OPP_DISCONNECTED;
BT_INFO_C("Disconnected [OPP]");
break;
+ case BLUETOOTH_EVENT_MAP_CONNECTED:
+ signal = BT_MAP_CONNECTED;
+ BT_INFO_C("Connected [MAP]");
+ break;
+ case BLUETOOTH_EVENT_MAP_DISCONNECTED:
+ signal = BT_MAP_DISCONNECTED;
+ BT_INFO_C("Disconnected [MAP]");
+ break;
case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED:
signal = BT_TRANSFER_CONNECTED;
break;
diff --git a/bt-service/bt-service-headset-connection.c b/bt-service/bt-service-headset-connection.c
index f88ffce..4fa18d7 100644
--- a/bt-service/bt-service-headset-connection.c
+++ b/bt-service/bt-service-headset-connection.c
@@ -33,6 +33,7 @@
#include "bt-service-headset-connection.h"
#include "bt-service-opp-client.h"
+#include "bt-service-map-client.h"
diff --git a/bt-service/bt-service-map-client.c b/bt-service/bt-service-map-client.c
new file mode 100644
index 0000000..187854e
--- /dev/null
+++ b/bt-service/bt-service-map-client.c
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "bluetooth-api.h"
+#include "bt-internal-types.h"
+
+#include "bt-service-common.h"
+#include "bt-service-event.h"
+#include "bt-service-util.h"
+#include "bt-service-map-client.h"
+#include "bt-service-obex-agent.h"
+#include "bt-service-adapter.h"
+
+#define DBUS_TIEMOUT 20 * 1000 /* 20 Seconds */
+
+bt_session_info_t *session_info;
+
+static void __bt_free_session_info(bt_session_info_t *info)
+{
+ ret_if(info == NULL);
+
+ /* TODO: MAP bt_session_info_t, see bt-service-opp-client.c */
+
+ g_free(info->address);
+ g_free(info);
+}
+
+static void __bt_free_session_data(gpointer data)
+{
+ bt_session_data_t *info = data;
+
+ ret_if(info == NULL);
+
+ _bt_delete_request_id(info->request_id);
+
+ /* TODO: MAP bt_session_data_t, see bt-service-opp-client.c */
+
+ g_free(info->address);
+ g_free(info);
+}
+
+static void __bt_session_release_cb(GDBusProxy *proxy,
+ GAsyncResult *res, gpointer user_data)
+{
+ BT_DBG("+");
+ ret_if(session_info == NULL);
+
+ GError *error = NULL;
+ int result = BLUETOOTH_ERROR_NONE;
+ GVariant *param = NULL;
+ g_dbus_proxy_call_finish(proxy, res, &error);
+ if (proxy)
+ g_object_unref(proxy);
+
+ if (error) {
+ BT_ERR("%s", error->message);
+ g_error_free(error);
+
+ result = BLUETOOTH_ERROR_INTERNAL;
+ } else {
+ BT_DBG("Session Removed");
+ }
+
+ session_info->result = result;
+ param = g_variant_new("(isi)", session_info->result,
+ session_info->address,
+ session_info->request_id);
+ /* Send the event in only error none case */
+ _bt_send_event(BT_OPP_CLIENT_EVENT,
+ BLUETOOTH_EVENT_OPC_DISCONNECTED,
+ param);
+
+ __bt_free_session_info(session_info);
+ session_info = NULL;
+
+ _bt_map_client_event_deinit();
+
+ /* Operate remain works */
+ /* TODO: MAP */
+
+ return;
+fail:
+
+ BT_DBG("-");
+
+ return;
+}
+
+static int _bt_remove_session()
+{
+ GDBusConnection *g_conn;
+ GDBusProxy *session_proxy;
+ GError *err = NULL;
+
+ g_conn = _bt_gdbus_get_session_gconn();
+ retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+ retv_if(session_info->session_path == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
+
+ session_proxy = g_dbus_proxy_new_sync(g_conn, G_DBUS_PROXY_FLAGS_NONE,
+ NULL, BT_OBEXD_DBUS_NAME,
+ BT_OBEX_CLIENT_PATH,
+ BT_OBEX_CLIENT_INTERFACE,
+ NULL, &err);
+
+ retv_if(session_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ g_dbus_proxy_call(session_proxy, "RemoveSession",
+ g_variant_new("(o)", session_info->session_path),
+ G_DBUS_CALL_FLAGS_NONE,
+ DBUS_TIEMOUT, NULL,
+ (GAsyncReadyCallback)__bt_session_release_cb,
+ NULL);
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+void _bt_map_disconnected(const char *session_path)
+{
+ BT_DBG("+");
+ GVariant *param = NULL;
+ ret_if(session_info == NULL);
+
+ if (g_strcmp0(session_info->session_path,
+ session_path) != 0) {
+ BT_INFO("Path mismatch, previous transfer failed! Returning");
+ return;
+ }
+
+ param = g_variant_new("(isi)", session_info->result,
+ session_info->address,
+ session_info->request_id);
+ _bt_send_event(BT_MAP_CLIENT_EVENT,
+ BLUETOOTH_EVENT_MAP_DISCONNECTED,
+ param);
+
+ __bt_free_session_info(session_info);
+ session_info = NULL;
+
+ BT_DBG("-");
+}
+
+static void __bt_create_session_cb(GDBusProxy *proxy,
+ GAsyncResult *res, gpointer user_data)
+{
+ BT_DBG("+");
+
+ GError *error = NULL;
+ GVariant *value;
+ int result = BLUETOOTH_ERROR_NONE;
+ char *session_path = NULL;
+ GVariant *param = NULL;
+
+ value = g_dbus_proxy_call_finish(proxy, res, &error);
+ if (value) {
+ g_variant_get(value, "(o)", &session_path);
+ g_variant_unref(value);
+ }
+ if (error) {
+
+ BT_ERR("%s", error->message);
+ g_clear_error(&error);
+
+ result = BLUETOOTH_ERROR_INTERNAL;
+ } else {
+ BT_DBG("Session created");
+ if (session_info != NULL)
+ session_info->session_path = g_strdup(session_path);
+ }
+ g_free(session_path);
+ g_object_unref(proxy);
+ ret_if(session_info == NULL);
+
+ session_info->result = result;
+ param = g_variant_new("(isi)", result,
+ session_info->address,
+ session_info->request_id);
+ /* Send the event in only error none case */
+ _bt_send_event(BT_MAP_CLIENT_EVENT,
+ BLUETOOTH_EVENT_MAP_CONNECTED,
+ param);
+
+ if (result != BLUETOOTH_ERROR_NONE) {
+ BT_ERR("Calling __bt_session_release");
+ gboolean ret = __bt_session_release();
+
+ __bt_free_session_info(session_info);
+ session_info = NULL;
+
+ if (ret == FALSE) {
+ BT_DBG("ReleaseSession Not called");
+ /* Operate remain works */
+
+ /* TODO: MAP */
+
+ }
+ } else {
+
+ /* TODO: MAP */
+
+ }
+ BT_DBG("-");
+
+}
+
+static int __bt_opp_client_start_XXXXXXXXXX(int request_id, char *address
+ /* parameters................... */)
+{
+ /* TODO: MAP */
+}
+
+/* TODO: MAP */
diff --git a/bt-service/include/bt-service-common.h b/bt-service/include/bt-service-common.h
index a9d063a..84a5677 100644
--- a/bt-service/include/bt-service-common.h
+++ b/bt-service/include/bt-service-common.h
@@ -244,6 +244,7 @@ extern "C" {
#define PBAP_UUID "0000112f-0000-1000-8000-00805f9b34fb"
#define OBEX_OPP_UUID "00001105-0000-1000-8000-00805f9b34fb"
+#define OBEX_MAP_UUID "00001134-0000-1000-8000-00805f9b34fb"
#define OBEX_PSE_UUID "0000112f-0000-1000-8000-00805f9b34fb"
#define GATT_UUID "00001801-0000-1000-8000-00805f9b34fb"
diff --git a/bt-service/include/bt-service-event.h b/bt-service/include/bt-service-event.h
index 1a4cd75..4312e8f 100644
--- a/bt-service/include/bt-service-event.h
+++ b/bt-service/include/bt-service-event.h
@@ -38,6 +38,9 @@ void _bt_deinit_service_event_receiver(void);
int _bt_opp_client_event_init(void);
void _bt_opp_client_event_deinit(void);
+int _bt_map_client_event_init(void);
+void _bt_map_client_event_deinit(void);
+
int _bt_send_hf_local_term_event(char *address);
int _bt_init_hf_local_term_event_sender(void);
void _bt_deinit_hf_local_term_event_sender(void);
diff --git a/bt-service/include/bt-service-map-client.h b/bt-service/include/bt-service-map-client.h
new file mode 100644
index 0000000..a413387
--- /dev/null
+++ b/bt-service/include/bt-service-map-client.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+#ifndef _BT_SERVICE_MAP_CLIENT_H_
+#define _BT_SERVICE_MAP_CLIENT_H_
+
+#include
+#include
+#include
+#include "bluetooth-api.h"
+#include "bt-internal-types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define BT_OBEX_CLIENT_AGENT_PATH "/org/obex/client_agent"
+
+/* TODO: MAP */
+
+typedef struct {
+ int request_id;
+ int result;
+
+ char *session_path;
+
+ char *address;
+
+/* int file_count;
+ int file_offset;
+ char **file_name_array;
+ gboolean is_canceled; */
+
+ /* TODO: MAP */
+
+} bt_session_info_t; /* TODO: "session"? */
+
+typedef struct {
+ char *address;
+ int request_id;
+
+ /* char **file_path;
+ int file_count; */
+
+ /* TODO: MAP */
+
+} bt_session_data_t; /* TODO: "session"? */
+
+/* TODO: MAP */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /*_BT_SERVICE_MAP_CLIENT_H_*/
diff --git a/include/bluetooth-api.h b/include/bluetooth-api.h
index c50657c..46c1a80 100644
--- a/include/bluetooth-api.h
+++ b/include/bluetooth-api.h
@@ -509,6 +509,8 @@ typedef struct {
/**< Base ID for AVRCP events */
#define BLUETOOTH_EVENT_IPSP_BASE ((int)(BLUETOOTH_EVENT_AVRCP_CONTROL_BASE + 0x0020))
/**< Base ID for IPSP events */
+#define BLUETOOTH_EVENT_MAP_BASE ((int)(BLUETOOTH_EVENT_IPSP_BASE + 0x0020))
+ /**< Base ID for MAP events */
/**
* Bluetooth event type
@@ -588,6 +590,28 @@ typedef enum {
BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS, /* OPC Transfer progress event */
BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE, /* OPC Transfer Complete event */
+ BLUETOOTH_EVENT_MAP_CONNECTED = BLUETOOTH_EVENT_MAP_BASE,
+ BLUETOOTH_EVENT_MAP_DISCONNECTED,
+ /*
+ BLUETOOTH_EVENT_MAP_SET_FOLDER_COMPLETE,
+ BLUETOOTH_EVENT_MAP_SET_FOLDER_INVALID_ARGUMENTS,
+ BLUETOOTH_EVENT_MAP_SET_FOLDER_FAILED,
+ BLUETOOTH_EVENT_MAP_UPDATE_INBOX_COMPLETE,
+ BLUETOOTH_EVENT_MAP_UPDATE_INBOX_FAILED,
+ */
+ BLUETOOTH_EVENT_MAP_LIST_FOLDERS_COMPLETE,
+ BLUETOOTH_EVENT_MAP_LIST_FOLDERS_INVALID_ARGUMENTS,
+ BLUETOOTH_EVENT_MAP_LIST_FOLDERS_FAILED,
+ BLUETOOTH_EVENT_MAP_LIST_MESSAGES_COMPLETE,
+ BLUETOOTH_EVENT_MAP_LIST_MESSAGES_INVALID_ARGUMENTS,
+ BLUETOOTH_EVENT_MAP_LIST_MESSAGES_FAILED,
+ BLUETOOTH_EVENT_MAP_PUSH_MESSAGE_COMPLETE,
+ BLUETOOTH_EVENT_MAP_PUSH_MESSAGE_INVALID_ARGUMENTS,
+ BLUETOOTH_EVENT_MAP_PUSH_MESSAGE_FAILED,
+ BLUETOOTH_EVENT_MAP_GET_MESSAGE_COMPLETE,
+ BLUETOOTH_EVENT_MAP_GET_MESSAGE_INVALID_ARGUMENTS,
+ BLUETOOTH_EVENT_MAP_GET_MESSAGE_FAILED,
+
BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE = BLUETOOTH_EVENT_OBEX_SERVER_BASE,
/* Obex server authorize event*/
BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED, /* Obex Server transfer started event*/
@@ -709,6 +733,7 @@ typedef enum {
BLUETOOTH_DUN_PROFILE_UUID = ((unsigned short)0x1103), /**