tizen 2.3.1 release
[framework/web/wearable/wrt-security.git] / ace / include / ace-dao-ro / PromptModel.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 /* @file        PromptModel.h
17  * @author      Justyna Mejzner (j.kwiatkowsk@samsung.com)
18  * @author      Jaroslaw Osmanski (j.osmanski@samsung.com)
19  * @version     1.0
20  *
21  */
22
23 #ifndef WRT_SRC_ACCESSCONTROL_ENGINE_PROMPT_MODEL_H_
24 #define WRT_SRC_ACCESSCONTROL_ENGINE_PROMPT_MODEL_H_
25
26 #include <memory>
27 #include <string>
28 #include <vector>
29
30 #include <dpl/optional_typedefs.h>
31
32 namespace Prompt {
33 typedef std::vector<std::string> ButtonLabels;
34
35 class PromptLabels
36 {
37 public:
38     PromptLabels(int promptType,
39                  const Prompt::ButtonLabels& questionLabel,
40                  const std::string& mainLabel);
41     DPL::OptionalString getCheckLabel() const;
42     bool isAllowed(const size_t buttonNumber) const;
43     int getPromptType() const;
44     const ButtonLabels& getButtonLabels() const;
45     const std::string& getMainLabel() const;
46
47 private:
48     int m_promptType;
49     ButtonLabels m_buttonLabels;
50     std::string m_mainLabel;
51 };
52
53 typedef std::unique_ptr<PromptLabels> PromptLabelsPtr;
54
55 enum Validity
56 {
57     ONCE,
58     SESSION,
59     ALWAYS
60 };
61
62 class PromptAnswer
63 {
64 public:
65     PromptAnswer(bool isAccessAllowed, Validity validity);
66     PromptAnswer(int aPromptType, unsigned int buttonAns, bool checkAns);
67     bool isAccessAllowed() const;
68     Validity getValidity() const;
69
70 private:
71     bool m_isAccessAllowed;
72     Validity m_validity;
73 };
74
75 class PromptModel
76 {
77   public:
78     static PromptLabels* getOneShotModel(const std::string& resourceId);
79     static PromptLabels* getSessionModel(const std::string& resourceId);
80     static PromptLabels* getBlanketModel(const std::string& resourceId);
81
82     enum PromptType
83     {
84         PROMPT_ONESHOT,
85         PROMPT_SESSION,
86         PROMPT_BLANKET
87     };
88 };
89
90 } // Prompt
91
92 #endif /* WRT_SRC_ACCESSCONTROL_ENGINE_PROMPT_MODEL_H_ */