2024-10-30 23:59:59 +08:00
|
|
|
#ifndef __WEBAPPLICATION_H__
|
|
|
|
#define __WEBAPPLICATION_H__
|
|
|
|
|
2024-11-11 19:21:48 +08:00
|
|
|
#include "Singleton.h"
|
2024-12-01 15:10:25 +08:00
|
|
|
#include <Wt/WApplication.h>
|
2024-11-14 23:06:22 +08:00
|
|
|
#include <memory>
|
2024-10-30 23:59:59 +08:00
|
|
|
|
|
|
|
namespace Wt {
|
|
|
|
class WServer;
|
2024-11-14 23:06:22 +08:00
|
|
|
class WApplication;
|
|
|
|
class WEnvironment;
|
2024-11-07 18:21:04 +08:00
|
|
|
|
2024-11-11 19:21:48 +08:00
|
|
|
namespace Auth {
|
|
|
|
class AuthService;
|
|
|
|
class PasswordService;
|
|
|
|
} // namespace Auth
|
|
|
|
|
2024-11-07 18:21:04 +08:00
|
|
|
}; // namespace Wt
|
2024-10-30 23:59:59 +08:00
|
|
|
|
2024-12-01 15:10:25 +08:00
|
|
|
class Session;
|
2024-11-14 23:06:22 +08:00
|
|
|
|
2024-12-01 15:10:25 +08:00
|
|
|
namespace WebToolkit {
|
|
|
|
|
|
|
|
class Application : public Wt::WApplication {
|
2024-10-30 23:59:59 +08:00
|
|
|
public:
|
2024-12-01 15:10:25 +08:00
|
|
|
Application(const Wt::WEnvironment &env, bool embedded);
|
|
|
|
~Application();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void greet();
|
|
|
|
void authEvent();
|
|
|
|
void handlePathChange(const std::string &path);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Wt::WLineEdit *m_nameEdit = nullptr;
|
|
|
|
Wt::WText *m_greeting = nullptr;
|
|
|
|
std::unique_ptr<Session> m_session;
|
|
|
|
std::string m_externalPath;
|
|
|
|
|
|
|
|
Wt::WContainerWidget *m_root = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Server {
|
|
|
|
friend class Amass::Singleton<Server>;
|
|
|
|
|
|
|
|
public:
|
|
|
|
~Server();
|
2024-10-30 23:59:59 +08:00
|
|
|
|
2024-11-11 19:21:48 +08:00
|
|
|
void initializeAuthenticationService();
|
|
|
|
const Wt::Auth::AuthService &authService();
|
|
|
|
const Wt::Auth::PasswordService &passwordService();
|
|
|
|
|
|
|
|
protected:
|
2024-12-01 15:10:25 +08:00
|
|
|
Server(uint16_t port, const std::string &documentRoot);
|
2024-11-14 23:06:22 +08:00
|
|
|
std::unique_ptr<Wt::WApplication> createApplication(const Wt::WEnvironment &env, bool embedded);
|
2024-11-11 19:21:48 +08:00
|
|
|
|
2024-10-30 23:59:59 +08:00
|
|
|
private:
|
|
|
|
std::unique_ptr<Wt::WServer> m_server;
|
2024-11-11 19:21:48 +08:00
|
|
|
|
|
|
|
std::unique_ptr<Wt::Auth::AuthService> m_authService;
|
|
|
|
std::unique_ptr<Wt::Auth::PasswordService> m_passwordService;
|
2024-10-30 23:59:59 +08:00
|
|
|
};
|
2024-12-01 15:10:25 +08:00
|
|
|
} // namespace WebToolkit
|
2024-10-30 23:59:59 +08:00
|
|
|
#endif // __WEBAPPLICATION_H__
|