TIVI-1924: Initial commit of IVI settings daemon.
[profile/ivi/settings-daemon.git] / src / configurator.hpp
1 /**
2  * @file configurator.hpp
3  *
4  * @brief settingsd configuration manager header.
5  *
6  * @author Ossama Othman @<ossama.othman@@intel.com@>
7  *
8  * @copyright @par
9  * Copyright 2012, 2013 Intel Corporation All Rights Reserved.
10  * @par
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation;
14  * version 2.1 of the License.
15  * @par
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  * @par
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
24  * Boston, MA  02110-1301  USA
25  *
26  * @note This is an internal header.
27  */
28
29 #ifndef IVI_SETTINGS_CONFIGURATOR_HPP
30 #define IVI_SETTINGS_CONFIGURATOR_HPP
31
32 #include <string>
33 #include <boost/program_options.hpp>
34
35
36 namespace ivi {
37   namespace settings{
38     /**
39      * @class configurator
40      *
41      * @brief Settingsd configuration manager
42      *
43      * The @c configurator class parses command line and file based
44      * settingsd configuration options.
45      */
46     class configurator
47     {
48     public:
49
50       /// Constructor.
51       configurator(int & argc, char * argv[], char const * logger_name);
52
53       /// Get directory containing the settings plugins.
54       std::string settings_dir() const;
55
56       /// The port on which the web socket server should listen.
57       int websocket_port() const;
58
59
60       /// Websocket server SSL certificate file.
61       char const * ssl_cert_file() const;
62
63       /// Websocket server SSL private key file.
64       char const * ssl_private_key_file() const;
65
66       /// Websocket server SSL CA certificate file.
67       char const * ssl_ca_file() const;
68
69     private:
70
71       /**
72        * @name Prevent copying
73        */
74       //@{
75       configurator(configurator const &) = delete;
76       configurator & operator=(configurator const &) = delete;
77       //@}
78
79       /**
80        * @brief Parse the settingsd configuration.
81        *
82        * Configuration options are obtained from the command line, the
83        * user configuration file and the system configuration file, in
84        * order of decreasing precedence.
85        */
86       void parse_config(int & argc, char * argv[]);
87
88       /// Display settingsd's version and copyright notices.
89       void display_version_info() const;
90
91       /// Configure the underlying logger.
92       void configure_logger(char const * logger_name);
93
94       /// Set the log level in the underlying logger.
95       void set_log_level();
96
97       /**
98        * libwebsockets wants a @c nullptr for SSL certificate/key
99        * paths if they won't be used.
100        *
101        * @param[in] option SSL certificate relate program option.
102        *
103        * @returns C string if @a option is not empty, @c nullptr
104        *          otherwise.
105        */
106       char const * libwebsocket_ssl_filepath(
107         std::string const & option) const;
108
109     private:
110
111       /// Map of settingsd program options.
112       boost::program_options::variables_map vm_;
113
114     };
115   }
116 }
117
118 #endif  /* IVI_SETTINGS_CONFIGURATOR_HPP */
119
120
121 // Local Variables:
122 // mode:c++
123 // c-basic-offset:2
124 // indent-tabs-mode: nil
125 // End: