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's behavior.
52 * @final This class is not intended for extension.
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.
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 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.
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.
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);
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.
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.
205 result Insert(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IMap& insertMap, RequestId& reqId);
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.
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.
245 result Update(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IMap& updateMap,
246 const Tizen::Base::String* pWhere, RequestId& reqId);
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.
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.
282 result Delete(const Tizen::Base::String& dataId, const Tizen::Base::String* pWhere, RequestId& reqId);
285 * Sets an SQL-friendly interface based data control listener to this instance.
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.
297 result SetSqlDataControlResponseListener(ISqlDataControlResponseListener* pListener);
301 * This default constructor is intentionally declared as private so that only the platform can create an instance.
305 SqlDataControl(void);
308 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
311 * @remarks This constructor is hidden.
313 SqlDataControl(const SqlDataControl& rhs);
316 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
319 * @remarks This operator is hidden.
321 SqlDataControl& operator =(const SqlDataControl& rhs);
323 class _SqlDataControlImpl* __pSqlDataControlImpl;
325 friend class _SqlDataControlImpl;
331 #endif // _FAPP_SQL_DATA_CONTROL_H_