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-type 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-type 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.
144 * @param[in] pOrder The sorting order of rows to query @n
145 * It is an SQL 'ORDER BY' clause excluding the 'ORDER BY' itself.
146 * @param[out] reqId The request ID
147 * @param[in] pageNo The page number of the result set @n It starts from @c 1.
148 * @param[in] countPerPage The desired maximum count of rows on a page
149 * @exception E_SUCCESS The method is successful.
150 * @exception E_INVALID_STATE This instance has not been properly constructed.
151 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
152 * - The specified @c pColumnList is empty.
153 * - The specified @c pageNo parameter is less than @c 1.
154 * - The specified @c countPerPage parameter is less than @c 1.
155 * @exception E_ILLEGAL_ACCESS Either of the following conditions has occurred: @n
156 * - Access is denied due to insufficient permission.
157 * - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
158 * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
159 * - The size of sending buffer has exceeded the maximum limit.
160 * - The number of sending requests has exceeded the maximum limit.
161 * @exception E_SYSTEM A system error has occurred.
162 * @remarks If the value specified in the @c pWhere is string, the value must be wrapped in
163 * single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
164 * For more information on the SQL statement, see SQLite SQL documents.
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.
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-type 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 contained in the specified @c insertMap must be
186 * Tizen::Base::String class.
187 * @param[out] reqId The request ID
188 * @exception E_SUCCESS The method is successful.
189 * @exception E_INVALID_STATE This instance has not been properly constructed.
190 * @exception E_INVALID_ARG The specified @c insertMap is empty.
191 * @exception E_ILLEGAL_ACCESS Either of the following conditions has occurred: @n
192 * - Access is denied due to insufficient permission.
193 * - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
194 * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
195 * - The size of sending buffer has exceeded the maximum limit.
196 * - The number of sending requests has exceeded the maximum limit.
197 * @exception E_SYSTEM A system error has occurred.
198 * @remarks If the value specified in the @c insertMap is string, the value must be wrapped in
199 * single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
200 * For more information on the SQL statement, see SQLite SQL documents.
201 * @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.
203 result Insert(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IMap& insertMap, RequestId& reqId);
206 * Updates values of a table owned by an SQL-type data control provider. @n
207 * The %Update() method is asynchronous.
208 * For receiving the response from the data control provider, set the listener with
209 * SqlDataControl::SetSqlDataControlResponseListener(). @n
210 * When the response has been received from the data control provider,
211 * the ISqlDataControlResponseListener::OnSqlDataControlUpdateResponseReceived() method is called.
215 * @return An error code
216 * @param[in] dataId A string for identifying specific data, usually a database table to update @n
217 * The string consists of one or more components, separated by a slash('/').
218 * @param[in] updateMap The column-value pairs to update @n
219 * The type of objects contained in the specified @c updateMap must be
220 * Tizen::Base::String class.
221 * @param[in] pWhere A filter to select desired rows to update @n
222 * It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as
223 * column1 = 'stringValue' AND column2 = numericValue.
224 * @param[out] reqId The request ID
225 * @exception E_SUCCESS The method is successful.
226 * @exception E_INVALID_STATE This instance has not been properly constructed.
227 * @exception E_INVALID_ARG The specified @c updateMap is empty.
228 * @exception E_ILLEGAL_ACCESS Either of the following conditions has occurred: @n
229 * - Access is denied due to insufficient permission.
230 * - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
231 * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
232 * - The size of sending buffer has exceeded the maximum limit.
233 * - The number of sending requests has exceeded the maximum limit.
234 * @exception E_SYSTEM A system error has occurred.
235 * @remarks If the value specified in the @c pWhere or @c updateMap is string, the value must be wrapped in
236 * single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
237 * For more information on the SQL statement, see SQLITE SQL documents.
238 * @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.
240 result Update(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IMap& updateMap,
241 const Tizen::Base::String* pWhere, RequestId& reqId);
244 * Deletes rows of a table owned by an SQL-type data control provider. @n
245 * The %Delete() method is asynchronous.
246 * For receiving the response from the data control provider, set the listener with
247 * SqlDataControl::SetSqlDataControlResponseListener(). @n
248 * When the response has been received from the data control provider,
249 * the ISqlDataControlResponseListener::OnSqlDataControlDeleteResponseReceived() method is called.
253 * @return An error code
254 * @param[in] dataId A string for identifying specific data, usually a database table to delete from @n
255 * The string consists of one or more components, separated by a slash('/').
256 * @param[in] pWhere A filter to select desired rows to delete @n
257 * It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as
258 * column1 = 'stringValue' AND column2 = numericValue.
259 * If it is @c null, all rows are deleted.
260 * @param[out] reqId The request ID
261 * @exception E_SUCCESS The method is successful.
262 * @exception E_INVALID_STATE This instance has not been properly constructed.
263 * @exception E_INVALID_ARG A specified parameter is invalid.
264 * @exception E_ILLEGAL_ACCESS Either of the following conditions has occurred: @n
265 * - Access is denied due to insufficient permission.
266 * - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
267 * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
268 * - The size of sending buffer has exceeded the maximum limit.
269 * - The number of sending requests has exceeded the maximum limit.
270 * @exception E_SYSTEM A system error has occurred.
271 * @remarks If the value specified in the @c pWhere is string, the value must be wrapped in
272 * single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
273 * For more information on the SQL statement, see SQLITE SQL documents.
274 * @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.
276 result Delete(const Tizen::Base::String& dataId, const Tizen::Base::String* pWhere, RequestId& reqId);
279 * Sets an SQL-type data control listener to this instance.
283 * @return An error code
284 * @param[in] pListener The data control callback listener @n
285 * Some data controls need to get the callback result by implementing
286 * the ISqlDataControlResponseListener interface.
287 * @exception E_SUCCESS The method is successful.
288 * @exception E_INVALID_STATE This instance has not been properly constructed.
289 * @exception E_SYSTEM A system error has occurred.
291 result SetSqlDataControlResponseListener(ISqlDataControlResponseListener* pListener);
295 * This default constructor is intentionally declared as private so that only the platform can create an instance.
299 SqlDataControl(void);
302 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
305 * @remarks This constructor is hidden.
307 SqlDataControl(const SqlDataControl& rhs);
310 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
313 * @remarks This operator is hidden.
315 SqlDataControl& operator =(const SqlDataControl& rhs);
317 class _SqlDataControlImpl* __pSqlDataControlImpl;
319 friend class _SqlDataControlImpl;
325 #endif // _FAPP_SQL_DATA_CONTROL_H_