" </interface>"
"</node>";
-GDBusNodeInfo *node_info = NULL;
+static gboolean name_acquired = FALSE;
static char *current_sender_playing = NULL;
break;
}
case BT_LE_CONN_UPDATE: {
+ char *sender = NULL;
bluetooth_device_address_t local_address = { {0} };
bluetooth_le_connection_param_t parameters = {0};
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+
__bt_service_get_parameters(in_param1, &local_address,
sizeof(bluetooth_device_address_t));
__bt_service_get_parameters(in_param2, ¶meters,
sizeof(bluetooth_le_connection_param_t));
- result = _bt_le_conn_update(local_address.addr,
+ result = _bt_le_conn_update(sender,
+ local_address.addr,
parameters.interval_min,
parameters.interval_max,
parameters.latency,
break;
}
case BT_UPDATE_LE_CONNECTION_MODE: {
+ char *sender = NULL;
bluetooth_device_address_t remote_address = { { 0 } };
bluetooth_le_connection_param_t param = { 0 };
bluetooth_le_connection_mode_t mode = BLUETOOTH_LE_CONNECTION_MODE_BALANCED;
if (result != BLUETOOTH_ERROR_NONE)
break;
- result = _bt_le_conn_update(remote_address.addr,
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+ result = _bt_le_conn_update(sender,
+ remote_address.addr,
param.interval_min,
param.interval_max,
param.latency,
return 0;
}
+static void __bt_service_bus_acquired_handler(GDBusConnection *connection,
+ const gchar *name, gpointer user_data)
+{
+ GDBusNodeInfo *node_info = NULL;
+
+ BT_INFO("bus acquired");
+
+ ret_if(connection == NULL);
+
+ node_info = __bt_service_create_method_node_info(
+ bt_service_introspection_xml);
+ ret_if(node_info == NULL);
+
+ __bt_service_register_object(connection, node_info, TRUE);
+ g_dbus_node_info_unref(node_info);
+
+ bt_service_conn = connection;
+}
+
+static void __bt_service_name_acquired_handler(GDBusConnection *connection,
+ const gchar *name, gpointer user_data)
+{
+ BT_INFO("name acquired");
+ name_acquired = TRUE;
+}
+
+static void __bt_service_name_lost_handler(GDBusConnection *connection,
+ const gchar *name, gpointer user_data)
+{
+ BT_INFO("name lost");
+ name_acquired = FALSE;
+}
+
+gboolean _is_name_acquired(void)
+{
+ return name_acquired;
+}
+
int _bt_service_register(void)
{
GDBusConnection *conn;
GError *err = NULL;
- int result;
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+ bt_service_conn = conn;
owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
BT_SERVICE_NAME,
G_BUS_NAME_OWNER_FLAGS_NONE,
- NULL, NULL, NULL,
+ __bt_service_bus_acquired_handler,
+ __bt_service_name_acquired_handler,
+ __bt_service_name_lost_handler,
NULL, NULL);
BT_DBG("owner_id is [%d]", owner_id);
if (owner_id == 0)
goto fail;
- node_info = __bt_service_create_method_node_info(
- bt_service_introspection_xml);
-
- if (node_info == NULL)
- goto fail;
-
- result = __bt_service_register_object(conn, node_info, TRUE);
- g_dbus_node_info_unref(node_info);
- node_info = NULL;
-
- if (result != BLUETOOTH_ERROR_NONE)
- goto fail;
-
- bt_service_conn = conn;
-
return BLUETOOTH_ERROR_NONE;
fail:
g_object_unref(bt_service_conn);
bt_service_conn = NULL;
}
- if (node_info) {
- g_dbus_node_info_unref(node_info);
- node_info = NULL;
- }
if (owner_id > 0) {
g_bus_unown_name(owner_id);
owner_id = 0;