/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * Copyright the Collabora Online contributors. * * SPDX-License-Identifier: MPL-2.0 * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include #include #include #include #include #include #include #include namespace config { static Poco::AutoPtr XmlConfig; static const Poco::Util::AbstractConfiguration* Config{ 0 }; void initialize(const Poco::Util::AbstractConfiguration* config) { assert(!Config && "Config is already initialized."); Config = config; } void initialize(const std::string& xml) { std::istringstream iss(xml); XmlConfig.reset(new Poco::Util::XMLConfiguration(iss)); initialize(XmlConfig); } bool isInitialized() { return Config; } std::string getString(const std::string& key, const std::string& def) { assert(Config && "Config is not initialized."); return Config ? Config->getString(key, def) : def; } bool getBool(const std::string& key, const bool def) { assert(Config && "Config is not initialized."); return Config ? Config->getBool(key, def) : def; } int getInt(const std::string& key, const int def) { assert(Config && "Config is not initialized."); return Config ? Config->getInt(key, def) : def; } bool has(const std::string& key) { assert(Config && "Config is not initialized."); return Config ? Config->has(key) : false; } bool isSslEnabled() { #if ENABLE_SSL return !Util::isFuzzing() && getBool("ssl.enable", true); #else return false; #endif } bool isSupportKeyEnabled() { #if ENABLE_SUPPORT_KEY return true; #else return false; #endif } } // namespace config