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 Type of service in plugin
51 typedef enum _service_plugin_service_type_e
53 SERVICE_PLUGIN_SERVICE_AUTH = (0x01 << 0), /**< Auth service type flag */
54 SERVICE_PLUGIN_SERVICE_STORAGE = (0x01 << 1), /**< Storage service type flag */
55 } service_plugin_service_type_e;
58 * @brief Definition for the service_plugin property: The application id 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_KEY "http://tizen.org/service-adaptor/plugin/property/app_key"
67 * @brief Definition for the service_plugin property: The application password be issued from service provider for 3rd party developer.
69 * @see service_plugin_add_property()
70 * @see service_plugin_remove_property()
71 * @see service_plugin_get_property()
73 #define SERVICE_PLUGIN_PROPERTY_APP_SECRET "http://tizen.org/service-adaptor/plugin/property/app_secret"
76 * @brief Definition for the service_plugin property: The user id for using specific service.
78 * @see service_plugin_add_property()
79 * @see service_plugin_remove_property()
80 * @see service_plugin_get_property()
82 #define SERVICE_PLUGIN_PROPERTY_USER_ID "http://tizen.org/service-adaptor/plugin/property/user_id"
85 * @brief The handle for connection and managing plugin handle of Service Adaptor
86 * @details The handle can be created by service_adaptor_create()<br>
87 * When a handle is no longer needed, use service_adaptor_destroy()
88 * @see #service_adaptor_create()
89 * @see #service_adaptor_destroy()
91 typedef struct _service_adaptor_s *service_adaptor_h;
94 * @brief The handle for connection and managing handle of Service Plugin
95 * @details The handle can be created by service_plugin_create()<br>
96 * When a handle is no longer needed, use service_plugin_destroy()
97 * @see #service_plugin_create()
98 * @see #service_plugin_destroy()
100 typedef struct _service_plugin_s *service_plugin_h;
103 * @brief Callback for service_adaptor_foreach_plugin API
105 * @param[in] uri The service plugin's unique uri, this value be set by plugin
106 * @param[in] service_mask Masked value for <b>installed</b> service plugins, this value can be masked multiple enum (#service_plugin_service_type_e)
107 * @param[in] user_data Passed data from #service_adaptor_foreach_plugin()
108 * @remarks @a service_mask check using 'bit and' operation with #service_plugin_service_type_e
109 * @remarks - for example,
110 * @remarks if(@a service_mask & SERVICE_PLUGIN_SERVICE_STORAGE)
111 * @remarks { @a USING_STORAGE_CODE }
112 * @remarks Do not release memory of @a plugin_uri
113 * @see service_plugin_service_type_e
114 * @return @c true to continue with the next iteration of the loop,
115 * otherwise @c false to break out of the loop
116 * @pre service_adaptor_foreach_plugin() will invoke this callback.
118 typedef bool (*service_adaptor_plugin_cb)(const char *uri,
123 * @brief Callback for service_plugin_login API
126 * @param[in] user_data Passed data from #service_plugin_login()
129 * @pre service_plugin_login() will invoke this callback.
131 typedef void (*service_plugin_login_cb)(int result,
134 /*==================================================================================================
136 ==================================================================================================*/
139 * @brief Create Service Adaptor
142 * @param[out] service_adaptor The Service Adaptor handle
143 * @remarks @a service_adaptor must be released memory using service_adaptor_destroy(), when a program no longer needs any function of Service Adaptor
144 * @see service_adaptor_destroy()
145 * @return 0 on success, otherwise a negative error value
146 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
147 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
148 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
150 int service_adaptor_create(service_adaptor_h *service_adaptor);
153 * @brief Destroy Service Adaptor
154 * @details It must called after a program no longer needs any function of Service Adaptor
157 * @param[in] service_adaptor The handle of Service Adaptor
158 * @see service_adaptor_create()
159 * @return 0 on success, otherwise a negative error value
160 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
161 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
162 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
163 * @pre @a service_adaptor must be issued by service_adaptor_create()
165 int service_adaptor_destroy(service_adaptor_h service_adaptor);
168 * @brief Create Service Adaptor
171 * @param[out] service_adaptor The Service Adaptor handle
172 * @remarks @a service_adaptor must be released memory using service_adaptor_destroy(), when a program no longer needs any function of Service Adaptor
173 * @see service_adaptor_destroy()
174 * @return 0 on success, otherwise a negative error value
175 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
176 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
177 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
179 int service_adaptor_connect();
182 * @brief Destroy Service Adaptor
183 * @details It must called after a program no longer needs any function of Service Adaptor
186 * @param[in] service_adaptor The handle of Service Adaptor
187 * @see service_adaptor_create()
188 * @return 0 on success, otherwise a negative error value
189 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
190 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
191 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
192 * @pre @a service_adaptor must be issued by service_adaptor_create()
194 int service_adaptor_disconnect();
197 * @brief Foreach the list of plugin
198 * @details Iterate to all installed plugin
201 * @param[in] service_adaptor The handle of Service Adaptor
202 * @param[in] callback The callback for foreach plugin
203 * @param[in] user_data Passed data to callback
204 * @return 0 on success, otherwise a negative error value
205 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
206 * @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no available plugins
207 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
208 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
209 * @pre @a service_adaptor must be issued by service_adaptor_create()
211 int service_adaptor_foreach_plugin(service_adaptor_h service_adaptor,
212 service_adaptor_plugin_cb callback,
216 * @brief Foreach the list of plugin
217 * @details Iterate to all installed plugin
220 * @param[in] callback The callback for foreach plugin
221 * @param[in] user_data Passed data to callback
222 * @return 0 on success, otherwise a negative error value
223 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
224 * @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no available plugins
225 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
226 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
227 * @pre @a service_adaptor must be issued by service_adaptor_create()
229 int service_adaptor_foreach_plugin2(service_adaptor_plugin_cb callback,
233 * @brief Gets service specfic last result
234 * @details This function retrieves the last error code that be issued from plugin.<br>
235 * When if API function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, gets using this function.
238 * @param[out] err The error number that is defined service plugin SPEC
239 * @remarks Thread safe functions
240 * @remarks The result number's detail specification is defined service plugin or provider.
241 * @remarks The detail error message can be got using service_adaptor_get_last_error_message()
242 * @see service_adaptor_get_last_error_message()
243 * @return 0 on success, otherwise a negative error value
244 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
245 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
246 * @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no result
247 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
249 int service_adaptor_get_last_result(int *err);
252 * @brief Gets service specfic last result error message
253 * @details This function retrieves the last error code that be issued from plugin.<br>
254 * When if API function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, gets using this function.
257 * @param[out] message The error message that is defined service plugin SPEC
258 * @remarks @a message must be released using free()
259 * @remarks Thread safe functions
260 * @remarks The result string's detail specification is defined service plugin or provider.
261 * @see service_adaptor_get_last_result()
262 * @return 0 on success, otherwise a negative error value
263 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
264 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
265 * @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no error message
266 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
268 int service_adaptor_get_last_error_message(char **message);
271 int service_adaptor_add_plugin(service_adaptor_h adaptor_client, const char *plugin_uri);
272 int service_adaptor_remove_plugin(service_adaptor_h adaptor_client, const char *plugin_uri);
273 int service_adaptor_get_auth(service_adaptor_h adaptor_client, const char *uri, service_auth_h *auth);
277 * @brief Create service plugin handle
278 * @details Create plugin handle using @a plugin_uri
281 * @param[in] service_adaptor The handle of Service Adaptor
282 * @param[in] plugin_uri The specfic string for use plugin, this values are set by plugin
283 * @param[out] plugin The handle for use Plugin APIs
284 * @remarks @a plugin must be released memory using service_plugin_destroy() when you no longer needs plugin's API
285 * @see service_plugin_destroy()
286 * @return 0 on success, otherwise a negative error value
287 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
288 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
289 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
290 * @pre @a service_adaptor must be issued by service_adaptor_create()
292 int service_adaptor_create_plugin(service_adaptor_h service_adaptor,
293 const char *plugin_uri,
294 service_plugin_h *plugin);
297 * @brief Create service plugin handle
298 * @details Create plugin handle using @a plugin_uri
301 * @param[in] service_adaptor The handle of Service Adaptor
302 * @param[in] plugin_uri The specfic string for use plugin, this values are set by plugin
303 * @param[out] plugin The handle for use Plugin APIs
304 * @remarks @a plugin must be released memory using service_plugin_destroy() when you no longer needs plugin's API
305 * @see service_plugin_destroy()
306 * @return 0 on success, otherwise a negative error value
307 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
308 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
309 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
310 * @pre @a service_adaptor must be issued by service_adaptor_create()
312 int service_plugin_create(const char *uri, service_plugin_h *plugin);
315 * @brief Destroy service plugin handle
316 * @details It must called after a program no longer needs APIs of specfic plugin
319 * @param[in] plugin The handle for use Plugin APIs
320 * @see service_adaptor_create_plugin()
321 * @return 0 on success, otherwise a negative error value
322 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
323 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
324 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
325 * @pre @a plugin must be issued by service_adaptor_create_plugin()
327 int service_plugin_destroy(service_plugin_h plugin);
330 * @brief Add Plugin Property
331 * @details The plguin property is used for plugin's basic or optional requirement.<br>
332 * This value is not used in Adaptor layer, but it can be uesd to important Key for plugin with service provider.<br>
335 * @param[in] plugin The handle for use Plugin APIs
336 * @param[in] key The key of plugin property
337 * @param[in] value The value of plugin property that matched @a key
338 * @remarks Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
339 * @remarks If the @a key already exists in the property its current value is replaced with the new @a value.
340 * @remarks @a plugin must be released memory using #service_plugin_destroy() when you no longer needs plugin's API
341 * @return 0 on success, otherwise a negative error value
342 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
343 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
344 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
345 * @see SERVICE_PLUGIN_PROPERTY_APP_KEY
346 * @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
347 * @see SERVICE_PLUGIN_PROPERTY_USER_ID
348 * @pre @a plugin must be issued by service_adaptor_create_plugin()
350 int service_plugin_add_property(service_plugin_h plugin,
355 * @brief Remove Plugin Property
358 * @param[in] plugin The handle for use Plugin APIs
359 * @param[in] key The key of plugin property
360 * @remarks Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
361 * @return 0 on success, otherwise a negative error value
362 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
363 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
364 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
365 * @see SERVICE_PLUGIN_PROPERTY_APP_KEY
366 * @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
367 * @see SERVICE_PLUGIN_PROPERTY_USER_ID
369 int service_plugin_remove_property(service_plugin_h plugin,
373 * @brief Gets Plugin Property
376 * @param[in] plugin The handle for use Plugin APIs
377 * @param[in] key The key of plugin property
378 * @param[out] value The value of plugin property that matched @a key
379 * @remarks Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
380 * @remarks @a value must be released using free()
381 * @return 0 on success, otherwise a negative error value
382 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
383 * @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no property
384 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
385 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
386 * @see SERVICE_PLUGIN_PROPERTY_APP_KEY
387 * @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
388 * @see SERVICE_PLUGIN_PROPERTY_USER_ID
389 * @pre The function get property already set by service_adaptor_set_plugin_property()
391 int service_plugin_get_property(service_plugin_h plugin,
396 * @brief Logins Plugin using Property
399 * @param[in] plugin The handle for use Plugin APIs
400 * @param[in] callback The callback for login
401 * @param[in] user_data Passed data to callback
403 * @remarks @a value must be released using free()
404 * @return 0 on success, otherwise a negative error value
405 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
406 * @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no property
407 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
408 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
409 * @pre The function get property already set by service_adaptor_set_plugin_property()
411 int service_plugin_login(service_plugin_h plugin, service_plugin_login_cb callback, void *user_data);
414 * @brief Requests start initalization for service plugin
417 * @param[in] plugin The handle for use Plugin APIs
418 * @param[in] service_mask The flag for use service plugins, this flag can be masked multiple enum (#service_plugin_service_type_e)
419 * @remarks @a service_mask must be input using 'bit or' operation with #service_plugin_service_type_e
420 * @remarks - for example,
421 * @remarks <b>int</b> @a service_mask |= SERVIE_PLUGIN_SERVICE_AUTH;
422 * @remarks @a service_mask |= SERVICE_PLUGIN_SERVICE_STORAGE;
423 * @remarks <b>int</b> ret = service_plugin_start(@a m_plugin, @a service_mask);
424 * @remarks If a program needs to stop plugin manually, use #service_plugin_stop(). <br>But in #service_plugin_destroy(), automatically stop service plugin
425 * @see service_plugin_service_type_e
426 * @see service_plugin_stop()
427 * @return 0 on success, otherwise a negative error value
428 * @return If return value is #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED, request authorization to signup application
429 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
430 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
431 * @retval #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED Need authorization
432 * @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
433 * @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
434 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
436 int service_plugin_start(service_plugin_h plugin,
440 * @brief Requests start initalization for service plugin
443 * @param[in] plugin The handle for use Plugin APIs
444 * @remarks @a service_mask must be input using 'bit or' operation with #service_plugin_service_type_e
445 * @remarks - for example,
446 * @remarks <b>int</b> @a service_mask |= SERVIE_PLUGIN_SERVICE_AUTH;
447 * @remarks @a service_mask |= SERVICE_PLUGIN_SERVICE_STORAGE;
448 * @remarks <b>int</b> ret = service_plugin_start(@a m_plugin, @a service_mask);
449 * @remarks If a program needs to stop plugin manually, use #service_plugin_stop(). <br>But in #service_plugin_destroy(), automatically stop service plugin
450 * @see service_plugin_service_type_e
451 * @see service_plugin_stop()
452 * @return 0 on success, otherwise a negative error value
453 * @return If return value is #SERVICE_ADAPTOR_ERROR_NOT_AUTHOLIZED, request signup to autholization application
454 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
455 * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
456 * @retval #SERVICE_ADAPTOR_ERROR_NOT_AUTHOLIZED Need atholization
457 * @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
458 * @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
459 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
461 int service_plugin_start2(service_plugin_h plugin);
464 * @brief Requests stop manually for service plugin
467 * @param[in] plugin The handle for use Plugin APIs
468 * @remarks If a program needs to stop plugin manually, use this function. <br>But in #service_plugin_destroy(), automatically stop service plugin
469 * @remarks @a plugin must be released memory using #service_plugin_destroy() when you no longer needs plugin's API
470 * @see service_plugin_start()
471 * @see service_plugin_destroy()
472 * @return 0 on success, otherwise a negative error value
473 * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
474 * @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
475 * @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
476 * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
477 * @pre service_plugin_start()
479 int service_plugin_stop(service_plugin_h plugin);
489 #endif /* __SERVICE_ADAPTOR_H__ */