sync with master
[platform/framework/native/appfw.git] / src / app / FApp_MapDataControlImpl.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file        FApp_MapDataControlImpl.cpp
20  * @brief       This is the implementation for the %_MapDataControlImpl class.
21  */
22
23 #include <typeinfo>
24 #include <new>
25 #include <unique_ptr.h>
26
27 #include <appsvc/appsvc.h>
28
29 #include <FBaseInteger.h>
30 #include <FBaseString.h>
31 #include <FBaseRtIEventArg.h>
32 #include <FAppMapDataControl.h>
33 #include <FAppIMapDataControlResponseListener.h>
34
35 #include <FBaseSysLog.h>
36
37 #include "FApp_AppControlManager.h"
38 #include "FApp_AppManagerProxy.h"
39 #include "FApp_MapDataControlImpl.h"
40 #include "FApp_AppArg.h"
41
42 using namespace std;
43
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;
49
50 namespace Tizen { namespace App
51 {
52
53 class _MapDataControlEventArg
54         : public IEventArg
55 {
56 public:
57                 _MapDataControlEventArg(_DataControlRequestType requestType, RequestId reqId, String providerId, String dataId,
58                                 IList* pResultValueList, bool providerResult, String* pErrorMsg)
59                         : __requestType(requestType)
60                         , __reqId(reqId)
61                         , __providerId(providerId)
62                         , __dataId(dataId)
63                         , __pResultValueList(pResultValueList)
64                         , __providerResult(providerResult)
65                         , __pErrorMsg(pErrorMsg)
66                 {
67                 }
68                 ~_MapDataControlEventArg(void)
69                 {
70                         if (__pResultValueList)
71                         {
72                                 __pResultValueList->RemoveAll(true);
73                                 delete __pResultValueList;
74                         }
75                         delete __pErrorMsg;
76                 }
77
78                 _DataControlRequestType __requestType;
79                 RequestId __reqId;
80                 String __providerId;
81                 String __dataId;
82                 IList* __pResultValueList;
83                 bool __providerResult;
84                 String* __pErrorMsg;
85 };
86
87 class _MapDataControlEvent
88         : public Event
89 {
90 protected:
91                 virtual void FireImpl(IEventListener& listener, const IEventArg& arg);
92 };
93
94 void
95 _MapDataControlEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
96 {
97         const _MapDataControlEventArg* pArg = dynamic_cast<const _MapDataControlEventArg*>(&arg);
98         if (pArg != null)
99         {
100                 IMapDataControlResponseListener* pListener = dynamic_cast<IMapDataControlResponseListener*> (&listener);
101                 if (pListener != null)
102                 {
103                         switch (pArg->__requestType)
104                         {
105                         case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
106                                 pListener->OnMapDataControlGetValueResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
107                                                 *(pArg->__pResultValueList), pArg->__providerResult, pArg->__pErrorMsg);
108                                 break;
109                         case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
110                                 pListener->OnMapDataControlAddValueResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
111                                                  pArg->__providerResult, pArg->__pErrorMsg);
112                                 break;
113                         case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
114                                 pListener->OnMapDataControlSetValueResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
115                                                 pArg->__providerResult, pArg->__pErrorMsg);
116                                 break;
117                         case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
118                                 pListener->OnMapDataControlRemoveValueResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
119                                                 pArg->__providerResult, pArg->__pErrorMsg);
120                                 break;
121                         default:
122                                 break;
123                         }
124                 }
125         }
126 }
127
128 // private
129 _MapDataControlImpl::_MapDataControlImpl(void)
130         : __appId(L"")
131         , __providerId(L"")
132         , __access(_DATACONTROL_ACCESS_UNDEFINED)
133         , __pPreviousListener(null)
134         , __pMapDataControlEvent(null)
135 {
136 }
137
138 _MapDataControlImpl::~_MapDataControlImpl(void)
139 {
140         delete __pMapDataControlEvent;
141 }
142
143 _MapDataControlImpl*
144 _MapDataControlImpl::GetInstance(MapDataControl& dc)
145 {
146         return dc.__pMapDataControlImpl;
147 }
148
149 const _MapDataControlImpl*
150 _MapDataControlImpl::GetInstance(const MapDataControl& dc)
151 {
152         return dc.__pMapDataControlImpl;
153 }
154
155 result
156 _MapDataControlImpl::StartMapDataControl(int type, const IList* pDataList, int* pReq)
157 {
158         result r = E_SUCCESS;
159
160         _AppArg* pArg = new(std::nothrow) _AppArg; // XXX: pArg will be released in _AppManagerImpl::LaunchApp().
161         SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
162
163         pArg->Construct(*this, static_cast <_DataControlRequestType>(type), pDataList);
164
165         _AppControlManager* pAppManagerImpl = _AppControlManager::GetInstance();
166         int req = -1;
167
168         if (__pMapDataControlEvent)
169         {
170                 // reqId is system-wide id because the bundle is system-wide.
171                 _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pAppManagerImpl, pArg, MapDataControlCallback, __pMapDataControlEvent, -1);
172                 req = reqObj.GetRequestNumber();
173
174                 r = pAppManagerImpl->LaunchApp(__appId, pArg, req);
175                 SysTryCatch(NID_APP, r == E_SUCCESS, reqObj.Invalidate(), r, "[%s] Propgated.", GetErrorMessage(r));
176
177                 if (pReq)
178                 {
179                         *pReq = req;
180                 }
181         }
182         else
183         {
184                 r = pAppManagerImpl->LaunchApp(__appId, pArg);
185                 delete pArg;
186         }
187
188 CATCH:
189         return r;
190 }
191
192 result
193 _MapDataControlImpl::GetValue(const String& dataId, const String& key,
194                 RequestId& reqId, int pageNo, int countPerPage)
195 {
196         SysTryReturnResult(NID_APP, pageNo > 0, E_INVALID_ARG, "The specified pageNo parameter is less than 1");
197         SysTryReturnResult(NID_APP, countPerPage > 0, E_INVALID_ARG, "The specified countPerPage parameter is less than 1");
198         SysTryReturnResult(NID_APP, (__access & _DATACONTROL_ACCESS_READ) > 0, E_ILLEGAL_ACCESS,
199                         "The GetValue query is not permitted by DataControl provider.");
200
201         int id = 0;
202         result r = E_SUCCESS;
203
204         ArrayList* pArgList = null;
205         pArgList = new ArrayList();
206         pArgList->Construct();
207
208         pArgList->Add(*(new String(dataId)));
209         pArgList->Add(*(new String(key)));
210
211         String* pPageNo = new String();
212         pPageNo->Append(pageNo);
213         pArgList->Add(*pPageNo);
214
215         String* pCountPerPage = new String();
216         pCountPerPage->Append(countPerPage);
217         pArgList->Add(*pCountPerPage);
218
219         r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_QUERY, pArgList, &id);
220         SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
221
222         reqId = static_cast< RequestId >(id);
223
224         SysLog(NID_APP, "dataId: %ls, key: %ls, reqId: %d, pageNo: %d, countPerPage: %d",
225                         dataId.GetPointer(), key.GetPointer(), reqId, pageNo, countPerPage);
226
227         // fall through
228 CATCH:
229         pArgList->RemoveAll(true);
230         delete pArgList;
231
232         return r;
233 }
234
235 result
236 _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop)
237 {
238         ArrayList* pResultList = null;
239         ArrayList* pOrigList = null;
240         String* pRequestType = null;
241         String* pResult = null;
242         String* pReqId = null;
243         String* pProviderId = null;
244         String* pDataId = null;
245         String* pErrorMessage = null;
246         String* pErrorMsg = null;
247         String* pResultCount = null;
248         String* pValue = null;
249         ArrayList* pResultValueList = null;
250         int resultCount = 0;
251         int requestType = 0;
252         int reqId = 0;
253         int providerRes = 0;
254         bool providerResult = true;
255         bundle* origBundle = null;
256         bundle* resBundle = null;
257         _MapDataControlEventArg* pEventArg = null;
258         result r = E_SUCCESS;
259
260         SysTryReturnResult(NID_APP, pResArg != null, E_INVALID_ARG, "Empty result callback.");
261         SysLog(NID_APP, "appsvc result value: %d", res);
262
263         resBundle = pResArg->GetBundle();
264         if (resBundle)
265         {
266                 _MapDataControlEvent* pMapDataControlEvent = static_cast< _MapDataControlEvent* >(data);
267
268                 if (pMapDataControlEvent != null && typeid(pMapDataControlEvent) == typeid(_MapDataControlEvent*))
269                 {
270                         const char* p = null;
271
272                         // result list
273                         pResultList = _AppArg::GetListN(resBundle, OSP_K_ARG);
274                         SysTryCatch(NID_APP, pResultList, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result");
275
276                         pResult = dynamic_cast <String*>(pResultList->GetAt(0));
277                         SysTryCatch(NID_APP, pResult, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result");
278                         Integer::Parse(*pResult, providerRes);
279                         providerResult = static_cast< bool >(providerRes);
280
281                         pErrorMessage = dynamic_cast< String* >(pResultList->GetAt(1));
282                         SysTryCatch(NID_APP, pErrorMessage, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result");
283                         pErrorMsg = new (std::nothrow) String(*pErrorMessage);
284                         SysTryCatch(NID_APP, pErrorMsg, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
285                                         "[E_OUT_OF_MEMORY] The memory is insufficient.");
286
287                         // request info
288                         origBundle = pArg->GetBundle();
289
290                         p = appsvc_get_data(origBundle, OSP_K_DATACONTROL_REQUEST_TYPE);
291                         SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
292                         pRequestType = new (std::nothrow) String(p);
293                         SysTryCatch(NID_APP, pRequestType, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
294                                         "[E_OUT_OF_MEMORY] The memory is insufficient.");
295                         Integer::Parse(*pRequestType, requestType);
296
297                         p = appsvc_get_data(origBundle, OSP_K_REQUEST_ID);
298                         SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
299                         pReqId = new (std::nothrow) String(p);
300                         SysTryCatch(NID_APP, pReqId, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
301                                         "[E_OUT_OF_MEMORY] The memory is insufficient.");
302                         Integer::Parse(*pReqId, reqId);
303
304                         p = appsvc_get_data(origBundle, OSP_K_DATACONTROL_PROVIDER);
305                         SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
306                         pProviderId = new (std::nothrow) String(p);
307                         SysTryCatch(NID_APP, pProviderId, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
308                                         "[E_OUT_OF_MEMORY] The memory is insufficient.");
309
310                         pOrigList = _AppArg::GetListN(origBundle, OSP_K_ARG);
311                         SysTryCatch(NID_APP, pOrigList, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
312                         pDataId = dynamic_cast <String*>(pOrigList->GetAt(0));
313                         SysTryCatch(NID_APP, pDataId, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
314
315                         SysLog(NID_APP, "result: %ld, requestType: %d, reqId: %d, providerId: %ls, dataId: %ls, errorMsg: %ls ",
316                                         providerRes, requestType, reqId, pProviderId->GetPointer(), pDataId->GetPointer(), pErrorMsg->GetPointer());
317
318                         switch (static_cast< _DataControlRequestType >(requestType))
319                         {
320                         case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
321                         {
322                                 pResultValueList = new (std::nothrow) ArrayList();
323                                 SysTryCatch(NID_APP, pResultValueList, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
324                                                 "[E_OUT_OF_MEMORY] The memory is insufficient.");
325
326                                 if (providerResult == true)
327                                 {
328                                         pResultCount = dynamic_cast< String* >(pResultList->GetAt(2));
329                                         if (pResultCount == null)
330                                         {
331                                                 SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] invalid result");
332                                                 pResultValueList->RemoveAll(true);
333                                                 delete pResultValueList;
334                                                 goto CATCH;
335                                         }
336                                         Integer::Parse(*pResultCount, resultCount);
337
338                                         int index = 3;
339                                         while (resultCount)
340                                         {
341                                                 pValue = dynamic_cast< String* >(pResultList->GetAt(index));
342                                                 if (pValue == null)
343                                                 {
344                                                         SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] invalid result");
345                                                         pResultValueList->RemoveAll(true);
346                                                         delete pResultValueList;
347                                                         goto CATCH;
348                                                 }
349
350                                                 pResultValueList->Add(*(new (std::nothrow) String(*pValue)));
351                                                 resultCount--;
352                                                 index++;
353                                         }
354                                 }
355
356                                 pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_QUERY, static_cast <RequestId>(reqId),
357                                                 *pProviderId, *pDataId, pResultValueList, providerResult, pErrorMsg);
358                                 SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
359                                 pMapDataControlEvent->Fire(*pEventArg);
360
361                                 break;
362                         }
363                         case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
364                         {
365                                 pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_INSERT, static_cast <RequestId>(reqId),
366                                                 *pProviderId, *pDataId, null, providerResult, pErrorMsg);
367                                 SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
368                                 pMapDataControlEvent->Fire(*pEventArg);
369                                 break;
370                         }
371                         case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
372                         {
373                                 pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_UPDATE, static_cast <RequestId>(reqId),
374                                                 *pProviderId, *pDataId, null, providerResult, pErrorMsg);
375                                 SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
376                                 pMapDataControlEvent->Fire(*pEventArg);
377                                 break;
378                         }
379                         case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
380                         {
381                                 pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_DELETE, static_cast <RequestId>(reqId),
382                                                 *pProviderId, *pDataId, null, providerResult, pErrorMsg);
383                                 SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
384                                 pMapDataControlEvent->Fire(*pEventArg);
385                                 break;
386                         }
387                         default:
388                                 break;
389                         }
390
391                         pResultList->RemoveAll(true);
392                         delete pResultList;
393
394                         pOrigList->RemoveAll(true);
395                         delete pOrigList;
396
397                         delete pRequestType;
398                         delete pReqId;
399                         delete pProviderId;
400                 }
401         }
402
403         return E_SUCCESS;
404
405 CATCH:
406         if (pResultList)
407         {
408                 pResultList->RemoveAll(true);
409                 delete pResultList;
410         }
411
412         if (pOrigList)
413         {
414                 pOrigList->RemoveAll(true);
415                 delete pOrigList;
416         }
417
418         delete pRequestType;
419         delete pReqId;
420         delete pProviderId;
421
422         return r;
423 }
424
425 result
426 _MapDataControlImpl::AddValue(const String& dataId, const String& key,
427                 const String& value, RequestId& reqId)
428 {
429         SysTryReturnResult(NID_APP, (__access & _DATACONTROL_ACCESS_WRITE) > 0, E_ILLEGAL_ACCESS,
430                         "The AddValue query is not permitted by DataControl provider.");
431
432         int id = 0;
433         result r = E_SUCCESS;
434
435         ArrayList* pArgList = null;
436         pArgList = new ArrayList();
437         pArgList->Construct();
438
439         pArgList->Add(*(new String(dataId)));
440         pArgList->Add(*(new String(key)));
441         pArgList->Add(*(new String(value)));
442
443         r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_INSERT, pArgList, &id);
444         SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
445
446         reqId = static_cast< RequestId >(id);
447
448         SysLog(NID_APP, "dataId: %ls, key: %ls, value: %ls, reqId: %d",
449                         dataId.GetPointer(), key.GetPointer(), value.GetPointer(), reqId);
450
451         // fall through
452 CATCH:
453         pArgList->RemoveAll(true);
454         delete pArgList;
455
456         return r;
457 }
458
459 result
460 _MapDataControlImpl::SetValue(const String& dataId, const String& key,
461                 const String& oldValue, const String& newValue, RequestId& reqId)
462 {
463         SysTryReturnResult(NID_APP, (__access & _DATACONTROL_ACCESS_WRITE) > 0, E_ILLEGAL_ACCESS,
464                         "The SetValue query is not permitted by DataControl provider.");
465
466         int id = 0;
467         result r = E_SUCCESS;
468
469         ArrayList* pArgList = null;
470         pArgList = new ArrayList();
471         pArgList->Construct();
472
473         pArgList->Add(*(new String(dataId)));
474         pArgList->Add(*(new String(key)));
475         pArgList->Add(*(new String(oldValue)));
476         pArgList->Add(*(new String(newValue)));
477
478         r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_UPDATE, pArgList, &id);
479         SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
480
481         reqId = static_cast< RequestId >(id);
482
483         SysLog(NID_APP, "dataId: %ls, key: %ls, oldValue: %ls, newValue: %ls, reqId: %d",
484                         dataId.GetPointer(), key.GetPointer(), oldValue.GetPointer(), newValue.GetPointer(), reqId);
485
486         // fall through
487 CATCH:
488         pArgList->RemoveAll(true);
489         delete pArgList;
490
491         return r;
492 }
493
494 result
495 _MapDataControlImpl::RemoveValue(const String& dataId, const String& key,
496                 const String& value, RequestId& reqId)
497 {
498         SysTryReturnResult(NID_APP, (__access & _DATACONTROL_ACCESS_WRITE) > 0, E_ILLEGAL_ACCESS,
499                         "The RemoveValue query is not permitted by DataControl provider.");
500
501         int id = 0;
502         result r = E_SUCCESS;
503
504         ArrayList* pArgList = null;
505         pArgList = new ArrayList();
506         pArgList->Construct();
507
508         pArgList->Add(*(new String(dataId)));
509         pArgList->Add(*(new String(key)));
510         pArgList->Add(*(new String(value)));
511
512         r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_DELETE, pArgList, &id);
513         SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
514
515         reqId = static_cast< RequestId >(id);
516
517         SysLog(NID_APP, "dataId: %ls, key: %ls, value: %ls, reqId: %d",
518                         dataId.GetPointer(), key.GetPointer(), value.GetPointer(), reqId);
519
520         // fall through
521 CATCH:
522         pArgList->RemoveAll(true);
523         delete pArgList;
524
525         return r;
526 }
527
528 result
529 _MapDataControlImpl::SetMapDataControlResponseListener(IMapDataControlResponseListener* pListener)
530 {
531         result r = E_SUCCESS;
532
533         if (__pPreviousListener != null)
534         {
535                 r =  __pMapDataControlEvent->RemoveListener(*__pPreviousListener);
536                 SysTryReturnResult(NID_APP, !IsFailed(r), E_SYSTEM, "Remove listener failed.");
537                  __pPreviousListener = null;
538         }
539
540         if (pListener != null)
541         {
542                 r =  __pMapDataControlEvent->AddListener(*pListener);
543                 if (IsFailed(r))
544                 {
545                         switch (r)
546                         {
547                         case E_OBJ_ALREADY_EXIST:
548                                 return E_SUCCESS;
549                         case E_INVALID_OPERATION:
550                                 SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] The thread setting the listener is worker thread.");
551                                 return E_SYSTEM;
552                         default:
553                                 SysLogException(NID_APP, r, "[%s] Propagating to caller...", GetErrorMessage(r));
554                                 return r;
555                         }
556                 }
557         }
558
559         __pPreviousListener = pListener;
560
561         return E_SUCCESS;
562 }
563
564 // private
565 MapDataControl*
566 _MapDataControlImpl::CreateMapDataControl(const AppId& appId, const String& providerId, const String& access)
567 {
568         unique_ptr<MapDataControl> pDc(new (std::nothrow) MapDataControl);
569         SysTryReturn(NID_APP, pDc != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient");
570
571         _MapDataControlImpl* pDcImpl = _MapDataControlImpl::GetInstance(*pDc);
572         unique_ptr<_MapDataControlEvent> pMapDataControlEvent(new (std::nothrow) _MapDataControlEvent);
573         SysTryReturn(NID_IO, pMapDataControlEvent != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
574
575         pDcImpl->__pMapDataControlEvent = pMapDataControlEvent.release();
576         pDcImpl->__appId = appId;
577         pDcImpl->__providerId = providerId;
578
579         if (access == L"readonly")
580         {
581                 pDcImpl->__access = _DATACONTROL_ACCESS_READ;
582         }
583         else if (access == L"writeonly")
584         {
585                 pDcImpl->__access = _DATACONTROL_ACCESS_WRITE;
586         }
587         else if (access == L"readwrite")
588         {
589                 pDcImpl->__access = _DATACONTROL_ACCESS_READWRITE;
590         }
591         else
592         {
593                 pDcImpl->__access = _DATACONTROL_ACCESS_UNDEFINED;
594                 SysLog(NID_IO, "The accessibility of DataControl provider is invalid.");
595         }
596
597         return pDc.release();
598 }
599
600 }} // Tizen::App
601