Service Adaptor
You can manage adaptors, which function as agents between the Service Adaptor Client and the related plugins, to take advantage of various services. For example, the Auth and Storage adaptors allow you to access the Auth and Service Plugins to use services, such as Amazon, Box, Dropbox, Google Drive, Onedrive, and Sugarsync.
This feature is supported in mobile applications only.
Figure: Service adaptor structure
The main feature of the Service Adaptor API is to connect adaptors to and disconnect them from the Service Adaptor Client though D-Bus. The Service adaptor uses 2 path types:
-
Logical path
The path of the root file system. It starts from the root path ("/"), and you can use the path like in Linux (for example, "/folder1/image1.jpg").
-
Physical path
A specific URI used for the cloud server. Some clouds use a logical path, but others use a specific key or URL (for example, "/" is "ZmNhMWY2MTZlY2M1NDg4OGJmZDY4O" and "/folder1" is "2JI32UNJDWQEQWQWEADSSAD").
Available Adaptors
The following adaptors are provided:
- Auth adaptor
This adaptor manages authentication plugins. It allows you to:
- Get the Auth Plugin list.
- Set the Plugin.
- Request the Channel Auth, such as the service name ("com.serviceadaptor.message"), app ID, service ID (0: contact, 1: free message), and mobile station identification number (IMSI).
- Storage adaptor
This adaptor handles files transfers to and from a cloud. It allows you to:
- Download a server or thumbnail file and write it to a local file.
- Upload a local file to a server path.
- Request the file status.
- Cancel, pause, and resume a file transfer.
- Contact adaptor
This adaptor manages contact information in the Contact server, including the contact profiles and service registration information. It allows you to:
- Reset contact information in the Contact server and upload native contact information of the device to the server.
- Synchronize native contact information of the device with the Contact server according to the [type] field of each contact.
- Get contact profiles and service registration information.
- Set and update the device profile in the server.
- Upload and delete profile image meta in the File server and set the my profile image to the Profile server.
- Set and get the my profile privacy level
- Set my presence ON/OFF information to the Presence server.
- Discovery adaptor
This adaptor is a future development. Not in use yet.
- Message adaptor
This adaptor manages chatting and messaging. It allows you to:
- Create a chatroom, and invite people to (or end) a chat.
- Get all unread messages.
- Read or unseal a message.
- Forward online or unread messages.
- Save the call log.
- Get the chat ID based on the phone number.
- Push adaptor
This adaptor receives push notifications from a push service.
- Shop adaptor
This adaptor allows you to:
- Get a list of items.
- Get item information for download.
- Download an item.
- Get the item panel URL.
Starting a Plugin
To start a plugin, use the following process:
- Create a Service adaptor with the service_adaptor_create() function.
- With a valid Service adaptor handler, iterate through all installed plugins with the service_adaptor_foreach_plugin() function.
- Inside the callback (invoked for each plugin), get the plugin_uri value, which is passed to the service_adaptor_create_plugin() function.
- Request a start initialization for the service plugin with the service_plugin_start() function.
The following example starts all installed Auth and Storage plugins appending each plugin_uri to the list object:
bool _plugin_iterator_cb(char *plugin_uri, int service_mask, void *user_data); service_adaptor_h service_adaptor = NULL; ret = service_adaptor_create(&service_adaptor); Evas_Object *list; ret = service_adaptor_foreach_plugin(service_adaptor, _plugin_iterator_cb, (void *)list); bool _plugin_iterator_cb(char *plugin_uri, int service_mask, void *user_data) { Evas_Object *list = (Evas_Object *)user_data; if (!plugin_uri || !list) return false; if ((service_mask & SERVICE_PLUGIN_SERVICE_AUTH) && (service_mask & SERVICE_PLUGIN_SERVICE_STORAGE)) { elm_list_item_append(list, plugin_uri, NULL, NULL, _show_plugin_view, plugin_uri); service_plugin_h plugin = NULL; service_adaptor_create_plugin(service_adaptor, plugin_uri, &plugin); // Hide this using config file or user input, because it is security information service_plugin_add_property(plugin, SERVICE_PLUGIN_PROPERTY_APP_KEY, "enasvv4l8hdbmhn"); service_plugin_add_property(plugin, SERVICE_PLUGIN_PROPERTY_APP_SECRET, "uqhl4pp8mo7hmgn"); service_plugin_start(plugin, (SERVICE_PLUGIN_SERVICE_AUTH | SERVICE_PLUGIN_SERVICE_STORAGE)); } return true; }