4 * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #ifndef __SERVICE_ADAPTOR_H__
21 #define __SERVICE_ADAPTOR_H__
24 #define API __attribute__ ((visibility("default")))
35 * @addtogroup SERVICE_ADAPTOR_MODULE
40 * @brief Type of service in plugin
42 typedef enum _service_plugin_type_e
44 SERVICE_PLUGIN_AUTH = (0x01 << 0), /**< Auth service type flag */
45 SERVICE_PLUGIN_STORAGE = (0x01 << 1), /**< Storage service type flag */
46 } service_plugin_type_e;
49 * @brief Definition for the service_plugin property: The application id be issued from service provider for 3rd party developer.
51 * @see service_plugin_add_property()
52 * @see service_plugin_remove_property()
53 * @see service_plugin_get_property()
55 #define SERVICE_PLUGIN_PROPERTY_APP_KEY "http://tizen.org/service-adaptor/plugin/property/app_key"
58 * @brief Definition for the service_plugin property: The application password be issued from service provider for 3rd party developer.
60 * @see service_plugin_add_property()
61 * @see service_plugin_remove_property()
62 * @see service_plugin_get_property()
64 #define SERVICE_PLUGIN_PROPERTY_APP_SECRET "http://tizen.org/service-adaptor/plugin/property/app_secret"
67 * @brief Definition for the service_plugin property: The user id for using specific service.
69 * @see service_plugin_add_property()
70 * @see service_plugin_remove_property()
71 * @see service_plugin_get_property()
73 #define SERVICE_PLUGIN_PROPERTY_USER_ID "http://tizen.org/service-adaptor/plugin/property/user_id"
76 * @brief The handle for connection and managing handle of Service Plugin
77 * @details The handle can be created by service_plugin_create()<br>
78 * When a handle is no longer needed, use service_plugin_destroy()
79 * @see #service_plugin_create()
80 * @see #service_plugin_destroy()
82 typedef struct _service_plugin_s *service_plugin_h;
85 * @brief Callback for service_adaptor_foreach_plugin API
87 * @param[in] uri The service plugin's unique uri, this value be set by plugin
88 * @param[in] service_mask Masked value for <b>installed</b> service plugins, this value can be masked multiple enum (#service_plugin_service_type_e)
89 * @param[in] user_data Passed data from #service_adaptor_foreach_plugin()
90 * @remarks @a service_mask check using 'bit and' operation with #service_plugin_service_type_e
91 * @remarks - for example,
92 * @remarks if(@a service_mask & SERVICE_PLUGIN_SERVICE_STORAGE)
93 * @remarks { @a USING_STORAGE_CODE }
94 * @remarks Do not release memory of @a plugin_uri
95 * @see service_plugin_service_type_e
96 * @return @c true to continue with the next iteration of the loop,
97 * otherwise @c false to break out of the loop
98 * @pre service_adaptor_foreach_plugin() will invoke this callback.
100 typedef bool (*service_adaptor_plugin_cb)(const char *uri,
105 * @brief Callback for service_plugin_login API
108 * @param[in] user_data Passed data from #service_plugin_login()
111 * @pre service_plugin_login() will invoke this callback.
113 typedef void (*service_plugin_login_cb)(int result,
116 /*==================================================================================================
118 ==================================================================================================*/
121 * @brief Create Service Adaptor
124 * @param[out] service_adaptor The Service Adaptor handle
125 * @remarks @a service_adaptor must be released memory using service_adaptor_destroy(), when a program no longer needs any function of Service Adaptor
126 * @see service_adaptor_destroy()
127 * @return 0 on success, otherwise a negative error value
128 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
129 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
130 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
132 int service_adaptor_connect();
135 * @brief Destroy Service Adaptor
136 * @details It must called after a program no longer needs any function of Service Adaptor
139 * @param[in] service_adaptor The handle of Service Adaptor
140 * @see service_adaptor_create()
141 * @return 0 on success, otherwise a negative error value
142 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
143 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
144 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
145 * @pre @a service_adaptor must be issued by service_adaptor_create()
147 int service_adaptor_disconnect();
150 * @brief Foreach the list of plugin
151 * @details Iterate to all installed plugin
154 * @param[in] callback The callback for foreach plugin
155 * @param[in] user_data Passed data to callback
156 * @return 0 on success, otherwise a negative error value
157 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
158 * @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no available plugins
159 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
160 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
161 * @pre @a service_adaptor must be issued by service_adaptor_create()
163 int service_adaptor_foreach_plugin(service_adaptor_plugin_cb callback,
167 * @brief Gets service specfic last result
168 * @details This function retrieves the last error code that be issued from plugin.<br>
169 * When if API function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, gets using this function.
172 * @param[out] err The error number that is defined service plugin SPEC
173 * @remarks Thread safe functions
174 * @remarks The result number's detail specification is defined service plugin or provider.
175 * @remarks The detail error message can be got using service_adaptor_get_last_error_message()
176 * @see service_adaptor_get_last_error_message()
177 * @return 0 on success, otherwise a negative error value
178 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
179 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
180 * @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no result
181 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
183 int service_adaptor_get_last_result(int *err);
186 * @brief Gets service specfic last result error message
187 * @details This function retrieves the last error code that be issued from plugin.<br>
188 * When if API function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, gets using this function.
191 * @param[out] message The error message that is defined service plugin SPEC
192 * @remarks @a message must be released using free()
193 * @remarks Thread safe functions
194 * @remarks The result string's detail specification is defined service plugin or provider.
195 * @see service_adaptor_get_last_result()
196 * @return 0 on success, otherwise a negative error value
197 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
198 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
199 * @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no error message
200 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
202 int service_adaptor_get_last_error_message(char **message);
205 int service_adaptor_add_plugin(service_adaptor_h adaptor_client, const char *plugin_uri);
206 int service_adaptor_remove_plugin(service_adaptor_h adaptor_client, const char *plugin_uri);
207 int service_adaptor_get_auth(service_adaptor_h adaptor_client, const char *uri, service_auth_h *auth);
211 * @brief Create service plugin handle
212 * @details Create plugin handle using @a plugin_uri
215 * @param[in] service_adaptor The handle of Service Adaptor
216 * @param[in] plugin_uri The specfic string for use plugin, this values are set by plugin
217 * @param[out] plugin The handle for use Plugin APIs
218 * @remarks @a plugin must be released memory using service_plugin_destroy() when you no longer needs plugin's API
219 * @see service_plugin_destroy()
220 * @return 0 on success, otherwise a negative error value
221 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
222 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
223 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
224 * @pre @a service_adaptor must be issued by service_adaptor_create()
226 int service_plugin_create(const char *uri, service_plugin_h *plugin);
229 * @brief Destroy service plugin handle
230 * @details It must called after a program no longer needs APIs of specfic plugin
233 * @param[in] plugin The handle for use Plugin APIs
234 * @see service_adaptor_create_plugin()
235 * @return 0 on success, otherwise a negative error value
236 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
237 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
238 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
239 * @pre @a plugin must be issued by service_adaptor_create_plugin()
241 int service_plugin_destroy(service_plugin_h plugin);
244 * @brief Add Plugin Property
245 * @details The plguin property is used for plugin's basic or optional requirement.<br>
246 * This value is not used in Adaptor layer, but it can be uesd to important Key for plugin with service provider.<br>
249 * @param[in] plugin The handle for use Plugin APIs
250 * @param[in] key The key of plugin property
251 * @param[in] value The value of plugin property that matched @a key
252 * @remarks Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
253 * @remarks If the @a key already exists in the property its current value is replaced with the new @a value.
254 * @remarks @a plugin must be released memory using #service_plugin_destroy() when you no longer needs plugin's API
255 * @return 0 on success, otherwise a negative error value
256 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
257 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
258 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
259 * @see SERVICE_PLUGIN_PROPERTY_APP_KEY
260 * @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
261 * @see SERVICE_PLUGIN_PROPERTY_USER_ID
262 * @pre @a plugin must be issued by service_adaptor_create_plugin()
264 int service_plugin_add_property(service_plugin_h plugin,
269 * @brief Remove Plugin Property
272 * @param[in] plugin The handle for use Plugin APIs
273 * @param[in] key The key of plugin property
274 * @remarks Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
275 * @return 0 on success, otherwise a negative error value
276 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
277 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
278 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
279 * @see SERVICE_PLUGIN_PROPERTY_APP_KEY
280 * @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
281 * @see SERVICE_PLUGIN_PROPERTY_USER_ID
283 int service_plugin_remove_property(service_plugin_h plugin,
287 * @brief Gets Plugin Property
290 * @param[in] plugin The handle for use Plugin APIs
291 * @param[in] key The key of plugin property
292 * @param[out] value The value of plugin property that matched @a key
293 * @remarks Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
294 * @remarks @a value must be released using free()
295 * @return 0 on success, otherwise a negative error value
296 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
297 * @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no property
298 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
299 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
300 * @see SERVICE_PLUGIN_PROPERTY_APP_KEY
301 * @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
302 * @see SERVICE_PLUGIN_PROPERTY_USER_ID
303 * @pre The function get property already set by service_adaptor_set_plugin_property()
305 int service_plugin_get_property(service_plugin_h plugin,
310 * @brief Logins Plugin using Property
313 * @param[in] plugin The handle for use Plugin APIs
314 * @param[in] callback The callback for login
315 * @param[in] user_data Passed data to callback
317 * @remarks @a value must be released using free()
318 * @return 0 on success, otherwise a negative error value
319 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
320 * @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no property
321 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
322 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
323 * @pre The function get property already set by service_adaptor_set_plugin_property()
325 int service_plugin_login(service_plugin_h plugin, service_plugin_login_cb callback, void *user_data);
328 * @brief Requests start initalization for service plugin
331 * @param[in] plugin The handle for use Plugin APIs
332 * @remarks @a service_mask must be input using 'bit or' operation with #service_plugin_service_type_e
333 * @remarks - for example,
334 * @remarks <b>int</b> @a service_mask |= SERVIE_PLUGIN_SERVICE_AUTH;
335 * @remarks @a service_mask |= SERVICE_PLUGIN_SERVICE_STORAGE;
336 * @remarks <b>int</b> ret = service_plugin_start(@a m_plugin, @a service_mask);
337 * @remarks If a program needs to stop plugin manually, use #service_plugin_stop(). <br>But in #service_plugin_destroy(), automatically stop service plugin
338 * @see service_plugin_service_type_e
339 * @see service_plugin_stop()
340 * @return 0 on success, otherwise a negative error value
341 * @return If return value is #SERVICE_ADAPTOR_ERROR_NOT_AUTHOLIZED, request signup to autholization application
342 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
343 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
344 * @retval #SERVICE_ADAPTOR_ERROR_NOT_AUTHOLIZED Need atholization
345 * @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
346 * @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
347 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
349 int service_plugin_start(service_plugin_h plugin);
351 * @brief Requests stop manually for service plugin
354 * @param[in] plugin The handle for use Plugin APIs
355 * @remarks If a program needs to stop plugin manually, use this function. <br>But in #service_plugin_destroy(), automatically stop service plugin
356 * @remarks @a plugin must be released memory using #service_plugin_destroy() when you no longer needs plugin's API
357 * @see service_plugin_start()
358 * @see service_plugin_destroy()
359 * @return 0 on success, otherwise a negative error value
360 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
361 * @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
362 * @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
363 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
364 * @pre service_plugin_start()
366 int service_plugin_stop(service_plugin_h plugin);
376 #endif /* __SERVICE_ADAPTOR_H__ */