Tizen Native API
Service Adaptor

Functions

int service_adaptor_create (service_adaptor_h *service_adaptor)
 Create Service Adaptor.
int service_adaptor_destroy (service_adaptor_h service_adaptor)
 Destroy Service Adaptor.
int service_adaptor_foreach_plugin (service_adaptor_h service_adaptor, service_adaptor_plugin_cb callback, void *user_data)
 Foreach the list of plugin.
int service_adaptor_create_plugin (service_adaptor_h service_adaptor, const char *plugin_uri, service_plugin_h *plugin)
 Create service plugin handle.
int service_adaptor_get_last_result (int *err)
 Gets service specfic last result.
int service_adaptor_get_last_error_message (char **message)
 Gets service specfic last result error message.
int service_plugin_get_property (service_plugin_h plugin, const char *key, char **value)
 Gets Plugin Property.

Typedefs

typedef struct _service_adaptor_s * service_adaptor_h
 The handle for connection and managing plugin handle of Service Adaptor.
typedef bool(* service_adaptor_plugin_cb )(char *plugin_uri, int service_mask, void *user_data)
 Callback for service_adaptor_foreach_plugin API.

The Service Adaptor API provides developer with common interfaces like using local service for various service infra.

Required Header

#include <service_adaptor_client.h>

Overview

Developers can use functions easily and commonly be provided from various service infra.
When you want use another service infra, you can use same interfaces if you change just initalize setting.
Service adaptor provides functions kind of Auth, Storage and it will provides more kinds of service infra.

API Description
Service Plugin Provide functions for handling service plugin



Typedef Documentation

typedef struct _service_adaptor_s* service_adaptor_h

The handle for connection and managing plugin handle of Service Adaptor.

The handle can be created by service_adaptor_create()
When a handle is no longer needed, use service_adaptor_destroy()

Since :
2.4
See also:
service_adaptor_create()
service_adaptor_destroy()
typedef bool(* service_adaptor_plugin_cb)(char *plugin_uri, int service_mask, void *user_data)

Callback for service_adaptor_foreach_plugin API.

Since :
2.4
Parameters:
[in]plugin_uriThe service plugin's unique uri, this value be set by plugin
[in]service_maskMasked value for installed service plugins, this value can be masked multiple enum (service_plugin_service_type_e)
[in]user_dataPassed data from service_adaptor_foreach_plugin()
Remarks:
service_mask check using 'bit and' operation with service_plugin_service_type_e
- for example,
     if(service_mask & SERVICE_PLUGIN_SERVICE_STORAGE)
         { USING_STORAGE_CODE }
Do not release memory of plugin_uri
See also:
service_plugin_service_type_e
Returns:
true to continue with the next iteration of the loop, otherwise false to break out of the loop
Precondition:
service_adaptor_foreach_plugin() will invoke this callback.

Enumeration Type Documentation

Enumerations of result code for Service Adaptor.

Since :
2.4
Enumerator:
SERVICE_ADAPTOR_ERROR_NONE 

Success

SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED 

Service plugin does not support API

SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER 

The parameter is invalid

SERVICE_ADAPTOR_ERROR_TIMED_OUT 

API time out

SERVICE_ADAPTOR_ERROR_NO_DATA 

There is no data available

SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED 

Permission denied

SERVICE_ADAPTOR_ERROR_UNKNOWN 

Unknown error

SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE 

IPC Connection unstabled

SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED 

The error occured from Plugin, See detail from service_adaptor_get_last_result() and Plugin SPEC

SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED 

Need Authorization

SERVICE_ADAPTOR_ERROR_INVALID_STATE 

The handle state is invalid for processing API


Function Documentation

int service_adaptor_create ( service_adaptor_h service_adaptor)

Create Service Adaptor.

Since :
2.4
Parameters:
[out]service_adaptorThe Service Adaptor handle
Remarks:
service_adaptor must be released memory using service_adaptor_destroy(), when a program no longer needs any function of Service Adaptor
See also:
service_adaptor_destroy()
Returns:
0 on success, otherwise a negative error value
Return values:
SERVICE_ADAPTOR_ERROR_NONESuccessful
SERVICE_ADAPTOR_ERROR_INVALID_PARAMETERInvalid parameter
SERVICE_ADAPTOR_ERROR_UNKNOWNUnknown error
int service_adaptor_create_plugin ( service_adaptor_h  service_adaptor,
const char *  plugin_uri,
service_plugin_h plugin 
)

Create service plugin handle.

Create plugin handle using plugin_uri

