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 FAppIMapDataControlProviderEventListener.h
19 * @brief This is the header file for the %IMapDataControlProviderEventListener interface.
21 * This header file contains the declarations of the %IMapDataControlProviderEventListener interface.
24 #ifndef _FAPP_IMAP_DATACONTROL_REQUESTEVENT_LISTENER_H_
25 #define _FAPP_IMAP_DATACONTROL_REQUESTEVENT_LISTENER_H_
27 #include <FBaseDataType.h>
28 #include <FBaseString.h>
29 #include <FBaseRtIEventListener.h>
31 namespace Tizen { namespace App
35 * @interface IMapDataControlProviderEventListener
36 * @brief This interface defines a listener for dealing with a key-value structured data control request.
40 * The %IMapDataControlProviderEventListener interface defines a listener for dealing with a key-value structured data control request.
42 * The following example demonstrates how to use the %IMapDataControlProviderEventListener interface.
49 : public Tizen::App::ServiceApp
50 : public Tizen::App::IMapDataControlProviderEventListener
54 virtual ~MyServiceApp(void);
56 virtual bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry);
57 virtual bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false);
59 virtual void OnMapDataControlGetValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
60 const Tizen::Base::String& dataId, const Tizen::Base::String& key);
61 virtual void OnMapDataControlAddValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
62 const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& value);
63 virtual void OnMapDataControlSetValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
64 const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& oldValue,
65 const Tizen::Base::String& newValue);
66 virtual void OnMapDataControlRemoveValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
67 const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& value);
71 MyServiceApp::OnAppInitializing(Tizen::App::AppRegistry& appRegistry)
75 DataControlProviderManager* pDcMgr = DataControlProviderManager::GetInstance();
78 AppLog("Failed to get the instance of data control provider manager.");
82 r = pDcMgr->SetMapDataControlProviderEventListener(this);
85 AppLog("Failed to set the data control provider listener.");
93 MyServiceApp::OnMapDataControlGetValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
94 const Tizen::Base::String& dataId, const Tizen::Base::String& key)
96 Registry* pReg = null;
98 ArrayList* pResultValueList = null;
100 result r = E_SUCCESS;
102 if (providerId.compareTo(L"http://tizen.org/datacontrol/provider/example") == 0)
104 if (dataId.compareTo(L"test") == 0)
106 String regPath(GetAppRootPath() + L"data/test.ini");
108 pReg = new Registry();
111 errorMsg.Append(L"The memory is insufficient.");
115 r = pReg->Construct(regPath, false);
118 errorMsg.Append(L"The data control provider failed to open the registry file.");
122 r = pReg->GetValue(dataId, key, retValue);
125 errorMsg.Append(L"The data control provider failed to get the value.");
129 pResultValueList = new ArrayList();
130 pResultValueList->Add(retValue);
136 errorMsg.Append(L"The data ID is invalid.");
141 errorMsg.Append(L"The provider ID is invalid.");
144 r = DataControlProviderManager::GetInstance()->SendMapDataControlResult(reqId, pResultValueList);
147 AppLog("The data control provider failed to send the result.");
150 if (pResultValueList)
152 pResultValueList->RemoveAll();
153 delete pResultValueList;
158 r = DataControlProviderManager::GetInstance()->SendDataControlError(reqId, errorMsg);
161 AppLog("The data control provider failed to send the result.");
165 if (pResultValueList)
167 pResultValueList->RemoveAll();
168 delete pResultValueList;
174 class _OSP_EXPORT_ IMapDataControlProviderEventListener
175 : virtual public Tizen::Base::Runtime::IEventListener
180 * This polymorphic destructor should be overridden if required. @n
181 * This way, the destructors of the derived classes are called when the destructor of this interface is called.
185 virtual ~IMapDataControlProviderEventListener(void) {}
188 * Called when the request for obtaining the value list is received from the key-value structured data control consumer. @n
189 * The provider must implement this listener for providing its own data.
193 * @param[in] reqId The request ID
194 * @param[in] providerId The data control provider ID
195 * @param[in] dataId The string that identifies the specific map to obtain from @n
196 * The string consists of one or more components, separated by a slash('/').
197 * @param[in] key The key of the value list to obtain
198 * @remarks For replying to the data control request, use the DataControlProviderManager::SendMapDataControlResult() method
199 * or the DataControlProviderManager::SendDataControlError() method.
201 virtual void OnMapDataControlGetValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
202 const Tizen::Base::String& dataId, const Tizen::Base::String& key) = 0;
205 * Called when the request for adding the value is received from the key-value structured data control consumer. @n
206 * The provider must implement this listener for providing its own data.
210 * @param[in] reqId The request ID
211 * @param[in] providerId The data control provider ID
212 * @param[in] dataId The string that identifies the specific map to add to @n
213 * The string consists of one or more components, separated by a slash('/').
214 * @param[in] key The key of the value list to add
215 * @param[in] value The value to add
216 * @remarks For replying to the data control request, use the DataControlProviderManager::SendMapDataControlResult() method
217 * or the DataControlProviderManager::SendDataControlError() method.
219 virtual void OnMapDataControlAddValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
220 const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& value) = 0;
223 * Called when the request for replacing the value is received from the key-value structured data control consumer. @n
224 * The provider must implement this listener for providing its own data.
228 * @param[in] reqId The request ID
229 * @param[in] providerId The data control provider ID
230 * @param[in] dataId The string that identifies the specific map to update @n
231 * The string consists of one or more components, separated by a slash('/').
232 * @param[in] key The key of the value to replace
233 * @param[in] oldValue The value to replace
234 * @param[in] newValue The new value that replaces the existing value
235 * @remarks For replying to the data control request, use the DataControlProviderManager::SendMapDataControlResult() method
236 * or the DataControlProviderManager::SendDataControlError() method.
238 virtual void OnMapDataControlSetValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
239 const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& oldValue,
240 const Tizen::Base::String& newValue) = 0;
243 * Called when the request for removing the value is received from the key-value structured data control consumer. @n
244 * The provider must implement this listener for providing its own data.
248 * @param[in] reqId The request ID
249 * @param[in] providerId The data control provider ID
250 * @param[in] dataId The string that identifies the specific map to remove from @n
251 * The string consists of one or more components, separated by a slash('/').
252 * @param[in] key The key of the value to remove
253 * @param[in] value The value to remove
254 * @remarks For replying to the data control request, use the DataControlProviderManager::SendMapDataControlResult() method
255 * or the DataControlProviderManager::SendDataControlError() method.
257 virtual void OnMapDataControlRemoveValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
258 const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& value) = 0;
262 // This method is for internal use only.
263 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
265 // This method is reserved and may change its name at any time without prior notice.
269 virtual void IMapDataControlProviderEventListener_Reserved1(void) {}
272 // This method is for internal use only.
273 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
275 // This method is reserved and may change its name at any time without prior notice.
279 virtual void IMapDataControlProviderEventListener_Reserved2(void) {}
282 // This method is for internal use only.
283 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
285 // This method is reserved and may change its name at any time without prior notice.
289 virtual void IMapDataControlProviderEventListener_Reserved3(void) {}
292 // This method is for internal use only.
293 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
295 // This method is reserved and may change its name at any time without prior notice.
299 virtual void IMapDataControlProviderEventListener_Reserved4(void) {}
302 // This method is for internal use only.
303 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
305 // This method is reserved and may change its name at any time without prior notice.
309 virtual void IMapDataControlProviderEventListener_Reserved5(void) {}
311 }; // IMapDataControlProviderEventListener
315 #endif // _FAPP_IMAP_DATACONTROL_REQUESTEVENT_LISTENER_H_