Merge "Remove the memory leak on osp-security-service" into tizen_2.2
[platform/framework/native/appfw.git] / inc / FAppSqlDataControl.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18 * @file       FAppSqlDataControl.h
19 * @brief      This is the header file for the %SqlDataControl class.
20 *
21 * This header file contains the declarations of the %SqlDataControl class.
22 */
23
24 #ifndef _FAPP_SQL_DATA_CONTROL_H_
25 #define _FAPP_SQL_DATA_CONTROL_H_
26
27 #include <FOspConfig.h>
28 #include <FBaseDataType.h>
29 #include <FBaseObject.h>
30
31 namespace Tizen { namespace Base
32 {
33 class String;
34 namespace Collection {
35 class IList;
36 class IMap;
37 }
38 }}
39
40 namespace Tizen { namespace App
41 {
42
43 class _SqlDataControlImpl;
44 class ISqlDataControlResponseListener;
45
46 /**
47  * @class   SqlDataControl
48  * @brief   This class represents the SQL-friendly interface based data control's behavior.
49  *
50  * @since       2.0
51  *
52  * @final   This class is not intended for extension.
53  *
54  * The %SqlDataControl class represents the data control's behavior that provides a standard mechanism
55  * for accessing the specific data exported by other applications.
56  * A data control provider can share its data with data control consumers.
57  *
58  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/app/data_controls.htm">Data Controls</a>.
59  *
60  * @see Tizen::App::AppManager
61  *
62  * @code
63  *
64  * #include <FBase.h>
65  * #include <FIo.h>
66  *
67  * using namespace Tizen::Base;
68  * using namespace Tizen::Io;
69  *
70  * class MySqlDataControlResponseListener:
71  *      : public Tizen::App::ISqlDataControlResponseListener
72  * {
73  * public:
74  *      void OnSqlDataControlInsertResponseReceived(RequestId reqId, const String& providerId, const String& dataId, long long insertRowId, bool providerResult, const String* pErrorMsg)
75  *      {
76  *              AppLog("Row Id = %d", insertRowId);
77  *      }
78  * };
79  *
80  * void
81  * MyClass::Execute(void)
82  * {
83  *              String providerId(L"http://tizen.org/datacontrol/provider/example");
84  *              SqlDataControl* pDc = AppManager::GetSqlDataControlN(providerId);
85  *
86  *              MySqlDataControlResponseListener* pResponseListener = new MySqlDataControlResponseListener();
87  *
88  *              pDc->SetSqlDataControlResponseListener(pResponseListener);
89  *
90  *              String dataId(L"test");
91  *              String person(L"person");
92  *              String number(L"number");
93  *              RequestId reqId;
94  *
95  *              ArrayList columnList(SingleObjectDeleter);
96  *              columnList.Construct();
97  *
98  *              columnList.Add(person);
99  *              columnList.Add(number);
100  *
101  *              String where(L"group = 'friend'");
102  *              String order(L"person ASC");
103  *
104  *              pDc->Select(dataId, &columnList, &where, &order, reqId);
105  * }
106  *
107  * @endcode
108
109  */
110
111 class _OSP_EXPORT_ SqlDataControl
112         : public Tizen::Base::Object
113 {
114
115 public:
116         /**
117         * This destructor overrides Tizen::Base::Object::~Object().
118         *
119         * @since        2.0
120         */
121         virtual ~SqlDataControl(void);
122
123         /**
124         * Selects the specified columns to be queried. @n
125         * The result set of the specified columns is retrieved from a table owned by the SQL-friendly interface based data control provider. @n
126         * The %Select() method is asynchronous.
127         * For receiving the response from the data control provider, set the listener using
128         * the SqlDataControl::SetSqlDataControlResponseListener() method. @n
129         * When the requested result set has been received from the data control provider,
130         * the ISqlDataControlResponseListener::OnSqlDataControlSelectResponseReceived() method is called.
131         *
132         * @since        2.0
133         *
134         * @return               An error code
135         * @param[in]    dataId                          The string that identifies the specific data, usually a database table to query from @n
136         *                                                                       The string consists of one or more components, separated by a slash('/').
137         * @param[in]    pColumnList                     The list of column names to query @n
138         *                                                                       The type of objects contained in the specified @c pColumnList must be
139         *                                                                       Tizen::Base::String @n
140         *                                                                       If the specified @c pColumnList is @c null, all the columns are selected.
141         * @param[in]    pWhere                          The filter to select the desired rows to query @n
142         *                                                                       It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as
143         *                                                                       column1 = 'stringValue' AND column2 = numericValue @n
144         *                                                                       If the value is a string, the value must be wrapped in single quotes,
145         *                                                                       otherwise it need not be wrapped in single quotes @n
146         *                                                                       For more information on the SQL statement, see SQLite SQL documents.
147         * @param[in]    pOrder                          The sorting order of the rows to query @n
148         *                                                                       It is an SQL 'ORDER BY' clause excluding the 'ORDER BY' itself.
149         * @param[out]   reqId                           The request ID
150         * @param[in]    pageNo                          The page number of the result set @n
151         *                                                                       It starts from @c 1.
152         * @param[in]    countPerPage            The desired maximum count of the rows per page
153         * @exception    E_SUCCESS                       The method is successful.
154         * @exception    E_INVALID_STATE         This instance has not been constructed properly.
155         * @exception    E_INVALID_ARG           Either of the following conditions has occurred:
156         *                                                                       - The specified @c pColumnList is empty.
157         *                                                                       - The specified @c pageNo is less than @c 1.
158         *                                                                       - The specified @c countPerPage is less than @c 1.
159         * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred:
160         *                                                                       - The access is denied due to insufficient permission.
161         *                                                                       - The application using this method is not signed with the same certificate as that of the provider application. @b Since: @b 2.1
162         * @exception    E_MAX_EXCEEDED          Either of the following conditions has occurred:
163         *                                                                       - The size of the sending buffer has exceeded the maximum limit.
164         *                                                                       - The number of sending requests have exceeded the maximum limit.
165         * @exception    E_SYSTEM                        A system error has occurred.
166         * @remarks      The recommended data size is under 16KB because a severe system performance degradation may occur for larger messages. @n
167         *                       @c E_MAX_EXCEEDED may be returned for messages over 16KB.
168         */
169         result Select(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IList* pColumnList,
170                         const Tizen::Base::String* pWhere, const Tizen::Base::String *pOrder, RequestId& reqId,
171                         int pageNo = 1, int countPerPage = 20);
172
173         /**
174         * Inserts new rows into a table owned by the SQL-friendly interface based data control provider. @n
175         * The %Insert() method is asynchronous.
176         * For receiving the response from the data control provider, set the listener using
177         * the SqlDataControl::SetSqlDataControlResponseListener() method. @n
178         * When the response has been received from the data control provider,
179         * the ISqlDataControlResponseListener::OnSqlDataControlInsertResponseReceived() method is called.
180         *
181         * @since        2.0
182         *
183         * @return               An error code
184         * @param[in]    dataId                          The string that identifies the specific data, usually a database table to insert into @n
185         *                                                                       The string consists of one or more components, separated by a slash('/').
186         * @param[in]    insertMap                       The column-value pairs to insert @n
187         *                                                                       The type of objects must be Tizen::Base::String @n
188         *                                                                       If the value is a string, the value must be wrapped in single quotes,
189         *                                                                       else it need not be wrapped in single quotes @n
190         *                                                                       For more information on the SQL statement, see SQLite SQL documents.
191         * @param[out]   reqId                           The request ID
192         * @exception    E_SUCCESS                       The method is successful.
193         * @exception    E_INVALID_STATE         This instance has not been constructed properly.
194         * @exception    E_INVALID_ARG           The specified @c insertMap is empty.
195         * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred:
196         *                                                                       - The access is denied due to insufficient permission.
197         *                                                                       - The application using this method is not signed with the same certificate as that of the provider application. @b Since: @b 2.1
198         * @exception    E_MAX_EXCEEDED          Either of the following conditions has occurred:
199         *                                                                       - The size of the sending buffer has exceeded the maximum limit.
200         *                                                                       - The number of sending requests have exceeded the maximum limit.
201         * @exception    E_SYSTEM                        A system error has occurred.
202         * @remarks      The recommended data size is under 1MB because a severe system performance degradation may occur for larger messages. @n
203         *                       @c E_MAX_EXCEEDED may be returned for messages over 1MB.
204         */
205         result Insert(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IMap& insertMap, RequestId& reqId);
206
207         /**
208         * Updates values of a table owned by the SQL-friendly interface based data control provider. @n
209         * The %Update() method is asynchronous.
210         * For receiving the response from the data control provider, set the listener using
211         * the SqlDataControl::SetSqlDataControlResponseListener() method. @n
212         * When the response has been received from the data control provider,
213         * the ISqlDataControlResponseListener::OnSqlDataControlUpdateResponseReceived() method is called.
214         *
215         * @since        2.0
216         *
217         * @return               An error code
218         * @param[in]    dataId                          The string that identifies the specific data, usually a database table to update @n
219         *                                                                       The string consists of one or more components, separated by a slash('/').
220         * @param[in]    updateMap                       The column-value pairs to update @n
221         *                                                                       The type of objects must be Tizen::Base::String @n
222         *                                                                       If the value is a string, the value must be wrapped in single quotes,
223         *                                                                       else it need not be wrapped in single quotes @n
224         *                                                                       For more information on the SQL statement, see SQLITE SQL documents.
225         * @param[in]    pWhere                          The filter to select the desired rows to update @n
226         *                                                                       It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as
227         *                                                                       column1 = 'stringValue' AND column2 = numericValue @n
228         *                                                                       If the value is a string, the value must be wrapped in single quotes,
229         *                                                                       else it is not wrapped in single quotes @n
230         *                                                                       For more information on the SQL statement, see SQLITE SQL documents.
231         * @param[out]   reqId                           The request ID
232         * @exception    E_SUCCESS                       The method is successful.
233         * @exception    E_INVALID_STATE         This instance has not been constructed properly.
234         * @exception    E_INVALID_ARG           The specified @c updateMap is empty.
235         * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred:
236         *                                                                       - The access is denied due to insufficient permission.
237         *                                                                       - The application using this method is not signed with the same certificate as that of the provider application. @b Since: @b 2.1
238         * @exception    E_MAX_EXCEEDED          Either of the following conditions has occurred:
239         *                                                                       - The size of the sending buffer has exceeded the maximum limit.
240         *                                                                       - The number of sending requests have exceeded the maximum limit.
241         * @exception    E_SYSTEM                        A system error has occurred.
242         * @remarks      The recommended data size is under 1MB because a severe system performance degradation may occur for larger messages. @n
243         *                       @c E_MAX_EXCEEDED may be returned for messages over 1MB.
244         */
245         result Update(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IMap& updateMap,
246                         const Tizen::Base::String* pWhere, RequestId& reqId);
247
248         /**
249         * Deletes rows of a table owned by the SQL-friendly interface based data control provider. @n
250         * The %Delete() method is asynchronous.
251         * For receiving the response from the data control provider, set the listener using
252         * the SqlDataControl::SetSqlDataControlResponseListener() method. @n
253         * When the response has been received from the data control provider,
254         * the ISqlDataControlResponseListener::OnSqlDataControlDeleteResponseReceived() method is called.
255         *
256         * @since        2.0
257         *
258         * @return               An error code
259         * @param[in]    dataId                          The string that identifies the specific data, usually a database table to delete from @n
260         *                                                                       The string consists of one or more components, separated by a slash('/').
261         * @param[in]    pWhere                          The filter to select the desired rows to delete @n
262         *                                                                       It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as
263         *                                                                       column1 = 'stringValue' AND column2 = numericValue @n
264         *                                                                       If it is @c null, all the rows are deleted @n
265         *                                                                       If the value is a string, the value must be wrapped in single quotes,
266         *                                                                       else it need not be wrapped in single quotes @n
267         *                                                                       For more information on the SQL statement, see SQLITE SQL documents.
268         * @param[out]   reqId                           The request ID
269         * @exception    E_SUCCESS                       The method is successful.
270         * @exception    E_INVALID_STATE         This instance has not been constructed properly.
271         * @exception    E_INVALID_ARG           A specified input parameter is invalid.
272         * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred:
273         *                                                                       - The access is denied due to insufficient permission.
274         *                                                                       - The application using this method is not signed with the same certificate as that of the provider application. @b Since: @b 2.1
275         * @exception    E_MAX_EXCEEDED          Either of the following conditions has occurred:
276         *                                                                       - The size of the sending buffer has exceeded the maximum limit.
277         *                                                                       - The number of sending requests have exceeded the maximum limit.
278         * @exception    E_SYSTEM                        A system error has occurred.
279         * @remarks      The recommended data size is under 16KB because a severe system performance degradation may occur for larger messages. @n
280         *                       @c E_MAX_EXCEEDED may be returned for messages over 16KB.
281         */
282         result Delete(const Tizen::Base::String& dataId, const Tizen::Base::String* pWhere, RequestId& reqId);
283
284         /**
285         * Sets an SQL-friendly interface based data control listener to this instance.
286         *
287         * @since        2.0
288         *
289         * @return               An error code
290         * @param[in]    pListener                       The data control callback listener @n
291         *                                                                       Some data controls get the callback result by implementing
292         *                                                                       the ISqlDataControlResponseListener interface.
293         * @exception    E_SUCCESS                       The method is successful.
294         * @exception    E_INVALID_STATE         This instance has not been constructed properly.
295         * @exception    E_SYSTEM                        A system error has occurred.
296         */
297         result SetSqlDataControlResponseListener(ISqlDataControlResponseListener* pListener);
298
299 private:
300         /**
301         * This default constructor is intentionally declared as private so that only the platform can create an instance.
302         *
303         * @since        2.0
304         */
305         SqlDataControl(void);
306
307         /**
308         * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
309         *
310         * @since        2.0
311         * @remarks      This constructor is hidden.
312         */
313         SqlDataControl(const SqlDataControl& rhs);
314
315         /**
316         * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
317         *
318         * @since        2.0
319         * @remarks      This operator is hidden.
320         */
321         SqlDataControl& operator =(const SqlDataControl& rhs);
322
323         class _SqlDataControlImpl* __pSqlDataControlImpl;
324
325         friend class _SqlDataControlImpl;
326
327 }; // SqlDataControl
328
329 }} // Tizen::App
330
331 #endif // _FAPP_SQL_DATA_CONTROL_H_
332