Update wrt_0.8.85
[platform/framework/web/wrt.git] / src / popup-process / 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 Wrt {
33 namespace Prompt {
34 typedef std::vector<std::string> ButtonLabels;
35
36 class PromptLabels
37 {
38 public:
39     PromptLabels(int promptType,
40                  const Prompt::ButtonLabels& questionLabel,
41                  const std::string& mainLabel);
42     DPL::OptionalString getCheckLabel() const;
43     bool isAllowed(const size_t buttonNumber) const;
44     int getPromptType() const;
45     const ButtonLabels& getButtonLabels() const;
46     const std::string& getMainLabel() const;
47
48 private:
49     int m_promptType;
50     ButtonLabels m_buttonLabels;
51     std::string m_mainLabel;
52 };
53
54 typedef std::unique_ptr<PromptLabels> PromptLabelsPtr;
55
56 enum Validity
57 {
58     ONCE,
59     SESSION,
60     ALWAYS
61 };
62
63 class PromptAnswer
64 {
65 public:
66     PromptAnswer(bool isAccessAllowed, Validity validity);
67     PromptAnswer(int aPromptType, unsigned int buttonAns, bool checkAns);
68     bool isAccessAllowed() const;
69     Validity getValidity() const;
70
71 private:
72     bool m_isAccessAllowed;
73     Validity m_validity;
74 };
75
76 class PromptModel
77 {
78   public:
79     static PromptLabels* getOneShotModel(const std::string& resourceId);
80     static PromptLabels* getSessionModel(const std::string& resourceId);
81     static PromptLabels* getBlanketModel(const std::string& resourceId);
82
83     enum PromptType
84     {
85         PROMPT_ONESHOT,
86         PROMPT_SESSION,
87         PROMPT_BLANKET
88     };
89 };
90
91 } // Prompt
92 } // Wrt
93
94 #endif /* WRT_SRC_ACCESSCONTROL_ENGINE_PROMPT_MODEL_H_ */