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 FApp_MapDataControlImpl.cpp
20 * @brief This is the implementation for the %_MapDataControlImpl class.
25 #include <unique_ptr.h>
27 #include <appsvc/appsvc.h>
29 #include <FBaseInteger.h>
30 #include <FBaseString.h>
31 #include <FBaseRtIEventArg.h>
32 #include <FAppMapDataControl.h>
33 #include <FAppIMapDataControlResponseListener.h>
35 #include <FBaseSysLog.h>
37 #include "FApp_AppControlManager.h"
38 #include "FApp_MapDataControlImpl.h"
39 #include "FApp_AppArg.h"
40 #include "FApp_DataControlManager.h"
44 using namespace Tizen::Base;
45 using namespace Tizen::Base::Collection;
46 using namespace Tizen::Base::Runtime;
47 using namespace Tizen::App;
48 using namespace Tizen::Io;
50 namespace Tizen { namespace App
53 static const int MAX_REQUEST_COUNT = 128;
54 static const int _MAX_ARGUMENT_SIZE = 16384; // 16KB
56 class _MapDataControlEventArg
60 _MapDataControlEventArg(_DataControlRequestType requestType, RequestId reqId, String providerId, String dataId,
61 IList* pResultValueList, bool providerResult, String* pErrorMsg)
62 : __requestType(requestType)
64 , __providerId(providerId)
66 , __pResultValueList(pResultValueList)
67 , __providerResult(providerResult)
68 , __pErrorMsg(pErrorMsg)
71 ~_MapDataControlEventArg(void)
73 if (__pResultValueList)
75 __pResultValueList->RemoveAll(true);
76 delete __pResultValueList;
81 _DataControlRequestType __requestType;
85 IList* __pResultValueList;
86 bool __providerResult;
90 class _MapDataControlEvent
94 virtual void FireImpl(IEventListener& listener, const IEventArg& arg);
98 _MapDataControlEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
100 const _MapDataControlEventArg* pArg = dynamic_cast<const _MapDataControlEventArg*>(&arg);
103 IMapDataControlResponseListener* pListener = dynamic_cast<IMapDataControlResponseListener*> (&listener);
104 if (pListener != null)
106 switch (pArg->__requestType)
108 case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
109 pListener->OnMapDataControlGetValueResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
110 *(pArg->__pResultValueList), pArg->__providerResult, pArg->__pErrorMsg);
112 case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
113 pListener->OnMapDataControlAddValueResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
114 pArg->__providerResult, pArg->__pErrorMsg);
116 case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
117 pListener->OnMapDataControlSetValueResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
118 pArg->__providerResult, pArg->__pErrorMsg);
120 case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
121 pListener->OnMapDataControlRemoveValueResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
122 pArg->__providerResult, pArg->__pErrorMsg);
132 _MapDataControlImpl::_MapDataControlImpl(void)
135 , __access(_DATACONTROL_ACCESS_UNDEFINED)
136 , __pPreviousListener(null)
137 , __pMapDataControlEvent(null)
141 _MapDataControlImpl::~_MapDataControlImpl(void)
143 delete __pMapDataControlEvent;
147 _MapDataControlImpl::GetInstance(MapDataControl& dc)
149 return dc.__pMapDataControlImpl;
152 const _MapDataControlImpl*
153 _MapDataControlImpl::GetInstance(const MapDataControl& dc)
155 return dc.__pMapDataControlImpl;
159 _MapDataControlImpl::StartMapDataControl(int type, const IList* pDataList, int* pReq)
161 Integer* pReqId = null;
162 _DataControlRequestInfo* pReqInfo = null;
163 result r = E_SUCCESS;
166 _AppControlManager* pAppManagerImpl = _AppControlManager::GetInstance();
168 // Check the request count of DataControl operation
169 int count = pAppManagerImpl->GetLaunchRequestCount();
170 SysLog(NID_APP, "Current launch request count: %d", count);
172 SysTryReturnResult(NID_APP, count < MAX_REQUEST_COUNT, E_MAX_EXCEEDED, "The number of requests has exceeded the maximum limit.");
174 _AppArg* pArg = new(std::nothrow) _AppArg; // XXX: pArg will be released in _AppManagerImpl::LaunchApp().
175 SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
177 pArg->Construct(*this, static_cast <_DataControlRequestType>(type), pDataList);
179 if (__pMapDataControlEvent)
181 // reqId is system-wide id because the bundle is system-wide.
183 _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pAppManagerImpl, pArg, MapDataControlCallback, __pMapDataControlEvent, -1);
184 req = reqObj.GetRequestNumber();
186 _DataControlManager* pDcMgr = _DataControlManager::GetInstance();
187 _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pAppManagerImpl, pArg, MapDataControlCallback, pDcMgr, -1);
188 req = reqObj.GetRequestNumber();
190 pReqId = new (std::nothrow) Integer(req);
191 SysTryCatch(NID_APP, pReqId != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
192 "[E_OUT_OF_MEMORY] The memory is insufficient");
194 pReqInfo = new (std::nothrow) _DataControlRequestInfo(__pMapDataControlEvent);
195 SysTryCatch(NID_APP, pReqId != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
196 "[E_OUT_OF_MEMORY] The memory is insufficient");
198 r = pDcMgr->AddRequestInfo(pReqId, pReqInfo);
199 SysTryCatch(NID_APP, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[%s] Failed to add request info", GetErrorMessage(r));
201 r = pAppManagerImpl->LaunchApp(__appId, pArg, req);
204 SysPropagate(NID_APP, r);
206 pDcMgr->RemoveRequestInfo(*pReqId);
218 r = pAppManagerImpl->LaunchApp(__appId, pArg);
219 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
233 _MapDataControlImpl::GetValue(const String& dataId, const String& key,
234 RequestId& reqId, int pageNo, int countPerPage)
236 SysTryReturnResult(NID_APP, pageNo > 0, E_INVALID_ARG, "The specified pageNo parameter is less than 1");
237 SysTryReturnResult(NID_APP, countPerPage > 0, E_INVALID_ARG, "The specified countPerPage parameter is less than 1");
238 SysTryReturnResult(NID_APP, (__access & _DATACONTROL_ACCESS_READ) > 0, E_ILLEGAL_ACCESS,
239 "The GetValue query is not permitted by DataControl provider.");
241 String* pPageNo = null;
242 String* pCountPerPage = null;
244 result r = E_SUCCESS;
246 ArrayList* pArgList = new ArrayList();
247 pArgList->Construct();
249 pArgList->Add(*(new String(dataId)));
250 pArgList->Add(*(new String(key)));
251 long long argSize = dataId.GetLength() * sizeof(wchar_t);
252 argSize += key.GetLength() * sizeof(wchar_t);
253 SysTryCatch(NID_APP, argSize <= _MAX_ARGUMENT_SIZE, r = E_MAX_EXCEEDED, E_MAX_EXCEEDED,
254 "[E_MAX_EXCEEDED] The size of sending argument (%d) exceeds the maximum limit.", argSize);
256 pPageNo = new (std::nothrow) String();
257 pPageNo->Append(pageNo);
258 pArgList->Add(*pPageNo);
260 pCountPerPage = new (std::nothrow) String();
261 pCountPerPage->Append(countPerPage);
262 pArgList->Add(*pCountPerPage);
264 r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_QUERY, pArgList, &id);
265 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
267 reqId = static_cast< RequestId >(id);
269 SysLog(NID_APP, "[DC_CALLER_SEND] data: %ls, key: %ls, req: %d, pageNo: %d, countPerPage: %d",
270 dataId.GetPointer(), key.GetPointer(), reqId, pageNo, countPerPage);
274 pArgList->RemoveAll(true);
281 _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop, int option)
283 ArrayList* pResultList = null;
284 String* pResult = null;
285 String* pProviderId = null;
286 String* pDataId = null;
287 String* pErrorMessage = null;
288 String* pErrorMsg = null;
289 String* pResultCount = null;
290 String* pValue = null;
291 ArrayList* pResultValueList = null;
297 bool providerResult = true;
298 //bundle* origBundle = null;
299 bundle* resBundle = null;
300 _MapDataControlEventArg* pEventArg = null;
301 const char* p = null;
302 result r = E_SUCCESS;
304 SysTryReturnResult(NID_APP, pResArg != null, E_INVALID_ARG, "Empty result callback.");
305 SysLog(NID_APP, "appsvc result value: %d", res);
307 resBundle = pResArg->GetBundle();
310 p = appsvc_get_data(resBundle, OSP_K_REQUEST_ID);
311 SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
315 _DataControlManager* pDcMgr = static_cast< _DataControlManager* >(data);
316 _DataControlRequestInfo* pReqInfo = pDcMgr->GetRequestInfo(key);
317 SysTryCatch(NID_APP, pReqInfo != null, r = E_SYSTEM, E_SYSTEM,
318 "[E_SYSTEM] Failed to get request info");
320 _MapDataControlEvent* pMapDataControlEvent = dynamic_cast< _MapDataControlEvent* >(pReqInfo->GetEvent());
321 SysTryCatch(NID_APP, pMapDataControlEvent != null, r = E_SYSTEM, E_SYSTEM,
322 "[E_SYSTEM] invalid request info");
324 pDcMgr->RemoveRequestInfo(key);
326 if (pMapDataControlEvent != null && typeid(pMapDataControlEvent) == typeid(_MapDataControlEvent*))
330 pResultList = _AppArg::GetListN(resBundle, OSP_K_ARG);
331 SysTryCatch(NID_APP, pResultList, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result");
333 pResult = dynamic_cast <String*>(pResultList->GetAt(0)); // result list[0]
334 SysTryCatch(NID_APP, pResult, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result");
335 Integer::Parse(*pResult, providerRes);
336 providerResult = static_cast< bool >(providerRes);
338 pErrorMessage = dynamic_cast< String* >(pResultList->GetAt(1)); // result list[1]
339 SysTryCatch(NID_APP, pErrorMessage, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result");
340 pErrorMsg = new (std::nothrow) String(*pErrorMessage);
341 SysTryCatch(NID_APP, pErrorMsg, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
342 "[E_OUT_OF_MEMORY] The memory is insufficient.");
345 //origBundle = pArg->GetBundle();
347 p = appsvc_get_data(resBundle, OSP_K_DATACONTROL_REQUEST_TYPE);
348 SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
349 requestType = atoi(p);
351 p = appsvc_get_data(resBundle, OSP_K_DATACONTROL_PROVIDER);
352 SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
353 pProviderId = new (std::nothrow) String(p);
354 SysTryCatch(NID_APP, pProviderId, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
355 "[E_OUT_OF_MEMORY] The memory is insufficient.");
357 p = appsvc_get_data(resBundle, OSP_K_DATACONTROL_DATA);
358 SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
359 pDataId = new (std::nothrow) String(p);
360 SysTryCatch(NID_APP, pDataId, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
361 "[E_OUT_OF_MEMORY] The memory is insufficient.");
363 SysLog(NID_APP, "[DC_CALLER_RECV] provider result: %ld, requestType: %d, req: %d, provider: %ls, data: %ls, errorMsg: %ls ",
364 providerRes, requestType, reqId, pProviderId->GetPointer(), pDataId->GetPointer(), pErrorMsg->GetPointer());
366 switch (static_cast< _DataControlRequestType >(requestType))
368 case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
370 pResultValueList = new (std::nothrow) ArrayList();
371 SysTryCatch(NID_APP, pResultValueList, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
372 "[E_OUT_OF_MEMORY] The memory is insufficient.");
374 if (providerResult == true)
376 pResultCount = dynamic_cast< String* >(pResultList->GetAt(2)); // result list[2]
377 if (pResultCount == null)
379 SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] invalid result");
380 pResultValueList->RemoveAll(true);
381 delete pResultValueList;
384 Integer::Parse(*pResultCount, resultCount);
389 pValue = dynamic_cast< String* >(pResultList->GetAt(index));
392 SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] invalid result");
393 pResultValueList->RemoveAll(true);
394 delete pResultValueList;
398 pResultValueList->Add(*(new (std::nothrow) String(*pValue)));
404 pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_QUERY, static_cast <RequestId>(reqId),
405 *pProviderId, *pDataId, pResultValueList, providerResult, pErrorMsg);
406 SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
407 pMapDataControlEvent->Fire(*pEventArg);
411 case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
413 pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_INSERT, static_cast <RequestId>(reqId),
414 *pProviderId, *pDataId, null, providerResult, pErrorMsg);
415 SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
416 pMapDataControlEvent->Fire(*pEventArg);
419 case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
421 pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_UPDATE, static_cast <RequestId>(reqId),
422 *pProviderId, *pDataId, null, providerResult, pErrorMsg);
423 SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
424 pMapDataControlEvent->Fire(*pEventArg);
427 case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
429 pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_DELETE, static_cast <RequestId>(reqId),
430 *pProviderId, *pDataId, null, providerResult, pErrorMsg);
431 SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
432 pMapDataControlEvent->Fire(*pEventArg);
439 pResultList->RemoveAll(true);
445 p = appsvc_get_data(pArg->GetBundle(), OSP_K_REQUEST_ID);
446 SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
447 launchReqId = atoi(p);
449 // Remove the request count
450 SysLog(NID_APP, "Remove a launch request: req: %d", launchReqId);
451 _AppControlManager::GetInstance()->RemoveLaunchRequest(launchReqId);
458 pResultList->RemoveAll(true);
467 _MapDataControlImpl::AddValue(const String& dataId, const String& key,
468 const String& value, RequestId& reqId)
470 SysTryReturnResult(NID_APP, (__access & _DATACONTROL_ACCESS_WRITE) > 0, E_ILLEGAL_ACCESS,
471 "The AddValue query is not permitted by DataControl provider.");
474 result r = E_SUCCESS;
476 ArrayList* pArgList = null;
477 pArgList = new ArrayList();
478 pArgList->Construct();
480 pArgList->Add(*(new String(dataId)));
481 pArgList->Add(*(new String(key)));
482 pArgList->Add(*(new String(value)));
483 long long argSize = dataId.GetLength() * sizeof(wchar_t);
484 argSize += key.GetLength() * sizeof(wchar_t);
485 argSize += value.GetLength() * sizeof(wchar_t);
486 SysTryCatch(NID_APP, argSize <= _MAX_ARGUMENT_SIZE, r = E_MAX_EXCEEDED, E_MAX_EXCEEDED,
487 "[E_MAX_EXCEEDED] The size of sending argument (%d) exceeds the maximum limit.", argSize);
489 r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_INSERT, pArgList, &id);
490 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
492 reqId = static_cast< RequestId >(id);
494 SysLog(NID_APP, "[DC_CALLER_SEND] data: %ls, key: %ls, value: %ls, req: %d",
495 dataId.GetPointer(), key.GetPointer(), value.GetPointer(), reqId);
499 pArgList->RemoveAll(true);
506 _MapDataControlImpl::SetValue(const String& dataId, const String& key,
507 const String& oldValue, const String& newValue, RequestId& reqId)
509 SysTryReturnResult(NID_APP, (__access & _DATACONTROL_ACCESS_WRITE) > 0, E_ILLEGAL_ACCESS,
510 "The SetValue query is not permitted by DataControl provider.");
513 result r = E_SUCCESS;
515 ArrayList* pArgList = null;
516 pArgList = new ArrayList();
517 pArgList->Construct();
519 pArgList->Add(*(new String(dataId)));
520 pArgList->Add(*(new String(key)));
521 pArgList->Add(*(new String(oldValue)));
522 pArgList->Add(*(new String(newValue)));
523 long long argSize = dataId.GetLength() * sizeof(wchar_t);
524 argSize += key.GetLength() * sizeof(wchar_t);
525 argSize += oldValue.GetLength() * sizeof(wchar_t);
526 argSize += newValue.GetLength() * sizeof(wchar_t);
527 SysTryCatch(NID_APP, argSize <= _MAX_ARGUMENT_SIZE, r = E_MAX_EXCEEDED, E_MAX_EXCEEDED,
528 "[E_MAX_EXCEEDED] The size of sending argument (%d) exceeds the maximum limit.", argSize);
530 r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_UPDATE, pArgList, &id);
531 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
533 reqId = static_cast< RequestId >(id);
535 SysLog(NID_APP, "[DC_CALLER_SEND] data: %ls, key: %ls, oldValue: %ls, newValue: %ls, req: %d",
536 dataId.GetPointer(), key.GetPointer(), oldValue.GetPointer(), newValue.GetPointer(), reqId);
540 pArgList->RemoveAll(true);
547 _MapDataControlImpl::RemoveValue(const String& dataId, const String& key,
548 const String& value, RequestId& reqId)
550 SysTryReturnResult(NID_APP, (__access & _DATACONTROL_ACCESS_WRITE) > 0, E_ILLEGAL_ACCESS,
551 "The RemoveValue query is not permitted by DataControl provider.");
554 result r = E_SUCCESS;
556 ArrayList* pArgList = null;
557 pArgList = new ArrayList();
558 pArgList->Construct();
560 pArgList->Add(*(new String(dataId)));
561 pArgList->Add(*(new String(key)));
562 pArgList->Add(*(new String(value)));
563 long long argSize = dataId.GetLength() * sizeof(wchar_t);
564 argSize += key.GetLength() * sizeof(wchar_t);
565 argSize += value.GetLength() * sizeof(wchar_t);
566 SysTryCatch(NID_APP, argSize <= _MAX_ARGUMENT_SIZE, r = E_MAX_EXCEEDED, E_MAX_EXCEEDED,
567 "[E_MAX_EXCEEDED] The size of sending argument (%d) exceeds the maximum limit.", argSize);
569 r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_DELETE, pArgList, &id);
570 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
572 reqId = static_cast< RequestId >(id);
574 SysLog(NID_APP, "[DC_CALLER_SEND] data: %ls, key: %ls, value: %ls, req: %d",
575 dataId.GetPointer(), key.GetPointer(), value.GetPointer(), reqId);
579 pArgList->RemoveAll(true);
586 _MapDataControlImpl::SetMapDataControlResponseListener(IMapDataControlResponseListener* pListener)
588 result r = E_SUCCESS;
590 if (__pPreviousListener != null)
592 r = __pMapDataControlEvent->RemoveListener(*__pPreviousListener);
593 SysTryReturnResult(NID_APP, !IsFailed(r), E_SYSTEM, "Remove listener failed.");
594 __pPreviousListener = null;
597 if (pListener != null)
599 r = __pMapDataControlEvent->AddListener(*pListener);
604 case E_OBJ_ALREADY_EXIST:
606 case E_INVALID_OPERATION:
607 SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] The thread setting the listener is worker thread.");
610 SysLogException(NID_APP, r, "[%s] Propagating to caller...", GetErrorMessage(r));
616 __pPreviousListener = pListener;
623 _MapDataControlImpl::CreateMapDataControl(const AppId& appId, const String& providerId, const String& access)
625 unique_ptr<MapDataControl> pDc(new (std::nothrow) MapDataControl);
626 SysTryReturn(NID_APP, pDc != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient");
628 _MapDataControlImpl* pDcImpl = _MapDataControlImpl::GetInstance(*pDc);
629 unique_ptr<_MapDataControlEvent> pMapDataControlEvent(new (std::nothrow) _MapDataControlEvent);
630 SysTryReturn(NID_IO, pMapDataControlEvent != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
632 pDcImpl->__pMapDataControlEvent = pMapDataControlEvent.release();
633 pDcImpl->__appId = appId;
634 pDcImpl->__providerId = providerId;
636 if (access == L"readonly")
638 pDcImpl->__access = _DATACONTROL_ACCESS_READ;
640 else if (access == L"writeonly")
642 pDcImpl->__access = _DATACONTROL_ACCESS_WRITE;
644 else if (access == L"readwrite")
646 pDcImpl->__access = _DATACONTROL_ACCESS_READWRITE;
650 pDcImpl->__access = _DATACONTROL_ACCESS_UNDEFINED;
651 SysLog(NID_IO, "The accessibility of DataControl provider is invalid.");
654 return pDc.release();