tizen 2.3.1 release tizen_2.3.1 submit/tizen_2.3.1/20150915.075714 tizen_2.3.1_release
authorjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:09:03 +0000 (22:09 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:09:03 +0000 (22:09 +0900)
21 files changed:
CMakeLists.txt [new file with mode: 0644]
LICENSE.Apache-2.0 [new file with mode: 0644]
NOTICE [new file with mode: 0644]
capi-data-control.pc.in [new file with mode: 0644]
doc/data_control_doc.h [new file with mode: 0755]
include/data_control.h [new file with mode: 0755]
include/data_control_internal.h [new file with mode: 0755]
include/data_control_map.h [new file with mode: 0755]
include/data_control_provider.h [new file with mode: 0755]
include/data_control_sql.h [new file with mode: 0755]
include/data_control_sql_cursor.h [new file with mode: 0755]
include/data_control_types.h [new file with mode: 0755]
packaging/capi-data-control.manifest [new file with mode: 0644]
packaging/capi-data-control.spec [new file with mode: 0644]
src/CMakeLists.txt [new file with mode: 0644]
src/data_control_internal.c [new file with mode: 0644]
src/data_control_log.h [new file with mode: 0644]
src/data_control_map.c [new file with mode: 0644]
src/data_control_provider.c [new file with mode: 0644]
src/data_control_sql.c [new file with mode: 0644]
src/data_control_sql_cursor.c [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..fbc29b1
--- /dev/null
@@ -0,0 +1,15 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+## OUTPUT PATHS
+SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output)
+
+## LIBRARY PATH
+LINK_DIRECTORIES (${LIBRARY_OUTPUT_PATH})
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DSLP_DEBUG")
+
+ADD_SUBDIRECTORY(src)
diff --git a/LICENSE.Apache-2.0 b/LICENSE.Apache-2.0
new file mode 100644 (file)
index 0000000..d645695
--- /dev/null
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..579ba56
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.Apache-2.0 file for Apache License terms and conditions.
diff --git a/capi-data-control.pc.in b/capi-data-control.pc.in
new file mode 100644 (file)
index 0000000..3d840d6
--- /dev/null
@@ -0,0 +1,15 @@
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@/appfw
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
+
diff --git a/doc/data_control_doc.h b/doc/data_control_doc.h
new file mode 100755 (executable)
index 0000000..09b446d
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2011 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_DATA_CONTROL_DOC_H__
+#define __TIZEN_DATA_CONTROL_DOC_H__
+
+/**
+ * @ingroup CAPI_APPLICATION_FRAMEWORK
+ * @defgroup CAPI_DATA_CONTROL_MODULE Data Control
+ * @brief Data control is a standard mechanism for exchanging specific data between applications.
+ *
+ * @section CAPI_DATA_CONTROL_MODULE_HEADER Required Header
+ *   \#include <data_control.h>
+ *
+ * @section CAPI_DATA_CONTROL_MODULE_OVERVIEW Overview
+ * All applications can request data shared by other applications using data control. However, only service applications can provide their own data.
+ * There are 2 types of data controls:
+ * - DATA_CONTROL_SQL
+ *   This allows you to use a SQL-type data control to access the specific data exported by other service applications. You can also define a SQL-type data control provider to export specific data from your service application.
+ * - DATA_CONTROL_MAP
+ *   This allows you to use a key value-type data control to access the data exported by other service applications. You can also define an key value-type data control provider to export the specific data from your service application.
+ *
+ */
+
+/**
+ * @ingroup CAPI_DATA_CONTROL_MODULE
+ * @defgroup CAPI_DATA_CONTROL_CONSUMER_MODULE Data Control Consumer
+ * @brief All applications can request data shared by other applications using data control.
+ *
+ * @section CAPI_DATA_CONTROL_CONSUMER_MODULE_HEADER Required Header
+ *   \#include <data_control.h>
+ *
+ * @section CAPI_DATA_CONTROL_CONSUMER_MODULE_OVERVIEW Overview
+ * You can get a datacontrol_h instance from data_control_map_create() or data_control_sql_create().
+ * - Map type data control
+ *   If you specify datacontrol_h using the data_control_map_create(), data_control_map_set_provider_id(), or data_control_map_set_data_id()  method, you can get the specific map-type data control uniquely. After resolving the data control, call data_control_map APIs, such as data_control_map_set(), data_control_map_get(), data_control_map_add(), and data_control_map_remove().
+ *   The result is returned by response callback, such as data_control_map_get_response_cb(), data_control_map_set_response_cb(), data_control_map_add_response_cb() or data_control_map_remove_response_cb() of the #data_control_map_response_cb struct. The response callback is invoked when a service application finishes its operation.
+ * - SQL type data control
+ *   If you specify the datacontrol_h using the data_control_sql_create(), data_control_sql_set_provider_id(), or data_control_sql_set_data_id()  method,  you can get the specific SQL-type data control uniquely. After resolving the data control, call data_control_sql APIs, such as  data_control_sql_select(), data_control_sql_insert(), data_control_sql_update(), and data_control_sql_delete().
+ *   The result is returned by response callback, such as data_control_sql_select_response_cb(), data_control_sql_insert_response_cb(), data_control_sql_update_response_cb() or data_control_sql_delete_response_cb() of the #data_control_sql_response_cb struct.  The response callback is invoked when a service application finishes its operation.
+ *   Once you get result_set_cursor using data_control_sql_select_response_cb(), then you can use following functions to get the information:
+ *   -  data_control_sql_step_first()
+ *   -  data_control_sql_step_last()
+ *   -  data_control_sql_step_next()
+ *   -  data_control_sql_step_previous()
+ *   -  data_control_sql_get_column_count()
+ *   -  data_control_sql_get_column_name()
+ *   -  data_control_sql_get_column_item_size()
+ *   -  data_control_sql_get_column_item_type()
+ *   -  data_control_sql_get_blob_data()
+ *   -  data_control_sql_get_int_data()
+ *   -  data_control_sql_get_int64_data()
+ *   -  data_control_sql_get_double_data()
+ *   -  data_control_sql_get_text_data()
+ */
+
+/**
+ * @ingroup CAPI_DATA_CONTROL_MODULE
+ * @defgroup CAPI_DATA_CONTROL_PROVIDER_MODULE Data Control Provider
+ * @brief Service applications can provide their own data.
+ *
+ * @section CAPI_DATA_CONTROL_PROVIDER_MODULE_HEADER Required Header
+ *   \#include <data_control.h>
+ *
+ * @section CAPI_DATA_CONTROL_PROVIDER_MODULE_OVERVIEW Overview
+ * The service application providing its own database file must register the provider callback using data_control_provider_sql_register_cb().
+ * The service application providing its own registry file or key-value pairs data set must register the provider callback using the data_control_provider_map_register_cb().
+ * The service application sends SQL-type or Map-type data control result to the other application, by using methods such as data_control_provider_send_select_result(),data_control_provider_send_insert_result(), data_control_provider_send_update_result(), or data_control_provider_send_delete_result().
+ */
+
+
+#endif /* __TIZEN_DATA_CONTROL_DOC_H__ */
+
+
diff --git a/include/data_control.h b/include/data_control.h
new file mode 100755 (executable)
index 0000000..94f07d6
--- /dev/null
@@ -0,0 +1,31 @@
+//
+// 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.
+//
+
+#ifndef __TIZEN_APPFW_DATA_CONTROL_H__
+#define __TIZEN_APPFW_DATA_CONTROL_H__
+
+#include <tizen.h>
+#include <data_control_sql.h>
+#include <data_control_map.h>
+#include <data_control_provider.h>
+
+/**
+ * @file   data_control.h
+ * @brief  This is the header file for the data control.
+ */
+
+#endif /* __TIZEN_APPFW_DATA_CONTROL_H__ */
+
diff --git a/include/data_control_internal.h b/include/data_control_internal.h
new file mode 100755 (executable)
index 0000000..08b205e
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011 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_INTERNAL_H__
+#define __TIZEN_APPFW_DATA_CONTROL_INTERNAL_H__
+
+#include <data-control-types.h>
+#include "data_control_types.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+       PRIVILEGE_DATA_SHARING,
+       PRIVILEGE_APP_MANAGER_LAUNCH
+} privilege_type;
+
+int convert_to_tizen_error(datacontrol_error_e error);
+int check_privilege(privilege_type type);
+int data_control_error(data_control_error_e error,
+               const char *function, const char *description);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*  __TIZEN_APPFW_DATA_CONTROL_INTERNAL_H__ */
diff --git a/include/data_control_map.h b/include/data_control_map.h
new file mode 100755 (executable)
index 0000000..ff71990
--- /dev/null
@@ -0,0 +1,617 @@
+//
+// 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.
+//
+
+#ifndef __TIZEN_APPFW_DATA_CONTROL_MAP_H__
+#define __TIZEN_APPFW_DATA_CONTROL_MAP_H__
+
+#include <data_control_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file   data_control_map.h
+ * @brief  This is the header file for the key-value structured data control.
+ */
+
+/**
+ * @addtogroup CAPI_DATA_CONTROL_CONSUMER_MODULE
+ * @{
+ */
+
+/**
+ * @brief  Called when the result value list is received from the key-value structured data control provider.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks You must release @a resule_value_list using free() after it is used. Note that @a result_value list is an array of char *. Its length is @a result_value_count. You should release all the elements in the @a result_value_list array and @a result_value_list itself like the following code.
+ *
+ * @code
+ *
+ *  int i;
+ *  for (i = 0; i < resule_value_count; i++)
+ *      free(result_value_list[i]);
+ *  free(result_value_list);
+ *
+ * @endcode
+
+ * @param[in]  request_id          The request ID
+ * @param[in]  provider            The provider handle
+ * @param[in]  result_value_list   The result value list of the data control request that gets the matching values
+ * @param[in]  result_value_count  The number of the values
+ * @param[in]  provider_result     Set to @c true if the data control provider is successfully processed, \n
+ *                                 otherwise set to @c false
+ * @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);
+
+/**
+ * @brief  Called when the response is received from the key-value structured data control provider.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  request_id       The request ID that identifies the data control
+ * @param[in]  provider         The provider handle
+ * @param[in]  provider_result  Set to @c true if the data control provider successfully processed, \n
+ *                              otherwise @c false
+ * @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);
+
+/**
+ * @brief  Called when the response is received from the key-value structured data control provider.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  request_id       The request ID that identifies the data control
+ * @param[in]  provider         The provider handle
+ * @param[in]  provider_result  Set to @c true if the data control provider successfully processed, \n
+ *                              otherwise set to @c false
+ * @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);
+
+/**
+ * @brief  Called when the response is received from the key-value structured data control provider.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  request_id       The request ID that identifies the data control
+ * @param[in]  provider         The provider handle
+ * @param[in]  provider_result  Set to @c true if the data control provider successfully processed, \n
+ *                              otherwise set to @c false
+ * @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);
+
+/**
+ * @brief  The structure type to contain the set of callback functions for handling the response events
+ *         of the key-value structured data control.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @see  data_control_map_get_response_cb()
+ * @see  data_control_map_set_response_cb()
+ * @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. */
+} data_control_map_response_cb;
+
+/**
+ * @brief  Creates a provider handle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks The following example demonstrates how to use the %data_control_map_create() method.
+ *
+ * @code
+ *
+ *  int main()
+ *  {
+ *      const char *provider_id = "http://tizen.org/datacontrol/provider/example";
+ *      const char *data_id = "table";
+ *      data_control_h provider;
+ *      int result = 0;
+ *
+ *      result = data_control_map_create(&provider);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Creating data control provider is failed with error: %d", result);
+ *          return result;
+ *      }
+ *
+ *      result = data_control_map_set_provider_id(provider, provider_id);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Setting providerID is failed with error: %d", result);
+ *          return result;
+ *      }
+ *
+ *      result = data_control_map_set_data_id(provider, data_id);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Setting dataID is failed with error: %d", result);
+ *          return result;
+ *      }
+ *
+ *      // Executes some operations
+ *
+ *      result = data_control_map_destroy(provider);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Destorying data control provider is failed with error: %d", result);
+ *      }
+ *
+ *      return result;
+ *  }
+ *
+ * @endcode
+
+ * @param[out]  provider  The provider handle
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ *
+ * @see        data_control_map_destroy()
+
+ */
+int data_control_map_create(data_control_h *provider);
+
+/**
+ * @brief  Destroys the provider handle and releases all its resources.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks  When operations of data control are finished, this function must be called to prevent memory leak.
+ *
+ * @param[in]  provider  The provider handle
+ *
+ * @return   @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @see data_control_map_create()
+ */
+int data_control_map_destroy(data_control_h provider);
+
+/**
+ * @brief  Sets the Provider ID.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  provider     The provider handle
+ * @param[in]  provider_id  The data control provider ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE               Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY      Out of memory
+ *
+ * @see        data_control_map_get_provider_id()
+ */
+int data_control_map_set_provider_id(data_control_h provider, const char *provider_id);
+
+/**
+ * @brief  Gets the Provider ID.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks  You must release @a provider_id using free() after it is used.
+ *
+ * @param[in]   provider     The provider handle
+ * @param[out]  provider_id  The data control provider ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ *
+ * @see  data_control_map_set_provider_id()
+ */
+int data_control_map_get_provider_id(data_control_h provider, char **provider_id);
+
+/**
+ * @brief  Sets the Data ID.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  provider  The provider handle
+ * @param[in]  data_id   A string for identifying a specific table to operate \n
+ *                       The string consists of one or more components separated by a slash('/').
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ *
+ * @see  data_control_map_get_data_id()
+ */
+int data_control_map_set_data_id(data_control_h provider, const char *data_id);
+
+/**
+ * @brief  Gets the data ID.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks You must release @a data_id using free() after it is used.
+ *
+ * @param[in]   provider  The provider handle
+ * @param[out]  data_id   A string for identifying a specific table to operate \n
+ *                        The string consists of one or more components separated by a slash('/').
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ *
+ * @see  data_control_map_set_data_id()
+ */
+int data_control_map_get_data_id(data_control_h provider, char **data_id);
+
+/**
+ * @brief  Registers a callback function for the key-value structured data control response.
+ *         The application is notified when a data control response is received from the @a provider.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  provider  The provider handle
+ * @param[in]  callback  The callback function to be called when a response is received
+ * @param[in]  user_data The user data to be passed to the callback function
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE          Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR      I/O error
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see        data_control_map_unregister_response_cb()
+ */
+int data_control_map_register_response_cb(data_control_h provider, data_control_map_response_cb* callback, void *user_data);
+
+/**
+ * @brief  Unregisters the callback function in the @a provider.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  provider  The provider handle
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ */
+int data_control_map_unregister_response_cb(data_control_h provider);
+
+/**
+ * @brief  Gets the value list associated with the specified @a key from the key-values map owned by the key-value structured data control provider.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel   public
+ * @privilege   %http://tizen.org/privilege/datasharing \n
+ *              %http://tizen.org/privilege/appmanager.launch
+ *
+ * @remarks If you want to use this api, you must add privileges.
+ * @remarks If the length of value list associated with the @a key is larger than 20, this API only returns the first 20 values.
+ * @remarks The following example demonstrates how to use the %data_control_map_get() method.
+ *
+ * @code
+ *
+ *  void map_get_response_cb(int request_id, data_control_h provider,
+ *          char **result_value_list, int ret_value_count,  bool provider_result, const char *error, void *user_data)
+ *  {
+ *      if (provider_result) {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "The get operation is successful");
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "The get operation for the request %d is failed. error message: %s", request_id, error);
+ *      }
+ *  }
+ *
+ *  data_control_map_response_cb map_callback;
+ *
+ *  int main()
+ *  {
+ *      int result = 0;
+ *      int req_id = 0;
+ *      char *key = "key";
+ *
+ *      map_callback.get_cb = map_get_response_cb;
+ *      result = data_control_map_register_response_cb(provider, &map_callback, NULL);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
+ *          return result;
+ *      }
+ *
+ *      result = data_control_map_get(provider, key, &req_id);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Getting the value list of the key(%s) is failed with error: %d", key, result);
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
+ *      }
+ *
+ *      return result;
+ *  }
+ *
+ * @endcode
+ *
+ * @param[in]   provider    The provider handle
+ * @param[in]   key         The key of the value list to obtain
+ * @param[out]  request_id  The request ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ * @retval #DATA_CONTROL_ERROR_MAX_EXCEEDED      Too long argument
+ * @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see data_control_map_get_with_page()
+ */
+int data_control_map_get(data_control_h provider, const char *key, int *request_id);
+
+/**
+ * @brief  Gets the value list associated with the specified @a key from the key-values map owned by the key-value structured data control provider.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel   public
+ * @privilege   %http://tizen.org/privilege/datasharing \n
+ *              %http://tizen.org/privilege/appmanager.launch
+ *
+ * @remarks If you want to use this api, you must add privileges.
+ *
+ * @param[in]   provider        The provider handle
+ * @param[in]   key             The key of the value list to obtain
+ * @param[out]  request_id      The request ID
+ * @param[in]   page_number     The page number of the value set \n
+ *                              It starts from @c 1.
+ * @param [in]  count_per_page  The desired maximum count of the data items per page. 1024 is the maximum value of count_per_page.
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ * @retval #DATA_CONTROL_ERROR_MAX_EXCEEDED      Too long argument
+ * @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see data_control_map_get()
+ */
+int data_control_map_get_with_page(data_control_h provider, const char *key, int *request_id, int page_number, int count_per_page);
+
+/**
+ * @brief  Sets the value associated with the specified @a key to a new value.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel   public
+ * @privilege   %http://tizen.org/privilege/datasharing \n
+ *              %http://tizen.org/privilege/appmanager.launch
+ *
+ * @remarks If you want to use this api, you must add privileges.
+ * @remarks The following example demonstrates how to use the %data_control_map_set() method.
+ *
+ * @code
+ *
+ *  void map_set_response_cb(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data)
+ *  {
+ *      if (provider_result) {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "The set operation is successful");
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "The set operation for the request %d is failed. error message: %s", request_id, error);
+ *      }
+ *  }
+ *
+ *  data_control_map_response_cb map_callback;
+ *
+ *  int main()
+ *  {
+ *      int result = 0;
+ *      int req_id = 0;
+ *      char *key = "key";
+ *      char *old_value = "old value";
+ *      char *new_value = "new value";
+ *
+ *      map_callback.set_cb = map_set_response_cb;
+ *      result = data_control_map_register_response_cb(provider, &map_callback, NULL);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
+ *          return result;
+ *      }
+ *
+ *      result = data_control_map_set(provider, key, old_value, new_value, &req_id);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Replacing old_value(%s) with new_value(%s) is failed with error: %d", old_value, new_value, result);
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
+ *      }
+ *
+ *      return result;
+ *  }
+ *
+ * @endcode
+
+ * @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[out]  request_id  The request ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ * @retval #DATA_CONTROL_ERROR_MAX_EXCEEDED      Too long argument
+ * @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
+ */
+int data_control_map_set(data_control_h provider, const char *key, const char *old_value, const char *new_value, int *request_id);
+
+/**
+ * @brief  Adds the @a value associated with the specified @a key to the key-values map owned by the key-value structured data control provider.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel   public
+ * @privilege   %http://tizen.org/privilege/datasharing \n
+ *              %http://tizen.org/privilege/appmanager.launch
+ *
+ * @remarks If you want to use this api, you must add privileges.
+ * @remarks The following example demonstrates how to use the %data_control_map_add() method.
+ *
+ * @code
+ *
+ *  void map_add_response_cb(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) {
+ *      if (provider_result) {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "The add operation is successful");
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "The add operation for the request %d is failed. error message: %s", request_id, error);
+ *      }
+ *  }
+ *
+ *  data_control_map_response_cb map_callback;
+ *
+ *  int main()
+ *  {
+ *      int result = 0;
+ *      int req_id = 0;
+ *      const char *key = "key";
+ *      const char *value = "value";
+ *
+ *      map_callback.add_cb = map_add_response_cb;
+ *      result = data_control_map_register_response_cb(provider, &map_callback, NULL);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
+ *          return result;
+ *      }
+ *
+ *      result = data_control_map_add(provider, key, value, &req_id);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Adding %s-%s pair is failed with error: %d", key, value, result);
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
+ *      }
+ *
+ *      return result;
+ *  }
+ *
+ * @endcode
+
+ * @param[in]   provider    The provider handle
+ * @param[in]   key         The key of the value to add
+ * @param[in]   value       The value to add
+ * @param[out]  request_id  The request ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ * @retval #DATA_CONTROL_ERROR_MAX_EXCEEDED      Too long argument
+ * @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
+ */
+int data_control_map_add(data_control_h provider, const char *key, const char *value, int *request_id);
+
+/**
+ * @brief  Removes the @a value associated with the specified @a key from the key-values map owned by the key-value structured data control provider.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel   public
+ * @privilege   %http://tizen.org/privilege/datasharing \n
+ *              %http://tizen.org/privilege/appmanager.launch
+ *
+ * @remarks If you want to use this api, you must add privileges.
+ * @remarks The following example demonstrates how to use the %data_control_map_remove() method.
+ *
+ * @code
+ *
+ *  void map_remove_response_cb(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) {
+ *      if (provider_result) {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "The remove operation is successful");
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "The remove operation for the request %d is failed. error message: %s", request_id, error);
+ *     }
+ *  }
+ *
+ *  data_control_map_response_cb map_callback;
+ *
+ *  int main()
+ *  {
+ *      int result = 0;
+ *      int req_id = 0;
+ *      const char *key = "key";
+ *      const char *value = "value";
+ *
+ *      map_callback.remove_cb = map_remove_response_cb;
+ *      result = data_control_map_register_response_cb(provider, &map_callback, NULL);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
+ *          return result;
+ *      }
+ *
+ *      result = data_control_map_remove(provider, key, value, &req_id);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Removing %s-%s pair is failed with error: %d", key, value, result);
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
+ *      }
+ *
+ *      return result;
+ *  }
+ *
+ * @endcode
+ *
+ * @param[in]   provider    The provider handle
+ * @param[in]   key         The key of the value to remove
+ * @param[in]   value       The value to remove
+ * @param[out]  request_id  The request ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ * @retval #DATA_CONTROL_ERROR_MAX_EXCEEDED      Too long argument
+ * @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
+ */
+int data_control_map_remove(data_control_h provider, const char *key, const char *value, int *request_id);
+
+/**
+* @}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_APPFW_DATA_CONTROL_MAP_H__ */
diff --git a/include/data_control_provider.h b/include/data_control_provider.h
new file mode 100755 (executable)
index 0000000..c1dffad
--- /dev/null
@@ -0,0 +1,473 @@
+//
+// 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.
+//
+
+#ifndef __TIZEN_APPFW_DATA_CONTROL_PROVIDER_H_
+#define __TIZEN_APPFW_DATA_CONTROL_PROVIDER_H_
+
+#include <data_control_types.h>
+#include <data_control_sql_cursor.h>
+#include <bundle.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file   data_control_provider.h
+ * @brief  This is the header file for the data control provider.
+ */
+
+/**
+ * @addtogroup CAPI_DATA_CONTROL_PROVIDER_MODULE
+ * @{
+ */
+
+/**
+ * @brief  Called when the insert request is received from an application using SQL-friendly interface based data control.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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
+ */
+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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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]  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
+ */
+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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  request_id  The request ID
+ * @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
+ */
+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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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]  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.
+ * @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
+ */
+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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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
+ */
+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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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]  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);
+
+/**
+ * @brief  Called when the request for adding the value is received from the key-value structured data control consumer.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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]  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);
+
+/**
+ * @brief  Called when the request for removing the value is received from the key-value structured data control consumer.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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]  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);
+
+/**
+ * @brief  The structure type to contain the set of callback functions for handling the request events
+ *         of SQL-friendly interface based data control.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @see  data_control_provider_sql_select_request_cb()
+ * @see  data_control_provider_sql_insert_request_cb()
+ * @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. */
+} data_control_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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @see  data_control_provider_map_get_value_request_cb()
+ * @see  data_control_provider_map_set_value_request_cb()
+ * @see  data_control_provider_map_add_value_request_cb()
+ * @see  data_control_provider_map_remove_value_request_cb()
+ */
+typedef struct
+{
+    data_control_provider_map_get_value_request_cb get_cb; /**< This callback function is called when a request for getting value is received from other application. */
+    data_control_provider_map_set_value_request_cb set_cb; /**< This callback function is called when a request for setting value is received from other application. */
+    data_control_provider_map_add_value_request_cb add_cb; /**< This callback function is called when a request for adding value is received from other application. */
+    data_control_provider_map_remove_value_request_cb remove_cb; /**< This callback function is called when a request for removing value is received from other application. */
+} data_control_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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel   public
+ * @privilege   %http://tizen.org/privilege/datasharing
+ *
+ * @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  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
+ */
+int data_control_provider_sql_register_cb(data_control_provider_sql_cb *callback, void *user_data);
+
+/**
+ * @brief  Unregisters the callback functions.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ */
+int data_control_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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel   public
+ * @privilege   %http://tizen.org/privilege/datasharing
+ *
+ * @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  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
+ */
+int data_control_provider_map_register_cb(data_control_provider_map_cb *callback, void *user_data);
+
+/**
+ * @brief  Unregisters the callback functions.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ */
+int data_control_provider_map_unregister_cb(void);
+
+/**
+ * @brief  Gets the application ID which sends the data control request.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]   request_id  The request ID
+ * @param[out]  appid       The application ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  request_id  The request ID
+ * @param[in]  db_handle   The result DB handle for the result set
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
+ */
+int data_control_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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  request_id  The request ID
+ * @param[in]  row_id      The row ID of the database changed by the insert request
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_provider_send_insert_result(int request_id, long long row_id);
+
+/**
+ * @brief  Sends the success result of the update request to the client application.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  request_id  The request ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_provider_send_update_result(int request_id);
+
+/**
+ * @brief  Sends the success result of the delete request to the client application.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  request_id  The request ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_provider_send_delete_result(int request_id);
+
+/**
+ * @brief  Sends the provider error message to the client application.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  request_id  The request ID
+ * @param[in]  error       The provider-defined error message
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  request_id  The request ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_provider_send_map_result(int request_id);
+
+/**
+ * @brief  Sends the success result of the request for getting the value list to the client application.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
+ */
+int data_control_provider_send_map_get_value_result(int request_id, char **value_list, int value_count);
+
+/**
+ * @brief  Creates SQL INSERT statement.
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  provider    The provider handle
+ * @param[in]  insert_map  The column-value pairs to insert
+ *
+ * @return  The SQL INSERT statement on success, otherwise NULL
+ * @exception DATA_CONTROL_ERROR_NONE  Success
+ * @exception DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception DATA_CONTROL_ERROR_INVALID_PARAMETER     Invalid parameter
+ */
+char* data_control_provider_create_insert_statement(data_control_h provider, bundle *insert_map);
+
+/**
+ * @brief  Creates SQL DELETE statement.
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  provider  The provider handle
+ * @param[in]  where      A filter to select the desired rows to delete \n
+ *                        Pass @c NULL if all rows need to be deleted.
+ *
+ * @return  The SQL DELETE statement on success, otherwise NULL
+ * @exception DATA_CONTROL_ERROR_NONE  Success
+ * @exception DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception DATA_CONTROL_ERROR_INVALID_PARAMETER     Invalid parameter
+ */
+char* data_control_provider_create_delete_statement(data_control_h provider, const char *where);
+
+/**
+ * @brief  Creates SQL UPDATE statement.
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  provider    The provider handle
+ * @param[in]  update_map  The column-value pairs to update
+ * @param[in]  where       A filter to select the desired rows to update
+ *
+ * @return The SQL UPDATE statement on success, otherwise NULL
+ * @exception DATA_CONTROL_ERROR_NONE  Success
+ * @exception DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception DATA_CONTROL_ERROR_INVALID_PARAMETER     Invalid parameter
+ */
+char* data_control_provider_create_update_statement(data_control_h provider, bundle *update_map, const char *where);
+
+/**
+ * @brief  Creates SQL SELECT statement.
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  provider      The provider handle
+ * @param[in]  column_list   The column names to query \n
+ *                           Pass @c NULL if all columns need to be selected.
+ * @param[in]  column_count  The total number of columns to be queried
+ * @param[in]  where         A filter to select the desired rows
+ * @param[in]  order         The sorting order of rows to query
+ *
+ * @return  The SQL SELECT statement on success, otherwise NULL
+ * @exception DATA_CONTROL_ERROR_NONE  Success
+ * @exception DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception DATA_CONTROL_ERROR_INVALID_PARAMETER     Invalid parameter
+ */
+char* data_control_provider_create_select_statement(data_control_h provider, const char **column_list, int column_count, const char *where, const char *order);
+
+/**
+ * @brief  Checks whether the given provider ID matches the provider handle's provider ID.
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  provider     The provider handle
+ * @param[in]  provider_id  The provider ID to be compared with handle's provider ID
+ *
+ * @return  @c true if the provider_id matches,
+ *          otherwise @c false if it does not match
+ * @exception DATA_CONTROL_ERROR_NONE  Success
+ * @exception DATA_CONTROL_ERROR_INVALID_PARAMETER     Invalid parameter
+ */
+bool data_control_provider_match_provider_id(data_control_h provider, const char *provider_id);
+
+/**
+ * @brief  Checks whether the given data ID matches the provider handle's data ID.
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  provider  The provider handle
+ * @param[in]  data_id   The data ID to be compared with handle's data ID
+ *
+ * @return  @c true if the @a data_id matches,
+ *          otherwise @c false if it does not match
+ * @exception DATA_CONTROL_ERROR_NONE  Success
+ * @exception DATA_CONTROL_ERROR_INVALID_PARAMETER     Invalid parameter
+ */
+bool data_control_provider_match_data_id(data_control_h provider, const char *data_id);
+
+/**
+* @}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_APPFW_DATA_CONTROL_PROVIDER_H_ */
+
diff --git a/include/data_control_sql.h b/include/data_control_sql.h
new file mode 100755 (executable)
index 0000000..c160bbb
--- /dev/null
@@ -0,0 +1,625 @@
+//
+// 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.
+//
+
+#ifndef __TIZEN_APPFW_DATA_CONTROL_SQL_H__
+#define __TIZEN_APPFW_DATA_CONTROL_SQL_H__
+
+#include <data_control_types.h>
+#include <data_control_sql_cursor.h>
+#include <bundle.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file   data_control_sql.h
+ * @brief  This is the header file for the SQL-friendly interface based data control.
+ */
+
+/**
+ * @addtogroup CAPI_DATA_CONTROL_CONSUMER_MODULE
+ * @{
+ */
+
+/**
+ * @brief  Called when a response is received for an insert operation from an application using the SQL-friendly interface based data control.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  request_id       The request ID
+ * @param[in]  provider         The provider handle
+ * @param[in]  inserted_row_id  The inserted row ID set by the data control
+ * @param[in]  provider_result  Set to @c true if the data control provider successfully processed, \n
+ *                              otherwise set to @c false
+ * @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);
+
+/**
+ * @brief  Called when a response is received for a delete operation from an application using the SQL-friendly interface based data control.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  request_id       The request ID that identifies the data control
+ * @param[in]  provider_result  Set to @c true if the data control provider successfully processed, \n
+ *                              otherwise set to @c false
+ * @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);
+
+/**
+ * @brief  Called when a response is received for a select operation from an application using the SQL-friendly interface based data control.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks  @a enumerator will be removed after this callback is called.
+ *
+ * @param[in]  request_id       The request ID
+ * @param[in]  provider         The provider handle
+ * @param[in]  enumerator       The enumerator for navigating the result of data control select request
+ * @param[in]  provider_result  Set to @c true if the data control provider successfully processed, \n
+ *                              otherwise set to @c false
+ * @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);
+
+/**
+ * @brief  Called when a response is received for an update operation from an application using the SQL-friendly interface based data control.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  request_id       The request ID
+ * @param[in]  provider         The provider handle
+ * @param[in]  provider_result  Set to @c true if the data control provider successfully processed, \n
+ *                              otherwise set to @c false
+ * @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);
+
+/**
+ * @brief  The structure type to contain the set of callback functions for handling the response events
+ *         of the SQL-friendly interface based data control.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @see  data_control_sql_select_response_cb()
+ * @see  data_control_sql_insert_response_cb()
+ * @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. */
+} data_control_sql_response_cb;
+
+/**
+ * @brief  Creates a provider handle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks The following example demonstrates how to use the %data_control_sql_create() method:
+ *
+ * @code
+ *
+ *  int main()
+ *  {
+ *      const char *provider_id = "http://tizen.org/datacontrol/provider/example";
+ *      const char *data_id = "table";
+ *      data_control_h provider;
+ *      int result = 0;
+ *
+ *      result = data_control_sql_create(&provider);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Creating data control provider is failed with error: %d", result);
+ *          return result;
+ *      }
+ *
+ *      result = data_control_sql_set_provider_id(provider, provider_id);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Setting providerID is failed with error: %d", result);
+ *          return result;
+ *      }
+ *
+ *      result = data_control_sql_set_data_id(provider, data_id);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Setting dataID is failed with error: %d", result);
+ *          return result;
+ *      }
+ *
+ *      // Executes some operations
+ *
+ *      result = data_control_sql_destroy(provider);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Destroying data control provider is failed with error: %d", result);
+ *      }
+ *
+ *      return result;
+ *  }
+ *
+ * @endcode
+
+ * @param[out]  provider  The provider handle
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ *
+ * @see  data_control_sql_destroy()
+ */
+int data_control_sql_create(data_control_h *provider);
+
+/**
+ * @brief  Destroys the provider handle and releases all its resources.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks  When operations of data control are finished, this function must be called to prevent the memory leak.
+ *
+ * @param[in]  provider  The provider handle
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @see data_control_sql_create()
+ */
+int data_control_sql_destroy(data_control_h provider);
+
+/**
+ * @brief  Sets the Provider ID.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  provider     The provider handle
+ * @param[in]  provider_id  The data control provider ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ *
+ * @see  data_control_sql_get_provider_id()
+ */
+int data_control_sql_set_provider_id(data_control_h provider, const char *provider_id);
+
+/**
+ * @brief  Gets the Provider ID.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks  You must release @a provider_id using free() after it is used.
+ *
+ * @param[in]   provider     The provider handle
+ * @param[out]  provider_id  The data control provider ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ *
+ * @see  data_control_sql_set_provider_id()
+ */
+int data_control_sql_get_provider_id(data_control_h provider, char **provider_id);
+
+/**
+ * @brief  Sets the data ID.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  provider  The provider handle
+ * @param[in]  data_id   A string for identifying a specific table to operate \n
+ *                       The string consists of one or more components separated by a slash('/').
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ *
+ * @see  data_control_sql_get_data_id()
+ */
+int data_control_sql_set_data_id(data_control_h provider, const char *data_id);
+
+/**
+ * @brief  Gets the data ID.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks You must release @a data_id using free() after it is used.
+ *
+ * @param[in]   provider  The provider handle
+ * @param[out]  data_id   A string for identifying a specific table to operate \n
+ *                        The string consists of one or more components separated by a slash('/').
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE               Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY      Out of memory
+ *
+ * @see  data_control_sql_set_data_id()
+ */
+int data_control_sql_get_data_id(data_control_h provider, char **data_id);
+
+/**
+ * @brief  Registers a callback function for the SQL data control response.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * remarks The application is notified when a data control response is received from the @a provider.
+ *
+ * @param[in]  provider  The provider handle
+ * @param[in]  callback  The callback function to be called when a response is received
+ * @param[in]  user_data The user data to be passed to the callback function
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE          Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR      I/O error
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see  data_control_sql_unregister_response_cb()
+ */
+int data_control_sql_register_response_cb(data_control_h provider, data_control_sql_response_cb* callback, void *user_data);
+
+/**
+ * @brief  Unregisters the callback function in the @a provider.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  provider  The provider handle
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ */
+int data_control_sql_unregister_response_cb(data_control_h provider);
+
+/**
+ * @brief  Deletes rows of a table owned by the SQL-type data control provider.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel   public
+ * @privilege   %http://tizen.org/privilege/datasharing \n
+ *              %http://tizen.org/privilege/appmanager.launch
+ *
+ * @remarks If you want to use this api, you must add privileges.
+ * @remarks If the value is a string, then the value must be wrapped in single quotes, else it does not need to be wrapped in single quotes.
+ * @remarks The following example demonstrates how to use the %data_control_sql_delete() method:
+ *
+ * @code
+ *
+ *  void sql_delete_response_cb(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) {
+ *      if (provider_result) {
+ *          dlog_print(DLOG_INFO, LOG_TAG, The delete operation is successful");
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "The delete operation for the request %d is failed. error message: %s", request_id, error);
+ *      }
+ *  }
+ *
+ *  data_control_sql_response_cb sql_callback;
+ *
+ *  int main()
+ *  {
+ *      const char *where = "group = 'friend'";
+ *      int result = 0;
+ *      int req_id = 0;
+ *
+ *      sql_callback.delete_cb = sql_delete_response_cb;
+ *      result = data_control_sql_register_response_cb(provider, &sql_callback, void *user_data);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
+ *          return result;
+ *      }
+ *
+ *      result = data_control_sql_delete(provider, where, &req_id);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Deleting is failed with error: %d", result);
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
+ *      }
+ *
+ *      return result;
+ *  }
+ *
+ * @endcode
+ *
+ * @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[out]  request_id  The request ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ * @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
+ */
+int data_control_sql_delete(data_control_h provider, const char *where, int *request_id);
+
+/**
+ * @brief  Inserts new rows in a table owned by the SQL-type data control provider.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel   public
+ * @privilege   %http://tizen.org/privilege/datasharing \n
+ *              %http://tizen.org/privilege/appmanager.launch
+ *
+ * @remarks If you want to use this api, you must add privileges.
+ * @remarks The following example demonstrates how to use the %data_control_sql_insert() method:
+ *
+ * @code
+ *
+ *  void sql_insert_response_cb(int request_id, data_control_h provider, long long inserted_row_id, bool provider_result, const char *error, void *user_data) {
+ *      if (provider_result) {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "The insert operation is successful");
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "The insert operation for the request %d is failed. error message: %s", request_id, error);
+ *      }
+ *  }
+ *
+ *  data_control_sql_response_cb sql_callback;
+ *
+ *  int main()
+ *  {
+ *      int result = 0;
+ *      int req_id = 0;
+ *      bundle *b = NULL;
+ *
+ *      sql_callback.insert_cb = sql_insert_response_cb;
+ *      result = data_control_sql_register_response_cb(provider, &sql_callback, void *user_data);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
+ *          return result;
+ *      }
+ *
+ *      b = bundle_create();
+ *      bundle_add_str(b, "WORD", "test");
+ *      bundle_add_str(b, "WORD_DESC", "test description");
+ *
+ *      result = data_control_sql_insert(provider, b, &req_id);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Inserting is failed with error: %d", result);
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
+ *      }
+ *
+ *      bundle_free(b);
+ *      return result;
+ *  }
+ *
+ * @endcode
+
+ * @param[in]   provider     The provider handle
+ * @param[in]   insert_data  The column-value pairs to insert\ n
+ *                           If the value is a string, then the value must be wrapped in single quotes,
+ *                           else it does not need to be wrapped in single quotes.
+ * @param[out]  request_id   The request ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ * @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
+ */
+int data_control_sql_insert(data_control_h provider, const bundle* insert_data, int *request_id);
+
+/**
+ * @brief  Selects the specified columns to be queried.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel   public
+ * @privilege   %http://tizen.org/privilege/datasharing \n
+ *              %http://tizen.org/privilege/appmanager.launch
+ *
+ * @remarks If you want to use this api, you must add privileges.
+ * @remarks The following example demonstrates how to use the %data_control_sql_select() method:
+ * @remarks If more than 20 rows are selected, only first 20 rows are included in select result.
+ *
+ * @code
+ *
+ *  void sql_select_response_cb(int request_id, data_control_h provider, result_set_cursor *enumerator, bool provider_result, const char *error, void *user_data) {
+ *      if (provider_result) {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "The select operation is successful");
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "The select operation for the request %d is failed. error message: %s", request_id, error);
+ *      }
+ *  }
+ *
+ *  data_control_sql_response_cb sql_callback;
+ *
+ *  int main()
+ *  {
+ *      int result = 0;
+ *      int req_id = 0;
+ *      char *column_list[2];
+ *      column_list[0] = "WORD";
+ *      column_list[1] = "WORD_DESC";
+ *      const char *where = "WORD = 'test'";
+ *      const char *order = "WORD ASC";
+ *
+ *      sql_callback.select_cb = sql_select_response_cb;
+ *      result = data_control_sql_register_response_cb(provider, &sql_callback, void *user_data);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
+ *          return result;
+ *      }
+ *
+ *      result = data_control_sql_select(provider, column_list, 2, where, order, &req_id);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Selecting is failed with error: %d", result);
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
+ *      }
+ *
+ *      return result;
+ *  }
+ *
+ * @endcode
+
+
+ * @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]   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.
+ * @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[out]  request_id    The request ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ * @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
+ */
+int data_control_sql_select(data_control_h provider, char **column_list, int column_count, const char *where, const char *order, int *request_id);
+
+/**
+ * @brief  Selects the specified columns to be queried.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel   public
+ * @privilege   %http://tizen.org/privilege/datasharing \n
+ *              %http://tizen.org/privilege/appmanager.launch
+ *
+ * @remarks  If you want to use this api, you must add privileges.
+ *
+ * @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]   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.
+ * @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]   page_number     The page number of the result set \n
+ *                              It starts from @c 1.
+ * @param[in]   count_per_page  The desired maximum count of rows on a page. 1024 is the maximum value of count_per_page.
+ * @param[out]  request_id      The request ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ * @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
+ * @see  data_control_sql_select()
+ */
+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);
+
+/**
+ * @brief  Updates values of a table owned by the SQL-type data control provider.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel   public
+ * @privilege   %http://tizen.org/privilege/datasharing \n
+ *              %http://tizen.org/privilege/appmanager.launch
+ *
+ * @remarks If you want to use this api, you must add privileges.
+ * @remarks The following example demonstrates how to use the %data_control_sql_update() method:
+ *
+ * @code
+ *
+ *  void sql_update_response_cb(int request_id, data_control_h provider, bool provider_result, const char *error, void *user_data) {
+ *      if (provider_result) {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "The update operation is successful");
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "The update operation for the request %d is failed. error message: %s", request_id, error);
+ *      }
+ *  }
+ *
+ *  data_control_sql_response_cb sql_callback;
+ *
+ *  int main()
+ *  {
+ *      int result = 0;
+ *      int req_id = 0;
+ *      const char *where = "WORD = 'test'";
+ *      bundle *b = NULL;
+ *
+ *      sql_callback.update_cb = sql_update_response_cb;
+ *      result = data_control_sql_register_response_cb(provider, &sql_callback, void *user_data);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
+ *          return result;
+ *      }
+ *
+ *      b = bundle_create();
+ *      bundle_add_str(b, "WORD", "test_new");
+ *
+ *      result = data_control_sql_update(provider, b, where, &req_id);
+ *      if (result != DATA_CONTROL_ERROR_NONE) {
+ *          dlog_print(DLOG_ERROR, LOG_TAG, "Updating is failed with error: %d", result);
+ *      }
+ *      else {
+ *          dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
+ *      }
+ *
+ *      bundle_free(b);
+ *      return result;
+ *  }
+ *
+ * @endcode
+ *
+ *
+ * @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[out]  request_id   The request ID
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ * @retval #DATA_CONTROL_ERROR_PERMISSION_DENIED Permission denied
+ */
+int data_control_sql_update(data_control_h provider, const bundle* update_data, const char *where, int *request_id);
+
+/**
+* @}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_APPFW__DATA_CONTROL_SQL_H__ */
diff --git a/include/data_control_sql_cursor.h b/include/data_control_sql_cursor.h
new file mode 100755 (executable)
index 0000000..ab08510
--- /dev/null
@@ -0,0 +1,313 @@
+//
+// 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.
+//
+
+#ifndef __TIZEN_APPFW_DATA_CONTROL_SQL_ENUMERATOR_H_
+#define __TIZEN_APPFW_DATA_CONTROL_SQL_ENUMERATOR_H_
+
+#include <stdio.h>
+#include "data_control_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file   data_control_sql_cursor.h
+ * @brief  This is the header file for the cursor of the SQL-friendly interface based data control.
+ */
+
+/**
+ * @addtogroup CAPI_DATA_CONTROL_CONSUMER_MODULE
+ * @{
+ */
+
+/**
+ * @brief   The structure type to represent a SQL result set.
+ * @details This type can be used to enumerate through the result set of an SQL query.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+typedef struct result_set_s *result_set_cursor;
+
+/**
+ * @brief  Moves the cursor to the first position.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks The following example demonstrates how to use the %data_control_sql_step_first() method:
+ *
+ * @code
+ *
+ *  void sql_select_response_cb(int request_id, data_control_h provider, result_set_cursor cursor, bool provider_result, const char *error)
+ *  {
+ *      char person_name[32] = {0,};
+ *      long long person_number = -1;
+ *
+ *      data_control_sql_step_first(cursor);
+ *      data_control_sql_get_text_data(cursor, 0, person_name);
+ *      data_control_sql_get_int64_data(cursor, 1, &person_number);
+ *      printf("The person %s has the number %l", person_name, person_number);
+ *  }
+ *
+ * @endcode
+
+ * @param[in]  cursor  The cursor that navigates the result of the request for the select operation
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE          Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR      I/O error
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_sql_step_first(result_set_cursor cursor);
+
+/**
+ * @brief  Moves the cursor to the last position.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks The following example demonstrates how to use the %data_control_sql_step_last() method:
+ *
+ * @code
+ *
+ *  void sql_select_response_cb(int request_id, data_control_h provider, result_set_cursor cursor, bool provider_result, const char *error)
+ *  {
+ *      char person_name[32] = {0,};
+ *      long long person_number = -1;
+ *
+ *      data_control_sql_step_last(cursor);
+ *      data_control_sql_get_text_data(cursor, 0, person_name);
+ *      data_control_sql_get_int64_data(cursor, 1, &person_number);
+ *      printf("The person %s has the number %l", person_name, person_number);
+ *  }
+ *
+ * @endcode
+
+ * @param[in]  cursor  The cursor that navigates the result of data control select request
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE          Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR      I/O error
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_sql_step_last(result_set_cursor cursor);
+
+/**
+ * @brief  Moves the cursor to the next position.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks The following example demonstrates how to use the %data_control_sql_step_next() method:
+ *
+ * @code
+ *
+ *  void sql_select_response_cb(int request_id, data_control_h provider, result_set_cursor cursor, bool provider_result, const char *error)
+ *  {
+ *      char person_name[32] = {0,};
+ *      long long person_number = -1;
+ *      while (data_control_sql_step_next(cursor) == DATA_CONTROL_ERROR_NONE) {
+ *          data_control_sql_get_text_data(cursor, 0, person_name);
+ *          data_control_sql_get_int64_data(cursor, 1, &person_number);
+ *          printf("The person %s has the number %l", person_name, person_number);
+ *      }
+ *  }
+ *
+ * @endcode
+ *
+ * @param[in]  cursor  The cursor that navigates the result of the request for the select operation
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE          Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR      I/O error
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_sql_step_next(result_set_cursor cursor);
+
+/**
+ * @brief  Moves the cursor to the previous position.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  cursor  The cursor that navigates the result of the request for the select operation
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_sql_step_previous(result_set_cursor cursor);
+
+/**
+ * @brief  Gets the number of columns for this cursor.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  cursor  The cursor that navigates the result of the request for the select operation
+ *
+ * @return  The number of columns in the calling cursor
+ */
+int data_control_sql_get_column_count(result_set_cursor cursor);
+
+/**
+ * @brief  Gets the name of the column indicated by the specified index.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]   cursor        The cursor that 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. You should provide a buffer for the column name. The limit of column name length is 4096 bytes.
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE     Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_sql_get_column_name(result_set_cursor cursor, int column_index, char *name);
+
+/**
+ * @brief  Gets the size of the data in the column indicated by the specified index.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  cursor        The cursor that 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, then a negative value is returned.
+ *
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_sql_get_column_item_size(result_set_cursor cursor, int column_index);
+
+/**
+ * @brief  Gets the type of the column indicated by the specified index.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]   cursor        The cursor that 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  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE     Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_sql_get_column_item_type(result_set_cursor cursor, int column_index, data_control_sql_column_type_e* type);
+
+/**
+ * @brief  Gets a blob data from the column indicated by the specified index.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]   cursor        The cursor that 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  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_MAX_EXCEEDED      Too long argument
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_sql_get_blob_data(result_set_cursor cursor, int column_index, void *data, int size);
+
+/**
+ * @brief  Gets an int value from the column indicated by the specified index.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]   cursor        The cursor that 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  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_sql_get_int_data(result_set_cursor cursor, int column_index, int *data);
+
+/**
+ * @brief  Gets a long long value from the column indicated by the specified index.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]   cursor        The cursor that 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  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_sql_get_int64_data(result_set_cursor cursor, int column_index, long long *data);
+
+/**
+ * @brief  Gets a double value from the column indicated by the specified index.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]   cursor        The cursor that 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  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int data_control_sql_get_double_data(result_set_cursor cursor, int column_index, double *data);
+
+/**
+ * @brief  Gets a text value from the column indicated by the specified index.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]   cursor        The cursor that 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. You should provide a buffer for the data. You can get the size of data via data_control_sql_get_column_item_size().
+ *
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ *
+ * @retval #DATA_CONTROL_ERROR_NONE              Successful
+ * @retval #DATA_CONTROL_ERROR_IO_ERROR          I/O error
+ * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY     Out of memory
+ */
+int data_control_sql_get_text_data(result_set_cursor cursor, int column_index, char *data);
+
+/**
+* @}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_APPFW_DATA_CONTROL_SQL_ENUMERATOR_H_ */
+
diff --git a/include/data_control_types.h b/include/data_control_types.h
new file mode 100755 (executable)
index 0000000..9e0ec1a
--- /dev/null
@@ -0,0 +1,71 @@
+//
+// 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.
+//
+
+#ifndef __TIZEN_APPFW__DATA_CONTROL_TYPES_H__
+#define __TIZEN_APPFW__DATA_CONTROL_TYPES_H__
+
+#include <tizen.h>
+
+/**
+ * @file    data_control_types.h
+ * @brief   This is the header file for data types of the data-control.
+ */
+
+/**
+ * @addtogroup CAPI_DATA_CONTROL_MODULE
+ * @{
+ */
+
+/**
+ * @brief The structure type for the provider handle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+typedef struct data_control_s *data_control_h;
+
+/**
+ * @brief Enumeration for different types of columns in a SQL table.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+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;
+
+/**
+* @}
+*/
+
+#endif /* __TIZEN_APPFW__DATA_CONTROL_TYPES_H__ */
+
diff --git a/packaging/capi-data-control.manifest b/packaging/capi-data-control.manifest
new file mode 100644 (file)
index 0000000..97e8c31
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
diff --git a/packaging/capi-data-control.spec b/packaging/capi-data-control.spec
new file mode 100644 (file)
index 0000000..10e60f3
--- /dev/null
@@ -0,0 +1,72 @@
+Name:          capi-data-control
+Summary:       Data Control managed library
+Version:       1.2.2.3
+Release:    2
+Group:         Application Framework/Libraries
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+Source1001:    %{name}.manifest
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(bundle)
+BuildRequires:  pkgconfig(data-control)
+BuildRequires:  pkgconfig(libsmack)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(capi-base-common)
+
+# runtime requires
+Requires: data-control
+
+Requires(post): /sbin/ldconfig
+Requires(post): coreutils
+Requires(postun): /sbin/ldconfig
+
+Provides:   lib%{name}.so.1
+
+%description
+Data Control managed library
+
+%package devel
+Summary:  Data Control managed library (Development)
+Group:    Application Framework/Development
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+Data Control managed library (DEV)
+
+%prep
+%setup -q
+cp %{SOURCE1001} .
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+
+%if 0%{?sec_build_binary_debug_enable}
+       CXXFLAGS="$CXXFLAGS -D_SECURE_LOG -DTIZEN_DEBUG_ENABLE"
+%endif
+
+%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+
+# Call make instruction with smp support
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+install LICENSE.Apache-2.0 %{buildroot}/usr/share/license/%{name}
+
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%{_libdir}/lib%{name}.so*
+%manifest %{name}.manifest
+/usr/share/license/%{name}
+
+%files devel
+%{_includedir}/appfw/*.h
+%{_libdir}/pkgconfig/*.pc
+%{_libdir}/lib%{name}.so
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..80091ba
--- /dev/null
@@ -0,0 +1,64 @@
+SET(this_target "capi-data-control")
+
+INCLUDE_DIRECTORIES (
+       ${CMAKE_SOURCE_DIR}/include
+       /usr/include/dlog
+       /usr/include/glib-2.0
+       /usr/lib/glib-2.0/include
+       )
+
+SET (${this_target}_SOURCE_FILES
+       data_control_internal.c
+       data_control_map.c
+       data_control_sql.c
+       data_control_sql_cursor.c
+       data_control_provider.c
+       )
+
+SET(requires "data-control dlog glib-2.0 capi-base-common bundle libsmack")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${this_target} REQUIRED ${requires})
+
+FOREACH(flag ${${this_target}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -fPIC -Wall -Werror -fvisibility=hidden")
+
+## SET C COMPILER FLAGS
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+## SET CPP COMPILER FLAGS
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## SET LINKER FLAGS
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed")
+
+## Create Library
+ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+TARGET_LINK_LIBRARIES(${this_target} ${${this_target}_LDFLAGS})
+
+SET_TARGET_PROPERTIES(${this_target}
+       PROPERTIES
+       VERSION ${FULLVER}
+       SOVERSION ${MAJORVER}
+       CLEAN_DIRECT_OUTPUT 1
+       )
+
+# pkgconfig file
+SET(PC_NAME ${this_target})
+SET(PACKAGE_DESCRIPTION "Data Control managed library")
+SET(VERSION ${FULLVER})
+SET(PC_REQUIRED ${requires})
+SET(PC_LDFLAGS "-l${this_target}")
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/${this_target}.pc.in ${CMAKE_SOURCE_DIR}/${this_target}.pc @ONLY)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/${this_target}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+
+# install
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/appfw FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/ DESTINATION ${LIB_INSTALL_DIR}
+               FILES_MATCHING PATTERN "*.so*"
+               PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
+                    GROUP_EXECUTE GROUP_READ
+                    WORLD_EXECUTE WORLD_READ)
diff --git a/src/data_control_internal.c b/src/data_control_internal.c
new file mode 100644 (file)
index 0000000..aa039ce
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2011 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 <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <unistd.h>
+
+#include <sys/smack.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include "data_control_internal.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "CAPI_APPFW_DATA_CONTROL"
+
+#define _LOGE(fmt, arg...) LOGE(fmt,##arg)
+#define _LOGD(fmt, arg...) LOGD(fmt, ##arg)
+
+static const char *data_control_error_to_string(data_control_error_e error)
+{
+       switch (error) {
+               case DATA_CONTROL_ERROR_NONE:
+                       return "NONE";
+               case DATA_CONTROL_ERROR_INVALID_PARAMETER:
+                       return "INVALID_PARAMETER";
+               case DATA_CONTROL_ERROR_OUT_OF_MEMORY:
+                       return "OUT_OF_MEMORY";
+               case DATA_CONTROL_ERROR_IO_ERROR:
+                       return "IO_ERROR";
+               case DATA_CONTROL_ERROR_PERMISSION_DENIED:
+                       return "PERMISSION_DENIED";
+               case DATA_CONTROL_ERROR_MAX_EXCEEDED:
+                       return "Too long argument";
+               default:
+                       return "UNKNOWN";
+       }
+}
+
+int convert_to_tizen_error(datacontrol_error_e error)
+{
+       switch (error) {
+               case DATACONTROL_ERROR_NONE:
+                       return DATA_CONTROL_ERROR_NONE;
+               case DATACONTROL_ERROR_INVALID_PARAMETER:
+                       return DATA_CONTROL_ERROR_INVALID_PARAMETER;
+               case DATACONTROL_ERROR_OUT_OF_MEMORY:
+                       return DATA_CONTROL_ERROR_OUT_OF_MEMORY;
+               case DATACONTROL_ERROR_IO_ERROR:
+                       return DATA_CONTROL_ERROR_IO_ERROR;
+               case DATACONTROL_ERROR_PERMISSION_DENIED:
+                       return DATA_CONTROL_ERROR_PERMISSION_DENIED;
+               case DATACONTROL_ERROR_MAX_EXCEEDED:
+                       return DATA_CONTROL_ERROR_MAX_EXCEEDED;
+               default:
+                       return error;
+       }
+}
+
+int data_control_error(data_control_error_e error,
+               const char *function, const char *description)
+{
+       if (description) {
+               _LOGE("[%s] %s(0x%08x) : %s", function,
+                               data_control_error_to_string(error), error,
+                               description);
+       } else {
+               _LOGE("[%s] %s(0x%08x)", function,
+                               data_control_error_to_string(error), error);
+       }
+
+       return error;
+}
+
+
+int check_privilege(privilege_type type)
+{
+       int fd = 0;
+       int ret = 0;
+       char subject_label[SMACK_LABEL_LEN + 1] = "";
+
+       fd = open("/proc/self/attr/current", O_RDONLY);
+       if (fd < 0) {
+               _LOGE("open [%d] failed!", errno);
+               return DATA_CONTROL_ERROR_IO_ERROR;
+       }
+
+       ret = read(fd, subject_label, SMACK_LABEL_LEN);
+       if (ret < 0) {
+               _LOGE("read [%d] failed!", errno);
+               close(fd);
+               return DATA_CONTROL_ERROR_IO_ERROR;
+       }
+       close(fd);
+
+       _LOGD("subject_label : %s", subject_label);
+       if (type == PRIVILEGE_DATA_SHARING) {
+               ret = smack_have_access(subject_label,
+                               "security-server::api-open-for-privileged", "rw");
+               if (ret == 1) {
+                       _LOGD("permission allowed");
+                       return DATA_CONTROL_ERROR_NONE;
+               } else if (ret == -1) {
+                       _LOGE("smack_have_access() fail");
+                       return DATA_CONTROL_ERROR_IO_ERROR;
+               } else if (ret == 0) {
+                       _LOGD("permission denied");
+                       return DATA_CONTROL_ERROR_PERMISSION_DENIED;
+               }
+       } else if (type == PRIVILEGE_APP_MANAGER_LAUNCH) {
+               ret = smack_have_access(subject_label, "aul::launch", "x");
+               if (ret == 1) {
+                       _LOGD("permission allowed");
+                       return DATA_CONTROL_ERROR_NONE;
+               } else if (ret == -1) {
+                       _LOGE("smack_have_access() fail");
+                       return DATA_CONTROL_ERROR_IO_ERROR;
+               } else if (ret == 0) {
+                       _LOGD("permission denied");
+                       return DATA_CONTROL_ERROR_PERMISSION_DENIED;
+               }
+
+               ret = smack_have_access(subject_label, "app-svc::db", "rwxa");
+               if (ret == 1) {
+                       _LOGD("permission allowed");
+                       return DATA_CONTROL_ERROR_NONE;
+               } else if (ret == -1) {
+                       _LOGE("smack_have_access() fail");
+                       return DATA_CONTROL_ERROR_IO_ERROR;
+               } else if (ret == 0) {
+                       _LOGD("permission denied");
+                       return DATA_CONTROL_ERROR_PERMISSION_DENIED;
+               }
+       }
+
+       return DATA_CONTROL_ERROR_IO_ERROR;
+}
diff --git a/src/data_control_log.h b/src/data_control_log.h
new file mode 100644 (file)
index 0000000..29165fc
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_APPFW_DATA_CONTROL_LOG_H__
+#define __TIZEN_APPFW_DATA_CONTROL_LOG_H__
+
+#include <dlog.h>
+
+#ifdef __GNUC__
+#   ifndef EXPORT_API
+#       define EXPORT_API __attribute__((visibility("default")))
+#   endif
+#else
+#   define EXPORT_API
+#endif
+
+#undef LOG_TAG
+#define LOG_TAG "DATA_CONTROL"
+
+#define _LOGE(fmt, arg...) LOGE(fmt, ##arg)
+#define _LOGI(fmt, arg...) LOGI(fmt, ##arg)
+
+#define _SECURE_LOGE(fmt, arg...) SECURE_LOGE(fmt, ##arg)
+#define _SECURE_LOGI(fmt, arg...) SECURE_LOGI(fmt, ##arg)
+
+#endif /* __TIZEN_APPFW_DATA_CONTROL_LOG_H__ */
diff --git a/src/data_control_map.c b/src/data_control_map.c
new file mode 100644 (file)
index 0000000..c2c3924
--- /dev/null
@@ -0,0 +1,273 @@
+#include <dlog.h>
+#include <bundle.h>
+#include <errno.h>
+#include <glib.h>
+#include <stdbool.h>
+#include <stdlib.h>
+
+#include <data-control-map.h>
+#include "data_control_internal.h"
+#include "data_control_map.h"
+#include "data_control_log.h"
+
+#define MAX_DATA_COUNT 1024
+
+struct data_control_s {
+       char *provider_id;
+       char *data_id;
+};
+
+struct datacontrol_s {
+       char *provider_id;
+       char *data_id;
+};
+
+
+static GHashTable *response_table = NULL;
+
+datacontrol_map_response_cb datacontrol_map_cb;
+
+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);
+       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)
+{
+       _LOGI("map_set_response");
+
+       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)
+{
+       _LOGI("map_add_response");
+
+       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)
+{
+       _LOGI("map_remove_response");
+
+       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)
+{
+       if (data)
+       {
+               g_free(data);
+               data = NULL;
+       }
+}
+
+static void
+__initialize(void)
+{
+       response_table = g_hash_table_new_full(g_str_hash, g_str_equal, __free_data, __free_data);
+
+       datacontrol_map_cb.get = __map_get_response;
+       datacontrol_map_cb.set = __map_set_response;
+       datacontrol_map_cb.add = __map_add_response;
+       datacontrol_map_cb.remove = __map_remove_response;
+}
+
+EXPORT_API int
+data_control_map_create(data_control_h *provider)
+{
+       return convert_to_tizen_error(datacontrol_map_create((datacontrol_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)
+{
+       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)
+{
+       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)
+{
+       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)
+{
+       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)
+{
+
+       if (response_table == NULL)
+       {
+               __initialize();
+       }
+
+       if (callback == NULL)
+       {
+               return DATA_CONTROL_ERROR_INVALID_PARAMETER;
+       }
+
+       char *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));
+       if (cb == NULL)
+       {
+               free(id);
+               return DATA_CONTROL_ERROR_OUT_OF_MEMORY;
+       }
+
+       memcpy(cb, callback, sizeof(data_control_map_response_cb));
+       g_hash_table_insert(response_table, id, cb);
+
+       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)
+{
+       if (provider->provider_id)
+       {
+               g_hash_table_remove(response_table, provider->provider_id);
+       }
+
+       return convert_to_tizen_error(datacontrol_map_unregister_response_cb((datacontrol_h)provider));
+}
+
+EXPORT_API int
+data_control_map_get(data_control_h provider, const char *key, int *request_id)
+{
+       int retval;
+
+       retval = check_privilege(PRIVILEGE_DATA_SHARING);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       retval = check_privilege(PRIVILEGE_APP_MANAGER_LAUNCH);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       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)
+{
+       int retval;
+
+       if (count_per_page > MAX_DATA_COUNT)
+       {
+               return DATA_CONTROL_ERROR_INVALID_PARAMETER;
+       }
+
+       retval = check_privilege(PRIVILEGE_DATA_SHARING);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       retval = check_privilege(PRIVILEGE_APP_MANAGER_LAUNCH);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       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)
+{
+       int retval;
+
+       retval = check_privilege(PRIVILEGE_DATA_SHARING);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       retval = check_privilege(PRIVILEGE_APP_MANAGER_LAUNCH);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+       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)
+{
+       int retval;
+
+       retval = check_privilege(PRIVILEGE_DATA_SHARING);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       retval = check_privilege(PRIVILEGE_APP_MANAGER_LAUNCH);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       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)
+{
+       int retval;
+
+       retval = check_privilege(PRIVILEGE_DATA_SHARING);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       retval = check_privilege(PRIVILEGE_APP_MANAGER_LAUNCH);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       return convert_to_tizen_error(datacontrol_map_remove((datacontrol_h)provider, key, value, request_id));
+}
diff --git a/src/data_control_provider.c b/src/data_control_provider.c
new file mode 100644 (file)
index 0000000..995cd3e
--- /dev/null
@@ -0,0 +1,630 @@
+#include <stdlib.h>
+
+#include <dlog.h>
+#include <bundle.h>
+
+#include <data-control-provider.h>
+
+#include "data_control_provider.h"
+#include "data_control_sql.h"
+#include "data_control_log.h"
+#include "data_control_internal.h"
+
+#define INSERT_STMT_CONST_LEN 25
+#define DELETE_STMT_CONST_LEN 12
+#define UPDATE_STMT_CONST_LEN 15
+#define SELECT_STMT_CONST_LEN 13
+#define WHERE_COND_CONST_LEN 7
+#define ORDER_CLS_CONST_LEN 10
+
+struct data_control_s {
+       char *provider_id;
+       char *data_id;
+};
+
+struct datacontrol_s {
+       char *provider_id;
+       char *data_id;
+};
+
+typedef struct
+{
+       int no_of_elements;
+       int length;
+       char** keys;
+       char** vals;
+}key_val_pair;
+
+static data_control_provider_sql_cb sql_provider_callback;
+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)
+{
+       _LOGI("sql_insert_request");
+
+       if (sql_provider_callback.insert_cb)
+       {
+               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)
+{
+       _LOGI("sql_update_request");
+
+       if (sql_provider_callback.update_cb)
+       {
+               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)
+{
+       _LOGI("sql_delete_request");
+
+       if (sql_provider_callback.delete_cb)
+       {
+               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)
+{
+       _LOGI("sql_select_request");
+
+       if (sql_provider_callback.select_cb)
+       {
+               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)
+{
+       _LOGI("map_get_request");
+
+       if (map_provider_callback.get_cb)
+       {
+               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)
+{
+       _LOGI("map_set_request");
+
+       if (map_provider_callback.set_cb)
+       {
+               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)
+{
+       _LOGI("map_add_request");
+
+       if (map_provider_callback.add_cb)
+       {
+               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)
+{
+       _LOGI("map_remove_request");
+
+       if (map_provider_callback.remove_cb)
+       {
+               map_provider_callback.remove_cb(request_id, (data_control_h)provider, key, value, user_data);
+       }
+}
+
+EXPORT_API int
+data_control_provider_sql_register_cb(data_control_provider_sql_cb *callback, void *user_data)
+{
+       int retval;
+
+       retval = check_privilege(PRIVILEGE_DATA_SHARING);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       if (!callback)
+               return DATA_CONTROL_ERROR_INVALID_PARAMETER;
+
+       sql_provider_callback = *callback;
+
+       sql_internal_callback.insert = __sql_insert_request_cb;
+       sql_internal_callback.update = __sql_update_request_cb;
+       sql_internal_callback.delete = __sql_delete_request_cb;
+       sql_internal_callback.select = __sql_select_request_cb;
+
+       return datacontrol_provider_sql_register_cb(&sql_internal_callback, user_data);
+}
+
+EXPORT_API int
+data_control_provider_sql_unregister_cb(void)
+{
+       memset(&sql_provider_callback, 0, sizeof(data_control_provider_sql_cb));
+
+       return datacontrol_provider_sql_unregister_cb();
+}
+
+EXPORT_API int
+data_control_provider_map_register_cb(data_control_provider_map_cb *callback, void *user_data)
+{
+       int retval;
+
+       retval = check_privilege(PRIVILEGE_DATA_SHARING);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       if (!callback)
+               return DATA_CONTROL_ERROR_INVALID_PARAMETER;
+
+       map_provider_callback = *callback;
+
+       map_internal_callback.get = __map_get_request_cb;
+       map_internal_callback.set = __map_set_request_cb;
+       map_internal_callback.add = __map_add_request_cb;
+       map_internal_callback.remove = __map_remove_request_cb;
+
+       return datacontrol_provider_map_register_cb(&map_internal_callback, user_data);
+}
+
+EXPORT_API int
+data_control_provider_map_unregister_cb(void)
+{
+       memset(&map_provider_callback, 0, sizeof(data_control_provider_map_cb));
+
+       return datacontrol_provider_map_unregister_cb();
+}
+
+EXPORT_API int
+data_control_provider_get_client_appid(int request_id, char **appid)
+{
+       return datacontrol_provider_get_client_appid(request_id, appid);
+}
+
+EXPORT_API int
+data_control_provider_send_select_result(int request_id, void *db_handle)
+{
+       return datacontrol_provider_send_select_result(request_id, db_handle);
+}
+
+EXPORT_API int
+data_control_provider_send_insert_result(int request_id, long long row_id)
+{
+       return datacontrol_provider_send_insert_result(request_id, row_id);
+}
+
+EXPORT_API int
+data_control_provider_send_update_result(int request_id)
+{
+       return datacontrol_provider_send_update_result(request_id);
+}
+
+EXPORT_API int
+data_control_provider_send_delete_result(int request_id)
+{
+       return datacontrol_provider_send_delete_result(request_id);
+}
+
+EXPORT_API int
+data_control_provider_send_error(int request_id, const char *error)
+{
+       return datacontrol_provider_send_error(request_id, error);
+}
+
+static void bundle_foreach_cb(const char *key, const int type, const bundle_keyval_t *kv, void *user_data)
+{
+       if (!key || !kv || !user_data)
+       {
+               return;
+       }
+
+       key_val_pair* pair = (key_val_pair *)user_data;
+       int 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;
+
+       ++(pair->no_of_elements);
+
+       return;
+}
+
+EXPORT_API char*
+data_control_provider_create_insert_statement(data_control_h provider, bundle *insert_map)
+{
+       int row_count = bundle_get_count(insert_map);
+       if (provider == NULL || row_count == 0)
+       {
+               set_last_result(DATA_CONTROL_ERROR_INVALID_PARAMETER);
+               return NULL;
+       }
+
+       key_val_pair *cols = (key_val_pair *) calloc(sizeof(key_val_pair), 1);
+       if (cols == NULL)
+       {
+               set_last_result(DATA_CONTROL_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
+
+       cols->no_of_elements = 0;
+       cols->length = 0;
+       cols->keys = (char **) calloc(sizeof(char *), row_count);
+       if (cols->keys == NULL)
+       {
+               free(cols);
+               set_last_result(DATA_CONTROL_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
+
+       cols->vals = (char **) calloc(sizeof(char *), row_count);
+       if (cols->vals == NULL)
+       {
+               free(cols->keys);
+               free(cols);
+               set_last_result(DATA_CONTROL_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
+
+       int 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;
+
+       _LOGI("SQL statement length: %d", sql_len);
+
+       char* sql = (char *) calloc(sizeof(char), sql_len);
+       if (sql == NULL)
+       {
+               free(data_id);
+               free(cols->keys);
+               free(cols->vals);
+               free(cols);
+               set_last_result(DATA_CONTROL_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
+       memset(sql, 0, sql_len);
+
+       sprintf(sql, "INSERT INTO %s (", data_id);
+       free(data_id);
+
+       for(index = 0; index < row_count - 1; index++)
+       {
+               strcat(sql, cols->keys[index]);
+               strcat(sql, ", ");
+       }
+
+       strcat(sql, cols->keys[index]);
+       strcat(sql, ") VALUES (");
+
+       for(index = 0; index < row_count - 1; index++)
+       {
+               strcat(sql, cols->vals[index]);
+               strcat(sql, ", ");
+       }
+
+       strcat(sql, cols->vals[index]);
+       strcat(sql, ")");
+
+       _LOGI("SQL statement is: %s", sql);
+
+       for(index = 0; index < row_count; index++)
+       {
+               free(cols->keys[index]);
+               free(cols->vals[index]);
+       }
+       free(cols->keys);
+       free(cols->vals);
+       free(cols);
+
+       return sql;
+}
+
+EXPORT_API char*
+data_control_provider_create_delete_statement(data_control_h provider, const char *where)
+{
+       char* data_id = NULL;
+
+       if (provider == NULL)
+       {
+               set_last_result(DATA_CONTROL_ERROR_INVALID_PARAMETER);
+               return 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 = DELETE_STMT_CONST_LEN + strlen(data_id) + cond_len + 1;
+
+       _LOGI("SQL statement length: %d", sql_len);
+
+       char* sql = (char *) calloc(sizeof(char), sql_len);
+       if (sql == NULL)
+       {
+               free(data_id);
+               set_last_result(DATA_CONTROL_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
+       memset(sql, 0, sql_len);
+
+       sprintf(sql, "DELETE FROM %s", data_id);
+       if (where)
+       {
+               strcat(sql, " WHERE ");
+               strcat(sql, where);
+       }
+
+       _LOGI("SQL statement is: %s", sql);
+
+       free(data_id);
+       return sql;
+}
+
+EXPORT_API char*
+data_control_provider_create_update_statement(data_control_h provider, bundle *update_map, const char *where)
+{
+       int row_count = bundle_get_count(update_map);
+       if (provider == NULL || row_count == 0)
+       {
+               set_last_result(DATA_CONTROL_ERROR_INVALID_PARAMETER);
+               return NULL;
+       }
+
+       key_val_pair *cols = (key_val_pair *) calloc(sizeof(key_val_pair), 1);
+       if (cols == NULL)
+       {
+               set_last_result(DATA_CONTROL_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
+
+       cols->no_of_elements = 0;
+       cols->length = 0;
+       cols->keys = (char **) calloc(sizeof(char *), row_count);
+       if (cols->keys == NULL)
+       {
+               free(cols);
+               set_last_result(DATA_CONTROL_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
+       cols->vals = (char **) calloc(sizeof(char *), row_count);
+       if (cols->vals == NULL)
+       {
+               free(cols->keys);
+               free(cols);
+               set_last_result(DATA_CONTROL_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
+
+       int 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;
+
+       _LOGI("SQL statement length: %d", sql_len);
+
+       char* sql = (char *) calloc(sizeof(char), sql_len);
+       if (sql == NULL)
+       {
+               free(data_id);
+               free(cols->keys);
+               free(cols->vals);
+               free(cols);
+               set_last_result(DATA_CONTROL_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
+       memset(sql, 0, sql_len);
+
+       sprintf(sql, "UPDATE %s SET ", data_id);
+       free(data_id);
+
+       for(index = 0; index < row_count - 1; index++)
+       {
+               strcat(sql, cols->keys[index]);
+               strcat(sql, " = ");
+               strcat(sql, cols->vals[index]);
+               strcat(sql, ", ");
+       }
+
+       strcat(sql, cols->keys[index]);
+       strcat(sql, " = ");
+       strcat(sql, cols->vals[index]);
+
+       if (where)
+       {
+               strcat(sql, " WHERE ");
+               strcat(sql, where);
+       }
+
+       _LOGI("SQL statement is: %s", sql);
+
+       for(index = 0; index < row_count; index++)
+       {
+               free(cols->keys[index]);
+               free(cols->vals[index]);
+       }
+       free(cols->keys);
+       free(cols->vals);
+       free(cols);
+
+       return sql;
+}
+
+EXPORT_API char*
+data_control_provider_create_select_statement(data_control_h provider, const char **column_list, int column_count, const char *where, const char *order)
+{
+       int index = 0;
+       int col_name_length = 0;
+       if (provider == NULL)
+       {
+               set_last_result(DATA_CONTROL_ERROR_INVALID_PARAMETER);
+               return NULL;
+       }
+
+       if (column_list)
+       {
+               for (index = 0; index < column_count; index++)
+               {
+                       col_name_length += strlen(column_list[index]);
+               }
+               if (column_count > 0)
+               {
+                       col_name_length += (column_count - 1) * 2;
+               }
+       }
+       else
+       {
+               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;
+
+       _LOGI("SQL statement length: %d", sql_len);
+
+       char* sql = (char *) calloc(sizeof(char), sql_len);
+       if (sql == NULL)
+       {
+               free(data_id);
+               set_last_result(DATA_CONTROL_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
+       memset(sql, 0, sql_len);
+
+       strcpy(sql, "SELECT ");
+       if (!column_list)
+       {
+               strcat(sql, "*");
+       }
+       else
+       {
+               for (index = 0; index < column_count - 1; index++)
+               {
+                       strcat(sql, column_list[index]);
+                       strcat(sql, ", ");
+               }
+               strcat(sql, column_list[index]);
+       }
+
+       strcat(sql, " FROM ");
+       strcat(sql, data_id);
+
+       if (where)
+       {
+               strcat(sql, " WHERE ");
+               strcat(sql, where);
+       }
+       if (order)
+       {
+               strcat(sql, " ORDER BY ");
+               strcat(sql, order);
+       }
+
+       _LOGI("SQL statement is: %s", sql);
+
+       free(data_id);
+       return sql;
+}
+
+EXPORT_API bool
+data_control_provider_match_provider_id(data_control_h provider, const char *provider_id)
+{
+       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;
+       }
+
+       ret = data_control_sql_get_provider_id(provider, &prov_id);
+       set_last_result(ret);
+       if (ret != DATA_CONTROL_ERROR_NONE)
+       {
+               return false;
+       }
+
+       if (strcmp(prov_id, provider_id) == 0)
+       {
+               free(prov_id);
+               return true;
+       }
+       else
+       {
+               free(prov_id);
+               return false;
+       }
+}
+
+EXPORT_API bool
+data_control_provider_match_data_id(data_control_h provider, const char *data_id)
+{
+       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;
+       }
+
+       ret = data_control_sql_get_data_id(provider, &data);
+       set_last_result(ret);
+       if (ret != DATA_CONTROL_ERROR_NONE)
+       {
+               return false;
+       }
+
+       if (strcmp(data, data_id) == 0)
+       {
+               free(data);
+               return true;
+       }
+       else
+       {
+               free(data);
+               return false;
+       }
+}
+
+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)
+{
+       return datacontrol_provider_send_map_get_value_result(request_id, value_list, value_count);
+}
diff --git a/src/data_control_sql.c b/src/data_control_sql.c
new file mode 100644 (file)
index 0000000..d62daed
--- /dev/null
@@ -0,0 +1,273 @@
+#include <dlog.h>
+#include <bundle.h>
+#include <errno.h>
+#include <glib.h>
+#include <stdbool.h>
+#include <stdlib.h>
+
+#include <data-control-sql.h>
+#include "data_control_internal.h"
+#include "data_control_sql.h"
+#include "data_control_log.h"
+
+#define MAX_ROW_COUNT 1024
+
+struct data_control_s {
+       char *provider_id;
+       char *data_id;
+};
+
+struct datacontrol_s {
+       char *provider_id;
+       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)
+{
+       _LOGI("sql_insert_response");
+
+       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)
+{
+       _LOGI("sql_update_response");
+
+       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)
+{
+       _LOGI("sql_delete_response");
+
+       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)
+{
+       _LOGI("sql_select_response");
+
+       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)
+{
+       if (data)
+       {
+               g_free(data);
+               data = NULL;
+       }
+}
+
+static void
+__initialize(void)
+{
+       response_table = g_hash_table_new_full(g_str_hash, g_str_equal, __free_data, __free_data);
+
+       datacontrol_sql_cb.insert = __sql_insert_response;
+       datacontrol_sql_cb.delete = __sql_delete_response;
+       datacontrol_sql_cb.select = __sql_select_response;
+       datacontrol_sql_cb.update = __sql_update_response;
+}
+
+EXPORT_API int
+data_control_sql_create(data_control_h *provider)
+{
+       return datacontrol_sql_create((datacontrol_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)
+{
+       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)
+{
+       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)
+{
+       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)
+{
+       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)
+{
+       if (response_table == NULL)
+       {
+               __initialize();
+       }
+
+       if (callback == NULL)
+       {
+               return DATA_CONTROL_ERROR_INVALID_PARAMETER;
+       }
+
+       char *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));
+       if (cb == NULL)
+       {
+               free(id);
+               return DATA_CONTROL_ERROR_OUT_OF_MEMORY;
+       }
+
+       memcpy(cb, callback, sizeof(data_control_sql_response_cb));
+       g_hash_table_insert(response_table, id, cb);
+
+       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)
+{
+       if (provider->provider_id)
+       {
+               g_hash_table_remove(response_table, provider->provider_id);
+       }
+
+       return datacontrol_sql_unregister_response_cb((datacontrol_h)provider);
+}
+
+EXPORT_API int
+data_control_sql_insert(data_control_h provider, const bundle* insert_data, int *request_id)
+{
+       int retval;
+
+       retval = check_privilege(PRIVILEGE_DATA_SHARING);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       retval = check_privilege(PRIVILEGE_APP_MANAGER_LAUNCH);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       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)
+{
+       int retval;
+
+       retval = check_privilege(PRIVILEGE_DATA_SHARING);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       retval = check_privilege(PRIVILEGE_APP_MANAGER_LAUNCH);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       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)
+{
+       int retval;
+
+       retval = check_privilege(PRIVILEGE_DATA_SHARING);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       retval = check_privilege(PRIVILEGE_APP_MANAGER_LAUNCH);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       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)
+{
+       int retval;
+
+       if (count_per_page > MAX_ROW_COUNT)
+       {
+               return DATA_CONTROL_ERROR_INVALID_PARAMETER;
+       }
+       retval = check_privilege(PRIVILEGE_DATA_SHARING);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       retval = check_privilege(PRIVILEGE_APP_MANAGER_LAUNCH);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       return datacontrol_sql_select_with_page((datacontrol_h)provider, column_list, column_count, where, order, page_number, count_per_page, 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;
+
+       retval = check_privilege(PRIVILEGE_DATA_SHARING);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       retval = check_privilege(PRIVILEGE_APP_MANAGER_LAUNCH);
+       if (retval != DATA_CONTROL_ERROR_NONE) {
+               return data_control_error(retval, __FUNCTION__, "failed to allow privilege");
+       }
+
+       return datacontrol_sql_update((datacontrol_h)provider, update_data, where, request_id);
+}
+
diff --git a/src/data_control_sql_cursor.c b/src/data_control_sql_cursor.c
new file mode 100644 (file)
index 0000000..cd12bfb
--- /dev/null
@@ -0,0 +1,158 @@
+
+#include <dlog.h>
+#include <data-control-sql-cursor.h>
+
+#include "data_control_sql_cursor.h"
+
+struct result_set_s
+{
+       int result_set_fd;
+       int result_set_row_count;
+       int result_set_col_count;
+       int result_set_col_type_offset;
+       int result_set_col_name_offset;
+       int result_set_content_offset;
+       int result_set_current_offset;
+       int result_set_current_row_count;
+       char* result_set_path;
+};
+
+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);
+}
+
+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);
+}
+
+
+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);
+}
+
+
+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);
+}
+
+
+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);
+}
+
+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);
+}
+
+
+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);
+}
+
+
+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);
+}
+
+
+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);
+}
+
+
+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);
+}
+
+
+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);
+}
+
+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);
+}
+
+
+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);
+}
+