Change length of copy when snprintf is called
[platform/core/api/gesture.git] / engine / gesture_engine_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_engine_dbus.h"
21 #include "gesture_engine_main.h"
22
23 #ifdef LOG_TAG
24 #undef LOG_TAG
25 #endif
26 #define LOG_TAG "GESTURE_ENGINE_DBUS"
27
28 static int is_server_started = 0;
29 static gesture_engine_request_callback_s g_basic_engine_callback;
30 static GDBusConnection *mgdbus_connection;
31
32 static int gdbus_send_message_with_async(GDBusConnection *gdbus_connection, GVariant *body, char *cmd);
33
34 static void _server_appeared_cb(GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data)
35 {
36         LOGD("name : %s, name_owner : %s", name, name_owner);
37 }
38
39 static void _server_vanished_cb(GDBusConnection *connection, const gchar *name, gpointer user_data)
40 {
41         LOGD("name : %s", name);
42 }
43
44 static int _dbus_init(GDBusConnection **gdbus_connection, guint *server_watcher_id)
45 {
46         GError *error = NULL;
47
48         if (*gdbus_connection == NULL) {
49                 GDBusConnection *conn = NULL;
50                 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
51                 if (conn == NULL) {
52                         if (error != NULL) {
53                                 LOGE("g_bus_get_sync error message = %s", error->message);
54                                 g_error_free(error);
55                         }
56                         return GESTURE_ENGINE_ERROR_IO_ERROR;
57                 }
58                 *gdbus_connection = conn;
59         }
60
61         LOGD("Connected bus name : %s", g_dbus_connection_get_unique_name(*gdbus_connection));
62         if (*server_watcher_id == 0) {
63                 *server_watcher_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
64                         GESTURE_DBUS_NAME,
65                         G_BUS_NAME_WATCHER_FLAGS_NONE,
66                         _server_appeared_cb,
67                         _server_vanished_cb,
68                         NULL, NULL);
69         }
70
71         LOGD("server_watcher_id : %d", *server_watcher_id);
72         if (*server_watcher_id == 0) {
73                 LOGE("Failed to get identifier");
74                 return GESTURE_ENGINE_ERROR_IO_ERROR;
75         }
76
77         return GESTURE_ENGINE_ERROR_NONE;
78 }
79
80 // callback the result data that received from engine service app.
81 // will pass this data to daemon
82 static void gesture_cb(hand_gesture_type_e gesture, const hand_gesture_data_h data, double timestamp, gesture_engine_error_e error, void *user_data)
83 {
84         if(!data) {
85                 LOGE("gesture cb data is NULL");
86                 return;
87         }
88         LOGD("gesture cb >> hand_gesture_type_e : %d", gesture);
89         LOGD("own_name : %s", g_dbus_connection_get_unique_name(mgdbus_connection));
90         gesture_engine_dbus_send_result(mgdbus_connection, GESTURE_ENGINE_RESULT_EVENT_FINAL_RESULT, gesture, data, NULL, user_data);
91 }
92
93 // called when daemon calls engine with g_dbus_connection_emit_signal.
94 // must send signal to the engine service app.
95 static void _handle_gesture_engine_cb(GDBusConnection *connection,
96                                         const gchar *sender_name,
97                                         const gchar *object_path,
98                                         const gchar *interface_name,
99                                         const gchar *signal_name,
100                                         GVariant *parameters,
101                                         gpointer user_data)
102 {
103 #if 0
104         LOGD("own_name : %s, sender_name : %s", g_dbus_connection_get_unique_name(connection), sender_name);
105         LOGD("object_path : %s, interface_name : %s", object_path, interface_name);
106         LOGD("signal_name : %s", signal_name);
107         char *printmsg = g_variant_print(parameters, true);
108         LOGD("_handle_gesture_engine_cb parameter print : %s", printmsg);
109         g_free(printmsg);
110 #endif
111         gesture_engine_h engine_handle = (gesture_engine_h)user_data;
112
113         if (engine_handle == NULL) {
114                 LOGE("engine handle is not available");
115                 return;
116         }
117
118         if (parameters == NULL) {
119                 LOGE("failed to get gesture info");
120                 return;
121         }
122
123         if (g_strcmp0(signal_name, GESTURE_ENGINE_SIGNAL_ENGINE_INITIALIZE) == 0) {
124                 LOGD("[engine_initialize] called");
125                 g_basic_engine_callback.initialize();
126         }
127         else if (g_strcmp0(signal_name, GESTURE_ENGINE_SIGNAL_ENGINE_DEINITIALIZE) == 0) {
128                 LOGD("[engine_deinitialize] called");
129                 g_basic_engine_callback.deinitialize();
130         }
131         else if (g_strcmp0(signal_name, GESTURE_ENGINE_SIGNAL_ENGINE_START) == 0) {
132                 LOGD("[GESTURE_ENGINE_SIGNAL_ENGINE_START] called");
133                 int gesture_type = 1;
134                 int hand_type = 2;
135                 int work_mode = 2;
136                 int option = 1;
137                 int sensitivity = 1;
138                 g_variant_get(parameters, "(iiiii)", &gesture_type, &hand_type, &work_mode, &option, &sensitivity);
139                 g_basic_engine_callback.start(gesture_type, hand_type, work_mode, option, sensitivity, gesture_cb, NULL);
140         }
141         else if (g_strcmp0(signal_name, GESTURE_ENGINE_SIGNAL_ENGINE_STOP) == 0) {
142                 LOGD("[GESTURE_ENGINE_SIGNAL_ENGINE_STOP] called");
143                 g_basic_engine_callback.stop();
144         }
145         else if (g_strcmp0(signal_name, GESTURE_ENGINE_SIGNAL_FOREACH_RESULT_TIME) == 0) {
146                 LOGD("[GESTURE_ENGINE_SIGNAL_FOREACH_RESULT_TIME] called");
147                 g_basic_engine_callback.foreach_result_time(NULL, NULL, NULL);
148         }
149         else if (g_strcmp0(signal_name, GESTURE_ENGINE_SIGNAL_FOREACH_SUPPORTED_TYPE) == 0) {
150                 LOGD("[GESTURE_ENGINE_SIGNAL_FOREACH_SUPPORTED_TYPE] called");
151                 g_basic_engine_callback.foreach_types(NULL, NULL);
152         }
153         else if (g_strcmp0(signal_name, GESTURE_ENGINE_SIGNAL_IS_SUPPORT_GESTURE_TYPE) == 0) {
154                 LOGD("[GESTURE_ENGINE_SIGNAL_IS_SUPPORT_GESTURE_TYPE] called");
155                 int id = 0;
156                 int gesture_type = 0;
157                 g_variant_get(parameters, "(ii)", &id, &gesture_type);
158                 LOGD("Invocation ID(%d), Gesture Type(%d)", id, gesture_type);
159
160                 bool is_supported = false;
161                 g_basic_engine_callback.is_support_gesture_type(gesture_type, &is_supported);
162                 GVariant* body = g_variant_new("(ib)", id, is_supported);
163                 if (NULL == body) {
164                         LOGE("Fail to create body");
165                         return;
166                 }
167
168                 LOGD("send message variant. ID(%d), Is supported(%d)", id, is_supported);
169                 gdbus_send_message_with_async(connection, body, GESTURE_ENGINE_MSG_IS_SUPPORT_GESTURE_TYPE);
170                 g_variant_unref(body);
171         }
172         else if (g_strcmp0(signal_name, GESTURE_ENGINE_SIGNAL_GET_ENGINE_INFO) == 0) {
173                 LOGD("[GESTURE_ENGINE_SIGNAL_GET_ENGINE_INFO] called");
174                 int id = 0;
175                 g_variant_get(parameters, "(i)", &id);
176                 LOGD("Invocation ID(%d)", id);
177
178                 char *engine_app_id = NULL;
179                 char *engine_name = NULL;
180                 g_basic_engine_callback.get_info(&engine_app_id, &engine_name);
181                 if (NULL == engine_app_id || NULL == engine_name) {
182                         LOGE("Fail to get engine information");
183                         return;
184                 }
185
186                 GVariant* body = g_variant_new("(iss)", id, engine_app_id, engine_name);
187                 if (NULL == body) {
188                         LOGE("Fail to create body");
189                         return;
190                 }
191
192                 LOGD("send message variant. APP ID(%s), Name(%s)", engine_app_id, engine_name);
193                 gdbus_send_message_with_async(connection, body, GESTURE_ENGINE_MSG_GET_ENGINE_INFO);
194                 g_variant_unref(body);
195         }
196 }
197
198 static int _dbus_signal_init(GDBusConnection *gdbus_connection, int *monitor_id, CLIENT_LIB lib, void *data)
199 {
200         int ret = GESTURE_ENGINE_ERROR_NONE;
201         if (*monitor_id == 0) {
202                 int id = 0;
203                 if (lib == GESTURE_CLIENT_LIB_GESTURE)
204                         LOGD("Fail to come for CLIENT lib");
205                 else if (lib == GESTURE_CLIENT_LIB_ENGINE)
206                         id = g_dbus_connection_signal_subscribe(gdbus_connection,
207                                                         GESTURE_DBUS_NAME,
208                                                         GESTURE_ENGINE_INTERFACE_NAME,
209                                                         NULL,
210                                                         GESTURE_OBJECT_PATH,
211                                                         NULL,
212                                                         G_DBUS_SIGNAL_FLAGS_NONE,
213                                                         _handle_gesture_engine_cb,
214                                                         data,
215                                                         NULL);
216                 else
217                         LOGD("Fail to Not come for Engine Lib");
218
219                 LOGD("id : %d", id);
220                 if (id == 0) {
221                         ret = GESTURE_ENGINE_ERROR_IO_ERROR;
222                         LOGE("g_dbus_connection_signal_subscribe() failed");
223                 } else {
224                         *monitor_id = id;
225                 }
226         }
227
228         return ret;
229 }
230
231 static GDBusMessage *gdbus_make_message(GVariant *body, const char *cmd)
232 {
233         LOGD("gdbus_make_message : cmd = %s", cmd);
234         GDBusMessage *message = NULL;
235         message = g_dbus_message_new_method_call(
236         GESTURE_DBUS_NAME,
237         GESTURE_OBJECT_PATH,
238         GESTURE_INTERFACE_NAME,
239         cmd);
240
241         if (!message) {
242                 LOGE("Failed to create a new gdbus message");
243                 if (body)
244                         g_variant_unref(body);
245                 return NULL;
246         }
247
248         if (body != NULL)
249                 g_dbus_message_set_body(message, body);
250
251         return message;
252 }
253
254 static int _send_message_with_sync(GDBusConnection *gdbus_connection, GDBusMessage *msg, GDBusMessage **reply, const char *cmd)
255 {
256         LOGD("_send_message_with_sync : cmd = %s", cmd);
257         int ret = GESTURE_ENGINE_ERROR_NONE;
258         GError *err = NULL;
259
260         gchar *printmsg = g_dbus_message_print (msg, 1);
261         LOGD("[sync] before send to server, print : %s", printmsg);
262         g_free(printmsg);
263
264         *reply = g_dbus_connection_send_message_with_reply_sync(
265                                         gdbus_connection,
266                                         msg,
267                                         G_DBUS_SEND_MESSAGE_FLAGS_NONE,
268                                         -1,
269                                         NULL,
270                                         NULL,
271                                         &err);
272
273         if (!*reply) {
274                 ret = GESTURE_ENGINE_ERROR_SERVICE_NOT_READY;
275                 if (err != NULL) {
276                         LOGE("Error occurred when sending message(%s) : %s", cmd, err->message);
277                         if (err->code == G_DBUS_ERROR_ACCESS_DENIED)
278                                 ret = GESTURE_ENGINE_ERROR_PERMISSION_DENIED;
279                         g_error_free(err);
280                 }
281                 return ret;
282         }
283
284         if (g_dbus_message_to_gerror(*reply, &err)) {
285                 LOGE("error message = %s, code = %d", err->message, err->code);
286                 if (err->code == G_DBUS_ERROR_ACCESS_DENIED)
287                         ret = GESTURE_ENGINE_ERROR_PERMISSION_DENIED;
288                 else
289                         ret = err->code;
290                 g_error_free(err);
291                 return ret;
292         }
293 #if 0
294         printmsg = g_dbus_message_print (*reply, 1);
295         LOGD("[sync] reply from server, print : %s", printmsg);
296         g_free(printmsg);
297
298         GVariant *result = NULL;
299         result = g_dbus_message_get_body(*reply);
300         if (result != NULL) {
301                 printmsg = g_variant_print(result, true);
302                 LOGD("Result msg print : %s", printmsg);
303                 g_free(printmsg);
304         }
305 #endif
306         return GESTURE_ENGINE_ERROR_NONE;
307 }
308
309 static int gdbus_send_message_with_sync(GDBusConnection *gdbus_connection, GVariant *body, GDBusMessage **reply, char *cmd)
310 {
311         LOGD("gdbus_send_message_with_sync start : cmd = %s", cmd);
312
313         int ret = GESTURE_ENGINE_ERROR_NONE;
314         GDBusMessage *msg = NULL;
315
316         msg = gdbus_make_message(body, cmd);
317         if (msg == NULL)
318                 return GESTURE_ENGINE_ERROR_IO_ERROR;
319
320         ret = _send_message_with_sync(gdbus_connection, msg, reply, cmd);
321
322         if (msg)
323                 g_object_unref(msg);
324
325         return ret;
326 }
327
328 static void _async_cb(GDBusConnection *connection, GAsyncResult *res, gpointer user_data)
329 {
330         LOGD("_async_cb start");
331         GDBusMessage *reply = NULL;
332         GError *err = NULL;
333
334         reply = g_dbus_connection_send_message_with_reply_finish(connection, res, &err);
335         if (reply) {
336                 if (g_dbus_message_to_gerror(reply, &err)) {
337                         LOGE("error message = %s, code = %d", err->message, err->code);
338                         g_error_free(err);
339                         return;
340                 }
341 #if 1
342                 GVariant *result = g_dbus_message_get_body(reply);
343                 if (result) {
344                         gchar *printmsg = g_variant_print (result, true);
345                         LOGD("[async] _async_cb, print : %s", printmsg);
346                         g_free(printmsg);
347                 } else {
348                         LOGD("[async] result is null");
349                 }
350 #endif
351
352         } else {
353                 LOGE("There is no reply");
354                 return;
355         }
356
357         if (reply)
358                 g_object_unref(reply);
359
360         return;
361 }
362
363 static int gdbus_send_message_with_async(GDBusConnection *gdbus_connection, GVariant *body, char *cmd)
364 {
365         LOGD("gdbus_send_message_with_async start : cmd = %s", cmd);
366         int ret = GESTURE_ENGINE_ERROR_NONE;
367         GDBusMessage *msg = NULL;
368
369         msg = gdbus_make_message(body, cmd);
370         if (msg == NULL)
371                 return GESTURE_ENGINE_ERROR_OPERATION_FAILED;
372
373         g_dbus_connection_send_message_with_reply(
374                 gdbus_connection,
375                 msg,
376                 G_DBUS_SEND_MESSAGE_FLAGS_NONE,
377                 -1,
378                 NULL,
379                 NULL,
380                 (GAsyncReadyCallback)_async_cb,
381                 NULL);
382
383         if (msg)
384                 g_object_unref(msg);
385
386         return ret;
387 }
388
389 static int _monitor_register(GDBusConnection *gdbus_connection)
390 {
391         int ret = GESTURE_ENGINE_ERROR_NONE;
392         GDBusMessage *reply = NULL;
393         GVariant *engine_body = NULL;
394
395         char appid[1024] = {0, };
396         ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid));
397         if (ret != 0) {
398                 LOGE("aul_app_get_appid_bypid() failed : %d", ret);
399                 return GESTURE_ENGINE_ERROR_OPERATION_FAILED;
400         }
401
402         engine_body = g_variant_new("(iisiss)", 22, GESTURE_CLIENT_LIB_ENGINE, appid, getpid(), "NULL", "NULL");
403
404         ret = gdbus_send_message_with_sync(gdbus_connection, engine_body, &reply, GESTURE_MSG_SERVICE_REGISTER);
405         if (reply)
406                 g_object_unref(reply);
407
408         if (engine_body)
409                 g_variant_unref(engine_body);
410
411         if (ret != GESTURE_ENGINE_ERROR_NONE) {
412                 LOGE("gdbus_send_message_with_sync() failed : %d", ret);
413                 return ret;
414         }
415
416         is_server_started = 1;
417         return ret;
418 }
419
420 static void _on_name_appeared(GDBusConnection *connection,
421                 const gchar     *name,
422                 const gchar     *name_owner,
423                 gpointer         user_data)
424 {
425         if (is_server_started == 0)
426         _monitor_register(connection);
427 }
428
429 static void _on_name_vanished(GDBusConnection *connection,
430                 const gchar     *name,
431                 gpointer         user_data)
432 {
433         is_server_started = 0;
434 }
435
436 int gesture_engine_dbus_init(GDBusConnection **gdbus_connection, guint *server_watcher_id,
437                                 int *monitor_id, int *server_monitor_id, CLIENT_LIB lib, void *data)
438 {
439         LOGD("gesture_dbus_init start");
440
441         int ret;
442
443         ret = _dbus_init(gdbus_connection, server_watcher_id);
444         if (ret != GESTURE_ENGINE_ERROR_NONE) {
445                 LOGE("_dbus_init() failed : %d", ret);
446                 return ret;
447         }
448
449         ret = _dbus_signal_init(*gdbus_connection, monitor_id, lib, data);
450         if (ret != GESTURE_ENGINE_ERROR_NONE) {
451                 LOGE("_dbus_signal_init() failed : %d", ret);
452                 return ret;
453         }
454
455         ret = _monitor_register(*gdbus_connection);
456         if (ret != GESTURE_ENGINE_ERROR_NONE) {
457                 LOGE("_monitor_register() failed : %d", ret);
458                 return ret;
459         }
460
461         if (*server_monitor_id == 0) {
462                 *server_monitor_id = g_bus_watch_name_on_connection(
463                                 *gdbus_connection,
464                                 GESTURE_DBUS_NAME,
465                                 G_BUS_NAME_WATCHER_FLAGS_NONE,
466                                 _on_name_appeared,
467                                 _on_name_vanished,
468                                 NULL,
469                                 NULL);
470                 if (*server_monitor_id == 0) {
471                         g_dbus_connection_signal_unsubscribe(*gdbus_connection, *monitor_id);
472                         *monitor_id = 0;
473                         LOGE("Failed to get identifier");
474                         return GESTURE_ENGINE_ERROR_IO_ERROR;
475                 }
476         }
477
478         return GESTURE_ENGINE_ERROR_NONE;
479 }
480
481 int gesture_engine_dbus_shutdown(GDBusConnection *gdbus_connection, int *server_monitor_id, int *monitor_id)
482 {
483         if (*server_monitor_id) {
484                 g_bus_unwatch_name(*server_monitor_id);
485                 *server_monitor_id = 0;
486         }
487
488         if (*monitor_id) {
489                 g_dbus_connection_signal_unsubscribe(gdbus_connection, *monitor_id);
490                 *monitor_id = 0;
491         }
492
493         return GESTURE_ENGINE_ERROR_NONE;
494 }
495 #if 0
496 static void proxy_new_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
497 {
498         LOGD("proxy_new_cb clled");
499
500         GDBusProxy **ret = user_data;
501         GError *error = NULL;
502         *ret = g_dbus_proxy_new_finish (res, &error);
503 }
504 #endif
505
506 int gesture_engine_dbus_main_start(GDBusConnection *gdbus_connection, gesture_engine_request_callback_s *callback)
507 {
508         LOGD("gesture_engine_dbus_main_start start");
509         LOGD("engine busname: %s", g_dbus_connection_get_unique_name(gdbus_connection));
510         mgdbus_connection = gdbus_connection;
511
512         int ret = GESTURE_ENGINE_ERROR_NONE;
513
514         // store engine callback sturct;
515         g_basic_engine_callback = *callback;
516
517         GVariant *body = NULL;
518         body = g_variant_new("(i)", 100);
519
520         ret = gdbus_send_message_with_async(gdbus_connection, body, GESTURE_ENGINE_MSG_MAIN_START);
521
522         if (body)
523                 g_variant_unref(body);
524
525         return ret;
526 }
527
528 int gesture_engine_dbus_send_result(GDBusConnection *gdbus_connection, gesture_engine_result_event_e event, hand_gesture_type_e gesture_type, hand_gesture_data_h result, void* time_info, void* user_data)
529 {
530         LOGD("gesture_engine_dbus_send_result start");
531         if (gesture_type) LOGD("gesture_type = %d", gesture_type);
532
533         int ret = GESTURE_ENGINE_ERROR_NONE;
534
535         GDBusMessage *reply = NULL;
536         GVariant *body = NULL;
537
538         if(!result) {
539                 LOGD("The returned hand_gesture_data_h is NULL");
540                 return GESTURE_ENGINE_ERROR_OPERATION_FAILED;
541         }
542
543         body = g_variant_new("(iiiii)", event, gesture_type, result->gesture_type, result->event, result->detected_Count);
544         ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_ENGINE_MSG_SEND_RESULT);
545         if (ret != GESTURE_ENGINE_ERROR_NONE) {
546                 LOGD("Fail to send result data to daemon");
547         }
548 #if 0
549         gchar *msg = g_dbus_message_print (reply, 1);
550         LOGD("Reply msg print : %s", msg);
551         g_free(msg);
552 #endif
553
554         if (body)
555                 g_variant_unref(body);
556
557         if (reply)
558                 g_object_unref(reply);
559
560         return ret;
561 }
562
563 int gesture_engine_dbus_send_error(GDBusConnection *gdbus_connection,  gesture_engine_error_e error, const char* msg)
564 {
565         LOGE("gesture_engine_dbus_send_error start");
566
567         int ret = GESTURE_ENGINE_ERROR_NONE;
568
569         GDBusMessage *reply = NULL;
570         GVariant *body = NULL;
571
572         body = g_variant_new("(is)", error, msg);
573
574         ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_ENGINE_MSG_SEND_ERROR);
575
576         if (ret == GESTURE_ENGINE_ERROR_NONE) {
577                 gchar *msg = g_dbus_message_print (reply, 1);
578                 LOGD("Reply msg print : %s", msg);
579                 g_free(msg);
580         }
581
582         if (body)
583                 g_variant_unref(body);
584
585         if (reply)
586                 g_object_unref(reply);
587
588         return ret;
589 }
590
591 int gesture_engine_dbus_send_motion_status(GDBusConnection *gdbus_connection, gesture_engine_motion_status_e status, void* user_data)
592 {
593         LOGE("gesture_engine_dbus_send_motion_status start");
594
595         int ret = GESTURE_ENGINE_ERROR_NONE;
596
597         GDBusMessage *reply = NULL;
598         GVariant *body = NULL;
599
600         body = g_variant_new("(i)", status);
601
602         ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_ENGINE_MSG_SEND_MOTION_STATUS);
603
604         if (ret == GESTURE_ENGINE_ERROR_NONE) {
605                 gchar *msg = g_dbus_message_print (reply, 1);
606                 LOGD("Reply msg print : %s", msg);
607                 g_free(msg);
608         }
609
610         if (body)
611                 g_variant_unref(body);
612
613         if (reply)
614                 g_object_unref(reply);
615
616         return ret;
617 }
618
619 int gesture_engine_dbus_send_engine_get_info(GDBusConnection *gdbus_connection, char* engine_app_id, char* engine_name)
620 {
621         LOGD("gesture_engine_send_engine_get_info start");
622         if (engine_app_id) LOGD("engine_app_id = %s", engine_app_id);
623
624         int ret = GESTURE_ENGINE_ERROR_NONE;
625
626         GDBusMessage *reply = NULL;
627         GVariant *body = NULL;
628
629         body = g_variant_new("(ss)", engine_app_id, engine_name);
630         ret = gdbus_send_message_with_sync(mgdbus_connection, body, &reply, GESTURE_ENGINE_MSG_GET_ENGINE_INFO);
631         if (ret != GESTURE_ENGINE_ERROR_NONE) {
632                 LOGE("Fail to send result data to daemon");
633         }
634 #if 0
635         gchar *msg = g_dbus_message_print (reply, 1);
636         LOGD("Reply msg print : %s", msg);
637         g_free(msg);
638 #endif
639
640         if (body)
641                 g_variant_unref(body);
642
643         if (reply)
644                 g_object_unref(reply);
645
646         return ret;
647 }
648