#include "bt-request-sender.h"
#include "bt-event-handler.h"
+#ifdef TIZEN_DPM_ENABLE
+#include "bt-dpm.h"
+#endif
+
+
static bt_user_info_t user_info[BT_MAX_USER_INFO];
-static DBusConnection *system_conn = NULL;
+static GDBusConnection *system_gdbus_conn = NULL;
static guint bus_id;
address = g_dbus_address_get_for_bus_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
if (address == NULL) {
if (error) {
- BT_ERR ("Failed to get bus address: %s", error->message);
+ BT_ERR("Failed to get bus address: %s", error->message);
g_clear_error(&error);
}
return NULL;
}
- private_gconn = g_dbus_connection_new_for_address_sync (address,
+ private_gconn = g_dbus_connection_new_for_address_sync(address,
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
NULL, /* GDBusAuthObserver */
GDBusConnection *_bt_gdbus_get_system_gconn(void)
{
+
+
if (system_gconn == NULL) {
system_gconn = _bt_gdbus_init_system_gconn();
- } else if (g_dbus_connection_is_closed(system_gconn)){
+ } else if (g_dbus_connection_is_closed(system_gconn)) {
system_gconn = g_bus_get_private_conn();
}
while (count > 0 && ((i + count) < length)) {
dest[i++] = *p;
p++;
- count --;
+ count--;
}
p = next;
}
return adapter_proxy;
}
-int _bt_register_new_conn_ex(const char *path, const char *bus_name,bt_new_connection_cb cb)
+int _bt_register_new_conn_ex(const char *path, const char *bus_name, bt_new_connection_cb cb)
{
GDBusConnection *gconn;
int id;
GError *err = NULL;
char **uuid_value = NULL;
gsize size = 0;
- int i =0;
+ int i = 0;
GVariant *value = NULL;
GVariant *ret = NULL;
int result = BLUETOOTH_ERROR_INTERNAL;
}
}
-/* TODO : replace the dbus-glib APIs to gdbus APIs */
-DBusConnection *__bt_init_system_conn(void)
-{
- if (system_conn == NULL)
- system_conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, NULL);
-
- if (system_conn) {
- dbus_connection_setup_with_g_main(system_conn, NULL);
- dbus_connection_set_exit_on_disconnect(system_conn, FALSE);
- }
-
- return system_conn;
-}
-
-DBusConnection *_bt_get_system_conn(void)
+GDBusConnection *_bt_init_system_gdbus_conn(void)
{
- DBusConnection *conn = NULL;
-
- if (system_conn == NULL) {
- conn = __bt_init_system_conn();
- } else {
- conn = system_conn;
+ GError *error = NULL;
+ if (system_gdbus_conn == NULL) {
+ system_gdbus_conn =
+ g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error) {
+ BT_ERR("GDBus connection Error : %s \n",
+ error->message);
+ g_clear_error(&error);
+ return NULL;
+ }
}
-
- return conn;
+ return system_gdbus_conn;
}
return NULL;
}
- result = g_dbus_proxy_call_sync (manager_proxy,
+ result = g_dbus_proxy_call_sync(manager_proxy,
"GetManagedObjects", NULL,
G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &error);
int ret;
_bt_gdbus_init_system_gconn();
- __bt_init_system_conn();
ret = _bt_init_event_handler();
if (ret != BLUETOOTH_ERROR_NONE &&
_bt_set_user_data(BT_COMMON, NULL, NULL);
- if (system_conn) {
- dbus_connection_flush(system_conn);
- dbus_connection_close(system_conn);
- dbus_connection_unref(system_conn);
- system_conn = NULL;
- }
if (system_gconn) {
g_object_unref(system_gconn);
system_gconn = NULL;
}
- _bt_gdbus_deinit_proxys();
return BLUETOOTH_ERROR_NONE;
}