static int register_pending_cnt = 0;
static bool is_server_started = false;
+GCancellable *register_cancel;
+
/* Introspection data for the service we are exporting */
static const gchar service_introspection_xml[] =
"<node name='/'>"
register_pending_cnt = 0;
- result = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
-
- if (result == NULL) {
- /* dBUS-RPC is failed */
- BT_ERR("Dbus-RPC is failed\n");
-
- if (error != NULL) {
- /* dBUS gives error cause */
- BT_ERR("D-Bus API failure: errCode[%x], message[%s]\n",
- error->code, error->message);
- g_clear_error(&error);
- }
- } else {
- g_variant_unref(result);
+ if (register_cancel) {
+ g_object_unref(register_cancel);
+ register_cancel = NULL;
}
-}
-
-void unregister_application_cb(GObject *object, GAsyncResult *res,
- gpointer user_data)
-{
- BT_INFO("UnregisterApplication is completed");
-
- GError *error = NULL;
- GVariant *result;
result = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
BT_ERR("Dbus-RPC is failed\n");
if (error != NULL) {
- /* dBUS gives error cause */
+ /* dBUS gives error cause */
BT_ERR("D-Bus API failure: errCode[%x], message[%s]\n",
- error->code, error->message);
+ error->code, error->message);
g_clear_error(&error);
}
} else {
GDBusProxy *proxy = NULL;
if (is_server_started) {
+ GVariant *ret;
+ GError *err = NULL;
+
proxy = __bt_gatt_gdbus_get_manager_proxy("org.bluez",
"/org/bluez/hci0", GATT_MNGR_INTERFACE);
BT_INFO("UnregisterApplication");
+ is_server_started = false;
+
/* Async Call to Unregister Service */
- g_dbus_proxy_call(proxy,
+ ret = g_dbus_proxy_call_sync(proxy,
"UnregisterApplication",
g_variant_new("(o)",
app_path),
G_DBUS_CALL_FLAGS_NONE, -1,
- NULL,
- (GAsyncReadyCallback) unregister_application_cb,
- NULL);
+ NULL, &err);
+
+ if (ret == NULL) {
+ /* dBUS-RPC is failed */
+ BT_ERR("dBUS-RPC is failed");
+ if (err != NULL) {
+ /* dBUS gives error cause */
+ BT_ERR("D-Bus API failure: errCode[%x], message[%s]",
+ err->code, err->message);
+
+ g_clear_error(&err);
+ }
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+ g_variant_unref(ret);
+
+ BT_INFO("UnregisterApplication is completed");
- is_server_started = false;
return BLUETOOTH_ERROR_NONE;
}
BT_EXPORT_API int bluetooth_gatt_deinit()
{
int ret = BLUETOOTH_ERROR_NONE;
+
+ if (register_cancel) {
+ g_cancellable_cancel(register_cancel);
+ g_object_unref(register_cancel);
+ register_cancel = NULL;
+ }
+
/* Unown gdbus bus */
if (owner_id) {
/* remove/unregister all services */
BT_INFO("RegisterApplication");
+ if (register_cancel) {
+ g_cancellable_cancel(register_cancel);
+ g_object_unref(register_cancel);
+ }
+
+ register_cancel = g_cancellable_new();
+
g_dbus_proxy_call(proxy,
"RegisterApplication",
g_variant_new("(oa{sv})",
app_path, NULL),
G_DBUS_CALL_FLAGS_NONE, -1,
- NULL,
+ register_cancel,
(GAsyncReadyCallback) register_application_cb,
NULL);