Since :
2.4
Parameters:
[in]service_adaptorThe handle of Service Adaptor
[in]plugin_uriThe specfic string for use plugin, this values are set by plugin
[out]pluginThe handle for use Plugin APIs
Remarks:
plugin must be released memory using service_plugin_destroy() when you no longer needs plugin's API
See also:
service_plugin_destroy()
Returns:
0 on success, otherwise a negative error value
Return values:
SERVICE_ADAPTOR_ERROR_NONESuccessful
SERVICE_ADAPTOR_ERROR_INVALID_PARAMETERInvalid parameter
SERVICE_ADAPTOR_ERROR_UNKNOWNUnknown error
Precondition:
service_adaptor must be issued by service_adaptor_create()
int service_adaptor_destroy ( service_adaptor_h  service_adaptor)

Destroy Service Adaptor.

It must called after a program no longer needs any function of Service Adaptor

Since :
2.4
Parameters:
[in]service_adaptorThe handle of Service Adaptor
See also:
service_adaptor_create()
Returns:
0 on success, otherwise a negative error value
Return values:
SERVICE_ADAPTOR_ERROR_NONESuccessful
SERVICE_ADAPTOR_ERROR_INVALID_PARAMETERInvalid parameter
SERVICE_ADAPTOR_ERROR_UNKNOWNUnknown error
Precondition:
service_adaptor must be issued by service_adaptor_create()
int service_adaptor_foreach_plugin ( service_adaptor_h  service_adaptor,
service_adaptor_plugin_cb  callback,
void *  user_data 
)

Foreach the list of plugin.

Iterate to all installed plugin

Since :
2.4
Parameters:
[in]service_adaptorThe handle of Service Adaptor
[in]callbackThe callback for foreach plugin
[in]user_dataPassed data to callback
Returns:
0 on success, otherwise a negative error value
Return values:
SERVICE_ADAPTOR_ERROR_NONESuccessful
SERVICE_ADAPTOR_ERROR_NO_DATAThere is no available plugins
SERVICE_ADAPTOR_ERROR_INVALID_PARAMETERInvalid parameter
SERVICE_ADAPTOR_ERROR_UNKNOWNUnknown error
Precondition:
service_adaptor must be issued by service_adaptor_create()
int service_adaptor_get_last_error_message ( char **  message)

Gets service specfic last result error message.

This function retrieves the last error code that be issued from plugin.
When if API function returns SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, gets using this function.

Since :
2.4
Parameters:
[out]messageThe error message that is defined service plugin SPEC
Remarks:
message must be released using free()
Thread safe functions
The result string's detail specification is defined service plugin or provider.
See also:
service_adaptor_get_last_result()
Returns:
0 on success, otherwise a negative error value
Return values:
SERVICE_ADAPTOR_ERROR_NONESuccessful
SERVICE_ADAPTOR_ERROR_INVALID_PARAMETERInvalid parameter
SERVICE_ADAPTOR_ERROR_NO_DATAThere is no error message
SERVICE_ADAPTOR_ERROR_UNKNOWNUnknown error
int service_adaptor_get_last_result ( int *  err)

Gets service specfic last result.

This function retrieves the last error code that be issued from plugin.
When if API function returns SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, gets using this function.

Since :
2.4
Parameters:
[out]errThe error number that is defined service plugin SPEC
Remarks:
Thread safe functions
The result number's detail specification is defined service plugin or provider.
The detail error message can be got using service_adaptor_get_last_error_message()
See also:
service_adaptor_get_last_error_message()
Returns:
0 on success, otherwise a negative error value
Return values:
SERVICE_ADAPTOR_ERROR_NONESuccessful
SERVICE_ADAPTOR_ERROR_INVALID_PARAMETERInvalid parameter
SERVICE_ADAPTOR_ERROR_NO_DATAThere is no result
SERVICE_ADAPTOR_ERROR_UNKNOWNUnknown error
int service_plugin_get_property ( service_plugin_h  plugin,
const char *  key,
char **  value 
)

Gets Plugin Property.

Since :
2.4
Parameters:
[in]pluginThe handle for use Plugin APIs
[in]keyThe key of plugin property
[out]valueThe value of plugin property that matched key
Remarks:
Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
value must be released using free()
Returns:
0 on success, otherwise a negative error value
Return values:
SERVICE_ADAPTOR_ERROR_NONESuccessful
SERVICE_ADAPTOR_ERROR_NO_DATAThere is no property
SERVICE_ADAPTOR_ERROR_INVALID_PARAMETERInvalid parameter
SERVICE_ADAPTOR_ERROR_UNKNOWNUnknown error
See also:
SERVICE_PLUGIN_PROPERTY_APP_KEY
SERVICE_PLUGIN_PROPERTY_APP_SECRET
SERVICE_PLUGIN_PROPERTY_USER_ID