Tizen Native API
5.0
|
All applications can request data shared by other applications using data control.
#include <data_control.h>
You can get a datacontrol_h instance from data_control_map_create() or data_control_sql_create().
Functions | |
int | data_control_bulk_data_get_data (data_control_bulk_data_h bulk_data, int idx, bundle **data) |
Gets the n-th bundle from bulk data. | |
int | data_control_bulk_data_get_count (data_control_bulk_data_h bulk_data, int *count) |
Gets the bulk data bundle count. | |
int | data_control_bulk_data_add (data_control_bulk_data_h bulk_data, bundle *data) |
Adds a bundle to bulk data. | |
int | data_control_bulk_data_create (data_control_bulk_data_h *bulk_data) |
Creates bulk data. | |
int | data_control_bulk_data_destroy (data_control_bulk_data_h bulk_data) |
Destroys bulk data. | |
int | data_control_bulk_result_data_get_result_data (data_control_bulk_result_data_h result_data, int idx, bundle **data, int *result) |
Gets the n-th bundle from bulk result data. | |
int | data_control_bulk_result_data_get_count (data_control_bulk_result_data_h result_data, int *count) |
Gets the bulk result data bundle count. | |
int | data_control_bulk_result_data_add (data_control_bulk_result_data_h result_data, bundle *data, int result) |
Adds bulk data. | |
int | data_control_bulk_result_data_create (data_control_bulk_result_data_h *result_data) |
Creates bulk result data. | |
int | data_control_bulk_result_data_destroy (data_control_bulk_result_data_h result_data) |
Destroys bulk result data. | |
int | data_control_map_create (data_control_h *provider) |
Creates a provider handle. | |
int | data_control_map_destroy (data_control_h provider) |
Destroys the provider handle and releases all its resources. | |
int | data_control_map_set_provider_id (data_control_h provider, const char *provider_id) |
Sets the Provider ID. | |
int | data_control_map_get_provider_id (data_control_h provider, char **provider_id) |
Gets the Provider ID. | |
int | data_control_map_set_data_id (data_control_h provider, const char *data_id) |
Sets the Data ID. | |
int | data_control_map_get_data_id (data_control_h provider, char **data_id) |
Gets the data ID. | |
int | data_control_map_register_response_cb (data_control_h provider, data_control_map_response_cb *callback, void *user_data) |
Registers a callback function for the key-value structured data control response. The application is notified when a data control response is received from the provider. | |
int | data_control_map_unregister_response_cb (data_control_h provider) |
Unregisters the callback function in the provider. | |
int | data_control_map_get (data_control_h provider, const char *key, int *request_id) |
Gets the value list associated with the specified key from the key-values map owned by the key-value structured data control provider. | |
int | data_control_map_get_with_page (data_control_h provider, const char *key, int *request_id, int page_number, int count_per_page) |
Gets the value list associated with the specified key from the key-values map owned by the key-value structured data control provider, with partition into pages. | |
int | data_control_map_set (data_control_h provider, const char *key, const char *old_value, const char *new_value, int *request_id) |
Sets the value associated with the specified key to a new value. | |
int | data_control_map_add (data_control_h provider, const char *key, const char *value, int *request_id) |
Adds the value associated with the specified key to the key-values map owned by the key-value structured data control provider. | |
int | data_control_map_remove (data_control_h provider, const char *key, const char *value, int *request_id) |
Removes the value associated with the specified key from the key-values map owned by the key-value structured data control provider. | |
int | data_control_map_add_bulk_data (data_control_h provider, data_control_bulk_data_h bulk_data, int *request_id) |
Adds multiple key-value pairs in one request. | |
int | data_control_map_register_add_bulk_data_response_cb (data_control_h provider, data_control_bulk_cb callback, void *user_data) |
Registers an add bulk data callback for the MAP data control response. The application is notified when a data control response is received from the provider. | |
int | data_control_map_unregister_add_bulk_data_response_cb (data_control_h provider) |
Unregisters the add bulk data callback. | |
int | data_control_map_bind_response_cb (data_control_h provider, data_control_map_response_cb *callback, void *user_data) |
Binds a response callback function to a data control provider handle. The application is notified when a data control response is received from the provider. | |
int | data_control_map_unbind_response_cb (data_control_h provider) |
Unbinds the callback function in the provider. | |
int | data_control_map_bind_add_bulk_data_response_cb (data_control_h provider, data_control_bulk_cb callback, void *user_data) |
Binds the add bulk data callback to the map data control response. | |
int | data_control_map_unbind_add_bulk_data_response_cb (data_control_h provider) |
Unbinds the add bulk data callback in the provider. | |
int | data_control_map_get_handle_id (data_control_h provider, int *handle_id) |
Gets the handle ID for provider. | |
int | data_control_add_data_change_cb (data_control_h provider, data_control_data_change_cb callback, void *user_data, data_control_add_callback_result_cb result_callback, void *result_cb_user_data, int *callback_id) |
Asynchronously adds a data changed callback, which is called whenever the provider's data is changed. | |
int | data_control_remove_data_change_cb (data_control_h provider, int callback_id) |
Removes data change callback function. | |
int | data_control_sql_create (data_control_h *provider) |
Creates a provider handle. | |
int | data_control_sql_destroy (data_control_h provider) |
Destroys the provider handle and releases all its resources. | |
int | data_control_sql_set_provider_id (data_control_h provider, const char *provider_id) |
Sets the Provider ID. | |
int | data_control_sql_get_provider_id (data_control_h provider, char **provider_id) |
Gets the Provider ID. | |
int | data_control_sql_set_data_id (data_control_h provider, const char *data_id) |
Sets the data ID. | |
int | data_control_sql_get_data_id (data_control_h provider, char **data_id) |
Gets the data ID. | |
int | data_control_sql_register_response_cb (data_control_h provider, data_control_sql_response_cb *callback, void *user_data) |
Registers a callback function for the SQL data control response. | |
int | data_control_sql_unregister_response_cb (data_control_h provider) |
Unregisters the callback function in the provider. | |
int | data_control_sql_delete (data_control_h provider, const char *where, int *request_id) |
Deletes rows of a table owned by the SQL-type data control provider. | |
int | data_control_sql_insert (data_control_h provider, const bundle *insert_data, int *request_id) |
Inserts new rows in a table owned by the SQL-type data control provider. | |
int | data_control_sql_select (data_control_h provider, char **column_list, int column_count, const char *where, const char *order, int *request_id) |
Selects the specified columns to be queried. | |
int | data_control_sql_select_with_page (data_control_h provider, char **column_list, int column_count, const char *where, const char *order, int page_number, int count_per_page, int *request_id) |
Selects the specified columns to be queried, with partition into pages. | |
int | data_control_sql_update (data_control_h provider, const bundle *update_data, const char *where, int *request_id) |
Updates values of a table owned by the SQL-type data control provider. | |
int | data_control_sql_insert_bulk_data (data_control_h provider, data_control_bulk_data_h bulk_data, int *request_id) |
Inserts multiple rows in one request. | |
int | data_control_sql_register_insert_bulk_data_response_cb (data_control_h provider, data_control_bulk_cb callback, void *user_data) |
Registers an insert bulk data callback for the SQL data control response. The application is notified when a data control response is received from the provider. | |
int | data_control_sql_unregister_insert_bulk_data_response_cb (data_control_h provider) |
Unregisters the insert bulk data callback. | |
int | data_control_sql_bind_response_cb (data_control_h provider, data_control_sql_response_cb *callback, void *user_data) |
Binds a callback function to the SQL data control response. | |
int | data_control_sql_unbind_response_cb (data_control_h provider) |
Unbinds the callback function in the provider. | |
int | data_control_sql_bind_insert_bulk_data_response_cb (data_control_h provider, data_control_bulk_cb callback, void *user_data) |
Binds the insert bulk data callback to the SQL data control response. | |
int | data_control_sql_unbind_insert_bulk_data_response_cb (data_control_h provider) |
Unbinds the insert bulk data callback in the provider. | |
int | data_control_sql_get_handle_id (data_control_h provider, int *handle_id) |
Gets the handle ID for provider. | |
int | data_control_sql_step_first (result_set_cursor cursor) |
Moves the cursor to the first position. | |
int | data_control_sql_step_last (result_set_cursor cursor) |
Moves the cursor to the last position. | |
int | data_control_sql_step_next (result_set_cursor cursor) |
Moves the cursor to the next position. | |
int | data_control_sql_step_previous (result_set_cursor cursor) |
Moves the cursor to the previous position. | |
int | data_control_sql_get_column_count (result_set_cursor cursor) |
Gets the number of columns for this cursor. | |
int | data_control_sql_get_column_name (result_set_cursor cursor, int column_index, char *name) |
Gets the name of the column indicated by the specified index. | |
int | data_control_sql_get_column_item_size (result_set_cursor cursor, int column_index) |
Gets the size of the data in the column indicated by the specified index. | |
int | data_control_sql_get_column_item_type (result_set_cursor cursor, int column_index, data_control_sql_column_type_e *type) |
Gets the type of the column indicated by the specified index. | |
int | data_control_sql_get_blob_data (result_set_cursor cursor, int column_index, void *data, int size) |
Gets a blob data from the column indicated by the specified index. | |
int | data_control_sql_get_int_data (result_set_cursor cursor, int column_index, int *data) |
Gets an int value from the column indicated by the specified index. | |
int | data_control_sql_get_int64_data (result_set_cursor cursor, int column_index, long long *data) |
Gets a long long value from the column indicated by the specified index. | |
int | data_control_sql_get_double_data (result_set_cursor cursor, int column_index, double *data) |
Gets a double value from the column indicated by the specified index. | |
int | data_control_sql_get_text_data (result_set_cursor cursor, int column_index, char *data) |
Gets a text value from the column indicated by the specified index. | |
Typedefs | |
typedef void(* | data_control_bulk_cb )(int request_id, data_control_h provider, data_control_bulk_result_data_h bulk_results, bool provider_result, const char *error, void *user_data) |
Called when a response is received for a bulk operation from a provider application. | |
typedef void(* | data_control_map_get_response_cb )(int request_id, data_control_h provider, char **result_value_list, int result_value_count, bool provider_result, const char *error, void *user_data) |
Called when the result value list is received from the key-value structured data control provider. | |
typedef void(* | data_control_map_set_response_cb )(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) |
Called when the response is received for a set operation from the key-value structured data control provider. | |
typedef void(* | data_control_map_add_response_cb )(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) |
Called when the response is received for an add operation from the key-value structured data control provider. | |
typedef void(* | data_control_map_remove_response_cb )(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) |
Called when the response is received for a remove operation from the key-value structured data control provider. | |
typedef void(* | data_control_data_change_cb )(data_control_h provider, data_control_data_change_type_e type, bundle *data, void *user_data) |
Called when received data changed notification from provider application. | |
typedef void(* | data_control_add_callback_result_cb )(data_control_h provider, data_control_error_e result, int callback_id, void *user_data) |
Called when the consumer receives the result of the data change callback adding operation. | |
typedef void(* | data_control_sql_insert_response_cb )(int request_id, data_control_h provider, long long inserted_row_id, bool provider_result, const char *error, void *user_data) |
Called when a response is received for an insert operation from an application using the SQL-friendly interface based data control. | |
typedef void(* | data_control_sql_delete_response_cb )(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) |
Called when a response is received for a delete operation from an application using the SQL-friendly interface based data control. | |
typedef void(* | data_control_sql_select_response_cb )(int request_id, data_control_h provider, result_set_cursor enumerator, bool provider_result, const char *error, void *user_data) |
Called when a response is received for a select operation from an application using the SQL-friendly interface based data control. | |
typedef void(* | data_control_sql_update_response_cb )(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) |
Called when a response is received for an update operation from an application using the SQL-friendly interface based data control. | |
typedef struct result_set_s * | result_set_cursor |
The structure type to represent a SQL result set. |
typedef void(* data_control_add_callback_result_cb)(data_control_h provider, data_control_error_e result, int callback_id, void *user_data) |
Called when the consumer receives the result of the data change callback adding operation.
The following error codes can be delivered:
DATA_CONTROL_ERROR_NONE,
DATA_CONTROL_ERROR_OUT_OF_MEMORY,
DATA_CONTROL_ERROR_IO_ERROR,
DATA_CONTROL_ERROR_PERMISSION_DENIED,
DATA_CONTROL_ERROR_MAX_EXCEEDED
[in] | provider | The provider handle. provider is valid only inside this function provider should not be destroyed. |
[in] | result | Add data change callback result |
[in] | callback_id | Added callback ID |
[in] | user_data | The user data passed from the add function |
typedef void(* data_control_bulk_cb)(int request_id, data_control_h provider, data_control_bulk_result_data_h bulk_results, bool provider_result, const char *error, void *user_data) |
Called when a response is received for a bulk operation from a provider application.
[in] | request_id | The request ID |
[in] | provider | The provider handle. provider is valid only inside this function. provider should not be destroyed. |
[in] | bulk_results | The result data for each insert request. bulk_results is valid only inside this function. bulk_results should not be freed. |
[in] | provider_result | Set to true if the data control provider successfully processed, otherwise set to false |
[in] | error | The error message from the data control provider. error is valid only inside this function. error should not be freed. |
[in] | user_data | The user data passed from the register function |
typedef void(* data_control_data_change_cb)(data_control_h provider, data_control_data_change_type_e type, bundle *data, void *user_data) |
Called when received data changed notification from provider application.
[in] | provider | The provider handle. provider is valid only inside this function provider should not be destroyed. |
[in] | type | Changed data type |
[in] | data | Data from provider, intended to contain information about changed data data is valid only inside this function To use outside the callback, make a copy. data should not be freed |
[in] | user_data | The user data passed from the add function |
typedef void(* data_control_map_add_response_cb)(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) |
Called when the response is received for an add operation from the key-value structured data control provider.
[in] | request_id | The request ID that identifies the data control |
[in] | provider | The provider handle. provider is valid only inside this function provider should not be destroyed. |
[in] | provider_result | Set to true if the data control provider successfully processed, otherwise set to false |
[in] | error | The error message from the data control provider |
[in] | user_data | The user data passed from the register function |
typedef void(* data_control_map_get_response_cb)(int request_id, data_control_h provider, char **result_value_list, int result_value_count, bool provider_result, const char *error, void *user_data) |
Called when the result value list is received from the key-value structured data control provider.
int i; for (i = 0; i < resule_value_count; i++) free(result_value_list[i]); free(result_value_list);
[in] | request_id | The request ID |
[in] | provider | The provider handle. provider is valid only inside this function provider should not be destroyed. |
[in] | result_value_list | The result value list of the data control request that gets the matching values |
[in] | result_value_count | The number of the values |
[in] | provider_result | Set to true if the data control provider is successfully processed, otherwise set to false |
[in] | error | The error message from the data control provider |
[in] | user_data | The user data passed from the register function |
typedef void(* data_control_map_remove_response_cb)(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) |
Called when the response is received for a remove operation from the key-value structured data control provider.
[in] | request_id | The request ID that identifies the data control |
[in] | provider | The provider handle. provider is valid only inside this function provider should not be destroyed. |
[in] | provider_result | Set to true if the data control provider successfully processed, otherwise set to false |
[in] | error | The error message from the data control provider |
[in] | user_data | The user data passed from the register function |
typedef void(* data_control_map_set_response_cb)(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) |
Called when the response is received for a set operation from the key-value structured data control provider.
[in] | request_id | The request ID that identifies the data control |
[in] | provider | The provider handle. provider is valid only inside this function provider should not be destroyed. |
[in] | provider_result | Set to true if the data control provider successfully processed, otherwise false |
[in] | error | The error message from the data control provider |
[in] | user_data | The user data passed from the register function |
typedef void(* data_control_sql_delete_response_cb)(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) |
Called when a response is received for a delete operation from an application using the SQL-friendly interface based data control.
[in] | request_id | The request ID that identifies the data control |
[in] | provider | The provider handle. provider is valid only inside this function provider should not be destroyed |
[in] | provider_result | Set to true if the data control provider successfully processed, otherwise set to false |
[in] | error | The error message from the data control provider |
[in] | user_data | The user data passed from the register function |
typedef void(* data_control_sql_insert_response_cb)(int request_id, data_control_h provider, long long inserted_row_id, bool provider_result, const char *error, void *user_data) |
Called when a response is received for an insert operation from an application using the SQL-friendly interface based data control.
[in] | request_id | The request ID |
[in] | provider | The provider handle. provider is valid only inside this function provider should not be destroyed |
[in] | inserted_row_id | The inserted row ID set by the data control |
[in] | provider_result | Set to true if the data control provider successfully processed, otherwise set to false |
[in] | error | The error message from the data control provider |
[in] | user_data | The user data passed from the register function |
typedef void(* data_control_sql_select_response_cb)(int request_id, data_control_h provider, result_set_cursor enumerator, bool provider_result, const char *error, void *user_data) |
Called when a response is received for a select operation from an application using the SQL-friendly interface based data control.
[in] | request_id | The request ID |
[in] | provider | The provider handle. provider is valid only inside this function provider should not be destroyed |
[in] | enumerator | The enumerator for navigating the result of data control select request |
[in] | provider_result | Set to true if the data control provider successfully processed, otherwise set to false |
[in] | error | The error message from the data control provider |
[in] | user_data | The user data passed from the register function |
typedef void(* data_control_sql_update_response_cb)(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) |
Called when a response is received for an update operation from an application using the SQL-friendly interface based data control.
[in] | request_id | The request ID |
[in] | provider | The provider handle. provider is valid only inside this function provider should not be destroyed |
[in] | provider_result | Set to true if the data control provider successfully processed, otherwise set to false |
[in] | error | The error message from the data control provider |
[in] | user_data | The user data passed from the register function |
typedef struct result_set_s* result_set_cursor |
The structure type to represent a SQL result set.
This type can be used to enumerate through the result set of an SQL query.
int data_control_add_data_change_cb | ( | data_control_h | provider, |
data_control_data_change_cb | callback, | ||
void * | user_data, | ||
data_control_add_callback_result_cb | result_callback, | ||
void * | result_cb_user_data, | ||
int * | callback_id | ||
) |
Asynchronously adds a data changed callback, which is called whenever the provider's data is changed.
The function attempts to add the callback asynchronously and calls result_callback to inform about the result of the attempt.
If the function is successful, result_callback will be called.
The provider will call any filters which were added for the callback addition process.
[in] | provider | Target provider handle |
[in] | callback | The callback function to be called when consumer receives data change notification |
[in] | user_data | The user data to be passed to the callback function |
[in] | result_callback | The callback function to be called when consumer receives add data change callback process result |
[in] | result_cb_user_data | The user data to be passed to the result_callback function |
[out] | callback_id | Added callback ID, it can be used to remove the callback |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_PERMISSION_DENIED | Permission denied |
int data_control_bulk_data_add | ( | data_control_bulk_data_h | bulk_data, |
bundle * | data | ||
) |
Adds a bundle to bulk data.
[in] | bulk_data | The bulk data handle |
[in] | data | The bundle |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_bulk_data_create | ( | data_control_bulk_data_h * | bulk_data | ) |
Creates bulk data.
[out] | bulk_data | The bulk data handle |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_bulk_data_destroy | ( | data_control_bulk_data_h | bulk_data | ) |
Destroys bulk data.
[in] | bulk_data | The bulk data handle |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_bulk_data_get_count | ( | data_control_bulk_data_h | bulk_data, |
int * | count | ||
) |
Gets the bulk data bundle count.
[in] | bulk_data | The bulk data handle |
[out] | count | The bundle count |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_bulk_data_get_data | ( | data_control_bulk_data_h | bulk_data, |
int | idx, | ||
bundle ** | data | ||
) |
Gets the n-th bundle from bulk data.
[in] | bulk_data | The bulk data handle |
[in] | idx | The bundle index. Index starts at 0 |
[out] | data | The n-th bundle. |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_bulk_result_data_add | ( | data_control_bulk_result_data_h | result_data, |
bundle * | data, | ||
int | result | ||
) |
Adds bulk data.
[in] | result_data | The bulk result data handle |
[in] | data | The bundle |
[in] | result | Bulk operation result. Possible values and their meaning are defined by the developer. |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_bulk_result_data_create | ( | data_control_bulk_result_data_h * | result_data | ) |
Creates bulk result data.
[out] | result_data | The bulk result data handle |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_bulk_result_data_destroy | ( | data_control_bulk_result_data_h | result_data | ) |
Destroys bulk result data.
[in] | result_data | The bulk result data handle |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_bulk_result_data_get_count | ( | data_control_bulk_result_data_h | result_data, |
int * | count | ||
) |
Gets the bulk result data bundle count.
[in] | result_data | The bulk result data handle |
[out] | count | The bundle count |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_bulk_result_data_get_result_data | ( | data_control_bulk_result_data_h | result_data, |
int | idx, | ||
bundle ** | data, | ||
int * | result | ||
) |
Gets the n-th bundle from bulk result data.
[in] | result_data | The bulk result data handle |
[in] | idx | The bundle index. Index starts at 0 |
[out] | data | The n-th bundle |
[out] | result | Bulk operation result. Possible values and their meaning are defined by the developer. |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_map_add | ( | data_control_h | provider, |
const char * | key, | ||
const char * | value, | ||
int * | request_id | ||
) |
Adds the value associated with the specified key to the key-values map owned by the key-value structured data control provider.
void map_add_response_cb(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) { if (provider_result) LOGI("The add operation is successful"); else LOGI("The add operation for the request %d is failed. error message: %s", request_id, error); } data_control_map_response_cb map_callback; { int result = 0; int req_id = 0; const char *key = "key"; const char *value = "value"; map_callback.add_cb = map_add_response_cb; result = data_control_map_register_response_cb(provider, &map_callback, NULL); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Registering the callback function is failed with error: %d", result); return result; } result = data_control_map_add(provider, key, value, &req_id); if (result != DATA_CONTROL_ERROR_NONE) LOGE("Adding %s-%s pair is failed with error: %d", key, value, result); else LOGI("req_id is %d", req_id); return result; }
[in] | provider | The provider handle |
[in] | key | The key of the value to add |
[in] | value | The value to add |
[out] | request_id | The request ID |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_MAX_EXCEEDED | Too long argument |
DATA_CONTROL_ERROR_PERMISSION_DENIED | Permission denied |
int data_control_map_add_bulk_data | ( | data_control_h | provider, |
data_control_bulk_data_h | bulk_data, | ||
int * | request_id | ||
) |
Adds multiple key-value pairs in one request.
void map_bulk_add_response_cb(int request_id, data_control_h provider, data_control_bulk_result_data_h bulk_results, bool provider_result, const char *error, void *user_data) { if (provider_result) LOGI("The add operation is successful"); else LOGI("The add operation for the request %d is failed. error message: %s", request_id, error); } data_control_map_response_cb map_callback; { data_control_bulk_data_h bulk_data; int req_id; bundle *b1; bundle *b2; int result = 0; int req_id = 0; int count; result = data_control_map_register_add_bulk_data_response_cb(provider, map_bulk_add_response_cb, user_data); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Registering the callback function is failed with error: %d", result); return result; } b1 = bundle_create(); bundle_add_str(b1, "key", "test key"); bundle_add_str(b1, "value", "test value"); b2 = bundle_create(); bundle_add_str(b2, "key", "test key2"); bundle_add_str(b2, "value", "test value2"); data_control_bulk_data_create(&bulk_data); data_control_bulk_data_add(bulk_data, b1); data_control_bulk_data_add(bulk_data, b2); data_control_bulk_data_get_count(bulk_data, &count); dlog_print(DLOG_INFO, LOG_TAG, "bulk add count %d ", count); data_control_map_add_bulk_data(provider, bulk_data, &req_id); data_control_bulk_data_destroy(bulk_data); bundle_free(b1); bundle_free(b2); return result; }
[in] | provider | The provider handle |
[in] | bulk_data | The bulk data handle |
[out] | request_id | The request ID |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_MAX_EXCEEDED | Too long argument. Bulk data total length cannot exceed 1MB |
DATA_CONTROL_ERROR_PERMISSION_DENIED | Permission denied |
int data_control_map_bind_add_bulk_data_response_cb | ( | data_control_h | provider, |
data_control_bulk_cb | callback, | ||
void * | user_data | ||
) |
Binds the add bulk data callback to the map data control response.
This function is very similar to data_control_map_register_add_bulk_data_response_cb(), which can register a callback for a given provider id. Calling data_control_map_register_add_bulk_data_response_cb() again overwrites the callback previously set for the provider id, which means that only one callback can be set for a given id. data_control_map_bind_add_bulk_data_response_cb() binds a callback to the handle of a provider, which allows registering multiple callbacks for a given provider id. To do that, you can create new data_control_h for the same provider id and register callback for the data_control_h.
[in] | provider | The provider handle |
[in] | callback | The callback function to be called when a response is received |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_map_bind_response_cb | ( | data_control_h | provider, |
data_control_map_response_cb * | callback, | ||
void * | user_data | ||
) |
Binds a response callback function to a data control provider handle. The application is notified when a data control response is received from the provider.
This function is very similar to data_control_map_register_response_cb(), which can register a callback for a given provider id. Calling data_control_map_register_response_cb() again overwrites the callback previously set for the provider id, which means that only one callback can be set for a given id. data_control_map_bind_response_cb() binds a callback to the handle of a provider, which allows registering multiple callbacks for a given provider id. To do that, you can create new data_control_h for the same provider id and register callback for the data_control_h.
[in] | provider | The provider handle |
[in] | callback | The callback function to be called when a response is received |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_map_create | ( | data_control_h * | provider | ) |
Creates a provider handle.
{ const char *provider_id = "http://tizen.org/datacontrol/provider/example"; const char *data_id = "table"; data_control_h provider; int result = 0; result = data_control_map_create(&provider); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Creating data control provider is failed with error: %d", result); return result; } result = data_control_map_set_provider_id(provider, provider_id); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Setting providerID is failed with error: %d", result); return result; } result = data_control_map_set_data_id(provider, data_id); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Setting dataID is failed with error: %d", result); return result; } // Executes some operations result = data_control_map_destroy(provider); if (result != DATA_CONTROL_ERROR_NONE) LOGE("Destroying data control provider is failed with error: %d", result); return result; }
[out] | provider | The provider handle |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
int data_control_map_destroy | ( | data_control_h | provider | ) |
Destroys the provider handle and releases all its resources.
[in] | provider | The provider handle |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_map_get | ( | data_control_h | provider, |
const char * | key, | ||
int * | request_id | ||
) |
Gets the value list associated with the specified key from the key-values map owned by the key-value structured data control provider.
void map_get_response_cb(int request_id, data_control_h provider, char **result_value_list, int ret_value_count, bool provider_result, const char *error, void *user_data) { if (provider_result) LOGI("The get operation is successful"); else LOGI("The get operation for the request %d is failed. error message: %s", request_id, error); } data_control_map_response_cb map_callback; { int result = 0; int req_id = 0; char *key = "key"; map_callback.get_cb = map_get_response_cb; result = data_control_map_register_response_cb(provider, &map_callback, NULL); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Registering the callback function is failed with error: %d", result); return result; } result = data_control_map_get(provider, key, &req_id); if (result != DATA_CONTROL_ERROR_NONE) LOGE("Getting the value list of the key(%s) is failed with error: %d", key, result); else LOGI("req_id is %d", req_id); return result; }
[in] | provider | The provider handle |
[in] | key | The key of the value list to obtain |
[out] | request_id | The request ID |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_MAX_EXCEEDED | Too long argument |
DATA_CONTROL_ERROR_PERMISSION_DENIED | Permission denied |
int data_control_map_get_data_id | ( | data_control_h | provider, |
char ** | data_id | ||
) |
Gets the data ID.
[in] | provider | The provider handle |
[out] | data_id | A string for identifying a specific table to operate The string consists of one or more components separated by a slash('/'). |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
int data_control_map_get_handle_id | ( | data_control_h | provider, |
int * | handle_id | ||
) |
Gets the handle ID for provider.
[in] | provider | The provider handle |
[out] | handle_id | The handle ID for provider |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_map_get_provider_id | ( | data_control_h | provider, |
char ** | provider_id | ||
) |
Gets the Provider ID.
[in] | provider | The provider handle |
[out] | provider_id | The data control provider ID |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
int data_control_map_get_with_page | ( | data_control_h | provider, |
const char * | key, | ||
int * | request_id, | ||
int | page_number, | ||
int | count_per_page | ||
) |
Gets the value list associated with the specified key from the key-values map owned by the key-value structured data control provider, with partition into pages.
[in] | provider | The provider handle |
[in] | key | The key of the value list to obtain |
[out] | request_id | The request ID |
[in] | page_number | The page number of the value set It starts from 1 . |
[in] | count_per_page | The desired maximum count of the data items per page |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_MAX_EXCEEDED | Too long argument |
DATA_CONTROL_ERROR_PERMISSION_DENIED | Permission denied |
int data_control_map_register_add_bulk_data_response_cb | ( | data_control_h | provider, |
data_control_bulk_cb | callback, | ||
void * | user_data | ||
) |
Registers an add bulk data callback for the MAP data control response. The application is notified when a data control response is received from the provider.
[in] | provider | The provider handle |
[in] | callback | The callback function to be called when a response is received |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_map_register_response_cb | ( | data_control_h | provider, |
data_control_map_response_cb * | callback, | ||
void * | user_data | ||
) |
Registers a callback function for the key-value structured data control response. The application is notified when a data control response is received from the provider.
[in] | provider | The provider handle |
[in] | callback | The callback function to be called when a response is received |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
int data_control_map_remove | ( | data_control_h | provider, |
const char * | key, | ||
const char * | value, | ||
int * | request_id | ||
) |
Removes the value associated with the specified key from the key-values map owned by the key-value structured data control provider.
void map_remove_response_cb(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) { if (provider_result) LOGI("The remove operation is successful"); else LOGI("The remove operation for the request %d is failed. error message: %s", request_id, error); } data_control_map_response_cb map_callback; { int result = 0; int req_id = 0; const char *key = "key"; const char *value = "value"; map_callback.remove_cb = map_remove_response_cb; result = data_control_map_register_response_cb(provider, &map_callback, NULL); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Registering the callback function is failed with error: %d", result); return result; } result = data_control_map_remove(provider, key, value, &req_id); if (result != DATA_CONTROL_ERROR_NONE) LOGE("Removing %s-%s pair is failed with error: %d", key, value, result); else LOGI("req_id is %d", req_id); return result; }
[in] | provider | The provider handle |
[in] | key | The key of the value to remove |
[in] | value | The value to remove |
[out] | request_id | The request ID |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_MAX_EXCEEDED | Too long argument |
DATA_CONTROL_ERROR_PERMISSION_DENIED | Permission denied |
int data_control_map_set | ( | data_control_h | provider, |
const char * | key, | ||
const char * | old_value, | ||
const char * | new_value, | ||
int * | request_id | ||
) |
Sets the value associated with the specified key to a new value.
void map_set_response_cb(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) { if (provider_result) LOGI("The set operation is successful"); else LOGI("The set operation for the request %d is failed. error message: %s", request_id, error); } data_control_map_response_cb map_callback; { int result = 0; int req_id = 0; char *key = "key"; char *old_value = "old value"; char *new_value = "new value"; map_callback.set_cb = map_set_response_cb; result = data_control_map_register_response_cb(provider, &map_callback, NULL); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Registering the callback function is failed with error: %d", result); return result; } result = data_control_map_set(provider, key, old_value, new_value, &req_id); if (result != DATA_CONTROL_ERROR_NONE) LOGE("Replacing old_value(%s) with new_value(%s) is failed with error: %d", old_value, new_value, result); else LOGI("req_id is %d", req_id); return result; }
[in] | provider | The provider handle |
[in] | key | The key of the value to replace |
[in] | old_value | The value to replace |
[in] | new_value | The new value that replaces the existing value |
[out] | request_id | The request ID |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_MAX_EXCEEDED | Too long argument |
DATA_CONTROL_ERROR_PERMISSION_DENIED | Permission denied |
int data_control_map_set_data_id | ( | data_control_h | provider, |
const char * | data_id | ||
) |
Sets the Data ID.
[in] | provider | The provider handle |
[in] | data_id | A string for identifying a specific table to operate The string consists of one or more components separated by a slash('/'). |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
int data_control_map_set_provider_id | ( | data_control_h | provider, |
const char * | provider_id | ||
) |
Sets the Provider ID.
[in] | provider | The provider handle |
[in] | provider_id | The data control provider ID |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
int data_control_map_unbind_add_bulk_data_response_cb | ( | data_control_h | provider | ) |
Unbinds the add bulk data callback in the provider.
[in] | provider | The provider handle |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_map_unbind_response_cb | ( | data_control_h | provider | ) |
Unbinds the callback function in the provider.
[in] | provider | The provider handle |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_map_unregister_add_bulk_data_response_cb | ( | data_control_h | provider | ) |
Unregisters the add bulk data callback.
[in] | provider | The provider handle |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_map_unregister_response_cb | ( | data_control_h | provider | ) |
Unregisters the callback function in the provider.
[in] | provider | The provider handle |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_remove_data_change_cb | ( | data_control_h | provider, |
int | callback_id | ||
) |
Removes data change callback function.
[in] | provider | Target provider handle |
[in] | callback_id | Target callback ID |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_PERMISSION_DENIED | Permission denied |
int data_control_sql_bind_insert_bulk_data_response_cb | ( | data_control_h | provider, |
data_control_bulk_cb | callback, | ||
void * | user_data | ||
) |
Binds the insert bulk data callback to the SQL data control response.
This function is very similar to data_control_sql_register_insert_bulk_data_response_cb(), which can register a callback for a given provider id. Calling data_control_sql_register_insert_bulk_data_response_cb() again overwrites the callback previously set for the provider id, which means that only one callback can be set for a given id. data_control_sql_bind_insert_bulk_data_response_cb() binds a callback to the handle of a provider, which allows registering multiple callbacks for a given provider id. To do that, you can create new data_control_h for the same provider id and register callback for the data_control_h.
[in] | provider | The provider handle |
[in] | callback | The callback function to be called when a response is received |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_bind_response_cb | ( | data_control_h | provider, |
data_control_sql_response_cb * | callback, | ||
void * | user_data | ||
) |
Binds a callback function to the SQL data control response.
This function is very similar to data_control_sql_register_response_cb(), which can register a callback for a given provider id. Calling data_control_sql_register_response_cb() again overwrites the callback previously set for the provider id, which means that only one callback can be set for a given id. data_control_sql_bind_response_cb() binds a callback to the handle of a provider, which allows registering multiple callbacks for a given provider id. To do that, you can create new data_control_h for the same provider id and register callback for the data_control_h.
[in] | provider | The provider handle |
[in] | callback | The callback function to be called when a response is received |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_create | ( | data_control_h * | provider | ) |
Creates a provider handle.
{ const char *provider_id = "http://tizen.org/datacontrol/provider/example"; const char *data_id = "table"; data_control_h provider; int result = 0; result = data_control_sql_create(&provider); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Creating data control provider is failed with error: %d", result); return result; } result = data_control_sql_set_provider_id(provider, provider_id); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Setting providerID is failed with error: %d", result); return result; } result = data_control_sql_set_data_id(provider, data_id); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Setting dataID is failed with error: %d", result); return result; } // Executes some operations result = data_control_sql_destroy(provider); if (result != DATA_CONTROL_ERROR_NONE) LOGE("Destroying data control provider is failed with error: %d", result); return result; }
[out] | provider | The provider handle |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
int data_control_sql_delete | ( | data_control_h | provider, |
const char * | where, | ||
int * | request_id | ||
) |
Deletes rows of a table owned by the SQL-type data control provider.
void sql_delete_response_cb(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) { if (provider_result) LOGI(The delete operation is successful"); else LOGI("The delete operation for the request %d is failed. error message: %s", request_id, error); } data_control_sql_response_cb sql_callback; { const char *where = "group = 'friend'"; int result = 0; int req_id = 0; sql_callback.delete_cb = sql_delete_response_cb; result = data_control_sql_register_response_cb(provider, &sql_callback, void *user_data); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Registering the callback function is failed with error: %d", result); return result; } result = data_control_sql_delete(provider, where, &req_id); if (result != DATA_CONTROL_ERROR_NONE) LOGE("Deleting is failed with error: %d", result); else LOGI("req_id is %d", req_id); return result; }
[in] | provider | The provider handle |
[in] | where | A filter to select the desired rows to delete It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as column1 = 'stringValue' and column2 = numericValue |
[out] | request_id | The request ID |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_PERMISSION_DENIED | Permission denied |
int data_control_sql_destroy | ( | data_control_h | provider | ) |
Destroys the provider handle and releases all its resources.
[in] | provider | The provider handle |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_get_blob_data | ( | result_set_cursor | cursor, |
int | column_index, | ||
void * | data, | ||
int | size | ||
) |
Gets a blob data from the column indicated by the specified index.
[in] | cursor | The cursor that navigates the result of the request for the select operation |
[in] | column_index | The index of the destination column |
[out] | data | The blob value obtained from the column |
[out] | size | The size of the data |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_MAX_EXCEEDED | Too long argument |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_get_column_count | ( | result_set_cursor | cursor | ) |
Gets the number of columns for this cursor.
[in] | cursor | The cursor that navigates the result of the request for the select operation |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_get_column_item_size | ( | result_set_cursor | cursor, |
int | column_index | ||
) |
Gets the size of the data in the column indicated by the specified index.
[in] | cursor | The cursor that navigates the result of the request for the select operation |
[in] | column_index | The index of the destination column |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_get_column_item_type | ( | result_set_cursor | cursor, |
int | column_index, | ||
data_control_sql_column_type_e * | type | ||
) |
Gets the type of the column indicated by the specified index.
[in] | cursor | The cursor that navigates the result of the request for the select operation |
[in] | column_index | The index of the destination column |
[out] | type | The type of the destination column |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_get_column_name | ( | result_set_cursor | cursor, |
int | column_index, | ||
char * | name | ||
) |
Gets the name of the column indicated by the specified index.
[in] | cursor | The cursor that navigates the result of the request for the select operation |
[in] | column_index | The index of the destination column |
[out] | name | The name of the destination column. You should provide a buffer for the column name. The limit of column name length is 4096 bytes |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_get_data_id | ( | data_control_h | provider, |
char ** | data_id | ||
) |
Gets the data ID.
[in] | provider | The provider handle |
[out] | data_id | A string for identifying a specific table to operate The string consists of one or more components separated by a slash('/') |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
int data_control_sql_get_double_data | ( | result_set_cursor | cursor, |
int | column_index, | ||
double * | data | ||
) |
Gets a double value from the column indicated by the specified index.
[in] | cursor | The cursor that navigates the result of the request for the select operation |
[in] | column_index | The index of the destination column |
[out] | data | The value obtained from the column as double |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_get_handle_id | ( | data_control_h | provider, |
int * | handle_id | ||
) |
Gets the handle ID for provider.
[in] | provider | The provider handle |
[out] | handle_id | The handle ID for provider |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_get_int64_data | ( | result_set_cursor | cursor, |
int | column_index, | ||
long long * | data | ||
) |
Gets a long long value from the column indicated by the specified index.
[in] | cursor | The cursor that navigates the result of the request for the select operation |
[in] | column_index | The index of the destination column |
[out] | data | The 64-bit integer value obtained from the column |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_get_int_data | ( | result_set_cursor | cursor, |
int | column_index, | ||
int * | data | ||
) |
Gets an int value from the column indicated by the specified index.
[in] | cursor | The cursor that navigates the result of the request for the select operation |
[in] | column_index | The index of the destination column |
[out] | data | The integer value obtained from the column |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_get_provider_id | ( | data_control_h | provider, |
char ** | provider_id | ||
) |
Gets the Provider ID.
[in] | provider | The provider handle |
[out] | provider_id | The data control provider ID |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
int data_control_sql_get_text_data | ( | result_set_cursor | cursor, |
int | column_index, | ||
char * | data | ||
) |
Gets a text value from the column indicated by the specified index.
[in] | cursor | The cursor that navigates the result of the request for the select operation |
[in] | column_index | The index of the destination column |
[out] | data | The value obtained from the column as text. You should provide a buffer for the data. You can get the size of data via data_control_sql_get_column_item_size() |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
int data_control_sql_insert | ( | data_control_h | provider, |
const bundle * | insert_data, | ||
int * | request_id | ||
) |
Inserts new rows in a table owned by the SQL-type data control provider.
void sql_insert_response_cb(int request_id, data_control_h provider, long long inserted_row_id, bool provider_result, const char *error, void *user_data) { if (provider_result) LOGI("The insert operation is successful"); else LOGI("The insert operation for the request %d is failed. error message: %s", request_id, error); } data_control_sql_response_cb sql_callback; { int result = 0; int req_id = 0; bundle *b = NULL; sql_callback.insert_cb = sql_insert_response_cb; result = data_control_sql_register_response_cb(provider, &sql_callback, void *user_data); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Registering the callback function is failed with error: %d", result); return result; } b = bundle_create(); bundle_add(b, "WORD", "test"); bundle_add(b, "WORD_DESC", "test description"); result = data_control_sql_insert(provider, b, &req_id); if (result != DATA_CONTROL_ERROR_NONE) LOGE("Inserting is failed with error: %d", result); else LOGI("req_id is %d", req_id); bundle_free(b); return result; }
[in] | provider | The provider handle |
[in] | insert_data | The column-value pairs to insert If the value is a string, then the value must be wrapped in single quotes, else it does not need to be wrapped in single quotes |
[out] | request_id | The request ID |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_PERMISSION_DENIED | Permission denied |
DATA_CONTROL_ERROR_MAX_EXCEEDED | Too long argument |
int data_control_sql_insert_bulk_data | ( | data_control_h | provider, |
data_control_bulk_data_h | bulk_data, | ||
int * | request_id | ||
) |
Inserts multiple rows in one request.
void sql_bulk_insert_response_cb(int request_id, data_control_h provider, data_control_bulk_result_data_h bulk_results, bool provider_result, const char *error, void *user_data) { if (provider_result) LOGI("The bulk insert operation is successful"); else LOGI("The bulk insert operation for the request %d is failed. error message: %s", request_id, error); } data_control_sql_response_cb sql_callback; { data_control_bulk_data_h bulk_data; int req_id; bundle *b1; bundle *b2; int result = 0; int req_id = 0; int bulk_count = 0; result = data_control_sql_register_insert_bulk_data_response_cb(provider, sql_bulk_insert_response_cb, user_data); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Registering the callback function is failed with error: %d", result); return result; } b1 = bundle_create(); bundle_add_str(b1, "WORD", "'test'"); bundle_add_str(b1, "WORD_DESC", "'test description'"); b2 = bundle_create(); bundle_add_str(b2, "WORD", "'test2'"); bundle_add_str(b2, "WORD_DESC", "'test2 description'"); data_control_bulk_data_create(&bulk_data); data_control_bulk_data_add(bulk_data, b1); data_control_bulk_data_add(bulk_data, b2); data_control_bulk_data_get_count(bulk_data, &bulk_count); dlog_print(DLOG_INFO, LOG_TAG, "bulk insert count %d ", bulk_count); data_control_sql_insert_bulk_data(provider, bulk_data, &req_id); data_control_bulk_data_destroy(bulk_data); bundle_free(b1); bundle_free(b2); return result; }
[in] | provider | The provider handle |
[in] | bulk_data | The bulk data handle |
[out] | request_id | The request ID |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_PERMISSION_DENIED | Permission denied |
DATA_CONTROL_ERROR_MAX_EXCEEDED | Too long argument |
int data_control_sql_register_insert_bulk_data_response_cb | ( | data_control_h | provider, |
data_control_bulk_cb | callback, | ||
void * | user_data | ||
) |
Registers an insert bulk data callback for the SQL data control response. The application is notified when a data control response is received from the provider.
[in] | provider | The provider handle |
[in] | callback | The callback function to be called when a response is received |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_register_response_cb | ( | data_control_h | provider, |
data_control_sql_response_cb * | callback, | ||
void * | user_data | ||
) |
Registers a callback function for the SQL data control response.
[in] | provider | The provider handle |
[in] | callback | The callback function to be called when a response is received |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
int data_control_sql_select | ( | data_control_h | provider, |
char ** | column_list, | ||
int | column_count, | ||
const char * | where, | ||
const char * | order, | ||
int * | request_id | ||
) |
Selects the specified columns to be queried.
void sql_select_response_cb(int request_id, data_control_h provider, result_set_cursor *enumerator, bool provider_result, const char *error, void *user_data) { if (provider_result) LOGI("The select operation is successful"); else LOGI("The select operation for the request %d is failed. error message: %s", request_id, error); } data_control_sql_response_cb sql_callback; { int result = 0; int req_id = 0; char *column_list[2]; column_list[0] = "WORD"; column_list[1] = "WORD_DESC"; const char *where = "WORD = 'test'"; const char *order = "WORD ASC"; sql_callback.select_cb = sql_select_response_cb; result = data_control_sql_register_response_cb(provider, &sql_callback, void *user_data); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Registering the callback function is failed with error: %d", result); return result; } result = data_control_sql_select(provider, column_list, 2, where, order, &req_id); if (result != DATA_CONTROL_ERROR_NONE) LOGE("Selecting is failed with error: %d", result); else LOGI("req_id is %d", req_id); return result; }
[in] | provider | The provider handle |
[in] | column_list | The column list to query |
[in] | column_count | The total number of columns to be queried |
[in] | where | A filter to select the desired rows It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as column1 = 'stringValue' and column2 = numericValue |
[in] | order | The sorting order of the rows to query It is an SQL 'ORDER BY' clause excluding the 'ORDER BY' itself. |
[out] | request_id | The request ID |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_PERMISSION_DENIED | Permission denied |
int data_control_sql_select_with_page | ( | data_control_h | provider, |
char ** | column_list, | ||
int | column_count, | ||
const char * | where, | ||
const char * | order, | ||
int | page_number, | ||
int | count_per_page, | ||
int * | request_id | ||
) |
Selects the specified columns to be queried, with partition into pages.
[in] | provider | The provider handle |
[in] | column_list | The column list to query |
[in] | column_count | The total number of columns to be queried |
[in] | where | A filter to select the desired rows It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as column1 = 'stringValue' and column2 = numericValue |
[in] | order | The sorting order of the rows to query It is an SQL 'ORDER BY' clause excluding the 'ORDER BY' itself |
[in] | page_number | The page number of the result set It starts from 1 |
[in] | count_per_page | The desired maximum count of rows on a page |
[out] | request_id | The request ID |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_PERMISSION_DENIED | Permission denied |
int data_control_sql_set_data_id | ( | data_control_h | provider, |
const char * | data_id | ||
) |
Sets the data ID.
[in] | provider | The provider handle |
[in] | data_id | A string for identifying a specific table to operate The string consists of one or more components separated by a slash('/') |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
{ bundle *b; int ret; // Insert data to Note table ret = data_control_sql_set_data_id(ad->provider_h, "Note"); if (ret != DATA_CONTROL_ERROR_NONE) dlog_print(DLOG_ERROR, LOG_TAG, "setting data id failed with error: %d", ret); b = bundle_create(); bundle_add_str(b, ""TITLE"", "test"); bundle_add_str(b, "CONTENTS", "test contents"); data_control_sql_insert(ad->provider_h, b, &req_id); bundle_free(b); // Insert data to Dictionary table ret = data_control_sql_set_data_id(ad->provider_h, "Dictionary"); if (ret != DATA_CONTROL_ERROR_NONE) dlog_print(DLOG_ERROR, LOG_TAG, "setting data id failed with error: %d", ret); b = bundle_create(); bundle_add_str(b, "WORD", "test"); bundle_add_str(b, "WORD_DESC", "test desc"); data_control_sql_insert(ad->provider_h, b, &req_id); bundle_free(b); }
int data_control_sql_set_provider_id | ( | data_control_h | provider, |
const char * | provider_id | ||
) |
Sets the Provider ID.
[in] | provider | The provider handle |
[in] | provider_id | The data control provider ID |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
int data_control_sql_step_first | ( | result_set_cursor | cursor | ) |
Moves the cursor to the first position.
void sql_select_response_cb(int request_id, data_control_h provider, result_set_cursor cursor, bool provider_result, const char *error) { char person_name[32] = {0,}; long long person_number = -1; data_control_sql_step_first(cursor); data_control_sql_get_text_data(cursor, 0, person_name); data_control_sql_get_int64_data(cursor, 1, &person_number); printf("The person %s has the number %l", person_name, person_number); }
[in] | cursor | The cursor that navigates the result of the request for the select operation |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_step_last | ( | result_set_cursor | cursor | ) |
Moves the cursor to the last position.
void sql_select_response_cb(int request_id, data_control_h provider, result_set_cursor cursor, bool provider_result, const char *error) { char person_name[32] = {0,}; long long person_number = -1; data_control_sql_step_last(cursor); data_control_sql_get_text_data(cursor, 0, person_name); data_control_sql_get_int64_data(cursor, 1, &person_number); printf("The person %s has the number %l", person_name, person_number); }
[in] | cursor | The cursor that navigates the result of data control select request |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_step_next | ( | result_set_cursor | cursor | ) |
Moves the cursor to the next position.
void sql_select_response_cb(int request_id, data_control_h provider, result_set_cursor cursor, bool provider_result, const char *error) { char person_name[32] = {0,}; long long person_number = -1; while (data_control_sql_step_next(cursor) == DATA_CONTROL_ERROR_NONE) { data_control_sql_get_text_data(cursor, 0, person_name); data_control_sql_get_int64_data(cursor, 1, &person_number); printf("The person %s has the number %l", person_name, person_number); } }
[in] | cursor | The cursor that navigates the result of the request for the select operation |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_step_previous | ( | result_set_cursor | cursor | ) |
Moves the cursor to the previous position.
[in] | cursor | The cursor that navigates the result of the request for the select operation |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_unbind_insert_bulk_data_response_cb | ( | data_control_h | provider | ) |
Unbinds the insert bulk data callback in the provider.
[in] | provider | The provider handle |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_unbind_response_cb | ( | data_control_h | provider | ) |
Unbinds the callback function in the provider.
[in] | provider | The provider handle |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
Unregisters the insert bulk data callback.
[in] | provider | The provider handle |
0
on success, otherwise a negative error value DATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_unregister_response_cb | ( | data_control_h | provider | ) |
Unregisters the callback function in the provider.
[in] | provider | The provider handle |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
int data_control_sql_update | ( | data_control_h | provider, |
const bundle * | update_data, | ||
const char * | where, | ||
int * | request_id | ||
) |
Updates values of a table owned by the SQL-type data control provider.
void sql_update_response_cb(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) { if (provider_result) LOGI("The update operation is successful"); else LOGI("The update operation for the request %d is failed. error message: %s", request_id, error); } data_control_sql_response_cb sql_callback; { int result = 0; int req_id = 0; const char *where = "WORD = 'test'"; bundle *b = NULL; sql_callback.update_cb = sql_update_response_cb; result = data_control_sql_register_response_cb(provider, &sql_callback, void *user_data); if (result != DATA_CONTROL_ERROR_NONE) { LOGE("Registering the callback function is failed with error: %d", result); return result; } b = bundle_create(); bundle_add(b, "WORD", "test_new"); result = data_control_sql_update(provider, b, where, &req_id); if (result != DATA_CONTROL_ERROR_NONE) LOGE("Updating is failed with error: %d", result); else LOGI("req_id is %d", req_id); bundle_free(b); return result; }
[in] | provider | The provider handle |
[in] | update_data | The column-value pairs to update If the value is a string, the value must be wrapped in single quotes, else it does not need to be wrapped in single quotes |
[in] | where | A filter to select the desired rows to update It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as column1 = 'stringValue' and column2 = numericValue |
[out] | request_id | The request ID |
0
on success, otherwise a negative error valueDATA_CONTROL_ERROR_NONE | Successful |
DATA_CONTROL_ERROR_INVALID_PARAMETER | Invalid parameter |
DATA_CONTROL_ERROR_IO_ERROR | I/O error |
DATA_CONTROL_ERROR_OUT_OF_MEMORY | Out of memory |
DATA_CONTROL_ERROR_PERMISSION_DENIED | Permission denied |
DATA_CONTROL_ERROR_MAX_EXCEEDED | Too long argument |