Tizen Native API
|
Functions | |
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. | |
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_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. | |
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_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_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 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 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 from the key-value structured data control provider. | |
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. |
All applications can request data shared by other applications using data control.
Required Header
#include <data_control.h>
Overview
You can get a datacontrol_h instance from data_control_map_create() or data_control_sql_create().
- Map type data control If you specify datacontrol_h using the data_control_map_create(), data_control_map_set_provider_id(), or data_control_map_set_data_id() method, you can get the specific map-type data control uniquely. After resolving the data control, call data_control_map APIs, such as data_control_map_set(), data_control_map_get(), data_control_map_add(), and data_control_map_remove(). The result is returned by response callback, such as data_control_map_get_response_cb(), data_control_map_set_response_cb(), data_control_map_add_response_cb() or data_control_map_remove_response_cb() of the data_control_map_response_cb struct. The response callback is invoked when a service application finishes its operation.
- SQL type data control If you specify the datacontrol_h using the data_control_sql_create(), data_control_sql_set_provider_id(), or data_control_sql_set_data_id() method, you can get the specific SQL-type data control uniquely. After resolving the data control, call data_control_sql APIs, such as data_control_sql_select(), data_control_sql_insert(), data_control_sql_update(), and data_control_sql_delete(). The result is returned by response callback, such as data_control_sql_select_response_cb(), data_control_sql_insert_response_cb(), data_control_sql_update_response_cb() or data_control_sql_delete_response_cb() of the data_control_sql_response_cb struct. The response callback is invoked when a service application finishes its operation. Once you get result_set_cursor using data_control_sql_select_response_cb(), then you can use following functions to get the information:
- data_control_sql_step_first()
- data_control_sql_step_last()
- data_control_sql_step_next()
- data_control_sql_step_previous()
- data_control_sql_get_column_count()
- data_control_sql_get_column_name()
- data_control_sql_get_column_item_size()
- data_control_sql_get_column_item_type()
- data_control_sql_get_blob_data()
- data_control_sql_get_int_data()
- data_control_sql_get_int64_data()
- data_control_sql_get_double_data()
- data_control_sql_get_text_data()
Typedef Documentation
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 from the key-value structured data control provider.
- Since :
- 2.3
- Parameters:
-
[in] request_id The request ID that identifies the data control [in] provider The provider handle [in] provider_result Set to true
if the data control provider successfully processed,
otherwise set tofalse
[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.
- Since :
- 2.3
- Remarks:
- You must release resule_value_list using free() after it is used. Note that result_value list is an array of char *. Its length is result_value_count. You should release all the elements in the result_value_list array and result_value_list itself like the following code.
int i; for (i = 0; i < resule_value_count; i++) free(result_value_list[i]); free(result_value_list);
- Parameters:
-
[in] request_id The request ID [in] provider The provider handle [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 tofalse
[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 from the key-value structured data control provider.
- Since :
- 2.3
- Parameters:
-
[in] request_id The request ID that identifies the data control [in] provider The provider handle [in] provider_result Set to true
if the data control provider successfully processed,
otherwise set tofalse
[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 from the key-value structured data control provider.
- Since :
- 2.3
- Parameters:
-
[in] request_id The request ID that identifies the data control [in] provider The provider handle [in] provider_result Set to true
if the data control provider successfully processed,
otherwisefalse
[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.
- Since :
- 2.3
- Parameters:
-
[in] request_id The request ID that identifies the data control [in] provider_result Set to true
if the data control provider successfully processed,
otherwise set tofalse
[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.
- Since :
- 2.3
- Parameters:
-
[in] request_id The request ID [in] provider The provider handle [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 tofalse
[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.
- Since :
- 2.3
- Remarks:
- enumerator will be removed after this callback is called.
- Parameters:
-
[in] request_id The request ID [in] provider The provider handle [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 tofalse
[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.
- Since :
- 2.3
- Parameters:
-
[in] request_id The request ID [in] provider The provider handle [in] provider_result Set to true
if the data control provider successfully processed,
otherwise set tofalse
[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.
- Since :
- 2.3
Function Documentation
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.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/datasharing
http://tizen.org/privilege/appmanager.launch
- Remarks:
- If you want to use this api, you must add privileges.
- The following example demonstrates how to use the data_control_map_add() method.
void map_add_response_cb(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) { if (provider_result) { dlog_print(DLOG_INFO, LOG_TAG, "The add operation is successful"); } else { dlog_print(DLOG_INFO, LOG_TAG, "The add operation for the request %d is failed. error message: %s", request_id, error); } } data_control_map_response_cb map_callback; int main() { 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) { dlog_print(DLOG_ERROR, LOG_TAG, "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) { dlog_print(DLOG_ERROR, LOG_TAG, "Adding %s-%s pair is failed with error: %d", key, value, result); } else { dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id); } return result; }
- Parameters:
-
[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
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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_create | ( | data_control_h * | provider | ) |
Creates a provider handle.
- Since :
- 2.3
- Remarks:
- The following example demonstrates how to use the data_control_map_create() method.
int main() { 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) { dlog_print(DLOG_ERROR, LOG_TAG, "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) { dlog_print(DLOG_ERROR, LOG_TAG, "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) { dlog_print(DLOG_ERROR, LOG_TAG, "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) { dlog_print(DLOG_ERROR, LOG_TAG, "Destorying data control provider is failed with error: %d", result); } return result; }
- Parameters:
-
[out] provider The provider handle
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DATA_CONTROL_ERROR_NONE Successful DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
- See also:
- data_control_map_destroy()
int data_control_map_destroy | ( | data_control_h | provider | ) |
Destroys the provider handle and releases all its resources.
- Since :
- 2.3
- Remarks:
- When operations of data control are finished, this function must be called to prevent memory leak.
- Parameters:
-
[in] provider The provider handle
- Returns:
0
on success, otherwise a negative error value
- See also:
- data_control_map_create()
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.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/datasharing
http://tizen.org/privilege/appmanager.launch
- Remarks:
- If you want to use this api, you must add privileges.
- If the length of value list associated with the key is larger than 20, this API only returns the first 20 values.
- The following example demonstrates how to use the data_control_map_get() method.
- If the length of value list associated with the key is larger than 20, value list only include first 20 values.
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) { dlog_print(DLOG_INFO, LOG_TAG, "The get operation is successful"); } else { dlog_print(DLOG_INFO, LOG_TAG, "The get operation for the request %d is failed. error message: %s", request_id, error); } } data_control_map_response_cb map_callback; int main() { 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) { dlog_print(DLOG_ERROR, LOG_TAG, "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) { dlog_print(DLOG_ERROR, LOG_TAG, "Getting the value list of the key(%s) is failed with error: %d", key, result); } else { dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id); } return result; }
- Parameters:
-
[in] provider The provider handle [in] key The key of the value list to obtain [out] request_id The request ID
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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
- See also:
- data_control_map_get_with_page()
int data_control_map_get_data_id | ( | data_control_h | provider, |
char ** | data_id | ||
) |
Gets the data ID.
- Since :
- 2.3
- Remarks:
- You must release data_id using free() after it is used.
- Parameters:
-
[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('/').
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DATA_CONTROL_ERROR_NONE Successful DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
- See also:
- data_control_map_set_data_id()
int data_control_map_get_provider_id | ( | data_control_h | provider, |
char ** | provider_id | ||
) |
Gets the Provider ID.
- Since :
- 2.3
- Remarks:
- You must release provider_id using free() after it is used.
- Parameters:
-
[in] provider The provider handle [out] provider_id The data control provider ID
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DATA_CONTROL_ERROR_NONE Successful DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
- See also:
- data_control_map_set_provider_id()
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.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/datasharing
http://tizen.org/privilege/appmanager.launch
- Remarks:
- If you want to use this api, you must add privileges.
- Parameters:
-
[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 from1
.[in] count_per_page The desired maximum count of the data items per page. 1024 is the maximum value of count_per_page.
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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
- See also:
- data_control_map_get()
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.
- Since :
- 2.3
- Parameters:
-
[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
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DATA_CONTROL_ERROR_NONE Successful 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.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/datasharing
http://tizen.org/privilege/appmanager.launch
- Remarks:
- If you want to use this api, you must add privileges.
- The following example demonstrates how to use the data_control_map_remove() method.
void map_remove_response_cb(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) { if (provider_result) { dlog_print(DLOG_INFO, LOG_TAG, "The remove operation is successful"); } else { dlog_print(DLOG_INFO, LOG_TAG, "The remove operation for the request %d is failed. error message: %s", request_id, error); } } data_control_map_response_cb map_callback; int main() { 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) { dlog_print(DLOG_ERROR, LOG_TAG, "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) { dlog_print(DLOG_ERROR, LOG_TAG, "Removing %s-%s pair is failed with error: %d", key, value, result); } else { dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id); } return result; }
- Parameters:
-
[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
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/datasharing
http://tizen.org/privilege/appmanager.launch
- Remarks:
- If you want to use this api, you must add privileges.
- The following example demonstrates how to use the data_control_map_set() method.
void map_set_response_cb(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) { if (provider_result) { dlog_print(DLOG_INFO, LOG_TAG, "The set operation is successful"); } else { dlog_print(DLOG_INFO, LOG_TAG, "The set operation for the request %d is failed. error message: %s", request_id, error); } } data_control_map_response_cb map_callback; int main() { 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) { dlog_print(DLOG_ERROR, LOG_TAG, "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) { dlog_print(DLOG_ERROR, LOG_TAG, "Replacing old_value(%s) with new_value(%s) is failed with error: %d", old_value, new_value, result); } else { dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id); } return result; }
- Parameters:
-
[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
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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.
- Since :
- 2.3
- Parameters:
-
[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('/').
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DATA_CONTROL_ERROR_NONE Successful DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
- See also:
- data_control_map_get_data_id()
int data_control_map_set_provider_id | ( | data_control_h | provider, |
const char * | provider_id | ||
) |
Sets the Provider ID.
- Since :
- 2.3
- Parameters:
-
[in] provider The provider handle [in] provider_id The data control provider ID
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DATA_CONTROL_ERROR_NONE Successful DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
- See also:
- data_control_map_get_provider_id()
int data_control_map_unregister_response_cb | ( | data_control_h | provider | ) |
Unregisters the callback function in the provider.
- Since :
- 2.3
- Parameters:
-
[in] provider The provider handle
- Returns:
0
on success, otherwise a negative error value
int data_control_sql_create | ( | data_control_h * | provider | ) |
Creates a provider handle.
- Since :
- 2.3
- Remarks:
- The following example demonstrates how to use the data_control_sql_create() method:
int main() { 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) { dlog_print(DLOG_ERROR, LOG_TAG, "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) { dlog_print(DLOG_ERROR, LOG_TAG, "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) { dlog_print(DLOG_ERROR, LOG_TAG, "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) { dlog_print(DLOG_ERROR, LOG_TAG, "Destroying data control provider is failed with error: %d", result); } return result; }
- Parameters:
-
[out] provider The provider handle
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DATA_CONTROL_ERROR_NONE Successful DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
- See also:
- data_control_sql_destroy()
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.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/datasharing
http://tizen.org/privilege/appmanager.launch
- Remarks:
- If you want to use this api, you must add privileges.
- 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.
- The following example demonstrates how to use the data_control_sql_delete() method:
void sql_delete_response_cb(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) { if (provider_result) { dlog_print(DLOG_INFO, LOG_TAG, The delete operation is successful"); } else { dlog_print(DLOG_INFO, LOG_TAG, "The delete operation for the request %d is failed. error message: %s", request_id, error); } } data_control_sql_response_cb sql_callback; int main() { 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) { dlog_print(DLOG_ERROR, LOG_TAG, "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) { dlog_print(DLOG_ERROR, LOG_TAG, "Deleting is failed with error: %d", result); } else { dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id); } return result; }
- Parameters:
-
[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
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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_PERMISSION_DENIED Permission denied
int data_control_sql_destroy | ( | data_control_h | provider | ) |
Destroys the provider handle and releases all its resources.
- Since :
- 2.3
- Remarks:
- When operations of data control are finished, this function must be called to prevent the memory leak.
- Parameters:
-
[in] provider The provider handle
- Returns:
0
on success, otherwise a negative error value
- See also:
- data_control_sql_create()
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.
- Since :
- 2.3
- Parameters:
-
[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
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DATA_CONTROL_ERROR_NONE Successful DATA_CONTROL_ERROR_IO_ERROR I/O error 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.
- Since :
- 2.3
- Parameters:
-
[in] cursor The cursor that navigates the result of the request for the select operation
- Returns:
- The number of columns in the calling cursor
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.
- Since :
- 2.3
- Parameters:
-
[in] cursor The cursor that navigates the result of the request for the select operation [in] column_index The index of the destination column
- Returns:
- The size of data in the column indicated by the specified index
If an error is occurred, then a negative value is returned.
- Return values:
-
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.
- Since :
- 2.3
- Parameters:
-
[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
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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.
- Since :
- 2.3
- Parameters:
-
[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.
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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_data_id | ( | data_control_h | provider, |
char ** | data_id | ||
) |
Gets the data ID.
- Since :
- 2.3
- Remarks:
- You must release data_id using free() after it is used.
- Parameters:
-
[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('/').
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DATA_CONTROL_ERROR_NONE Successful DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
- See also:
- data_control_sql_set_data_id()
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.
- Since :
- 2.3
- Parameters:
-
[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
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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_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.
- Since :
- 2.3
- Parameters:
-
[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
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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.
- Since :
- 2.3
- Parameters:
-
[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
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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.
- Since :
- 2.3
- Remarks:
- You must release provider_id using free() after it is used.
- Parameters:
-
[in] provider The provider handle [out] provider_id The data control provider ID
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DATA_CONTROL_ERROR_NONE Successful DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
- See also:
- data_control_sql_set_provider_id()
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.
- Since :
- 2.3
- Parameters:
-
[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().
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/datasharing
http://tizen.org/privilege/appmanager.launch
- Remarks:
- If you want to use this api, you must add privileges.
- The following example demonstrates how to use the data_control_sql_insert() method:
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) { dlog_print(DLOG_INFO, LOG_TAG, "The insert operation is successful"); } else { dlog_print(DLOG_INFO, LOG_TAG, "The insert operation for the request %d is failed. error message: %s", request_id, error); } } data_control_sql_response_cb sql_callback; int main() { 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) { dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result); return result; } b = bundle_create(); bundle_add_str(b, "WORD", "test"); bundle_add_str(b, "WORD_DESC", "test description"); result = data_control_sql_insert(provider, b, &req_id); if (result != DATA_CONTROL_ERROR_NONE) { dlog_print(DLOG_ERROR, LOG_TAG, "Inserting is failed with error: %d", result); } else { dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id); } bundle_free(b); return result; }
- Parameters:
-
[in] provider The provider handle [in] insert_data The column-value pairs to insert\ n 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
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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_PERMISSION_DENIED Permission denied
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.
- Since :
- 2.3 remarks The application is notified when a data control response is received from the provider.
- Parameters:
-
[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
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DATA_CONTROL_ERROR_NONE Successful 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.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/datasharing
http://tizen.org/privilege/appmanager.launch
- Remarks:
- If you want to use this api, you must add privileges.
- The following example demonstrates how to use the data_control_sql_select() method:
- If more than 20 rows are selected, only first 20 rows are included in select result.
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) { dlog_print(DLOG_INFO, LOG_TAG, "The select operation is successful"); } else { dlog_print(DLOG_INFO, LOG_TAG, "The select operation for the request %d is failed. error message: %s", request_id, error); } } data_control_sql_response_cb sql_callback; int main() { 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) { dlog_print(DLOG_ERROR, LOG_TAG, "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) { dlog_print(DLOG_ERROR, LOG_TAG, "Selecting is failed with error: %d", result); } else { dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id); } return result; }
- Parameters:
-
[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
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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_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.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/datasharing
http://tizen.org/privilege/appmanager.launch
- Remarks:
- If you want to use this api, you must add privileges.
- Parameters:
-
[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 from1
.[in] count_per_page The desired maximum count of rows on a page. 1024 is the maximum value of count_per_page. [out] request_id The request ID
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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_PERMISSION_DENIED Permission denied
- See also:
- data_control_sql_select()
int data_control_sql_set_data_id | ( | data_control_h | provider, |
const char * | data_id | ||
) |
Sets the data ID.
- Since :
- 2.3
- Parameters:
-
[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('/').
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DATA_CONTROL_ERROR_NONE Successful DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
- See also:
- data_control_sql_get_data_id()
int data_control_sql_set_provider_id | ( | data_control_h | provider, |
const char * | provider_id | ||
) |
Sets the Provider ID.
- Since :
- 2.3
- Parameters:
-
[in] provider The provider handle [in] provider_id The data control provider ID
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DATA_CONTROL_ERROR_NONE Successful DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
- See also:
- data_control_sql_get_provider_id()
int data_control_sql_step_first | ( | result_set_cursor | cursor | ) |
Moves the cursor to the first position.
- Since :
- 2.3
- Remarks:
- The following example demonstrates how to use the data_control_sql_step_first() method:
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); }
- Parameters:
-
[in] cursor The cursor that navigates the result of the request for the select operation
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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_step_last | ( | result_set_cursor | cursor | ) |
Moves the cursor to the last position.
- Since :
- 2.3
- Remarks:
- The following example demonstrates how to use the data_control_sql_step_last() method:
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); }
- Parameters:
-
[in] cursor The cursor that navigates the result of data control select request
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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_step_next | ( | result_set_cursor | cursor | ) |
Moves the cursor to the next position.
- Since :
- 2.3
- Remarks:
- The following example demonstrates how to use the data_control_sql_step_next() method:
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); } }
- Parameters:
-
[in] cursor The cursor that navigates the result of the request for the select operation
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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_step_previous | ( | result_set_cursor | cursor | ) |
Moves the cursor to the previous position.
- Since :
- 2.3
- Parameters:
-
[in] cursor The cursor that navigates the result of the request for the select operation
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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.
- Since :
- 2.3
- Parameters:
-
[in] provider The provider handle
- Returns:
0
on success, otherwise a negative error value
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.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/datasharing
http://tizen.org/privilege/appmanager.launch
- Remarks:
- If you want to use this api, you must add privileges.
- The following example demonstrates how to use the data_control_sql_update() method:
void sql_update_response_cb(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) { if (provider_result) { dlog_print(DLOG_INFO, LOG_TAG, "The update operation is successful"); } else { dlog_print(DLOG_INFO, LOG_TAG, "The update operation for the request %d is failed. error message: %s", request_id, error); } } data_control_sql_response_cb sql_callback; int main() { 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) { dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result); return result; } b = bundle_create(); bundle_add_str(b, "WORD", "test_new"); result = data_control_sql_update(provider, b, where, &req_id); if (result != DATA_CONTROL_ERROR_NONE) { dlog_print(DLOG_ERROR, LOG_TAG, "Updating is failed with error: %d", result); } else { dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id); } bundle_free(b); return result; }
- Parameters:
-
[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
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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_PERMISSION_DENIED Permission denied