Refactor gdbus interface of gesture FW 97/242297/4
authorSuyeon Hwang <stom.hwang@samsung.com>
Tue, 25 Aug 2020 10:40:39 +0000 (19:40 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 1 Sep 2020 08:42:07 +0000 (17:42 +0900)
This patch includes these changes.
- Extract gdbus interface definition xml from source code to .xml file.
- Create invocation manager class to manager gdbus method call session.
- Synchronize API behavior(hand_gesture_is_supported_type, hand_gesture_get_engine_info).

Change-Id: Ied0b8a766d4b07634b31f6dc9f5325d057471936
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
12 files changed:
CMakeLists.txt
capi-ui-gesture-gdbus.xml [new file with mode: 0644]
client/gesture.c
client/gesture_client_dbus.c
engine/gesture_engine_dbus.c
include/gesture_defs.h
manager/gestured_invocation_manager.cpp [new file with mode: 0644]
manager/gestured_invocation_manager.h [new file with mode: 0644]
packaging/capi-ui-gesture.spec
server/CMakeLists.txt
server/gestured_dbus.c
server/gestured_dbus.h

index 5ccea7d..c3e0afd 100644 (file)
@@ -46,3 +46,5 @@ ADD_SUBDIRECTORY(client)
 
 ## Gesture manager ##
 #ADD_SUBDIRECTORY(manager)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/capi-ui-gesture-gdbus.xml DESTINATION ${TZ_SYS_RO_SHARE}/gesture)
diff --git a/capi-ui-gesture-gdbus.xml b/capi-ui-gesture-gdbus.xml
new file mode 100644 (file)
index 0000000..4adff75
--- /dev/null
@@ -0,0 +1,65 @@
+<node>
+       <interface name='org.tizen.gesture_service'>
+               <!-- Client to Server -->
+               <method name='gesture_service_register'>
+                       <arg type='i' name='value' direction='in'/>
+                       <arg type='i' name='clientlib' direction='in'/>
+                       <arg type='s' name='pkgName' direction='in'/>
+                       <arg type='i' name='client_pid' direction='in'/>
+                       <arg type='s' name='client_uid' direction='in'/>
+                       <arg type='s' name='client_smack_label' direction='in'/>
+               </method>
+               <method name='gesture_client_initialize_engine'>
+               </method>
+               <method name='gesture_client_deinitialize_engine'>
+               </method>
+               <method name='gesture_client_start_recognition'>
+                       <arg type='i' name='gesture_type' direction='in'/>
+                       <arg type='i' name='hand_type' direction='in'/>
+                       <arg type='i' name='work_mode' direction='in'/>
+                       <arg type='i' name='option' direction='in'/>
+                       <arg type='i' name='sensitivity' direction='in'/>
+               </method>
+               <method name='gesture_client_stop_recognition'>
+               </method>
+               <method name='gesture_client_foreach_result_time'>
+               </method>
+               <method name='gesture_client_foreach_supported_type'>
+               </method>
+               <method name='gesture_client_is_support_gesture_type'>
+                       <arg type='i' name='type' direction='in'/>
+                       <arg type='b' name='supported' direction='out'/>
+               </method>
+               <method name='gesture_client_engine_get_info'>
+                       <arg type='s' name='engine_app_id' direction='out'/>
+                       <arg type='s' name='engine_name' direction='out'/>
+               </method>
+               <!-- Engine to Server -->
+               <method name='gesture_engine_send_result'>
+                       <arg type='i' name='event' direction='in'/>
+                       <arg type='i' name='gesture_type' direction='in'/>
+                       <arg type='i' name='lgesture_type' direction='in'/>
+                       <arg type='i' name='levent' direction='in'/>
+                       <arg type='i' name='ldetected_Count' direction='in'/>
+               </method>
+               <method name='gesture_engine_send_error'>
+                       <arg type='i' name='error' direction='in'/>
+                       <arg type='s' name='msg' direction='in'/>
+               </method>
+               <method name='gesture_engine_send_motion_status'>
+                       <arg type='i' name='status' direction='in'/>
+               </method>
+               <method name='gesture_engine_main_start'>
+                       <arg type='i' name='psw' direction='in'/>
+               </method>
+               <method name='gesture_engine_get_engine_info'>
+                       <arg type='i' name='id' direction='in'/>
+                       <arg type='s' name='engine_app_id' direction='in'/>
+                       <arg type='s' name='engine_name' direction='in'/>
+               </method>
+               <method name='gesture_engine_is_support_gesture_type'>
+                       <arg type='i' name='id' direction='in'/>
+                       <arg type='b' name='supported' direction='in'/>
+               </method>
+       </interface>
+</node>
\ No newline at end of file
index f333dea..3872631 100644 (file)
@@ -201,6 +201,7 @@ EXPORT_API int hand_gesture_is_supported_type(hand_gesture_h handle, hand_gestur
        LOGD("hand_gesture_is_supported_type");
 
        CHECK_GESTURE_FEATURE();
+       ASSERT_NOT_NULL(handle);
        ASSERT_NOT_NULL(supported);
 
        int ret;
index 532ac88..0c58dad 100644 (file)
@@ -623,10 +623,21 @@ int gesture_client_dbus_is_support_gesture_type(GDBusConnection *gdbus_connectio
        GDBusMessage *reply = NULL;
        GVariant *body = NULL;
 
-       body = g_variant_new("()");
+       body = g_variant_new("(i)", gesture);
        ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_CLIENT_MSG_IS_SUPPORT_GESTURE_TYPE);
-       if (ret != HAND_GESTURE_ERROR_NONE)
+       if (ret != HAND_GESTURE_ERROR_NONE || NULL == reply) {
                LOGE("failed to is_supported_gesture_type");
+       } else {
+               LOGD("Check reply from server");
+               GVariant *reply_body = g_dbus_message_get_body(reply);
+               if (NULL == reply_body) {
+                       LOGE("There is no return value");
+                       ret = HAND_GESTURE_ERROR_OPERATION_FAILED;
+               } else {
+                       g_variant_get(reply_body, "(b)", supported);
+                       LOGD("supported(%d)", *supported);
+               }
+       }
 
        if (body)
                g_variant_unref(body);
@@ -643,13 +654,35 @@ int gesture_client_dbus_get_engine_info(GDBusConnection *gdbus_connection, char*
        int ret;
        GDBusMessage *reply = NULL;
        GVariant *body = NULL;
-       g_engine_app_id = *engine_app_id;
-       g_engine_name = *engine_name;
 
        body = g_variant_new("()");
        ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_CLIENT_MSG_ENGINE_GET_INFO);
        if (ret != HAND_GESTURE_ERROR_NONE)
-               LOGE("failed to engine_get_info");
+               LOGE("Fail to send message");
+
+       GVariant *reply_body = g_dbus_message_get_body(reply);
+       if (NULL == reply_body) {
+               LOGE("There is no return value");
+               ret = HAND_GESTURE_ERROR_OPERATION_FAILED;
+       } else {
+               g_variant_get(reply_body, "(ss)", engine_app_id, engine_name);
+               if (NULL == engine_app_id || NULL == engine_name) {
+                       LOGE("Fail to get engine info");
+                       ret = HAND_GESTURE_ERROR_OPERATION_FAILED;
+               } else {
+                       if (NULL != g_engine_app_id) {
+                               free(g_engine_app_id);
+                       }
+
+                       if (NULL != g_engine_name) {
+                               free(g_engine_name);
+                       }
+
+                       g_engine_app_id = *engine_app_id;
+                       g_engine_name = *engine_name;
+                       LOGD("APP ID(%s), Name(%s)", *engine_app_id, *engine_name);
+               }
+       }
 
        if (body)
                g_variant_unref(body);
index 3eeb674..a0ec977 100644 (file)
@@ -29,6 +29,8 @@ static int is_server_started = 0;
 static gesture_engine_request_callback_s g_basic_engine_callback;
 static GDBusConnection *mgdbus_connection;
 
+static int gdbus_send_message_with_async(GDBusConnection *gdbus_connection, GVariant *body, char *cmd);
+
 static void _server_appeared_cb(GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data)
 {
        LOGD("name : %s, name_owner : %s", name, name_owner);
@@ -150,16 +152,46 @@ static void _handle_gesture_engine_cb(GDBusConnection *connection,
        }
        else if (g_strcmp0(signal_name, GESTURE_ENGINE_SIGNAL_IS_SUPPORT_GESTURE_TYPE) == 0) {
                LOGD("[GESTURE_ENGINE_SIGNAL_IS_SUPPORT_GESTURE_TYPE] called");
-               int gesture_type = 1;
-               bool isSupported = false;
-               g_variant_get(parameters, "(i)", &gesture_type);
-               g_basic_engine_callback.is_support_gesture_type(gesture_type, &isSupported);
-       }
-       else if (g_strcmp0(signal_name, GESTURE_ENGINE_SIGNAL_ENGINE_GET_INFO) == 0) {
-               LOGD("[GESTURE_ENGINE_SIGNAL_ENGINE_GET_INFO] called");
-               char *engine_app_id;
-               char *engine_name;
+               int id = 0;
+               int gesture_type = 0;
+               g_variant_get(parameters, "(ii)", &id, &gesture_type);
+               LOGD("Invocation ID(%d), Gesture Type(%d)", id, gesture_type);
+
+               bool is_supported = false;
+               g_basic_engine_callback.is_support_gesture_type(gesture_type, &is_supported);
+               GVariant* body = g_variant_new("(ib)", id, is_supported);
+               if (NULL == body) {
+                       LOGE("Fail to create body");
+                       return;
+               }
+
+               LOGD("send message variant. ID(%d), Is supported(%d)", id, is_supported);
+               gdbus_send_message_with_async(connection, body, GESTURE_ENGINE_MSG_IS_SUPPORT_GESTURE_TYPE);
+               g_variant_unref(body);
+       }
+       else if (g_strcmp0(signal_name, GESTURE_ENGINE_SIGNAL_GET_ENGINE_INFO) == 0) {
+               LOGD("[GESTURE_ENGINE_SIGNAL_GET_ENGINE_INFO] called");
+               int id = 0;
+               g_variant_get(parameters, "(i)", &id);
+               LOGD("Invocation ID(%d)", id);
+
+               char *engine_app_id = NULL;
+               char *engine_name = NULL;
                g_basic_engine_callback.get_info(&engine_app_id, &engine_name);
+               if (NULL == engine_app_id || NULL == engine_name) {
+                       LOGE("Fail to get engine information");
+                       return;
+               }
+
+               GVariant* body = g_variant_new("(iss)", id, engine_app_id, engine_name);
+               if (NULL == body) {
+                       LOGE("Fail to create body");
+                       return;
+               }
+
+               LOGD("send message variant. APP ID(%s), Name(%s)", engine_app_id, engine_name);
+               gdbus_send_message_with_async(connection, body, GESTURE_ENGINE_MSG_GET_ENGINE_INFO);
+               g_variant_unref(body);
        }
 }
 
@@ -595,7 +627,7 @@ int gesture_engine_dbus_send_engine_get_info(GDBusConnection *gdbus_connection,
        GVariant *body = NULL;
 
        body = g_variant_new("(ss)", engine_app_id, engine_name);
-       ret = gdbus_send_message_with_sync(mgdbus_connection, body, &reply, GESTURE_ENGINE_MSG_SEND_ENGINE_GET_INFO);
+       ret = gdbus_send_message_with_sync(mgdbus_connection, body, &reply, GESTURE_ENGINE_MSG_GET_ENGINE_INFO);
        if (ret != GESTURE_ENGINE_ERROR_NONE) {
                LOGE("Fail to send result data to daemon");
        }
index d08beca..613e697 100644 (file)
@@ -27,6 +27,8 @@ extern "C" {
 
 #define HAPI __attribute__((visibility("hidden")))
 
+#define GESTURE_SHARED_RESOURCE_PATH           tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_SHARE"), "gesture")
+
 #define DBUS_NAME                                      "org.freedesktop.DBus"
 #define DBUS_OBJECT_PATH                               "/org/freedesktop/DBus"
 #define DBUS_INTERFACE_NAME                            "org.freedesktop.DBus"
@@ -56,7 +58,8 @@ extern "C" {
 #define GESTURE_ENGINE_MSG_SEND_RESULT                 "gesture_engine_send_result"
 #define GESTURE_ENGINE_MSG_SEND_ERROR                  "gesture_engine_send_error"
 #define GESTURE_ENGINE_MSG_SEND_MOTION_STATUS          "gesture_engine_send_motion_status"
-#define GESTURE_ENGINE_MSG_SEND_ENGINE_GET_INFO                "gesture_engine_send_engine_get_info"
+#define GESTURE_ENGINE_MSG_IS_SUPPORT_GESTURE_TYPE     "gesture_engine_is_support_gesture_type"
+#define GESTURE_ENGINE_MSG_GET_ENGINE_INFO             "gesture_engine_get_engine_info"
 
 #define GESTURE_ENGINE_SIGNAL_ENGINE_INITIALIZE                "engine_initialize"
 #define GESTURE_ENGINE_SIGNAL_ENGINE_DEINITIALIZE      "engine_deinitialize"
@@ -65,7 +68,7 @@ extern "C" {
 #define GESTURE_ENGINE_SIGNAL_FOREACH_RESULT_TIME      "engine_foreach_result_time"
 #define GESTURE_ENGINE_SIGNAL_FOREACH_SUPPORTED_TYPE   "engine_foreach_supported_type"
 #define GESTURE_ENGINE_SIGNAL_IS_SUPPORT_GESTURE_TYPE  "engine_is_support_gesture_type"
-#define GESTURE_ENGINE_SIGNAL_ENGINE_GET_INFO          "engine_get_info"
+#define GESTURE_ENGINE_SIGNAL_GET_ENGINE_INFO          "engine_get_engine_info"
 
 #define GESTURE_PRIVILEGE_APPLAUNCH            "http://tizen.org/privilege/appmanager.launch"
 #define GESTURE_FEATURE_GESTURE         "tizen.org/feature/sensor.gesture_recognition"
diff --git a/manager/gestured_invocation_manager.cpp b/manager/gestured_invocation_manager.cpp
new file mode 100644 (file)
index 0000000..7f1cd14
--- /dev/null
@@ -0,0 +1,71 @@
+#include <stdlib.h>
+#include <map>
+
+#include <dlog.h>
+
+#include "gestured_invocation_manager.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "GESTURE_INVOCATION"
+
+static const int MAX_INVOCATION_ID = 1000000;
+
+static std::map<int, GDBusMethodInvocation*> g_invocation_map;
+static int g_last_id = -1;
+
+int gestureInvocationManagerInit()
+{
+       LOGD("Initialize invocation manager");
+       g_last_id = -1;
+       g_invocation_map.clear();
+
+       return 0;
+}
+
+int gestureInvocationManagerAdd(GDBusMethodInvocation* invocation)
+{
+       if (NULL == invocation) {
+               LOGE("Invalid parameter");
+               return -1;
+       }
+
+       LOGD("Add new invocation handle");
+       bool findId = false;
+       for (int i = g_last_id + 1; i != g_last_id; i = (i + 1) % MAX_INVOCATION_ID) {
+               if (g_invocation_map.find(i) == g_invocation_map.end()) {
+                       g_last_id = i;
+                       findId = true;
+                       break;
+               }
+       }
+
+       if (!findId) {
+               LOGE("Invocation map is full");
+               return -1;
+       }
+
+       g_invocation_map.insert({g_last_id, invocation});
+
+       return g_last_id;
+}
+
+GDBusMethodInvocation* gestureInvocationManagerGet(int invocation_id)
+{
+       LOGD("Find invocation handle. ID(%d)", invocation_id);
+       auto iter = g_invocation_map.find(invocation_id);
+       if (iter == g_invocation_map.end()) {
+               LOGE("There is no handle");
+               return nullptr;
+       }
+
+       return iter->second;
+}
+
+bool gestureInvocationManagerRemove(int invocation_id)
+{
+       LOGD("Remove invocation handle. ID(%d)", invocation_id);
+       g_invocation_map.erase(invocation_id);
+       return true;
+}
\ No newline at end of file
diff --git a/manager/gestured_invocation_manager.h b/manager/gestured_invocation_manager.h
new file mode 100644 (file)
index 0000000..32c3458
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef __GESTURED_INVOCATION_MANAGER_H__
+#define __GESTURED_INVOCATION_MANAGER_H__
+
+#include <gio/gio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int gestureInvocationManagerInit();
+int gestureInvocationManagerAdd(GDBusMethodInvocation* invocation);
+GDBusMethodInvocation* gestureInvocationManagerGet(int invocation_id);
+bool gestureInvocationManagerRemove(int invocation_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __GESTURED_INVOCATION_MANAGER_H__ */
+
index 7fb84c2..2bae1f2 100644 (file)
@@ -104,6 +104,7 @@ cp %{SOURCE3} %{buildroot}/etc/dbus-1/system.d/capi-ui-gesture.conf
 %license LICENSE
 %{_libdir}/lib*.so
 %attr(0755,ui_fw,ui_fw) %{_bindir}/gesture-server
+%attr(0644,root,root) %{_datadir}/gesture/capi-ui-gesture-gdbus.xml
 %attr(0644,root,root) %{_unitdir}/capi-ui-gesture.service
 %attr(0644,root,root) %{_datadir}/dbus-1/system-services/org.tizen.gesture.server.service
 %config %{_sysconfdir}/dbus-1/system.d/capi-ui-gesture.conf
index c41307a..d79d081 100644 (file)
@@ -4,6 +4,7 @@ SET(SRCS
     gestured_dbus.c
     ../manager/gestured_client_manager.cpp
     ../manager/gestured_engine_manager.cpp
+    ../manager/gestured_invocation_manager.cpp
 )
 
 FOREACH(flag ${pkgs_CFLAGS})
index 20a956e..0673c4d 100644 (file)
@@ -30,6 +30,7 @@
 #include "gesture_defs.h"
 #include "gestured_client_manager.h"
 #include "gestured_engine_manager.h"
+#include "gestured_invocation_manager.h"
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -300,6 +301,8 @@ int gestured_server_register_dbus_interface(char *introspection_xml, GDBusInterf
                goto cleanup;
        }
 
+       gestureInvocationManagerInit();
+
        return GESTURED_ERROR_NONE;
 
 cleanup:
@@ -448,6 +451,7 @@ static void _gestured_client_dbus_method_call_handler(GDBusConnection *conn, con
 
        GVariant *reply_body = NULL;
        int ret = GESTURED_ERROR_NONE;
+       bool delay_response = false;
 
        if (g_strcmp0(method_name, GESTURE_MSG_SERVICE_REGISTER) == 0) {
                LOGD("[GESTURE_MSG_SERVICE_REGISTER] called");
@@ -481,11 +485,13 @@ static void _gestured_client_dbus_method_call_handler(GDBusConnection *conn, con
        }
        else if (g_strcmp0(method_name, GESTURE_CLIENT_MSG_IS_SUPPORT_GESTURE_TYPE) == 0) {
                LOGD("[GESTURE_CLIENT_MSG_IS_SUPPORT_GESTURE_TYPE] called");
-               ret = gestured_client_is_support_gesture_type(parameters, &reply_body, sender);
+               ret = gestured_client_is_support_gesture_type(parameters, &reply_body, sender, invocation);
+               delay_response = true;
        }
        else if (g_strcmp0(method_name, GESTURE_CLIENT_MSG_ENGINE_GET_INFO) == 0) {
                LOGD("[GESTURE_CLIENT_MSG_ENGINE_GET_INFO] called");
-               ret = gestured_client_engine_get_info(parameters, &reply_body, sender);
+               ret = gestured_client_get_engine_info(parameters, &reply_body, sender, invocation);
+               delay_response = true;
        }
 
        /* from engine */
@@ -504,24 +510,32 @@ static void _gestured_client_dbus_method_call_handler(GDBusConnection *conn, con
        else if (g_strcmp0(method_name, GESTURE_ENGINE_MSG_MAIN_START) == 0) {
                LOGD("[GESTURE_ENGINE_MSG_MAIN_START] called");
        }
-       else if (g_strcmp0(method_name, GESTURE_ENGINE_MSG_SEND_ENGINE_GET_INFO) == 0) {
-               LOGD("[GESTURE_ENGINE_MSG_SEND_ENGINE_GET_INFO] called");
-               ret = gestured_engine_send_engine_get_info(parameters, &reply_body, sender);
+       else if (g_strcmp0(method_name, GESTURE_ENGINE_MSG_GET_ENGINE_INFO) == 0) {
+               LOGD("[GESTURE_ENGINE_MSG_GET_ENGINE_INFO] called");
+               int id = -1;
+               char* app_id = NULL;
+               char* name = NULL;
+
+               g_variant_get(parameters, "(iss)", &id, &app_id, &name);
+               ret = gestured_reply_get_engine_info(id, app_id, name);
        }
+       else if (g_strcmp0(method_name, GESTURE_ENGINE_MSG_IS_SUPPORT_GESTURE_TYPE) == 0) {
+               LOGD("[GESTURE_ENGINE_MSG_IS_SUPPORT_GESTURE_TYPE] called");
+               int id = -1;
+               bool is_supported = false;
 
-       if (ret == GESTURED_ERROR_NONE) {
-               LOGD("method_call successful, method_name : %s", method_name);
-#if 0
-               if (reply_body != NULL) {
-                       gchar *printmsg = g_variant_print(reply_body, true);
-                       LOGD("<<<reply_body>>> : %s", printmsg);
-                       g_free(printmsg);
+               g_variant_get(parameters, "(ib)", &id, &is_supported);
+               ret = gestured_reply_is_support_gesture_type(id, is_supported);
+       }
+
+       if (false == delay_response) {
+               if (ret == GESTURED_ERROR_NONE) {
+                       LOGD("method_call successful, method_name : %s", method_name);
+                       g_dbus_method_invocation_return_value(invocation, reply_body);
+               } else {
+                       LOGE("method_call failed, method_name : %s", method_name);
+                       g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, ret, "gesture error");
                }
-#endif
-               g_dbus_method_invocation_return_value(invocation, reply_body);
-       } else {
-               LOGE("method_call failed, method_name : %s", method_name);
-               g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, ret, "gesture error");
        }
 
        if (reply_body)
@@ -537,77 +551,48 @@ static const GDBusInterfaceVTable _gesture_interface_vtable = {
 int gestured_register_dbus_interface(void)
 {
        LOGD("gestured_register_dbus_interface");
-       static gchar introspection_xml[] =
-                       "       <node>"
-                       "       <interface name='org.tizen.gesture_service'>"
-                       "               <method name='gesture_service_register'>"
-                       "                       <arg type='i' name='value' direction='in'/>"
-                       "                       <arg type='i' name='clientlib' direction='in'/>"
-                       "                       <arg type='s' name='pkgName' direction='in'/>"
-                       "                       <arg type='i' name='client_pid' direction='in'/>"
-                       "                       <arg type='s' name='client_uid' direction='in'/>"
-                       "                       <arg type='s' name='client_smack_label' direction='in'/>"
-                       "               </method>"
-
-                       "               <method name='gesture_client_initialize_engine'>"
-                       "               </method>"
-
-                       "               <method name='gesture_client_deinitialize_engine'>"
-                       "               </method>"
-
-                       "               <method name='gesture_client_start_recognition'>"
-                       "                       <arg type='i' name='gesture_type' direction='in'/>"
-                       "                       <arg type='i' name='hand_type' direction='in'/>"
-                       "                       <arg type='i' name='work_mode' direction='in'/>"
-                       "                       <arg type='i' name='option' direction='in'/>"
-                       "                       <arg type='i' name='sensitivity' direction='in'/>"
-                       "               </method>"
-
-                       "               <method name='gesture_client_stop_recognition'>"
-                       "               </method>"
-
-                       "               <method name='gesture_client_foreach_result_time'>"
-                       "               </method>"
-
-                       "               <method name='gesture_client_foreach_supported_type'>"
-                       "               </method>"
-
-                       "               <method name='gesture_client_is_support_gesture_type'>"
-                       "               </method>"
-
-                       "               <method name='gesture_client_engine_get_info'>"
-                       "               </method>"
-
-                       "               <method name='gesture_engine_send_result'>"
-                       "                       <arg type='i' name='event' direction='in'/>"
-                       "                       <arg type='i' name='gesture_type' direction='in'/>"
-                       "                       <arg type='i' name='lgesture_type' direction='in'/>"
-                       "                       <arg type='i' name='levent' direction='in'/>"
-                       "                       <arg type='i' name='ldetected_Count' direction='in'/>"
-                       "               </method>"
-
-                       "               <method name='gesture_engine_send_error'>"
-                       "                       <arg type='i' name='error' direction='in'/>"
-                       "                       <arg type='s' name='msg' direction='in'/>"
-                       "               </method>"
-
-                       "               <method name='gesture_engine_send_motion_status'>"
-                       "                       <arg type='i' name='status' direction='in'/>"
-                       "               </method>"
-
-                       "               <method name='gesture_engine_main_start'>"
-                       "                       <arg type='i' name='psw' direction='in'/>"
-                       "               </method>"
-
-                       "               <method name='gesture_engine_send_engine_get_info'>"
-                       "                       <arg type='s' name='engine_app_id' direction='in'/>"
-                       "                       <arg type='s' name='engine_name' direction='in'/>"
-                       "               </method>"
-
-                       "       </interface>"
-                       "       </node>";
-
-       return gestured_server_register_dbus_interface(introspection_xml, _gesture_interface_vtable);
+
+       FILE* xml_file = NULL;
+       char xml_file_path[256] = {'\0', };
+       char* introspection_xml = NULL;
+       int size = 0;
+       int ret = 0;
+
+       snprintf(xml_file_path, strlen(GESTURE_SHARED_RESOURCE_PATH) + 27, "%s/capi-ui-gesture-gdbus.xml", GESTURE_SHARED_RESOURCE_PATH);
+       ret = access(xml_file_path, R_OK);
+       if (0 != ret) {
+               LOGE("Introspection file is not exist. path(%s)", xml_file_path);
+               return GESTURED_ERROR_OPERATION_FAILED;
+       }
+
+       xml_file = fopen(xml_file_path, "r");
+       if (NULL == xml_file) {
+               LOGE("Fail to open introspection file");
+               return GESTURED_ERROR_OPERATION_FAILED;
+       }
+
+       fseek(xml_file, 0, SEEK_END);
+       size = ftell(xml_file);
+       rewind(xml_file);
+
+       introspection_xml = (char*)calloc(sizeof(char), size);
+       if (NULL == introspection_xml) {
+               LOGE("Fail to allocate memory");
+               return GESTURED_ERROR_OUT_OF_MEMORY;
+       }
+
+       ret = fread(introspection_xml, 1, size, xml_file);
+       if (ret != size) {
+               LOGE("Error is occured reading file");
+               return GESTURED_ERROR_OPERATION_FAILED;
+       }
+
+       ret = gestured_server_register_dbus_interface(introspection_xml, _gesture_interface_vtable);
+
+       fclose(xml_file);
+       free(introspection_xml);
+
+       return ret;
 }
 
 int gestured_dbus_init(void)
@@ -750,7 +735,7 @@ int gestured_client_foreach_supported_type(GVariant *parameters, GVariant **repl
        return ret;
 }
 
-int gestured_client_is_support_gesture_type(GVariant *parameters, GVariant **reply_body, const char *sender)
+int gestured_client_is_support_gesture_type(GVariant *parameters, GVariant **reply_body, const char *sender, GDBusMethodInvocation* invocation)
 {
        int ret = GESTURED_ERROR_NONE;
        char *cmd = GESTURE_ENGINE_SIGNAL_IS_SUPPORT_GESTURE_TYPE;
@@ -760,26 +745,55 @@ int gestured_client_is_support_gesture_type(GVariant *parameters, GVariant **rep
                return GESTURED_ERROR_INVALID_PARAMETER;
        }
 
-       ret = gestured_send_dbus_message(parameters, sender, cmd, GESTURE_CLIENT_LIB_ENGINE);
+       int id = gestureInvocationManagerAdd(invocation);
+       if (0 > id) {
+               LOGE("Fail to store invocation");
+               return GESTURED_ERROR_OPERATION_FAILED;
+       }
+
+       int gesture_type = 0;
+       g_variant_get(parameters, "(i)", &gesture_type);
+
+       LOGD("invocation id (%d), gesture type(%d)", id, gesture_type);
+       GVariant* body = g_variant_new("(ii)", id, gesture_type);
+       if (NULL == body) {
+               LOGE("Fail to create body");
+               return GESTURED_ERROR_OPERATION_FAILED;
+       }
+
+       ret = gestured_send_dbus_message(body, sender, cmd, GESTURE_CLIENT_LIB_ENGINE);
        if (ret != GESTURED_ERROR_NONE)
                LOGE("Failed to start to engine");
 
        return ret;
 }
 
-int gestured_client_engine_get_info(GVariant *parameters, GVariant **reply_body, const char *sender)
+int gestured_client_get_engine_info(GVariant *parameters, GVariant **reply_body, const char *sender, GDBusMethodInvocation* invocation)
 {
-       LOGD("[engineInfo] gestured_client_engine_get_info : sendor [%s]", sender);
+       LOGD("[engineInfo] gestured_client_get_engine_info : sendor [%s]", sender);
 
        int ret = GESTURED_ERROR_NONE;
-       char *cmd = GESTURE_ENGINE_SIGNAL_ENGINE_GET_INFO;
+       char *cmd = GESTURE_ENGINE_SIGNAL_GET_ENGINE_INFO;
 
        if (parameters == NULL) {
                LOGE("failed to get parameters");
                return GESTURED_ERROR_INVALID_PARAMETER;
        }
 
-       ret = gestured_send_dbus_message(parameters, sender, cmd, GESTURE_CLIENT_LIB_ENGINE);
+       int id = gestureInvocationManagerAdd(invocation);
+       if (0 > id) {
+               LOGE("Fail to store invocation");
+               return GESTURED_ERROR_OPERATION_FAILED;
+       }
+
+       LOGD("invocation ID (%d)", id);
+       GVariant* body = g_variant_new("(i)", id);
+       if (NULL == body) {
+               LOGE("Fail to create body");
+               return GESTURED_ERROR_OPERATION_FAILED;
+       }
+
+       ret = gestured_send_dbus_message(body, sender, cmd, GESTURE_CLIENT_LIB_ENGINE);
        if (ret != GESTURED_ERROR_NONE)
                LOGE("Failed to start to engine");
 
@@ -835,6 +849,64 @@ int gestured_engine_send_engine_get_info(GVariant *parameters, GVariant **reply_
        return ret;
 }
 
+int gestured_reply_is_support_gesture_type(int invocation_id, bool is_supported)
+{
+       GDBusMethodInvocation *invocation = gestureInvocationManagerGet(invocation_id);
+       if (NULL == invocation) {
+               LOGE("Invalid invocation ID");
+               return GESTURED_ERROR_INVALID_PARAMETER;
+       }
+       gestureInvocationManagerRemove(invocation_id);
+
+       GVariant *reply_body = g_variant_new("(b)", is_supported);
+       if (NULL == reply_body) {
+               LOGE("Fail to create reply_body");
+               g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, GESTURED_ERROR_OPERATION_FAILED, "Fail to create return value");
+               return GESTURED_ERROR_OPERATION_FAILED;
+       }
+
+       LOGD("Invocation ID(%d), IsSupport(%d)", invocation_id, is_supported);
+
+       g_dbus_method_invocation_return_value(invocation, reply_body);
+       g_variant_unref(reply_body);
+       reply_body = NULL;
+
+       return GESTURED_ERROR_NONE;
+}
+
+
+int gestured_reply_get_engine_info(int invocation_id, char* engine_app_id, char* engine_name)
+{
+       GDBusMethodInvocation *invocation = gestureInvocationManagerGet(invocation_id);
+       if (NULL == invocation) {
+               LOGE("Invalid invocation ID");
+               return GESTURED_ERROR_INVALID_PARAMETER;
+       }
+       gestureInvocationManagerRemove(invocation_id);
+
+       if (NULL == engine_app_id || NULL == engine_name) {
+               LOGE("Invalid parameter");
+               g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, GESTURED_ERROR_INVALID_PARAMETER, "Invalid parameter");
+               return GESTURED_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *reply_body = g_variant_new("(ss)", engine_app_id, engine_name);
+       if (NULL == reply_body) {
+               LOGE("Fail to create reply_body");
+               g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, GESTURED_ERROR_OPERATION_FAILED, "Fail to create return value");
+               return GESTURED_ERROR_OPERATION_FAILED;
+       }
+
+       LOGD("Invocation ID(%d), APP ID(%s), Name(%s)", invocation_id, engine_app_id, engine_name);
+
+       g_dbus_method_invocation_return_value(invocation, reply_body);
+       g_variant_unref(reply_body);
+       reply_body = NULL;
+
+       return GESTURED_ERROR_NONE;
+}
+
+
 static void __response_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
 {
        LOGD("app_control launch result : %d", result);
index 03d5452..5ccda23 100644 (file)
@@ -50,8 +50,8 @@ int gestured_client_start_recognition(GVariant *parameters, GVariant **reply_bod
 int gestured_client_stop_recognition(GVariant *parameters, GVariant **reply_body, const char *sender);
 int gestured_client_foreach_result_time(GVariant *parameters, GVariant **reply_body, const char *sender);
 int gestured_client_foreach_supported_type(GVariant *parameters, GVariant **reply_body, const char *sender);
-int gestured_client_is_support_gesture_type(GVariant *parameters, GVariant **reply_body, const char *sender);
-int gestured_client_engine_get_info(GVariant *parameters, GVariant **reply_body, const char *sender);
+int gestured_client_is_support_gesture_type(GVariant *parameters, GVariant **reply_body, const char *sender, GDBusMethodInvocation* invocation);
+int gestured_client_get_engine_info(GVariant *parameters, GVariant **reply_body, const char *sender, GDBusMethodInvocation* invocation);
 
 /* engine side function : engine -> daemon */
 int gestured_engine_send_result(GVariant *parameters, GVariant **reply_body, const char *sender);
@@ -59,6 +59,10 @@ int gestured_engine_send_error(GVariant *parameters, GVariant **reply_body, cons
 int gestured_engine_send_motion_status(GVariant *parameters, GVariant **reply_body, const char *sender);
 int gestured_engine_send_engine_get_info(GVariant *parameters, GVariant **reply_body, const char *sender);
 
+/* daemon side function : daemon -> client */
+int gestured_reply_is_support_gesture_type(int invocation_id, bool is_supported);
+int gestured_reply_get_engine_info(int invocation_id, char* engine_app_id, char* engine_name);
+
 int __launch_engine_service_app(char *appid);