tizen beta release
[framework/web/wrt-commons.git] / modules / ace / include / dpl / ace-dao-ro / AceDAOReadOnly.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  *
18  *
19  * @file       AceDAOReadOnly.h
20  * @author     Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
21  * @author     Grzegorz Krawczyk (g.krawczyk@samsung.com)
22  * @version    0.1
23  * @brief
24  */
25
26 #ifndef ACE_DAO_READ_ONLY_H_
27 #define ACE_DAO_READ_ONLY_H_
28
29 #include <openssl/md5.h>
30 #include <dpl/string.h>
31 #include <dpl/exception.h>
32 #include <dpl/ace-dao-ro/PreferenceTypes.h>
33 #include <dpl/ace-dao-ro/BaseAttribute.h>
34 #include <dpl/ace-dao-ro/BasePermission.h>
35 #include <dpl/ace-dao-ro/IRequest.h>
36 #include <dpl/ace/PolicyEffect.h>
37 #include <dpl/ace/PolicyResult.h>
38 #include <dpl/ace/PromptDecision.h>
39 #include <dpl/ace-dao-ro/wrt_db_types.h>
40
41 namespace AceDB {
42
43 class AceDAOReadOnly
44 {
45   public:
46     class Exception
47     {
48       public:
49         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
50         DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
51     };
52
53     AceDAOReadOnly() {}
54
55     static void attachToThread();
56     static void detachFromThread();
57
58     // policy effect/decision
59     static OptionalPolicyResult getPolicyResult(
60             const BaseAttributeSet &attributes);
61
62     static OptionalPolicyResult getPolicyResult(
63         const DPL::String &attrHash);
64
65     // prompt decision
66     static OptionalCachedPromptDecision getPromptDecision(
67             const DPL::String &hash,
68             const std::string &userParam);
69     static OptionalCachedPromptDecision getPromptDecision(
70             const BaseAttributeSet &attribites,
71             const std::string &userParam);
72
73     // resource settings
74     static PreferenceTypes getDevCapSetting(const std::string &resource);
75     static void getDevCapSettings(PreferenceTypesMap *preferences);
76
77     // user settings
78     static void getWidgetDevCapSettings(BasePermissionList *permissions);
79     static PreferenceTypes getWidgetDevCapSetting(
80             const std::string &resource,
81             WidgetHandle handler);
82
83     static void getAttributes(BaseAttributeSet *attributes);
84
85     // static dev cap permissions
86     //
87     // (For a given widget handle, a set of device caps is
88     // granted "statically", i.e. it is determined at installation
89     // time that the widget will always get (at launch) the SMACK
90     // permissions needed to use those device caps).
91     //
92     // 'permissions' is an output parameter - it must point to
93     // an existing set and the function will clear it and fill
94     // with the device cap names as described.
95     static void getStaticDevCapPermissions(
96         int widgetHandle,
97         std::set<DPL::String> *permissions);
98
99   protected:
100     static int promptDecisionToInt(PromptDecision decision);
101     static PromptDecision intToPromptDecision(int decision);
102 };
103
104 }
105
106 #endif