#include "bt-common.h"
#include "bluetooth-telephony-api.h"
#include "marshal.h"
+#include "bt-internal-types.h"
#define BT_SCO_TIMEOUT 3000
const char *interface, const char *method,
GError **err, GVariant *parameters)
{
-#if defined(TIZEN_PROFILE_WEARABLE) || defined(TIZEN_PROFILE_IVI)
- int timeout = 4000;
-#else
int timeout = -1;
-#endif
+
+ if (TIZEN_PROFILE_WEARABLE || TIZEN_PROFILE_IVI)
+ timeout = 4000;
+
GVariant *reply;
GDBusProxy *proxy;
GDBusConnection *conn;
node_info = __bt_telephony_create_method_node_info(
bt_telephony_introspection_xml);
-
if (node_info == NULL) {
BT_ERR("node_info NULL");
return BLUETOOTH_TELEPHONY_ERROR_INVALID_PARAM;
if (__bluetooth_telephony_register_object(TRUE, node_info) !=
BLUETOOTH_TELEPHONY_ERROR_NONE) {
BT_ERR("Registation of Method Failed");
+ g_dbus_node_info_unref(node_info);
return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
}
FN_END;
+ g_dbus_node_info_unref(node_info);
return BLUETOOTH_TELEPHONY_ERROR_NONE;
}
return BLUETOOTH_TELEPHONY_ERROR_NONE;
}
-#if defined(TIZEN_PROFILE_WEARABLE) || defined(TIZEN_PROFILE_IVI)
static void __bluetooth_telephony_init_headset_state(void)
{
GVariant *reply;
FN_END;
}
-#endif
static gboolean __bluetooth_telephony_is_headset(uint32_t device_class)
{
if (conn == NULL)
return -1;
- static int subscribe_adapter_id = -1;
+ static guint subscribe_adapter_id = 0;
+
if (subscribe == TRUE) {
- if (subscribe_adapter_id == -1) {
+ if (subscribe_adapter_id == 0) {
subscribe_adapter_id = g_dbus_connection_signal_subscribe(conn,
NULL, "org.freedesktop.DBus.ObjectManager",
"InterfacesAdded", NULL, NULL, 0,
}
return BLUETOOTH_TELEPHONY_ERROR_NONE;
} else {
- if (subscribe_adapter_id != -1) {
+ if (subscribe_adapter_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subscribe_adapter_id);
- subscribe_adapter_id = -1;
+ subscribe_adapter_id = 0;
}
return BLUETOOTH_TELEPHONY_ERROR_NONE;
}
if (conn == NULL)
return -1;
- static int subscribe_event1_id = -1;
- static int subscribe_event2_id = -1;
- static int subscribe_event3_id = -1;
- static int subscribe_event4_id = -1;
- static int subscribe_event5_id = -1;
- static int subscribe_event6_id = -1;
+ static guint subscribe_event1_id = 0;
+ static guint subscribe_event2_id = 0;
+ static guint subscribe_event3_id = 0;
+ static guint subscribe_event4_id = 0;
+ static guint subscribe_event5_id = 0;
+ static guint subscribe_event6_id = 0;
+
if (subscribe == TRUE) {
- if (subscribe_event1_id == -1) {
+ if (subscribe_event1_id == 0) {
subscribe_event1_id = g_dbus_connection_signal_subscribe(conn,
NULL, BLUEZ_HEADSET_INTERFACE,
"PropertyChanged", NULL, NULL, 0,
__bluetooth_telephony_event_filter,
NULL, NULL);
}
- if (subscribe_event2_id == -1) {
+ if (subscribe_event2_id == 0) {
subscribe_event2_id = g_dbus_connection_signal_subscribe(conn,
NULL, HFP_AGENT_SERVICE,
HFP_NREC_STATUS_CHANGE, NULL, NULL, 0,
NULL, NULL);
}
- if (subscribe_event3_id == -1) {
+ if (subscribe_event3_id == 0) {
subscribe_event3_id = g_dbus_connection_signal_subscribe(conn,
NULL, HFP_AGENT_SERVICE,
HFP_ANSWER_CALL, NULL, NULL, 0,
__bluetooth_telephony_event_filter,
NULL, NULL);
}
- if (subscribe_event4_id == -1) {
+ if (subscribe_event4_id == 0) {
subscribe_event4_id = g_dbus_connection_signal_subscribe(conn,
NULL, HFP_AGENT_SERVICE,
HFP_REJECT_CALL, NULL, NULL, 0,
__bluetooth_telephony_event_filter,
NULL, NULL);
}
- if (subscribe_event5_id == -1) {
+ if (subscribe_event5_id == 0) {
subscribe_event5_id = g_dbus_connection_signal_subscribe(conn,
NULL, HFP_AGENT_SERVICE,
HFP_RELEASE_CALL, NULL, NULL, 0,
__bluetooth_telephony_event_filter,
NULL, NULL);
}
- if (subscribe_event6_id == -1) {
+ if (subscribe_event6_id == 0) {
subscribe_event6_id = g_dbus_connection_signal_subscribe(conn,
NULL, HFP_AGENT_SERVICE,
HFP_THREEWAY_CALL, NULL, NULL, 0,
return BLUETOOTH_TELEPHONY_ERROR_NONE;
} else {
- if (subscribe_event1_id != -1) {
+ if (subscribe_event1_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subscribe_event1_id);
- subscribe_event1_id = -1;
+ subscribe_event1_id = 0;
}
- if (subscribe_event2_id != -1) {
+ if (subscribe_event2_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subscribe_event2_id);
- subscribe_event2_id = -1;
+ subscribe_event2_id = 0;
}
- if (subscribe_event3_id != -1) {
+ if (subscribe_event3_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subscribe_event3_id);
- subscribe_event3_id = -1;
+ subscribe_event3_id = 0;
}
- if (subscribe_event4_id != -1) {
+ if (subscribe_event4_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subscribe_event4_id);
- subscribe_event4_id = -1;
+ subscribe_event4_id = 0;
}
- if (subscribe_event5_id != -1) {
+ if (subscribe_event5_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subscribe_event5_id);
- subscribe_event5_id = -1;
+ subscribe_event5_id = 0;
}
- if (subscribe_event6_id != -1) {
+ if (subscribe_event6_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subscribe_event6_id);
- subscribe_event6_id = -1;
+ subscribe_event6_id = 0;
}
return BLUETOOTH_TELEPHONY_ERROR_NONE;
}
goto fail;
}
-#if defined(TIZEN_PROFILE_WEARABLE) || defined(TIZEN_PROFILE_IVI)
- __bluetooth_telephony_init_headset_state();
-#endif
+ if (TIZEN_PROFILE_WEARABLE || TIZEN_PROFILE_IVI)
+ __bluetooth_telephony_init_headset_state();
FN_END;
return ret;
g_variant_get(reply, "(b)", &status);
g_variant_unref(reply);
-#if defined(TIZEN_PROFILE_WEARABLE) || defined(TIZEN_PROFILE_IVI)
- if (status == TRUE && telephony_info.headset_state != BLUETOOTH_STATE_PLAYING)
- telephony_info.headset_state = BLUETOOTH_STATE_PLAYING;
-#endif
+ if (TIZEN_PROFILE_WEARABLE || TIZEN_PROFILE_IVI)
+ if (status == TRUE && telephony_info.headset_state != BLUETOOTH_STATE_PLAYING)
+ telephony_info.headset_state = BLUETOOTH_STATE_PLAYING;
BT_INFO("SCO Connected Status = [%d]", status);
return status;
{
GError *error = NULL;
GVariant *reply, *parameters;
+ int ret = BLUETOOTH_TELEPHONY_ERROR_NONE;
FN_START;
g_variant_unref(reply);
+ if (error) {
+ g_dbus_error_strip_remote_error(error);
+ ret = __bt_telephony_get_error(error->message);
+ BT_ERR("Error here %d\n", ret);
+ g_error_free(error);
+ }
+
FN_END;
- return BLUETOOTH_TELEPHONY_ERROR_NONE;
+ return ret;
}
BT_EXPORT_API int bluetooth_telephony_start_voice_recognition(void)
GAsyncResult *res, gpointer user_data)
{
GError *error = NULL;
- GVariant *value;
+ GVariant *value = NULL;
value = g_dbus_proxy_call_finish(proxy, res, &error);
if (value == NULL) {
} else {
BT_ERR("SCo Start Failed");
}
+ g_object_unref(proxy);
+ return;
}
BT_DBG("sco_start_cb : -");
GAsyncResult *res, gpointer user_data)
{
GError *error = NULL;
- GVariant *value;
+ GVariant *value = NULL;
value = g_dbus_proxy_call_finish(proxy, res, &error);
if (value == NULL) {
} else {
BT_ERR("SCo close Failed");
}
+ g_object_unref(proxy);
+ return;
}
BT_DBG("sco_close_cb : -");
/*Make sure SCO is already connected */
ret = __bluetooth_telephony_send_call_status(
CSD_CALL_STATUS_MO_ALERTING, call_id, NULL);
- if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE) {
+
+ if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE)
BT_ERR("send call status Failed = [%d]", ret);
- return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
- }
+
FN_END;
- return BLUETOOTH_TELEPHONY_ERROR_NONE;
+ return ret;
}
BT_EXPORT_API int bluetooth_telephony_call_answered(unsigned int call_id,
if (bt_audio) {
if (!bluetooth_telephony_is_sco_connected()) {
ret = bluetooth_telephony_audio_open();
- if (ret != 0) {
+ if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE)
BT_ERR("Audio connection call Failed[%d]", ret);
- return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
- }
}
}
ret = __bluetooth_telephony_send_call_status(CSD_CALL_STATUS_MT_RELEASE,
call_id, NULL);
- if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE) {
+ if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE)
BT_ERR("send call status Failed = [%d]", ret);
- return ret;
- }
FN_END;
return ret;
GVariant *param;
GError *err = NULL;
const char *path = telephony_info.call_path;
- int ret;
+ int ret = BLUETOOTH_TELEPHONY_ERROR_NONE;
FN_START;
if (bt_audio) {
if (!bluetooth_telephony_is_sco_connected()) {
ret = bluetooth_telephony_audio_open();
- if (ret != 0) {
+ if (ret != 0)
BT_ERR(" Audio connection Failed = %d", ret);
- return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
- }
}
}
FN_END;
- return BLUETOOTH_TELEPHONY_ERROR_NONE;
+ return ret;
}
BT_EXPORT_API int bluetooth_telephony_indicate_incoming_call(
return BLUETOOTH_ERROR_NONE;
}
+BT_EXPORT_API int bluetooth_telephony_set_active_headset(const char *remote_addr)
+{
+#ifdef TIZEN_BT_DUAL_HEADSET_CONNECT
+ GVariant *reply;
+ GVariant *param;
+ GError *err = NULL;
+ int ret;
+
+ BT_CHECK_ENABLED(return);
+
+ if (NULL == remote_addr)
+ return BLUETOOTH_TELEPHONY_ERROR_INVALID_PARAM;
+
+ param = g_variant_new("(s)", remote_addr);
+ reply = __bluetooth_telephony_dbus_method_send(
+ HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
+ "SwapHeadset", &err, param);
+
+ if (!reply) {
+ BT_ERR("Error returned in method call\n");
+ if (err) {
+ g_dbus_error_strip_remote_error(err);
+ ret = __bt_telephony_get_error(err->message);
+ g_error_free(err);
+ return ret;
+ }
+ return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
+ }
+
+ g_variant_unref(reply);
+ return BLUETOOTH_TELEPHONY_ERROR_NONE;
+#else
+ return BLUETOOTH_ERROR_NOT_SUPPORT;
+#endif
+}
+
static void __bt_telephony_adapter_filter(GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE)
BT_ERR("__bluetooth_telephony_register failed");
}
+
+ g_variant_unref(optional_param);
}
FN_END;