+ if (_bt_register_service_event(opc_obexd_conn,
+ BT_OPP_CLIENT_EVENT) != BLUETOOTH_ERROR_NONE) {
+ g_object_unref(opc_obexd_conn);
+ opc_obexd_conn = NULL;
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+void _bt_opp_client_event_deinit(void)
+{
+ if (opc_obexd_conn) {
+ _bt_unregister_service_event(opc_obexd_conn,
+ BT_OPP_CLIENT_EVENT);
+ g_object_unref(opc_obexd_conn);
+ opc_obexd_conn = NULL;
+ }
+}
+
+int _bt_register_manager_subscribe_signal(GDBusConnection *conn,
+ int subscribe)
+{
+ if (conn == NULL)
+ return -1;
+
+ static int subs_interface_added_id = -1;
+ static int subs_interface_removed_id = -1;
+ static int subs_name_owner_id = -1;
+ static int subs_property_id = -1;
+ static int subs_adapter_id = -1;
+ static int subs_gatt_id = -1;
+
+ if (subscribe) {
+ if (subs_interface_added_id == -1) {
+ subs_interface_added_id = g_dbus_connection_signal_subscribe(conn,
+ NULL, BT_MANAGER_INTERFACE,
+ BT_INTERFACES_ADDED, NULL, NULL, 0,
+ __bt_manager_event_filter,
+ NULL, NULL);
+ }
+ if (subs_interface_removed_id == -1) {
+ subs_interface_removed_id = g_dbus_connection_signal_subscribe(conn,
+ NULL, BT_MANAGER_INTERFACE,
+ BT_INTERFACES_REMOVED, NULL, NULL, 0,
+ __bt_manager_event_filter,
+ NULL, NULL);
+ }
+ if (subs_name_owner_id == -1) {
+ subs_name_owner_id = g_dbus_connection_signal_subscribe(conn,
+ NULL, BT_FREEDESKTOP_INTERFACE,
+ BT_NAME_OWNER_CHANGED, NULL, NULL, 0,
+ __bt_manager_event_filter,
+ NULL, NULL);
+ }
+ if (subs_property_id == -1) {
+ subs_property_id = g_dbus_connection_signal_subscribe(conn,
+ NULL, BT_PROPERTIES_INTERFACE,
+ BT_PROPERTIES_CHANGED, NULL, NULL, 0,
+ __bt_manager_event_filter,
+ NULL, NULL);
+ }
+ if (subs_adapter_id == -1) {
+ subs_adapter_id = g_dbus_connection_signal_subscribe(conn,
+ NULL, BT_ADAPTER_INTERFACE,
+ NULL, NULL, NULL, 0,
+ __bt_manager_event_filter,
+ NULL, NULL);
+ }
+ if (subs_gatt_id == -1) {
+ subs_gatt_id = g_dbus_connection_signal_subscribe(conn,
+ NULL, BT_GATT_CHAR_INTERFACE,
+ NULL, NULL, NULL, 0,
+ __bt_manager_event_filter,
+ NULL, NULL);
+ }
+ } else {
+ if (subs_interface_added_id != -1) {
+ g_dbus_connection_signal_unsubscribe(conn,
+ subs_interface_added_id);
+ subs_interface_added_id = -1;
+ }
+ if (subs_interface_removed_id != -1) {
+ g_dbus_connection_signal_unsubscribe(conn,
+ subs_interface_removed_id);
+ subs_interface_removed_id = -1;
+ }
+ if (subs_name_owner_id != -1) {
+ g_dbus_connection_signal_unsubscribe(conn,
+ subs_name_owner_id);
+ subs_name_owner_id = -1;
+ }
+ if (subs_property_id != -1) {
+ g_dbus_connection_signal_unsubscribe(conn,
+ subs_property_id);
+ subs_property_id = -1;
+ }
+ if (subs_adapter_id != -1) {
+ g_dbus_connection_signal_unsubscribe(conn, subs_adapter_id);
+ subs_adapter_id = -1;