3002bf5c17f4bc7416d5a7466cd1b14fd80e9c5c
[platform/core/uifw/voice-control.git] / client / vc_widget_tidl.c
1 /*
2 * Copyright (c) 2022 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 <pthread.h>
18 #include <rpc-port.h>
19
20 #include "vc_main.h"
21 #include "vc_widget_client.h"
22 #include "vc_widget_tidl.h"
23 #include "vc_widget_proxy.h"
24 #include "vc_widget_stub.h"
25
26 typedef struct {
27         bool connected;
28         bool connection_requesting;
29         bool register_callback_invoked;
30         rpc_port_proxy_vc_widget_h rpc_h;
31         rpc_port_proxy_vc_widget_notify_cb_h notify_cb_h;
32 } vc_widget_tidl_info_s;
33
34 typedef struct {
35         bool connected;
36         bool register_callback_requesting;
37 } vcd_widget_tidl_info_s;
38
39 static vc_widget_tidl_info_s* g_proxy_tidl_info = NULL;
40
41 static vcd_widget_tidl_info_s* g_stub_tidl_info = NULL;
42
43 static pthread_mutex_t g_w_tidl_mutex = PTHREAD_MUTEX_INITIALIZER;
44 static pthread_mutex_t g_w_init_mutex = PTHREAD_MUTEX_INITIALIZER;
45
46 static rpc_port_stub_vcd_widget_callback_s g_widget_callback;
47
48 extern int __vc_widget_cb_error(int reason, int daemon_pid, char* msg);
49
50 extern void __vc_widget_cb_show_tooltip(int pid, bool show);
51
52 extern void __vc_widget_cb_result();
53
54 extern bool __vc_widget_cb_asr_result(int event, const char* asr_result);
55
56 extern int __vc_widget_cb_service_state(int state);
57
58 static void __notify_cb(void *user_data, bundle *msg)
59 {
60         char* method = NULL;
61         char* val = NULL;
62         SLOG(LOG_DEBUG, TAG_VCW, "__notify_cb is invoked");
63
64         bundle_get_str(msg, VC_WIDGET_BUNDLE_METHOD, &method);
65
66         if (0 == strncmp(VCD_WIDGET_METHOD_HELLO, method, strlen(VCD_WIDGET_METHOD_HELLO))) {
67                 SLOG(LOG_INFO, TAG_VCW, "@@@ Get widget hello");
68                 bundle_get_str(msg, VC_WIDGET_BUNDLE_MESSAGE, &val);
69                 if (val) {
70                         SLOG(LOG_DEBUG, TAG_VCW, "@@ vc widget get hello : pid(%d) ", atoi(val));
71                 } else {
72                         SLOG(LOG_ERROR, TAG_VCW, "@@ vc widget get hello : invalid pid ");
73                 }
74                 SLOG(LOG_DEBUG, TAG_VCW, "@@@");
75         } /* VCD_METHOD_HELLO */
76
77         else if (0 == strncmp(VCD_WIDGET_METHOD_SET_SERVICE_STATE, method, strlen(VCD_WIDGET_METHOD_SET_SERVICE_STATE))) {
78                 bundle_get_str(msg, VC_WIDGET_BUNDLE_MESSAGE, &val);
79                 int state = 0;
80                 if (val) {
81                         state = atoi(val);
82                         SLOG(LOG_INFO, TAG_VCW, "@@ service state changed : %d", state);
83                         __vc_widget_cb_service_state(state);
84                 }
85         } /* VCD_WIDGET_METHOD_SET_SERVICE_STATE */
86
87         else if (0 == strncmp(VCD_WIDGET_METHOD_SHOW_TOOLTIP, method, strlen(VCD_WIDGET_METHOD_SHOW_TOOLTIP))) {
88                 SLOG(LOG_DEBUG, TAG_VCW, "@@@ Show / Hide tooltip");
89                 char* temp_show = NULL;
90                 bundle_get_str(msg, VC_WIDGET_BUNDLE_MESSAGE, &val);
91                 bundle_get_str(msg, VC_WIDGET_BUNDLE_SHOW, &temp_show);
92                 int pid = 0;
93                 int show = 0;
94
95                 if (val) {
96                         pid = atoi(val);
97                 }
98                 if (temp_show) {
99                         show = atoi(temp_show);
100                 }
101
102                 if(pid > 0){
103                         SLOG(LOG_DEBUG, TAG_VCW, "@@ vc widget show tooltip : pid(%d), show(%d)", pid, show);
104                         __vc_widget_cb_show_tooltip(pid, (bool)show);
105                 } else {
106                         SLOG(LOG_ERROR, TAG_VCW, "@@ vc widget show tooltip : invalid pid");
107                 }
108                 SLOG(LOG_DEBUG, TAG_VCW, "@@@");
109         } /* VCD_WIDGET_METHOD_SHOW_TOOLTIP */
110
111         else if (0 == strncmp(VCD_WIDGET_METHOD_RESULT, method, strlen(VCD_WIDGET_METHOD_RESULT))) {
112                 SLOG(LOG_DEBUG, TAG_VCW, "@@@ Get widget result");
113
114                 __vc_widget_cb_result();
115
116                 SLOG(LOG_DEBUG, TAG_VCW, "@@@");
117         } /* VCD_WIDGET_METHOD_RESULT */
118
119         else if (0 == strncmp(VCD_WIDGET_METHOD_ERROR, method, strlen(VCD_WIDGET_METHOD_ERROR))) {
120                 SLOG(LOG_INFO, TAG_VCW, "@@@ Get Pre Result");
121                 char* temp_reason = NULL;
122                 char* temp_daemon_pid = NULL;
123                 char* err_msg = NULL;
124
125                 bundle_get_str(msg, VC_WIDGET_BUNDLE_REASON, &temp_reason);
126                 bundle_get_str(msg, VC_WIDGET_BUNDLE_DAEMON_PID, &temp_daemon_pid);
127                 bundle_get_str(msg, VC_WIDGET_BUNDLE_ERROR_MESSAGE, &err_msg);
128                 int reason = 0;
129                 int daemon_pid = 0;
130
131                 if (NULL != temp_reason) {
132                         reason = atoi(temp_reason);
133                 }
134                 if (NULL != temp_daemon_pid) {
135                         daemon_pid = atoi(temp_daemon_pid);
136                 }
137
138                 SLOG(LOG_DEBUG, TAG_VCW, "@@ vc widget get error message : reason(%d), daemon_pid(%d), msg(%s)", reason, daemon_pid, err_msg);
139                 __vc_widget_cb_error(reason, daemon_pid, err_msg);
140
141                 SLOG(LOG_DEBUG, TAG_VCW, "@@@");
142         } /* VCD_WIDGET_METHOD_ERROR */
143
144         else {
145                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid msg");
146         }
147 }
148
149 static void __on_connected(rpc_port_proxy_vc_widget_h h, void *user_data)
150 {
151         g_proxy_tidl_info->connected = true;
152         g_proxy_tidl_info->connection_requesting = false;
153         g_proxy_tidl_info->register_callback_invoked = false;
154
155         SLOG(LOG_INFO, TAG_VCW, "Connected to server");
156 }
157
158 static void __on_disconnected(rpc_port_proxy_vc_widget_h h, void *user_data)
159 {
160         g_proxy_tidl_info->connected = false;
161         g_proxy_tidl_info->connection_requesting = false;
162         g_proxy_tidl_info->register_callback_invoked = false;
163
164         SLOG(LOG_INFO, TAG_VCW, "Disonnected to server");
165 }
166
167 static void __on_rejected(rpc_port_proxy_vc_widget_h h, void *user_data)
168 {
169         g_proxy_tidl_info->connection_requesting = false;
170         g_proxy_tidl_info->register_callback_invoked = false;
171
172         SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Rejected from server");
173 }
174
175
176 static rpc_port_proxy_vc_widget_h __create_rpc_port(const char* engine_app_id)
177 {
178         SLOG(LOG_DEBUG, TAG_VCW, "[TIDL] __create_rpc_port");
179         rpc_port_proxy_vc_widget_callback_s rpc_callback = {
180                 .connected = __on_connected,
181                 .disconnected = __on_disconnected,
182                 .rejected = __on_rejected
183         };
184
185         rpc_port_proxy_vc_widget_h handle = NULL;
186         if (0 != rpc_port_proxy_vc_widget_create(engine_app_id, &rpc_callback, NULL, &handle)) {
187                 SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Fail to create proxy");
188                 return NULL;
189         }
190
191         return handle;
192 }
193
194 static void __vcd_widget_create_cb(rpc_port_stub_vcd_widget_context_h context, void *user_data)
195 {
196         g_stub_tidl_info->connected = true;
197         g_stub_tidl_info->register_callback_requesting = false;
198
199         SLOG(LOG_DEBUG, TAG_VCW, "Connected to server");
200
201         char *sender = NULL;
202
203         rpc_port_stub_vcd_widget_context_get_sender(context, &sender);
204         if (!sender) {
205                 SLOG(LOG_ERROR, TAG_VCW, "@@@ Sender is NULL");
206                 return;
207         }
208
209         SLOG(LOG_DEBUG, TAG_VCW, "@@@ Server connect. appid(%s)", sender);
210         free(sender);
211 }
212
213 static void __vcd_widget_terminate_cb(rpc_port_stub_vcd_widget_context_h context, void *user_data)
214 {
215         g_stub_tidl_info->connected = false;
216         g_stub_tidl_info->register_callback_requesting = false;
217
218         rpc_port_stub_vcd_widget_context_set_tag(context, NULL);
219
220         char *sender = NULL;
221         rpc_port_stub_vcd_widget_context_get_sender(context, &sender);
222         if (!sender)
223                 return;
224
225         SLOG(LOG_INFO, TAG_VCW, "@@@ Server disconnect. appid(%s)", sender);
226         free(sender);
227 }
228
229 static int __vcd_widget_asr_result_cb(rpc_port_stub_vcd_widget_context_h context, int pid, int event, const char *asr_result, bool *is_consumed, void *user_data)
230 {
231         SLOG(LOG_DEBUG, TAG_VCW, "@@@ Get widget asr result");
232
233         bool result = false;
234         result = __vc_widget_cb_asr_result(event, asr_result);
235         *is_consumed = result;
236
237         return VC_ERROR_NONE;
238 }
239
240 static void __register_stub_callback()
241 {
242         if (g_stub_tidl_info->register_callback_requesting) {
243                 return;
244         }
245
246         SLOG(LOG_DEBUG, TAG_VCW, "[TIDL] __register_stub_callback");
247
248         g_widget_callback.create = __vcd_widget_create_cb;
249         g_widget_callback.terminate = __vcd_widget_terminate_cb;
250         g_widget_callback.send_asr_result = __vcd_widget_asr_result_cb;
251
252         int ret = -1;
253         ret = rpc_port_stub_vcd_widget_register(&g_widget_callback, NULL);
254         if (0 == ret) {
255                 SLOG(LOG_DEBUG, TAG_VCW, "register callback");
256                 g_stub_tidl_info->register_callback_requesting = true;
257                 return;
258         }
259
260         SLOG(LOG_ERROR, TAG_VCW, "Fail to rister callback(%d)", ret);
261         return;
262 }
263
264 int vc_widget_tidl_open_connection()
265 {
266         SLOG(LOG_DEBUG, TAG_VCW, "[TIDL] vc_widget_tidl_open_connection");
267         pthread_mutex_lock(&g_w_tidl_mutex);
268
269         if (NULL != g_proxy_tidl_info) {
270                 SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] g_proxy_tidl_info already created");
271                 pthread_mutex_unlock(&g_w_tidl_mutex);
272                 return VC_ERROR_NONE;
273         }
274
275         g_proxy_tidl_info = (vc_widget_tidl_info_s*)calloc(1, sizeof(vc_widget_tidl_info_s));
276
277         if (NULL == g_proxy_tidl_info) {
278                 SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Fail to create vc_widget_tidl_info_s");
279                 pthread_mutex_unlock(&g_w_tidl_mutex);
280                 return VC_ERROR_OUT_OF_MEMORY;
281         }
282
283         char* engine_app_id = vconf_get_str(VC_ENGINE_DB_DEFAULT);
284         if (NULL == engine_app_id) {
285                 SLOG(LOG_ERROR, TAG_VCW, "[TIDL] vconf not found");
286                 free(g_proxy_tidl_info);
287                 g_proxy_tidl_info = NULL;
288                 pthread_mutex_unlock(&g_w_tidl_mutex);
289                 return VC_ERROR_ENGINE_NOT_FOUND;
290         }
291
292         g_proxy_tidl_info->rpc_h = __create_rpc_port(engine_app_id);
293         if (NULL == g_proxy_tidl_info->rpc_h) {
294                 SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Fail to create proxy");
295                 free(engine_app_id);
296                 free(g_proxy_tidl_info);
297                 g_proxy_tidl_info = NULL;
298                 pthread_mutex_unlock(&g_w_tidl_mutex);
299                 return VC_ERROR_OPERATION_FAILED;
300         }
301
302         SLOG(LOG_INFO, TAG_VCW, "[TIDL] rpc_h(%p), engine_app_id(%s)", g_proxy_tidl_info->rpc_h, engine_app_id);
303         free(engine_app_id);
304
305         g_stub_tidl_info = (vcd_widget_tidl_info_s*)calloc(1, sizeof(vcd_widget_tidl_info_s));
306
307         if (NULL == g_stub_tidl_info) {
308                 SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Fail to create vcd_widget_tidl_info_s");
309                 pthread_mutex_unlock(&g_w_tidl_mutex);
310                 return VC_ERROR_OUT_OF_MEMORY;
311         }
312
313         __register_stub_callback();
314
315         pthread_mutex_unlock(&g_w_tidl_mutex);
316
317         return VC_ERROR_NONE;
318 }
319
320 int vc_widget_tidl_close_connection()
321 {
322         SLOG(LOG_DEBUG, TAG_VCW, "[TIDL] vc_widget_tidl_close_connection");
323         pthread_mutex_lock(&g_w_tidl_mutex);
324
325         if (NULL == g_proxy_tidl_info) {
326                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get tidl info");
327                 pthread_mutex_unlock(&g_w_tidl_mutex);
328                 return VC_ERROR_OPERATION_FAILED;
329         }
330
331         if (0 != rpc_port_proxy_vc_widget_destroy(g_proxy_tidl_info->rpc_h)) {
332                 SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Fail to destroy tidl handle");
333                 pthread_mutex_unlock(&g_w_tidl_mutex);
334                 return VC_ERROR_OPERATION_FAILED;
335         }
336
337         g_proxy_tidl_info->rpc_h = NULL;
338         g_proxy_tidl_info->notify_cb_h = NULL;
339
340         free(g_proxy_tidl_info);
341         g_proxy_tidl_info = NULL;
342
343         free(g_stub_tidl_info);
344         g_stub_tidl_info = NULL;
345
346         pthread_mutex_unlock(&g_w_tidl_mutex);
347
348         return VC_ERROR_NONE;
349 }
350
351 static void __request_tidl_connect()
352 {
353         if (g_proxy_tidl_info->connection_requesting) {
354                 return;
355         }
356
357         int ret = rpc_port_proxy_vc_widget_connect(g_proxy_tidl_info->rpc_h);
358         SLOG(LOG_INFO, TAG_VCW, "[INFO] Request connection to stub. ret(%d)", ret);
359
360         if (0 == ret) {
361                 g_proxy_tidl_info->connection_requesting = true;
362         }
363 }
364
365 static int __create_callback_handles()
366 {
367         if (NULL != g_proxy_tidl_info->notify_cb_h) {
368                 rpc_port_proxy_vc_widget_notify_cb_dispose(g_proxy_tidl_info->rpc_h, g_proxy_tidl_info->notify_cb_h);
369                 g_proxy_tidl_info->notify_cb_h = NULL;
370         }
371
372         if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_widget_notify_cb_create(&g_proxy_tidl_info->notify_cb_h)) {
373                 return VC_ERROR_OUT_OF_MEMORY;
374         }
375
376         rpc_port_proxy_vc_widget_notify_cb_set_callback(g_proxy_tidl_info->notify_cb_h, __notify_cb, NULL);
377
378         rpc_port_proxy_vc_widget_notify_cb_set_once(g_proxy_tidl_info->notify_cb_h, false);
379
380         return VC_ERROR_NONE;
381 }
382
383 static int __invoke_register_callback()
384 {
385         if (g_proxy_tidl_info->register_callback_invoked) {
386                 SLOG(LOG_ERROR, TAG_VCW, "[INFO] Already register callback is invoked");
387                 return VC_ERROR_NONE;
388         }
389
390         int ret = __create_callback_handles(g_proxy_tidl_info);
391         if (VC_ERROR_NONE != ret) {
392                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to create callback handle. ret(%d)", ret);
393                 return VC_ERROR_OPERATION_FAILED;
394         }
395
396         rpc_port_proxy_vc_widget_invoke_register_cb(g_proxy_tidl_info->rpc_h, getpid(), g_proxy_tidl_info->notify_cb_h);
397         g_proxy_tidl_info->register_callback_invoked = true;
398         return VC_ERROR_NONE;
399 }
400
401 int vc_widget_tidl_request_hello()
402 {
403         SLOG(LOG_DEBUG, TAG_VCW, "[TIDL] vc_widget_tidl_request_hello");
404
405         if (NULL == g_proxy_tidl_info) {
406                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get proxy tidl info");
407                 return VC_ERROR_OPERATION_FAILED;
408         }
409
410         if (!g_proxy_tidl_info->connected) {
411                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Proxy Not Connected");
412                 __request_tidl_connect();
413                 return VC_ERROR_OPERATION_FAILED;
414         }
415
416         if (VC_ERROR_NONE != __invoke_register_callback()) {
417                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to invoke register callback");
418                 return VC_ERROR_OPERATION_FAILED;
419         }
420
421         if (NULL == g_stub_tidl_info) {
422                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get stub tidl info");
423                 return VC_ERROR_OPERATION_FAILED;
424         }
425
426         if (!g_stub_tidl_info->connected) {
427                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Stub Not Connected");
428                 __register_stub_callback();
429                 return VC_ERROR_OPERATION_FAILED;
430         }
431
432         SLOG(LOG_DEBUG, TAG_VCW, ">>>>> VCW Hello");
433
434         SLOG(LOG_DEBUG, TAG_VCW, "<<<<");
435
436         return VC_ERROR_NONE;
437 }
438
439 int vc_widget_tidl_request_initialize(int pid, int* service_state, int* daemon_pid)
440 {
441         pthread_mutex_lock(&g_w_init_mutex);
442         SLOG(LOG_DEBUG, TAG_VCW, "[TIDL] vc_widget_tidl_request_initialize");
443
444         if (NULL == g_proxy_tidl_info) {
445                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get tidl info");
446                 pthread_mutex_unlock(&g_w_init_mutex);
447                 return VC_ERROR_OPERATION_FAILED;
448         }
449
450         int temp_service_state = 0;
451         int temp_daemon_pid = 0;
452         if (0 != rpc_port_proxy_vc_widget_invoke_initialize(g_proxy_tidl_info->rpc_h, pid, &temp_service_state, &temp_daemon_pid)) {
453                 SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget initialize : Fail to invoke message");
454                 pthread_mutex_unlock(&g_w_init_mutex);
455                 return VC_ERROR_OPERATION_FAILED;
456         }
457
458         *service_state = temp_service_state;
459         *daemon_pid = temp_daemon_pid;
460
461         pthread_mutex_unlock(&g_w_init_mutex);
462         SLOG(LOG_DEBUG, TAG_VCW, "[TIDL] vc widget initialize: service_state(%d), daemon_pid(%d)", *service_state, *daemon_pid);
463
464         return VC_ERROR_NONE;
465 }
466
467 int vc_widget_tidl_request_finalize(int pid)
468 {
469         pthread_mutex_lock(&g_w_init_mutex);
470         SLOG(LOG_DEBUG, TAG_VCW, "[TIDL] vc_widget_tidl_request_finalize");
471
472         if (NULL == g_proxy_tidl_info) {
473                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get tidl info");
474                 pthread_mutex_unlock(&g_w_init_mutex);
475                 return VC_ERROR_OPERATION_FAILED;
476         }
477
478         if (!g_proxy_tidl_info->connected) {
479                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Not Connected");
480                 pthread_mutex_unlock(&g_w_init_mutex);
481                 return VC_ERROR_OPERATION_FAILED;
482         }
483
484         if (0 != rpc_port_proxy_vc_widget_invoke_finalize(g_proxy_tidl_info->rpc_h, pid)) {
485                 SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget finalize : Fail to invoke message");
486                 pthread_mutex_unlock(&g_w_init_mutex);
487                 return VC_ERROR_OPERATION_FAILED;
488         }
489
490         pthread_mutex_unlock(&g_w_init_mutex);
491         return VC_ERROR_NONE;
492 }
493
494 int vc_widget_tidl_request_start_recording(int pid, bool command)
495 {
496         SLOG(LOG_DEBUG, TAG_VCW, "[TIDL] vc_widget_tidl_request_start_recording");
497
498         if (NULL == g_proxy_tidl_info) {
499                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get tidl info");
500                 return VC_ERROR_OPERATION_FAILED;
501         }
502
503         if (!g_proxy_tidl_info->connected) {
504                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Not Connected");
505                 return VC_ERROR_OPERATION_FAILED;
506         }
507
508         if (0 != rpc_port_proxy_vc_widget_invoke_start_recording(g_proxy_tidl_info->rpc_h, pid, (int)command)) {
509                 SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget start recording : Fail to invoke message");
510                 return VC_ERROR_OPERATION_FAILED;
511         }
512
513         return VC_ERROR_NONE;
514 }
515
516 int vc_widget_tidl_set_foreground(int pid, bool value)
517 {
518         SLOG(LOG_DEBUG, TAG_VCW, "[TIDL] vc_widget_tidl_set_foreground");
519
520         if (NULL == g_proxy_tidl_info) {
521                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get tidl info");
522                 return VC_ERROR_OPERATION_FAILED;
523         }
524
525         if (!g_proxy_tidl_info->connected) {
526                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Not Connected");
527                 return VC_ERROR_OPERATION_FAILED;
528         }
529
530         rpc_port_proxy_vc_widget_invoke_set_foreground(g_proxy_tidl_info->rpc_h, pid, (int)value);
531
532         return VC_ERROR_NONE;
533 }
534
535 int vc_widget_tidl_request_enable_asr_result(int pid, bool enable)
536 {
537         SLOG(LOG_DEBUG, TAG_VCW, "[TIDL] vc_widget_tidl_request_enable_asr_result");
538
539         if (NULL == g_proxy_tidl_info) {
540                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get tidl info");
541                 return VC_ERROR_OPERATION_FAILED;
542         }
543
544         if (!g_proxy_tidl_info->connected) {
545                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Not Connected");
546                 return VC_ERROR_OPERATION_FAILED;
547         }
548
549         if (0 != rpc_port_proxy_vc_widget_invoke_enable_asr_result(g_proxy_tidl_info->rpc_h, pid, (int)enable)) {
550                 SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget enable asr result : Fail to invoke message");
551                 return VC_ERROR_OPERATION_FAILED;
552         }
553
554         return VC_ERROR_NONE;
555 }
556
557 int vc_widget_tidl_request_start(int pid, int silence)
558 {
559         SLOG(LOG_DEBUG, TAG_VCW, "[TIDL] vc_widget_tidl_request_start");
560
561         if (NULL == g_proxy_tidl_info) {
562                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get tidl info");
563                 return VC_ERROR_OPERATION_FAILED;
564         }
565
566         if (!g_proxy_tidl_info->connected) {
567                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Not Connected");
568                 return VC_ERROR_OPERATION_FAILED;
569         }
570
571         if (0 != rpc_port_proxy_vc_widget_invoke_start(g_proxy_tidl_info->rpc_h, pid, silence)) {
572                 SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget start : Fail to invoke message");
573                 return VC_ERROR_OPERATION_FAILED;
574         }
575
576         return VC_ERROR_NONE;
577 }
578
579 int vc_widget_tidl_request_stop(int pid)
580 {
581         SLOG(LOG_DEBUG, TAG_VCW, "[TIDL] vc_widget_tidl_request_stop");
582
583         if (NULL == g_proxy_tidl_info) {
584                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get tidl info");
585                 return VC_ERROR_OPERATION_FAILED;
586         }
587
588         if (!g_proxy_tidl_info->connected) {
589                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Not Connected");
590                 return VC_ERROR_OPERATION_FAILED;
591         }
592
593         if (0 != rpc_port_proxy_vc_widget_invoke_stop(g_proxy_tidl_info->rpc_h, pid)) {
594                 SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget stop : Fail to invoke message");
595                 return VC_ERROR_OPERATION_FAILED;
596         }
597
598         return VC_ERROR_NONE;
599 }
600
601 int vc_widget_tidl_request_cancel(int pid)
602 {
603         SLOG(LOG_DEBUG, TAG_VCW, "[TIDL] vc_widget_tidl_request_cancel");
604
605         if (NULL == g_proxy_tidl_info) {
606                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get tidl info");
607                 return VC_ERROR_OPERATION_FAILED;
608         }
609
610         if (!g_proxy_tidl_info->connected) {
611                 SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Not Connected");
612                 return VC_ERROR_OPERATION_FAILED;
613         }
614
615         if (0 != rpc_port_proxy_vc_widget_invoke_cancel(g_proxy_tidl_info->rpc_h, pid)) {
616                 SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget cancel : Fail to invoke message");
617                 return VC_ERROR_OPERATION_FAILED;
618         }
619
620         return VC_ERROR_NONE;
621 }