WIP. Adding config file handling. UserInterface settings implemented

This commit is contained in:
emeric
2014-08-21 15:24:23 +02:00
parent 2f376fbc7a
commit e8b2412cd6
16 changed files with 211 additions and 23 deletions
+33 -6
View File
@@ -1,17 +1,43 @@
#include <iostream>
#include <iomanip>
#include "UserInterfaceService.hpp"
#include "ui/LmsApplication.hpp"
UserInterfaceService::UserInterfaceService( int argc, char* argv[], boost::filesystem::path dbPath)
: _server(argv[0], "")
namespace Service {
UserInterfaceService::UserInterfaceService( boost::filesystem::path runAppPath, const Config& config)
: _server(runAppPath.string())
{
// TODO configure server using another way (config file?)
_server.setServerConfiguration (argc, argv, WTHTTP_CONFIGURATION);
std::vector<std::string> args;
args.push_back(runAppPath.string());
args.push_back("--docroot=" + config.docRootPath.string());
args.push_back("--approot=" + config.appRootPath.string());
{
std::ostringstream oss; oss << config.httpsPort;
args.push_back("--https-port=" + oss.str());
}
args.push_back("--https-address=" + config.httpsAddress.to_string());
args.push_back("--ssl-certificate=" + config.sslCertificatePath.string());
args.push_back("--ssl-private-key=" + config.sslPrivateKeyPath.string());
args.push_back("--ssl-tmp-dh=" + config.sslTempDhPath.string());
// Construct argc/argv
int argc = args.size();
const char* argv[args.size()];
for (int i = 0; i < argc; ++i)
argv[i] = args[i].c_str();
for(int i = 0; i < argc; ++i)
{
std::cout << "i = " << i << ", arg = '" << argv[i] << "'" << std::endl;
}
_server.setServerConfiguration (argc, const_cast<char**>(argv));
// bind entry point
_server.addEntryPoint(Wt::Application, boost::bind(UserInterface::LmsApplication::create, _1, dbPath));
_server.addEntryPoint(Wt::Application, boost::bind(UserInterface::LmsApplication::create, _1, config.dbPath));
}
void
@@ -35,4 +61,5 @@ UserInterfaceService::restart(void)
}
} // namespace Service