[2.2.1] Apply reviewed header file (Base to Collection)
[platform/framework/native/appfw.git] / inc / FAppMapDataControl.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    FAppMapDataControl.h
19  * @brief   This is the header file for the %MapDataControl class.
20  *
21  * This header file contains the declarations of the %MapDataControl class.
22  */
23
24 #ifndef _FAPP_MAP_DATA_CONTROL_H_
25 #define _FAPP_MAP_DATA_CONTROL_H_
26
27 #include <FBaseDataType.h>
28 #include <FBaseObject.h>
29
30 namespace Tizen { namespace Base
31 {
32 class String;
33 }}
34
35 namespace Tizen { namespace App
36 {
37
38 class IMapDataControlResponseListener;
39
40 /**
41  * @class   MapDataControl
42  * @brief   This class represents the key-value structured data control behavior.
43  *
44  * @since       2.0
45  *
46  * @final   This class is not intended for extension.
47  *
48  * The %MapDataControl class represents the key-value structured data control behavior, that provides a standard mechanism
49  * for accessing specific data exported by other applications.
50  * Data control provider can share its own data to data control consumers.
51  *
52  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/app/data_controls.htm">Data Controls</a>.
53  *
54  * @see Tizen::App::AppManager
55  *
56  * The following example demonstrates how to use the %MapDataControl class.
57  *
58  * @code
59  *
60  * #include <FBase.h>
61  * #include <FApp.h>
62  *
63  * using namespace Tizen::Base;
64  * using namespace Tizen::App;
65  *
66  * class MyMapDataControlResponseListener:
67  *      : public Tizen::App::IMapDataControlResponseListener
68  * {
69  * public:
70  *      void OnMapDataControlGetValueResponseReceived(RequestId reqId, const String& providerId, const String& dataId, IList& resultValueList, bool providerResult, const String* pErrorMsg)
71  *      {
72  *              int count = resultValueList.GetCount();
73  *              for (int i = 0; i < count; i++)
74  *              {
75  *                      String pPerson = static_cast< String* >(resultValueList.GetAt(i));
76  *                      AppLog("%dth person: %ls", i, pPerson->GetPointer());
77  *              }
78  *      }
79  * };
80  *
81  * void
82  * MyClass::Execute(void)
83  * {
84  *              String providerId(L"http://tizen.org/datacontrol/provider/example");
85  *              MapDataControl* pDc = AppManager::GetMapDataControlN(providerId);
86  *
87  *              MyMapDataControlResponseListener* pResponseListener = new MyMapDataControlResponseListener();
88  *
89  *              pDc->SetMapDataControlResponseListener(pResponseListener);
90  *
91  *              String dataId(L"test");
92  *              String person(L"person");
93  *              RequestId reqId;
94  *
95  *              pDc->GetValue(dataId, person, reqId);
96  * }
97  *
98  * @endcode
99  */
100
101 class _OSP_EXPORT_ MapDataControl
102         : public Tizen::Base::Object
103 {
104
105 public:
106         /**
107         * This destructor overrides Tizen::Base::Object::~Object().
108         *
109         * @since        2.0
110         */
111         virtual ~MapDataControl(void);
112
113         /**
114         * Gets the value list associated with the specified @c key, from a key-values map owned by key-value structured data control provider. @n
115         * The %GetValue() method is asynchronous.
116         * For receiving the response from data control provider, set the listener
117         * with MapDataControl::SetMapDataControlResponseListener(). @n
118         * When the requested value list has been received from data control provider,
119         * the IMapDataControlResponseListener::OnMapDataControlGetValueResponseReceived() method is called.
120         *
121         * @since        2.0
122         *
123         * @return               An error code
124         * @param[in]    dataId                  A string for identifying specific data, usually a registry section to get from @n
125         *                               The string consists of one or more components, separated by a slash('/').
126         * @param[in]    key             A key of the value list to obtain
127         * @param[out]   reqId                   The ID of the request
128         * @param[in]    pageNo                  The page number of the value set @n
129         *                                                               It starts from @c 1.
130         * @param[in]    countPerPage    The desired maximum count of the data item on the page
131         * @exception    E_SUCCESS                       The method is successful.
132         * @exception    E_INVALID_STATE         This instance has not been properly constructed as yet.
133         * @exception    E_INVALID_ARG           Either of the following conditions has occurred: @n
134         *                                                                       - The specified @c pageNo parameter is less than @c 1.
135         *                                                                       - The specified @c countPerPage parameter is less than @c 1.
136         * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred: @n
137         *                                                                       - Access is denied due to insufficient permission.
138         *                                                                       - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
139         * @exception    E_MAX_EXCEEDED          Either of the following conditions has occurred: @n
140         *                                                                       - The total size of method arguments has exceeded the maximum limit.
141         *                                                                       - The number of requests sent has exceeded the maximum limit.
142         * @exception    E_SYSTEM                        A system error has occurred.
143         * @remarks              The total size of method arguments 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.
144         */
145         result GetValue(const Tizen::Base::String& dataId, const Tizen::Base::String& key, RequestId& reqId, int pageNo = 1, int countPerPage = 20);
146
147         /**
148         * Adds the value associated with the specified @c key, to a key-values map owned by key-value structured data control provider. @n
149         * The %AddValue() method is asynchronous.
150         * For receiving the response from data control provider, set the listener
151         * with MapDataControl::SetMapDataControlResponseListener(). @n
152         * When the response has been received from the data control provider,
153         * the IMapDataControlResponseListener::OnMapDataControlAddValueResponseReceived() method is called.
154         *
155         * @since        2.0
156         *
157         * @return               An error code
158         * @param[in]    dataId          A string for identifying specific data, usually a registry section to add to @n
159         *                                                       The string consists of one or more components, separated by a slash('/').
160         * @param[in]    key                     A key of the value list to add
161         * @param[in]    value       A value to add
162         * @param[out]   reqId           The ID of the request
163         * @exception    E_SUCCESS                       The method is successful.
164         * @exception    E_INVALID_STATE         This instance has not been properly constructed as yet.
165         * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred: @n
166         *                                                                       - Access is denied due to insufficient permission.
167         *                                                                       - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
168         * @exception    E_MAX_EXCEEDED          Either of the following conditions has occurred: @n
169         *                                                                       - The total size of method arguments has exceeded the maximum limit.
170         *                                                                       - The number of requests sent has exceeded the maximum limit.
171         * @exception    E_SYSTEM                        A system error has occurred.
172         * @remarks              The total size of method arguments 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.
173         */
174         result AddValue(const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& value, RequestId& reqId);
175
176         /**
177         * Sets the value associated with the specified @c key with a new value. @n
178         * The key-values map is owned by key-value structured data control provider. @n
179         * The %SetValue() method is asynchronous.
180         * For receiving the response from data control provider, set the listener
181         * with MapDataControl::SetMapDataControlResponseListener(). @n
182         * When the response has been received from the data control provider,
183         * the IMapDataControlResponseListener::OnMapDataControlSetValueResponseReceived() method is called.
184         *
185         * @since        2.0
186         *
187         * @return               An error code
188         * @param[in]    dataId          A string for identifying specific data, usually a registry section to update @n
189         *                                                       The string consists of one or more components, separated by a slash('/').
190         * @param[in]    key                     A key of the value to replace
191         * @param[in]    oldValue        A value to replace
192         * @param[in]    newValue        A new value to replace the existing value
193         * @param[out]   reqId           The ID of the request
194         * @exception    E_SUCCESS                       The method is successful.
195         * @exception    E_INVALID_STATE         This instance has not been properly constructed as yet.
196         * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred: @n
197         *                                                                       - Access is denied due to insufficient permission.
198         *                                                                       - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
199         * @exception    E_MAX_EXCEEDED          Either of the following conditions has occurred: @n
200         *                                                                       - The total size of method arguments has exceeded the maximum limit.
201         *                                                                       - The number of requests sent has exceeded the maximum limit.
202         * @exception    E_SYSTEM                        A system error has occurred.
203         * @remarks              The total size of method arguments 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.
204         */
205         result SetValue(const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& oldValue, const Tizen::Base::String& newValue, RequestId& reqId);
206
207         /**
208         * Removes the value associated with the specified @c key, from a key-values map owned by key-value structured data control provider. @n
209         * The %RemoveValue() method is asynchronous.
210         * For receiving the response from data control provider, set the listener
211         * with MapDataControl::SetMapDataControlResponseListener(). @n
212         * When the response has been received from the data control provider,
213         * the IMapDataControlResponseListener::OnMapDataControlRemoveValueResponseReceived() method is called.
214         *
215         * @since        2.0
216         *
217         * @return               An error code
218         * @param[in]    dataId          A string for identifying specific data, usually a registry section to remove from @n
219         *                                                       The string consists of one or more components, separated by a slash('/').
220         * @param[in]    key                     A key of the value to remove
221         * @param[in]    value       A value to remove
222         * @param[out]   reqId           The ID of the request
223         * @exception    E_SUCCESS                       The method is successful.
224         * @exception    E_INVALID_STATE         This instance has not been properly constructed as yet.
225         * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred: @n
226         *                                                                       - Access is denied due to insufficient permission.
227         *                                                                       - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
228         * @exception    E_MAX_EXCEEDED          Either of the following conditions has occurred: @n
229         *                                                                       - The total size of method arguments has exceeded the maximum limit.
230         *                                                                       - The number of requests sent has exceeded the maximum limit.
231         * @exception    E_SYSTEM                        A system error has occurred.
232         * @remarks              The total size of method arguments 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.
233         */
234         result RemoveValue(const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& value, RequestId& reqId);
235
236         /**
237         * Sets the MAP-based data control listener to this instance.
238         *
239         * @since        2.0
240         *
241         * @return               An error code
242         * @param[in]    pListener                       The data control callback listener @n
243         *                                                                       Some data controls need to get the callback result by implementing
244         *                                                                       the IMapDataControlResponseListener interface.
245         * @exception    E_SUCCESS                       The method is successful.
246         * @exception    E_INVALID_STATE         This instance has not been properly constructed.
247         * @exception    E_SYSTEM                        A system error has occurred.
248         */
249         result SetMapDataControlResponseListener(IMapDataControlResponseListener* pListener);
250
251 private:
252         /**
253         * This default constructor is intentionally declared as private so that only the platform can create an instance.
254         *
255         * @since        2.0
256         */
257         MapDataControl(void);
258
259         /**
260         * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
261         *
262         * @since        2.0
263         * @remarks      This constructor is hidden.
264         */
265         MapDataControl(const MapDataControl& mapDataControl);
266
267         /**
268         * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
269         *
270         * @since        2.0
271         * @remarks      This operator is hidden.
272         */
273         MapDataControl& operator =(const MapDataControl& mapDataControl);
274
275 private:
276         class _MapDataControlImpl * __pMapDataControlImpl;
277
278         friend class _MapDataControlImpl;
279 }; // MapDataControl
280
281 }} // Tizen::App
282
283 #endif // _FAPP_MAP_DATA_CONTROL_H_
284