WIP. Reorganizing things to get settings work. First attempt on Database settings
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include "DirectoryValidator.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
DirectoryValidator::DirectoryValidator(bool mandatory, Wt::WObject *parent)
|
||||
: Wt::WValidator(mandatory, parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Wt::WValidator::Result
|
||||
DirectoryValidator::validate(const Wt::WString& input) const
|
||||
{
|
||||
boost::filesystem::path p(input.toUTF8());
|
||||
boost::system::error_code ec;
|
||||
|
||||
bool res = boost::filesystem::is_directory(p, ec);
|
||||
if (ec)
|
||||
return Wt::WValidator::Result(Wt::WValidator::Invalid, ec.message());
|
||||
else if (res)
|
||||
return Wt::WValidator::Result(Wt::WValidator::Valid, "Valid");
|
||||
else
|
||||
return Wt::WValidator::Result(Wt::WValidator::Invalid, "Not a directory");
|
||||
}
|
||||
|
||||
|
||||
} // namespace UserInterface
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <Wt/WValidator>
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
class DirectoryValidator : public Wt::WValidator
|
||||
{
|
||||
public:
|
||||
DirectoryValidator(bool mandatory, Wt::WObject *parent = 0);
|
||||
|
||||
Wt::WValidator::Result validate(const Wt::WString& input) const;
|
||||
|
||||
};
|
||||
|
||||
} // namespace UserInterface
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef UI_SESSION_DATA_HPP
|
||||
#define UI_SESSION_DATA_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
@@ -15,17 +13,12 @@ class SessionData
|
||||
|
||||
SessionData(boost::filesystem::path dbPath);
|
||||
|
||||
void setAuthenticatedUser(std::string user);
|
||||
|
||||
|
||||
Database::Handler& getDatabaseHandler() { return _db;}
|
||||
const Database::Handler& getDatabaseHandler() const { return _db;}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Database::Handler _db;
|
||||
std::string _authenticatedUser;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user