tizen 2.3 release
[framework/web/wearable/wrt-security.git] / mockups / AceDAOReadOnly_mock.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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  * @author     Tomasz Swierczek (t.swierczek@samsung.com)
18  * @version    0.1
19  * @brief      ACE DAO read only mockup class
20  */
21
22 #ifndef WRT_MOCKUPS_ACE_DAO_READ_ONLY_MOCK_H_
23 #define WRT_MOCKUPS_ACE_DAO_READ_ONLY_MOCK_H_
24
25 #include <set>
26 #include <utility>
27 #include <string>
28
29 #include <openssl/md5.h>
30 #include <dpl/exception.h>
31 #include <dpl/string.h>
32
33 #include <PreferenceTypes.h>
34 #include <BaseAttribute.h>
35 #include <BasePermission.h>
36 #include <IRequest.h>
37 #include <PolicyEffect.h>
38 #include <PolicyResult.h>
39 #include <PromptDecision.h>
40 #include <dpl/foreach.h>
41
42 namespace AceDB {
43
44 typedef std::map<DPL::String, bool> RequestedDevCapsMap;
45 typedef DPL::String FeatureName;
46 typedef std::vector<FeatureName> FeatureNameVector;
47
48 class AceDAOReadOnly
49 {
50   public:
51     class Exception
52     {
53       public:
54         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
55         DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
56     };
57
58     AceDAOReadOnly() {}
59
60     static void attachToThreadRO(){};
61     static void attachToThreadRW(){};
62     static void detachFromThread(){};
63
64     // policy effect/decision
65     static OptionalExtendedPolicyResult getPolicyResult(
66             const BaseAttributeSet &/*attributes*/)
67     {
68         return m_policyResult;
69     }
70
71     // prompt decision
72     static OptionalCachedPromptDecision getPromptDecision(
73             WidgetHandle /*widgetHandle*/,
74             int /*hash*/)
75     {
76         return m_promptDecision;
77     }
78
79     // resource settings
80     static PreferenceTypes getDevCapSetting(const std::string &/*resource*/)
81     {
82         return m_devCapSetting;
83     }
84     static void getDevCapSettings(PreferenceTypesMap *preferences)
85     {
86         *preferences = m_devCapSettings;
87     }
88
89     // user settings
90     static void getWidgetDevCapSettings(BasePermissionList *permissions)
91     {
92         *permissions = m_widgetDevCapSettings;
93     }
94
95     static PreferenceTypes getWidgetDevCapSetting(
96             const std::string &/*resource*/,
97             WidgetHandle /*handler*/)
98     {
99         return m_widgetDevCapSetting;
100     }
101
102     static void getAttributes(BaseAttributeSet *attributes)
103     {
104         *attributes = m_attributeSet;
105     }
106
107     static void getRequestedDevCaps(
108         int /*widgetHandle*/,
109         RequestedDevCapsMap *permissions)
110     {
111         *permissions = m_devCapPermissions;
112     }
113
114     // Setting return values for mockups
115     static void setPolicyResult(OptionalExtendedPolicyResult value)
116     {
117         m_policyResult = value;
118     }
119
120     static void setPromptDecision(OptionalCachedPromptDecision value)
121     {
122         m_promptDecision = value;
123     }
124
125     static void setDevCapSetting(PreferenceTypes value)
126     {
127         m_devCapSetting = value;
128     }
129
130     static void setWidgetDevCapSetting(PreferenceTypes value)
131     {
132         m_widgetDevCapSetting = value;
133     }
134
135     static void setWidgetDevCapSettings(BasePermissionList value)
136     {
137         m_widgetDevCapSettings = value;
138     }
139
140     static void setDevCapSettings(PreferenceTypesMap value)
141     {
142         m_devCapSettings = value;
143     }
144
145     static void setAttributeSet(BaseAttributeSet value)
146     {
147         m_attributeSet = value;
148     }
149
150     static void setDevCapPermissions(RequestedDevCapsMap value)
151     {
152         m_devCapPermissions = value;
153     }
154
155     static void getAcceptedFeature(
156         WidgetHandle /* widgetHandle */,
157         FeatureNameVector *featureVector)
158     {
159         *featureVector = m_featureName;
160     }
161
162     static void setAcceptedFeature(const FeatureNameVector &fvector)
163     {
164         m_featureName = fvector;
165     }
166
167     static std::string getGUID(const WidgetHandle& handle)
168     {
169         return m_guid;
170     }
171
172   protected:
173     static OptionalExtendedPolicyResult m_policyResult;
174     static OptionalCachedPromptDecision m_promptDecision;
175     static PreferenceTypes m_devCapSetting;
176     static PreferenceTypes m_widgetDevCapSetting;
177     static PreferenceTypesMap m_devCapSettings;
178     static BaseAttributeSet m_attributeSet;
179     static BasePermissionList m_widgetDevCapSettings;
180     static RequestedDevCapsMap m_devCapPermissions;
181     static FeatureNameVector m_featureName;
182     static std::string m_guid;
183 };
184
185 }
186
187 #endif // WRT_MOCKUPS_ACE_DAO_READ_ONLY_MOCK_H_