2 * Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <app_manager.h>
19 #include <aul_window.h>
21 #include "vcd_client_data.h"
22 #include "vcd_config.h"
27 static GSList* g_client_list = NULL;
29 static GSList* g_widget_list = NULL;
31 static manager_info_s g_manager;
33 /* Client IPC info list */
34 static GSList* g_client_tidl_info_list = NULL;
36 /* Manager IPC info */
37 static manager_tidl_info_s* g_mgr_tidl_info = NULL;
40 static GSList* g_widget_tidl_info_list = NULL;
42 /* Setting IPC info list */
43 static GSList* g_setting_tidl_info_list = NULL;
46 static current_commands_list_s g_cur_cmd_list;
48 /* Demandable client list */
49 static GSList* g_demandable_client = NULL;
52 static bool g_silence_detection;
53 static vcd_recognition_mode_e g_recognition_mode;
54 static char* g_result_text = NULL;
55 static bool g_is_waiting_recording = false;
56 static int g_waiting_recording_pid = -1;
58 /* Function definitions */
59 widget_info_s* __widget_get_element(int pid);
61 vc_client_info_s* __client_get_element(int pid);
64 int vcd_client_manager_set(int pid)
66 // Get appid by pid using app control
68 int ret = app_manager_get_app_id(pid, &appid);
69 if (0 != ret || NULL == appid) {
70 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] fail to get app id, ret(%d), pid(%d)", ret, pid);
71 return VCD_ERROR_OPERATION_FAILED;
74 if (-1 != g_manager.pid && NULL != g_manager.appid && 0 == strncmp(g_manager.appid, appid, strlen(g_manager.appid))) {
75 SLOG(LOG_WARN, TAG_VCD, "Same manager has already registered. It doesn't need to set manager again.");
78 return VCD_ERROR_NONE;
82 g_manager.manager_cmd = false;
83 g_manager.exclusive_cmd_option = false;
84 g_manager.appid = NULL;
86 g_manager.appid = strdup(appid);
90 return VCD_ERROR_NONE;
93 int vcd_client_manager_unset()
96 g_manager.manager_cmd = false;
97 g_manager.exclusive_cmd_option = false;
99 return VCD_ERROR_NONE;
102 int vcd_client_manager_unset_appid()
104 if (NULL != g_manager.appid) {
105 free(g_manager.appid);
106 g_manager.appid = NULL;
108 return VCD_ERROR_NONE;
111 bool vcd_client_manager_is_valid(int pid)
113 if (-1 == g_manager.pid || pid == g_manager.pid) {
119 int vcd_client_manager_set_command(int pid)
121 if (pid != g_manager.pid) {
122 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid);
123 return VCD_ERROR_INVALID_PARAMETER;
125 g_manager.manager_cmd = true;
126 return VCD_ERROR_NONE;
129 int vcd_client_manager_unset_command(int pid)
131 if (pid != g_manager.pid) {
132 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid);
133 return VCD_ERROR_INVALID_PARAMETER;
135 g_manager.manager_cmd = false;
136 return VCD_ERROR_NONE;
139 bool vcd_client_manager_is_system_command_valid(int pid)
141 if (pid != g_manager.pid) {
142 SLOG(LOG_WARN, TAG_VCD, "[Client Data WARNING] pid(%d) is NOT valid", pid);
146 if (true == g_manager.manager_cmd)
152 int vcd_client_manager_set_demandable_client(int pid, GSList* client_list)
154 if (0 != g_slist_length(g_demandable_client)) {
157 vc_demandable_client_s* temp_client;
158 iter = g_slist_nth(g_demandable_client, 0);
160 while (NULL != iter) {
161 temp_client = iter->data;
163 if (NULL != temp_client) {
164 if (NULL != temp_client->appid) free(temp_client->appid);
168 iter = g_slist_next(iter);
170 g_demandable_client = NULL;
173 g_demandable_client = client_list;
175 return VCD_ERROR_NONE;
178 bool vcd_client_manager_check_demandable_client(int pid)
180 if (0 == g_slist_length(g_demandable_client)) {
181 SLOG(LOG_INFO, TAG_VCD, "[Client Data] All client is available to request start");
185 /* Check demandable appid */
186 char appid[1024] = {0, };
187 if (0 == aul_app_get_appid_bypid(pid, appid, sizeof(appid) - 1)) {
188 SLOG(LOG_INFO, TAG_VCD, "[Client Data] %s(%d) requests start", appid, pid);
190 SLOG(LOG_INFO, TAG_VCD, "[Client Data] daemon(%d) requests start", pid);
195 vc_demandable_client_s* temp_client;
196 iter = g_slist_nth(g_demandable_client, 0);
198 while (NULL != iter) {
199 temp_client = iter->data;
201 if (NULL != temp_client) {
203 SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] demandable appid(%s)", temp_client->appid);
205 if (NULL != temp_client->appid) {
206 if (0 == strcmp(temp_client->appid, appid)) {
207 SLOG(LOG_INFO, TAG_VCD, "[Client Data] pid(%d) is available", pid);
211 if (0 == strlen(appid)) {
212 SLOG(LOG_INFO, TAG_VCD, "[Client Data] pid(%d) is available", pid);
218 iter = g_slist_next(iter);
224 bool vcd_client_manager_get_exclusive()
226 return g_manager.exclusive_cmd_option;
229 int vcd_client_manager_set_exclusive(bool value)
231 g_manager.exclusive_cmd_option = value;
232 return VCD_ERROR_NONE;
235 int vcd_client_manager_get_pid()
237 return g_manager.pid;
240 int vcd_client_manager_get_appid(char** appid)
242 if (NULL != g_manager.appid)
243 *appid = strdup(g_manager.appid);
245 return VCD_ERROR_NONE;
248 int vcd_client_manager_set_result_text(const char* result)
250 if (NULL != g_result_text) {
252 g_result_text = NULL;
255 if (NULL != result) {
256 g_result_text = strdup(result);
259 return VCD_ERROR_NONE;
262 char* vcd_client_manager_get_result_text()
264 return g_result_text;
267 int vcd_client_manager_create_tidl_info()
269 /*Check already created*/
270 if (NULL != g_mgr_tidl_info) {
271 SLOG(LOG_WARN, TAG_VCD, "[Client Data] Manager tidl info pid is already registered");
272 return VCD_ERROR_NONE;
275 SLOG(LOG_INFO, TAG_VCD, "[Client Data] There is no manager tidl info. Create new one.");
276 g_mgr_tidl_info = (manager_tidl_info_s*)calloc(1, sizeof(manager_tidl_info_s));
277 if (NULL == g_mgr_tidl_info) {
278 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory");
279 return VCD_ERROR_OUT_OF_MEMORY;
282 g_mgr_tidl_info->notify_cb = NULL;
283 g_mgr_tidl_info->notify_cb_user_data = NULL;
284 g_mgr_tidl_info->send_buffer_cb = NULL;
285 g_mgr_tidl_info->send_buffer_cb_user_data = NULL;
287 g_mgr_tidl_info->connected = false;
288 g_mgr_tidl_info->connection_requesting = false;
289 g_mgr_tidl_info->rpc_h = NULL;
291 SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new manager tidl info.");
293 return VCD_ERROR_NONE;
296 int vcd_client_manager_set_tidl_notify_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h callback, void* user_data)
298 if (NULL == g_mgr_tidl_info) {
299 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no manager tidl info");
300 return VCD_ERROR_INVALID_PARAMETER;
304 ret = rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_clone(callback, &(g_mgr_tidl_info->notify_cb));
306 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to clone notify callback. ret(%d)", ret);
308 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to clone notify callback. ret(%d)", ret);
310 g_mgr_tidl_info->notify_cb_user_data = user_data;
312 return VCD_ERROR_NONE;
315 int vcd_client_manager_unset_tidl_notify_cb()
317 if (NULL == g_mgr_tidl_info) {
318 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no manager tidl info");
319 return VCD_ERROR_INVALID_PARAMETER;
323 ret = rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_destroy(g_mgr_tidl_info->notify_cb);
325 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to destroy notify callback. ret(%d)", ret);
327 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to destroy notify callback. ret(%d)", ret);
329 g_mgr_tidl_info->notify_cb = NULL;
330 g_mgr_tidl_info->notify_cb_user_data = NULL;
332 return VCD_ERROR_NONE;
335 int vcd_client_manager_set_tidl_send_buffer_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_h callback, void* user_data)
337 if (NULL == g_mgr_tidl_info) {
338 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no manager tidl info");
339 return VCD_ERROR_INVALID_PARAMETER;
343 ret = rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_clone(callback, &(g_mgr_tidl_info->send_buffer_cb));
345 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to clone feedback callback. ret(%d)", ret);
347 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to clone feedback callback. ret(%d)", ret);
349 g_mgr_tidl_info->send_buffer_cb_user_data = user_data;
351 return VCD_ERROR_NONE;
354 int vcd_client_manager_unset_tidl_send_buffer_cb()
356 if (NULL == g_mgr_tidl_info) {
357 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no manager tidl info");
358 return VCD_ERROR_INVALID_PARAMETER;
362 ret = rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_destroy(g_mgr_tidl_info->send_buffer_cb);
364 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to destroy feedback callback. ret(%d)", ret);
366 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to destroy feedback callback. ret(%d)", ret);
368 g_mgr_tidl_info->send_buffer_cb = NULL;
369 g_mgr_tidl_info->send_buffer_cb_user_data = NULL;
371 return VCD_ERROR_NONE;
374 int vcd_client_manager_delete_tidl_info()
376 if (NULL == g_mgr_tidl_info) {
377 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no manager tidl info");
378 return VCD_ERROR_INVALID_PARAMETER;
381 if (0 != rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_destroy(g_mgr_tidl_info->rpc_h)) {
382 SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to destroy tidl handle");
385 g_mgr_tidl_info->rpc_h = NULL;
386 free(g_mgr_tidl_info);
387 g_mgr_tidl_info = NULL;
389 return VCD_ERROR_NONE;
392 manager_tidl_info_s* vcd_client_manager_get_tidl_info()
394 return g_mgr_tidl_info;
397 static void __vcd_client_release_each_commands(GSList** cmds)
399 if (0 < g_slist_length(*cmds)) {
400 GSList *iter = g_slist_nth(*cmds, 0);
401 while (NULL != iter) {
402 vc_cmd_s *temp_cmd = iter->data;
404 if (NULL != temp_cmd) {
405 if (NULL != temp_cmd->command) {
406 free(temp_cmd->command);
407 temp_cmd->command = NULL;
409 if (NULL != temp_cmd->appid) {
410 free(temp_cmd->appid);
411 temp_cmd->appid = NULL;
413 if (NULL != temp_cmd->parameter) {
414 free(temp_cmd->parameter);
415 temp_cmd->parameter = NULL;
417 if (NULL != temp_cmd->invocation_name) {
418 free(temp_cmd->invocation_name);
419 temp_cmd->invocation_name = NULL;
421 if (NULL != temp_cmd->fixed) {
422 free(temp_cmd->fixed);
423 temp_cmd->fixed = NULL;
428 *cmds = g_slist_remove_link(*cmds, iter);
430 iter = g_slist_nth(*cmds, 0);
436 int __vcd_client_release_commands()
438 g_cur_cmd_list.total_cmd_count = 0;
439 g_cur_cmd_list.foreground = VC_NO_FOREGROUND_PID;
441 __vcd_client_release_each_commands(&(g_cur_cmd_list.widget_cmds));
442 __vcd_client_release_each_commands(&(g_cur_cmd_list.system_cmds));
443 __vcd_client_release_each_commands(&(g_cur_cmd_list.system_background_cmds));
444 __vcd_client_release_each_commands(&(g_cur_cmd_list.exclusive_system_cmds));
445 __vcd_client_release_each_commands(&(g_cur_cmd_list.foreground_cmds));
446 __vcd_client_release_each_commands(&(g_cur_cmd_list.background_cmds));
448 return VCD_ERROR_NONE;
451 int vcd_client_command_collect_command()
453 /* 1. Get foreground pid */
456 if (0 != vcd_config_get_foreground(&fg_pid)) {
457 SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to get foreground pid");
458 /* There is no foreground app for voice control */
461 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Foreground pid(%d)", fg_pid);
463 /* 2. Clean up command list */
464 __vcd_client_release_commands();
466 /* Check exclusive system command */
467 if (true == g_manager.exclusive_cmd_option && 1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_EXCLUSIVE)) {
468 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Exclusive option of manager is ON");
470 GSList* ex_sys_cmd_list = NULL;
471 if (true == g_manager.manager_cmd) {
472 ret = vc_cmd_parser_get_commands(g_manager.pid, VC_COMMAND_TYPE_EXCLUSIVE, &ex_sys_cmd_list);
474 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the system command list");
476 g_cur_cmd_list.exclusive_system_cmds = ex_sys_cmd_list;
479 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No exclusive system commands");
482 return VCD_ERROR_NONE;
485 /* 3. Set system command */
486 GSList* sys_cmd_list = NULL;
487 if (true == g_manager.manager_cmd && 1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_SYSTEM)) {
488 ret = vc_cmd_parser_get_commands(g_manager.pid, VC_COMMAND_TYPE_SYSTEM, &sys_cmd_list);
490 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the system command list");
492 g_cur_cmd_list.system_cmds = sys_cmd_list;
495 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No system commands");
498 GSList* sys_back_cmd_list = NULL;
499 if (true == g_manager.manager_cmd && 1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_SYSTEM_BACKGROUND)) {
500 ret = vc_cmd_parser_get_commands(g_manager.pid, VC_COMMAND_TYPE_SYSTEM_BACKGROUND, &sys_back_cmd_list);
502 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the system command list");
504 g_cur_cmd_list.system_background_cmds = sys_back_cmd_list;
507 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No system background commands");
510 /* 4. Set foreground commands and widget */
511 GSList* fg_cmd_list = NULL;
512 if (VC_NO_FOREGROUND_PID != fg_pid) {
513 GSList* widget_cmd_list = NULL;
515 g_cur_cmd_list.foreground = fg_pid;
517 /* 4-1. Set widget command */
518 widget_info_s* widget_info = NULL;
519 widget_info = __widget_get_element(fg_pid);
520 if (NULL != widget_info && 1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_WIDGET)) {
521 if (true == widget_info->widget_cmd) {
522 ret = vc_cmd_parser_get_commands(fg_pid, VC_COMMAND_TYPE_WIDGET, &widget_cmd_list);
524 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the WIDGET command list");
526 g_cur_cmd_list.widget_cmds = widget_cmd_list;
530 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No widget commands");
533 /* 4-2. Set foreground command of foreground app */
534 if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_FOREGROUND)) {
535 ret = vc_cmd_parser_get_commands(fg_pid, VC_COMMAND_TYPE_FOREGROUND, &fg_cmd_list);
537 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the fg command list");
539 g_cur_cmd_list.foreground_cmds = fg_cmd_list;
543 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No foreground app");
545 if (true == g_manager.manager_cmd && 1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_FOREGROUND)) {
546 /* 4-3. Set foreground command by manager */
547 ret = vc_cmd_parser_get_commands(g_manager.pid, VC_COMMAND_TYPE_FOREGROUND, &fg_cmd_list);
549 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No foreground commands of manager app");
551 g_cur_cmd_list.foreground_cmds = fg_cmd_list;
555 /* 5. Set background commands */
556 GSList* bg_cmd_list = NULL;
557 if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_BACKGROUND)) {
558 ret = vc_cmd_parser_get_commands(fg_pid, VC_COMMAND_TYPE_BACKGROUND, &bg_cmd_list);
560 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the bg command list");
562 /* Add item to global command list */
563 g_cur_cmd_list.background_cmds = bg_cmd_list;
566 return VCD_ERROR_NONE;
569 int vcd_client_get_length()
571 int command_count = 0;
572 command_count += g_slist_length(g_cur_cmd_list.widget_cmds);
573 command_count += g_slist_length(g_cur_cmd_list.system_cmds);
574 command_count += g_slist_length(g_cur_cmd_list.exclusive_system_cmds);
575 command_count += g_slist_length(g_cur_cmd_list.system_background_cmds);
576 command_count += g_slist_length(g_cur_cmd_list.foreground_cmds);
577 command_count += g_slist_length(g_cur_cmd_list.background_cmds);
579 g_cur_cmd_list.total_cmd_count = command_count;
581 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Command count : %d ", g_cur_cmd_list.total_cmd_count);
582 return command_count;
585 int vcd_client_foreach_command(client_foreach_command_cb callback, void* user_data)
587 if (NULL == callback) {
588 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] input parameter is NULL");
589 return VCD_ERROR_INVALID_PARAMETER;
592 if (0 != vcd_client_command_collect_command()) {
593 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to collect command");
594 return VCD_ERROR_OPERATION_FAILED;
597 if (0 >= vcd_client_get_length()) {
598 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] No current command");
599 return VCD_ERROR_OPERATION_FAILED;
606 if (0 < g_slist_length(g_cur_cmd_list.widget_cmds)) {
607 iter = g_slist_nth(g_cur_cmd_list.widget_cmds, 0);
608 while (NULL != iter) {
609 temp_cmd = iter->data;
611 SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Widget : id(%d) type(%d) format(%d) command(%s) domain(%d)"
612 , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->domain);
614 callback(temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, user_data);
616 iter = g_slist_next(iter);
619 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No widget commands");
622 if (0 < g_slist_length(g_cur_cmd_list.foreground_cmds)) {
623 iter = g_slist_nth(g_cur_cmd_list.foreground_cmds, 0);
624 while (NULL != iter) {
625 temp_cmd = iter->data;
627 SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Fore : id(%d) type(%d) format(%d) command(%s) param(%s) domain(%d) fixed(%s)"
628 , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, temp_cmd->fixed);
630 callback(temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, user_data);
632 iter = g_slist_next(iter);
635 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No foreground commands");
638 if (0 < g_slist_length(g_cur_cmd_list.system_cmds)) {
639 iter = g_slist_nth(g_cur_cmd_list.system_cmds, 0);
640 while (NULL != iter) {
641 temp_cmd = iter->data;
643 SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] System : id(%d) type(%d) format(%d) command(%s) param(%s) domain(%d)"
644 , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain);
646 callback(temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, user_data);
648 iter = g_slist_next(iter);
651 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No system commands");
654 if (0 < g_slist_length(g_cur_cmd_list.system_background_cmds)) {
655 iter = g_slist_nth(g_cur_cmd_list.system_background_cmds, 0);
656 while (NULL != iter) {
657 temp_cmd = iter->data;
659 SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] System background : id(%d) type(%d) format(%d) command(%s) param(%s) domain(%d)"
660 , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain);
662 callback(temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, user_data);
664 iter = g_slist_next(iter);
667 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No system background commands");
670 if (0 < g_slist_length(g_cur_cmd_list.exclusive_system_cmds)) {
671 iter = g_slist_nth(g_cur_cmd_list.exclusive_system_cmds, 0);
672 while (NULL != iter) {
673 temp_cmd = iter->data;
675 SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Exclusive system : id(%d) type(%d) format(%d) command(%s) param(%s) domain(%d)"
676 , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain);
678 callback(temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, user_data);
680 iter = g_slist_next(iter);
683 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No exclusive system commands");
686 if (0 < g_slist_length(g_cur_cmd_list.background_cmds)) {
687 iter = g_slist_nth(g_cur_cmd_list.background_cmds, 0);
688 while (NULL != iter) {
689 temp_cmd = iter->data;
691 SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Back : id(%d) format(%d) type(%d) command(%s) param(%s) domain(%d) appid(%s) invocation(%s) fixed(%s)"
692 , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, temp_cmd->appid, temp_cmd->invocation_name, temp_cmd->fixed);
694 callback(temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, user_data);
696 iter = g_slist_next(iter);
699 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No background commands");
701 return VCD_ERROR_NONE;
704 static vc_cmd_s* __command_copy(vc_cmd_s* src_cmd)
706 if (NULL == src_cmd) {
707 SLOG(LOG_WARN, TAG_VCD, "[Client Data] Input command is NULL");
711 vc_cmd_s* temp_cmd = NULL;
712 temp_cmd = (vc_cmd_s*)calloc(sizeof(vc_cmd_s), 1);
713 if (NULL == temp_cmd) {
714 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory");
718 temp_cmd->id = src_cmd->id;
719 temp_cmd->pid = src_cmd->pid;
720 temp_cmd->index = src_cmd->index;
721 temp_cmd->type = src_cmd->type;
722 temp_cmd->format = src_cmd->format;
723 temp_cmd->domain = src_cmd->domain;
725 if (VC_COMMAND_TYPE_SYSTEM == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_SYSTEM;
726 else if (VC_COMMAND_TYPE_EXCLUSIVE == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_EXCLUSIVE;
727 else if (VC_COMMAND_TYPE_WIDGET == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_WIDGET;
728 else if (VC_COMMAND_TYPE_FOREGROUND == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_FOREGROUND;
729 else if (VC_COMMAND_TYPE_SYSTEM_BACKGROUND == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_SYSTEM_BACKGROUND;
730 else if (VC_COMMAND_TYPE_BACKGROUND == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_BACKGROUND;
732 if (NULL != src_cmd->command) {
733 temp_cmd->command = strdup(src_cmd->command);
736 if (NULL != src_cmd->parameter) {
737 temp_cmd->parameter = strdup(src_cmd->parameter);
740 if (NULL != src_cmd->appid) {
741 temp_cmd->appid = strdup(src_cmd->appid);
744 if (NULL != src_cmd->invocation_name) {
745 temp_cmd->invocation_name = strdup(src_cmd->invocation_name);
748 if (NULL != src_cmd->fixed) {
749 temp_cmd->fixed = strdup(src_cmd->fixed);
752 temp_cmd->key = src_cmd->key;
753 temp_cmd->modifier = src_cmd->modifier;
758 int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result)
763 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Result id(%d)", result_id);
765 if (0 < g_slist_length(g_cur_cmd_list.widget_cmds)) {
766 iter = g_slist_nth(g_cur_cmd_list.widget_cmds, 0);
767 while (NULL != iter) {
768 temp_cmd = iter->data;
770 if (result_id == temp_cmd->id) {
771 /**pid = g_cur_cmd_list.foreground; */
772 /**cmd_type = VCD_CLIENT_COMMAND_GROUP_TYPE_UI_CONTROL; */
773 /*SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Find result pid(%d) type(%d)", *pid, *cmd_type); */
775 *result = __command_copy(temp_cmd);
777 return VCD_ERROR_NONE;
780 iter = g_slist_next(iter);
783 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No widget commands");
786 if (0 < g_slist_length(g_cur_cmd_list.foreground_cmds)) {
787 iter = g_slist_nth(g_cur_cmd_list.foreground_cmds, 0);
789 while (NULL != iter) {
790 temp_cmd = iter->data;
792 SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] command id (%d)", temp_cmd->id);
794 if (result_id == temp_cmd->id) {
795 /**pid = g_cur_cmd_list.foreground; */
796 /**cmd_type = VCD_CLIENT_COMMAND_GROUP_TYPE_FOREGROUND; */
797 /*SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Find result pid(%d) type(%d)", *pid, *cmd_type); */
799 *result = __command_copy(temp_cmd);
800 return VCD_ERROR_NONE;
803 iter = g_slist_next(iter);
806 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No foreground commands");
809 if (0 < g_slist_length(g_cur_cmd_list.system_cmds)) {
810 iter = g_slist_nth(g_cur_cmd_list.system_cmds, 0);
811 while (NULL != iter) {
812 temp_cmd = iter->data;
814 if (result_id == temp_cmd->id) {
815 /**pid = g_manager.pid; */
816 /**cmd_type = VCD_CLIENT_COMMAND_GROUP_TYPE_SYSTEM; */
817 /*SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Find result pid(%d) type(%d)", *pid, *cmd_type); */
819 *result = __command_copy(temp_cmd);
820 return VCD_ERROR_NONE;
823 iter = g_slist_next(iter);
826 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No system commands");
829 if (0 < g_slist_length(g_cur_cmd_list.system_background_cmds)) {
830 iter = g_slist_nth(g_cur_cmd_list.system_background_cmds, 0);
831 while (NULL != iter) {
832 temp_cmd = iter->data;
834 if (result_id == temp_cmd->id) {
835 /**pid = g_manager.pid; */
836 /**cmd_type = VCD_CLIENT_COMMAND_GROUP_TYPE_SYSTEM_BACKGROUND; */
837 /*SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Find result pid(%d) type(%d)", *pid, *cmd_type); */
839 *result = __command_copy(temp_cmd);
840 return VCD_ERROR_NONE;
843 iter = g_slist_next(iter);
846 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No system background commands");
849 if (0 < g_slist_length(g_cur_cmd_list.exclusive_system_cmds)) {
850 iter = g_slist_nth(g_cur_cmd_list.exclusive_system_cmds, 0);
851 while (NULL != iter) {
852 temp_cmd = iter->data;
854 if (result_id == temp_cmd->id) {
855 /**pid = g_manager.pid; */
856 /**cmd_type = VCD_CLIENT_COMMAND_GROUP_TYPE_SYSTEM_EXCLUSIVE; */
857 /*SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Find result pid(%d) type(%d)", *pid, *cmd_type); */
859 *result = __command_copy(temp_cmd);
860 return VCD_ERROR_NONE;
863 iter = g_slist_next(iter);
866 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No exclusive system commands");
869 if (0 < g_slist_length(g_cur_cmd_list.background_cmds)) {
870 iter = g_slist_nth(g_cur_cmd_list.background_cmds, 0);
872 while (NULL != iter) {
873 temp_cmd = iter->data;
875 SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] command id (%d)", temp_cmd->id);
877 if (result_id == temp_cmd->id) {
878 *result = __command_copy(temp_cmd);
879 return VCD_ERROR_NONE;
882 iter = g_slist_next(iter);
885 SLOG(LOG_INFO, TAG_VCD, "[Client Data] No background commands");
888 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Not find matched result");
889 return VCD_ERROR_INVALID_PARAMETER;
892 int vcd_client_set_slience_detection(bool value)
894 g_silence_detection = value;
895 return VCD_ERROR_NONE;
898 bool vcd_client_get_slience_detection()
900 return g_silence_detection;
903 int vcd_client_set_recognition_mode(vcd_recognition_mode_e mode)
905 g_recognition_mode = mode;
906 return VCD_ERROR_NONE;
909 vcd_recognition_mode_e vcd_client_get_recognition_mode()
911 return g_recognition_mode;
914 int vcd_client_set_server_dialog(int pid, bool is_server_dialog)
916 vc_client_info_s* client_info = NULL;
918 client_info = __client_get_element(pid);
919 if (NULL == client_info) {
920 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] vcd_client_get_pid : pid(%d) is not found", pid);
921 return VCD_ERROR_INVALID_PARAMETER;
924 client_info->server_dialog = is_server_dialog;
926 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Set server dialog, client pid(%d), server_dialog(%d)", pid, client_info->server_dialog);
927 return VCD_ERROR_NONE;
930 int vcd_client_get_server_dialog(int pid, bool* is_server_dialog)
932 vc_client_info_s* client_info = NULL;
934 client_info = __client_get_element(pid);
935 if (NULL == client_info) {
936 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] vcd_client_get_pid : pid(%d) is not found", pid);
937 return VCD_ERROR_INVALID_PARAMETER;
940 *is_server_dialog = client_info->server_dialog;
942 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Get server dialog, client pid(%d), server_dialog(%d)", pid, *is_server_dialog);
943 return VCD_ERROR_NONE;
946 int vcd_client_append_cmd_from_type(int type, vc_cmd_list_h list)
951 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid list parameter");
952 return VCD_ERROR_INVALID_PARAMETER;
956 case VC_COMMAND_TYPE_SYSTEM:
957 item = g_cur_cmd_list.system_cmds;
959 case VC_COMMAND_TYPE_FOREGROUND:
960 item = g_cur_cmd_list.foreground_cmds;
962 case VC_COMMAND_TYPE_WIDGET:
963 item = g_cur_cmd_list.widget_cmds;
965 case VC_COMMAND_TYPE_SYSTEM_BACKGROUND:
966 item = g_cur_cmd_list.system_background_cmds;
968 case VC_COMMAND_TYPE_BACKGROUND:
969 item = g_cur_cmd_list.background_cmds;
971 case VC_COMMAND_TYPE_EXCLUSIVE:
972 item = g_cur_cmd_list.exclusive_system_cmds;
975 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid type parameter");
976 return VCD_ERROR_INVALID_PARAMETER;
979 while (NULL != item) {
980 vc_cmd_h temp_cmd = NULL;
981 vc_cmd_h target_cmd = (vc_cmd_h)item->data;
983 temp_cmd = (vc_cmd_h)__command_copy((vc_cmd_s*)target_cmd);
985 if (NULL == temp_cmd) {
986 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to copy the command");
987 return VCD_ERROR_OUT_OF_MEMORY;
990 if (0 != vc_cmd_list_add(list, temp_cmd)) {
991 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to add the command in the list");
992 if (NULL != temp_cmd) {
993 vc_cmd_destroy(temp_cmd);
997 return VCD_ERROR_OPERATION_FAILED;
1003 return VCD_ERROR_NONE;
1006 int __show_client_list()
1008 GSList *iter = NULL;
1009 vc_client_info_s *data = NULL;
1011 SLOG(LOG_DEBUG, TAG_VCD, "@@@ client list");
1013 int count = g_slist_length(g_client_list);
1017 SLOG(LOG_DEBUG, TAG_VCD, "No Client");
1019 iter = g_slist_nth(g_client_list, 0);
1020 for (i = 0; i < count; i++) {
1027 SLOG(LOG_DEBUG, TAG_VCD, "[%dth] pid(%d)", i, data->pid);
1029 iter = g_slist_next(iter);
1033 SLOG(LOG_DEBUG, TAG_VCD, "@@@");
1035 SLOG(LOG_DEBUG, TAG_VCD, "@@@ widget list");
1037 widget_info_s *widget_data = NULL;
1039 count = g_slist_length(g_widget_list);
1042 SLOG(LOG_DEBUG, TAG_VCD, "No widget");
1044 iter = g_slist_nth(g_widget_list, 0);
1045 for (i = 0; i < count; i++) {
1049 widget_data = iter->data;
1051 if (NULL != widget_data) {
1052 SLOG(LOG_DEBUG, TAG_VCD, "[%dth] pid(%d)", i, widget_data->pid);
1054 iter = g_slist_next(iter);
1058 SLOG(LOG_DEBUG, TAG_VCD, "@@@");
1060 return VCD_ERROR_NONE;
1063 int __show_command_list(GSList* cmd_group)
1065 GSList *iter = NULL;
1066 vc_cmd_s *data = NULL;
1068 SLOG(LOG_DEBUG, TAG_VCD, "@@@ command group");
1070 int count = g_slist_length(cmd_group);
1074 SLOG(LOG_DEBUG, TAG_VCD, "No command");
1076 iter = g_slist_nth(cmd_group, 0);
1077 for (i = 0; i < count; i++) {
1083 if (NULL != data->parameter) {
1084 SLOG(LOG_DEBUG, TAG_VCD, "[%dth] command(%s) parameter(%s) key(%d)", i, data->command, data->parameter, data->key);
1086 SLOG(LOG_DEBUG, TAG_VCD, "[%dth] command(%s) key(%d)", i, data->command, data->key);
1089 iter = g_slist_next(iter);
1093 SLOG(LOG_DEBUG, TAG_VCD, "@@@");
1095 return VCD_ERROR_NONE;
1098 GSList* __client_get_item(const int pid)
1100 GSList *iter = NULL;
1101 vc_client_info_s *data = NULL;
1103 int count = g_slist_length(g_client_list);
1107 iter = g_slist_nth(g_client_list, 0);
1108 for (i = 0; i < count; i++) {
1114 if (pid == data->pid)
1118 iter = g_slist_next(iter);
1125 vc_client_info_s* __client_get_element(int pid)
1127 GSList *iter = NULL;
1128 vc_client_info_s *data = NULL;
1130 int count = g_slist_length(g_client_list);
1134 iter = g_slist_nth(g_client_list, 0);
1135 for (i = 0; i < count; i++) {
1142 if (pid == data->pid)
1146 iter = g_slist_next(iter);
1153 int vcd_client_add(int pid)
1155 /*Check pid is duplicated*/
1157 tmp = __client_get_item(pid);
1160 SLOG(LOG_WARN, TAG_VCD, "[Client Data] Client pid is already registered");
1161 return VCD_ERROR_INVALID_PARAMETER;
1164 vc_client_info_s *info = (vc_client_info_s*)calloc(1, sizeof(vc_client_info_s));
1166 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory");
1167 return VCD_ERROR_OUT_OF_MEMORY;
1172 info->fg_cmd = false;
1173 info->bg_cmd = false;
1174 info->exclusive_cmd = false;
1175 info->server_dialog = false;
1177 /* Add item to global list */
1178 g_client_list = g_slist_append(g_client_list, info);
1180 if (NULL == g_client_list) {
1181 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to add new client");
1186 return VCD_ERROR_OUT_OF_MEMORY;
1188 SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new client");
1191 #ifdef CLIENT_DATA_DEBUG
1192 __show_client_list();
1194 return VCD_ERROR_NONE;
1197 int vcd_client_delete(int pid)
1200 vc_client_info_s* client_info = NULL;
1203 tmp = __client_get_item(pid);
1205 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid);
1206 return VCD_ERROR_INVALID_PARAMETER;
1209 /*Free client structure*/
1210 client_info = tmp->data;
1211 if (NULL != client_info) {
1215 /*Remove handle from list*/
1216 g_client_list = g_slist_remove_link(g_client_list, tmp);
1219 #ifdef CLIENT_DATA_DEBUG
1220 __show_client_list();
1223 return VCD_ERROR_NONE;
1226 GSList* __get_client_tidl_info_item(const int pid)
1228 GSList *iter = NULL;
1229 client_tidl_info_s *data = NULL;
1231 int count = g_slist_length(g_client_tidl_info_list);
1235 iter = g_slist_nth(g_client_tidl_info_list, 0);
1236 for (i = 0; i < count; i++) {
1242 if (pid == data->pid)
1246 iter = g_slist_next(iter);
1253 client_tidl_info_s* __get_client_tidl_info_element(int pid)
1255 GSList *iter = NULL;
1256 client_tidl_info_s *data = NULL;
1258 int count = g_slist_length(g_client_tidl_info_list);
1262 iter = g_slist_nth(g_client_tidl_info_list, 0);
1263 for (i = 0; i < count; i++) {
1270 if (pid == data->pid)
1274 iter = g_slist_next(iter);
1281 int vcd_client_add_tidl_info(int pid)
1283 /*Check pid is duplicated*/
1284 client_tidl_info_s* info = NULL;
1285 info = __get_client_tidl_info_element(pid);
1288 SLOG(LOG_WARN, TAG_VCD, "[Client Data] Client tidl info pid is already registered");
1289 return VCD_ERROR_NONE;
1292 SLOG(LOG_INFO, TAG_VCD, "[Client Data] There is no tidl info of pid(%d). Create new one.", pid);
1293 info = (client_tidl_info_s*)calloc(1, sizeof(client_tidl_info_s));
1295 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory");
1296 return VCD_ERROR_OUT_OF_MEMORY;
1300 info->notify_cb = NULL;
1301 info->notify_cb_user_data = NULL;
1302 info->feedback_cb = NULL;
1303 info->feedback_cb_user_data = NULL;
1305 g_client_tidl_info_list = g_slist_append(g_client_tidl_info_list, info);
1306 if (NULL == g_client_tidl_info_list) {
1307 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to add new client tidl info");
1312 return VCD_ERROR_OUT_OF_MEMORY;
1314 SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new client tidl info. pid(%d)", pid);
1317 return VCD_ERROR_NONE;
1320 int vcd_client_set_tidl_notify_cb(int pid, rpc_port_stub_vcd_stub_vc_notify_cb_h callback, void* user_data)
1323 client_tidl_info_s* info = NULL;
1324 info = __get_client_tidl_info_element(pid);
1327 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no tidl info in the list. pid(%d)", pid);
1328 return VCD_ERROR_INVALID_PARAMETER;
1332 ret = rpc_port_stub_vcd_stub_vc_notify_cb_clone(callback, &(info->notify_cb));
1334 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to clone notify callback. ret(%d)", ret);
1336 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to clone notify callback. ret(%d)", ret);
1338 info->notify_cb_user_data = user_data;
1340 return VCD_ERROR_NONE;
1343 int vcd_client_unset_tidl_notify_cb(int pid)
1346 client_tidl_info_s* info = NULL;
1347 info = __get_client_tidl_info_element(pid);
1350 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no tidl info in the list. pid(%d)", pid);
1351 return VCD_ERROR_INVALID_PARAMETER;
1355 ret = rpc_port_stub_vcd_stub_vc_notify_cb_destroy(info->notify_cb);
1357 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to destroy notify callback. ret(%d)", ret);
1359 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to destroy notify callback. ret(%d)", ret);
1361 info->notify_cb = NULL;
1362 info->notify_cb_user_data = NULL;
1364 return VCD_ERROR_NONE;
1367 int vcd_client_set_tidl_feedback_cb(int pid, rpc_port_stub_vcd_stub_vc_feedback_cb_h callback, void* user_data)
1370 client_tidl_info_s* info = NULL;
1371 info = __get_client_tidl_info_element(pid);
1374 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no tidl info in the list. pid(%d)", pid);
1375 return VCD_ERROR_INVALID_PARAMETER;
1379 ret = rpc_port_stub_vcd_stub_vc_feedback_cb_clone(callback, &(info->feedback_cb));
1381 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to clone feedback callback. ret(%d)", ret);
1383 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to clone feedback callback. ret(%d)", ret);
1385 info->feedback_cb_user_data = user_data;
1387 return VCD_ERROR_NONE;
1390 int vcd_client_unset_tidl_feedback_cb(int pid)
1393 client_tidl_info_s* info = NULL;
1394 info = __get_client_tidl_info_element(pid);
1397 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no tidl info in the list. pid(%d)", pid);
1398 return VCD_ERROR_INVALID_PARAMETER;
1402 ret = rpc_port_stub_vcd_stub_vc_feedback_cb_destroy(info->feedback_cb);
1404 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to destroy feedback callback. ret(%d)", ret);
1406 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to destroy feedback callback. ret(%d)", ret);
1408 info->feedback_cb = NULL;
1409 info->feedback_cb_user_data = NULL;
1411 return VCD_ERROR_NONE;
1414 int vcd_client_delete_tidl_info(int pid)
1417 client_tidl_info_s* client_tidl_info = NULL;
1420 tmp = __get_client_tidl_info_item(pid);
1422 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid);
1423 return VCD_ERROR_INVALID_PARAMETER;
1426 /*Free client structure*/
1427 client_tidl_info = tmp->data;
1428 if (NULL != client_tidl_info) {
1429 free(client_tidl_info);
1432 /*Delete handle from list*/
1433 g_client_tidl_info_list = g_slist_delete_link(g_client_tidl_info_list, tmp);
1435 return VCD_ERROR_NONE;
1438 client_tidl_info_s* vcd_client_get_tidl_info(int pid)
1440 return __get_client_tidl_info_element(pid);
1443 int vcd_client_get_tidl_list(int** pids, int* pid_count)
1445 if (NULL == pids || NULL == pid_count)
1446 return VCD_ERROR_INVALID_PARAMETER;
1448 int count = g_slist_length(g_client_tidl_info_list);
1451 return VCD_ERROR_OUT_OF_MEMORY;
1454 tmp = (int*)calloc(count, sizeof(int));
1456 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory");
1457 return VCD_ERROR_OUT_OF_MEMORY;
1460 GSList *iter = NULL;
1461 client_tidl_info_s *data = NULL;
1464 iter = g_slist_nth(g_client_tidl_info_list, 0);
1466 while (NULL != iter) {
1473 iter = g_slist_next(iter);
1480 return VCD_ERROR_NONE;
1483 bool vcd_client_is_available(int pid)
1485 vc_client_info_s* client_info = NULL;
1487 client_info = __client_get_element(pid);
1488 if (NULL == client_info) {
1489 SLOG(LOG_WARN, TAG_VCD, "[Client Data] pid(%d) is NOT valid", pid);
1496 int vcd_client_get_ref_count()
1500 count = g_slist_length(g_client_list) + g_slist_length(g_widget_list);
1501 if (0 < g_manager.pid) {
1505 SLOG(LOG_INFO, TAG_VCD, "[Client Data] client count : %d", count);
1510 int vcd_client_get_list(int** pids, int* pid_count)
1512 if (NULL == pids || NULL == pid_count)
1513 return VCD_ERROR_INVALID_PARAMETER;
1515 int count = g_slist_length(g_client_list);
1518 return VCD_ERROR_OUT_OF_MEMORY;
1521 tmp = (int*)calloc(count, sizeof(int));
1523 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory");
1524 return VCD_ERROR_OUT_OF_MEMORY;
1527 GSList *iter = NULL;
1528 vc_client_info_s *data = NULL;
1531 iter = g_slist_nth(g_client_list, 0);
1533 while (NULL != iter) {
1540 iter = g_slist_next(iter);
1547 return VCD_ERROR_NONE;
1550 int vcd_client_set_command_type(int pid, int type)
1552 vc_client_info_s* client_info = NULL;
1554 client_info = __client_get_element(pid);
1555 if (NULL == client_info) {
1556 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] vcd_client_get_pid : pid(%d) is not found", pid);
1557 return VCD_ERROR_INVALID_PARAMETER;
1561 case VC_COMMAND_TYPE_FOREGROUND:
1562 client_info->fg_cmd = true;
1564 case VC_COMMAND_TYPE_BACKGROUND:
1565 client_info->bg_cmd = true;
1568 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] not supported command type(%d)", type);
1569 return VCD_ERROR_INVALID_PARAMETER;
1572 return VCD_ERROR_NONE;
1575 int vcd_client_unset_command_type(int pid, int type)
1577 vc_client_info_s* client_info = NULL;
1579 client_info = __client_get_element(pid);
1580 if (NULL == client_info) {
1581 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] vcd_client_get_pid : pid(%d) is not found", pid);
1582 return VCD_ERROR_INVALID_PARAMETER;
1586 case VC_COMMAND_TYPE_FOREGROUND:
1587 client_info->fg_cmd = false;
1589 case VC_COMMAND_TYPE_BACKGROUND:
1590 client_info->bg_cmd = false;
1593 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] not supported command type(%d)", type);
1594 return VCD_ERROR_INVALID_PARAMETER;
1597 return VCD_ERROR_NONE;
1600 int vcd_client_set_exclusive_command(int pid)
1602 vc_client_info_s* client_info = NULL;
1604 client_info = __client_get_element(pid);
1605 if (NULL == client_info) {
1606 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is not found", pid);
1607 return VCD_ERROR_INVALID_PARAMETER;
1610 client_info->exclusive_cmd = true;
1612 return VCD_ERROR_NONE;
1615 int vcd_client_unset_exclusive_command(int pid)
1617 vc_client_info_s* client_info = NULL;
1619 client_info = __client_get_element(pid);
1620 if (NULL == client_info) {
1621 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is not found", pid);
1622 return VCD_ERROR_INVALID_PARAMETER;
1625 client_info->exclusive_cmd = false;
1627 return VCD_ERROR_NONE;
1630 int vcd_client_save_client_info()
1632 if (0 != vc_info_parser_set_client_info(g_client_list)) {
1633 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to save client info");
1634 return VCD_ERROR_OPERATION_FAILED;
1637 return VCD_ERROR_NONE;
1641 * Functions for widget
1643 GSList* __widget_get_item(int pid)
1645 GSList *iter = NULL;
1646 widget_info_s *data = NULL;
1648 int count = g_slist_length(g_widget_list);
1652 iter = g_slist_nth(g_widget_list, 0);
1653 for (i = 0; i < count; i++) {
1660 if (pid == data->pid)
1664 iter = g_slist_next(iter);
1671 widget_info_s* __widget_get_element(int pid)
1673 GSList *iter = NULL;
1674 widget_info_s *data = NULL;
1676 int count = g_slist_length(g_widget_list);
1680 iter = g_slist_nth(g_widget_list, 0);
1683 while (iter && i < count) {
1687 if (pid == data->pid)
1691 iter = g_slist_next(iter);
1700 int vcd_client_widget_get_list(int** pids, int* pid_count)
1702 if (NULL == pids || NULL == pid_count)
1703 return VCD_ERROR_INVALID_PARAMETER;
1705 int count = g_slist_length(g_widget_list);
1708 return VCD_ERROR_OUT_OF_MEMORY;
1711 tmp = (int*)calloc(count, sizeof(int));
1713 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory");
1714 return VCD_ERROR_OUT_OF_MEMORY;
1717 GSList *iter = NULL;
1718 widget_info_s *data = NULL;
1721 iter = g_slist_nth(g_widget_list, 0);
1722 while (NULL != iter) {
1729 iter = g_slist_next(iter);
1736 return VCD_ERROR_NONE;
1739 int vcd_client_widget_add(int pid)
1741 /*Check pid is duplicated*/
1743 tmp = __widget_get_item(pid);
1746 SLOG(LOG_WARN, TAG_VCD, "[Client Data] widget pid is already registered");
1747 return VCD_ERROR_INVALID_PARAMETER;
1750 widget_info_s *info = (widget_info_s*)calloc(1, sizeof(widget_info_s));
1752 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory");
1753 return VCD_ERROR_OUT_OF_MEMORY;
1757 info->widget_cmd = false;
1759 /* Add item to global list */
1760 g_widget_list = g_slist_append(g_widget_list, info);
1762 if (NULL == g_widget_list) {
1763 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to add new widget");
1768 return VCD_ERROR_OUT_OF_MEMORY;
1770 SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new widget");
1773 #ifdef CLIENT_DATA_DEBUG
1774 __show_client_list();
1776 return VCD_ERROR_NONE;
1779 int vcd_client_widget_delete(int pid)
1782 widget_info_s* widget_info = NULL;
1785 tmp = __widget_get_item(pid);
1787 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid);
1788 return VCD_ERROR_INVALID_PARAMETER;
1791 /*Free client structure*/
1792 widget_info = tmp->data;
1793 if (NULL != widget_info) {
1797 /*Remove handle from list*/
1798 g_widget_list = g_slist_remove_link(g_widget_list, tmp);
1801 #ifdef CLIENT_DATA_DEBUG
1802 __show_client_list();
1805 return VCD_ERROR_NONE;
1808 int vcd_client_widget_get_foreground_pid()
1810 /* 1. Get foreground pid */
1812 if (0 != vcd_config_get_foreground(&fg_pid)) {
1813 SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to get foreground pid");
1814 /* There is no foreground app for voice control */
1817 widget_info_s* widget = NULL;
1819 widget = __widget_get_element(fg_pid);
1820 if (NULL == widget) {
1821 SLOG(LOG_WARN, TAG_VCD, "[Client Data] Not found foreground pid of widget");
1829 bool vcd_client_widget_is_available(int pid)
1831 widget_info_s* widget_info = NULL;
1833 widget_info = __widget_get_element(pid);
1834 if (NULL == widget_info) {
1835 SLOG(LOG_WARN, TAG_VCD, "[Client Data] pid(%d) is NOT valid", pid);
1842 int vcd_client_widget_set_command(int pid)
1844 widget_info_s *info = NULL;
1845 info = __widget_get_element(pid);
1847 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid);
1848 return VCD_ERROR_INVALID_PARAMETER;
1851 info->widget_cmd = true;
1853 return VCD_ERROR_NONE;
1856 int vcd_client_widget_unset_command(int pid)
1858 widget_info_s *info = NULL;
1859 info = __widget_get_element(pid);
1861 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid);
1862 return VCD_ERROR_INVALID_PARAMETER;
1865 info->widget_cmd = false;
1867 return VCD_ERROR_NONE;
1870 int vcd_client_widget_set_asr_result_enabled(int pid, bool enable)
1872 widget_info_s *info = NULL;
1873 info = __widget_get_element(pid);
1875 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid);
1876 return VCD_ERROR_INVALID_PARAMETER;
1879 info->asr_result_enabled = enable;
1881 return VCD_ERROR_NONE;
1884 int vcd_client_widget_get_asr_result_enabled(int pid, bool* enable)
1886 widget_info_s *info = NULL;
1887 info = __widget_get_element(pid);
1889 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid);
1890 return VCD_ERROR_INVALID_PARAMETER;
1893 *enable = info->asr_result_enabled;
1895 return VCD_ERROR_NONE;
1898 int vcd_client_widget_set_waiting_for_recording(int pid, bool waiting)
1901 if (TRUE == waiting && pid != vcd_client_widget_get_foreground_pid()) {
1902 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT foreground pid", pid);
1903 return VCD_ERROR_INVALID_PARAMETER;
1906 g_is_waiting_recording = waiting;
1907 g_waiting_recording_pid = pid;
1908 SLOG(LOG_ERROR, TAG_VCD, "[INFO] Success to set waiting for recording, pid(%d), waiting(%d)", pid, waiting);
1909 return VCD_ERROR_NONE;
1912 int vcd_client_widget_get_waiting_for_recording(int pid, bool* waiting)
1914 if (pid != g_waiting_recording_pid) {
1915 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT waiting pid", pid);
1916 return VCD_ERROR_INVALID_PARAMETER;
1919 *waiting = g_is_waiting_recording;
1920 SLOG(LOG_ERROR, TAG_VCD, "[INFO] Success to get waiting for recording, waiting(%d)", *waiting);
1921 return VCD_ERROR_NONE;
1924 GSList* __get_widget_tidl_info_item(const int pid)
1926 GSList *iter = NULL;
1927 widget_tidl_info_s *data = NULL;
1929 int count = g_slist_length(g_widget_tidl_info_list);
1933 iter = g_slist_nth(g_widget_tidl_info_list, 0);
1934 for (i = 0; i < count; i++) {
1940 if (pid == data->pid)
1944 iter = g_slist_next(iter);
1951 widget_tidl_info_s* __get_widget_tidl_info_element(int pid)
1953 GSList *iter = NULL;
1954 widget_tidl_info_s *data = NULL;
1956 int count = g_slist_length(g_widget_tidl_info_list);
1960 iter = g_slist_nth(g_widget_tidl_info_list, 0);
1961 for (i = 0; i < count; i++) {
1968 if (pid == data->pid)
1972 iter = g_slist_next(iter);
1979 int vcd_client_widget_add_tidl_info(int pid)
1981 /*Check pid is duplicated*/
1982 widget_tidl_info_s* info = NULL;
1983 info = __get_widget_tidl_info_element(pid);
1986 SLOG(LOG_WARN, TAG_VCD, "[Client Data] Widget tidl info pid is already registered");
1987 return VCD_ERROR_NONE;
1990 SLOG(LOG_INFO, TAG_VCD, "[Client Data] There is no tidl info of pid(%d). Create new one.", pid);
1991 info = (widget_tidl_info_s*)calloc(1, sizeof(widget_tidl_info_s));
1993 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory");
1994 return VCD_ERROR_OUT_OF_MEMORY;
1998 info->notify_cb = NULL;
1999 info->notify_cb_user_data = NULL;
2001 info->connected = false;
2002 info->connection_requesting = false;
2005 g_widget_tidl_info_list = g_slist_append(g_widget_tidl_info_list, info);
2006 if (NULL == g_widget_tidl_info_list) {
2007 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to add new widget tidl info");
2012 return VCD_ERROR_OUT_OF_MEMORY;
2014 SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new widget tidl info. pid(%d)", pid);
2017 return VCD_ERROR_NONE;
2020 int vcd_client_widget_set_tidl_notify_cb(int pid, rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_h callback, void* user_data)
2023 widget_tidl_info_s* info = NULL;
2024 info = __get_widget_tidl_info_element(pid);
2027 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no tidl info in the list. pid(%d)", pid);
2028 return VCD_ERROR_INVALID_PARAMETER;
2032 ret = rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_clone(callback, &(info->notify_cb));
2034 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to clone notify callback. ret(%d)", ret);
2036 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to clone notify callback. ret(%d)", ret);
2038 info->notify_cb_user_data = user_data;
2040 return VCD_ERROR_NONE;
2043 int vcd_client_widget_unset_tidl_notify_cb(int pid)
2046 widget_tidl_info_s* info = NULL;
2047 info = __get_widget_tidl_info_element(pid);
2050 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no tidl info in the list. pid(%d)", pid);
2051 return VCD_ERROR_INVALID_PARAMETER;
2055 ret = rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_destroy(info->notify_cb);
2057 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to destroy notify callback. ret(%d)", ret);
2059 SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to destroy notify callback. ret(%d)", ret);
2061 info->notify_cb = NULL;
2062 info->notify_cb_user_data = NULL;
2064 return VCD_ERROR_NONE;
2067 int vcd_client_widget_delete_tidl_info(int pid)
2070 widget_tidl_info_s* widget_tidl_info = NULL;
2073 tmp = __get_widget_tidl_info_item(pid);
2075 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid);
2076 return VCD_ERROR_INVALID_PARAMETER;
2079 /*Free widget structure*/
2080 widget_tidl_info = tmp->data;
2081 if (NULL != widget_tidl_info) {
2082 free(widget_tidl_info);
2085 /*Delete handle from list*/
2086 g_widget_tidl_info_list = g_slist_delete_link(g_widget_tidl_info_list, tmp);
2088 return VCD_ERROR_NONE;
2091 widget_tidl_info_s* vcd_client_widget_get_tidl_info(int pid)
2093 return __get_widget_tidl_info_element(pid);
2096 GSList* vcd_client_widget_get_tidl_info_list()
2098 return g_widget_tidl_info_list;
2102 void vcd_client_update_foreground_pid()
2104 int tmp_pid = VC_RUNTIME_INFO_NO_FOREGROUND;
2105 vcd_config_get_foreground(&tmp_pid);
2107 int pid = VC_RUNTIME_INFO_NO_FOREGROUND;
2108 int ret = aul_window_get_focused_pid(&pid);
2110 SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get focused pid, ret(%d)", ret);
2112 SLOG(LOG_INFO, TAG_VCD, "[INFO] Foreground pid (%d), Focused pid (%d)", tmp_pid, pid);
2114 GSList *iter = NULL;
2115 vc_client_info_s *data = NULL;
2117 int count = g_slist_length(g_client_list);
2121 SLOG(LOG_INFO, TAG_VCD, "No Client");
2123 iter = g_slist_nth(g_client_list, 0);
2124 for (i = 0; i < count; i++) {
2131 SLOG(LOG_INFO, TAG_VCD, "[%dth] pid(%d)", i, data->pid);
2132 if (pid == data->pid) {
2133 SLOG(LOG_INFO, TAG_VCD, "[INFO] foreground pid (%d)", data->pid);
2134 vcd_config_set_foreground(data->pid, true);
2135 if (tmp_pid != data->pid) {
2136 SLOG(LOG_INFO, TAG_VCD, "[INFO] foreground pid is different");
2141 iter = g_slist_next(iter);
2145 widget_info_s *widget_data = NULL;
2146 count = g_slist_length(g_widget_list);
2149 SLOG(LOG_INFO, TAG_VCD, "No widget");
2151 iter = g_slist_nth(g_widget_list, 0);
2152 for (i = 0; i < count; i++) {
2156 widget_data = iter->data;
2158 if (NULL != widget_data) {
2159 SLOG(LOG_INFO, TAG_VCD, "[%dth] pid(%d)", i, widget_data->pid);
2160 if (pid == widget_data->pid) {
2161 SLOG(LOG_INFO, TAG_VCD, "[INFO] foreground pid (%d)", widget_data->pid);
2162 vcd_config_set_foreground(widget_data->pid, true);
2163 if (tmp_pid != widget_data->pid) {
2164 SLOG(LOG_INFO, TAG_VCD, "[INFO] foreground pid is changed");
2169 iter = g_slist_next(iter);
2173 SLOG(LOG_INFO, TAG_VCD, "[INFO] No foreground");
2174 vcd_config_set_foreground(VC_RUNTIME_INFO_NO_FOREGROUND, true);
2181 GSList* __get_setting_tidl_info_item(const int pid)
2183 GSList *iter = NULL;
2184 setting_tidl_info_s *data = NULL;
2186 int count = g_slist_length(g_setting_tidl_info_list);
2190 iter = g_slist_nth(g_setting_tidl_info_list, 0);
2191 for (i = 0; i < count; i++) {
2197 if (pid == data->pid)
2201 iter = g_slist_next(iter);
2208 setting_tidl_info_s* __get_setting_tidl_info_element(int pid)
2210 GSList *iter = NULL;
2211 setting_tidl_info_s *data = NULL;
2213 int count = g_slist_length(g_setting_tidl_info_list);
2217 iter = g_slist_nth(g_setting_tidl_info_list, 0);
2218 for (i = 0; i < count; i++) {
2225 if (pid == data->pid)
2229 iter = g_slist_next(iter);
2236 int vcd_client_setting_add_tidl_info(int pid)
2238 /*Check pid is duplicated*/
2239 setting_tidl_info_s* info = NULL;
2240 info = __get_setting_tidl_info_element(pid);
2243 SLOG(LOG_WARN, TAG_VCD, "[Setting Data] Setting tidl info pid is already registered");
2244 return VCD_ERROR_NONE;
2247 SLOG(LOG_INFO, TAG_VCD, "[Setting Data] There is no tidl info of pid(%d). Create new one.", pid);
2248 info = (setting_tidl_info_s*)calloc(1, sizeof(setting_tidl_info_s));
2250 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory");
2251 return VCD_ERROR_OUT_OF_MEMORY;
2255 info->notify_cb = NULL;
2256 info->notify_cb_user_data = NULL;
2258 g_setting_tidl_info_list = g_slist_append(g_setting_tidl_info_list, info);
2259 if (NULL == g_setting_tidl_info_list) {
2260 SLOG(LOG_ERROR, TAG_VCD, "[Setting Data ERROR] Fail to add new setting client tidl info");
2265 return VCD_ERROR_OUT_OF_MEMORY;
2267 SLOG(LOG_INFO, TAG_VCD, "[Setting Data SUCCESS] Add new setting client tidl info. pid(%d)", pid);
2270 return VCD_ERROR_NONE;
2273 int vcd_client_setting_set_tidl_notify_cb(int pid, rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_h callback, void* user_data)
2276 setting_tidl_info_s* info = NULL;
2277 info = __get_setting_tidl_info_element(pid);
2280 SLOG(LOG_ERROR, TAG_VCD, "[Setting Data ERROR] There is no tidl info in the list. pid(%d)", pid);
2281 return VCD_ERROR_INVALID_PARAMETER;
2285 ret = rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_clone(callback, &(info->notify_cb));
2287 SLOG(LOG_ERROR, TAG_VCD, "[Setting Data ERROR] Fail to clone notify callback. ret(%d)", ret);
2289 SLOG(LOG_INFO, TAG_VCD, "[Setting Data] Succeed to clone notify callback. ret(%d)", ret);
2291 info->notify_cb_user_data = user_data;
2293 return VCD_ERROR_NONE;
2296 int vcd_client_setting_unset_tidl_notify_cb(int pid)
2299 setting_tidl_info_s* info = NULL;
2300 info = __get_setting_tidl_info_element(pid);
2303 SLOG(LOG_ERROR, TAG_VCD, "[Setting Data ERROR] There is no tidl info in the list. pid(%d)", pid);
2304 return VCD_ERROR_INVALID_PARAMETER;
2308 ret = rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_destroy(info->notify_cb);
2310 SLOG(LOG_ERROR, TAG_VCD, "[Setting Data ERROR] Fail to destroy notify callback. ret(%d)", ret);
2312 SLOG(LOG_INFO, TAG_VCD, "[Setting Data] Succeed to destroy notify callback. ret(%d)", ret);
2314 info->notify_cb = NULL;
2315 info->notify_cb_user_data = NULL;
2317 return VCD_ERROR_NONE;
2320 int vcd_client_setting_delete_tidl_info(int pid)
2323 setting_tidl_info_s* setting_tidl_info = NULL;
2326 tmp = __get_setting_tidl_info_item(pid);
2328 SLOG(LOG_ERROR, TAG_VCD, "[Setting Data ERROR] pid(%d) is NOT valid", pid);
2329 return VCD_ERROR_INVALID_PARAMETER;
2332 /*Free setting client structure*/
2333 setting_tidl_info = tmp->data;
2334 if (NULL != setting_tidl_info) {
2335 free(setting_tidl_info);
2338 /*Delete handle from list*/
2339 g_setting_tidl_info_list = g_slist_delete_link(g_setting_tidl_info_list, tmp);
2341 return VCD_ERROR_NONE;
2344 setting_tidl_info_s* vcd_client_setting_get_tidl_info(int pid)
2346 return __get_setting_tidl_info_element(pid);
2349 int vcd_client_setting_get_tidl_list(int** pids, int* pid_count)
2351 if (NULL == pids || NULL == pid_count)
2352 return VCD_ERROR_INVALID_PARAMETER;
2354 int count = g_slist_length(g_setting_tidl_info_list);
2357 return VCD_ERROR_OUT_OF_MEMORY;
2360 tmp = (int*)calloc(count, sizeof(int));
2362 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory");
2363 return VCD_ERROR_OUT_OF_MEMORY;
2366 GSList *iter = NULL;
2367 setting_tidl_info_s *data = NULL;
2370 iter = g_slist_nth(g_setting_tidl_info_list, 0);
2372 while (NULL != iter) {
2379 iter = g_slist_next(iter);
2386 return VCD_ERROR_NONE;