tizen 2.3 release
[framework/web/wearable/wrt-security.git] / ace / include / ace / ConfigurationManager.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 #ifndef _CONFIGURATIONMANAGER_H_
17 #define _CONFIGURATIONMANAGER_H_
18
19 #include <list>
20 #include <string.h>
21 #include <string>
22 #include "Constants.h"
23 #include <iostream>
24 #include <dpl/log/log.h>
25
26 enum class PolicyType {
27     WAC2_0,
28     Tizen
29 };
30
31 #define POLICY_NAME_WAC2_0                  "WAC2.0"
32 #define POLICY_NAME_TIZEN                   "Tizen"
33 #define POLICY_WIDGET_TYPE_ATTRIBUTE_NAME   "WrtSecurity.WidgetPolicyType"
34
35 #pragma message "ATTR_ACTIVE_POLICY BAD_CAST, PARSER_ERROR, PARSER_SUCCESS\
36  macros are DEPRECATED"
37 #define ATTR_ACTIVE_POLICY BAD_CAST("active") // !! DEPRECATED !!
38 #define PARSER_ERROR     1 // !! DEPRECATED !!
39 #define PARSER_SUCCESS   0 // !! DEPRECATED !!
40
41 class ConfigurationManager
42 {
43   public:
44     // !! DEPRECATED !!
45     enum ConfigurationManagerResult
46     {
47         CM_OPERATION_SUCCESS = 0,
48         CM_GENERAL_ERROR = -1,
49         CM_FILE_EXISTS = -2,
50         CM_REMOVE_ERROR = -3,
51         CM_REMOVE_CURRENT = -4,
52         CM_REMOVE_NOT_EXISTING = -5
53     };
54
55     // !! DEPRECATED !!
56     std::string getCurrentPolicyFile(void) const;
57     std::string getFullPathToCurrentPolicyFile(void) const;
58     std::string getFullPathToCurrentPolicyXMLSchema(void) const;
59     int addPolicyFile(const std::string & filePath);
60     int removePolicyFile(const std::string& fileName);
61     int changeCurrentPolicyFile(const std::string& filePath);
62     std::string extractFilename(const std::string& path) const;
63
64     /**
65      * ACE policy file path getter
66      * @return Full path to policy file
67      */
68     std::string getFullPathToPolicyFile(PolicyType policy) const;
69
70     /**
71      * ACE policy dtd file path getter
72      * @return Full path to ACE current policy file
73      */
74     std::string getFullPathToPolicyXMLSchema(void) const;
75
76     /**
77      * ACE policy storage path getter
78      * @return Full path to ACE policy file storage
79      */
80     std::string getCscStoragePath(void) const;
81
82    /**
83      * ACE policy storage path getter
84      * @return Full path to ACE policy file storage
85      */
86     std::string getStoragePath(void) const;
87
88     /**
89      * Method to obtain instance of configuration manager
90      * @return retuns pointer to configuration manager or NULL in case of error
91      */
92     static ConfigurationManager * getInstance()
93     {
94         if (!instance) {
95             instance = new ConfigurationManager();
96         }
97         return instance;
98     }
99
100   protected:
101
102     // !! DEPRECATED !!
103     int parse(const std::string&);
104     bool copyFile(FILE*, FILE*, int lenght = 1024) const;
105     bool checkIfFileExistst(const std::string&) const;
106     const std::list<std::string> & getPolicyFiles() const;
107     const std::string & getConfigFile() const;
108
109     ConfigurationManager()
110     {
111     }
112     virtual ~ConfigurationManager()
113     {
114     }
115
116 private:
117
118     static ConfigurationManager * instance;
119 };
120
121 #endif
122