2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FAppSqlDataControl.h
19 * @brief This is the header file for the %SqlDataControl class.
21 * This header file contains the declarations of the %SqlDataControl class.
24 #ifndef _FAPP_SQL_DATA_CONTROL_H_
25 #define _FAPP_SQL_DATA_CONTROL_H_
27 #include <FOspConfig.h>
28 #include <FBaseDataType.h>
29 #include <FBaseObject.h>
31 namespace Tizen { namespace Base
34 namespace Collection {
40 namespace Tizen { namespace App
43 class _SqlDataControlImpl;
44 class ISqlDataControlResponseListener;
47 * @class SqlDataControl
48 * @brief This class represents the SQL-friendly interface based data control behavior.
52 * @final This class is not intended for extension.
54 * The %SqlDataControl class represents the data control behavior, that provides a standard mechanism
55 * for accessing specific data exported by other applications.
56 * Data control provider can share its own data to data control consumers.
58 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/app/data_controls.htm">Data Controls</a>.
60 * @see Tizen::App::AppManager
67 * using namespace Tizen::Base;
68 * using namespace Tizen::Io;
70 * class MySqlDataControlResponseListener:
71 * : public Tizen::App::ISqlDataControlResponseListener
74 * void OnSqlDataControlInsertResponseReceived(RequestId reqId, const String& providerId, const String& dataId, long long insertRowId, bool providerResult, const String* pErrorMsg)
76 * AppLog("Row Id = %d", insertRowId);
81 * MyClass::Execute(void)
83 * String providerId(L"http://tizen.org/datacontrol/provider/example");
84 * SqlDataControl* pDc = AppManager::GetSqlDataControlN(providerId);
86 * MySqlDataControlResponseListener* pResponseListener = new MySqlDataControlResponseListener();
88 * pDc->SetSqlDataControlResponseListener(pResponseListener);
90 * String dataId(L"test");
91 * String person(L"person");
92 * String number(L"number");
95 * ArrayList columnList(SingleObjectDeleter);
96 * columnList.Construct();
98 * columnList.Add(person);
99 * columnList.Add(number);
101 * String where(L"group = 'friend'");
102 * String order(L"person ASC");
104 * pDc->Select(dataId, &columnList, &where, &order, reqId);
111 class _OSP_EXPORT_ SqlDataControl
112 : public Tizen::Base::Object
117 * This destructor overrides Tizen::Base::Object::~Object().
121 virtual ~SqlDataControl(void);
124 * Selects the specified columns to be queried. @n
125 * The result set of the specified columns is retrieved from a table owned by an 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 with
128 * SqlDataControl::SetSqlDataControlResponseListener(). @n
129 * When the requested result set has been received from the data control provider,
130 * the ISqlDataControlResponseListener::OnSqlDataControlSelectResponseReceived() method is called.
134 * @return An error code
135 * @param[in] dataId A string for identifying 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 A list of column names to query @n
138 * The type of objects contained in the specified @c pColumnList must be
139 * Tizen::Base::String class.
140 * If the specified @c pColumnList is @c null, all columns are selected.
141 * @param[in] pWhere A filter to select 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
\r
144 * If the value is string, the value must be wrapped in single quotes.
\r
145 * Otherwise it is not needed to wrap the numeric value in single quotes.
\r
146 * For more information on the SQL statement, see SQLite SQL documents.
\r
147 * @param[in] pOrder The sorting order of 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 It starts from @c 1.
151 * @param[in] countPerPage The desired maximum count of rows on a page
152 * @exception E_SUCCESS The method is successful.
153 * @exception E_INVALID_STATE This instance has not been properly constructed.
154 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
155 * - The specified @c pColumnList is empty.
156 * - The specified @c pageNo parameter is less than @c 1.
157 * - The specified @c countPerPage parameter is less than @c 1.
158 * @exception E_ILLEGAL_ACCESS Either of the following conditions has occurred: @n
159 * - Access is denied due to insufficient permission.
160 * - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
161 * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
162 * - The size of sending buffer has exceeded the maximum limit.
163 * - The number of sending requests has exceeded the maximum limit.
164 * @exception E_SYSTEM A system error has occurred.
165 * @remarks The recommended data size is under 16KB because severe system performance degradation may occur for large messages. @c E_MAX_EXCEEDED may be returned for messages over 16KB size.
\r
167 result Select(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IList* pColumnList,
168 const Tizen::Base::String* pWhere, const Tizen::Base::String *pOrder, RequestId& reqId,
169 int pageNo = 1, int countPerPage = 20);
172 * Inserts new rows into a table owned by an SQL-friendly interface based data control provider. @n
173 * The %Insert() method is asynchronous.
174 * For receiving the response from the data control provider, set the listener with
175 * SqlDataControl::SetSqlDataControlResponseListener(). @n
176 * When the response has been received from the data control provider,
177 * the ISqlDataControlResponseListener::OnSqlDataControlInsertResponseReceived() method is called.
181 * @return An error code
182 * @param[in] dataId A string for identifying specific data, usually a database table to insert into @n
183 * The string consists of one or more components, separated by a slash('/').
184 * @param[in] insertMap The column-value pairs to insert @n
185 * The type of objects must be Tizen::Base::String class. @n
\r
186 * If the value is string, the value must be wrapped in
\r
187 * single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
\r
188 * For more information on the SQL statement, see SQLite SQL documents.
\r
189 * @param[out] reqId The request ID
190 * @exception E_SUCCESS The method is successful.
191 * @exception E_INVALID_STATE This instance has not been properly constructed.
192 * @exception E_INVALID_ARG The specified @c insertMap is empty.
193 * @exception E_ILLEGAL_ACCESS Either of the following conditions has occurred: @n
194 * - Access is denied due to insufficient permission.
195 * - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
196 * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
197 * - The size of sending buffer has exceeded the maximum limit.
198 * - The number of sending requests has exceeded the maximum limit.
199 * @exception E_SYSTEM A system error has occurred.
200 * @remarks The recommended data size is under 1MB because severe system performance degradation may occur for large messages. @c E_MAX_EXCEEDED may be returned for messages over 1MB size.
\r
202 result Insert(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IMap& insertMap, RequestId& reqId);
205 * Updates values of a table owned by an SQL-friendly interface based data control provider. @n
206 * The %Update() method is asynchronous.
207 * For receiving the response from the data control provider, set the listener with
208 * SqlDataControl::SetSqlDataControlResponseListener(). @n
209 * When the response has been received from the data control provider,
210 * the ISqlDataControlResponseListener::OnSqlDataControlUpdateResponseReceived() method is called.
214 * @return An error code
215 * @param[in] dataId A string for identifying specific data, usually a database table to update @n
216 * The string consists of one or more components, separated by a slash('/').
217 * @param[in] updateMap The column-value pairs to update @n
218 * The type of objects must be Tizen::Base::String class. @n
\r
219 * If the value is string, the value must be wrapped in
\r
220 * single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
\r
221 * For more information on the SQL statement, see SQLITE SQL documents.
\r
222 * @param[in] pWhere A filter to select desired rows to update @n
223 * It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as
224 * column1 = 'stringValue' AND column2 = numericValue. @n
\r
225 * If the value is string, the value must be wrapped in
\r
226 * single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
\r
227 * For more information on the SQL statement, see SQLITE SQL documents.
\r
228 * @param[out] reqId The request ID
229 * @exception E_SUCCESS The method is successful.
230 * @exception E_INVALID_STATE This instance has not been properly constructed.
231 * @exception E_INVALID_ARG The specified @c updateMap is empty.
232 * @exception E_ILLEGAL_ACCESS Either of the following conditions has occurred: @n
233 * - Access is denied due to insufficient permission.
234 * - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
235 * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
236 * - The size of sending buffer has exceeded the maximum limit.
237 * - The number of sending requests has exceeded the maximum limit.
238 * @exception E_SYSTEM A system error has occurred.
239 * @remarks The recommended data size is under 1MB because severe system performance degradation may occur for large messages. @c E_MAX_EXCEEDED may be returned for messages over 1MB size.
\r
241 result Update(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IMap& updateMap,
242 const Tizen::Base::String* pWhere, RequestId& reqId);
245 * Deletes rows of a table owned by an SQL-friendly interface based data control provider. @n
246 * The %Delete() method is asynchronous.
247 * For receiving the response from the data control provider, set the listener with
248 * SqlDataControl::SetSqlDataControlResponseListener(). @n
249 * When the response has been received from the data control provider,
250 * the ISqlDataControlResponseListener::OnSqlDataControlDeleteResponseReceived() method is called.
254 * @return An error code
255 * @param[in] dataId A string for identifying specific data, usually a database table to delete from @n
256 * The string consists of one or more components, separated by a slash('/').
257 * @param[in] pWhere A filter to select desired rows to delete @n
258 * It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as
259 * column1 = 'stringValue' AND column2 = numericValue.
260 * If it is @c null, all rows are deleted. @n
\r
261 * If the value is string, the value must be wrapped in
\r
262 * single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
\r
263 * For more information on the SQL statement, see SQLITE SQL documents.
\r
264 * @param[out] reqId The request ID
265 * @exception E_SUCCESS The method is successful.
266 * @exception E_INVALID_STATE This instance has not been properly constructed.
267 * @exception E_INVALID_ARG A specified parameter is invalid.
268 * @exception E_ILLEGAL_ACCESS Either of the following conditions has occurred: @n
269 * - Access is denied due to insufficient permission.
270 * - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
271 * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
272 * - The size of sending buffer has exceeded the maximum limit.
273 * - The number of sending requests has exceeded the maximum limit.
274 * @exception E_SYSTEM A system error has occurred.
275 * @remarks The recommended data size is under 16KB because severe system performance degradation may occur for large messages. @c E_MAX_EXCEEDED may be returned for messages over 16KB size.
\r
277 result Delete(const Tizen::Base::String& dataId, const Tizen::Base::String* pWhere, RequestId& reqId);
280 * Sets an SQL-friendly interface based data control listener to this instance.
284 * @return An error code
285 * @param[in] pListener The data control callback listener @n
286 * Some data controls need to get the callback result by implementing
287 * the ISqlDataControlResponseListener interface.
288 * @exception E_SUCCESS The method is successful.
289 * @exception E_INVALID_STATE This instance has not been properly constructed.
290 * @exception E_SYSTEM A system error has occurred.
292 result SetSqlDataControlResponseListener(ISqlDataControlResponseListener* pListener);
296 * This default constructor is intentionally declared as private so that only the platform can create an instance.
300 SqlDataControl(void);
303 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
306 * @remarks This constructor is hidden.
308 SqlDataControl(const SqlDataControl& rhs);
311 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
314 * @remarks This operator is hidden.
316 SqlDataControl& operator =(const SqlDataControl& rhs);
318 class _SqlDataControlImpl* __pSqlDataControlImpl;
320 friend class _SqlDataControlImpl;
326 #endif // _FAPP_SQL_DATA_CONTROL_H_