Merge "Update deprecated libprivilege-control API functions." into tizen
[platform/framework/native/appfw.git] / src / app / FAppMapDataControl.cpp
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.cpp
19  * @brief       This is the implementation for the %MapDataControl class.
20  */
21
22 #include <FAppMapDataControl.h>
23
24 #include <FBaseSysLog.h>
25 #include <FBase_NativeError.h>
26
27 #include "FApp_MapDataControlImpl.h"
28 #include <FSec_AccessController.h>
29
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::App;
33 using namespace Tizen::Security;
34
35 namespace Tizen { namespace App {
36
37 MapDataControl::MapDataControl(void)
38         : __pMapDataControlImpl(null)
39 {
40         __pMapDataControlImpl = new _MapDataControlImpl;
41 }
42
43 MapDataControl::~MapDataControl(void)
44 {
45         delete __pMapDataControlImpl;
46 }
47
48 result
49 MapDataControl::GetValue(const String& dataId, const String& key,
50                 RequestId& reqId, int pageNo, int countPerPage)
51 {
52         result r = _AccessController::CheckUserPrivilege(_PRV_DATACONTROL_CONSUMER);
53         SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
54
55         SysTryReturnResult(NID_APP, __pMapDataControlImpl, E_INVALID_STATE,
56                         "This instance has not been properly constructed yet.");
57
58         return __pMapDataControlImpl->GetValue(dataId, key, reqId, pageNo, countPerPage);
59 }
60
61 result
62 MapDataControl::AddValue(const String& dataId, const String& key,
63                 const String& value, RequestId& reqId)
64 {
65         result r = _AccessController::CheckUserPrivilege(_PRV_DATACONTROL_CONSUMER);
66         SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
67
68         SysTryReturnResult(NID_APP, __pMapDataControlImpl, E_INVALID_STATE,
69                         "This instance has not been properly constructed yet.");
70
71         return __pMapDataControlImpl->AddValue(dataId, key, value, reqId);
72 }
73
74 result
75 MapDataControl::SetValue(const String& dataId, const String& key,
76                 const String& oldValue, const String& newValue, RequestId& reqId)
77 {
78         result r = _AccessController::CheckUserPrivilege(_PRV_DATACONTROL_CONSUMER);
79         SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
80
81         SysTryReturnResult(NID_APP, __pMapDataControlImpl, E_INVALID_STATE,
82                         "This instance has not been properly constructed yet.");
83
84         return __pMapDataControlImpl->SetValue(dataId, key, oldValue, newValue, reqId);
85 }
86
87 result
88 MapDataControl::RemoveValue(const String& dataId, const String& key,
89                 const String& value, RequestId& reqId)
90 {
91         result r = _AccessController::CheckUserPrivilege(_PRV_DATACONTROL_CONSUMER);
92         SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
93
94         SysTryReturnResult(NID_APP, __pMapDataControlImpl, E_INVALID_STATE,
95                         "This instance has not been properly constructed yet.");
96
97         return __pMapDataControlImpl->RemoveValue(dataId, key, value, reqId);
98 }
99
100 result
101 MapDataControl::SetMapDataControlResponseListener(IMapDataControlResponseListener* pListener)
102 {
103         SysTryReturnResult(NID_APP, __pMapDataControlImpl, E_INVALID_STATE,
104                         "This instance has not been properly constructed yet.");
105
106         return __pMapDataControlImpl->SetMapDataControlResponseListener(pListener);
107 }
108
109 }} // Tizen::App
110