2 * Copyright (c) 2019 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 #ifndef __TIZEN_APPFW_COMPONENT_CONTEXT_H__
18 #define __TIZEN_APPFW_COMPONENT_CONTEXT_H__
21 #include <sys/types.h>
29 * @file component_context.h
33 * @addtogroup CAPI_COMPONENT_CONTEXT_MODULE
39 * @brief Component context handle.
42 typedef void *component_context_h;
45 * @brief Enumeration for the component state.
49 COMPONENT_STATE_INITIALIZED, /**< The initialized state. This is the state when the component is constructed but the create callback is not called yet */
50 COMPONENT_STATE_CREATED, /**< The created state. This state is reached after the create callback is called. */
51 COMPONENT_STATE_STARTED, /**< The started state. This state is reached after the start callback is called. */
52 COMPONENT_STATE_RESUMED, /**< The resumed state. This state is reached after the resume callback is called. */
53 COMPONENT_STATE_PAUSED, /**< The paused state. This state is reached after the pause callback is called. */
54 COMPONENT_STATE_DESTROYED, /**< The destroyed state. This state is reached right before the destroy callback call. */
58 * @brief Destroys the component context handle and releases all its resources.
61 * @param[in] handle The component context handle
62 * @return @c 0 on success,
63 * otherwise a negative error value
64 * @retval #COMPONENT_MANAGER_ERROR_NONE Successful
65 * @retval #COMPONENT_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
67 int component_context_destroy(component_context_h handle);
70 * @brief Gets the application ID of the component.
72 * @remarks You MUST release @c app_id using free().
74 * @param[in] handle The component context handle
75 * @param[out] app_id The application ID
76 * @return @c 0 on success,
77 * otherwise a negative error value
78 * @retval #COMPONENT_MANAGER_ERROR_NONE Successful
79 * @retval #COMPONENT_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
80 * @retval #COMPONENT_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
82 int component_context_get_app_id(component_context_h handle, char **app_id);
85 * @brief Gets the ID of the component.
87 * @remarks You MUST release @c comp_id using free().
89 * @param[in] handle The component context handle
90 * @param[out] component_id The component ID
91 * @return @c 0 on success,
92 * otherwise a negative error value
93 * @retval #COMPONENT_MANAGER_ERROR_NONE Successful
94 * @retval #COMPONENT_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
95 * @retval #COMPONENT_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
97 int component_context_get_component_id(component_context_h handle, char **component_id);
100 * @brief Gets the instance ID of the component.
102 * @remarks You MUST release @c instance_id using free().
104 * @param[in] handle The component context handle
105 * @param[out] instance_id The instance ID
106 * @return @c 0 on success,
107 * otherwise a negative error value
108 * @retval #COMPONENT_MANAGER_ERROR_NONE Successful
109 * @retval #COMPONENT_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
110 * @retval #COMPONENT_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
112 int component_context_get_instance_id(component_context_h handle, char **instance_id);
115 * @brief Gets the state of the component.
118 * @param[in] handle The component context handle
119 * @param[out] state The component state
120 * @return @c 0 on success,
121 * otherwise a negative error value
122 * @retval #COMPONENT_MANAGER_ERROR_NONE Successful
123 * @retval #COMPONENT_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
125 int component_context_get_component_state(component_context_h handle, component_state_e *state);
128 * @brief Checks whether the component is terminated or not.
131 * @param[in] handle The component context handle
132 * @param[out] terminated @c true if the component is terminated, \n
133 * otherwise @c false if the component is running
134 * @return @c 0 on success,
135 * otherwise a negative error value
136 * @retval #COMPONENT_MANAGER_ERROR_NONE Successful
137 * @retval #COMPONENT_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
138 * @retval #COMPONENT_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
139 * @retval #COMPONENT_MANAGER_ERROR_IO_ERROR I/O error
141 int component_context_is_terminated(component_context_h handle, bool *terminated);
144 * @brief Checks whether the component is running as sub component of the group.
147 * @param[in] handle The component context handle
148 * @param[out] is_subcomponent @c true if the sub component of the group, \n
149 * otherwise @c false if the main component of the group
150 * @return @c 0 on success,
151 * otherwise a negative error value
152 * @retval #COMPONENT_MANAGER_ERROR_NONE Successful
153 * @retval #COMPONENT_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
155 int component_context_is_subcomponent(component_context_h handle, bool *is_subcomponent);
158 * @brief Clones the component context handle.
160 * @remarks The @a clone should be released using component_context_destroy().
162 * @param[out] clone A newly created component context handle, if cloning is successful
163 * @param[in] handle The component context handle
164 * @return @c 0 on success,
165 * otherwise a negative error value
166 * @retval #COMPONENT_MANAGER_ERROR_NONE Successful
167 * @retval #COMPONENT_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
168 * @retval #COMPONENT_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
170 int component_context_clone(component_context_h *clone, component_context_h handle);
180 #endif /* __TIZEN_APPFW_COMPONENT_CONTEXT_H__ */