[ACR-1585][gesture][Add changes in gesture.h]
[platform/core/api/gesture.git] / client / gesture_client_dbus.c
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <dlog.h>
18 #include <aul.h>
19
20 #include "gesture_client_dbus.h"
21
22 #ifdef LOG_TAG
23 #undef LOG_TAG
24 #endif
25 #define LOG_TAG "GESTURE_CLIENT_DBUS"
26
27 static int is_server_started = 0;
28 static hand_gesture_recognition_cb g_callback;
29 static hand_gesture_data_h g_gesture_data;
30
31 static hand_gesture_handtype_e g_hand_type = HAND_GESTURE_LEFT_HAND;
32 static hand_gesture_workmode_e g_work_mode = HAND_GESTURE_WORK_MODE_ONE_WAY;
33 static hand_gesture_option_e g_option = HAND_GESTURE_OPTION_DEFAULT;
34 static int g_sensitivity = 1;
35
36 static char *g_engine_app_id;
37 static char *g_engine_name;
38
39 static void _free_gesture_data(hand_gesture_data_h gesture_data)
40 {
41         free(gesture_data);
42         gesture_data = NULL;
43 }
44
45 static void _server_appeared_cb(GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data)
46 {
47         LOGD("name : %s, name_owner : %s", name, name_owner);
48 }
49
50 static void _server_vanished_cb(GDBusConnection *connection, const gchar *name, gpointer user_data)
51 {
52         LOGD("name : %s", name);
53 }
54
55 static int _dbus_init(GDBusConnection **gdbus_connection, guint *server_watcher_id)
56 {
57         GError *error = NULL;
58
59         if (*gdbus_connection == NULL) {
60                 GDBusConnection *conn = NULL;
61                 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
62                 if (conn == NULL) {
63                         if (error != NULL) {
64                                 LOGE("g_bus_get_sync error message = %s", error->message);
65                                 g_error_free(error);
66                         }
67                         return HAND_GESTURE_ERROR_OPERATION_FAILED;
68                 }
69                 *gdbus_connection = conn;
70         }
71
72         LOGD("Connected bus name : %s", g_dbus_connection_get_unique_name(*gdbus_connection));
73         if (*server_watcher_id == 0) {
74                 *server_watcher_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
75                         GESTURE_DBUS_NAME,
76                         G_BUS_NAME_WATCHER_FLAGS_NONE,
77                         _server_appeared_cb,
78                         _server_vanished_cb,
79                         NULL, NULL);
80         }
81
82         LOGD("server_watcher_id : %d", *server_watcher_id);
83         if (*server_watcher_id == 0) {
84                 LOGE("Failed to get identifier");
85                 return HAND_GESTURE_ERROR_OPERATION_FAILED;
86         }
87
88         return HAND_GESTURE_ERROR_NONE;
89 }
90
91
92 static void _handle_gesture_cb(GDBusConnection *connection,
93                                         const gchar *sender_name,
94                                         const gchar *object_path,
95                                         const gchar *interface_name,
96                                         const gchar *signal_name,
97                                         GVariant *parameters,
98                                         gpointer user_data)
99 {
100         LOGD("own_name : %s, signal_name : %s", g_dbus_connection_get_unique_name(connection), signal_name);
101         hand_gesture_h _handle = (hand_gesture_h)user_data;
102
103         if (_handle == NULL) {
104                 LOGE("handle is not available");
105                 return;
106         }
107
108         if (parameters == NULL) {
109                 LOGE("failed to get gesture info");
110                 return;
111         }
112
113         if (g_strcmp0(signal_name, GESTURE_CLIENT_SIGNAL_GET_RESULT) == 0) {
114                 LOGD("[GESTURE_CLIENT_SIGNAL_GET_RESULT] called");
115                 int event;
116                 int gesture_type;
117                 int ltype;
118                 int levent;
119                 int lcount;
120                 g_variant_get(parameters, "(iiiii)", &event, &gesture_type, &ltype, &levent, &lcount);
121 #if 0
122                 char *printmsg = g_variant_print(parameters, true);
123                 LOGD("start parameter print : %s", printmsg);
124                 g_free(printmsg);
125                 LOGD("[event = %d] [gesture_type = %d] [ltype = %d] [levent = %d] [lcount = %d]", event, gesture_type, ltype, levent, lcount);
126 #endif
127                 if (g_gesture_data == NULL){
128                         LOGD("Can't send the result to Client because g_gesture_data is NULL");
129                         return;
130                 }
131                 LOGD("address = %p", g_gesture_data);
132                 g_gesture_data->gesture_type = ltype;
133                 g_gesture_data->event = levent;
134                 g_gesture_data->detected_Count = lcount;
135
136 //              g_callback(gesture_type, g_gesture_data, 0, HAND_GESTURE_ERROR_NONE, user_data);
137                 if (_handle->recog_cb) {
138                         LOGD("[CLIENT DBUS] Send recognition result. gesture_type(%d)", gesture_type);
139                         _handle->recog_cb(_handle, gesture_type, 0, HAND_GESTURE_ERROR_NONE, _handle->recog_user_data);
140                 }
141         }
142         else if (g_strcmp0(signal_name, GESTURE_CLIENT_SIGNAL_GET_ERROR) == 0) {
143                 int error;
144                 char* err_msg = NULL;
145                 g_variant_get(parameters, "(is)", &error, err_msg);
146                 LOGD("[CLIENT DBUS] error(%d)", error);
147
148                 if (_handle->error_cb) {
149                         LOGD("[CLIENT DBUS] Send error");
150                         _handle->error_cb(_handle, (hand_gesture_error_e)error, err_msg, _handle->error_user_data);
151                 } else {
152                         LOGW("[CLIENT DBUS] There is no error callback");
153                 }
154         }
155         else if (g_strcmp0(signal_name, GESTURE_CLIENT_SIGNAL_GET_MOTION_STATUS) == 0) {
156
157         }
158         else if (g_strcmp0(signal_name, GESTURE_CLIENT_SIGNAL_GET_ENGINE_INFO) == 0) {
159                 g_variant_get(parameters, "(ss)", &g_engine_app_id, &g_engine_name);
160 #if 1
161                 char *printmsg = g_variant_print(parameters, true);
162                 LOGD("[engineInfo]start parameter print : %s", printmsg);
163                 g_free(printmsg);
164                 LOGE("[engineInfo][g_engine_app_id = %s] [g_engine_name = %s]", g_engine_app_id, g_engine_name);
165 #endif
166
167         }
168 }
169
170 static int _dbus_signal_init(GDBusConnection *gdbus_connection, int *monitor_id, CLIENT_LIB lib, void *data)
171 {
172         int ret = HAND_GESTURE_ERROR_NONE;
173         if (*monitor_id == 0) {
174                 int id = 0;
175                 if (lib == GESTURE_CLIENT_LIB_GESTURE) {
176                         id = g_dbus_connection_signal_subscribe(gdbus_connection,
177                                                         GESTURE_DBUS_NAME,
178                                                         GESTURE_CLIENT_INTERFACE_NAME,
179                                                         NULL,
180                                                         GESTURE_OBJECT_PATH,
181                                                         NULL,
182                                                         G_DBUS_SIGNAL_FLAGS_NONE,
183                                                         _handle_gesture_cb,
184                                                         data,
185                                                         NULL);
186                 } else if (lib == GESTURE_CLIENT_LIB_ENGINE) {
187                         LOGD("Fail to come for ENGINE lib");
188                 } else {
189                         LOGD("Fail to Not CLIENT lib");
190                 }
191
192                 LOGD("id : %d", id);
193                 if (id == 0) {
194                         ret = HAND_GESTURE_ERROR_OPERATION_FAILED;
195                         LOGE("g_dbus_connection_signal_subscribe() failed");
196                 } else {
197                         *monitor_id = id;
198                 }
199         }
200
201         return ret;
202 }
203
204 static GDBusMessage *gdbus_make_message(GVariant *body, const char *cmd)
205 {
206         LOGD("gdbus_make_message : cmd = %s", cmd);
207         GDBusMessage *message = NULL;
208         message = g_dbus_message_new_method_call(
209         GESTURE_DBUS_NAME,
210         GESTURE_OBJECT_PATH,
211         GESTURE_INTERFACE_NAME,
212         cmd);
213
214         if (!message) {
215                 LOGE("Failed to create a new gdbus message");
216                 if (body)
217                         g_variant_unref(body);
218                 return NULL;
219         }
220
221         if (body != NULL)
222                 g_dbus_message_set_body(message, body);
223
224         return message;
225 }
226
227 static int _send_message_with_sync(GDBusConnection *gdbus_connection, GDBusMessage *msg, GDBusMessage **reply, const char *cmd)
228 {
229         LOGD("_send_message_with_sync : cmd = %s", cmd);
230         int ret = HAND_GESTURE_ERROR_NONE;
231         GError *err = NULL;
232
233         gchar *printmsg = g_dbus_message_print (msg, 1);
234         LOGD("[sync] before send to server, print : %s", printmsg);
235         g_free(printmsg);
236
237         *reply = g_dbus_connection_send_message_with_reply_sync(
238                                         gdbus_connection,
239                                         msg,
240                                         G_DBUS_SEND_MESSAGE_FLAGS_NONE,
241                                         -1,
242                                         NULL,
243                                         NULL,
244                                         &err);
245
246         if (!*reply) {
247                 ret = HAND_GESTURE_ERROR_OPERATION_FAILED;
248                 if (err != NULL) {
249                         LOGE("Error occurred when sending message(%s) : %s", cmd, err->message);
250                         if (err->code == G_DBUS_ERROR_ACCESS_DENIED)
251                                 ret = HAND_GESTURE_ERROR_PERMISSION_DENIED;
252                         g_error_free(err);
253                 }
254                 return ret;
255         }
256
257         if (g_dbus_message_to_gerror(*reply, &err)) {
258                 LOGE("error message = %s, code = %d", err->message, err->code);
259                 if (err->code == G_DBUS_ERROR_ACCESS_DENIED)
260                         ret = HAND_GESTURE_ERROR_PERMISSION_DENIED;
261                 else
262                         ret = err->code;
263                 g_error_free(err);
264                 return ret;
265         }
266 #if 0
267         printmsg = g_dbus_message_print (*reply, 1);
268         LOGD("[sync] reply from server, print : %s", printmsg);
269         g_free(printmsg);
270
271         GVariant *result = NULL;
272         result = g_dbus_message_get_body(*reply);
273         if (result != NULL) {
274                 printmsg = g_variant_print(result, true);
275                 LOGD("Result msg print : %s", printmsg);
276                 g_free(printmsg);
277         }
278 #endif
279         return HAND_GESTURE_ERROR_NONE;
280 }
281
282 static int gdbus_send_message_with_sync(GDBusConnection *gdbus_connection, GVariant *body, GDBusMessage **reply, char *cmd)
283 {
284         LOGD("gdbus_send_message_with_sync start : cmd = %s", cmd);
285
286         int ret = HAND_GESTURE_ERROR_NONE;
287         GDBusMessage *msg = NULL;
288
289         msg = gdbus_make_message(body, cmd);
290         if (msg == NULL)
291                 return HAND_GESTURE_ERROR_OPERATION_FAILED;
292
293         ret = _send_message_with_sync(gdbus_connection, msg, reply, cmd);
294
295         if (msg)
296                 g_object_unref(msg);
297
298         return ret;
299 }
300
301 static void _async_cb(GDBusConnection *connection, GAsyncResult *res, gpointer user_data)
302 {
303         LOGD("_async_cb start");
304         GDBusMessage *reply = NULL;
305         GError *err = NULL;
306 //      hand_gesture_data_h gesturedata = (hand_gesture_data_h)user_data;
307
308         reply = g_dbus_connection_send_message_with_reply_finish(connection, res, &err);
309         if (reply) {
310                 if (g_dbus_message_to_gerror(reply, &err)) {
311                         LOGE("error message = %s, code = %d", err->message, err->code);
312                         g_error_free(err);
313                         return;
314                 }
315 #if 0
316                 GVariant *result = g_dbus_message_get_body(reply);
317                 gchar *printmsg = g_variant_print (result, true);
318                 LOGD("[async] _async_cb, print : %s", printmsg);
319                 g_free(printmsg);
320 #endif
321
322         } else {
323                 LOGE("There is no reply");
324                 return;
325         }
326
327         if (reply)
328                 g_object_unref(reply);
329
330         return;
331 }
332
333 static int gdbus_send_message_with_async(GDBusConnection *gdbus_connection, GVariant *body, char *cmd, hand_gesture_data_h gesture_data)
334 {
335         LOGD("gdbus_send_message_with_async start : cmd = %s", cmd);
336         int ret = HAND_GESTURE_ERROR_NONE;
337         GDBusMessage *msg = NULL;
338
339         msg = gdbus_make_message(body, cmd);
340         if (msg == NULL)
341                 return HAND_GESTURE_ERROR_OPERATION_FAILED;
342
343         g_dbus_connection_send_message_with_reply(
344                 gdbus_connection,
345                 msg,
346                 G_DBUS_SEND_MESSAGE_FLAGS_NONE,
347                 -1,
348                 NULL,
349                 NULL,
350                 (GAsyncReadyCallback)_async_cb,
351                 gesture_data);
352
353         if (msg)
354                 g_object_unref(msg);
355
356         return ret;
357 }
358
359 static int _monitor_register(GDBusConnection *gdbus_connection)
360 {
361         int ret;
362         GDBusMessage *reply = NULL;
363         GVariant *client_body = NULL;
364
365         char appid[1024] = {0, };
366         ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid));
367         if (ret != 0) {
368                 LOGE("aul_app_get_appid_bypid() failed : %d", ret);
369         }
370
371         client_body = g_variant_new("(iis)", 11, GESTURE_CLIENT_LIB_GESTURE, appid);
372
373         ret = gdbus_send_message_with_sync(gdbus_connection, client_body, &reply, GESTURE_MSG_SERVICE_REGISTER);
374         if (reply)
375                 g_object_unref(reply);
376
377         if (client_body)
378                 g_variant_unref(client_body);
379
380         if (ret != HAND_GESTURE_ERROR_NONE) {
381                 LOGE("gdbus_send_message_with_sync() failed : %d", ret);
382                 return ret;
383         }
384
385         is_server_started = 1;
386         return ret;
387 }
388
389 static void _on_name_appeared(GDBusConnection *connection,
390                 const gchar     *name,
391                 const gchar     *name_owner,
392                 gpointer         user_data)
393 {
394         if (is_server_started == 0)
395         _monitor_register(connection);
396 }
397
398 static void _on_name_vanished(GDBusConnection *connection,
399                 const gchar     *name,
400                 gpointer         user_data)
401 {
402         is_server_started = 0;
403 }
404
405 int gesture_client_dbus_init(GDBusConnection **gdbus_connection, guint *server_watcher_id,
406                                 int *monitor_id, int *server_monitor_id, CLIENT_LIB lib, void *data)
407 {
408         LOGD("gesture_client_dbus_init start");
409
410         int ret;
411
412         ret = _dbus_init(gdbus_connection, server_watcher_id);
413         if (ret != HAND_GESTURE_ERROR_NONE) {
414                 LOGE("_dbus_init() failed : %d", ret);
415                 return ret;
416         }
417
418         ret = _dbus_signal_init(*gdbus_connection, monitor_id, lib, data);
419         if (ret != HAND_GESTURE_ERROR_NONE) {
420                 LOGE("_dbus_signal_init() failed : %d", ret);
421                 return ret;
422         }
423
424         ret = _monitor_register(*gdbus_connection);
425         if (ret != HAND_GESTURE_ERROR_NONE) {
426                 LOGE("_monitor_register() failed : %d", ret);
427                 return ret;
428         }
429
430         if (*server_monitor_id == 0) {
431                 *server_monitor_id = g_bus_watch_name_on_connection(
432                                 *gdbus_connection,
433                                 GESTURE_DBUS_NAME,
434                                 G_BUS_NAME_WATCHER_FLAGS_NONE,
435                                 _on_name_appeared,
436                                 _on_name_vanished,
437                                 NULL,
438                                 NULL);
439                 if (*server_monitor_id == 0) {
440                         g_dbus_connection_signal_unsubscribe(*gdbus_connection, *monitor_id);
441                         *monitor_id = 0;
442                         LOGE("Failed to get identifier");
443                         return HAND_GESTURE_ERROR_OPERATION_FAILED;
444                 }
445         }
446
447         return HAND_GESTURE_ERROR_NONE;
448 }
449
450 int gesture_client_dbus_shutdown(GDBusConnection *gdbus_connection, int *server_monitor_id, int *monitor_id)
451 {
452         if (*server_monitor_id) {
453                 g_bus_unwatch_name(*server_monitor_id);
454                 *server_monitor_id = 0;
455         }
456
457         if (*monitor_id) {
458                 g_dbus_connection_signal_unsubscribe(gdbus_connection, *monitor_id);
459                 *monitor_id = 0;
460         }
461
462         return HAND_GESTURE_ERROR_NONE;
463 }
464
465 int gesture_client_dbus_initialize_engine(GDBusConnection *gdbus_connection)
466 {
467         int ret;
468         GDBusMessage *reply = NULL;
469         GVariant *body = NULL;
470
471         body = g_variant_new("()");
472         ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_CLIENT_MSG_INITIALIZE_ENGINE);
473         if (ret != HAND_GESTURE_ERROR_NONE)
474                 LOGE("failed to initialize");
475
476         if (body)
477                 g_variant_unref(body);
478
479         if (reply)
480                 g_object_unref(reply);
481
482         return ret;
483
484 }
485
486 int gesture_client_dbus_deinitialize_engine(GDBusConnection *gdbus_connection)
487 {
488         int ret;
489         GDBusMessage *reply = NULL;
490         GVariant *body = NULL;
491
492         body = g_variant_new("()");
493         ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_CLIENT_MSG_DEINITIALIZE_ENGINE);
494         if (ret != HAND_GESTURE_ERROR_NONE)
495                 LOGE("failed to deinitialize");
496
497         if (body)
498                 g_variant_unref(body);
499
500         if (reply)
501                 g_object_unref(reply);
502
503         return ret;
504
505 }
506
507 int gesture_client_dbus_set_handtype(GDBusConnection *gdbus_connection, hand_gesture_handtype_e hand_type)
508 {
509         int ret = HAND_GESTURE_ERROR_NONE;
510         if (hand_type > HAND_GESTURE_RIGHT_HAND || hand_type < HAND_GESTURE_NO_SELECTED_HAND) {
511                 LOGE("Invalid Parmeter");
512                 return HAND_GESTURE_ERROR_INVALID_PARAMETER;
513         }
514         g_hand_type = hand_type;
515
516         return ret;
517 }
518
519 int gesture_client_dbus_set_workmode(GDBusConnection *gdbus_connection, hand_gesture_workmode_e work_mode)
520 {
521         int ret = HAND_GESTURE_ERROR_NONE;
522         if (work_mode > HAND_GESTURE_WORK_MODE_UNDEFINED || work_mode < HAND_GESTURE_WORK_MODE_ONE_WAY) {
523                 LOGE("Invalid Parmeter");
524                 return HAND_GESTURE_ERROR_INVALID_PARAMETER;
525         }
526         g_work_mode = work_mode;
527
528         return ret;
529 }
530
531 int gesture_client_dbus_set_option(GDBusConnection *gdbus_connection, hand_gesture_option_e option)
532 {
533         int ret = HAND_GESTURE_ERROR_NONE;
534         if (option > HAND_GESTURE_OPTION_ALWAYS_ON || option < HAND_GESTURE_OPTION_DEFAULT) {
535                 LOGE("Invalid Parmeter");
536                 return HAND_GESTURE_ERROR_INVALID_PARAMETER;
537         }
538         g_option = option;
539
540         return ret;
541 }
542
543 int gesture_client_dbus_set_sensitivity(GDBusConnection *gdbus_connection, int sensitivity)
544 {
545         int ret = HAND_GESTURE_ERROR_NONE;
546         g_sensitivity = sensitivity;
547
548         return ret;
549 }
550
551 int gesture_client_dbus_start_recognition(GDBusConnection *gdbus_connection, hand_gesture_type_e gesture_type, hand_gesture_data_h gesture_data, hand_gesture_recognition_cb callback)
552 {
553         LOGD("gesture_client_dbus_start_recognition start");
554         LOGD("client busname: %s", g_dbus_connection_get_unique_name(gdbus_connection));
555         g_callback = callback;
556         g_gesture_data = gesture_data;
557
558         GVariant *body = NULL;
559         body = g_variant_new("(iiiii)", gesture_type, g_hand_type, g_work_mode, g_option, g_sensitivity);
560
561         gdbus_send_message_with_async(gdbus_connection, body, GESTURE_CLIENT_MSG_START_RECOGNITION, gesture_data);
562
563         if (body)
564                 g_variant_unref(body);
565
566         return HAND_GESTURE_ERROR_NONE;
567 }
568
569 int gesture_client_dbus_stop_recognition(GDBusConnection *gdbus_connection)
570 {
571         int ret;
572         GDBusMessage *reply = NULL;
573         GVariant *body = NULL;
574
575         /* free for gesture data struct */
576         _free_gesture_data(g_gesture_data);
577
578         body = g_variant_new("()");
579         ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_CLIENT_MSG_STOP_RECOGNITION);
580         if (ret != HAND_GESTURE_ERROR_NONE)
581                 LOGE("failed to stop gesture");
582
583         if (body)
584                 g_variant_unref(body);
585
586         if (reply)
587                 g_object_unref(reply);
588
589         return ret;
590
591 }
592
593 int gesture_client_dbus_foreach_result_time(GDBusConnection *gdbus_connection)
594 {
595         int ret;
596         GDBusMessage *reply = NULL;
597         GVariant *body = NULL;
598
599         body = g_variant_new("()");
600         ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_CLIENT_MSG_FOREACH_RESULT_TIME);
601         if (ret != HAND_GESTURE_ERROR_NONE)
602                 LOGE("failed to foreach_result_time");
603
604         if (body)
605                 g_variant_unref(body);
606
607         if (reply)
608                 g_object_unref(reply);
609
610         return ret;
611
612 }
613
614 int gesture_client_dbus_foreach_supported_type(GDBusConnection *gdbus_connection)
615 {
616         int ret;
617         GDBusMessage *reply = NULL;
618         GVariant *body = NULL;
619
620         body = g_variant_new("()");
621         ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_CLIENT_MSG_FOREACH_SUPPORTED_TYPE);
622         if (ret != HAND_GESTURE_ERROR_NONE)
623                 LOGE("failed to foreach_supported_type");
624
625         if (body)
626                 g_variant_unref(body);
627
628         if (reply)
629                 g_object_unref(reply);
630
631         return ret;
632
633 }
634
635 int gesture_client_dbus_is_support_gesture_type(GDBusConnection *gdbus_connection, hand_gesture_type_e gesture, bool* supported)
636 {
637         int ret;
638         GDBusMessage *reply = NULL;
639         GVariant *body = NULL;
640
641         body = g_variant_new("()");
642         ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_CLIENT_MSG_IS_SUPPORT_GESTURE_TYPE);
643         if (ret != HAND_GESTURE_ERROR_NONE)
644                 LOGE("failed to is_supported_gesture_type");
645
646         if (body)
647                 g_variant_unref(body);
648
649         if (reply)
650                 g_object_unref(reply);
651
652         return ret;
653
654 }
655
656 int gesture_client_dbus_get_engine_info(GDBusConnection *gdbus_connection, char** engine_app_id, char** engine_name)
657 {
658         int ret;
659         GDBusMessage *reply = NULL;
660         GVariant *body = NULL;
661         g_engine_app_id = *engine_app_id;
662         g_engine_name = *engine_name;
663
664         body = g_variant_new("()");
665         ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_CLIENT_MSG_ENGINE_GET_INFO);
666         if (ret != HAND_GESTURE_ERROR_NONE)
667                 LOGE("failed to engine_get_info");
668
669         if (body)
670                 g_variant_unref(body);
671
672         if (reply)
673                 g_object_unref(reply);
674
675         return ret;
676 }
677