Move function definition to aul header
[platform/core/appfw/aul-1.git] / include / aul_widget.h
1 /*
2  * Copyright (c) 2017 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 #pragma once
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 /**
24  * @par Description:
25  *      Widget information handle.
26  */
27 typedef struct aul_widget_info_s *aul_widget_info_h;
28
29 /**
30  * @par Description:
31  *      Called to get the widget information
32  * @param[in]   info            The handle of the widget information
33  * @param[in]   user_data       The user data passed from the foreach function
34  *
35  * @pre aul_widget_info_foreach() will invoke this callback.
36  * @see aul_widget_info_foreach()
37  */
38 typedef void (*aul_widget_info_cb)(aul_widget_info_h info, void *user_data);
39
40 /**
41  * @par Description:
42  *      Retrieves all widget information of running widget applications.
43  * @privlevel   platform
44  * @privilege   %http://tizen.org/privilege/internal/default/platform
45  * @param[in]   callback        The callback function to invoke
46  * @param[in]   user_data       The user data to be passed to the callback function
47  * @return      @c 0 on success,
48  *              otherwise a negative error value
49  * @post This function invokes aul_widget_info_cb() for each widget information.
50  * @see aul_widget_info_cb()
51  */
52 int aul_widget_info_foreach(aul_widget_info_cb callback, void *user_data);
53 int aul_widget_info_foreach_for_uid(aul_widget_info_cb callback,
54                 void *user_data, uid_t uid);
55
56 /**
57  * @par Description:
58  *      Gets the process ID with the given handle.
59  * @param[in]   info            The handle of the widget information
60  * @param[out]  pid             The process ID
61  * @return      @c 0 on success,
62  *              otherwise a negative error value
63  */
64 int aul_widget_info_get_pid(aul_widget_info_h info, pid_t *pid);
65
66 /**
67  * @par Description:
68  *      Gets the surface ID with the given handle.
69  * @param[in]   info            The handle of the widget information
70  * @param[out]  surf            The surface ID
71  * @return      @c 0 on success,
72  *              otherwise a negative error value
73  */
74 int aul_widget_info_get_surface_id(aul_widget_info_h info, unsigned int *surf);
75
76 /**
77  * @par Description:
78  *      Gets the widget ID with the given handle.
79  * @param[in]   info            The handle of the widget information
80  * @param[out]  widget_id       The widget ID
81  * @return      @c 0 on success,
82  *              otherwise a negative error value
83  * @remarks The @a widget_id must be released using free().
84  */
85 int aul_widget_info_get_widget_id(aul_widget_info_h info, char **widget_id);
86
87 /**
88  * @par Description:
89  *      Gets the widget instance ID with the given handle.
90  * @param[in]   info            The handle of the widget information
91  * @param[out]  instance_id     The widget instance ID
92  * @return      @c 0 on success,
93  *              otherwise a negative error value
94  * @remarks The @a instance_id must be released using free().
95  */
96 int aul_widget_info_get_instance_id(aul_widget_info_h info, char **instance_id);
97
98 /**
99  * @par Description:
100  *      Gets the application ID with the given handle.
101  * @param[in]   info            The handle of the widget information
102  * @param[out]  app_id          The application ID
103  * @return      @c 0 on success,
104  *              otherwise a negative error value
105  * @remarks The @a app_id must be released using free().
106  */
107 int aul_widget_info_get_app_id(aul_widget_info_h info, char **app_id);
108
109 /**
110  * @par Description:
111  *      Gets the package ID with the given handle.
112  * @param[in]   info            The handle of the widget information
113  * @param[out]  package_id      The package ID
114  * @return      @c 0 on success,
115  *              otherwise a negative error value
116  * @remarks The @a app_id must be released using free().
117  */
118 int aul_widget_info_get_package_id(aul_widget_info_h info, char **package_id);
119
120 /**
121  * @par Description:
122  *      Gets the path with the given handle.
123  * @param[in]   info            The handle of the widget information
124  * @param[out]  app_path        The path of the widget application
125  * @return      @c 0 on success,
126  *              otherwise a negative error value
127  * @remarks The @a app_id must be released using free().
128  */
129 int aul_widget_info_get_app_path(aul_widget_info_h info, char **app_path);
130
131 /**
132  * @par Description:
133  *      Change app status.
134  * @param[in]   widget_id       The widget app id
135  * @param[in]   status          The widget app status
136  * @return      @c 0 on success,
137  *              otherwise a negative error value
138  */
139 int aul_widget_instance_change_status(const char *widget_id, const char *status);
140
141 /**
142  * @par Description:
143  *      Writes file log.
144  * @param[in]   tag             The log tag
145  * @param[in]   format          The log foramt
146  * @return      @c 0 on success,
147  *              otherwise a negative error value
148  */
149 int aul_widget_write_log(const char *tag, const char *format, ...);
150
151 int aul_widget_service_set_disable(const char *widget_id, bool is_disable);
152
153 /**
154  * @brief Called when the widget event is delivered.
155  * @since_tizen 5.5
156  *
157  * @param[in]   event_name      The event name
158  * @param[in]   event_data      The event data
159  * @param[in]   user_data       The user data passed from the registration function
160  *
161  * @see aul_widget_set_event_cb()
162  */
163 typedef void (*aul_widget_event_cb)(const char *event_name, bundle *event_data,
164                 void *user_data);
165
166 /**
167  * @brief Definition for AUL widget event: Saves image.
168  * @since_tizen 5.5
169  */
170 #define AUL_WIDGET_EVENT_SAVE_IMAGE "save.image"
171
172 /**
173  * @brief Registers the event callback function.
174  * @since_tizen 5.5
175  *
176  * @param[in]   callback        The callback function
177  * @param[in]   user_data       The user data to be passed to the callback function
178  * @return      @c 0 on success,
179  *              otherwise a negative error value
180  *
181  * @see aul_widget_event_cb()
182  * @see aul_widget_unset_event_cb()
183  */
184 int aul_widget_set_event_cb(aul_widget_event_cb callback, void *user_data);
185
186 /**
187  * @brief Unregisters the event callback function.
188  * @since_tizen 5.5
189  *
190  * @return      @c 0 on success,
191  *              otherwise a negative error value
192  *
193  * @see aul_widget_set_event_cb()
194  */
195 int aul_widget_unset_event_cb(void);
196
197 /**
198  * @brief Sends the widget event.
199  * @since_tizen 5.5
200  * @privlevel   platform
201  * @privilege   %http://tizen.org/privilege/internal/default/platform
202  *
203  * @param[in]   event_name      The event name
204  * @param[in]   event_data      The event data
205  * @return      @c 0 on success,
206  *              otherwise a negative error value
207  *
208  * @see aul_widget_set_event_cb()
209  */
210 int aul_widget_send_event(const char *event_name, bundle *event_data);
211
212
213 int aul_widget_send_status_to_service(const char *class_id,
214         const char *instance_id, const char *sender_pkgid, int status);
215
216 int aul_widget_send_status_to_viewer(const char *class_id,
217         const char *instance_id, const char *viewer_endpoint,
218         int status, int err, bundle *extra);
219
220 #ifdef __cplusplus
221 }
222 #endif