Adjust coding rules 97/63797/2 accepted/tizen/common/20160406.143404 accepted/tizen/ivi/20160406.012025 accepted/tizen/mobile/20160406.011853 accepted/tizen/tv/20160406.011944 accepted/tizen/wearable/20160406.012005 submit/tizen/20160405.001024
authorHwankyu Jhun <h.jhun@samsung.com>
Sun, 27 Mar 2016 23:52:00 +0000 (08:52 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 31 Mar 2016 00:50:00 +0000 (09:50 +0900)
Change-Id: I237548594b6fe4e229f70d585aa48424579ee1a9
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
26 files changed:
doc/data_control_doc.h
include/data-control-map.h
include/data-control-provider.h
include/data-control-sql-cursor.h
include/data-control-sql.h
include/data-control-types.h
include/data-control.h
include/data_control.h
include/data_control_internal.h
include/data_control_map.h
include/data_control_provider.h
include/data_control_sql.h
include/data_control_sql_cursor.h
include/data_control_types.h
src/data-control-internal.c
src/data-control-internal.h
src/data-control-map.c
src/data-control-provider.c
src/data-control-sql-cursor.c
src/data-control-sql.c
src/data_control_internal.c
src/data_control_log.h
src/data_control_map.c
src/data_control_provider.c
src/data_control_sql.c
src/data_control_sql_cursor.c

index 09b446d3dc7570f70e8c58306fe2a7df0832492a..025783105501d8c93ff1187c275b01f541188b4e 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * 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.
index 85b2075d2405158ceaa79423585c5c68455c2b18..d5c8e066334d24b864938793db76925a4b743f78 100644 (file)
@@ -1,18 +1,18 @@
-//
-// 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
@@ -42,7 +42,7 @@ extern "C" {
  * @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.
@@ -91,8 +91,7 @@ typedef void (*datacontrol_map_remove_response_cb)(int request_id, datacontrol_h
  * @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;
@@ -117,7 +116,7 @@ typedef struct
  *             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) {
@@ -222,7 +221,7 @@ EXPORT_API int datacontrol_map_get_data_id(datacontrol_h provider, char **data_i
  * @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_cbcallback, 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.
index 4d0ddc4912b2548cf0bdfd5b105ed988e731d710..957627d3924a92be90131e9976b88daccbbac312 100644 (file)
@@ -1,18 +1,18 @@
-//
-// 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
@@ -31,116 +31,115 @@ extern "C" {
 
 
 /**
- * @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;
@@ -148,15 +147,14 @@ typedef struct
 } 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;
@@ -164,11 +162,11 @@ typedef struct
 } 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
  */
@@ -181,37 +179,37 @@ EXPORT_API int datacontrol_provider_sql_register_cb(datacontrol_provider_sql_cb
 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
@@ -219,10 +217,10 @@ EXPORT_API int datacontrol_provider_get_client_appid(int request_id, char **appi
 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
@@ -230,9 +228,9 @@ EXPORT_API int datacontrol_provider_send_select_result(int request_id, void *db_
 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
@@ -240,9 +238,9 @@ EXPORT_API int datacontrol_provider_send_insert_result(int request_id, long long
 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
@@ -250,10 +248,10 @@ EXPORT_API int datacontrol_provider_send_update_result(int request_id);
 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
@@ -261,9 +259,9 @@ EXPORT_API int datacontrol_provider_send_delete_result(int request_id);
 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
@@ -271,11 +269,11 @@ EXPORT_API int datacontrol_provider_send_error(int request_id, const char *error
 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
index 0c022dd4367546b2dd82744f7516401d6c026865..42bf058ad9c287006cd900bdedd9b55691e53864 100644 (file)
@@ -1,18 +1,18 @@
-//
-// 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
@@ -33,8 +33,7 @@ extern "C" {
 /**
  * @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;
@@ -53,7 +52,7 @@ typedef struct
  * @param [in] path            The path of the file containing the SQL result set
  * @return             A pointer to struct @c resultset_cursor
  */
-resultset_cursordatacontrol_sql_get_cursor();
+resultset_cursor *datacontrol_sql_get_cursor();
 
 /**
  * @brief              Moves the cursor to the first position
@@ -140,17 +139,17 @@ EXPORT_API int datacontrol_sql_step_last(resultset_cursor *cursor);
 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
@@ -158,48 +157,48 @@ EXPORT_API int datacontrol_sql_step_previous(resultset_cursor *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
@@ -208,12 +207,12 @@ EXPORT_API int datacontrol_sql_get_column_item_type(resultset_cursor *cursor, in
 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
@@ -221,12 +220,12 @@ EXPORT_API int datacontrol_sql_get_blob_data(resultset_cursor *cursor, int colum
 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
@@ -234,12 +233,12 @@ EXPORT_API int datacontrol_sql_get_int_data(resultset_cursor *cursor, int column
 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
@@ -247,12 +246,12 @@ EXPORT_API int datacontrol_sql_get_int64_data(resultset_cursor *cursor, int colu
 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
@@ -261,10 +260,10 @@ EXPORT_API int datacontrol_sql_get_double_data(resultset_cursor *cursor, int col
 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
  */
index bc9d691e35ec93ef9450cdc5fdab993ff569e3bc..f260ab11f9acfb660cf8821604224ed310fa542b 100644 (file)
@@ -1,18 +1,18 @@
-//
-// 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
@@ -91,8 +91,7 @@ typedef void (*datacontrol_sql_update_response_cb)(int request_id, datacontrol_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;
@@ -117,7 +116,7 @@ typedef struct
  *             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) {
@@ -222,7 +221,7 @@ EXPORT_API int datacontrol_sql_get_data_id(datacontrol_h provider, char **data_i
  * @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_cbcallback, 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.
@@ -349,7 +348,7 @@ EXPORT_API int datacontrol_sql_delete(datacontrol_h provider, const char *where,
  *
  * @endcode
  */
-EXPORT_API int datacontrol_sql_insert(datacontrol_h provider, const bundleinsert_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
@@ -501,7 +500,7 @@ EXPORT_API int datacontrol_sql_select_with_page(datacontrol_h provider, char **c
  *
  * @endcode
  */
-EXPORT_API int datacontrol_sql_update(datacontrol_h provider, const bundleupdate_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
 }
index 4b8e1ea601c53766470c24806806bd6d2a74faba..a59e6239f4854d462c328179b7c704049108d35d 100644 (file)
@@ -1,18 +1,18 @@
-//
-// 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
@@ -40,8 +40,7 @@ typedef struct datacontrol_s *datacontrol_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,
@@ -53,8 +52,7 @@ typedef enum
 /**
  * @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 */
index e1b84c003c71b9295f6e03e2a13f3402928fc96a..f0eb75fab76ab56d6df1fc2c9f2d779a29035847 100644 (file)
@@ -1,18 +1,18 @@
-//
-// 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
index 94f07d690fbd7ba9e492abffdab87ac348fb3598..68769f6a33c3f0af81ac5329b58c373783d10137 100644 (file)
@@ -1,18 +1,18 @@
-//
-// 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__
index 308dfe3635d3c4ab65ed8d0488813f09aad09aa8..107990d756bd2849923af743eba171298aa82c8f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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.
@@ -39,3 +39,4 @@ int datacontrol_check_privilege(privilege_type check_type);
 #endif
 
 #endif /*  __TIZEN_APPFW_DATA_CONTROL_INTERNAL_H__ */
+
index d6e7c9b59e64bc1c07fc370832ea4df9f07c39b8..97d6433f2be2b5793e588c1c34c278ceb7bec3e6 100644 (file)
@@ -1,18 +1,18 @@
-//
-// 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__
@@ -57,8 +57,10 @@ extern "C" {
  * @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.
@@ -71,8 +73,9 @@ typedef void (*data_control_map_get_response_cb)(int request_id, data_control_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_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.
@@ -85,8 +88,9 @@ typedef void (*data_control_map_set_response_cb)(int request_id, data_control_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_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.
@@ -99,8 +103,9 @@ typedef void (*data_control_map_add_response_cb)(int request_id, data_control_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_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
@@ -112,12 +117,11 @@ typedef void (*data_control_map_remove_response_cb)(int request_id, data_control
  * @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;
 
 /**
@@ -289,7 +293,7 @@ int data_control_map_get_data_id(data_control_h provider, char **data_id);
  *
  * @see        data_control_map_unregister_response_cb()
  */
-int data_control_map_register_response_cb(data_control_h provider, data_control_map_response_cbcallback, 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.
@@ -615,3 +619,4 @@ int data_control_map_remove(data_control_h provider, const char *key, const char
 #endif
 
 #endif /* __TIZEN_APPFW_DATA_CONTROL_MAP_H__ */
+
index 2690c9741d4bb962dac0235ef9618179345c2466..ccfdf482e639bc12a74076a6a7b15d16c5f33571 100644 (file)
@@ -1,18 +1,18 @@
-//
-// 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_
@@ -45,8 +45,8 @@ extern "C" {
  *                          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.
@@ -60,8 +60,9 @@ typedef void (*data_control_provider_sql_insert_request_cb)(int request_id, data
  *                          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.
@@ -73,8 +74,8 @@ typedef void (*data_control_provider_sql_update_request_cb)(int request_id, data
  *                         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.
@@ -90,8 +91,10 @@ typedef void (*data_control_provider_sql_delete_request_cb)(int request_id, data
  *                           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.
@@ -102,7 +105,8 @@ typedef void (*data_control_provider_sql_select_request_cb)(int request_id, data
  * @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.
@@ -115,8 +119,9 @@ typedef void (*data_control_provider_map_get_value_request_cb)(int request_id, d
  * @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.
@@ -128,8 +133,9 @@ typedef void (*data_control_provider_map_set_value_request_cb)(int request_id, d
  * @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.
@@ -141,8 +147,9 @@ typedef void (*data_control_provider_map_add_value_request_cb)(int request_id, d
  * @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
@@ -154,12 +161,11 @@ typedef void (*data_control_provider_map_remove_value_request_cb)(int request_id
  * @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;
 
 /**
@@ -172,12 +178,11 @@ typedef struct
  * @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;
 
 /**
@@ -376,7 +381,7 @@ int data_control_provider_send_map_get_value_result(int request_id, char **value
  * @exception DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
  * @exception DATA_CONTROL_ERROR_INVALID_PARAMETER     Invalid parameter
  */
-chardata_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.
@@ -392,7 +397,7 @@ char* data_control_provider_create_insert_statement(data_control_h provider, bun
  * @exception DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
  * @exception DATA_CONTROL_ERROR_INVALID_PARAMETER     Invalid parameter
  */
-chardata_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.
@@ -408,7 +413,7 @@ char* data_control_provider_create_delete_statement(data_control_h provider, con
  * @exception DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
  * @exception DATA_CONTROL_ERROR_INVALID_PARAMETER     Invalid parameter
  */
-chardata_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.
@@ -427,7 +432,7 @@ char* data_control_provider_create_update_statement(data_control_h provider, bun
  * @exception DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
  * @exception DATA_CONTROL_ERROR_INVALID_PARAMETER     Invalid parameter
  */
-chardata_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.
index 9f1f4bda1dbe5443ac44ee5a6d2b2a45d48954d7..00cf733d7f8f8967b1d1f657828e14aa7d3c9620 100644 (file)
@@ -1,18 +1,19 @@
-//
-// 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__
@@ -47,8 +48,9 @@ extern "C" {
  * @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.
@@ -60,8 +62,9 @@ typedef void (*data_control_sql_insert_response_cb)(int request_id, 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.
@@ -77,8 +80,9 @@ typedef void (*data_control_sql_delete_response_cb)(int request_id, 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.
@@ -91,8 +95,9 @@ typedef void (*data_control_sql_select_response_cb)(int request_id, 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
@@ -104,12 +109,11 @@ typedef void (*data_control_sql_update_response_cb)(int request_id, data_control
  * @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;
 
 /**
@@ -282,7 +286,7 @@ int data_control_sql_get_data_id(data_control_h provider, char **data_id);
  *
  * @see  data_control_sql_unregister_response_cb()
  */
-int data_control_sql_register_response_cb(data_control_h provider, data_control_sql_response_cbcallback, 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.
@@ -430,7 +434,7 @@ int data_control_sql_delete(data_control_h provider, const char *where, int *req
  * @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 bundleinsert_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.
@@ -611,7 +615,7 @@ int data_control_sql_select_with_page(data_control_h provider, char **column_lis
  * @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 bundleupdate_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);
 
 /**
 * @}
index 60175b66228fce49a4f763b778a57a9f1caf8724..641b1c93f61271ab7a99d6071960d4af3e9ae8f4 100644 (file)
@@ -1,18 +1,19 @@
-//
-// 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_
@@ -211,7 +212,7 @@ int data_control_sql_get_column_item_size(result_set_cursor cursor, int column_i
  * @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_etype);
+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.
index dbeed3a42a35174cbca66dad3d5f785392daecd2..63545b85da7d8d9bb38e3210ce8da567f5bd7051 100644 (file)
@@ -1,18 +1,18 @@
-//
-// 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__
@@ -39,28 +39,26 @@ typedef struct data_control_s *data_control_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;
 
 /**
index 51b442396eb4ed40a3842e1130674493dd06bbc3..6caba2f6014c213b224e7cf789459b8c22715293 100755 (executable)
@@ -1,3 +1,19 @@
+/*
+ * 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>
@@ -41,14 +57,11 @@ int _consumer_request_compare_cb(gconstpointer a, gconstpointer b)
        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;
@@ -75,14 +88,11 @@ int _write_socket(int fd,
        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;
@@ -110,11 +120,14 @@ int _read_socket(int fd,
        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]);
@@ -125,7 +138,7 @@ char *_datacontrol_create_select_statement(char *data_id, const char **column_li
 
        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);
 
@@ -166,11 +179,13 @@ 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)
+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);
@@ -190,9 +205,8 @@ datacontrol_socket_info *_get_socket_info(const char *caller_id, const char *cal
                        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");
@@ -219,7 +233,6 @@ datacontrol_socket_info *_get_socket_info(const char *caller_id, const char *cal
 
 int _request_appsvc_run(const char *caller_id, const char *callee_id)
 {
-
        int pid = -1;
        int count = 0;
        const int TRY_COUNT = 4;
@@ -244,14 +257,11 @@ int _request_appsvc_run(const char *caller_id, const char *callee_id)
        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);
@@ -267,7 +277,7 @@ int _request_appsvc_run(const char *caller_id, const char *callee_id)
                LOGE("unable to launch service: %d", pid);
                return DATACONTROL_ERROR_IO_ERROR;
        }
-       return DATACONTROL_ERROR_NONE;
 
+       return DATACONTROL_ERROR_NONE;
 }
 
index 280d157a7d232d746c445c1aed807e204520ce21..a9be2ae694b7e89e92600720b5a9778465638c58 100755 (executable)
@@ -1,18 +1,18 @@
-//
-// 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
@@ -43,7 +43,7 @@
 #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"
@@ -57,8 +57,7 @@
 /**
  * @brief Enumerations of different type of data control requests.
  */
-typedef enum
-{
+typedef enum {
        DATACONTROL_TYPE_ERROR = -1,
        DATACONTROL_TYPE_UNDEFINED,
        DATACONTROL_TYPE_SQL_SELECT,
@@ -89,25 +88,27 @@ typedef struct datacontrol_consumer_request {
 } 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_ */
 
index cb1036add2f3b98fbf4321d2a3fd3acf87853221..f927fe6cf71e7b54c64712f85ae5cdffb0048a70 100755 (executable)
@@ -1,3 +1,19 @@
+/*
+ * 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>
@@ -60,9 +76,7 @@ static void __map_call_cb(const char *provider_id, int request_id, datacontrol_r
        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);
@@ -70,9 +84,7 @@ static void __map_call_cb(const char *provider_id, int request_id, datacontrol_r
                        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);
@@ -80,9 +92,7 @@ static void __map_call_cb(const char *provider_id, int request_id, datacontrol_r
                        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);
@@ -90,9 +100,7 @@ static void __map_call_cb(const char *provider_id, int request_id, datacontrol_r
                        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);
@@ -100,7 +108,6 @@ static void __map_call_cb(const char *provider_id, int request_id, datacontrol_r
                        LOGI("No registered callback function");
 
                break;
-       }
        default:
                break;
        }
@@ -136,6 +143,7 @@ static char **__map_get_value_list(int fd, int *value_count)
        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);
@@ -170,7 +178,6 @@ static char **__map_get_value_list(int fd, int *value_count)
 
 ERROR:
        if (value_list) {
-               int j;
                for (j = 0; j < i; j++) {
                        if (value_list[j] != NULL)
                                free(value_list[j]);
@@ -190,13 +197,10 @@ static void __remove_map_request_info(int request_id, map_response_cb_s *map_dc)
                        (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;
@@ -208,6 +212,8 @@ static int __map_handle_cb(int fd, bundle *b, int request_type, int request_id,
        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;
@@ -254,7 +260,6 @@ static int __map_handle_cb(int fd, bundle *b, int request_type, int request_id,
 
        switch (request_type) {
        case DATACONTROL_TYPE_MAP_GET:
-       {
                LOGI("GET RESPONSE");
                if (provider_result) {
                        value_list = __map_get_value_list(fd, &value_count);
@@ -265,14 +270,11 @@ static int __map_handle_cb(int fd, bundle *b, int request_type, int request_id,
                        }
                }
                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;
        }
@@ -281,17 +283,15 @@ static int __map_handle_cb(int fd, bundle *b, int request_type, int request_id,
                __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;
@@ -299,6 +299,8 @@ static int __datacontrol_send_map_async(int sockfd, bundle *kb, datacontrol_requ
        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");
@@ -328,7 +330,6 @@ static int __datacontrol_send_map_async(int sockfd, bundle *kb, datacontrol_requ
        return ret;
 }
 
-
 static gboolean __recv_map_message(GIOChannel *channel,
                GIOCondition cond,
                gpointer data)
@@ -342,6 +343,10 @@ static gboolean __recv_map_message(GIOChannel *channel,
        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" : "",
@@ -352,7 +357,6 @@ static gboolean __recv_map_message(GIOChannel *channel,
                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;
@@ -366,7 +370,6 @@ static gboolean __recv_map_message(GIOChannel *channel,
 
                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!!");
@@ -410,7 +413,6 @@ static gboolean __recv_map_message(GIOChannel *channel,
 
                                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;
@@ -431,13 +433,12 @@ 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);
@@ -453,11 +454,18 @@ error:
 
 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);
@@ -498,7 +506,6 @@ static int __map_request_provider(datacontrol_h provider, datacontrol_request_ty
        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);
@@ -518,7 +525,6 @@ static int __map_request_provider(datacontrol_h provider, datacontrol_request_ty
 
        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);
@@ -528,22 +534,16 @@ static int __map_request_provider(datacontrol_h provider, datacontrol_request_ty
        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)
@@ -564,11 +564,9 @@ static int __map_request_provider(datacontrol_h provider, datacontrol_request_ty
                        break;
                count++;
                nanosleep(&TRY_SLEEP_TIME, 0);
-
        } while (ret != DATACONTROL_ERROR_NONE && count < TRY_COUNT);
 
        return ret;
-
 }
 
 int datacontrol_map_create(datacontrol_h *provider)
@@ -631,8 +629,9 @@ int datacontrol_map_get_provider_id(datacontrol_h provider, char **provider_id)
                if (*provider_id == NULL)
                        return DATACONTROL_ERROR_OUT_OF_MEMORY;
 
-       } else
+       } else {
                *provider_id = NULL;
+       }
 
        return 0;
 }
@@ -662,8 +661,9 @@ int datacontrol_map_get_data_id(datacontrol_h provider, char **data_id)
                if (*data_id == NULL)
                        return DATACONTROL_ERROR_OUT_OF_MEMORY;
 
-       } else
+       } else {
                *data_id = NULL;
+       }
 
        return 0;
 }
@@ -673,6 +673,7 @@ int datacontrol_map_register_response_cb(datacontrol_h provider, datacontrol_map
        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) {
@@ -708,7 +709,6 @@ int datacontrol_map_register_response_cb(datacontrol_h provider, datacontrol_map
        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;
@@ -741,6 +741,7 @@ int datacontrol_map_unregister_response_cb(datacontrol_h provider)
 {
        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);
 
@@ -757,8 +758,6 @@ int datacontrol_map_unregister_response_cb(datacontrol_h provider)
                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");
@@ -784,6 +783,13 @@ int datacontrol_map_get(datacontrol_h provider, const char *key, int *request_id
 
 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;
@@ -791,13 +797,12 @@ int datacontrol_map_get_with_page(datacontrol_h provider, const char *key, int *
 
        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);
@@ -807,20 +812,17 @@ int datacontrol_map_get_with_page(datacontrol_h provider, const char *key, int *
        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);
@@ -833,7 +835,7 @@ int datacontrol_map_get_with_page(datacontrol_h provider, const char *key, int *
        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);
@@ -844,6 +846,12 @@ int datacontrol_map_get_with_page(datacontrol_h provider, const char *key, int *
 
 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;
@@ -851,13 +859,13 @@ int datacontrol_map_set(datacontrol_h provider, const char *key, const char *old
 
        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;
@@ -866,7 +874,6 @@ int datacontrol_map_set(datacontrol_h provider, const char *key, const char *old
        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;
@@ -875,10 +882,10 @@ int datacontrol_map_set(datacontrol_h provider, const char *key, const char *old
        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;
@@ -886,6 +893,12 @@ int datacontrol_map_set(datacontrol_h provider, const char *key, const char *old
 
 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;
@@ -893,13 +906,13 @@ int datacontrol_map_add(datacontrol_h provider, const char *key, const char *val
 
        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;
@@ -908,7 +921,6 @@ int datacontrol_map_add(datacontrol_h provider, const char *key, const char *val
        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;
@@ -916,10 +928,10 @@ int datacontrol_map_add(datacontrol_h provider, const char *key, const char *val
        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;
@@ -927,6 +939,12 @@ int datacontrol_map_add(datacontrol_h provider, const char *key, const char *val
 
 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;
@@ -934,13 +952,13 @@ int datacontrol_map_remove(datacontrol_h provider, const char *key, const char *
 
        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;
@@ -949,7 +967,6 @@ int datacontrol_map_remove(datacontrol_h provider, const char *key, const char *
        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;
@@ -957,11 +974,12 @@ int datacontrol_map_remove(datacontrol_h provider, const char *key, const char *
        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;
 }
+
index 5e3a80952c8eb6781a74d16f816bbec28c0b1fff..60c0f6c107d22af0790d318cae636c5d7c71fb69 100755 (executable)
@@ -1,3 +1,19 @@
+/*
+ * 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>
@@ -61,7 +77,7 @@ struct datacontrol_s {
 };
 
 
-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;
@@ -91,9 +107,6 @@ static int __provider_new_request_id(void)
 
 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
@@ -115,7 +128,19 @@ static int __send_select_result(int fd, bundle *b, void *data)
        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;
@@ -153,7 +178,7 @@ static int __send_select_result(int fd, bundle *b, void *data)
         #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;
@@ -168,7 +193,7 @@ static int __send_select_result(int fd, bundle *b, void *data)
                        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;
@@ -193,9 +218,8 @@ static int __send_select_result(int fd, bundle *b, void *data)
 
        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);
 
@@ -252,14 +276,8 @@ static int __send_select_result(int fd, bundle *b, void *data)
                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;
@@ -343,22 +361,21 @@ static int _get_int_from_str(const char *str)
 
 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);
@@ -368,7 +385,7 @@ static int __send_get_value_result(int fd, bundle *b, void *data)
        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);
 
@@ -380,7 +397,7 @@ static int __send_get_value_result(int fd, bundle *b, void *data)
        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);
@@ -398,8 +415,6 @@ static int __send_get_value_result(int fd, bundle *b, void *data)
 
 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;
@@ -407,6 +422,8 @@ int __datacontrol_send_async(int sockfd, bundle *kb, datacontrol_request_type ty
        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");
@@ -444,8 +461,10 @@ static bundle *__get_data_sql(int fd)
 {
        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)
@@ -454,7 +473,7 @@ static bundle *__get_data_sql(int fd)
        }
 
        if (len > 0) {
-               char *buf = (char *)calloc(len, sizeof(char));
+               buf = (char *)calloc(len, sizeof(char));
                if (buf == NULL) {
                        LOGE("calloc fail");
                        if (b)
@@ -474,22 +493,30 @@ static bundle *__get_data_sql(int fd)
 
                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);
 
@@ -500,31 +527,29 @@ static bundle *__set_result(bundle *b, datacontrol_request_type type, void *data
        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);
 
@@ -604,7 +629,6 @@ static bundle *__set_result(bundle *b, datacontrol_request_type type, void *data
 
 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;
@@ -823,8 +847,8 @@ err:
 
 gboolean __provider_recv_message(GIOChannel *channel,
                GIOCondition cond,
-               gpointer data) {
-
+               gpointer data)
+{
        char *buf = NULL;
        int data_len;
        guint nb;
@@ -842,7 +866,6 @@ gboolean __provider_recv_message(GIOChannel *channel,
                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;
@@ -898,12 +921,11 @@ 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)
@@ -988,16 +1010,19 @@ int datacontrol_provider_map_unregister_cb(void)
 
 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;
@@ -1012,19 +1037,23 @@ int datacontrol_provider_get_client_appid(int request_id, char **appid)
 
 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;
@@ -1032,64 +1061,74 @@ int datacontrol_provider_send_select_result(int request_id, void *db_handle)
 
 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;
@@ -1097,66 +1136,76 @@ int datacontrol_provider_send_delete_result(int request_id)
 
 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;
-
 }
+
index 82f4b758bb921a8a3fe7ea236876be4574f31488..fdd45162d8cd57ceb6330b00f44d64afdfbd112c 100755 (executable)
@@ -1,3 +1,20 @@
+/*
+ * 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>
@@ -35,9 +52,9 @@ int datacontrol_sql_step_next(resultset_cursor *cursor)
                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;
@@ -53,6 +70,8 @@ int datacontrol_sql_step_next(resultset_cursor *cursor)
 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 */
 
@@ -67,7 +86,6 @@ int datacontrol_sql_step_last(resultset_cursor *cursor)
                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 */
@@ -79,7 +97,6 @@ int datacontrol_sql_step_last(resultset_cursor *cursor)
        return DATACONTROL_ERROR_NONE;
 }
 
-
 int datacontrol_sql_step_first(resultset_cursor *cursor)
 {
        if (cursor->resultset_current_offset > 0) {
@@ -93,7 +110,6 @@ int datacontrol_sql_step_first(resultset_cursor *cursor)
        return datacontrol_sql_step_next(cursor);
 }
 
-
 int datacontrol_sql_step_previous(resultset_cursor *cursor)
 {
        if ((cursor->resultset_current_row_count - 1) < 0) {
@@ -106,7 +122,6 @@ int datacontrol_sql_step_previous(resultset_cursor *cursor)
        return DATACONTROL_ERROR_NONE;
 }
 
-
 int datacontrol_sql_get_column_count(resultset_cursor *cursor)
 {
        return cursor->resultset_col_count;
@@ -159,7 +174,6 @@ int datacontrol_sql_get_column_name(resultset_cursor *cursor, int column_index,
        return DATACONTROL_ERROR_NONE;
 }
 
-
 int datacontrol_sql_get_column_item_size(resultset_cursor *cursor, int column_index)
 {
        int type = -1;
@@ -212,7 +226,6 @@ int datacontrol_sql_get_column_item_size(resultset_cursor *cursor, int column_in
        return size;
 }
 
-
 int datacontrol_sql_get_column_item_type(resultset_cursor *cursor, int column_index,
                datacontrol_sql_column_type *col_type)
 {
@@ -260,23 +273,18 @@ int datacontrol_sql_get_column_item_type(resultset_cursor *cursor, int column_in
        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;
@@ -285,7 +293,6 @@ int datacontrol_sql_get_column_item_type(resultset_cursor *cursor, int column_in
        return DATACONTROL_ERROR_NONE;
 }
 
-
 int datacontrol_sql_get_blob_data(resultset_cursor *cursor, int column_index, void *buffer, int data_size)
 {
        int type = -1;
@@ -294,6 +301,7 @@ int datacontrol_sql_get_blob_data(resultset_cursor *cursor, int column_index, vo
        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) {
@@ -345,7 +353,7 @@ int datacontrol_sql_get_blob_data(resultset_cursor *cursor, int column_index, vo
        }
 
        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);
@@ -361,7 +369,6 @@ int datacontrol_sql_get_blob_data(resultset_cursor *cursor, int column_index, vo
        return DATACONTROL_ERROR_NONE;
 }
 
-
 int datacontrol_sql_get_int_data(resultset_cursor *cursor, int column_index, int *data)
 {
        long long long_value = 0;
@@ -374,7 +381,6 @@ int datacontrol_sql_get_int_data(resultset_cursor *cursor, int column_index, int
        return ret;
 }
 
-
 int datacontrol_sql_get_int64_data(resultset_cursor *cursor, int column_index, long long *data)
 {
        int type = -1;
@@ -508,6 +514,7 @@ int datacontrol_sql_get_text_data(resultset_cursor *cursor, int column_index, ch
        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) {
@@ -555,7 +562,7 @@ int datacontrol_sql_get_text_data(resultset_cursor *cursor, int column_index, ch
        }
 
        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;
@@ -576,12 +583,13 @@ int datacontrol_sql_get_text_data(resultset_cursor *cursor, int column_index, ch
        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);
 
@@ -594,3 +602,4 @@ int datacontrol_sql_remove_cursor(resultset_cursor *cursor)
 
        return DATACONTROL_ERROR_NONE;
 }
+
index 520519ae9c2c4eeb2796ea3e98a2b36e04c0ea4d..debdbb8b7bf329bd2d1cf8d1ceef152420aa3782 100755 (executable)
@@ -1,3 +1,20 @@
+/*
+ * 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>
@@ -43,16 +60,20 @@ typedef struct {
 
 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) {
@@ -60,15 +81,12 @@ static void __sql_call_cb(const char *provider_id, int request_id, datacontrol_r
                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);
@@ -76,9 +94,7 @@ static void __sql_call_cb(const char *provider_id, int request_id, datacontrol_r
                        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);
@@ -86,25 +102,20 @@ static void __sql_call_cb(const char *provider_id, int request_id, datacontrol_r
                        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;
        }
@@ -160,7 +171,6 @@ static int __sql_handle_cb(bundle *b, void *data, int fd, int request_id)
        const char *p = NULL;
 
        if (b) {
-
                /* result list */
                result_list = appsvc_get_data_array(b, OSP_K_ARG, &result_list_len);
                if (!result_list) {
@@ -209,9 +219,7 @@ static int __sql_handle_cb(bundle *b, void *data, int fd, int request_id)
                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) {
@@ -223,9 +231,7 @@ static int __sql_handle_cb(bundle *b, void *data, int fd, int request_id)
                                        return DATACONTROL_ERROR_IO_ERROR;
                        }
                        break;
-               }
                case DATACONTROL_TYPE_SQL_INSERT:
-               {
                        LOGI("INSERT RESPONSE");
                        if (provider_result) {
                                p = result_list[2]; /* result list[2] */
@@ -237,13 +243,10 @@ static int __sql_handle_cb(bundle *b, void *data, int fd, int request_id)
                                insert_rowid = atoll(p);
                        }
                        break;
-               }
                case DATACONTROL_TYPE_SQL_UPDATE:
                case DATACONTROL_TYPE_SQL_DELETE:
-               {
                        LOGI("UPDATE or DELETE RESPONSE");
                        break;
-               }
                default:
                        break;
                }
@@ -270,7 +273,6 @@ static int __sql_handle_cb(bundle *b, void *data, int fd, int request_id)
 
 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;
@@ -466,7 +468,7 @@ static int __recv_sql_select_process(bundle *kb, int fd, resultset_cursor *curso
                        }
 
                        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;
@@ -508,15 +510,21 @@ out:
 
        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" : "",
@@ -528,11 +536,6 @@ static gboolean __consumer_recv_sql_message(GIOChannel *channel,
                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);
@@ -542,7 +545,6 @@ static gboolean __consumer_recv_sql_message(GIOChannel *channel,
                        goto error;
                }
                if (data_len > 0) {
-                       bundle *kb = NULL;
                        buf = (char *)calloc(data_len + 1, sizeof(char));
                        if (buf == NULL) {
                                LOGE("Out of memory.");
@@ -591,12 +593,12 @@ error:
        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);
@@ -613,8 +615,6 @@ error:
 
 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;
@@ -624,6 +624,8 @@ int __datacontrol_send_sql_async(int sockfd, bundle *kb, bundle *extra_kb, datac
        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");
@@ -676,17 +678,26 @@ out:
 
 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;
@@ -697,7 +708,7 @@ static int __sql_request_provider(datacontrol_h provider, datacontrol_request_ty
                        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;
@@ -723,7 +734,6 @@ static int __sql_request_provider(datacontrol_h provider, datacontrol_request_ty
                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);
@@ -746,7 +756,6 @@ static int __sql_request_provider(datacontrol_h provider, datacontrol_request_ty
                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);
@@ -756,18 +765,12 @@ static int __sql_request_provider(datacontrol_h provider, datacontrol_request_ty
        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);
 
@@ -784,7 +787,7 @@ static int __sql_request_provider(datacontrol_h provider, datacontrol_request_ty
                                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;
@@ -804,7 +807,6 @@ static int __sql_request_provider(datacontrol_h provider, datacontrol_request_ty
        } while (ret != DATACONTROL_ERROR_NONE && count < TRY_COUNT);
 
        return ret;
-
 }
 
 int datacontrol_sql_create(datacontrol_h *provider)
@@ -867,8 +869,9 @@ int datacontrol_sql_get_provider_id(datacontrol_h provider, char **provider_id)
                if (*provider_id == NULL)
                        return DATACONTROL_ERROR_OUT_OF_MEMORY;
 
-       } else
+       } else {
                *provider_id = NULL;
+       }
 
        return 0;
 }
@@ -907,10 +910,11 @@ int datacontrol_sql_get_data_id(datacontrol_h provider, char **data_id)
 
 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) {
@@ -946,10 +950,9 @@ int datacontrol_sql_register_response_cb(datacontrol_h provider, datacontrol_sql
        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;
@@ -978,8 +981,9 @@ EXCEPTION:
 
 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);
@@ -999,7 +1003,6 @@ int datacontrol_sql_unregister_response_cb(datacontrol_h provider)
                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");
@@ -1015,12 +1018,11 @@ EXCEPTION:
        }
 
        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);
@@ -1031,6 +1033,13 @@ static void bundle_foreach_check_arg_size_cb(const char *key, const int type,
 
 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;
@@ -1038,10 +1047,7 @@ int datacontrol_sql_insert(datacontrol_h provider, const bundle *insert_data, in
 
        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) {
@@ -1049,7 +1055,7 @@ int datacontrol_sql_insert(datacontrol_h provider, const bundle *insert_data, in
                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;
@@ -1058,8 +1064,7 @@ int datacontrol_sql_insert(datacontrol_h provider, const bundle *insert_data, in
        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);
@@ -1067,7 +1072,6 @@ int datacontrol_sql_insert(datacontrol_h provider, const bundle *insert_data, in
                return DATACONTROL_ERROR_OUT_OF_MEMORY;
        }
 
-       const char *arg_list[2];
        arg_list[0] = provider->data_id;
        arg_list[1] = insert_column_count;
 
@@ -1084,13 +1088,17 @@ int datacontrol_sql_insert(datacontrol_h provider, const bundle *insert_data, in
 
 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;
@@ -1099,7 +1107,6 @@ int datacontrol_sql_delete(datacontrol_h provider, const char *where, int *reque
        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)
@@ -1110,21 +1117,33 @@ int datacontrol_sql_delete(datacontrol_h provider, const char *where, int *reque
        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");
@@ -1138,10 +1157,7 @@ int datacontrol_sql_select_with_page(datacontrol_h provider, char **column_list,
                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;
@@ -1150,7 +1166,6 @@ int datacontrol_sql_select_with_page(datacontrol_h provider, char **column_list,
        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);
@@ -1158,7 +1173,6 @@ int datacontrol_sql_select_with_page(datacontrol_h provider, char **column_list,
                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);
@@ -1167,14 +1181,13 @@ int datacontrol_sql_select_with_page(datacontrol_h provider, char **column_list,
        }
 
        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);
@@ -1187,10 +1200,9 @@ int datacontrol_sql_select_with_page(datacontrol_h provider, char **column_list,
                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 */
@@ -1210,7 +1222,7 @@ int datacontrol_sql_select_with_page(datacontrol_h provider, char **column_list,
        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);
@@ -1218,19 +1230,21 @@ int datacontrol_sql_select_with_page(datacontrol_h provider, char **column_list,
        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) {
@@ -1238,7 +1252,7 @@ int datacontrol_sql_update(datacontrol_h provider, const bundle *update_data, co
                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;
@@ -1247,8 +1261,6 @@ int datacontrol_sql_update(datacontrol_h provider, const bundle *update_data, co
        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);
@@ -1256,7 +1268,6 @@ int datacontrol_sql_update(datacontrol_h provider, const bundle *update_data, co
                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;
@@ -1268,3 +1279,4 @@ int datacontrol_sql_update(datacontrol_h provider, const bundle *update_data, co
        bundle_free(b);
        return ret;
 }
+
index b2056cd2135407ea4d2d4dcba726db015cf25211..0a880102fd5603235fe3301a003b7995da998fc3 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * 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.
index 29165fc0044d75bf24a502b5bdb720c6850c579f..fcdc27210aa3f1c5d9aaec7364453f3eb5aa801b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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.
index 9661b5412e9427639a9f013496301b5c3b7067ef..bb18b7b4682b81fe878c6af35d90ac6e1c915dac 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * 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>
@@ -25,49 +41,44 @@ static GHashTable *response_table = NULL;
 
 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);
@@ -75,8 +86,7 @@ __free_data(gpointer 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);
 
@@ -86,45 +96,40 @@ __initialize(void)
        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();
@@ -132,12 +137,11 @@ data_control_map_register_response_cb(data_control_h provider, data_control_map_
        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;
@@ -149,8 +153,7 @@ data_control_map_register_response_cb(data_control_h provider, data_control_map_
        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);
@@ -158,8 +161,7 @@ data_control_map_unregister_response_cb(data_control_h provider)
        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)
@@ -168,8 +170,7 @@ data_control_map_get(data_control_h provider, const char *key, int *request_id)
        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)
@@ -178,8 +179,7 @@ data_control_map_get_with_page(data_control_h provider, const char *key, int *re
        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)
@@ -188,8 +188,7 @@ data_control_map_set(data_control_h provider, const char *key, const char *old_v
        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)
@@ -198,8 +197,7 @@ data_control_map_add(data_control_h provider, const char *key, const char *value
        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)
@@ -207,3 +205,4 @@ data_control_map_remove(data_control_h provider, const char *key, const char *va
 
        return convert_to_tizen_error(datacontrol_map_remove((datacontrol_h)provider, key, value, request_id));
 }
+
index f5acca4cd78fdb2ad82a2bc4d17afc33be007673..86ace9b09b29d5f342e60cf2250040a33b1886e3 100755 (executable)
@@ -1,8 +1,23 @@
-#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"
@@ -40,7 +55,7 @@ static data_control_provider_map_cb map_provider_callback;
 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");
 
@@ -48,7 +63,7 @@ void __sql_insert_request_cb(int request_id, datacontrol_h provider, bundle *ins
                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");
 
@@ -56,7 +71,7 @@ void __sql_update_request_cb(int request_id, datacontrol_h provider, bundle *upd
                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");
 
@@ -64,7 +79,7 @@ void __sql_delete_request_cb(int request_id, datacontrol_h provider, const char
                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");
 
@@ -72,7 +87,7 @@ void __sql_select_request_cb(int request_id, datacontrol_h provider, const char
                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");
 
@@ -80,7 +95,7 @@ void __map_get_request_cb(int request_id, datacontrol_h provider, const char *ke
                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");
 
@@ -88,7 +103,7 @@ void __map_set_request_cb(int request_id, datacontrol_h provider, const char *ke
                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");
 
@@ -96,7 +111,7 @@ void __map_add_request_cb(int request_id, datacontrol_h provider, const char *ke
                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");
 
@@ -106,7 +121,6 @@ void __map_remove_request_cb(int request_id, datacontrol_h provider, const char
 
 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;
@@ -133,7 +147,6 @@ EXPORT_API int data_control_provider_sql_unregister_cb(void)
 
 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;
@@ -190,17 +203,18 @@ EXPORT_API int data_control_provider_send_error(int request_id, const char *erro
 
 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;
@@ -212,7 +226,12 @@ static void bundle_foreach_cb(const char *key, const int type, const bundle_keyv
 
 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;
@@ -241,17 +260,16 @@ EXPORT_API char *data_control_provider_create_insert_statement(data_control_h pr
                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);
@@ -297,6 +315,9 @@ EXPORT_API char *data_control_provider_create_insert_statement(data_control_h pr
 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);
@@ -305,12 +326,12 @@ EXPORT_API char *data_control_provider_create_delete_statement(data_control_h pr
 
        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);
@@ -332,7 +353,13 @@ EXPORT_API char *data_control_provider_create_delete_statement(data_control_h pr
 
 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;
@@ -346,13 +373,13 @@ EXPORT_API char *data_control_provider_create_update_statement(data_control_h pr
 
        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);
@@ -360,18 +387,17 @@ EXPORT_API char *data_control_provider_create_update_statement(data_control_h pr
                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);
@@ -419,6 +445,12 @@ EXPORT_API char *data_control_provider_create_select_statement(data_control_h pr
 {
        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;
@@ -434,16 +466,15 @@ EXPORT_API char *data_control_provider_create_select_statement(data_control_h pr
                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);
@@ -484,6 +515,7 @@ EXPORT_API bool data_control_provider_match_provider_id(data_control_h provider,
 {
        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;
@@ -507,6 +539,7 @@ EXPORT_API bool data_control_provider_match_data_id(data_control_h provider, con
 {
        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;
@@ -526,14 +559,13 @@ EXPORT_API bool data_control_provider_match_data_id(data_control_h provider, con
        }
 }
 
-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);
 }
+
index 9865997f3d34d6ad4822b425eac7d695743c455b..20334419c486dddd635f6d669e7bd2987d95abc3 100644 (file)
@@ -1,3 +1,20 @@
+/*
+ * 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>
@@ -20,53 +37,47 @@ struct datacontrol_s {
        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);
@@ -74,8 +85,7 @@ __free_data(gpointer 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);
 
@@ -85,57 +95,52 @@ __initialize(void)
        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;
@@ -147,8 +152,7 @@ data_control_sql_register_response_cb(data_control_h provider, data_control_sql_
        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);
@@ -156,8 +160,7 @@ data_control_sql_unregister_response_cb(data_control_h provider)
        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);
@@ -167,8 +170,7 @@ data_control_sql_insert(data_control_h provider, const bundle* insert_data, int
        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)
@@ -177,8 +179,7 @@ data_control_sql_delete(data_control_h provider, const char *where, int *request
        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)
@@ -187,8 +188,7 @@ data_control_sql_select(data_control_h provider, char **column_list, int column_
        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)
@@ -198,10 +198,8 @@ data_control_sql_select_with_page(data_control_h provider, char **column_list, i
 }
 
 
-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;
index d6ed1d7ee1321d47392a04d94414ba83995aa246..d8b8c95d8a4db1a8b2024b1d44f34b263534e346 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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>
@@ -13,119 +28,97 @@ struct result_set_s {
        int result_set_content_offset;
        int result_set_current_offset;
        int result_set_current_row_count;
-       charresult_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);
 }