Change audio recording procedure
[platform/core/uifw/voice-control.git] / server / vcd_engine_agent.c
1 /*
2 * Copyright (c) 2011-2015 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
18 #include <dlfcn.h>
19 #include <dirent.h>
20
21 #include "vcd_client_data.h"
22 #include "vcd_config.h"
23 #include "vcd_engine_agent.h"
24 #include "vcd_main.h"
25 #include "vcd_recorder.h"
26 #include "vcd_dbus.h"
27
28 /*
29 * Internal data structure
30 */
31 typedef struct {
32         /* engine info */
33         char*   engine_uuid;
34         char*   engine_name;
35         char*   engine_path;
36
37         /* engine load info */
38         bool    is_set;
39         bool    is_loaded;
40         bool    is_command_ready;
41         void    *handle;
42
43         vcpe_funcs_s*   pefuncs;
44         vcpd_funcs_s*   pdfuncs;
45
46         int (*vcp_load_engine)(vcpd_funcs_s* pdfuncs, vcpe_funcs_s* pefuncs);
47         int (*vcp_unload_engine)();
48 } vcengine_s;
49
50 typedef struct _vcengine_info {
51         char*   engine_uuid;
52         char*   engine_path;
53         char*   engine_name;
54 } vcengine_info_s;
55
56
57 /*
58 * static data
59 */
60
61 /** vc engine agent init */
62 static bool g_agent_init;
63
64 /** vc engine list */
65 static GList *g_engine_list;
66
67 /** current engine information */
68 static vcengine_s g_dynamic_engine;
69
70 static char* g_default_lang;
71
72 /** callback functions */
73 static result_callback g_result_cb = NULL;
74
75 static asr_result_callback g_asr_result_cb = NULL;
76 static nlg_result_callback g_nlg_result_cb = NULL;
77
78 #if 0
79 static pre_result_callback g_pre_result_cb = NULL;
80
81 static nlu_result_callback g_nlu_result_cb = NULL;
82 #endif
83
84 static error_callback g_error_cb = NULL;
85
86 bool __supported_language_cb(const char* language, void* user_data);
87
88 void __engine_info_cb(const char* engine_uuid, const char* engine_name, const char* engine_setting, bool use_network, void* user_data);
89
90 bool __engine_setting_cb(const char* key, const char* value, void* user_data);
91
92 /** Free voice list */
93 void __free_language_list(GList* lang_list);
94
95
96 /*
97 * Internal Interfaces
98 */
99
100 /** check engine id */
101 int __internal_check_engine_id(const char* engine_uuid);
102
103 /** update engine list */
104 int __internal_update_engine_list();
105
106 /** get engine info */
107 int __internal_get_engine_info(const char* filepath, vcengine_info_s** info);
108
109 int __log_enginelist();
110
111 /*
112 * VCS Engine Agent Interfaces
113 */
114 //int vcd_engine_agent_init(pre_result_callback pre_result_cb, result_callback result_cb, nlu_result_callback nlu_result_cb, error_callback error_cb)
115 int vcd_engine_agent_init(asr_result_callback asr_result_cb, result_callback result_cb, nlg_result_callback nlg_result_cb, error_callback error_cb)
116 {
117         if (/*NULL == pre_result_cb*/ NULL == asr_result_cb || NULL == result_cb /*|| NULL == nlu_result_cb*/ || NULL == error_cb) {
118                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Input parameter is NULL");
119                 return VCD_ERROR_OPERATION_FAILED;
120         }
121
122         /* init dynamic engine */
123         g_dynamic_engine.engine_uuid = NULL;
124         g_dynamic_engine.engine_name = NULL;
125         g_dynamic_engine.engine_path = NULL;
126
127         g_dynamic_engine.is_set = false;
128         g_dynamic_engine.is_loaded = false;
129         g_dynamic_engine.handle = NULL;
130         g_dynamic_engine.is_command_ready = false;
131         g_dynamic_engine.pefuncs = (vcpe_funcs_s*)calloc(1, sizeof(vcpe_funcs_s));
132         g_dynamic_engine.pdfuncs = (vcpd_funcs_s*)calloc(1, sizeof(vcpd_funcs_s));
133
134         g_agent_init = true;
135
136         //g_pre_result_cb = pre_result_cb;
137         g_asr_result_cb = asr_result_cb;
138         g_nlg_result_cb = nlg_result_cb;
139         g_result_cb = result_cb;
140         //g_nlu_result_cb = nlu_result_cb;
141         g_error_cb = error_cb;
142
143         if (0 != vcd_config_get_default_language(&g_default_lang)) {
144                 SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] There is No default voice in config");
145                 /* Set default voice */
146                 g_default_lang = strdup(VC_BASE_LANGUAGE);
147         }
148
149         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent SUCCESS] Engine Agent Initialize");
150
151         return 0;
152 }
153
154 int vcd_engine_agent_release()
155 {
156         if (false == g_agent_init) {
157                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
158                 return VCD_ERROR_OPERATION_FAILED;
159         }
160
161         /* unload current engine */
162         vcd_engine_agent_unload_current_engine();
163
164         /* release engine list */
165         GList *iter = NULL;
166         vcengine_s *data = NULL;
167
168         if (g_list_length(g_engine_list) > 0) {
169                 /* Get a first item */
170                 iter = g_list_first(g_engine_list);
171
172                 while (NULL != iter) {
173                         /* Get handle data from list */
174                         data = iter->data;
175                         iter = g_list_remove(iter, data);
176
177                         if (NULL != data) {
178                                 if (NULL != data->engine_uuid) {
179                                         g_free(data->engine_uuid);
180                                         data->engine_uuid = NULL;
181                                 }
182                                 if (NULL != data->engine_name) {
183                                         g_free(data->engine_name);
184                                         data->engine_name = NULL;
185                                 }
186                                 if (NULL != data->engine_path) {
187                                         g_free(data->engine_path);
188                                         data->engine_path = NULL;
189                                 }
190
191                                 free(data);
192                                 data = NULL;
193                         }
194                 }
195         }
196
197         g_list_free(iter);
198         g_engine_list = NULL;
199
200         /* release current engine data */
201         if (NULL != g_dynamic_engine.pefuncs) {
202                 free(g_dynamic_engine.pefuncs);
203                 g_dynamic_engine.pefuncs = NULL;
204         }
205         if (NULL != g_dynamic_engine.pdfuncs) {
206                 free(g_dynamic_engine.pdfuncs);
207                 g_dynamic_engine.pdfuncs = NULL;
208         }
209
210         g_agent_init = false;
211
212         //g_pre_result_cb = NULL;
213         g_asr_result_cb = NULL;
214         g_nlg_result_cb = NULL;
215         g_result_cb = NULL;
216         //g_nlu_result_cb = NULL;
217         g_error_cb = NULL;
218
219         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent SUCCESS] Engine Agent release");
220
221         return 0;
222 }
223
224 bool vcd_engine_is_available_engine()
225 {
226         if (true == g_dynamic_engine.is_loaded)
227                 return true;
228
229         return false;
230 }
231
232 int vcd_engine_agent_initialize_current_engine()
233 {
234         /* check agent init */
235         if (false == g_agent_init) {
236                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
237                 return VCD_ERROR_OPERATION_FAILED;
238         }
239
240         /* update engine list */
241         if (0 != __internal_update_engine_list()) {
242                 SLOG(LOG_ERROR, TAG_VCD, "[engine agent] vcd_engine_agent_init : __internal_update_engine_list : no engine error");
243                 return VCD_ERROR_ENGINE_NOT_FOUND;
244         }
245
246         /* check whether engine id is valid or not.*/
247         GList *iter = NULL;
248         vcengine_info_s *dynamic_engine = NULL;
249
250         if (g_list_length(g_engine_list) > 0) {
251                 /*Get a first item*/
252                 iter = g_list_first(g_engine_list);
253
254                 while (NULL != iter) {
255                         /*Get handle data from list*/
256                         dynamic_engine = iter->data;
257                         if (NULL != dynamic_engine) {
258                                 break;
259                         }
260
261                         /*Get next item*/
262                         iter = g_list_next(iter);
263                 }
264         } else {
265                 return VCD_ERROR_ENGINE_NOT_FOUND;
266         }
267
268         if (NULL == dynamic_engine) {
269                 return VCD_ERROR_ENGINE_NOT_FOUND;
270         } else {
271                 if (NULL != g_dynamic_engine.engine_uuid) {
272                         /* set data from g_engine_list */
273                         if (g_dynamic_engine.engine_uuid != NULL)       g_free(g_dynamic_engine.engine_uuid);
274                         if (g_dynamic_engine.engine_name != NULL)       g_free(g_dynamic_engine.engine_name);
275                         if (g_dynamic_engine.engine_path != NULL)       g_free(g_dynamic_engine.engine_path);
276                 }
277
278                 g_dynamic_engine.engine_uuid = g_strdup(dynamic_engine->engine_uuid);
279                 g_dynamic_engine.engine_name = g_strdup(dynamic_engine->engine_name);
280                 g_dynamic_engine.engine_path = g_strdup(dynamic_engine->engine_path);
281
282                 g_dynamic_engine.handle = NULL;
283                 g_dynamic_engine.is_loaded = false;
284                 g_dynamic_engine.is_set = true;
285
286                 SLOG(LOG_DEBUG, TAG_VCD, "-----");
287                 SLOG(LOG_DEBUG, TAG_VCD, " Dynamic engine uuid : %s", g_dynamic_engine.engine_uuid);
288                 SLOG(LOG_DEBUG, TAG_VCD, " Dynamic engine name : %s", g_dynamic_engine.engine_name);
289                 SLOG(LOG_DEBUG, TAG_VCD, " Dynamic engine path : %s", g_dynamic_engine.engine_path);
290                 SLOG(LOG_DEBUG, TAG_VCD, "-----");
291
292         }
293
294         return 0;
295 }
296
297 int __internal_check_engine_id(const char* engine_uuid)
298 {
299         if (NULL == engine_uuid) {
300                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid Parameter");
301                 return VCD_ERROR_INVALID_PARAMETER;
302         }
303
304         GList *iter = NULL;
305         vcengine_s *data = NULL;
306
307         if (0 < g_list_length(g_engine_list)) {
308                 /*Get a first item*/
309                 iter = g_list_first(g_engine_list);
310
311                 while (NULL != iter) {
312                         data = iter->data;
313
314                         if (0 == strncmp(engine_uuid, data->engine_uuid, strlen(data->engine_uuid))) {
315                                 return 0;
316                         }
317
318                         iter = g_list_next(iter);
319                 }
320         }
321
322         return -1;
323 }
324
325 void __engine_info_cb(const char* engine_uuid, const char* engine_name, const char* engine_setting, bool use_network, void* user_data)
326 {
327         vcengine_info_s* temp = (vcengine_info_s*)user_data;
328
329         temp->engine_uuid = g_strdup(engine_uuid);
330         temp->engine_name = g_strdup(engine_name);
331 }
332
333
334 int __internal_get_engine_info(const char* filepath, vcengine_info_s** info)
335 {
336         if (NULL == filepath || NULL == info) {
337                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid Parameter");
338                 return VCD_ERROR_INVALID_PARAMETER;
339         }
340
341         /* load engine */
342         char *error;
343         void* handle;
344
345         handle = dlopen(filepath, RTLD_LAZY);
346         if (!handle) {
347                 SLOG(LOG_WARN, TAG_VCD, "[Engine Agent] Invalid engine : %s", filepath);
348                 if ((error = dlerror()) != NULL) {
349                         SLOG(LOG_ERROR, TAG_VCD, "[ERROR] %s", error);
350                 }
351                 return -1;
352         }
353
354         /* link engine to daemon */
355         dlsym(handle, "vcp_load_engine");
356         if ((error = dlerror()) != NULL) {
357                 SLOG(LOG_WARN, TAG_VCD, "[Engine Agent] Invalid engine. Fail to open vcp_load_engine : %s", filepath);
358                 dlclose(handle);
359                 return -1;
360         }
361
362         dlsym(handle, "vcp_unload_engine");
363         if ((error = dlerror()) != NULL) {
364                 SLOG(LOG_WARN, TAG_VCD, "[Engine Agent] Invalid engine. Fail to open vcp_unload_engine : %s", filepath);
365                 dlclose(handle);
366                 return -1;
367         }
368
369         int (*get_engine_info)(vcpe_engine_info_cb callback, void* user_data);
370
371         get_engine_info = (int (*)(vcpe_engine_info_cb, void*))dlsym(handle, "vcp_get_engine_info");
372         if (NULL != (error = dlerror()) || NULL == get_engine_info) {
373                 SLOG(LOG_WARN, TAG_VCD, "[Engine Agent WARNING] Invalid engine. Fail to open vcp_get_engine_info : %s", filepath);
374                 dlclose(handle);
375                 return -1;
376         }
377
378         vcengine_info_s* temp;
379         temp = (vcengine_info_s*)calloc(1, sizeof(vcengine_info_s));
380         if (NULL == temp) {
381                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory");
382                 dlclose(handle);
383                 return VCD_ERROR_OUT_OF_MEMORY;
384         }
385
386         /* get engine info */
387         if (0 != get_engine_info(__engine_info_cb, (void*)temp)) {
388                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to get engine info from engine");
389                 dlclose(handle);
390                 free(temp);
391                 return -1;
392         }
393
394         /* close engine */
395         dlclose(handle);
396
397         temp->engine_path = g_strdup(filepath);
398
399         SLOG(LOG_DEBUG, TAG_VCD, "----- Valid Engine");
400         SLOG(LOG_DEBUG, TAG_VCD, "Engine uuid : %s", temp->engine_uuid);
401         SLOG(LOG_DEBUG, TAG_VCD, "Engine name : %s", temp->engine_name);
402         SLOG(LOG_DEBUG, TAG_VCD, "Engine path : %s", temp->engine_path);
403         SLOG(LOG_DEBUG, TAG_VCD, "-----");
404         SLOG(LOG_DEBUG, TAG_VCD, "  ");
405
406         *info = temp;
407
408         return 0;
409 }
410
411 int __internal_update_engine_list()
412 {
413         /* relsease engine list */
414         GList *iter = NULL;
415         vcengine_info_s *data = NULL;
416
417         if (0 < g_list_length(g_engine_list)) {
418                 /* Get a first item */
419                 iter = g_list_first(g_engine_list);
420
421                 while (NULL != iter) {
422                         /* Get handle data from list */
423                         data = iter->data;
424
425                         if (NULL != data) {
426                                 if (NULL != data->engine_uuid)          g_free(data->engine_uuid);
427                                 if (NULL != data->engine_path)          g_free(data->engine_path);
428                                 if (NULL != data->engine_name)          g_free(data->engine_name);
429
430                                 data->engine_uuid = NULL;
431                                 data->engine_path = NULL;
432                                 data->engine_name = NULL;
433
434                                 free(data);
435                         }
436
437                         g_engine_list = g_list_remove_link(g_engine_list, iter);
438                         iter = g_list_first(g_engine_list);
439                 }
440         }
441
442         /* Get file name from default engine directory */
443         DIR *dp = NULL;
444         struct dirent *dirp = NULL;
445
446         dp  = opendir(VC_DEFAULT_ENGINE);
447         if (NULL != dp) {
448                 do {
449                         dirp = readdir(dp);
450
451                         if (NULL != dirp) {
452                                 if (!strcmp(".", dirp->d_name) || !strcmp("..", dirp->d_name))
453                                         continue;
454
455                                 vcengine_info_s* info = NULL;
456                                 char* filepath = NULL;
457                                 int filesize = 0;
458
459                                 filesize = strlen(VC_DEFAULT_ENGINE) + strlen(dirp->d_name) + 5;
460                                 filepath = (char*)calloc(filesize, sizeof(char));
461
462                                 if (NULL != filepath) {
463                                         snprintf(filepath, filesize, "%s/%s", VC_DEFAULT_ENGINE, dirp->d_name);
464                                 } else {
465                                         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Memory not enough!!");
466                                         continue;
467                                 }
468
469                                 /* get its info and update engine list */
470                                 if (0 == __internal_get_engine_info(filepath, &info)) {
471                                         /* add engine info to g_engine_list */
472                                         g_engine_list = g_list_append(g_engine_list, info);
473                                 }
474
475                                 if (NULL != filepath) {
476                                         free(filepath);
477                                         filepath = NULL;
478                                 }
479                         }
480                 } while (NULL != dirp);
481
482                 closedir(dp);
483         } else {
484                 SLOG(LOG_WARN, TAG_VCD, "[Engine Agent WARNING] Fail to open default directory");
485         }
486
487         if (0 >= g_list_length(g_engine_list)) {
488                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] No Engine");
489                 return VCD_ERROR_ENGINE_NOT_FOUND;
490         }
491
492         __log_enginelist();
493
494         return 0;
495 }
496
497
498 int __foreach_command(vcp_cmd_h vc_command, vcpd_foreach_command_cb callback, void* user_data)
499 {
500         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request foreach command from engine");
501         return vcd_client_foreach_command((client_foreach_command_cb)callback, user_data);
502 }
503
504 int __command_get_length(vcp_cmd_h vc_command)
505 {
506         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request command length from engine");
507         return vcd_client_get_length();
508 }
509
510 int __get_audio_type(char** audio_type)
511 {
512         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request audio type");
513
514         return vcd_recorder_get(audio_type);
515 }
516
517 int __set_private_data(const char* key, const char* data)
518 {
519         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request set private data");
520         vcdc_send_request_set_private_data(vcd_client_manager_get_pid(), key, data);
521
522         return 0;
523 }
524
525 int __get_private_data(const char* key, char** data)
526 {
527         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request get private data");
528         vcdc_send_request_get_private_data(vcd_client_manager_get_pid(), key, data);
529
530         return 0;
531 }
532
533 int __start_recording()
534 {
535         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request start recording");
536
537         int ret = vcd_recorder_start();
538         if (0 != ret) {
539                 SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recorder : result(%d)", ret);
540                 vcd_engine_recognize_cancel();
541                 /* Send error cb to manager */
542                 vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_engine.error.proc_fail");
543                 return ret;
544         }
545
546         return 0;
547 }
548
549 int __stop_recording()
550 {
551         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request stop recording");
552
553         return vcd_recorder_stop();
554 }
555
556 void __result_cb(vcp_result_event_e event, int* result_id, int count, const char* all_result, const char* non_fixed, const char* nlu_result, const char* msg, void *user_data)
557 {
558         SLOG(LOG_DEBUG, TAG_VCD, "[Engine agent] Event(%d), Count(%d) Text(%s) Nonfixed(%s) NLU result(%s) Msg(%s)", event, count, all_result, non_fixed, nlu_result, msg);
559
560         if (NULL != g_result_cb) {
561                 g_result_cb(event, result_id, count, all_result, non_fixed, nlu_result, msg, user_data);
562         } else {
563                 SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent ERROR] Result callback function is NOT valid");
564         }
565
566         return;
567 }
568
569 void __asr_result_cb(vcp_asr_result_event_e event, const char* asr_result, void *user_data)
570 {
571         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] ASR result -  Event(%d), Result(%s)", event, asr_result);
572
573         if (NULL != g_asr_result_cb) {
574                 g_asr_result_cb(event, asr_result, user_data);
575         } else {
576                 SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent ERROR] ASR result callback function is NOT valid");
577         }
578
579         return;
580 }
581
582 void __nlg_result_cb(const char* nlg_result, void *user_data)
583 {
584         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] NLG result -  Result(%s)", nlg_result);
585
586         if (NULL != g_nlg_result_cb) {
587                 g_nlg_result_cb(nlg_result, user_data);
588         } else {
589                 SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent ERROR] NLG result callback function is NOT valid");
590         }
591
592         return;
593 }
594
595 void __error_cb(vcp_error_e error, const char* msg, void *user_data)
596 {
597         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent] ERROR(%d)", error);
598
599         if (NULL != g_error_cb) {
600                 g_error_cb(error, msg, user_data);
601         } else {
602                 SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent ERROR] Error callback function is NOT vaild");
603         }
604
605         return;
606 }
607
608 int __load_engine(vcengine_s* engine)
609 {
610         /* check whether current engine is loaded or not */
611         if (true == engine->is_loaded) {
612                 SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Engine has already been loaded ");
613                 return 0;
614         }
615
616         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Current engine path : %s", engine->engine_path);
617
618         /* open engine */
619         char *error;
620         engine->handle = dlopen(engine->engine_path, RTLD_LAZY);
621
622         if ((error = dlerror()) != NULL || !engine->handle) {
623                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to get engine handle");
624                 return VCD_ERROR_OPERATION_FAILED;
625         }
626
627         engine->vcp_unload_engine = (int (*)())dlsym(engine->handle, "vcp_unload_engine");
628         if ((error = dlerror()) != NULL) {
629                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to link daemon to vcp_unload_engine()");
630                 dlclose(engine->handle);
631                 return VCD_ERROR_OPERATION_FAILED;
632         }
633
634         engine->vcp_load_engine = (int (*)(vcpd_funcs_s*, vcpe_funcs_s*))dlsym(engine->handle, "vcp_load_engine");
635         if (NULL != (error = dlerror()) || NULL == engine->vcp_load_engine) {
636                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to link daemon to vcp_load_engine()");
637                 dlclose(engine->handle);
638                 return VCD_ERROR_OPERATION_FAILED;
639         }
640
641         /* load engine */
642         engine->pdfuncs->version = 1;
643         engine->pdfuncs->size = sizeof(vcpd_funcs_s);
644
645         engine->pdfuncs->foreach_command = __foreach_command;
646         engine->pdfuncs->get_command_count = __command_get_length;
647         engine->pdfuncs->get_audio_type = __get_audio_type;
648
649         engine->pdfuncs->set_private_data = __set_private_data;
650         engine->pdfuncs->get_private_data = __get_private_data;
651
652         engine->pdfuncs->start_recording = __start_recording;
653         engine->pdfuncs->stop_recording = __stop_recording;
654
655         if (0 != engine->vcp_load_engine(engine->pdfuncs, engine->pefuncs)) {
656                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail vcp_load_engine()");
657                 dlclose(engine->handle);
658                 return VCD_ERROR_OPERATION_FAILED;
659         }
660
661         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] engine info : version(%d), size(%d)(%d)", engine->pefuncs->version, engine->pefuncs->size, sizeof(vcpe_funcs_s));
662
663         /* engine error check */
664         if (engine->pefuncs->size != sizeof(vcpe_funcs_s)) {
665                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Engine is not valid");
666                 return VCD_ERROR_OPERATION_FAILED;
667         }
668
669         /* Check all engine functions */
670         if (NULL == engine->pefuncs->initialize ||
671                 NULL == engine->pefuncs->deinitialize ||
672                 NULL == engine->pefuncs->get_recording_format ||
673                 NULL == engine->pefuncs->foreach_langs ||
674                 NULL == engine->pefuncs->is_lang_supported ||
675                 NULL == engine->pefuncs->set_result_cb ||
676                 NULL == engine->pefuncs->set_language ||
677                 NULL == engine->pefuncs->set_commands ||
678                 NULL == engine->pefuncs->unset_commands ||
679                 NULL == engine->pefuncs->start ||
680                 NULL == engine->pefuncs->set_recording ||
681                 NULL == engine->pefuncs->stop ||
682                 NULL == engine->pefuncs->cancel ||
683                 NULL == engine->pefuncs->set_audio_type ||
684                 NULL == engine->pefuncs->set_asr_result_cb ||
685                 NULL == engine->pefuncs->set_nlg_result_cb ||
686                 //NULL == engine->pefuncs->set_pre_result_cb ||
687                 NULL == engine->pefuncs->set_error_cb ||
688                 NULL == engine->pefuncs->set_domain ||
689                 NULL == engine->pefuncs->get_nlu_base_info ||
690                 //NULL == engine->pefuncs->set_nlu_result_cb ||
691                 NULL == engine->pefuncs->set_private_data ||
692                 NULL == engine->pefuncs->get_private_data ||
693                 NULL == engine->pefuncs->process_text ||
694                 NULL == engine->pefuncs->process_list_event ||
695                 NULL == engine->pefuncs->process_haptic_event) {
696                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] The current engine is NOT valid");
697                 return VCD_ERROR_OPERATION_FAILED;
698         }
699
700         /* initalize engine */
701         if (0 != engine->pefuncs->initialize()) {
702                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to initialize vc-engine");
703                 return VCD_ERROR_OPERATION_FAILED;
704         }
705
706         if (0 != engine->pefuncs->set_result_cb(__result_cb, NULL)) {
707                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set result callback of vc-engine");
708                 return VCD_ERROR_OPERATION_FAILED;
709         }
710
711         if (0 != engine->pefuncs->set_asr_result_cb(__asr_result_cb, NULL)) {
712                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set asr result callback of vc-engine");
713                 return VCD_ERROR_OPERATION_FAILED;
714         }
715
716         if (0 != engine->pefuncs->set_nlg_result_cb(__nlg_result_cb, NULL)) {
717                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set nlg result callback of vc-engine");
718                 return VCD_ERROR_OPERATION_FAILED;
719         }
720
721         if (0 != engine->pefuncs->set_error_cb(__error_cb, NULL)) {
722                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set error callback of vc-engine");
723                 return VCD_ERROR_OPERATION_FAILED;
724         }
725
726         /* load engine */
727         if (true == engine->pefuncs->is_lang_supported(g_default_lang)) {
728                 if (0 != engine->pefuncs->set_language(g_default_lang)) {
729                         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to load current engine");
730                         return VCD_ERROR_OPERATION_FAILED;
731                 }
732                 SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent SUCCESS] The %s has been loaded !!!", engine->engine_name);
733                 engine->is_loaded = true;
734         } else {
735                 SLOG(LOG_WARN, TAG_VCD, "[Engine Agent WARNING] This engine do not support default language : lang(%s)", g_default_lang);
736                 engine->is_loaded = false;
737         }
738
739         return 0;
740 }
741
742 int vcd_engine_agent_load_current_engine()
743 {
744         if (false == g_agent_init) {
745                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
746                 return VCD_ERROR_OPERATION_FAILED;
747         }
748
749         if (true == g_dynamic_engine.is_set) {
750                 if (0 != __load_engine(&g_dynamic_engine)) {
751                         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to load dynamic engine");
752
753                         /* need to initialize dynamic engine data */
754                         g_dynamic_engine.is_loaded = false;
755                 } else {
756                         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent SUCCESS] Load dynamic engine");
757                 }
758         }
759
760         return 0;
761 }
762
763 int vcd_engine_agent_unload_current_engine()
764 {
765         if (false == g_agent_init) {
766                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized ");
767                 return VCD_ERROR_OPERATION_FAILED;
768         }
769
770         if (true == g_dynamic_engine.is_set) {
771                 /* unload dynamic engine */
772                 if (true == g_dynamic_engine.is_loaded) {
773                         /* shutdown engine */
774                         g_dynamic_engine.pefuncs->deinitialize();
775                         g_dynamic_engine.vcp_unload_engine();
776                         dlclose(g_dynamic_engine.handle);
777                         g_dynamic_engine.handle = NULL;
778                         g_dynamic_engine.is_loaded = false;
779                 }
780         }
781         return 0;
782 }
783
784
785 /*
786 * VCS Engine Interfaces for client
787 */
788
789 int vcd_engine_set_commands()
790 {
791         if (false == g_agent_init) {
792                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
793                 return VCD_ERROR_OPERATION_FAILED;
794         }
795
796         int ret = -1;
797
798         if (true == g_dynamic_engine.is_loaded) {
799                 /* Set dynamic command */
800                 ret = g_dynamic_engine.pefuncs->set_commands((vcp_cmd_h)0);
801                 if (0 != ret) {
802                         SLOG(LOG_WARN, TAG_VCD, "[Engine Agent ERROR] Fail to set command of dynamic engine : error(%d)", ret);
803                         g_dynamic_engine.is_command_ready = false;
804                 } else {
805                         g_dynamic_engine.is_command_ready = true;
806                 }
807
808                 SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent SUCCESS] set command");
809         } else {
810                 SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Dynamic engine is not available");
811         }
812
813         return 0;
814 }
815
816 int vcd_engine_recognize_start(bool silence)
817 {
818         if (false == g_agent_init) {
819                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
820                 return VCD_ERROR_OPERATION_FAILED;
821         }
822
823         int ret = -1;
824         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] silence is %s", silence ? "true" : "false");
825
826         if (true == g_dynamic_engine.is_loaded && true == g_dynamic_engine.is_command_ready) {
827                 ret = g_dynamic_engine.pefuncs->start(silence);
828                 if (0 != ret) {
829                         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent] Fail to start engine error(%d)", ret);
830                         return VCD_ERROR_OPERATION_FAILED;
831                 }
832         } else {
833                 SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Engine is not available (Cannot start)");
834                 return VCD_ERROR_OPERATION_FAILED;
835         }
836
837         SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent SUCCESS] Engine start");
838         return 0;
839 }
840
841 int vcd_engine_recognize_audio(const void* data, unsigned int length, vcp_speech_detect_e* speech_detected)
842 {
843         if (false == g_agent_init) {
844                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
845                 return VCD_ERROR_OPERATION_FAILED;
846         }
847
848         if (NULL == data) {
849                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid Parameter");
850                 return VCD_ERROR_INVALID_PARAMETER;
851         }
852
853         int ret = -1;
854
855         if (true == g_dynamic_engine.is_loaded) {
856                 ret = g_dynamic_engine.pefuncs->set_recording(data, length, speech_detected);
857                 if (0 != ret) {
858                         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set recording dynamic engine error(%d)", ret);
859                         if (VCP_ERROR_OUT_OF_NETWORK == ret) {
860                                 return VCD_ERROR_TIMED_OUT;
861                         }
862                         return VCD_ERROR_OPERATION_FAILED;
863                 }
864         }
865
866         return 0;
867 }
868
869 int vcd_engine_recognize_stop()
870 {
871         if (false == g_agent_init) {
872                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
873                 return VCD_ERROR_OPERATION_FAILED;
874         }
875
876         if (true == g_dynamic_engine.is_loaded) {
877                 int ret = -1;
878                 ret = g_dynamic_engine.pefuncs->stop();
879                 if (0 != ret) {
880                         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to stop dynamic engine error(%d)", ret);
881                         return VCD_ERROR_OPERATION_FAILED;
882                 }
883         } else {
884                 SLOG(LOG_WARN, TAG_VCD, "[Engine Agent] Dynamic engine is not recording state");
885                 return VCD_ERROR_OPERATION_FAILED;
886         }
887
888         return 0;
889 }
890
891 int vcd_engine_recognize_cancel()
892 {
893         if (false == g_agent_init) {
894                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
895                 return VCD_ERROR_OPERATION_FAILED;
896         }
897
898         int ret = -1;
899         if (true == g_dynamic_engine.is_loaded) {
900                 ret = g_dynamic_engine.pefuncs->cancel();
901                 if (0 != ret) {
902                         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to cancel dynamic engine error(%d)", ret);
903                         return VCD_ERROR_OPERATION_FAILED;
904                 }
905         }
906
907         return 0;
908 }
909
910 int vcd_engine_set_audio_type(const char* audio)
911 {
912         if (false == g_agent_init) {
913                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
914                 return VCD_ERROR_OPERATION_FAILED;
915         }
916
917         int ret = -1;
918         if (true == g_dynamic_engine.is_loaded) {
919                 ret = g_dynamic_engine.pefuncs->set_audio_type(audio);
920                 if (0 != ret) {
921                         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set audio type(%d)", ret);
922                         return VCD_ERROR_OPERATION_FAILED;
923                 }
924         }
925
926         return 0;
927 }
928
929 int vcd_engine_set_domain(int pid, const char* domain)
930 {
931         if (false == g_agent_init) {
932                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
933                 return VCD_ERROR_OPERATION_FAILED;
934         }
935
936         int ret = -1;
937         if (true == g_dynamic_engine.is_loaded) {
938                 ret = g_dynamic_engine.pefuncs->set_domain(domain);
939                 if (0 != ret) {
940                         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set domain (%d)", ret);
941                         return VCD_ERROR_OPERATION_FAILED;
942                 }
943         }
944
945         return 0;
946 }
947
948 int vcd_engine_get_nlu_base_info(int pid, const char* key, char** value)
949 {
950         if (NULL == value) {
951                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid Parameter");
952                 return VCD_ERROR_INVALID_PARAMETER;
953         }
954
955         if (false == g_agent_init) {
956                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
957                 return VCD_ERROR_OPERATION_FAILED;
958         }
959
960         int ret = -1;
961         if (true == g_dynamic_engine.is_loaded) {
962                 ret = g_dynamic_engine.pefuncs->get_nlu_base_info(key, value);
963                 if (0 != ret) {
964                         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to get nlu base info (%d)", ret);
965                         return VCD_ERROR_OPERATION_FAILED;
966                 }
967         }
968
969         return 0;
970 }
971
972 int vcd_engine_set_private_data(int pid, const char* key, const char* data)
973 {
974         if (false == g_agent_init) {
975                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
976                 return VCD_ERROR_OPERATION_FAILED;
977         }
978
979         int ret = -1;
980         if (true == g_dynamic_engine.is_loaded) {
981                 ret = g_dynamic_engine.pefuncs->set_private_data(key, data);
982                 if (0 != ret) {
983                         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set private data (%d)", ret);
984                         return VCD_ERROR_OPERATION_FAILED;
985                 }
986         }
987
988         return 0;
989 }
990
991 int vcd_engine_get_private_data(int pid, const char* key, char** data)
992 {
993         if (NULL == data) {
994                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid Parameter");
995                 return VCD_ERROR_INVALID_PARAMETER;
996         }
997
998         if (false == g_agent_init) {
999                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
1000                 return VCD_ERROR_OPERATION_FAILED;
1001         }
1002
1003         int ret = -1;
1004         if (true == g_dynamic_engine.is_loaded) {
1005                 ret = g_dynamic_engine.pefuncs->get_private_data(key, data);
1006                 if (0 != ret) {
1007                         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to get private data (%d)", ret);
1008                         return VCD_ERROR_OPERATION_FAILED;
1009                 }
1010         }
1011
1012         return 0;
1013 }
1014
1015 int vcd_engine_process_text(int pid, const char* text)
1016 {
1017         if (false == g_agent_init) {
1018                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
1019                 return VCD_ERROR_OPERATION_FAILED;
1020         }
1021
1022         int ret = -1;
1023         if (true == g_dynamic_engine.is_loaded) {
1024                 ret = g_dynamic_engine.pefuncs->process_text(text);
1025                 if (0 != ret) {
1026                         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to process text (%d)", ret);
1027                         return VCD_ERROR_OPERATION_FAILED;
1028                 }
1029         }
1030
1031         return 0;
1032 }
1033
1034 int vcd_engine_process_list_event(int pid, const char* event)
1035 {
1036         if (false == g_agent_init) {
1037                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
1038                 return VCD_ERROR_OPERATION_FAILED;
1039         }
1040
1041         int ret = -1;
1042         if (true == g_dynamic_engine.is_loaded) {
1043                 ret = g_dynamic_engine.pefuncs->process_list_event(event);
1044                 if (0 != ret) {
1045                         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to process list event (%d)", ret);
1046                         return VCD_ERROR_OPERATION_FAILED;
1047                 }
1048         }
1049
1050         return 0;
1051 }
1052
1053 int vcd_engine_process_haptic_event(int pid, const char* event)
1054 {
1055         if (false == g_agent_init) {
1056                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
1057                 return VCD_ERROR_OPERATION_FAILED;
1058         }
1059
1060         int ret = -1;
1061         if (true == g_dynamic_engine.is_loaded) {
1062                 ret = g_dynamic_engine.pefuncs->process_haptic_event(event);
1063                 if (0 != ret) {
1064                         SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to process haptic event (%d)", ret);
1065                         return VCD_ERROR_OPERATION_FAILED;
1066                 }
1067         }
1068
1069         return 0;
1070 }
1071
1072 /*
1073 * VCS Engine Interfaces for client and setting
1074 */
1075
1076 int vcd_engine_get_audio_format(const char* audio_id, vcp_audio_type_e* types, int* rate, int* channels)
1077 {
1078         if (false == g_agent_init) {
1079                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
1080                 return VCD_ERROR_OPERATION_FAILED;
1081         }
1082
1083         if (true != g_dynamic_engine.is_loaded) {
1084                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Engine is not loaded");
1085         }
1086
1087         if (NULL == g_dynamic_engine.pefuncs->get_recording_format) {
1088                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] The function of engine is NULL!!");
1089                 return VCD_ERROR_OPERATION_FAILED;
1090         }
1091
1092         int ret = g_dynamic_engine.pefuncs->get_recording_format(audio_id, types, rate, channels);
1093         if (0 != ret) {
1094                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] get recording format(%d)", ret);
1095                 return VCD_ERROR_OPERATION_FAILED;
1096         }
1097
1098         return 0;
1099 }
1100
1101 bool __supported_language_cb(const char* language, void* user_data)
1102 {
1103         GList** lang_list = (GList**)user_data;
1104
1105         if (NULL == language || NULL == lang_list) {
1106                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Input parameter is NULL in callback!!!!");
1107                 return false;
1108         }
1109
1110         SLOG(LOG_DEBUG, TAG_VCD, "-- Language(%s)", language);
1111
1112         char* temp_lang = g_strdup(language);
1113
1114         *lang_list = g_list_append(*lang_list, temp_lang);
1115
1116         return true;
1117 }
1118
1119 int vcd_engine_supported_langs(GList** lang_list)
1120 {
1121         if (false == g_agent_init) {
1122                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
1123                 return VCD_ERROR_OPERATION_FAILED;
1124         }
1125
1126         if (true != g_dynamic_engine.is_loaded) {
1127                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Engine is not loaded");
1128         }
1129
1130         if (NULL == g_dynamic_engine.pefuncs->foreach_langs) {
1131                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] The function of engine is NULL!!");
1132                 return VCD_ERROR_OPERATION_FAILED;
1133         }
1134
1135         int ret = g_dynamic_engine.pefuncs->foreach_langs(__supported_language_cb, (void*)lang_list);
1136         if (0 != ret) {
1137                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] get language list error(%d)", ret);
1138                 return VCD_ERROR_OPERATION_FAILED;
1139         }
1140
1141         return 0;
1142 }
1143
1144
1145 int vcd_engine_get_current_language(char** lang)
1146 {
1147         if (false == g_agent_init) {
1148                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
1149                 return VCD_ERROR_OPERATION_FAILED;
1150         }
1151
1152         if (NULL == lang) {
1153                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid Parameter");
1154                 return VCD_ERROR_INVALID_PARAMETER;
1155         }
1156
1157         /* get default language */
1158         *lang = g_strdup(g_default_lang);
1159
1160         return 0;
1161 }
1162
1163 int vcd_engine_set_current_language(const char* language)
1164 {
1165         if (false == g_agent_init) {
1166                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
1167                 return VCD_ERROR_OPERATION_FAILED;
1168         }
1169
1170         if (NULL == language) {
1171                 SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid Parameter");
1172                 return VCD_ERROR_INVALID_PARAMETER;
1173         }
1174
1175         int ret;
1176
1177         if (true == g_dynamic_engine.is_loaded) {
1178                 g_dynamic_engine.is_command_ready = false;
1179
1180                 ret = g_dynamic_engine.pefuncs->set_language(language);
1181                 if (0 != ret) {
1182                         SLOG(LOG_WARN, TAG_VCD, "[Engine Agent] Fail to set language of dynamic engine error(%d, %s)", ret, language);
1183                 }
1184         } else {
1185                 SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Dynamic engine is not available (Cannot start)");
1186         }
1187
1188         return 0;
1189 }
1190
1191 void __free_language_list(GList* lang_list)
1192 {
1193         GList *iter = NULL;
1194         char* data = NULL;
1195
1196         /* if list have item */
1197         if (g_list_length(lang_list) > 0) {
1198                 /* Get a first item */
1199                 iter = g_list_first(lang_list);
1200
1201                 while (NULL != iter) {
1202                         data = iter->data;
1203
1204                         if (NULL != data)
1205                                 free(data);
1206
1207                         lang_list = g_list_remove_link(lang_list, iter);
1208
1209                         iter = g_list_first(lang_list);
1210                 }
1211         }
1212 }
1213
1214 int __log_enginelist()
1215 {
1216         GList *iter = NULL;
1217         vcengine_info_s *data = NULL;
1218
1219         if (0 < g_list_length(g_engine_list)) {
1220
1221                 /* Get a first item */
1222                 iter = g_list_first(g_engine_list);
1223
1224                 SLOG(LOG_DEBUG, TAG_VCD, "--------------- engine list -------------------");
1225
1226                 int i = 1;
1227                 while (NULL != iter) {
1228                         /* Get handle data from list */
1229                         data = iter->data;
1230
1231                         SLOG(LOG_DEBUG, TAG_VCD, "[%dth]", i);
1232                         SLOG(LOG_DEBUG, TAG_VCD, "  engine uuid : %s", data->engine_uuid);
1233                         SLOG(LOG_DEBUG, TAG_VCD, "  engine name : %s", data->engine_name);
1234                         SLOG(LOG_DEBUG, TAG_VCD, "  engine path : %s", data->engine_path);
1235                         iter = g_list_next(iter);
1236                         i++;
1237                 }
1238                 SLOG(LOG_DEBUG, TAG_VCD, "----------------------------------------------");
1239         } else {
1240                 SLOG(LOG_DEBUG, TAG_VCD, "-------------- engine list -------------------");
1241                 SLOG(LOG_DEBUG, TAG_VCD, "  No Engine in engine directory");
1242                 SLOG(LOG_DEBUG, TAG_VCD, "----------------------------------------------");
1243         }
1244
1245         return 0;
1246 }