2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef _CONFIGURATIONMANAGER_H_
17 #define _CONFIGURATIONMANAGER_H_
22 #include "Constants.h"
24 #include <dpl/log/log.h>
26 enum class PolicyType {
31 #define POLICY_NAME_WAC2_0 "WAC2.0"
32 #define POLICY_NAME_TIZEN "Tizen"
33 #define POLICY_WIDGET_TYPE_ATTRIBUTE_NAME "WrtSecurity.WidgetPolicyType"
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 !!
41 class ConfigurationManager
45 enum ConfigurationManagerResult
47 CM_OPERATION_SUCCESS = 0,
48 CM_GENERAL_ERROR = -1,
51 CM_REMOVE_CURRENT = -4,
52 CM_REMOVE_NOT_EXISTING = -5
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;
65 * ACE policy file path getter
66 * @return Full path to policy file
68 std::string getFullPathToPolicyFile(PolicyType policy) const;
71 * ACE policy dtd file path getter
72 * @return Full path to ACE current policy file
74 std::string getFullPathToPolicyXMLSchema(void) const;
77 * ACE policy storage path getter
78 * @return Full path to ACE policy file storage
80 std::string getCscStoragePath(void) const;
83 * ACE policy storage path getter
84 * @return Full path to ACE policy file storage
86 std::string getStoragePath(void) const;
89 * Method to obtain instance of configuration manager
90 * @return retuns pointer to configuration manager or NULL in case of error
92 static ConfigurationManager * getInstance()
95 instance = new ConfigurationManager();
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;
109 ConfigurationManager()
112 virtual ~ConfigurationManager()
118 static ConfigurationManager * instance;