2 * Copyright (c) 2011 - 2016 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.
18 #ifndef __TIZEN_APPFW_APP_CONTEXT_H
19 #define __TIZEN_APPFW_APP_CONTEXT_H
21 #include <sys/types.h>
33 * @addtogroup CAPI_APP_CONTEXT_MODULE
39 * @brief Application context handle.
40 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
42 typedef struct app_context_s *app_context_h;
46 * @brief Enumeration for Application Context Event.
47 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
50 APP_CONTEXT_EVENT_LAUNCHED, /**< The application is launched */
51 APP_CONTEXT_EVENT_TERMINATED, /**< The application is terminated */
52 } app_context_event_e;
56 * @brief Enumeration for the application state.
60 APP_STATE_UNDEFINED, /**< The undefined state */
61 APP_STATE_FOREGROUND, /**< The UI application is running in the foreground. */
62 APP_STATE_BACKGROUND, /**< The UI application is running in the background. */
63 APP_STATE_SERVICE, /**< The Service application is running. */
64 APP_STATE_TERMINATED, /**< The application is terminated. */
69 * @brief Destroys the application context handle and releases all its resources.
70 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
71 * @param[in] app_context The application context handle
72 * @return @c 0 on success,
73 * otherwise a negative error value
74 * @retval #APP_MANAGER_ERROR_NONE Successful
75 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
76 * @see app_manager_foreach_app_context()
77 * @see app_manager_get_app_context()
79 int app_context_destroy(app_context_h app_context);
83 * @deprecated Deprecated since 2.3.1. Use app_context_get_app_id() instead.
84 * @brief Gets the application ID with the given application context.
85 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
86 * @remarks You must release @a package using free().
87 * @param[in] app_context The application context
88 * @param[out] package The application ID of the given application context
89 * @return @c 0 on success,
90 * otherwise a negative error value
91 * @retval #APP_MANAGER_ERROR_NONE Successful
92 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
93 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
95 int app_context_get_package(app_context_h app_context, char **package) TIZEN_DEPRECATED_API;
99 * @brief Gets the application ID with the given application context.
100 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
101 * @remarks You must release @a app_id using free().
102 * @param[in] app_context The application context
103 * @param[out] app_id The application ID of the given application context
104 * @return @c 0 on success,
105 * otherwise a negative error value
106 * @retval #APP_MANAGER_ERROR_NONE Successful
107 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
108 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
110 int app_context_get_app_id(app_context_h app_context, char **app_id);
114 * @brief Gets the process ID with the given application context.
115 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
116 * @param[in] app_context The application context
117 * @param[out] pid The process ID of the given application context
118 * @return @c 0 on success,
119 * otherwise a negative error value
120 * @retval #APP_MANAGER_ERROR_NONE Successful
121 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
123 int app_context_get_pid(app_context_h app_context, pid_t *pid);
127 * @brief Gets the package id with the given application context.
129 * @remarks You must release @a pkg_id using free().
130 * @param[in] app_context The application context
131 * @param[out] pkg_id The package ID of the given application context
132 * @return @c 0 on success,
133 * otherwise a negative error value
134 * @retval #APP_MANAGER_ERROR_NONE Successful
135 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
136 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
138 int app_context_get_package_id(app_context_h app_context, char **pkg_id);
142 * @brief Gets the application state with the given application context.
144 * @remarks Note that application's state might be changed after you get app_context.
145 * This function just returns the state of application when you get the app_context.
146 * @param[in] app_context The application context
147 * @param[out] state The application state of the given application context
148 * @return @c 0 on success,
149 * otherwise a negative error value
150 * @retval #APP_MANAGER_ERROR_NONE Successful
151 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
153 int app_context_get_app_state(app_context_h app_context, app_state_e *state);
157 * @brief Checks whether the application with the given application context is terminated.
158 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
159 * @param[in] app_context The application context
160 * @param[out] terminated @c true if the application is terminated, \n
161 * otherwise @c false if the application is running
162 * @return @c 0 on success,
163 * otherwise a negative error value
164 * @retval #APP_MANAGER_ERROR_NONE Successful
165 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
167 int app_context_is_terminated(app_context_h app_context, bool *terminated);
171 * @brief Checks whether two application contexts are equal.
172 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
173 * @param[in] lhs The first application context to compare
174 * @param[in] rhs The second application context to compare
175 * @param[out] equal @c true if the application contexts are equal, \n
176 * otherwise @c false if they are not equal
177 * @return @c 0 on success,
178 * otherwise a negative error value
179 * @retval #APP_MANAGER_ERROR_NONE Successful
180 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
182 int app_context_is_equal(app_context_h lhs, app_context_h rhs, bool *equal);
186 * @brief Checks whether the application is running as a sub application of the application group.
188 * @param[in] app_context The application context
189 * @param[out] is_sub_app @c true if the sub application of the group, \n
190 * otherwise @c false if the main application of the group
191 * @return @c 0 on success,
192 * otherwise a negative error value
193 * @retval #APP_MANAGER_ERROR_NONE Successful
194 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
196 int app_context_is_sub_app(app_context_h app_context, bool *is_sub_app);
199 * @brief Clones the application context handle.
200 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
201 * @remarks The @a clone should be released using app_context_destroy()
202 * @param[out] clone The newly created application context handle, if cloning is successful
203 * @param[in] app_context The application context
204 * @return @c 0 on success,
205 * otherwise a negative error value
206 * @retval #APP_MANAGER_ERROR_NONE Successful
207 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
208 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
210 int app_context_clone(app_context_h *clone, app_context_h app_context);
221 #endif /* __TIZEN_APPFW_APP_CONTEXT_H */