2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FAppIMapDataControlProviderEventListener.h
20 * @brief This is the header file for the %IMapDataControlProviderEventListener interface.
22 * This header file contains the declarations of the %IMapDataControlProviderEventListener interface.
25 #ifndef _FAPP_IMAP_DATACONTROL_REQUESTEVENT_LISTENER_H_
26 #define _FAPP_IMAP_DATACONTROL_REQUESTEVENT_LISTENER_H_
28 #include <FBaseDataType.h>
29 #include <FBaseString.h>
30 #include <FBaseRtIEventListener.h>
32 namespace Tizen { namespace App
36 * @interface IMapDataControlProviderEventListener
37 * @brief This interface defines a listener for dealing with MAP-type data control request.
41 * The %IMapDataControlProviderEventListener interface defines a listener for dealing with MAP-type data control request.
43 * The following example demonstrates how to use the %IMapDataControlProviderEventListener interface.
50 : public Tizen::App::ServiceApp
51 : public Tizen::App::IMapDataControlProviderEventListener
55 virtual ~MyServiceApp(void);
57 virtual bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry);
58 virtual bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false);
60 virtual void OnMapDataControlGetValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
61 const Tizen::Base::String& dataId, const Tizen::Base::String& key);
62 virtual void OnMapDataControlAddValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
63 const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& value);
64 virtual void OnMapDataControlSetValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
65 const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& oldValue,
66 const Tizen::Base::String& newValue);
67 virtual void OnMapDataControlRemoveValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
68 const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& value);
72 MyServiceApp::OnAppInitializing(Tizen::App::AppRegistry& appRegistry)
76 DataControlProviderManager* pDcMgr = DataControlProviderManager::GetInstance();
79 AppLog("Failed to get the instance of data control provider manager.");
83 r = pDcMgr->SetMapDataControlProviderEventListener(this);
86 AppLog("Failed to set the data control provider listener.");
94 MyServiceApp::OnMapDataControlGetValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
95 const Tizen::Base::String& dataId, const Tizen::Base::String& key)
97 Registry* pReg = null;
99 ArrayList* pResultValueList = null;
101 result r = E_SUCCESS;
103 if (providerId.compareTo(L"http://tizen.org/datacontrol/provider/example") == 0)
105 if (dataId.compareTo(L"test") == 0)
107 String regPath(GetAppRootPath() + L"data/test.ini");
109 pReg = new Registry();
112 errorMsg.Append(L"The memory is insufficient.");
116 r = pReg->Construct(regPath, false);
119 errorMsg.Append(L"The data control provider failed to open the registry file.");
123 r = pReg->GetValue(dataId, key, retValue);
126 errorMsg.Append(L"The data control provider failed to get the value.");
130 pResultValueList = new ArrayList();
131 pResultValueList->Add(retValue);
137 errorMsg.Append(L"The data ID is invalid.");
142 errorMsg.Append(L"The provider ID is invalid.");
145 r = DataControlProviderManager::GetInstance()->SendMapDataControlResult(reqId, pResultValueList);
148 AppLog("The data control provider failed to send the result.");
151 if (pResultValueList)
153 pResultValueList->RemoveAll();
154 delete pResultValueList;
159 r = DataControlProviderManager::GetInstance()->SendDataControlError(reqId, errorMsg);
162 AppLog("The data control provider failed to send the result.");
166 if (pResultValueList)
168 pResultValueList->RemoveAll();
169 delete pResultValueList;
175 class _OSP_EXPORT_ IMapDataControlProviderEventListener
176 : virtual public Tizen::Base::Runtime::IEventListener
181 * This polymorphic destructor should be overridden if required.
182 * This way, the destructors of the derived classes are called when the destructor of this interface is called.
186 virtual ~IMapDataControlProviderEventListener(void) {}
189 * Called when the request for getting the value list is received from MAP-type data control consumer. @n
190 * The provider must implement this listener for providing its own data.
194 * @param[in] reqId The request ID
195 * @param[in] providerId The data control provider ID
196 * @param[in] dataId A string for identifying a specific map to get from @n
197 * The string consists of one or more components, separated by a slash('/').
198 * @param[in] key A key of the value list to obtain
199 * @remarks For replying to the data control request, use DataControlProviderManager::SendMapDataControlResult()
200 * or DataControlProviderManager::SendDataControlError().
202 virtual void OnMapDataControlGetValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
203 const Tizen::Base::String& dataId, const Tizen::Base::String& key) = 0;
206 * Called when the request for adding the value is received from MAP-type data control consumer. @n
207 * The provider must implement this listener for providing its own data.
211 * @param[in] reqId The request ID
212 * @param[in] providerId The data control provider ID
213 * @param[in] dataId A string for identifying a specific map to add to @n
214 * The string consists of one or more components, separated by a slash('/').
215 * @param[in] key A key of the value list to add
216 * @param[in] value A value to add
217 * @remarks For replying to the data control request, use DataControlProviderManager::SendMapDataControlResult()
218 * or DataControlProviderManager::SendDataControlError().
220 virtual void OnMapDataControlAddValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
221 const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& value) = 0;
224 * Called when the request for replacing the value is received from MAP-type data control consumer. @n
225 * The provider must implement this listener for providing its own data.
229 * @param[in] reqId The request ID
230 * @param[in] providerId The data control provider ID
231 * @param[in] dataId A string for identifying a specific map to update @n
232 * The string consists of one or more components, separated by a slash('/').
233 * @param[in] key A key of the value to replace
234 * @param[in] oldValue A value to replace
235 * @param[in] newValue A new value to replace the existing value
236 * @remarks For replying to the data control request, use DataControlProviderManager::SendMapDataControlResult()
237 * or DataControlProviderManager::SendDataControlError().
239 virtual void OnMapDataControlSetValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
240 const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& oldValue,
241 const Tizen::Base::String& newValue) = 0;
244 * Called when the request for removing the value is received from MAP-type data control consumer. @n
245 * The provider must implement this listener for providing its own data.
249 * @param[in] reqId The request ID
250 * @param[in] providerId The data control provider ID
251 * @param[in] dataId A string for identifying a specific map to remove from @n
252 * The string consists of one or more components, separated by a slash('/').
253 * @param[in] key A key of the value to remove
254 * @param[in] value A value to remove
255 * @remarks For replying to the data control request, use DataControlProviderManager::SendMapDataControlResult()
256 * or DataControlProviderManager::SendDataControlError().
258 virtual void OnMapDataControlRemoveValueRequestReceived(RequestId reqId, const Tizen::Base::String& providerId,
259 const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& value) = 0;
263 // This method is for internal use only.
264 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
266 // This method is reserved and may change its name at any time without prior notice.
270 virtual void IMapDataControlProviderEventListener_Reserved1(void) {}
273 // This method is for internal use only.
274 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
276 // This method is reserved and may change its name at any time without prior notice.
280 virtual void IMapDataControlProviderEventListener_Reserved2(void) {}
283 // This method is for internal use only.
284 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
286 // This method is reserved and may change its name at any time without prior notice.
290 virtual void IMapDataControlProviderEventListener_Reserved3(void) {}
293 // This method is for internal use only.
294 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
296 // This method is reserved and may change its name at any time without prior notice.
300 virtual void IMapDataControlProviderEventListener_Reserved4(void) {}
303 // This method is for internal use only.
304 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
306 // This method is reserved and may change its name at any time without prior notice.
310 virtual void IMapDataControlProviderEventListener_Reserved5(void) {}
312 }; // IMapDataControlProviderEventListener
316 #endif // _FAPP_IMAP_DATACONTROL_REQUESTEVENT_LISTENER_H_