2 * Copyright (c) 2011 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_SERVICE_APP_H__
19 #define __TIZEN_APPFW_SERVICE_APP_H__
22 #include <app_control.h>
23 #include <app_common.h>
30 * @addtogroup CAPI_SERVICE_APP_MODULE
36 * @brief Called at the start of the agent application.
38 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
40 * @param[in] user_data The user data passed from the callback registration function
41 * @return @c true on success,
43 * @pre service_app_main() will invoke this callback function.
44 * @see service_app_main()
45 * @see #service_app_lifecycle_callback_s
47 typedef bool (*service_app_create_cb) (void *user_data);
51 * @brief Called once after the main loop of the agent application exits.
53 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
55 * @param[in] user_data The user data passed from the callback registration function
56 * @see service_app_main()
57 * @see #service_app_lifecycle_callback_s
59 typedef void (*service_app_terminate_cb) (void *user_data);
63 * @brief Called when another application sends the launch request to the agent application.
65 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
67 * @param[in] app_control The handle to the app_control
68 * @param[in] user_data The user data passed from the callback registration function
69 * @see service_app_main()
70 * @see #service_app_lifecycle_callback_s
71 * @see @ref CAPI_APP_CONTROL_MODULE API
73 typedef void (*service_app_control_cb) (app_control_h app_control, void *user_data);
77 * @brief The structure type containing the set of callback functions for handling application events.
78 * @details It is one of the input parameters of the service_app_efl_main() function.
80 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
82 * @see service_app_main()
83 * @see service_app_create_cb()
84 * @see service_app_terminate_cb()
85 * @see service_app_control_cb()
88 service_app_create_cb create; /**< This callback function is called at the start of the application. */
89 service_app_terminate_cb terminate; /**< This callback function is called once after the main loop of the application exits. */
90 service_app_control_cb app_control; /**< This callback function is called when another application sends the launch request to the application. */
91 } service_app_lifecycle_callback_s;
95 * @brief Adds the system event handler
97 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
98 * @remarks The service application can handle low memory event, low battery event, language setting changed event and region format changed event.
99 * @param[out] handler The event handler
100 * @param[in] event_type The system event type
101 * @param[in] callback The callback function
102 * @param[in] user_data The user data to be passed to the callback function
104 * @return 0 on success, otherwise a negative error value
105 * @retval #APP_ERROR_NONE Successfull
106 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
107 * @retval #APP_ERROR_OUT_OF_MEMORY Out of memory
109 * @see app_event_type_e
111 * @see service_app_remove_event_handler
113 int service_app_add_event_handler(app_event_handler_h *handler, app_event_type_e event_type, app_event_cb callback, void *user_data);
117 * @brief Removes registered event handler
119 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
120 * @param[in] event_handler The event handler
122 * @return 0 on success, otherwise a negative error value
123 * @retval #APP_ERROR_NONE Successfull
124 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
126 * @see service_app_add_event_handler
128 int service_app_remove_event_handler(app_event_handler_h event_handler);
132 * @brief Runs the main loop of the application until service_app_exit() is called.
134 * @details This function is the main entry point of the Tizen service application.
135 * This main loop supports event handling for the GMainLoop and the Ecore Main Loop.
137 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
139 * @param[in] argc The argument count
140 * @param[in] argv The argument vector
141 * @param[in] callback The set of callback functions to handle application events
142 * @param[in] user_data The user data to be passed to the callback functions
144 * @return @c 0 on success,
145 * otherwise a negative error value.
146 * @retval #APP_ERROR_NONE Successful
147 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
148 * @retval #APP_ERROR_INVALID_CONTEXT The application is illegally launched, not launched by the launch system.
149 * @retval #APP_ERROR_ALREADY_RUNNING The main loop has already started
151 * @see service_app_create_cb()
152 * @see service_app_terminate_cb()
153 * @see service_app_control_cb()
154 * @see service_app_exit()
155 * @see #service_app_lifecycle_callback_s
157 int service_app_main(int argc, char **argv, service_app_lifecycle_callback_s *callback, void *user_data);
161 * @brief Exits the main loop of the application.
163 * @details The main loop of the application stops and service_app_terminate_cb() is invoked.
165 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
167 * @see service_app_main()
168 * @see service_app_terminate_cb()
170 void service_app_exit(void);
180 #endif /* __TIZEN_APPFW_SERVICE_APP_H__ */