check null before use when dbus close connection
[platform/core/uifw/voice-control.git] / server / vcd_client_data.h
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 #ifndef __VCD_CLIENT_DATA_H_
19 #define __VCD_CLIENT_DATA_H_
20
21 #include <glib.h>
22 #include "vc_command.h"
23 #include "vc_info_parser.h"
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 typedef struct {
30         int     pid;
31         int     cmd_count;
32
33         GSList* cmds;
34 } command_list_s;
35
36 typedef struct {
37         int total_cmd_count;
38
39         /* Foreground application */
40         int foreground;
41         GSList* widget_cmds;
42         GSList* foreground_cmds;
43
44         /* Manager application */
45         GSList* system_cmds;
46         GSList* exclusive_system_cmds;
47         GSList* system_background_cmds;
48
49         /* Other applications */
50         int     bg_cmd_count;
51         GSList* background_cmds;
52 } current_commands_list_s;
53
54
55 typedef struct {
56         int     pid;
57         char*   appid;
58         bool    manager_cmd;
59         bool    exclusive_cmd_option;
60 } manager_info_s;
61
62 typedef struct {
63         int     pid;
64         bool    widget_cmd;
65         bool    asr_result_enabled;
66 } widget_info_s;
67
68 typedef enum {
69         VCD_RECOGNITION_MODE_STOP_BY_SILENCE,           /**< Default mode */
70         VCD_RECOGNITION_MODE_RESTART_AFTER_REJECT,      /**< Restart recognition after rejected result */
71         VCD_RECOGNITION_MODE_RESTART_CONTINUOUSLY,      /**< Continuously restart recognition - not support yet*/
72         VCD_RECOGNITION_MODE_MANUAL                     /**< Start and stop manually without silence */
73 } vcd_recognition_mode_e;
74
75
76 /*
77 * Command API
78 */
79 typedef bool (* client_foreach_command_cb)(int id, int type, int format, const char* command, const char* param, int domain, void* user_data);
80
81 int vcd_client_command_collect_command();
82
83 int vcd_client_get_length();
84
85 int vcd_client_foreach_command(client_foreach_command_cb callback, void* user_data);
86
87 int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result);
88
89 int vcd_client_get_cmd_info_from_result_id(int result_id, int* pid, int* cmd_type, vc_cmd_s** result);
90
91 int vcd_client_set_slience_detection(bool value);
92
93 bool vcd_client_get_slience_detection();
94
95 int vcd_client_set_recognition_mode(vcd_recognition_mode_e mode);
96
97 vcd_recognition_mode_e vcd_client_get_recognition_mode();
98
99 /*
100 * Manager API
101 */
102 int vcd_client_manager_set(int pid);
103
104 int vcd_client_manager_unset();
105
106 int vcd_client_manager_unset_appid();
107
108 bool vcd_client_manager_is_valid(int pid);
109
110 int vcd_client_manager_set_command(int pid);
111
112 int vcd_client_manager_unset_command(int pid);
113
114 int vcd_client_manager_set_demandable_client(int pid, GSList* client_list);
115
116 bool vcd_client_manager_check_demandable_client(int pid);
117
118 bool vcd_client_manager_get_exclusive();
119
120 int vcd_client_manager_set_exclusive(bool value);
121
122 int vcd_client_manager_get_pid();
123
124 int vcd_client_manager_get_appid(char** appid);
125
126 int vcd_client_manager_set_result_text(const char* result);
127
128 char* vcd_client_manager_get_result_text();
129
130 bool vcd_client_manager_is_system_command_valid(int pid);
131
132 /*
133 * client API
134 */
135 int vcd_client_add(int pid);
136
137 int vcd_client_delete(int pid);
138
139 bool vcd_client_is_available(int pid);
140
141 int vcd_client_get_ref_count();
142
143 int vcd_client_get_list(int** pids, int* pid_count);
144
145 int vcd_client_set_command_type(int pid, int type);
146
147 int vcd_client_unset_command_type(int pid, int type);
148
149 int vcd_client_set_exclusive_command(int pid);
150
151 int vcd_client_unset_exclusive_command(int pid);
152
153 int vcd_client_save_client_info();
154
155 void vcd_client_update_foreground_pid();
156 /*
157 * widget API
158 */
159 int vcd_client_widget_get_list(int** pids, int* pid_count);
160
161 int vcd_client_widget_add(int pid);
162
163 int vcd_client_widget_delete(int pid);
164
165 bool vcd_client_widget_is_available(int pid);
166
167 int vcd_client_widget_get_foreground_pid();
168
169 int vcd_client_widget_set_command(int pid);
170
171 int vcd_client_widget_unset_command(int pid);
172
173 int vcd_client_widget_set_asr_result_enabled(int pid, bool enable);
174
175 int vcd_client_widget_get_asr_result_enabled(int pid, bool* enable);
176
177 #ifdef __cplusplus
178 }
179 #endif
180
181 #endif  /* __VCD_CLIENT_DATA_H_ */
182