Merge "Revert "Fix incorrect interface name and improve dbus policy"" into tizen
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-gatt-service.c
index 724780e..b912965 100644 (file)
@@ -977,10 +977,6 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                req_info->context = invocation;
                gatt_requests = g_slist_append(gatt_requests, req_info);
 
-               _bt_common_event_cb(BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED,
-                                       BLUETOOTH_ERROR_NONE, &read_req,
-                                       user_info->cb, user_info->user_data);
-
 #if defined(TIZEN_FEATURE_BT_HPS) || defined(TIZEN_FEATURE_BT_OTP)
                param = g_variant_new("(sssyq)",
                                read_req.att_handle,
@@ -995,6 +991,10 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                __bt_send_event_to_otp(BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED, param);
 #endif
 #endif
+
+               _bt_common_event_cb(BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED,
+                                       BLUETOOTH_ERROR_NONE, &read_req,
+                                       user_info->cb, user_info->user_data);
                return;
        } else if (g_strcmp0(method_name, "WriteValue") == 0) {
                GVariant *var = NULL;
@@ -1072,11 +1072,6 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                        g_object_unref(invocation);
                }
 
-               _bt_common_event_cb(
-                       BLUETOOTH_EVENT_GATT_SERVER_VALUE_CHANGED,
-                       BLUETOOTH_ERROR_NONE, &value_change,
-                       user_info->cb, user_info->user_data);
-
 #if defined(TIZEN_FEATURE_BT_HPS) || defined(TIZEN_FEATURE_BT_OTP)
                if (len > 0) {
                        gchar *svc_path;
@@ -1099,6 +1094,11 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                }
 #endif
 
+               _bt_common_event_cb(
+                       BLUETOOTH_EVENT_GATT_SERVER_VALUE_CHANGED,
+                       BLUETOOTH_ERROR_NONE, &value_change,
+                       user_info->cb, user_info->user_data);
+
                g_free(value_change.att_value);
                g_variant_unref(var);
                return;
@@ -1117,10 +1117,6 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                                notify_change.service_handle = svc_info->serv_path;
                                notify_change.att_handle = (char *)object_path;
                                notify_change.att_notify = TRUE;
-                               _bt_common_event_cb(
-                                       BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED,
-                                       BLUETOOTH_ERROR_NONE, &notify_change,
-                                       user_info->cb, user_info->user_data);
 #if TIZEN_FEATURE_BT_OTP
                                param = g_variant_new("(ssb)",
                                notify_change.att_handle,
@@ -1128,6 +1124,10 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                                notify_change.att_notify);
                                __bt_send_event_to_otp(BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED, param);
 #endif
+                               _bt_common_event_cb(
+                                       BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED,
+                                       BLUETOOTH_ERROR_NONE, &notify_change,
+                                       user_info->cb, user_info->user_data);
                        }
                }
                g_object_unref(invocation);
@@ -1147,10 +1147,6 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                                notify_change.service_handle = svc_info->serv_path;
                                notify_change.att_handle = (char *)object_path;
                                notify_change.att_notify = FALSE;
-                               _bt_common_event_cb(
-                                       BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED,
-                                       BLUETOOTH_ERROR_NONE, &notify_change,
-                                       user_info->cb, user_info->user_data);
 #if TIZEN_FEATURE_BT_OTP
                                param = g_variant_new("(ssb)",
                                notify_change.att_handle,
@@ -1158,6 +1154,10 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                                notify_change.att_notify);
                                __bt_send_event_to_otp(BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED, param);
 #endif
+                               _bt_common_event_cb(
+                                       BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED,
+                                       BLUETOOTH_ERROR_NONE, &notify_change,
+                                       user_info->cb, user_info->user_data);
                        }
                }
                g_object_unref(invocation);
@@ -1352,7 +1352,7 @@ gboolean __bt_gatt_emit_interface_removed(gchar *object_path, gchar *interface)
        g_variant_builder_add(array_builder, "s", interface);
 
        ret = g_dbus_connection_emit_signal(g_conn, NULL, "/",
-                                       "org.freedesktop.DBus.ObjectManager",
+                                       "org.freedesktop.Dbus.Objectmanager",
                                        "InterfacesRemoved",
                                        g_variant_new("(oas)",
                                        object_path, array_builder),
@@ -1967,7 +1967,7 @@ BT_EXPORT_API int bluetooth_gatt_add_service(const char *svc_uuid,
                GATT_SERV_INTERFACE, inner_builder);
 
        g_dbus_connection_emit_signal(g_conn, NULL, "/",
-                               "org.freedesktop.DBus.ObjectManager",
+                               "org.freedesktop.Dbus.ObjectManager",
                                "InterfacesAdded",
                                g_variant_new("(oa{sa{sv}})",
                                path, builder),
@@ -2097,7 +2097,7 @@ BT_EXPORT_API int bluetooth_gatt_add_new_characteristic(
                        inner_builder);
 
        g_dbus_connection_emit_signal(g_conn, NULL, "/",
-                       "org.freedesktop.DBus.ObjectManager",
+                       "org.freedesktop.Dbus.ObjectManager",
                        "InterfacesAdded",
                        g_variant_new("(oa{sa{sv}})",
                                path, builder),
@@ -2178,7 +2178,7 @@ BT_EXPORT_API int bluetooth_gatt_set_characteristic_value(
                        inner_builder);
 
        g_dbus_connection_emit_signal(g_conn, NULL, "/",
-                       "org.freedesktop.DBus.ObjectManager",
+                       "org.freedesktop.Dbus.ObjectManager",
                        "InterfacesAdded",
                        g_variant_new("(oa{sa{sv}})",
                                char_info->char_path, builder),
@@ -2301,7 +2301,7 @@ BT_EXPORT_API int bluetooth_gatt_add_descriptor(
                                inner_builder);
 
        g_dbus_connection_emit_signal(g_conn, NULL, "/",
-                               "org.freedesktop.DBus.ObjectManager",
+                               "org.freedesktop.Dbus.ObjectManager",
                                "InterfacesAdded",
                                g_variant_new("(oa{sa{sv}})",
                                path, builder),
@@ -2380,7 +2380,7 @@ BT_EXPORT_API int bluetooth_gatt_set_descriptor_value(
                        inner_builder);
 
        g_dbus_connection_emit_signal(g_conn, NULL, "/",
-                       "org.freedesktop.DBus.ObjectManager",
+                       "org.freedesktop.Dbus.ObjectManager",
                        "InterfacesAdded",
                        g_variant_new("(oa{sa{sv}})",
                                desc_info->desc_path, builder),