Reworked the project layout

This commit is contained in:
emeric
2014-10-10 20:41:34 +02:00
parent 92a176c899
commit 49ff050539
146 changed files with 156 additions and 162 deletions
+51
View File
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2013 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include <boost/filesystem.hpp>
#include "DirectoryValidator.hpp"
namespace UserInterface {
DirectoryValidator::DirectoryValidator(Wt::WObject *parent)
: Wt::WValidator(parent)
{
}
Wt::WValidator::Result
DirectoryValidator::validate(const Wt::WString& input) const
{
if (input.empty())
return Wt::WValidator::validate(input);
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);
else
return Wt::WValidator::Result(Wt::WValidator::Invalid, "Not a directory");
}
} // namespace UserInterface
+33
View File
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2013 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Wt/WValidator>
namespace UserInterface {
class DirectoryValidator : public Wt::WValidator
{
public:
DirectoryValidator(Wt::WObject *parent = 0);
Wt::WValidator::Result validate(const Wt::WString& input) const;
};
} // namespace UserInterface
+30
View File
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2013 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include "SessionData.hpp"
namespace UserInterface {
SessionData::SessionData(boost::filesystem::path dbPath)
: _db(dbPath)
{
}
} // namespace UserInterface
+47
View File
@@ -0,0 +1,47 @@
/*
* Copyright (C) 2013 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UI_SESSION_DATA_HPP
#define UI_SESSION_DATA_HPP
#include <boost/filesystem.hpp>
#include "database/DatabaseHandler.hpp"
namespace UserInterface {
class SessionData
{
public:
SessionData(boost::filesystem::path dbPath);
Database::Handler& getDatabaseHandler() { return _db;}
const Database::Handler& getDatabaseHandler() const { return _db;}
private:
Database::Handler _db;
};
} // namespace UserInterface
#endif
+42
View File
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2013 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Wt/WRegExpValidator>
#include <Wt/WLengthValidator>
#include "database/User.hpp"
namespace UserInterface {
static inline Wt::WValidator *createEmailValidator()
{
Wt::WValidator *res = new Wt::WRegExpValidator("[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}");
res->setMandatory(true);
return res;
}
static inline Wt::WValidator *createNameValidator() {
Wt::WLengthValidator *v = new Wt::WLengthValidator();
v->setMandatory(true);
v->setMinimumLength(3);
v->setMaximumLength(::Database::User::MaxNameLength);
return v;
}
} // namespace UserInterface