/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
-//
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/**
* @file data-control-map.h
* @param [in] user_data The user data passed from the register function
*/
typedef void (*datacontrol_map_get_response_cb)(int request_id, datacontrol_h provider,
- char ** result_value_list, int result_value_count, bool provider_result, const char *error, void *user_data);
+ char **result_value_list, int result_value_count, bool provider_result, const char *error, void *user_data);
/**
* @brief Called when the response is received from the key-value structured data control provider.
* @see datacontrol_map_add_response_cb()
* @see datacontrol_map_remove_response_cb()
*/
-typedef struct
-{
+typedef struct {
datacontrol_map_get_response_cb get;
datacontrol_map_set_response_cb set;
datacontrol_map_add_response_cb add;
* const char *provider_id = "http://tizen.org/datacontrol/provider/example";
* const char *data_id = "table";
* datacontrol_h provider;
- * int result = 0;
+ * int result = 0;
*
* result = datacontrol_map_create(&provider);
* if (result != DATACONTROL_ERROR_NONE) {
* @retval #DATACONTROL_ERROR_OUT_OF_MEMORY Out of memory
* @see datacontrol_map_unregister_response_cb()
*/
-EXPORT_API int datacontrol_map_register_response_cb(datacontrol_h provider, datacontrol_map_response_cb* callback, void *user_data);
+EXPORT_API int datacontrol_map_register_response_cb(datacontrol_h provider, datacontrol_map_response_cb *callback, void *user_data);
/**
* @brief Unregisters the callback function in @c provider.
-//
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/**
* @file data-control-provider.h
/**
- * @brief Called when the insert request is received from an application using SQL-friendly interface based data control.
+ * @brief Called when the insert request is received from an application using SQL-friendly interface based data control.
*
* @param [in] request_id The request ID
- * @param [in] provider The provider handle
- * @param [in] insert_data The column-value pairs to insert @n
- * 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.
- * @param [in] user_data The user data passed from the register function
+ * @param [in] provider The provider handle
+ * @param [in] insert_data The column-value pairs to insert @n
+ * 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.
+ * @param [in] user_data The user data passed from the register function
*/
typedef void (*datacontrol_provider_sql_insert_request_cb)(int request_id, datacontrol_h provider,
bundle *insert_data, void *user_data);
/**
- * @brief Called when the update request is received from an application using SQL-friendly interface based data control.
+ * @brief Called when the update request is received from an application using SQL-friendly interface based data control.
*
* @param [in] request_id The request ID
- * @param [in] provider The provider handle
- * @param [in] update_data The column-value pairs to update @n
- * 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.
+ * @param [in] provider The provider handle
+ * @param [in] update_data The column-value pairs to update @n
+ * 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.
* @param [in] where A filter to select the desired rows to update. @n
- * It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as column1 = 'stringValue' and column2 = numericValue.
- * @param [in] user_data The user data passed from the register function
+ * It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as column1 = 'stringValue' and column2 = numericValue.
+ * @param [in] user_data The user data passed from the register function
*/
typedef void (*datacontrol_provider_sql_update_request_cb)(int request_id, datacontrol_h provider,
bundle *update_data, const char *where, void *user_data);
/**
- * @brief Called when the delete request is received from an application using SQL-friendly interface based data control.
+ * @brief Called when the delete request is received from an application using SQL-friendly interface based data control.
*
* @param [in] request_id The request ID
- * @param [in] provider The provider handle
+ * @param [in] provider The provider handle
* @param [in] where A filter to select the desired rows to delete. @n
- * It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as column1 = 'stringValue' and column2 = numericValue.
- * @param [in] user_data The user data passed from the register function
+ * It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as column1 = 'stringValue' and column2 = numericValue.
+ * @param [in] user_data The user data passed from the register function
*/
typedef void (*datacontrol_provider_sql_delete_request_cb)(int request_id, datacontrol_h provider,
const char *where, void *user_data);
/**
- * @brief Called when the select request is received from an application using SQL-friendly interface based data control.
+ * @brief Called when the select request is received from an application using SQL-friendly interface based data control.
*
* @param [in] request_id The request ID
* @param [in] provider The provider handle
- * @param [in] column_list The column list to query
- * @param [in] column_count The total number of columns to be queried
+ * @param [in] column_list The column list to query
+ * @param [in] column_count The total number of columns to be queried
* @param [in] where A filter to select the desired rows. @n
- * It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as column1 = 'stringValue' and column2 = numericValue.
+ * It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as column1 = 'stringValue' and column2 = numericValue.
* @param [in] order The sorting order of the rows to query. @n
- * It is an SQL 'ORDER BY' clause excluding the 'ORDER BY' itself.
- * @param [in] user_data The user data passed from the register function
+ * It is an SQL 'ORDER BY' clause excluding the 'ORDER BY' itself.
+ * @param [in] user_data The user data passed from the register function
*/
typedef void (*datacontrol_provider_sql_select_request_cb)(int request_id, datacontrol_h provider,
const char **column_list, int column_count, const char *where, const char *order, void *user_data);
/**
- * @brief Called when the request for obtaining the value list is received from the key-value structured data control consumer.
+ * @brief Called when the request for obtaining the value list is received from the key-value structured data control consumer.
*
* @param [in] request_id The request ID
- * @param [in] provider The provider handle
- * @param [in] key The key of the value list to obtain
- * @param [in] user_data The user data passed from the register function
+ * @param [in] provider The provider handle
+ * @param [in] key The key of the value list to obtain
+ * @param [in] user_data The user data passed from the register function
*/
typedef void (*datacontrol_provider_map_get_value_request_cb)(int request_id, datacontrol_h provider, const char *key, void *user_data);
/**
- * @brief Called when the request for replacing the value is received from the key-value structured data control consumer.
+ * @brief Called when the request for replacing the value is received from the key-value structured data control consumer.
*
* @param [in] request_id The request ID
- * @param [in] provider The provider handle
- * @param [in] key The key of the value to replace
- * @param [in] old_value The value to replace
+ * @param [in] provider The provider handle
+ * @param [in] key The key of the value to replace
+ * @param [in] old_value The value to replace
* @param [in] new_value The new value that replaces the existing value
- * @param [in] user_data The user data passed from the register function
+ * @param [in] user_data The user data passed from the register function
*/
typedef void (*datacontrol_provider_map_set_value_request_cb)(int request_id, datacontrol_h provider, const char *key,
const char *old_value, const char *new_value, void *user_data);
/**
- * @brief Called when the request for adding the value is received from the key-value structured data control consumer.
+ * @brief Called when the request for adding the value is received from the key-value structured data control consumer.
*
* @param [in] request_id The request ID
- * @param [in] provider The provider handle
- * @param [in] key The key of the value to add
+ * @param [in] provider The provider handle
+ * @param [in] key The key of the value to add
* @param [in] value The value to add
- * @param [in] user_data The user data passed from the register function
+ * @param [in] user_data The user data passed from the register function
*/
typedef void (*datacontrol_provider_map_add_value_request_cb)(int request_id, datacontrol_h provider, const char *key,
const char *value, void *user_data);
/**
- * @brief Called when the request for removing the value is received from the key-value structured data control consumer.
+ * @brief Called when the request for removing the value is received from the key-value structured data control consumer.
*
* @param [in] request_id The request ID
- * @param [in] provider The provider handle
- * @param [in] key The key of the value to remove
+ * @param [in] provider The provider handle
+ * @param [in] key The key of the value to remove
* @param [in] value The value to remove
- * @param [in] user_data The user data passed from the register function
+ * @param [in] user_data The user data passed from the register function
*/
typedef void (*datacontrol_provider_map_remove_value_request_cb)(int request_id, datacontrol_h provider, const char *key,
const char *value, void *user_data);
/**
- * @brief The structure type to contain the set of callback functions for handling the request events
- * of SQL-friendly interface based data control.
+ * @brief The structure type to contain the set of callback functions for handling the request events
+ * of SQL-friendly interface based data control.
* @see datacontrol_provider_sql_select_request_cb()
* @see datacontrol_provider_sql_insert_request_cb()
* @see datacontrol_provider_sql_update_request_cb()
* @see datacontrol_provider_sql_delete_request_cb()
*/
-typedef struct
-{
+typedef struct {
datacontrol_provider_sql_insert_request_cb insert;
datacontrol_provider_sql_select_request_cb select;
datacontrol_provider_sql_update_request_cb update;
} datacontrol_provider_sql_cb;
/**
- * @brief The structure type to contain the set of callback functions for handling the request events
- * from the key-value structured data control consumer.
+ * @brief The structure type to contain the set of callback functions for handling the request events
+ * from the key-value structured data control consumer.
* @see datacontrol_provider_map_get_value_request_cb()
* @see datacontrol_provider_map_set_value_request_cb()
* @see datacontrol_provider_map_add_value_request_cb()
* @see datacontrol_provider_map_remove_value_request_cb()
*/
-typedef struct
-{
+typedef struct {
datacontrol_provider_map_get_value_request_cb get;
datacontrol_provider_map_set_value_request_cb set;
datacontrol_provider_map_add_value_request_cb add;
} datacontrol_provider_map_cb;
/**
- * @brief Registers a callback function for the sql data control request.
- * The provider is notified when a data control request is received from the client applications.
+ * @brief Registers a callback function for the sql data control request.
+ * The provider is notified when a data control request is received from the client applications.
* @param [in] callback The callback function to be called when a data control request is received
* @param [in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value.
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
*/
EXPORT_API int datacontrol_provider_sql_unregister_cb(void);
/**
- * @brief Registers a callback function for the map data control request.
- * The provider is notified when a data control request is received from the client applications.
+ * @brief Registers a callback function for the map data control request.
+ * The provider is notified when a data control request is received from the client applications.
* @param [in] callback The callback function to be called when a data control request is received
- * @param [in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value.
+ * @param [in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
*/
EXPORT_API int datacontrol_provider_map_register_cb(datacontrol_provider_map_cb *callback, void *user_data);
/**
- * @brief Unregisters the callback functions.
+ * @brief Unregisters the callback functions.
* @return 0 on success, otherwise a negative error value.
*/
EXPORT_API int datacontrol_provider_map_unregister_cb(void);
/**
- * @brief Gets the application ID which sends the data control request.
+ * @brief Gets the application ID which sends the data control request.
* @param [in] request_id The request ID
* @param [out] appid The application ID
- * @return 0 on success, otherwise a negative error value.
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
*/
EXPORT_API int datacontrol_provider_get_client_appid(int request_id, char **appid);
/**
- * @brief Sends the success result and the result set of the select request to the client application.
+ * @brief Sends the success result and the result set of the select request to the client application.
* @param [in] request_id The request ID
* @param [in] db_handle The result db handle for the result set
- * @return 0 on success, otherwise a negative error value.
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
EXPORT_API int datacontrol_provider_send_select_result(int request_id, void *db_handle);
/**
- * @brief Sends the success result of the insert request and the last inserted row ID to the client application.
+ * @brief Sends the success result of the insert request and the last inserted row ID to the client application.
* @param [in] request_id The request ID
* @param [in] row_id The row ID of the database changed by the insert request
- * @return 0 on success, otherwise a negative error value.
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
EXPORT_API int datacontrol_provider_send_insert_result(int request_id, long long row_id);
/**
- * @brief Sends the success result of the update request the client application.
+ * @brief Sends the success result of the update request the client application.
* @param [in] request_id The request ID
- * @return 0 on success, otherwise a negative error value.
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
EXPORT_API int datacontrol_provider_send_update_result(int request_id);
/**
- * @brief Sends the success result of the delete request the client application.
+ * @brief Sends the success result of the delete request the client application.
* @param [in] request_id The request ID
- * @return 0 on success, otherwise a negative error value.
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
EXPORT_API int datacontrol_provider_send_delete_result(int request_id);
/**
- * @brief Sends the provider error message to the client application.
+ * @brief Sends the provider error message to the client application.
* @param [in] request_id The request ID
* @param [in] error The provider-defined error message
- * @return 0 on success, otherwise a negative error value.
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
EXPORT_API int datacontrol_provider_send_error(int request_id, const char *error);
/**
- * @brief Sends the success result of the request for setting, adding and removing the key-value structured data the client application.
+ * @brief Sends the success result of the request for setting, adding and removing the key-value structured data the client application.
* @param [in] request_id The request ID
- * @return 0 on success, otherwise a negative error value.
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
EXPORT_API int datacontrol_provider_send_map_result(int request_id);
/**
- * @brief Sends the success result of the request for getting the value list the client application.
+ * @brief Sends the success result of the request for getting the value list the client application.
* @param [in] request_id The request ID
* @param [in] value_list The result value list
* @param [in] value_count The number of the values
- * @return 0 on success, otherwise a negative error value.
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
-//
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/**
* @file data-control-sql-cursor.h
/**
* @brief The structure type to represent a sql result set. This type can be used to enumerate through the result set of an SQL query.
*/
-typedef struct
-{
+typedef struct {
int resultset_fd;
sqlite3_int64 resultset_row_count;
int resultset_col_count;
* @param [in] path The path of the file containing the SQL result set
* @return A pointer to struct @c resultset_cursor
*/
-resultset_cursor* datacontrol_sql_get_cursor();
+resultset_cursor *datacontrol_sql_get_cursor();
/**
* @brief Moves the cursor to the first position
EXPORT_API int datacontrol_sql_step_next(resultset_cursor *cursor);
/**
- * @brief Moves the cursor to the previous position
+ * @brief Moves the cursor to the previous position
*
* @param [in] cursor Navigates the result of the request for the select operation
- * @return 0 on success, otherwise a negative error value.
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
*/
EXPORT_API int datacontrol_sql_step_previous(resultset_cursor *cursor);
/**
- * @brief Gets the number of columns for this cursor
+ * @brief Gets the number of columns for this cursor
*
* @param [in] cursor Navigates the result of the request for the select operation
* @return The number of columns in the calling cursor
EXPORT_API int datacontrol_sql_get_column_count(resultset_cursor *cursor);
/**
- * @brief Gets the name of the column indicated by the specified index
+ * @brief Gets the name of the column indicated by the specified index
*
- * @param [in] cursor Navigates the result of the request for the select operation
- * @param [in] column_index The index of the destination column
- * @param [out] name The name of the destination column
- * @return 0 on success, otherwise a negative error value.
+ * @param [in] cursor Navigates the result of the request for the select operation
+ * @param [in] column_index The index of the destination column
+ * @param [out] name The name of the destination column
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
*/
EXPORT_API int datacontrol_sql_get_column_name(resultset_cursor *cursor, int column_index, char *name);
/**
- * @brief Gets the size of data in the column indicated by the specified index
+ * @brief Gets the size of data in the column indicated by the specified index
*
- * @param [in] cursor Navigates the result of the request for the select operation
- * @param [in] column_index The index of the destination column
- * @return The size of data in the column indicated by the specified index. @n
- * If an error is occurred, a negative value is returned.
+ * @param [in] cursor Navigates the result of the request for the select operation
+ * @param [in] column_index The index of the destination column
+ * @return The size of data in the column indicated by the specified index. @n
+ * If an error is occurred, a negative value is returned.
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
*/
EXPORT_API int datacontrol_sql_get_column_item_size(resultset_cursor *cursor, int column_index);
/**
- * @brief Gets the type of the column indicated by the specified index
+ * @brief Gets the type of the column indicated by the specified index
*
* @param [in] cursor Navigates the result of the request for the select operation
* @param [in] column_index The index of the destination column
- * @param [out] type The type of the destination column
- * @return 0 on success, otherwise a negative error value.
+ * @param [out] type The type of the destination column
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
*/
EXPORT_API int datacontrol_sql_get_column_item_type(resultset_cursor *cursor, int column_index, datacontrol_sql_column_type* type);
/**
- * @brief Gets a blob data from the column indicated by the specified index
+ * @brief Gets a blob data from the column indicated by the specified index
*
* @param [in] cursor Navigates the result of the request for the select operation
* @param [in] column_index The index of the destination column
- * @param [out] data The blob value obtained from the column
- * @param [out] size The size of the data
- * @return 0 on success, otherwise a negative error value.
+ * @param [out] data The blob value obtained from the column
+ * @param [out] size The size of the data
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
EXPORT_API int datacontrol_sql_get_blob_data(resultset_cursor *cursor, int column_index, void *data, int size);
/**
- * @brief Gets an int value from the column indicated by the specified index
+ * @brief Gets an int value from the column indicated by the specified index
*
* @param [in] cursor Navigates the result of the request for the select operation
* @param [in] column_index The index of the destination column
- * @param [out] data The integer value obtained from the column
- * @return 0 on success, otherwise a negative error value.
+ * @param [out] data The integer value obtained from the column
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
EXPORT_API int datacontrol_sql_get_int_data(resultset_cursor *cursor, int column_index, int *data);
/**
- * @brief Gets a long long value from the column indicated by the specified index
+ * @brief Gets a long long value from the column indicated by the specified index
*
* @param [in] cursor Navigates the result of the request for the select operation
* @param [in] column_index The index of the destination column
- * @param [out] data The 64-bit integer value obtained from the column
- * @return 0 on success, otherwise a negative error value.
+ * @param [out] data The 64-bit integer value obtained from the column
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
EXPORT_API int datacontrol_sql_get_int64_data(resultset_cursor *cursor, int column_index, long long *data);
/**
- * @brief Gets a double value from the column indicated by the specified index
+ * @brief Gets a double value from the column indicated by the specified index
*
* @param [in] cursor Navigates the result of the request for the select operation
- * @param [in] column_index The index of the destination column
- * @param [out] data The value obtained from the column as double
- * @return 0 on success, otherwise a negative error value.
+ * @param [in] column_index The index of the destination column
+ * @param [out] data The value obtained from the column as double
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
EXPORT_API int datacontrol_sql_get_double_data(resultset_cursor *cursor, int column_index, double *data);
/**
- * @brief Gets a text value from the column indicated by the specified index
+ * @brief Gets a text value from the column indicated by the specified index
*
* @param [in] cursor Navigates the result of the request for the select operation
* @param [in] column_index The index of the destination column
- * @param [out] data The value obtained from the column as text
- * @return 0 on success, otherwise a negative error value.
+ * @param [out] data The value obtained from the column as text
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
* @retval #DATACONTROL_ERROR_INVALID_PARAMETER Invalid parameter
EXPORT_API int datacontrol_sql_get_text_data(resultset_cursor *cursor, int column_index, char *data);
/**
- * @brief Removes the @c cursor containing SQL result set
+ * @brief Removes the @c cursor containing SQL result set
*
* @param [in] cursor A pointer to the result set cursor to be removed
- * @return 0 on success, otherwise a negative error value.
+ * @return 0 on success, otherwise a negative error value.
* @retval #DATACONTROL_ERROR_NONE Successful
* @retval #DATACONTROL_ERROR_IO_ERROR I/O error
*/
-//
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/**
* @file data-control-sql.h
* @see datacontrol_sql_update_response_cb()
* @see datacontrol_sql_delete_response_cb()
*/
-typedef struct
-{
+typedef struct {
datacontrol_sql_select_response_cb select;
datacontrol_sql_insert_response_cb insert;
datacontrol_sql_update_response_cb update;
* const char *provider_id = "http://tizen.org/datacontrol/provider/example";
* const char *data_id = "table";
* datacontrol_h provider;
- * int result = 0;
+ * int result = 0;
*
* result = datacontrol_sql_create(&provider);
* if (result != DATACONTROL_ERROR_NONE) {
* @retval #DATACONTROL_ERROR_OUT_OF_MEMORY Out of memory
* @see datacontrol_sql_unregister_response_cb()
*/
-EXPORT_API int datacontrol_sql_register_response_cb(datacontrol_h provider, datacontrol_sql_response_cb* callback, void *user_data);
+EXPORT_API int datacontrol_sql_register_response_cb(datacontrol_h provider, datacontrol_sql_response_cb *callback, void *user_data);
/**
* @brief Unregisters the callback function in @c provider.
*
* @endcode
*/
-EXPORT_API int datacontrol_sql_insert(datacontrol_h provider, const bundle* insert_data, int *request_id);
+EXPORT_API int datacontrol_sql_insert(datacontrol_h provider, const bundle *insert_data, int *request_id);
/**
* @brief Selects the specified columns to be queried
*
* @endcode
*/
-EXPORT_API int datacontrol_sql_update(datacontrol_h provider, const bundle* update_data, const char *where, int *request_id);
+EXPORT_API int datacontrol_sql_update(datacontrol_h provider, const bundle *update_data, const char *where, int *request_id);
#ifdef __cplusplus
}
-//
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/**
* @file data-control-types.h
/**
* @brief Enumerations of different types of columns in an SQL table.
*/
-typedef enum
-{
+typedef enum {
DATACONTROL_SQL_COLUMN_TYPE_UNDEFINED = 0,
DATACONTROL_SQL_COLUMN_TYPE_INT64,
DATACONTROL_SQL_COLUMN_TYPE_DOUBLE,
/**
* @brief Enumerations of the various error-codes an API can return.
*/
-typedef enum
-{
+typedef enum {
DATACONTROL_ERROR_NONE = 0, /**< Successful */
DATACONTROL_ERROR_OUT_OF_MEMORY = -ENOMEM, /**< Out of memory */
DATACONTROL_ERROR_IO_ERROR = -EIO, /**< I/O error */
-//
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/**
* @file data-control.h
-//
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef __TIZEN_APPFW_DATA_CONTROL_H__
#define __TIZEN_APPFW_DATA_CONTROL_H__
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
#endif
#endif /* __TIZEN_APPFW_DATA_CONTROL_INTERNAL_H__ */
+
-//
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at:
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef __TIZEN_APPFW_DATA_CONTROL_MAP_H__
#define __TIZEN_APPFW_DATA_CONTROL_MAP_H__
* @param[in] error The error message from the data control provider
* @param[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);
+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);
/**
* @brief Called when the response is received from the key-value structured data control provider.
* @param[in] error The error message from the data control provider
* @param[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);
+typedef void (*data_control_map_set_response_cb)(int request_id,
+ data_control_h provider, bool provider_result,
+ const char *error, void *user_data);
/**
* @brief Called when the response is received from the key-value structured data control provider.
* @param[in] error The error message from the data control provider
* @param[in] user_data The user data passed from the register 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);
+typedef void (*data_control_map_add_response_cb)(int request_id,
+ data_control_h provider, bool provider_result,
+ const char *error, void *user_data);
/**
* @brief Called when the response is received from the key-value structured data control provider.
* @param[in] error The error message from the data control provider
* @param[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);
+typedef void (*data_control_map_remove_response_cb)(int request_id,
+ data_control_h provider, bool provider_result,
+ const char *error, void *user_data);
/**
* @brief The structure type to contain the set of callback functions for handling the response events
* @see data_control_map_add_response_cb()
* @see data_control_map_remove_response_cb()
*/
-typedef struct
-{
- data_control_map_get_response_cb get_cb; /**< This callback function is called when the response is received for a getting value from the key-value structured data control provider. */
- data_control_map_set_response_cb set_cb; /**< This callback function is called when the response is received for a setting value from the key-value structured data control provider. */
- data_control_map_add_response_cb add_cb; /**< This callback function is called when the response is received for a adding value from the key-value structured data control provider. */
- data_control_map_remove_response_cb remove_cb; /**< This callback function is called when the response is for a removing value received from the key-value structured data control provider. */
+typedef struct {
+ data_control_map_get_response_cb get_cb; /**< This callback function is called when the response is received for a getting value from the key-value structured data control provider. */
+ data_control_map_set_response_cb set_cb; /**< This callback function is called when the response is received for a setting value from the key-value structured data control provider. */
+ data_control_map_add_response_cb add_cb; /**< This callback function is called when the response is received for a adding value from the key-value structured data control provider. */
+ data_control_map_remove_response_cb remove_cb; /**< This callback function is called when the response is for a removing value received from the key-value structured data control provider. */
} data_control_map_response_cb;
/**
*
* @see data_control_map_unregister_response_cb()
*/
-int data_control_map_register_response_cb(data_control_h provider, data_control_map_response_cb* callback, void *user_data);
+int data_control_map_register_response_cb(data_control_h provider, data_control_map_response_cb *callback, void *user_data);
/**
* @brief Unregisters the callback function in the @a provider.
#endif
#endif /* __TIZEN_APPFW_DATA_CONTROL_MAP_H__ */
+
-//
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at:
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef __TIZEN_APPFW_DATA_CONTROL_PROVIDER_H_
#define __TIZEN_APPFW_DATA_CONTROL_PROVIDER_H_
* 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.
* @param[in] user_data The user data passed from the register function
*/
-typedef void (*data_control_provider_sql_insert_request_cb)(int request_id, data_control_h provider,
- bundle *insert_data, void *user_data);
+typedef void (*data_control_provider_sql_insert_request_cb)(int request_id,
+ data_control_h provider, bundle *insert_data, void *user_data);
/**
* @brief Called when the update request is received from an application using SQL-friendly interface based data control.
* It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as column1 = 'stringValue' and column2 = numericValue.
* @param[in] user_data The user data passed from the register function
*/
-typedef void (*data_control_provider_sql_update_request_cb)(int request_id, data_control_h provider,
- bundle *update_data, const char *where, void *user_data);
+typedef void (*data_control_provider_sql_update_request_cb)(int request_id,
+ data_control_h provider, bundle *update_data,
+ const char *where, void *user_data);
/**
* @brief Called when the delete request is received from an application using SQL-friendly interface based data control.
* It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as column1 = 'stringValue' and column2 = numericValue.
* @param[in] user_data The user data passed from the register function
*/
-typedef void (*data_control_provider_sql_delete_request_cb)(int request_id, data_control_h provider,
- const char *where, void *user_data);
+typedef void (*data_control_provider_sql_delete_request_cb)(int request_id,
+ data_control_h provider, const char *where, void *user_data);
/**
* @brief Called when the select request is received from an application using SQL-friendly interface based data control.
* It is an SQL 'ORDER BY' clause excluding the 'ORDER BY' itself.
* @param[in] user_data The user data passed from the register function
*/
-typedef void (*data_control_provider_sql_select_request_cb)(int request_id, data_control_h provider,
- const char **column_list, int column_count, const char *where, const char *order, void *user_data);
+typedef void (*data_control_provider_sql_select_request_cb)(int request_id,
+ data_control_h provider, const char **column_list,
+ int column_count, const char *where, const char *order,
+ void *user_data);
/**
* @brief Called when the request for obtaining the value list is received from the key-value structured data control consumer.
* @param[in] key The key of the value list to obtain
* @param[in] user_data The user data passed from the register function
*/
-typedef void (*data_control_provider_map_get_value_request_cb)(int request_id, data_control_h provider, const char *key, void *user_data);
+typedef void (*data_control_provider_map_get_value_request_cb)(int request_id,
+ data_control_h provider, const char *key, void *user_data);
/**
* @brief Called when the request for replacing the value is received from the key-value structured data control consumer.
* @param[in] new_value The new value that replaces the existing value
* @param[in] user_data The user data passed from the register function
*/
-typedef void (*data_control_provider_map_set_value_request_cb)(int request_id, data_control_h provider, const char *key,
- const char *old_value, const char *new_value, void *user_data);
+typedef void (*data_control_provider_map_set_value_request_cb)(int request_id,
+ data_control_h provider, const char *key,
+ const char *old_value, const char *new_value, void *user_data);
/**
* @brief Called when the request for adding the value is received from the key-value structured data control consumer.
* @param[in] value The value to add
* @param[in] user_data The user data passed from the register function
*/
-typedef void (*data_control_provider_map_add_value_request_cb)(int request_id, data_control_h provider, const char *key,
- const char *value, void *user_data);
+typedef void (*data_control_provider_map_add_value_request_cb)(int request_id,
+ data_control_h provider, const char *key,
+ const char *value, void *user_data);
/**
* @brief Called when the request for removing the value is received from the key-value structured data control consumer.
* @param[in] value The value to remove
* @param[in] user_data The user data passed from the register function
*/
-typedef void (*data_control_provider_map_remove_value_request_cb)(int request_id, data_control_h provider, const char *key,
- const char *value, void *user_data);
+typedef void (*data_control_provider_map_remove_value_request_cb)(
+ int request_id, data_control_h provider, const char *key,
+ const char *value, void *user_data);
/**
* @brief The structure type to contain the set of callback functions for handling the request events
* @see data_control_provider_sql_update_request_cb()
* @see data_control_provider_sql_delete_request_cb()
*/
-typedef struct
-{
- data_control_provider_sql_insert_request_cb insert_cb; /**< This callback function is called when a request for insert operation is received from other application. */
- data_control_provider_sql_select_request_cb select_cb; /**< This callback function is called when a request for select operation is received from other application. */
- data_control_provider_sql_update_request_cb update_cb; /**< This callback function is called when a request for update operation is received from other application. */
- data_control_provider_sql_delete_request_cb delete_cb; /**< This callback function is called when a request for delete operation is received from other application. */
+typedef struct {
+ data_control_provider_sql_insert_request_cb insert_cb; /**< This callback function is called when a request for insert operation is received from other application. */
+ data_control_provider_sql_select_request_cb select_cb; /**< This callback function is called when a request for select operation is received from other application. */
+ data_control_provider_sql_update_request_cb update_cb; /**< This callback function is called when a request for update operation is received from other application. */
+ data_control_provider_sql_delete_request_cb delete_cb; /**< This callback function is called when a request for delete operation is received from other application. */
} data_control_provider_sql_cb;
/**
* @see data_control_provider_map_add_value_request_cb()
* @see data_control_provider_map_remove_value_request_cb()
*/
-typedef struct
-{
- data_control_provider_map_get_value_request_cb get_cb; /**< This callback function is called when a request for getting value is received from other application. */
- data_control_provider_map_set_value_request_cb set_cb; /**< This callback function is called when a request for setting value is received from other application. */
- data_control_provider_map_add_value_request_cb add_cb; /**< This callback function is called when a request for adding value is received from other application. */
- data_control_provider_map_remove_value_request_cb remove_cb; /**< This callback function is called when a request for removing value is received from other application. */
+typedef struct {
+ data_control_provider_map_get_value_request_cb get_cb; /**< This callback function is called when a request for getting value is received from other application. */
+ data_control_provider_map_set_value_request_cb set_cb; /**< This callback function is called when a request for setting value is received from other application. */
+ data_control_provider_map_add_value_request_cb add_cb; /**< This callback function is called when a request for adding value is received from other application. */
+ data_control_provider_map_remove_value_request_cb remove_cb; /**< This callback function is called when a request for removing value is received from other application. */
} data_control_provider_map_cb;
/**
* @exception DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
* @exception DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
*/
-char* data_control_provider_create_insert_statement(data_control_h provider, bundle *insert_map);
+char *data_control_provider_create_insert_statement(data_control_h provider, bundle *insert_map);
/**
* @brief Creates SQL DELETE statement.
* @exception DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
* @exception DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
*/
-char* data_control_provider_create_delete_statement(data_control_h provider, const char *where);
+char *data_control_provider_create_delete_statement(data_control_h provider, const char *where);
/**
* @brief Creates SQL UPDATE statement.
* @exception DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
* @exception DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
*/
-char* data_control_provider_create_update_statement(data_control_h provider, bundle *update_map, const char *where);
+char *data_control_provider_create_update_statement(data_control_h provider, bundle *update_map, const char *where);
/**
* @brief Creates SQL SELECT statement.
* @exception DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
* @exception DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
*/
-char* data_control_provider_create_select_statement(data_control_h provider, const char **column_list, int column_count, const char *where, const char *order);
+char *data_control_provider_create_select_statement(data_control_h provider, const char **column_list, int column_count, const char *where, const char *order);
/**
* @brief Checks whether the given provider ID matches the provider handle's provider ID.
-//
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at:
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#ifndef __TIZEN_APPFW_DATA_CONTROL_SQL_H__
#define __TIZEN_APPFW_DATA_CONTROL_SQL_H__
* @param[in] error The error message from the data control provider
* @param[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);
+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);
/**
* @brief Called when a response is received for a delete operation from an application using the SQL-friendly interface based data control.
* @param[in] error The error message from the data control provider
* @param[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);
+typedef void (*data_control_sql_delete_response_cb)(int request_id,
+ data_control_h provider, bool provider_result,
+ const char *error, void *user_data);
/**
* @brief Called when a response is received for a select operation from an application using the SQL-friendly interface based data control.
* @param[in] error The error message from the data control provider
* @param[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);
+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);
/**
* @brief Called when a response is received for an update operation from an application using the SQL-friendly interface based data control.
* @param[in] error The error message from the data control provider
* @param[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);
+typedef void (*data_control_sql_update_response_cb)(int request_id,
+ data_control_h provider, bool provider_result,
+ const char *error, void *user_data);
/**
* @brief The structure type to contain the set of callback functions for handling the response events
* @see data_control_sql_update_response_cb()
* @see data_control_sql_delete_response_cb()
*/
-typedef struct
-{
- data_control_sql_select_response_cb select_cb; /**< This callback function is called when a response is received for an select operation from an application using the SQL-friendly interface based data control. */
- data_control_sql_insert_response_cb insert_cb; /**< This callback function is called when a response is received for an insert operation from an application using the SQL-friendly interface based data control. */
- data_control_sql_update_response_cb update_cb; /**< This callback function is called when a response is received for an update operation from an application using the SQL-friendly interface based data control. */
- data_control_sql_delete_response_cb delete_cb; /**< This callback function is called when a response is received for a delete operation from an application using the SQL-friendly interface based data control. */
+typedef struct {
+ data_control_sql_select_response_cb select_cb; /**< This callback function is called when a response is received for an select operation from an application using the SQL-friendly interface based data control. */
+ data_control_sql_insert_response_cb insert_cb; /**< This callback function is called when a response is received for an insert operation from an application using the SQL-friendly interface based data control. */
+ data_control_sql_update_response_cb update_cb; /**< This callback function is called when a response is received for an update operation from an application using the SQL-friendly interface based data control. */
+ data_control_sql_delete_response_cb delete_cb; /**< This callback function is called when a response is received for a delete operation from an application using the SQL-friendly interface based data control. */
} data_control_sql_response_cb;
/**
*
* @see data_control_sql_unregister_response_cb()
*/
-int data_control_sql_register_response_cb(data_control_h provider, data_control_sql_response_cb* callback, void *user_data);
+int data_control_sql_register_response_cb(data_control_h provider, data_control_sql_response_cb *callback, void *user_data);
/**
* @brief Unregisters the callback function in the @a provider.
* @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
* @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
*/
-int data_control_sql_insert(data_control_h provider, const bundle* insert_data, int *request_id);
+int data_control_sql_insert(data_control_h provider, const bundle *insert_data, int *request_id);
/**
* @brief Selects the specified columns to be queried.
* @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
* @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
*/
-int data_control_sql_update(data_control_h provider, const bundle* update_data, const char *where, int *request_id);
+int data_control_sql_update(data_control_h provider, const bundle *update_data, const char *where, int *request_id);
/**
* @}
-//
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at:
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#ifndef __TIZEN_APPFW_DATA_CONTROL_SQL_ENUMERATOR_H_
#define __TIZEN_APPFW_DATA_CONTROL_SQL_ENUMERATOR_H_
* @retval #DATA_CONTROL_ERROR_IO_ERROR I/O error
* @retval #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);
+int data_control_sql_get_column_item_type(result_set_cursor cursor, int column_index, data_control_sql_column_type_e *type);
/**
* @brief Gets a blob data from the column indicated by the specified index.
-//
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at:
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef __TIZEN_APPFW__DATA_CONTROL_TYPES_H__
#define __TIZEN_APPFW__DATA_CONTROL_TYPES_H__
* @brief Enumeration for different types of columns in a SQL table.
* @since_tizen 2.3
*/
-typedef enum
-{
- DATA_CONTROL_SQL_COLUMN_TYPE_UNDEFINED = 0, /**< undefined type */
- DATA_CONTROL_SQL_COLUMN_TYPE_INT64, /**< integer type */
- DATA_CONTROL_SQL_COLUMN_TYPE_DOUBLE, /**< double type */
- DATA_CONTROL_SQL_COLUMN_TYPE_TEXT, /**< text type */
- DATA_CONTROL_SQL_COLUMN_TYPE_BLOB, /**< blob type */
- DATA_CONTROL_SQL_COLUMN_TYPE_NULL /**< null value */
+typedef enum {
+ DATA_CONTROL_SQL_COLUMN_TYPE_UNDEFINED = 0, /**< undefined type */
+ DATA_CONTROL_SQL_COLUMN_TYPE_INT64, /**< integer type */
+ DATA_CONTROL_SQL_COLUMN_TYPE_DOUBLE, /**< double type */
+ DATA_CONTROL_SQL_COLUMN_TYPE_TEXT, /**< text type */
+ DATA_CONTROL_SQL_COLUMN_TYPE_BLOB, /**< blob type */
+ DATA_CONTROL_SQL_COLUMN_TYPE_NULL /**< null value */
} data_control_sql_column_type_e;
/**
* @brief Enumeration for the various error-codes an API can return.
* @since_tizen 2.3
*/
-typedef enum
-{
- DATA_CONTROL_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
- DATA_CONTROL_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
- DATA_CONTROL_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
- DATA_CONTROL_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- DATA_CONTROL_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
- DATA_CONTROL_ERROR_MAX_EXCEEDED = TIZEN_ERROR_DATA_CONTROL | 0x01 /**< Too long argument */
+typedef enum {
+ DATA_CONTROL_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ DATA_CONTROL_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ DATA_CONTROL_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
+ DATA_CONTROL_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ DATA_CONTROL_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ DATA_CONTROL_ERROR_MAX_EXCEEDED = TIZEN_ERROR_DATA_CONTROL | 0x01 /**< Too long argument */
} data_control_error_e;
/**
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include <dlog.h>
#include <errno.h>
#include <stdio.h>
return 1;
}
-int _write_socket(int fd,
- void *buffer,
- unsigned int nbytes,
- unsigned int *bytes_write) {
-
+int _write_socket(int fd, void *buffer, unsigned int nbytes,
+ unsigned int *bytes_write)
+{
unsigned int left = nbytes;
gsize nb;
-
int retry_cnt = 0;
*bytes_write = 0;
return DATACONTROL_ERROR_NONE;
}
-int _read_socket(int fd,
- char *buffer,
- unsigned int nbytes,
- unsigned int *bytes_read) {
-
+int _read_socket(int fd, char *buffer, unsigned int nbytes,
+ unsigned int *bytes_read)
+{
unsigned int left = nbytes;
gsize nb;
-
int retry_cnt = 0;
*bytes_read = 0;
return DATACONTROL_ERROR_NONE;
}
-char *_datacontrol_create_select_statement(char *data_id, const char **column_list, int column_count,
- const char *where, const char *order, int page_number, int count_per_page)
+char *_datacontrol_create_select_statement(char *data_id,
+ const char **column_list, int column_count,
+ const char *where, const char *order, int page_number,
+ int count_per_page)
{
char *column = calloc(MAX_COLUMN_SIZE, sizeof(char));
int i = 0;
+ char *statement;
while (i < column_count - 1) {
LOGI("column i = %d, %s", i, column_list[i]);
strncat(column, column_list[i], MAX_COLUMN_SIZE - (strlen(column) + 1));
- char *statement = calloc(MAX_STATEMENT_SIZE, sizeof(char));
+ statement = calloc(MAX_STATEMENT_SIZE, sizeof(char));
snprintf(statement, MAX_STATEMENT_SIZE, "SELECT %s * FROM %s WHERE %s ORDER BY %s", column,
data_id, where, order);
}
-datacontrol_socket_info *_get_socket_info(const char *caller_id, const char *callee_id, const char *type,
- GIOFunc cb, void *data)
+datacontrol_socket_info *_get_socket_info(const char *caller_id,
+ const char *callee_id, const char *type, GIOFunc cb, void *data)
{
char err_buf[ERR_BUFFER_SIZE];
int socketpair = 0;
+ int g_src_id;
+
datacontrol_socket_info *socket_info = NULL;
bundle *sock_bundle = bundle_create();
bundle_add_str(sock_bundle, AUL_K_CALLER_APPID, caller_id);
return NULL;
}
- int g_src_id = g_io_add_watch(gio_read, G_IO_IN | G_IO_HUP,
+ g_src_id = g_io_add_watch(gio_read, G_IO_IN | G_IO_HUP,
cb, data);
-
if (g_src_id == 0) {
g_io_channel_unref(gio_read);
LOGE("fail to add watch on socket");
int _request_appsvc_run(const char *caller_id, const char *callee_id)
{
-
int pid = -1;
int count = 0;
const int TRY_COUNT = 4;
bundle_add_str(arg_list, AUL_K_DATA_CONTROL_TYPE, "CORE");
do {
-
pid = appsvc_run_service(arg_list, 0, NULL, NULL);
-
if (pid >= 0) {
LOGI("Launch the provider app successfully: %d", pid);
bundle_free(arg_list);
break;
-
} else if (pid == APPSVC_RET_EINVAL) {
LOGE("not able to launch service: %d", pid);
bundle_free(arg_list);
LOGE("unable to launch service: %d", pid);
return DATACONTROL_ERROR_IO_ERROR;
}
- return DATACONTROL_ERROR_NONE;
+ return DATACONTROL_ERROR_NONE;
}
-//
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/**
* @file data-control-internal.h
#define DATACONTROL_SELECT_STATEMENT "DATACONTROL_SELECT_STATEMENT"
#define DATACONTROL_EMPTY "NULL"
-#define DATACONTROL_SELECT_EXTRA_COUNT 6 // data id, column count, where, order, page, per_page
+#define DATACONTROL_SELECT_EXTRA_COUNT 6 /* data id, column count, where, order, page, per_page */
#define DATACONTROL_RESULT_NO_DATA -1
#define OSP_V_LAUNCH_TYPE_DATACONTROL "datacontrol"
/**
* @brief Enumerations of different type of data control requests.
*/
-typedef enum
-{
+typedef enum {
DATACONTROL_TYPE_ERROR = -1,
DATACONTROL_TYPE_UNDEFINED,
DATACONTROL_TYPE_SQL_SELECT,
} datacontrol_consumer_request_info;
int _consumer_request_compare_cb(gconstpointer a, gconstpointer b);
-
int _datacontrol_sql_set_cursor(const char *path);
-
-char *_datacontrol_create_select_statement(char *data_id, const char **column_list, int column_count,
- const char *where, const char *order, int page_number, int count_per_page);
-
+char *_datacontrol_create_select_statement(char *data_id,
+ const char **column_list, int column_count,
+ const char *where, const char *order, int page_number,
+ int count_per_page);
int _datacontrol_create_request_id(void);
-
-int _datacontrol_send_async(int sockfd, bundle *kb, datacontrol_request_type type, void *data);
-int _read_socket(int fd, char *buffer, unsigned int nbytes, unsigned int *bytes_read);
-int _write_socket(int fd, void *buffer, unsigned int nbytes, unsigned int *bytes_write);
-
-gboolean _datacontrol_recv_message(GIOChannel *channel, GIOCondition cond, gpointer data);
-int _get_gdbus_shared_connection(GDBusConnection **connection, char *provider_id);
-void _socket_info_free (gpointer socket);
-datacontrol_socket_info * _get_socket_info(const char *caller_id, const char *callee_id, const char *type, GIOFunc cb, void *data);
+int _datacontrol_send_async(int sockfd, bundle *kb,
+ datacontrol_request_type type, void *data);
+int _read_socket(int fd, char *buffer, unsigned int nbytes,
+ unsigned int *bytes_read);
+int _write_socket(int fd, void *buffer, unsigned int nbytes,
+ unsigned int *bytes_write);
+gboolean _datacontrol_recv_message(GIOChannel *channel, GIOCondition cond,
+ gpointer data);
+int _get_gdbus_shared_connection(GDBusConnection **connection,
+ char *provider_id);
+void _socket_info_free(gpointer socket);
+datacontrol_socket_info *_get_socket_info(const char *caller_id,
+ const char *callee_id, const char *type, GIOFunc cb,
+ void *data);
int _request_appsvc_run(const char *caller_id, const char *callee_id);
-
-
#endif /* _APPFW_DATA_CONTROL_INTERNAL_H_ */
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include <dlog.h>
#include <errno.h>
#include <search.h>
datacontrol_map_set_data_id(provider, data_id);
switch (type) {
-
case DATACONTROL_TYPE_MAP_GET:
- {
LOGI("GET VALUE");
if (callback != NULL && callback->get != NULL)
callback->get(request_id, provider, result_value_list, result_value_count, provider_result, error, map_dc->user_data);
LOGI("No registered callback function");
break;
- }
case DATACONTROL_TYPE_MAP_SET:
- {
LOGI("SET VALUE");
if (callback != NULL && callback->set != NULL)
callback->set(request_id, provider, provider_result, error, map_dc->user_data);
LOGI("No registered callback function");
break;
- }
case DATACONTROL_TYPE_MAP_ADD:
- {
LOGI("ADD VALUE");
if (callback != NULL && callback->add != NULL)
callback->add(request_id, provider, provider_result, error, map_dc->user_data);
LOGI("No registered callback function");
break;
- }
case DATACONTROL_TYPE_MAP_REMOVE:
- {
LOGI("REMOVE VALUE");
if (callback != NULL && callback->remove != NULL)
callback->remove(request_id, provider, provider_result, error, map_dc->user_data);
LOGI("No registered callback function");
break;
- }
default:
break;
}
int count = 0;
int nbytes = 0;
unsigned int nb = 0;
+ int j;
if (_read_socket(fd, (char *)&count, sizeof(count), &nb)) {
LOGE("datacontrol_recv_map_get_value_list : ...from %d: fail to read\n", fd);
ERROR:
if (value_list) {
- int j;
for (j = 0; j < i; j++) {
if (value_list[j] != NULL)
free(value_list[j]);
(GCompareFunc)_consumer_request_compare_cb);
if (list != NULL)
map_dc->request_info_list = g_list_remove(map_dc->request_info_list, list->data);
-
}
static int __map_handle_cb(int fd, bundle *b, int request_type, int request_id, appsvc_result_val res, void *data)
{
- LOGI("__map_handle_cb, request_type: %d", request_type);
-
int ret = 0;
const char **result_list = NULL;
const char *provider_id = NULL;
char **value_list = NULL;
const char *p = NULL;
+ LOGI("__map_handle_cb, request_type: %d", request_type);
+
if (!b) {
LOGE("the bundle returned from datacontrol-provider-service is null");
return DATACONTROL_ERROR_INVALID_PARAMETER;
switch (request_type) {
case DATACONTROL_TYPE_MAP_GET:
- {
LOGI("GET RESPONSE");
if (provider_result) {
value_list = __map_get_value_list(fd, &value_count);
}
}
break;
- }
case DATACONTROL_TYPE_MAP_SET:
case DATACONTROL_TYPE_MAP_ADD:
case DATACONTROL_TYPE_MAP_REMOVE:
- {
LOGI("SET or ADD or REMOVE RESPONSE");
break;
- }
default:
break;
}
__map_call_cb(provider_id, request_id, request_type, data_id, provider_result,
error_message, value_list, value_count, data);
ret = DATACONTROL_ERROR_NONE;
- } else
+ } else {
ret = DATACONTROL_ERROR_INVALID_PARAMETER;
+ }
return ret;
}
static int __datacontrol_send_map_async(int sockfd, bundle *kb, datacontrol_request_type type, void *data)
{
-
- LOGI("send async ~~~");
-
bundle_raw *kb_data = NULL;
int ret = DATACONTROL_ERROR_NONE;
int datalen;
int total_len;
unsigned int nb = 0;
+ LOGI("send async ~~~");
+
bundle_encode_raw(kb, &kb_data, &datalen);
if (kb_data == NULL) {
LOGE("bundle encode error");
return ret;
}
-
static gboolean __recv_map_message(GIOChannel *channel,
GIOCondition cond,
gpointer data)
int request_id = -1;
bundle *kb = NULL;
gint fd = g_io_channel_unix_get_fd(channel);
+ map_response_cb_s *map_dc;
+ GList *itr;
+ datacontrol_consumer_request_info *request_info;
+
LOGI("__recv_map_message: ...from %d:%s%s%s%s\n", fd,
(cond & G_IO_ERR) ? " ERR" : "",
(cond & G_IO_HUP) ? " HUP" : "",
goto error;
if (cond & G_IO_IN) {
-
if (_read_socket(fd, (char *)&nbytes, sizeof(nbytes), &nb)) {
LOGE("Fail to read nbytes from socket");
goto error;
LOGI("__recv_map_message: ...from %d: %d bytes\n", fd, nbytes);
if (nbytes > 0) {
-
buf = (char *) calloc(nbytes + 1, sizeof(char));
if (buf == NULL) {
LOGE("Malloc failed!!");
if (__map_handle_cb(fd, kb, request_type, request_id, 0, data) != DATACONTROL_ERROR_NONE)
goto error;
-
} else {
LOGE("error: listener information is null");
goto error;
free(buf);
if (((map_response_cb_s *)data) != NULL) {
-
- map_response_cb_s *map_dc = (map_response_cb_s *)data;
+ map_dc = (map_response_cb_s *)data;
g_hash_table_remove(__socket_pair_hash, map_dc->provider_id);
- GList *itr = g_list_first(map_dc->request_info_list);
+ itr = g_list_first(map_dc->request_info_list);
while (itr != NULL) {
- datacontrol_consumer_request_info *request_info = (datacontrol_consumer_request_info *)itr->data;
+ request_info = (datacontrol_consumer_request_info *)itr->data;
__map_call_cb(map_dc->provider_id, request_info->request_id, request_info->type, map_dc->data_id, false,
"provider IO Error", NULL, 0, data);
itr = g_list_next(itr);
static int __map_request_provider(datacontrol_h provider, datacontrol_request_type type, bundle *request_data, int request_id)
{
- LOGI("Map Data control request, type: %d, request id: %d", type, request_id);
-
char *app_id = NULL;
void *data = NULL;
int ret = DATACONTROL_ERROR_NONE;
+ void *map_dc_returned = NULL;
+ char caller_app_id[255];
+ char datacontrol_request_operation[MAX_LEN_DATACONTROL_REQ_TYPE] = {0, };
+ char req_id[32] = {0,};
+ int count = 0;
+ const int TRY_COUNT = 2;
+ const struct timespec TRY_SLEEP_TIME = { 0, 1000 * 1000 * 1000 };
+
+ LOGI("Map Data control request, type: %d, request id: %d", type, request_id);
if (type < DATACONTROL_TYPE_MAP_GET || type > DATACONTROL_TYPE_MAP_REMOVE) {
LOGE("Invalid request type: %d", (int)type);
map_dc_temp->user_data = NULL;
map_dc_temp->map_response_cb = NULL;
- void *map_dc_returned = NULL;
map_dc_returned = tfind(map_dc_temp, &datacontrol_map_tree_root, __map_instance_compare);
__map_instance_free(map_dc_temp);
LOGI("Map datacontrol appid: %s", map_dc->app_id);
- char caller_app_id[255];
pid_t pid = getpid();
if (aul_app_get_appid_bypid(pid, caller_app_id, sizeof(caller_app_id)) != 0) {
LOGE("Failed to get appid by pid(%d).", pid);
bundle_add_str(request_data, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_V_VERSION_2_1_0_3);
bundle_add_str(request_data, AUL_K_CALLER_APPID, caller_app_id);
- char datacontrol_request_operation[MAX_LEN_DATACONTROL_REQ_TYPE] = {0, };
snprintf(datacontrol_request_operation, MAX_LEN_DATACONTROL_REQ_TYPE, "%d", (int)(type));
bundle_add_str(request_data, OSP_K_DATACONTROL_REQUEST_TYPE, datacontrol_request_operation);
- char req_id[32] = {0,};
snprintf(req_id, 32, "%d", request_id);
bundle_add_str(request_data, OSP_K_REQUEST_ID, req_id);
- int count = 0;
- const int TRY_COUNT = 2;
- const struct timespec TRY_SLEEP_TIME = { 0, 1000 * 1000 * 1000 };
LOGI("caller_id %s, app_id %s", caller_app_id, app_id);
do {
datacontrol_socket_info *socket_info = g_hash_table_lookup(__socket_pair_hash, provider->provider_id);
-
if (socket_info == NULL) {
ret = _request_appsvc_run(caller_app_id, app_id);
if (ret != DATACONTROL_ERROR_NONE)
break;
count++;
nanosleep(&TRY_SLEEP_TIME, 0);
-
} while (ret != DATACONTROL_ERROR_NONE && count < TRY_COUNT);
return ret;
-
}
int datacontrol_map_create(datacontrol_h *provider)
if (*provider_id == NULL)
return DATACONTROL_ERROR_OUT_OF_MEMORY;
- } else
+ } else {
*provider_id = NULL;
+ }
return 0;
}
if (*data_id == NULL)
return DATACONTROL_ERROR_OUT_OF_MEMORY;
- } else
+ } else {
*data_id = NULL;
+ }
return 0;
}
int ret = 0;
char *app_id = NULL;
char *access = NULL;
+ void *map_dc_returned = NULL;
ret = pkgmgrinfo_appinfo_usr_get_datacontrol_info(provider->provider_id, "Map", getuid(), &app_id, &access);
if (ret != PMINFO_R_OK) {
map_dc_temp->user_data = user_data;
map_dc_temp->map_response_cb = callback;
- void *map_dc_returned = NULL;
map_dc_returned = tsearch(map_dc_temp, &datacontrol_map_tree_root, __map_instance_compare);
map_response_cb_s *map_dc = *(map_response_cb_s **)map_dc_returned;
{
int ret = DATACONTROL_ERROR_NONE;
map_response_cb_s *map_dc_temp = (map_response_cb_s *)calloc(1, sizeof(map_response_cb_s));
+ void *map_dc_returned = NULL;
g_hash_table_remove(__socket_pair_hash, provider->provider_id);
goto EXCEPTION;
}
- void *map_dc_returned = NULL;
-
map_dc_returned = tdelete(map_dc_temp, &datacontrol_map_tree_root, __map_instance_compare);
if (map_dc_returned == NULL) {
LOGE("invalid parameter");
int datacontrol_map_get_with_page(datacontrol_h provider, const char *key, int *request_id, int page_number, int count_per_page)
{
+ unsigned int arg_size;
+ int ret = 0;
+ const char *arg_list[4];
+ char page_no_str[32];
+ char count_per_page_str[32];
+ int reqId;
+
if (provider == NULL || provider->provider_id == NULL || provider->data_id == NULL || key == NULL) {
LOGE("Invalid parameter");
return DATACONTROL_ERROR_INVALID_PARAMETER;
LOGI("Gets the value list from provider_id: %s, data_id: %s", provider->provider_id, provider->data_id);
- unsigned int arg_size = (strlen(provider->data_id) + strlen(key)) * sizeof(wchar_t);
+ arg_size = (strlen(provider->data_id) + strlen(key)) * sizeof(wchar_t);
if (arg_size > MAX_ARGUMENT_SIZE) {
LOGE("The size of sending argument (%u) exceeds the maximum limit.", arg_size);
return DATACONTROL_ERROR_MAX_EXCEEDED;
}
- int ret = 0;
bundle *b = bundle_create();
if (!b) {
LOGE("unable to create bundle: %d", errno);
bundle_add_str(b, OSP_K_DATACONTROL_PROVIDER, provider->provider_id);
bundle_add_str(b, OSP_K_DATACONTROL_DATA, provider->data_id);
- const char *arg_list[4];
arg_list[0] = provider->data_id;
arg_list[1] = key;
- char page_no_str[32] = {0, };
- ret = snprintf(page_no_str, 32, "%d", page_number);
+ ret = snprintf(page_no_str, sizeof(page_no_str), "%d", page_number);
if (ret < 0) {
LOGE("unable to convert page no to string: %d", errno);
bundle_free(b);
return DATACONTROL_ERROR_OUT_OF_MEMORY;
}
- char count_per_page_str[32] = {0, };
- ret = snprintf(count_per_page_str, 32, "%d", count_per_page);
+ ret = snprintf(count_per_page_str, sizeof(count_per_page_str), "%d", count_per_page);
if (ret < 0) {
LOGE("unable to convert count per page no to string: %d", errno);
bundle_free(b);
bundle_add_str_array(b, OSP_K_ARG, arg_list, 4);
/* Set the request id */
- int reqId = _datacontrol_create_request_id();
+ reqId = _datacontrol_create_request_id();
*request_id = reqId;
ret = __map_request_provider(provider, DATACONTROL_TYPE_MAP_GET, b, reqId);
int datacontrol_map_set(datacontrol_h provider, const char *key, const char *old_value, const char *new_value, int *request_id)
{
+ unsigned int arg_size;
+ bundle *b;
+ const char *arg_list[4];
+ int reqId;
+ int ret;
+
if (provider == NULL || provider->provider_id == NULL || provider->data_id == NULL || key == NULL || old_value == NULL || new_value == NULL) {
LOGE("Invalid parameter");
return DATACONTROL_ERROR_INVALID_PARAMETER;
LOGI("Sets the old value to new value in provider_id: %s, data_id: %s", provider->provider_id, provider->data_id);
- unsigned int arg_size = (strlen(provider->data_id) + strlen(key) + strlen(old_value) + strlen(new_value)) * sizeof(wchar_t);
+ arg_size = (strlen(provider->data_id) + strlen(key) + strlen(old_value) + strlen(new_value)) * sizeof(wchar_t);
if (arg_size > MAX_ARGUMENT_SIZE) {
LOGE("The size of sending argument (%u) exceeds the maximum limit.", arg_size);
return DATACONTROL_ERROR_MAX_EXCEEDED;
}
- bundle *b = bundle_create();
+ b = bundle_create();
if (!b) {
LOGE("unable to create bundle: %d", errno);
return DATACONTROL_ERROR_OUT_OF_MEMORY;
bundle_add_str(b, OSP_K_DATACONTROL_PROVIDER, provider->provider_id);
bundle_add_str(b, OSP_K_DATACONTROL_DATA, provider->data_id);
- const char *arg_list[4];
arg_list[0] = provider->data_id;
arg_list[1] = key;
arg_list[2] = old_value;
bundle_add_str_array(b, OSP_K_ARG, arg_list, 4);
/* Set the request id */
- int reqId = _datacontrol_create_request_id();
+ reqId = _datacontrol_create_request_id();
*request_id = reqId;
- int ret = __map_request_provider(provider, DATACONTROL_TYPE_MAP_SET, b, reqId);
+ ret = __map_request_provider(provider, DATACONTROL_TYPE_MAP_SET, b, reqId);
bundle_free(b);
return ret;
int datacontrol_map_add(datacontrol_h provider, const char *key, const char *value, int *request_id)
{
+ unsigned int arg_size;
+ bundle *b;
+ const char *arg_list[3];
+ int reqId;
+ int ret;
+
if (provider == NULL || provider->provider_id == NULL || provider->data_id == NULL || key == NULL || value == NULL) {
LOGE("Invalid parameter");
return DATACONTROL_ERROR_INVALID_PARAMETER;
LOGI("Adds the value in provider_id: %s, data_id: %s", provider->provider_id, provider->data_id);
- unsigned int arg_size = (strlen(provider->data_id) + strlen(key) + strlen(value)) * sizeof(wchar_t);
+ arg_size = (strlen(provider->data_id) + strlen(key) + strlen(value)) * sizeof(wchar_t);
if (arg_size > MAX_ARGUMENT_SIZE) {
LOGE("The size of sending argument (%u) exceeds the maximum limit.", arg_size);
return DATACONTROL_ERROR_MAX_EXCEEDED;
}
- bundle *b = bundle_create();
+ b = bundle_create();
if (!b) {
LOGE("unable to create bundle: %d", errno);
return DATACONTROL_ERROR_OUT_OF_MEMORY;
bundle_add_str(b, OSP_K_DATACONTROL_PROVIDER, provider->provider_id);
bundle_add_str(b, OSP_K_DATACONTROL_DATA, provider->data_id);
- const char *arg_list[3];
arg_list[0] = provider->data_id;
arg_list[1] = key;
arg_list[2] = value;
bundle_add_str_array(b, OSP_K_ARG, arg_list, 3);
/* Set the request id */
- int reqId = _datacontrol_create_request_id();
+ reqId = _datacontrol_create_request_id();
*request_id = reqId;
- int ret = __map_request_provider(provider, DATACONTROL_TYPE_MAP_ADD, b, reqId);
+ ret = __map_request_provider(provider, DATACONTROL_TYPE_MAP_ADD, b, reqId);
bundle_free(b);
return ret;
int datacontrol_map_remove(datacontrol_h provider, const char *key, const char *value, int *request_id)
{
+ unsigned int arg_size;
+ bundle *b;
+ const char *arg_list[3];
+ int reqId;
+ int ret;
+
if (provider == NULL || provider->provider_id == NULL || provider->data_id == NULL || key == NULL || value == NULL) {
LOGE("Invalid parameter");
return DATACONTROL_ERROR_INVALID_PARAMETER;
LOGI("Removes the value in provider_id: %s, data_id: %s", provider->provider_id, provider->data_id);
- unsigned int arg_size = (strlen(provider->data_id) + strlen(key) + strlen(value)) * sizeof(wchar_t);
+ arg_size = (strlen(provider->data_id) + strlen(key) + strlen(value)) * sizeof(wchar_t);
if (arg_size > MAX_ARGUMENT_SIZE) {
LOGE("The size of sending argument (%u) exceeds the maximum limit.", arg_size);
return DATACONTROL_ERROR_MAX_EXCEEDED;
}
- bundle *b = bundle_create();
+ b = bundle_create();
if (!b) {
LOGE("unable to create bundle: %d", errno);
return DATACONTROL_ERROR_OUT_OF_MEMORY;
bundle_add_str(b, OSP_K_DATACONTROL_PROVIDER, provider->provider_id);
bundle_add_str(b, OSP_K_DATACONTROL_DATA, provider->data_id);
- const char *arg_list[3];
arg_list[0] = provider->data_id;
arg_list[1] = key;
arg_list[2] = value;
bundle_add_str_array(b, OSP_K_ARG, arg_list, 3);
/* Set the request id */
- int reqId = _datacontrol_create_request_id();
+ reqId = _datacontrol_create_request_id();
*request_id = reqId;
- int ret = __map_request_provider(provider, DATACONTROL_TYPE_MAP_REMOVE, b, reqId);
+ ret = __map_request_provider(provider, DATACONTROL_TYPE_MAP_REMOVE, b, reqId);
bundle_free(b);
return ret;
}
+
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include <dlog.h>
#include <errno.h>
#include <search.h>
};
-typedef int (*provider_handler_cb) (bundle *b, int request_id, void *data);
+typedef int (*provider_handler_cb)(bundle *b, int request_id, void *data);
static datacontrol_provider_sql_cb *provider_sql_cb = NULL;
static datacontrol_provider_map_cb *provider_map_cb = NULL;
static int __send_select_result(int fd, bundle *b, void *data)
{
-
- LOGI("__send_select_result");
-
/*
In this function, the result set is written in socket as specific form.
[sizeof(int)] column count
sqlite3_int64 offset_idx = 0;
sqlite3_int64 row_count = 0;
unsigned int nb = 0;
+ int type;
+ int column_name_len;
+ const char *page_number_str;
+ int size = 0;
+ void *value = NULL;
+ int column_type;
+ long long tmp_long = 0;
+ double tmp_double = 0.0;
+ void *buf = NULL;
+ int buf_len = 0;
+ const char *count_per_page_str;
+ LOGI("__send_select_result");
if (b == NULL || data == NULL) {
LOGE("The input param is invalid.");
return DATACONTROL_ERROR_INVALID_PARAMETER;
#define SQLITE_NULL 5
*/
for (i = 0; i < column_count; i++) {
- int type = sqlite3_column_type(state, i);
+ type = sqlite3_column_type(state, i);
if (_write_socket(fd, &type, sizeof(int), &nb) != DATACONTROL_ERROR_NONE) {
LOGI("Writing a type to a file descriptor is failed.");
return DATACONTROL_ERROR_IO_ERROR;
LOGI("sqlite3_column_name is failed. errno = %d", errno);
return DATACONTROL_ERROR_INVALID_PARAMETER;
} else {
- int column_name_len = strlen(column_name) + 1;
+ column_name_len = strlen(column_name) + 1;
if (_write_socket(fd, &column_name_len, sizeof(int), &nb) != DATACONTROL_ERROR_NONE) {
LOGI("Writing a column_name_len to a file descriptor is failed. errno = %d", errno);
return DATACONTROL_ERROR_IO_ERROR;
LOGI("Writing a total_len_of_column_names %d", total_len_of_column_names);
-
- const char *page_number_str = bundle_get_val(b, RESULT_PAGE_NUMBER);
- const char *count_per_page_str = bundle_get_val(b, MAX_COUNT_PER_PAGE);
+ page_number_str = bundle_get_val(b, RESULT_PAGE_NUMBER);
+ count_per_page_str = bundle_get_val(b, MAX_COUNT_PER_PAGE);
LOGI("page_number: %s, per_page: %s", page_number_str, count_per_page_str);
if (offset_idx > offset) {
++row_count;
for (i = 0; i < column_count; ++i) {
- int type = 0;
- int size = 0;
- void *value = NULL;
- int column_type = sqlite3_column_type(state, i);
- long long tmp_long = 0;
- double tmp_double = 0.0;
- void *buf = NULL;
- int buf_len = 0;
+ column_type = sqlite3_column_type(state, i);
+
switch (column_type) {
case SQLITE_INTEGER:
type = 1;
static int __send_get_value_result(int fd, bundle *b, void *data)
{
-
int i = 0;
char **value_list = (char **)data;
-
const char *page_num_str = bundle_get_val(b, RESULT_PAGE_NUMBER);
const char *count_per_page_str = bundle_get_val(b, MAX_COUNT_PER_PAGE);
const char *value_count_str = bundle_get_val(b, RESULT_VALUE_COUNT);
-
- LOGI("page num: %s, count_per_page: %s, value_count %s", page_num_str, count_per_page_str, value_count_str);
-
int page_number = 0;
int count_per_page = 0;
int value_count = 0;
int current_offset = 0;
int remain_count = 0;
unsigned int nb;
+ int add_value_count;
+ int length;
+
+ LOGI("page num: %s, count_per_page: %s, value_count %s", page_num_str, count_per_page_str, value_count_str);
page_number = _get_int_from_str(page_num_str);
count_per_page = _get_int_from_str(count_per_page_str);
remain_count = value_count - current_offset;
remain_count = (remain_count > 0) ? remain_count : 0; /* round off to zero if the negative num is found */
- int add_value_count = (count_per_page > remain_count) ? remain_count : count_per_page;
+ add_value_count = (count_per_page > remain_count) ? remain_count : count_per_page;
LOGI("add_value_count: %d, current_offset: %d, remain_count %d", add_value_count, current_offset, remain_count);
add_value_count += current_offset;
for (i = current_offset; i < add_value_count; i++) {
- int length = strlen(value_list[i]);
+ length = strlen(value_list[i]);
LOGI("length = %d", length);
if (_write_socket(fd, &length, sizeof(int), &nb) != DATACONTROL_ERROR_NONE) {
LOGE("Writing a length to a file descriptor is failed. errno = %d", errno);
int __datacontrol_send_async(int sockfd, bundle *kb, datacontrol_request_type type, void *data)
{
- LOGI("send async ~~~");
-
bundle_raw *kb_data = NULL;
int ret = DATACONTROL_ERROR_NONE;
int datalen = 0;
int total_len = 0;
unsigned int nb = 0;
+ LOGI("send async ~~~");
+
bundle_encode_raw(kb, &kb_data, &datalen);
if (kb_data == NULL) {
LOGE("bundle encode error");
{
bundle *b = bundle_create();
int len = 0;
+ int ret;
+ char *buf;
- int ret = read(fd, &len, sizeof(int));
+ ret = read(fd, &len, sizeof(int));
if (ret < sizeof(int)) {
LOGE("read error :%d", ret);
if (b)
}
if (len > 0) {
- char *buf = (char *)calloc(len, sizeof(char));
+ buf = (char *)calloc(len, sizeof(char));
if (buf == NULL) {
LOGE("calloc fail");
if (b)
if (buf)
free(buf);
- } else
+ } else {
LOGE("__get_data_sql read count : %d", len);
+ }
return b;
}
static bundle *__set_result(bundle *b, datacontrol_request_type type, void *data)
{
-
bundle *res = bundle_create();
/* Set the type */
char type_str[MAX_LEN_DATACONTROL_REQ_TYPE] = {0,};
+ const char *request_type;
+ const char *provider_id;
+ const char *data_id;
+ const char *request_id;
+ const char *caller_appid;
+ const char *list[3];
+ const char *page_num = bundle_get_val(b, RESULT_PAGE_NUMBER);
+ const char *count_per_page = bundle_get_val(b, MAX_COUNT_PER_PAGE);
if (type == DATACONTROL_TYPE_UNDEFINED || type == DATACONTROL_TYPE_ERROR) {
- char *request_type = (char *)bundle_get_val(b, OSP_K_DATACONTROL_REQUEST_TYPE);
+ request_type = bundle_get_val(b, OSP_K_DATACONTROL_REQUEST_TYPE);
strncpy(type_str, request_type, MAX_LEN_DATACONTROL_REQ_TYPE);
LOGI("type is %s", type_str);
bundle_add_str(res, OSP_K_DATACONTROL_REQUEST_TYPE, type_str);
/* Set the provider id */
- char *provider_id = (char *)bundle_get_val(b, OSP_K_DATACONTROL_PROVIDER);
+ provider_id = bundle_get_val(b, OSP_K_DATACONTROL_PROVIDER);
bundle_add_str(res, OSP_K_DATACONTROL_PROVIDER, provider_id);
/* Set the data id */
- char *data_id = (char *)bundle_get_val(b, OSP_K_DATACONTROL_DATA);
+ data_id = bundle_get_val(b, OSP_K_DATACONTROL_DATA);
bundle_add_str(res, OSP_K_DATACONTROL_DATA, data_id);
/* Set the caller request id */
- char *request_id = (char *)bundle_get_val(b, OSP_K_REQUEST_ID);
+ request_id = bundle_get_val(b, OSP_K_REQUEST_ID);
bundle_add_str(res, OSP_K_REQUEST_ID, request_id);
- char *caller_appid = (char *)bundle_get_val(b, AUL_K_CALLER_APPID);
+ caller_appid = bundle_get_val(b, AUL_K_CALLER_APPID);
bundle_add_str(res, AUL_K_CALLER_APPID, caller_appid);
switch (type) {
case DATACONTROL_TYPE_SQL_SELECT:
{
- const char *list[3];
-
list[PACKET_INDEX_REQUEST_RESULT] = "1"; /* request result */
list[PACKET_INDEX_ERROR_MSG] = DATACONTROL_EMPTY;
list[PACKET_INDEX_SELECT_RESULT_FILE] = DATACONTROL_EMPTY;
- const char *page_num = bundle_get_val(b, RESULT_PAGE_NUMBER);
- const char *count_per_page = bundle_get_val(b, MAX_COUNT_PER_PAGE);
+ page_num = bundle_get_val(b, RESULT_PAGE_NUMBER);
+ count_per_page = bundle_get_val(b, MAX_COUNT_PER_PAGE);
LOGI("page num: %s, count_per_page: %s", page_num, count_per_page);
static int __send_result(bundle *b, datacontrol_request_type type, void *data)
{
-
datacontrol_socket_info *socket_info;
char *caller_app_id = (char *)bundle_get_val(b, AUL_K_CALLER_APPID);
int ret = DATACONTROL_ERROR_NONE;
gboolean __provider_recv_message(GIOChannel *channel,
GIOCondition cond,
- gpointer data) {
-
+ gpointer data)
+{
char *buf = NULL;
int data_len;
guint nb;
goto error;
if (cond & G_IO_IN) {
-
if (_read_socket(fd, (char *)&data_len, sizeof(data_len), &nb) != DATACONTROL_ERROR_NONE) {
LOGE("read socket fail : data_len");
goto error;
int __datacontrol_handler_cb(bundle *b, int request_id, void *data)
{
- LOGI("datacontrol_handler_cb");
datacontrol_socket_info *socket_info;
-
char *caller = (char *)bundle_get_val(b, AUL_K_CALLER_APPID);
char *callee = (char *)bundle_get_val(b, AUL_K_CALLEE_APPID);
+ LOGI("datacontrol_handler_cb");
socket_info = g_hash_table_lookup(__socket_pair_hash, caller);
if (socket_info != NULL)
int datacontrol_provider_get_client_appid(int request_id, char **appid)
{
+ const char *caller;
+ bundle *b;
+
if (__request_table == NULL)
__initialize_provider();
- bundle *b = g_hash_table_lookup(__request_table, &request_id);
+ b = g_hash_table_lookup(__request_table, &request_id);
if (!b) {
LOGE("No data for the request id: %d", request_id);
return DATACONTROL_ERROR_INVALID_PARAMETER;
}
- const char *caller = bundle_get_val(b, AUL_K_CALLER_APPID);
+ caller = bundle_get_val(b, AUL_K_CALLER_APPID);
if (!caller) {
LOGE("No appid for the request id: %d", request_id);
return DATACONTROL_ERROR_INVALID_PARAMETER;
int datacontrol_provider_send_select_result(int request_id, void *db_handle)
{
+ int ret;
+ bundle *res;
+ bundle *b;
+
LOGI("Send a select result for request id: %d", request_id);
if (__request_table == NULL)
__initialize_provider();
- bundle *b = g_hash_table_lookup(__request_table, &request_id);
+ b = g_hash_table_lookup(__request_table, &request_id);
if (!b) {
LOGE("No data for the request id: %d", request_id);
return DATACONTROL_ERROR_INVALID_PARAMETER;
}
- bundle *res = __set_result(b, DATACONTROL_TYPE_SQL_SELECT, db_handle);
- int ret = __send_result(res, DATACONTROL_TYPE_SQL_SELECT, db_handle);
+ res = __set_result(b, DATACONTROL_TYPE_SQL_SELECT, db_handle);
+ ret = __send_result(res, DATACONTROL_TYPE_SQL_SELECT, db_handle);
g_hash_table_remove(__request_table, &request_id);
return ret;
int datacontrol_provider_send_insert_result(int request_id, long long row_id)
{
+ int ret;
+ bundle *res;
+ bundle *b;
+
LOGI("Send an insert result for request id: %d", request_id);
if (__request_table == NULL)
__initialize_provider();
- bundle *b = g_hash_table_lookup(__request_table, &request_id);
+ b = g_hash_table_lookup(__request_table, &request_id);
if (!b) {
LOGE("No data for the request id: %d", request_id);
return DATACONTROL_ERROR_INVALID_PARAMETER;
}
- bundle *res = __set_result(b, DATACONTROL_TYPE_SQL_INSERT, (void *)&row_id);
+ res = __set_result(b, DATACONTROL_TYPE_SQL_INSERT, (void *)&row_id);
- int ret = __send_result(res, DATACONTROL_TYPE_SQL_INSERT, NULL);
+ ret = __send_result(res, DATACONTROL_TYPE_SQL_INSERT, NULL);
g_hash_table_remove(__request_table, &request_id);
return ret;
-
}
int datacontrol_provider_send_update_result(int request_id)
{
+ int ret;
+ bundle *res;
+ bundle *b;
+
LOGI("Send an update result for request id: %d", request_id);
if (__request_table == NULL)
__initialize_provider();
- bundle *b = g_hash_table_lookup(__request_table, &request_id);
+ b = g_hash_table_lookup(__request_table, &request_id);
if (!b) {
LOGE("No data for the request id: %d", request_id);
return DATACONTROL_ERROR_INVALID_PARAMETER;
}
- bundle *res = __set_result(b, DATACONTROL_TYPE_SQL_UPDATE, NULL);
+ res = __set_result(b, DATACONTROL_TYPE_SQL_UPDATE, NULL);
- int ret = __send_result(res, DATACONTROL_TYPE_SQL_UPDATE, NULL);
+ ret = __send_result(res, DATACONTROL_TYPE_SQL_UPDATE, NULL);
g_hash_table_remove(__request_table, &request_id);
return ret;
-
}
int datacontrol_provider_send_delete_result(int request_id)
{
+ int ret;
+ bundle *res;
+ bundle *b;
+
LOGI("Send a delete result for request id: %d", request_id);
if (__request_table == NULL)
__initialize_provider();
- bundle *b = g_hash_table_lookup(__request_table, &request_id);
+ b = g_hash_table_lookup(__request_table, &request_id);
if (!b) {
LOGE("No data for the request id: %d", request_id);
return DATACONTROL_ERROR_INVALID_PARAMETER;
}
- bundle *res = __set_result(b, DATACONTROL_TYPE_SQL_DELETE, NULL);
+ res = __set_result(b, DATACONTROL_TYPE_SQL_DELETE, NULL);
- int ret = __send_result(res, DATACONTROL_TYPE_SQL_DELETE, NULL);
+ ret = __send_result(res, DATACONTROL_TYPE_SQL_DELETE, NULL);
g_hash_table_remove(__request_table, &request_id);
return ret;
int datacontrol_provider_send_error(int request_id, const char *error)
{
+ bundle *res;
+ bundle *b;
+
LOGI("Send an error for request id: %d", request_id);
if (__request_table == NULL)
__initialize_provider();
- bundle *b = g_hash_table_lookup(__request_table, &request_id);
+ b = g_hash_table_lookup(__request_table, &request_id);
if (!b) {
LOGE("No data for the request id: %d", request_id);
return DATACONTROL_ERROR_INVALID_PARAMETER;
}
- bundle *res = __set_result(b, DATACONTROL_TYPE_ERROR, (void *)error);
+ res = __set_result(b, DATACONTROL_TYPE_ERROR, (void *)error);
return __send_result(res, DATACONTROL_TYPE_ERROR, NULL);
}
int datacontrol_provider_send_map_result(int request_id)
{
+ int ret;
+ bundle *res;
+ bundle *b;
+
LOGI("Send a set/add/remove result for request id: %d", request_id);
if (__request_table == NULL)
__initialize_provider();
- bundle *b = g_hash_table_lookup(__request_table, &request_id);
+ b = g_hash_table_lookup(__request_table, &request_id);
if (!b) {
LOGE("No data for the request id: %d", request_id);
return DATACONTROL_ERROR_INVALID_PARAMETER;
}
- bundle *res = __set_result(b, DATACONTROL_TYPE_UNDEFINED, NULL);
+ res = __set_result(b, DATACONTROL_TYPE_UNDEFINED, NULL);
- int ret = __send_result(res, DATACONTROL_TYPE_UNDEFINED, NULL);
+ ret = __send_result(res, DATACONTROL_TYPE_UNDEFINED, NULL);
g_hash_table_remove(__request_table, &request_id);
return ret;
-
}
int datacontrol_provider_send_map_get_value_result(int request_id, char **value_list, int value_count)
{
+ int ret;
+ char value_count_str[32];
+ bundle *b;
+ bundle *res;
+
LOGI("Send a get result for request id: %d", request_id);
if (__request_table == NULL)
__initialize_provider();
- bundle *b = g_hash_table_lookup(__request_table, &request_id);
+ b = g_hash_table_lookup(__request_table, &request_id);
if (!b) {
LOGE("No data for the request id: %d", request_id);
return DATACONTROL_ERROR_INVALID_PARAMETER;
}
- char value_count_str[32] = {0,};
snprintf(value_count_str, 32, "%d", value_count);
bundle_add_str(b, RESULT_VALUE_COUNT, value_count_str);
- bundle *res = __set_result(b, DATACONTROL_TYPE_MAP_GET, value_list);
+ res = __set_result(b, DATACONTROL_TYPE_MAP_GET, value_list);
- int ret = __send_result(res, DATACONTROL_TYPE_MAP_GET, value_list);
+ ret = __send_result(res, DATACONTROL_TYPE_MAP_GET, value_list);
g_hash_table_remove(__request_table, &request_id);
return ret;
-
}
+
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
#include <dlog.h>
#include <errno.h>
#include <stdlib.h>
return DATACONTROL_ERROR_IO_ERROR;
}
- if (cursor->resultset_current_offset == 0)
+ if (cursor->resultset_current_offset == 0) {
cursor->resultset_current_offset = cursor->resultset_content_offset;
- else {
+ } else {
if (!(cursor->resultset_current_row_count < (cursor->resultset_row_count - 1))) {
LOGE("Reached to the end of the result set");
return DATACONTROL_ERROR_IO_ERROR;
int datacontrol_sql_step_last(resultset_cursor *cursor)
{
int ret = 0;
+ int i = 0;
+
if (cursor->resultset_current_row_count == (cursor->resultset_row_count - 1))
return DATACONTROL_ERROR_NONE; /* Already @ last row */
cursor->resultset_current_offset = cursor->row_offset_list[cursor->resultset_row_count - 1];
cursor->resultset_current_row_count = cursor->resultset_row_count - 1;
} else {
- int i = 0;
/* Move till last row offset. */
for (i = (cursor->resultset_current_row_count + 1); i < cursor->resultset_row_count; i++) {
ret = datacontrol_sql_step_next(cursor); /* move till last row data offset */
return DATACONTROL_ERROR_NONE;
}
-
int datacontrol_sql_step_first(resultset_cursor *cursor)
{
if (cursor->resultset_current_offset > 0) {
return datacontrol_sql_step_next(cursor);
}
-
int datacontrol_sql_step_previous(resultset_cursor *cursor)
{
if ((cursor->resultset_current_row_count - 1) < 0) {
return DATACONTROL_ERROR_NONE;
}
-
int datacontrol_sql_get_column_count(resultset_cursor *cursor)
{
return cursor->resultset_col_count;
return DATACONTROL_ERROR_NONE;
}
-
int datacontrol_sql_get_column_item_size(resultset_cursor *cursor, int column_index)
{
int type = -1;
return size;
}
-
int datacontrol_sql_get_column_item_type(resultset_cursor *cursor, int column_index,
datacontrol_sql_column_type *col_type)
{
case DATACONTROL_SQL_COLUMN_TYPE_INT64:
*col_type = DATACONTROL_SQL_COLUMN_TYPE_INT64;
break;
-
case DATACONTROL_SQL_COLUMN_TYPE_DOUBLE:
*col_type = DATACONTROL_SQL_COLUMN_TYPE_DOUBLE;
break;
-
case DATACONTROL_SQL_COLUMN_TYPE_TEXT:
*col_type = DATACONTROL_SQL_COLUMN_TYPE_TEXT;
break;
-
case DATACONTROL_SQL_COLUMN_TYPE_BLOB:
*col_type = DATACONTROL_SQL_COLUMN_TYPE_BLOB;
break;
-
case DATACONTROL_SQL_COLUMN_TYPE_NULL:
*col_type = DATACONTROL_SQL_COLUMN_TYPE_NULL;
break;
-
default:
*col_type = DATACONTROL_SQL_COLUMN_TYPE_UNDEFINED;
break;
return DATACONTROL_ERROR_NONE;
}
-
int datacontrol_sql_get_blob_data(resultset_cursor *cursor, int column_index, void *buffer, int data_size)
{
int type = -1;
int ret = 0;
char err_buf[ERR_BUFFER_SIZE];
int fd = cursor->resultset_fd;
+ char *data;
ret = lseek(fd, cursor->resultset_current_offset, SEEK_SET);
if (ret < 0) {
}
if (size > 0) {
- char *data = (char *)malloc((size + 1) * (sizeof(char)));
+ data = (char *)malloc((size + 1) * (sizeof(char)));
memset(data, 0, size + 1);
ret = read(fd, data, size);
return DATACONTROL_ERROR_NONE;
}
-
int datacontrol_sql_get_int_data(resultset_cursor *cursor, int column_index, int *data)
{
long long long_value = 0;
return ret;
}
-
int datacontrol_sql_get_int64_data(resultset_cursor *cursor, int column_index, long long *data)
{
int type = -1;
int ret = 0;
char err_buf[ERR_BUFFER_SIZE];
int fd = cursor->resultset_fd;
+ char *data;
ret = lseek(fd, cursor->resultset_current_offset, SEEK_SET);
if (ret < 0) {
}
if (size > 0) {
- char *data = (char *)malloc((size + 1) * (sizeof(char)));
+ data = (char *)malloc((size + 1) * (sizeof(char)));
if (!data) {
LOGE("unable to create buffer to read");
return DATACONTROL_ERROR_OUT_OF_MEMORY;
return DATACONTROL_ERROR_NONE;
}
-
int datacontrol_sql_remove_cursor(resultset_cursor *cursor)
{
+ int ret;
+
close(cursor->resultset_fd);
- int ret = remove(cursor->resultset_path);
+ ret = remove(cursor->resultset_path);
if (ret == -1)
LOGE("unable to remove map query result file: %d", ret);
return DATACONTROL_ERROR_NONE;
}
+
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
#include <dlog.h>
#include <errno.h>
#include <search.h>
static void *datacontrol_sql_tree_root = NULL;
static GHashTable *__socket_pair_hash = NULL;
-static int __recv_sql_select_process(bundle *kb, int fd, resultset_cursor *cursor);
+static int __recv_sql_select_process(bundle *kb, int fd,
+ resultset_cursor *cursor);
-static void __sql_call_cb(const char *provider_id, int request_id, datacontrol_request_type type,
- const char *data_id, bool provider_result, const char *error, long long insert_rowid, resultset_cursor *cursor, void *data)
+static void __sql_call_cb(const char *provider_id, int request_id,
+ datacontrol_request_type type, const char *data_id,
+ bool provider_result, const char *error, long long insert_rowid,
+ resultset_cursor *cursor, void *data)
{
- LOGI("__sql_call_cb, dataID !!!: %s", data_id);
-
datacontrol_sql_response_cb *callback = NULL;
+ sql_response_cb_s *sql_dc;
+ datacontrol_h provider;
+
+ LOGI("__sql_call_cb, dataID !!!: %s", data_id);
- sql_response_cb_s *sql_dc = NULL;
sql_dc = (sql_response_cb_s *)data;
callback = sql_dc->sql_response_cb;
if (!callback) {
return;
}
- datacontrol_h provider;
datacontrol_sql_create(&provider);
-
datacontrol_sql_set_provider_id(provider, provider_id);
datacontrol_sql_set_data_id(provider, data_id);
switch (type) {
case DATACONTROL_TYPE_SQL_SELECT:
- {
LOGI("SELECT");
if (callback != NULL && callback->select != NULL)
callback->select(request_id, provider, cursor, provider_result, error, sql_dc->user_data);
LOGI("No registered callback function");
break;
- }
case DATACONTROL_TYPE_SQL_INSERT:
- {
LOGI("INSERT row_id: %lld", insert_rowid);
if (callback != NULL && callback->insert != NULL)
callback->insert(request_id, provider, insert_rowid, provider_result, error, sql_dc->user_data);
LOGI("No registered callback function");
break;
- }
case DATACONTROL_TYPE_SQL_UPDATE:
- {
LOGI("UPDATE");
if (callback != NULL && callback->update != NULL)
callback->update(request_id, provider, provider_result, error, sql_dc->user_data);
else
LOGI("No registered callback function");
break;
- }
case DATACONTROL_TYPE_SQL_DELETE:
- {
LOGI("DELETE");
if (callback != NULL && callback->delete != NULL)
callback->delete(request_id, provider, provider_result, error, sql_dc->user_data);
else
LOGI("No registered callback function");
break;
- }
default:
break;
}
const char *p = NULL;
if (b) {
-
/* result list */
result_list = appsvc_get_data_array(b, OSP_K_ARG, &result_list_len);
if (!result_list) {
LOGI("Provider ID: %s, Data ID: %s, Operation type: %d", provider_id, data_id, request_type);
switch (request_type) {
-
case DATACONTROL_TYPE_SQL_SELECT:
- {
if (provider_result) {
cursor = datacontrol_sql_get_cursor();
if (!cursor) {
return DATACONTROL_ERROR_IO_ERROR;
}
break;
- }
case DATACONTROL_TYPE_SQL_INSERT:
- {
LOGI("INSERT RESPONSE");
if (provider_result) {
p = result_list[2]; /* result list[2] */
insert_rowid = atoll(p);
}
break;
- }
case DATACONTROL_TYPE_SQL_UPDATE:
case DATACONTROL_TYPE_SQL_DELETE:
- {
LOGI("UPDATE or DELETE RESPONSE");
break;
- }
default:
break;
}
static int __recv_sql_select_process(bundle *kb, int fd, resultset_cursor *cursor)
{
-
int column_count = 0;
int column_type = 0;
int column_name_len = 0;
}
if (size > 0) {
- value = (void *) malloc(sizeof(void) * size);
+ value = (void *)malloc(sizeof(void) * size);
if (value == NULL) {
LOGE("Out of mememory");
retval = DATACONTROL_ERROR_IO_ERROR;
datacontrol_sql_remove_cursor(cursor);
return retval;
-
}
static gboolean __consumer_recv_sql_message(GIOChannel *channel,
- GIOCondition cond,
- gpointer data) {
-
+ GIOCondition cond, gpointer data)
+{
gint fd = g_io_channel_unix_get_fd(channel);
char *buf = NULL;
+ int data_len;
+ guint nb;
+ const char *p = NULL;
+ int request_id;
+ bundle *kb;
+ sql_response_cb_s *sql_dc;
+ GList *itr;
+ datacontrol_consumer_request_info *request_info;
LOGI("__consumer_recv_sql_message: ...from %d:%s%s%s%s\n", fd,
(cond & G_IO_ERR) ? " ERR" : "",
goto error;
if (cond & G_IO_IN) {
- int data_len;
- guint nb;
- const char *p = NULL;
- int request_id;
-
if (_read_socket(fd, (char *)&data_len, sizeof(data_len), &nb) != DATACONTROL_ERROR_NONE)
goto error;
LOGI("data_len : %d", data_len);
goto error;
}
if (data_len > 0) {
- bundle *kb = NULL;
buf = (char *)calloc(data_len + 1, sizeof(char));
if (buf == NULL) {
LOGE("Out of memory.");
if (((sql_response_cb_s *)data) != NULL) {
LOGE("g_hash_table_remove");
- sql_response_cb_s *sql_dc = (sql_response_cb_s *)data;
+ sql_dc = (sql_response_cb_s *)data;
g_hash_table_remove(__socket_pair_hash, sql_dc->provider_id);
- GList *itr = g_list_first(sql_dc->request_info_list);
+ itr = g_list_first(sql_dc->request_info_list);
while (itr != NULL) {
- datacontrol_consumer_request_info *request_info = (datacontrol_consumer_request_info *)itr->data;
+ request_info = (datacontrol_consumer_request_info *)itr->data;
__sql_call_cb(sql_dc->provider_id, request_info->request_id, request_info->type, sql_dc->data_id, false,
"provider IO Error", -1, NULL, data);
itr = g_list_next(itr);
int __datacontrol_send_sql_async(int sockfd, bundle *kb, bundle *extra_kb, datacontrol_request_type type, void *data)
{
-
- LOGE("send async ~~~");
bundle_raw *kb_data = NULL;
bundle_raw *extra_kb_data = NULL;
int ret = DATACONTROL_ERROR_NONE;
int total_len = 0;
unsigned int nb = 0;
+ LOGE("send async ~~~");
+
bundle_encode_raw(kb, &kb_data, &datalen);
if (kb_data == NULL) {
LOGE("bundle encode error");
static int __sql_request_provider(datacontrol_h provider, datacontrol_request_type type, bundle *request_data, bundle *extra_kb, int request_id)
{
- LOGI("SQL Data control request, type: %d, request id: %d", type, request_id);
-
char *app_id = NULL;
void *data = NULL;
int ret = DATACONTROL_ERROR_NONE;
+ sql_response_cb_s *sql_dc_temp;
+ void *sql_dc_returned = NULL;
+ char caller_app_id[255];
+ char datacontrol_request_operation[MAX_LEN_DATACONTROL_REQ_TYPE] = {0, };
+ char req_id[32] = {0, };
+ int count = 0;
+ const int TRY_COUNT = 2;
+ const struct timespec TRY_SLEEP_TIME = { 0, 1000 * 1000 * 1000 };
+ char *socket_info_key;
+
+
+ LOGI("SQL Data control request, type: %d, request id: %d", type, request_id);
if (__socket_pair_hash == NULL)
__socket_pair_hash = g_hash_table_new_full(g_str_hash, g_str_equal, free, _socket_info_free);
if ((int)type <= (int)DATACONTROL_TYPE_SQL_DELETE) {
-
if ((int)type < (int)DATACONTROL_TYPE_SQL_SELECT) {
LOGE("invalid request type: %d", (int)type);
return DATACONTROL_ERROR_INVALID_PARAMETER;
return DATACONTROL_ERROR_INVALID_PARAMETER;
}
- sql_response_cb_s *sql_dc_temp = (sql_response_cb_s *)calloc(1, sizeof(sql_response_cb_s));
+ sql_dc_temp = (sql_response_cb_s *)calloc(1, sizeof(sql_response_cb_s));
if (!sql_dc_temp) {
LOGE("failed to create sql datacontrol");
return DATACONTROL_ERROR_OUT_OF_MEMORY;
sql_dc_temp->user_data = NULL;
sql_dc_temp->sql_response_cb = NULL;
- void *sql_dc_returned = NULL;
sql_dc_returned = tfind(sql_dc_temp, &datacontrol_sql_tree_root, __sql_instance_compare);
__sql_instance_free(sql_dc_temp);
LOGI("SQL datacontrol appid: %s", sql_dc->app_id);
}
- char caller_app_id[255];
pid_t pid = getpid();
if (aul_app_get_appid_bypid(pid, caller_app_id, sizeof(caller_app_id)) != 0) {
LOGE("Failed to get appid by pid(%d).", pid);
bundle_add_str(request_data, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_V_VERSION_2_1_0_3);
bundle_add_str(request_data, AUL_K_CALLER_APPID, caller_app_id);
- char datacontrol_request_operation[MAX_LEN_DATACONTROL_REQ_TYPE] = {0, };
snprintf(datacontrol_request_operation, MAX_LEN_DATACONTROL_REQ_TYPE, "%d", (int)(type));
bundle_add_str(request_data, OSP_K_DATACONTROL_REQUEST_TYPE, datacontrol_request_operation);
- char req_id[32] = {0, };
snprintf(req_id, 32, "%d", request_id);
bundle_add_str(request_data, OSP_K_REQUEST_ID, req_id);
- int count = 0;
- const int TRY_COUNT = 2;
- const struct timespec TRY_SLEEP_TIME = { 0, 1000 * 1000 * 1000 };
-
do {
datacontrol_socket_info *socket_info = g_hash_table_lookup(__socket_pair_hash, provider->provider_id);
return DATACONTROL_ERROR_IO_ERROR;
}
- char *socket_info_key = strdup(provider->provider_id);
+ socket_info_key = strdup(provider->provider_id);
if (socket_info_key == NULL) {
LOGE("Out of memory. can not dup select map file.");
return DATACONTROL_ERROR_IO_ERROR;
} while (ret != DATACONTROL_ERROR_NONE && count < TRY_COUNT);
return ret;
-
}
int datacontrol_sql_create(datacontrol_h *provider)
if (*provider_id == NULL)
return DATACONTROL_ERROR_OUT_OF_MEMORY;
- } else
+ } else {
*provider_id = NULL;
+ }
return 0;
}
int datacontrol_sql_register_response_cb(datacontrol_h provider, datacontrol_sql_response_cb *callback, void *user_data)
{
-
int ret = 0;
char *app_id = NULL;
char *access = NULL;
+ void *sql_dc_returned = NULL;
+ sql_response_cb_s *sql_dc;
ret = pkgmgrinfo_appinfo_usr_get_datacontrol_info(provider->provider_id, "Sql", getuid(), &app_id, &access);
if (ret != PMINFO_R_OK) {
sql_dc_temp->user_data = user_data;
sql_dc_temp->sql_response_cb = callback;
- void *sql_dc_returned = NULL;
sql_dc_returned = tsearch(sql_dc_temp, &datacontrol_sql_tree_root, __sql_instance_compare);
- sql_response_cb_s *sql_dc = *(sql_response_cb_s **)sql_dc_returned;
+ sql_dc = *(sql_response_cb_s **)sql_dc_returned;
if (sql_dc != sql_dc_temp) {
sql_dc->sql_response_cb = callback;
sql_dc->user_data = user_data;
int datacontrol_sql_unregister_response_cb(datacontrol_h provider)
{
-
int ret = DATACONTROL_ERROR_NONE;
+ void *sql_dc_returned = NULL;
+
LOGE("g_hash_table_remove");
g_hash_table_remove(__socket_pair_hash, provider->provider_id);
goto EXCEPTION;
}
- void *sql_dc_returned = NULL;
sql_dc_returned = tdelete(sql_dc_temp, &datacontrol_sql_tree_root, __sql_instance_compare);
if (sql_dc_returned == NULL) {
LOGE("invalid parameter");
}
return ret;
-
}
static void bundle_foreach_check_arg_size_cb(const char *key, const int type,
- const bundle_keyval_t *kv, void *arg_size) {
-
+ const bundle_keyval_t *kv, void *arg_size)
+{
char *value = NULL;
size_t value_len = 0;
bundle_keyval_get_basic_val((bundle_keyval_t *)kv, (void **)&value, &value_len);
int datacontrol_sql_insert(datacontrol_h provider, const bundle *insert_data, int *request_id)
{
+ int ret = 0;
+ long long arg_size = 0;
+ const char *arg_list[2];
+ bundle *b;
+ char insert_column_count[MAX_LEN_DATACONTROL_COLUMN_COUNT] = {0, };
+ int count;
+
if (provider == NULL || provider->provider_id == NULL || provider->data_id == NULL || insert_data == NULL) {
LOGE("Invalid parameter");
return DATACONTROL_ERROR_INVALID_PARAMETER;
LOGI("SQL data control, insert to provider_id: %s, data_id: %s", provider->provider_id, provider->data_id);
- int ret = 0;
-
/* Check size of arguments */
- long long arg_size = 0;
bundle_foreach((bundle *)insert_data, bundle_foreach_check_arg_size_cb, &arg_size);
arg_size += strlen(provider->data_id) * sizeof(wchar_t);
if (arg_size > MAX_REQUEST_ARGUMENT_SIZE) {
return DATACONTROL_ERROR_MAX_EXCEEDED;
}
- bundle *b = bundle_create();
+ b = bundle_create();
if (!b) {
LOGE("unable to create bundle: %d", errno);
return DATACONTROL_ERROR_OUT_OF_MEMORY;
bundle_add_str(b, OSP_K_DATACONTROL_PROVIDER, provider->provider_id);
bundle_add_str(b, OSP_K_DATACONTROL_DATA, provider->data_id);
- char insert_column_count[MAX_LEN_DATACONTROL_COLUMN_COUNT] = {0, };
- int count = bundle_get_count((bundle *)insert_data);
+ count = bundle_get_count((bundle *)insert_data);
ret = snprintf(insert_column_count, MAX_LEN_DATACONTROL_COLUMN_COUNT, "%d", count);
if (ret < 0) {
LOGE("unable to convert insert column count to string: %d", errno);
return DATACONTROL_ERROR_OUT_OF_MEMORY;
}
- const char *arg_list[2];
arg_list[0] = provider->data_id;
arg_list[1] = insert_column_count;
int datacontrol_sql_delete(datacontrol_h provider, const char *where, int *request_id)
{
+ const char *arg_list[2];
+ int reqId;
+ int ret;
+ bundle *b;
if (provider == NULL || provider->provider_id == NULL || provider->data_id == NULL) {
LOGE("Invalid parameter");
return DATACONTROL_ERROR_INVALID_PARAMETER;
}
- bundle *b = bundle_create();
+ b = bundle_create();
if (!b) {
LOGE("unable to create bundle: %d", errno);
return DATACONTROL_ERROR_OUT_OF_MEMORY;
bundle_add_str(b, OSP_K_DATACONTROL_PROVIDER, provider->provider_id);
bundle_add_str(b, OSP_K_DATACONTROL_DATA, provider->data_id);
- const char *arg_list[2];
arg_list[0] = provider->data_id;
if (where)
bundle_add_str_array(b, OSP_K_ARG, arg_list, 2);
/* Set the request id */
- int reqId = _datacontrol_create_request_id();
+ reqId = _datacontrol_create_request_id();
*request_id = reqId;
- int ret = __sql_request_provider(provider, DATACONTROL_TYPE_SQL_DELETE, b, NULL, reqId);
+ ret = __sql_request_provider(provider, DATACONTROL_TYPE_SQL_DELETE, b, NULL, reqId);
bundle_free(b);
return ret;
}
int datacontrol_sql_select(datacontrol_h provider, char **column_list, int column_count,
- const char *where, const char *order, int *request_id) {
+ const char *where, const char *order, int *request_id)
+{
return datacontrol_sql_select_with_page(provider, column_list, column_count, where, order, 1, 20, request_id);
}
int datacontrol_sql_select_with_page(datacontrol_h provider, char **column_list, int column_count,
- const char *where, const char *order, int page_number, int count_per_page, int *request_id) {
+ const char *where, const char *order, int page_number, int count_per_page, int *request_id)
+{
+ int total_arg_count = -1;
+ int ret = 0;
+ bundle *b;
+ char page[32] = {0, };
+ char count_per_page_no[32] = {0, };
+ const char **arg_list;
+ int i;
+ char select_column_count[MAX_LEN_DATACONTROL_COLUMN_COUNT] = {0, };
+ int select_col;
+ int reqId;
if (provider == NULL || provider->provider_id == NULL || provider->data_id == NULL) {
LOGE("Invalid parameter");
return DATACONTROL_ERROR_INVALID_PARAMETER;
}
- int total_arg_count = -1;
- int ret = 0;
-
- bundle *b = bundle_create();
+ b = bundle_create();
if (!b) {
LOGE("unable to create bundle: %d", errno);
return DATACONTROL_ERROR_OUT_OF_MEMORY;
bundle_add_str(b, OSP_K_DATACONTROL_PROVIDER, provider->provider_id);
bundle_add_str(b, OSP_K_DATACONTROL_DATA, provider->data_id);
- char page[32] = {0, };
ret = snprintf(page, 32, "%d", page_number);
if (ret < 0) {
LOGE("unable to convert page no to string: %d", errno);
return DATACONTROL_ERROR_OUT_OF_MEMORY;
}
- char count_per_page_no[32] = {0, };
ret = snprintf(count_per_page_no, 32, "%d", count_per_page);
if (ret < 0) {
LOGE("unable to convert count per page no to string: %d", errno);
}
total_arg_count = column_count + DATACONTROL_SELECT_EXTRA_COUNT;
- const char **arg_list = (const char **)malloc(total_arg_count * (sizeof(char *)));
+ arg_list = (const char **)malloc(total_arg_count * (sizeof(char *)));
LOGI("total arg count %d", total_arg_count);
arg_list[0] = provider->data_id; /* arg[0]: data ID */
- int i = 1;
+ i = 1;
if (column_list) {
- char select_column_count[MAX_LEN_DATACONTROL_COLUMN_COUNT] = {0, };
ret = snprintf(select_column_count, MAX_LEN_DATACONTROL_COLUMN_COUNT, "%d", column_count);
if (ret < 0) {
LOGE("unable to convert select col count to string: %d", errno);
arg_list[i] = select_column_count; /* arg[1]: selected column count */
++i;
- int select_col = 0;
+ select_col = 0;
while (select_col < column_count)
arg_list[i++] = column_list[select_col++];
-
}
if (where) /* arg: where clause */
bundle_add_str_array(b, OSP_K_ARG, arg_list, total_arg_count);
free(arg_list);
- int reqId = _datacontrol_create_request_id();
+ reqId = _datacontrol_create_request_id();
*request_id = reqId;
ret = __sql_request_provider(provider, DATACONTROL_TYPE_SQL_SELECT, b, NULL, reqId);
return ret;
}
-
int datacontrol_sql_update(datacontrol_h provider, const bundle *update_data, const char *where, int *request_id)
{
+ int ret = 0;
+ long long arg_size = 0;
+ bundle *b;
+ char update_column_count[MAX_LEN_DATACONTROL_COLUMN_COUNT] = {0, };
+ int count;
+ const char *arg_list[4];
if (provider == NULL || provider->provider_id == NULL || provider->data_id == NULL || update_data == NULL || where == NULL) {
LOGE("Invalid parameter");
return DATACONTROL_ERROR_INVALID_PARAMETER;
}
- int ret = 0;
-
/* Check size of arguments */
- long long arg_size = 0;
bundle_foreach((bundle *)update_data, bundle_foreach_check_arg_size_cb, &arg_size);
arg_size += strlen(provider->data_id) * sizeof(wchar_t);
if (arg_size > MAX_REQUEST_ARGUMENT_SIZE) {
return DATACONTROL_ERROR_MAX_EXCEEDED;
}
- bundle *b = bundle_create();
+ b = bundle_create();
if (!b) {
LOGE("unable to create bundle: %d", errno);
return DATACONTROL_ERROR_OUT_OF_MEMORY;
bundle_add_str(b, OSP_K_DATACONTROL_PROVIDER, provider->provider_id);
bundle_add_str(b, OSP_K_DATACONTROL_DATA, provider->data_id);
- char update_column_count[MAX_LEN_DATACONTROL_COLUMN_COUNT] = {0, };
- int count = bundle_get_count((bundle *)update_data);
ret = snprintf(update_column_count, MAX_LEN_DATACONTROL_COLUMN_COUNT, "%d", count);
if (ret < 0) {
LOGE("unable to convert update col count to string: %d", errno);
return DATACONTROL_ERROR_OUT_OF_MEMORY;
}
- const char *arg_list[4];
arg_list[0] = provider->data_id; /* list(0): data ID */
arg_list[1] = update_column_count;
arg_list[2] = where;
bundle_free(b);
return ret;
}
+
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include <dlog.h>
#include <bundle.h>
#include <errno.h>
datacontrol_map_response_cb datacontrol_map_cb;
-void
-__map_get_response(int request_id, datacontrol_h provider,
+static void __map_get_response(int request_id, datacontrol_h provider,
char **result_value_list, int result_value_count, bool provider_result, const char *error, void *user_data)
{
_LOGI("map_get_response");
- data_control_map_response_cb *callback = (data_control_map_response_cb*)g_hash_table_lookup(response_table, provider->provider_id);
+ data_control_map_response_cb *callback = (data_control_map_response_cb *)g_hash_table_lookup(response_table, provider->provider_id);
if (callback)
callback->get_cb(request_id, (data_control_h)provider, result_value_list, result_value_count, provider_result, error, user_data);
}
-void
-__map_set_response(int request_id, datacontrol_h provider, bool provider_result, const char *error, void *user_data)
+static void __map_set_response(int request_id, datacontrol_h provider, bool provider_result, const char *error, void *user_data)
{
_LOGI("map_set_response");
- data_control_map_response_cb *callback = (data_control_map_response_cb*)g_hash_table_lookup(response_table, provider->provider_id);
+ data_control_map_response_cb *callback = (data_control_map_response_cb *)g_hash_table_lookup(response_table, provider->provider_id);
if (callback)
callback->set_cb(request_id, (data_control_h)provider, provider_result, error, user_data);
}
-void
-__map_add_response(int request_id, datacontrol_h provider, bool provider_result, const char *error, void *user_data)
+static void __map_add_response(int request_id, datacontrol_h provider, bool provider_result, const char *error, void *user_data)
{
_LOGI("map_add_response");
- data_control_map_response_cb *callback = (data_control_map_response_cb*)g_hash_table_lookup(response_table, provider->provider_id);
+ data_control_map_response_cb *callback = (data_control_map_response_cb *)g_hash_table_lookup(response_table, provider->provider_id);
if (callback)
callback->add_cb(request_id, (data_control_h)provider, provider_result, error, user_data);
}
-void
-__map_remove_response(int request_id, datacontrol_h provider, bool provider_result, const char *error, void *user_data)
+static void __map_remove_response(int request_id, datacontrol_h provider, bool provider_result, const char *error, void *user_data)
{
_LOGI("map_remove_response");
- data_control_map_response_cb *callback = (data_control_map_response_cb*)g_hash_table_lookup(response_table, provider->provider_id);
+ data_control_map_response_cb *callback = (data_control_map_response_cb *)g_hash_table_lookup(response_table, provider->provider_id);
if (callback)
callback->remove_cb(request_id, (data_control_h)provider, provider_result, error, user_data);
}
-static void
-__free_data(gpointer data)
+static void __free_data(gpointer data)
{
if (data) {
g_free(data);
}
}
-static void
-__initialize(void)
+static void __initialize(void)
{
response_table = g_hash_table_new_full(g_str_hash, g_str_equal, __free_data, __free_data);
datacontrol_map_cb.remove = __map_remove_response;
}
-EXPORT_API int
-data_control_map_create(data_control_h *provider)
+EXPORT_API int data_control_map_create(data_control_h *provider)
{
- return convert_to_tizen_error(datacontrol_map_create((datacontrol_h*)provider));
+ return convert_to_tizen_error(datacontrol_map_create((datacontrol_h *)provider));
}
-EXPORT_API int
-data_control_map_destroy(data_control_h provider)
+EXPORT_API int data_control_map_destroy(data_control_h provider)
{
return convert_to_tizen_error(datacontrol_map_destroy((datacontrol_h)provider));
}
-EXPORT_API int
-data_control_map_set_provider_id(data_control_h provider, const char *provider_id)
+EXPORT_API int data_control_map_set_provider_id(data_control_h provider, const char *provider_id)
{
return convert_to_tizen_error(datacontrol_map_set_provider_id((datacontrol_h)provider, provider_id));
}
-EXPORT_API int
-data_control_map_get_provider_id(data_control_h provider, char **provider_id)
+EXPORT_API int data_control_map_get_provider_id(data_control_h provider, char **provider_id)
{
return convert_to_tizen_error(datacontrol_map_get_provider_id((datacontrol_h)provider, provider_id));
}
-EXPORT_API int
-data_control_map_set_data_id(data_control_h provider, const char *data_id)
+EXPORT_API int data_control_map_set_data_id(data_control_h provider, const char *data_id)
{
return convert_to_tizen_error(datacontrol_map_set_data_id((datacontrol_h)provider, data_id));
}
-EXPORT_API int
-data_control_map_get_data_id(data_control_h provider, char **data_id)
+EXPORT_API int data_control_map_get_data_id(data_control_h provider, char **data_id)
{
return convert_to_tizen_error(datacontrol_map_get_data_id((datacontrol_h)provider, data_id));
}
-EXPORT_API int
-data_control_map_register_response_cb(data_control_h provider, data_control_map_response_cb* callback, void *user_data)
+EXPORT_API int data_control_map_register_response_cb(data_control_h provider, data_control_map_response_cb *callback, void *user_data)
{
+ data_control_map_response_cb *cb;
+ char *id;
if (response_table == NULL)
__initialize();
if (callback == NULL)
return DATA_CONTROL_ERROR_INVALID_PARAMETER;
- char *id = strdup(provider->provider_id);
+ id = strdup(provider->provider_id);
if (id == NULL)
return DATA_CONTROL_ERROR_OUT_OF_MEMORY;
- data_control_map_response_cb *cb
- = (data_control_map_response_cb *)malloc(sizeof(data_control_map_response_cb));
+ cb = (data_control_map_response_cb *)malloc(sizeof(data_control_map_response_cb));
if (cb == NULL) {
free(id);
return DATA_CONTROL_ERROR_OUT_OF_MEMORY;
return convert_to_tizen_error(datacontrol_map_register_response_cb((datacontrol_h)provider, &datacontrol_map_cb, user_data));
}
-EXPORT_API int
-data_control_map_unregister_response_cb(data_control_h provider)
+EXPORT_API int data_control_map_unregister_response_cb(data_control_h provider)
{
if (provider->provider_id)
g_hash_table_remove(response_table, provider->provider_id);
return convert_to_tizen_error(datacontrol_map_unregister_response_cb((datacontrol_h)provider));
}
-EXPORT_API int
-data_control_map_get(data_control_h provider, const char *key, int *request_id)
+EXPORT_API int data_control_map_get(data_control_h provider, const char *key, int *request_id)
{
int retval = datacontrol_check_privilege(PRIVILEGE_CONSUMER);
if (retval != DATA_CONTROL_ERROR_NONE)
return convert_to_tizen_error(datacontrol_map_get((datacontrol_h)provider, key, request_id));
}
-EXPORT_API int
-data_control_map_get_with_page(data_control_h provider, const char *key, int *request_id, int page_number, int count_per_page)
+EXPORT_API int data_control_map_get_with_page(data_control_h provider, const char *key, int *request_id, int page_number, int count_per_page)
{
int retval = datacontrol_check_privilege(PRIVILEGE_CONSUMER);
if (retval != DATA_CONTROL_ERROR_NONE)
return convert_to_tizen_error(datacontrol_map_get_with_page((datacontrol_h)provider, key, request_id, page_number, count_per_page));
}
-EXPORT_API int
-data_control_map_set(data_control_h provider, const char *key, const char *old_value, const char *new_value, int *request_id)
+EXPORT_API int data_control_map_set(data_control_h provider, const char *key, const char *old_value, const char *new_value, int *request_id)
{
int retval = datacontrol_check_privilege(PRIVILEGE_CONSUMER);
if (retval != DATA_CONTROL_ERROR_NONE)
return convert_to_tizen_error(datacontrol_map_set((datacontrol_h)provider, key, old_value, new_value, request_id));
}
-EXPORT_API int
-data_control_map_add(data_control_h provider, const char *key, const char *value, int *request_id)
+EXPORT_API int data_control_map_add(data_control_h provider, const char *key, const char *value, int *request_id)
{
int retval = datacontrol_check_privilege(PRIVILEGE_CONSUMER);
if (retval != DATA_CONTROL_ERROR_NONE)
return convert_to_tizen_error(datacontrol_map_add((datacontrol_h)provider, key, value, request_id));
}
-EXPORT_API int
-data_control_map_remove(data_control_h provider, const char *key, const char *value, int *request_id)
+EXPORT_API int data_control_map_remove(data_control_h provider, const char *key, const char *value, int *request_id)
{
int retval = datacontrol_check_privilege(PRIVILEGE_CONSUMER);
if (retval != DATA_CONTROL_ERROR_NONE)
return convert_to_tizen_error(datacontrol_map_remove((datacontrol_h)provider, key, value, request_id));
}
+
-#include <stdlib.h>
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
#include <dlog.h>
#include <bundle.h>
-
#include <data-control-provider.h>
#include "data_control_provider.h"
datacontrol_provider_sql_cb sql_internal_callback;
datacontrol_provider_map_cb map_internal_callback;
-void __sql_insert_request_cb(int request_id, datacontrol_h provider, bundle *insert_data, void *user_data)
+static void __sql_insert_request_cb(int request_id, datacontrol_h provider, bundle *insert_data, void *user_data)
{
_LOGI("sql_insert_request");
sql_provider_callback.insert_cb(request_id, (data_control_h)provider, insert_data, user_data);
}
-void __sql_update_request_cb(int request_id, datacontrol_h provider, bundle *update_data, const char *where, void *user_data)
+static void __sql_update_request_cb(int request_id, datacontrol_h provider, bundle *update_data, const char *where, void *user_data)
{
_LOGI("sql_update_request");
sql_provider_callback.update_cb(request_id, (data_control_h)provider, update_data, where, user_data);
}
-void __sql_delete_request_cb(int request_id, datacontrol_h provider, const char *where, void *user_data)
+static void __sql_delete_request_cb(int request_id, datacontrol_h provider, const char *where, void *user_data)
{
_LOGI("sql_delete_request");
sql_provider_callback.delete_cb(request_id, (data_control_h)provider, where, user_data);
}
-void __sql_select_request_cb(int request_id, datacontrol_h provider, const char **column_list, int column_count, const char *where, const char *order, void *user_data)
+static void __sql_select_request_cb(int request_id, datacontrol_h provider, const char **column_list, int column_count, const char *where, const char *order, void *user_data)
{
_LOGI("sql_select_request");
sql_provider_callback.select_cb(request_id, (data_control_h)provider, column_list, column_count, where, order, user_data);
}
-void __map_get_request_cb(int request_id, datacontrol_h provider, const char *key, void *user_data)
+static void __map_get_request_cb(int request_id, datacontrol_h provider, const char *key, void *user_data)
{
_LOGI("map_get_request");
map_provider_callback.get_cb(request_id, (data_control_h)provider, key, user_data);
}
-void __map_set_request_cb(int request_id, datacontrol_h provider, const char *key, const char *old_value, const char *new_value, void *user_data)
+static void __map_set_request_cb(int request_id, datacontrol_h provider, const char *key, const char *old_value, const char *new_value, void *user_data)
{
_LOGI("map_set_request");
map_provider_callback.set_cb(request_id, (data_control_h)provider, key, old_value, new_value, user_data);
}
-void __map_add_request_cb(int request_id, datacontrol_h provider, const char *key, const char *value, void *user_data)
+static void __map_add_request_cb(int request_id, datacontrol_h provider, const char *key, const char *value, void *user_data)
{
_LOGI("map_add_request");
map_provider_callback.add_cb(request_id, (data_control_h)provider, key, value, user_data);
}
-void __map_remove_request_cb(int request_id, datacontrol_h provider, const char *key, const char *value, void *user_data)
+static void __map_remove_request_cb(int request_id, datacontrol_h provider, const char *key, const char *value, void *user_data)
{
_LOGI("map_remove_request");
EXPORT_API int data_control_provider_sql_register_cb(data_control_provider_sql_cb *callback, void *user_data)
{
-
int retval = datacontrol_check_privilege(PRIVILEGE_PROVIDER);
if (retval != DATA_CONTROL_ERROR_NONE)
return retval;
EXPORT_API int data_control_provider_map_register_cb(data_control_provider_map_cb *callback, void *user_data)
{
-
int retval = datacontrol_check_privilege(PRIVILEGE_PROVIDER);
if (retval != DATA_CONTROL_ERROR_NONE)
return retval;
static void bundle_foreach_cb(const char *key, const int type, const bundle_keyval_t *kv, void *user_data)
{
+ int index;
+ char *value = NULL;
+ size_t value_len = 0;
+
if (!key || !kv || !user_data)
return;
key_val_pair *pair = (key_val_pair *)user_data;
- int index = pair->no_of_elements;
+ index = pair->no_of_elements;
pair->keys[index] = strdup(key);
- char *value = NULL;
- size_t value_len = 0;
-
bundle_keyval_get_basic_val((bundle_keyval_t *)kv, (void **)&value, &value_len);
pair->vals[index] = strdup(value);
pair->length += strlen(key) + value_len;
EXPORT_API char *data_control_provider_create_insert_statement(data_control_h provider, bundle *insert_map)
{
+ int index;
+ char *data_id = NULL;
+ int sql_len;
+ char *sql;
int row_count = bundle_get_count(insert_map);
+
if (provider == NULL || row_count == 0) {
set_last_result(DATA_CONTROL_ERROR_INVALID_PARAMETER);
return NULL;
return NULL;
}
- int index = 0;
+ index = 0;
bundle_foreach(insert_map, bundle_foreach_cb, (void *)(cols));
- char* data_id = NULL;
data_control_sql_get_data_id(provider, &data_id);
- int sql_len = INSERT_STMT_CONST_LEN + strlen(data_id) + (row_count - 1) * 4 + (cols->length) + 1;
+ sql_len = INSERT_STMT_CONST_LEN + strlen(data_id) + (row_count - 1) * 4 + (cols->length) + 1;
_LOGI("SQL statement length: %d", sql_len);
- char* sql = (char *)calloc(sql_len, sizeof(char));
+ sql = (char *)calloc(sql_len, sizeof(char));
if (sql == NULL) {
free(data_id);
free(cols->keys);
EXPORT_API char *data_control_provider_create_delete_statement(data_control_h provider, const char *where)
{
char *data_id = NULL;
+ int cond_len;
+ int sql_len;
+ char *sql;
if (provider == NULL) {
set_last_result(DATA_CONTROL_ERROR_INVALID_PARAMETER);
data_control_sql_get_data_id(provider, &data_id);
- int cond_len = (where != NULL) ? (WHERE_COND_CONST_LEN + strlen(where)) : 0;
- int sql_len = DELETE_STMT_CONST_LEN + strlen(data_id) + cond_len + 1;
+ cond_len = (where != NULL) ? (WHERE_COND_CONST_LEN + strlen(where)) : 0;
+ sql_len = DELETE_STMT_CONST_LEN + strlen(data_id) + cond_len + 1;
_LOGI("SQL statement length: %d", sql_len);
- char *sql = (char *)calloc(sql_len, sizeof(char));
+ sql = (char *)calloc(sql_len, sizeof(char));
if (sql == NULL) {
free(data_id);
set_last_result(DATA_CONTROL_ERROR_OUT_OF_MEMORY);
EXPORT_API char *data_control_provider_create_update_statement(data_control_h provider, bundle *update_map, const char *where)
{
+ int index;
+ char *data_id = NULL;
+ int cond_len;
+ int sql_len;
+ char *sql;
int row_count = bundle_get_count(update_map);
+
if (provider == NULL || row_count == 0) {
set_last_result(DATA_CONTROL_ERROR_INVALID_PARAMETER);
return NULL;
cols->no_of_elements = 0;
cols->length = 0;
- cols->keys = (char **) calloc(row_count, sizeof(char *));
+ cols->keys = (char **)calloc(row_count, sizeof(char *));
if (cols->keys == NULL) {
free(cols);
set_last_result(DATA_CONTROL_ERROR_OUT_OF_MEMORY);
return NULL;
}
- cols->vals = (char **) calloc(row_count, sizeof(char *));
+ cols->vals = (char **)calloc(row_count, sizeof(char *));
if (cols->vals == NULL) {
free(cols->keys);
free(cols);
return NULL;
}
- int index = 0;
- bundle_foreach(update_map, bundle_foreach_cb, (void*)(cols));
+ index = 0;
+ bundle_foreach(update_map, bundle_foreach_cb, (void *)(cols));
- char *data_id = NULL;
data_control_sql_get_data_id(provider, &data_id);
- int cond_len = (where != NULL) ? (WHERE_COND_CONST_LEN + strlen(where)) : 0;
- int sql_len = UPDATE_STMT_CONST_LEN + strlen(data_id) + (cols->length) + (row_count - 1) * 5 + cond_len + 1;
+ cond_len = (where != NULL) ? (WHERE_COND_CONST_LEN + strlen(where)) : 0;
+ sql_len = UPDATE_STMT_CONST_LEN + strlen(data_id) + (cols->length) + (row_count - 1) * 5 + cond_len + 1;
_LOGI("SQL statement length: %d", sql_len);
- char *sql = (char *) calloc(sql_len, sizeof(char));
+ sql = (char *) calloc(sql_len, sizeof(char));
if (sql == NULL) {
free(data_id);
free(cols->keys);
{
int index = 0;
int col_name_length = 0;
+ char *data_id = NULL;
+ int cond_len;
+ int order_len;
+ int sql_len;
+ char *sql;
+
if (provider == NULL) {
set_last_result(DATA_CONTROL_ERROR_INVALID_PARAMETER);
return NULL;
col_name_length = 1;
}
- char *data_id = NULL;
data_control_sql_get_data_id(provider, &data_id);
- int cond_len = (where != NULL) ? (WHERE_COND_CONST_LEN + strlen(where)) : 0;
- int order_len = (order != NULL) ? (ORDER_CLS_CONST_LEN + strlen(order)) : 0;
- int sql_len = SELECT_STMT_CONST_LEN + col_name_length + strlen(data_id) + cond_len + order_len + 1;
+ cond_len = (where != NULL) ? (WHERE_COND_CONST_LEN + strlen(where)) : 0;
+ order_len = (order != NULL) ? (ORDER_CLS_CONST_LEN + strlen(order)) : 0;
+ sql_len = SELECT_STMT_CONST_LEN + col_name_length + strlen(data_id) + cond_len + order_len + 1;
_LOGI("SQL statement length: %d", sql_len);
- char *sql = (char *) calloc(sql_len, sizeof(char));
+ sql = (char *) calloc(sql_len, sizeof(char));
if (sql == NULL) {
free(data_id);
set_last_result(DATA_CONTROL_ERROR_OUT_OF_MEMORY);
{
int ret = DATA_CONTROL_ERROR_NONE;
char *prov_id = NULL;
+
if (provider == NULL || provider_id == NULL) {
set_last_result(DATA_CONTROL_ERROR_INVALID_PARAMETER);
return false;
{
int ret = DATA_CONTROL_ERROR_NONE;
char *data = NULL;
+
if (provider == NULL || data_id == NULL) {
set_last_result(DATA_CONTROL_ERROR_INVALID_PARAMETER);
return false;
}
}
-EXPORT_API int
-data_control_provider_send_map_result(int request_id)
+EXPORT_API int data_control_provider_send_map_result(int request_id)
{
return datacontrol_provider_send_map_result(request_id);
}
-EXPORT_API int
-data_control_provider_send_map_get_value_result(int request_id, char **value_list, int value_count)
+EXPORT_API int data_control_provider_send_map_get_value_result(int request_id, char **value_list, int value_count)
{
return datacontrol_provider_send_map_get_value_result(request_id, value_list, value_count);
}
+
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
#include <dlog.h>
#include <bundle.h>
#include <errno.h>
char *data_id;
};
-
static GHashTable *response_table = NULL;
datacontrol_sql_response_cb datacontrol_sql_cb;
-void
-__sql_insert_response(int req_id, datacontrol_h provider, long long insert_rowid, bool provider_result, const char *error, void *user_data)
+static void __sql_insert_response(int req_id, datacontrol_h provider, long long insert_rowid, bool provider_result, const char *error, void *user_data)
{
_LOGI("sql_insert_response");
- data_control_sql_response_cb *callback = (data_control_sql_response_cb*)g_hash_table_lookup(response_table, provider->provider_id);
+ data_control_sql_response_cb *callback = (data_control_sql_response_cb *)g_hash_table_lookup(response_table, provider->provider_id);
if (callback)
callback->insert_cb(req_id, (data_control_h)provider, insert_rowid, provider_result, error, user_data);
}
-void
-__sql_update_response(int req_id, datacontrol_h provider, bool provider_result, const char *error, void *user_data)
+static void __sql_update_response(int req_id, datacontrol_h provider, bool provider_result, const char *error, void *user_data)
{
_LOGI("sql_update_response");
- data_control_sql_response_cb *callback = (data_control_sql_response_cb*)g_hash_table_lookup(response_table, provider->provider_id);
+ data_control_sql_response_cb *callback = (data_control_sql_response_cb *)g_hash_table_lookup(response_table, provider->provider_id);
if (callback)
callback->update_cb(req_id, (data_control_h)provider, provider_result, error, user_data);
}
-void
-__sql_delete_response(int req_id, datacontrol_h provider, bool provider_result, const char *error, void *user_data)
+static void __sql_delete_response(int req_id, datacontrol_h provider, bool provider_result, const char *error, void *user_data)
{
_LOGI("sql_delete_response");
- data_control_sql_response_cb *callback = (data_control_sql_response_cb*)g_hash_table_lookup(response_table, provider->provider_id);
+ data_control_sql_response_cb *callback = (data_control_sql_response_cb *)g_hash_table_lookup(response_table, provider->provider_id);
if (callback)
callback->delete_cb(req_id, (data_control_h)provider, provider_result, error, user_data);
}
-void
-__sql_select_response(int req_id, datacontrol_h provider, resultset_cursor* enumerator, bool provider_result, const char *error, void *user_data)
+static void __sql_select_response(int req_id, datacontrol_h provider, resultset_cursor *enumerator, bool provider_result, const char *error, void *user_data)
{
_LOGI("sql_select_response");
- data_control_sql_response_cb *callback = (data_control_sql_response_cb*)g_hash_table_lookup(response_table, provider->provider_id);
+ data_control_sql_response_cb *callback = (data_control_sql_response_cb *)g_hash_table_lookup(response_table, provider->provider_id);
if (callback)
callback->select_cb(req_id, (data_control_h)provider, (result_set_cursor)enumerator, provider_result, error, user_data);
}
-static void
-__free_data(gpointer data)
+static void __free_data(gpointer data)
{
if (data) {
g_free(data);
}
}
-static void
-__initialize(void)
+static void __initialize(void)
{
response_table = g_hash_table_new_full(g_str_hash, g_str_equal, __free_data, __free_data);
datacontrol_sql_cb.update = __sql_update_response;
}
-EXPORT_API int
-data_control_sql_create(data_control_h *provider)
+EXPORT_API int data_control_sql_create(data_control_h *provider)
{
- return datacontrol_sql_create((datacontrol_h*)provider);
+ return datacontrol_sql_create((datacontrol_h *)provider);
}
-EXPORT_API int
-data_control_sql_destroy(data_control_h provider)
+EXPORT_API int data_control_sql_destroy(data_control_h provider)
{
return datacontrol_sql_destroy((datacontrol_h)provider);
}
-EXPORT_API int
-data_control_sql_set_provider_id(data_control_h provider, const char *provider_id)
+EXPORT_API int data_control_sql_set_provider_id(data_control_h provider, const char *provider_id)
{
return datacontrol_sql_set_provider_id((datacontrol_h)provider, provider_id);
}
-EXPORT_API int
-data_control_sql_get_provider_id(data_control_h provider, char **provider_id)
+EXPORT_API int data_control_sql_get_provider_id(data_control_h provider, char **provider_id)
{
return datacontrol_sql_get_provider_id((datacontrol_h)provider, provider_id);
}
-EXPORT_API int
-data_control_sql_set_data_id(data_control_h provider, const char *data_id)
+EXPORT_API int data_control_sql_set_data_id(data_control_h provider, const char *data_id)
{
return datacontrol_sql_set_data_id((datacontrol_h)provider, data_id);
}
-EXPORT_API int
-data_control_sql_get_data_id(data_control_h provider, char **data_id)
+EXPORT_API int data_control_sql_get_data_id(data_control_h provider, char **data_id)
{
return datacontrol_sql_get_data_id((datacontrol_h)provider, data_id);
}
-EXPORT_API int
-data_control_sql_register_response_cb(data_control_h provider, data_control_sql_response_cb* callback, void *user_data)
+EXPORT_API int data_control_sql_register_response_cb(data_control_h provider, data_control_sql_response_cb *callback, void *user_data)
{
+ char *id;
+ data_control_sql_response_cb *cb;
+
if (response_table == NULL)
__initialize();
if (callback == NULL)
return DATA_CONTROL_ERROR_INVALID_PARAMETER;
- char *id = strdup(provider->provider_id);
+ id = strdup(provider->provider_id);
if (id == NULL)
return DATA_CONTROL_ERROR_OUT_OF_MEMORY;
- data_control_sql_response_cb *cb
- = (data_control_sql_response_cb *)malloc(sizeof(data_control_sql_response_cb));
+ cb = (data_control_sql_response_cb *)malloc(sizeof(data_control_sql_response_cb));
if (cb == NULL) {
free(id);
return DATA_CONTROL_ERROR_OUT_OF_MEMORY;
return datacontrol_sql_register_response_cb((datacontrol_h)provider, &datacontrol_sql_cb, user_data);
}
-EXPORT_API int
-data_control_sql_unregister_response_cb(data_control_h provider)
+EXPORT_API int data_control_sql_unregister_response_cb(data_control_h provider)
{
if (provider->provider_id)
g_hash_table_remove(response_table, provider->provider_id);
return datacontrol_sql_unregister_response_cb((datacontrol_h)provider);
}
-EXPORT_API int
-data_control_sql_insert(data_control_h provider, const bundle* insert_data, int *request_id)
+EXPORT_API int data_control_sql_insert(data_control_h provider, const bundle *insert_data, int *request_id)
{
int retval = datacontrol_check_privilege(PRIVILEGE_CONSUMER);
return datacontrol_sql_insert((datacontrol_h)provider, insert_data, request_id);
}
-EXPORT_API int
-data_control_sql_delete(data_control_h provider, const char *where, int *request_id)
+EXPORT_API int data_control_sql_delete(data_control_h provider, const char *where, int *request_id)
{
int retval = datacontrol_check_privilege(PRIVILEGE_CONSUMER);
if (retval != DATA_CONTROL_ERROR_NONE)
return datacontrol_sql_delete((datacontrol_h)provider, where, request_id);
}
-EXPORT_API int
-data_control_sql_select(data_control_h provider, char **column_list, int column_count, const char *where, const char *order, int *request_id)
+EXPORT_API int data_control_sql_select(data_control_h provider, char **column_list, int column_count, const char *where, const char *order, int *request_id)
{
int retval = datacontrol_check_privilege(PRIVILEGE_CONSUMER);
if (retval != DATA_CONTROL_ERROR_NONE)
return datacontrol_sql_select((datacontrol_h)provider, column_list, column_count, where, order, request_id);
}
-EXPORT_API 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)
+EXPORT_API 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)
{
int retval = datacontrol_check_privilege(PRIVILEGE_CONSUMER);
if (retval != DATA_CONTROL_ERROR_NONE)
}
-EXPORT_API int
-data_control_sql_update(data_control_h provider, const bundle* update_data, const char *where, int *request_id)
+EXPORT_API int data_control_sql_update(data_control_h provider, const bundle *update_data, const char *where, int *request_id)
{
-
int retval = datacontrol_check_privilege(PRIVILEGE_CONSUMER);
if (retval != DATA_CONTROL_ERROR_NONE)
return retval;
+/*
+ * Copyright (c) 2013 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include <dlog.h>
#include <data-control-sql-cursor.h>
int result_set_content_offset;
int result_set_current_offset;
int result_set_current_row_count;
- char* result_set_path;
+ char *result_set_path;
};
-EXPORT_API int
-data_control_sql_step_next(result_set_cursor cursor)
+EXPORT_API int data_control_sql_step_next(result_set_cursor cursor)
{
if (cursor == NULL)
return DATA_CONTROL_ERROR_INVALID_PARAMETER;
- return datacontrol_sql_step_next((resultset_cursor*)cursor);
+ return datacontrol_sql_step_next((resultset_cursor *)cursor);
}
-EXPORT_API int
-data_control_sql_step_last(result_set_cursor cursor)
+EXPORT_API int data_control_sql_step_last(result_set_cursor cursor)
{
if (cursor == NULL)
return DATA_CONTROL_ERROR_INVALID_PARAMETER;
- return datacontrol_sql_step_last((resultset_cursor*)cursor);
+ return datacontrol_sql_step_last((resultset_cursor *)cursor);
}
-
-EXPORT_API int
-data_control_sql_step_first(result_set_cursor cursor)
+EXPORT_API int data_control_sql_step_first(result_set_cursor cursor)
{
if (cursor == NULL)
return DATA_CONTROL_ERROR_INVALID_PARAMETER;
- return datacontrol_sql_step_first((resultset_cursor*)cursor);
+ return datacontrol_sql_step_first((resultset_cursor *)cursor);
}
-
-EXPORT_API int
-data_control_sql_step_previous(result_set_cursor cursor)
+EXPORT_API int data_control_sql_step_previous(result_set_cursor cursor)
{
if (cursor == NULL)
return DATA_CONTROL_ERROR_INVALID_PARAMETER;
- return datacontrol_sql_step_previous((resultset_cursor*)cursor);
+ return datacontrol_sql_step_previous((resultset_cursor *)cursor);
}
-
-EXPORT_API int
-data_control_sql_get_column_count(result_set_cursor cursor)
+EXPORT_API int data_control_sql_get_column_count(result_set_cursor cursor)
{
if (cursor == NULL)
return DATA_CONTROL_ERROR_INVALID_PARAMETER;
- return datacontrol_sql_get_column_count((resultset_cursor*)cursor);
+ return datacontrol_sql_get_column_count((resultset_cursor *)cursor);
}
-EXPORT_API int
-data_control_sql_get_column_name(result_set_cursor cursor, int column_index, char *name)
+EXPORT_API int data_control_sql_get_column_name(result_set_cursor cursor, int column_index, char *name)
{
if (cursor == NULL)
return DATA_CONTROL_ERROR_INVALID_PARAMETER;
- return datacontrol_sql_get_column_name((resultset_cursor*)cursor, column_index, name);
+ return datacontrol_sql_get_column_name((resultset_cursor *)cursor, column_index, name);
}
-
-EXPORT_API int
-data_control_sql_get_column_item_size(result_set_cursor cursor, int column_index)
+EXPORT_API int data_control_sql_get_column_item_size(result_set_cursor cursor, int column_index)
{
if (cursor == NULL)
return DATA_CONTROL_ERROR_INVALID_PARAMETER;
- return datacontrol_sql_get_column_item_size((resultset_cursor*)cursor, column_index);
+ return datacontrol_sql_get_column_item_size((resultset_cursor *)cursor, column_index);
}
-
-EXPORT_API int
-data_control_sql_get_column_item_type(result_set_cursor cursor, int column_index, data_control_sql_column_type_e* col_type)
+EXPORT_API int data_control_sql_get_column_item_type(result_set_cursor cursor, int column_index, data_control_sql_column_type_e *col_type)
{
if (cursor == NULL)
return DATA_CONTROL_ERROR_INVALID_PARAMETER;
- return datacontrol_sql_get_column_item_type((resultset_cursor*)cursor, column_index, (datacontrol_sql_column_type*)col_type);
+ return datacontrol_sql_get_column_item_type((resultset_cursor *)cursor, column_index, (datacontrol_sql_column_type *)col_type);
}
-
-EXPORT_API int
-data_control_sql_get_blob_data(result_set_cursor cursor, int column_index, void *buffer, int data_size)
+EXPORT_API int data_control_sql_get_blob_data(result_set_cursor cursor, int column_index, void *buffer, int data_size)
{
if (cursor == NULL)
return DATA_CONTROL_ERROR_INVALID_PARAMETER;
- return datacontrol_sql_get_blob_data((resultset_cursor*)cursor, column_index, buffer, data_size);
+ return datacontrol_sql_get_blob_data((resultset_cursor *)cursor, column_index, buffer, data_size);
}
-
-EXPORT_API int
-data_control_sql_get_int_data(result_set_cursor cursor, int column_index, int *data)
+EXPORT_API int data_control_sql_get_int_data(result_set_cursor cursor, int column_index, int *data)
{
if (cursor == NULL)
return DATA_CONTROL_ERROR_INVALID_PARAMETER;
- return datacontrol_sql_get_int_data((resultset_cursor*)cursor, column_index, data);
+ return datacontrol_sql_get_int_data((resultset_cursor *)cursor, column_index, data);
}
-
-EXPORT_API int
-data_control_sql_get_int64_data(result_set_cursor cursor, int column_index, long long *data)
+EXPORT_API int data_control_sql_get_int64_data(result_set_cursor cursor, int column_index, long long *data)
{
if (cursor == NULL)
return DATA_CONTROL_ERROR_INVALID_PARAMETER;
- return datacontrol_sql_get_int64_data((resultset_cursor*)cursor, column_index, data);
+ return datacontrol_sql_get_int64_data((resultset_cursor *)cursor, column_index, data);
}
-EXPORT_API int
-data_control_sql_get_double_data(result_set_cursor cursor, int column_index, double *data)
+EXPORT_API int data_control_sql_get_double_data(result_set_cursor cursor, int column_index, double *data)
{
if (cursor == NULL)
return DATA_CONTROL_ERROR_INVALID_PARAMETER;
- return datacontrol_sql_get_double_data((resultset_cursor*)cursor, column_index, data);
+ return datacontrol_sql_get_double_data((resultset_cursor *)cursor, column_index, data);
}
-
-EXPORT_API int
-data_control_sql_get_text_data(result_set_cursor cursor, int column_index, char *buffer)
+EXPORT_API int data_control_sql_get_text_data(result_set_cursor cursor, int column_index, char *buffer)
{
if (cursor == NULL)
return DATA_CONTROL_ERROR_INVALID_PARAMETER;
- return datacontrol_sql_get_text_data((resultset_cursor*)cursor, column_index, buffer);
+ return datacontrol_sql_get_text_data((resultset_cursor *)cursor, column_index, buffer);
}