2017-02-01 18:01:02 +01:00
|
|
|
|
#ifndef MASTERCONTROLLER_H
|
|
|
|
|
|
#define MASTERCONTROLLER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
2018-11-08 21:50:49 +01:00
|
|
|
|
#include <QSqlDatabase>
|
|
|
|
|
|
#include <atomic>
|
2017-08-24 19:45:00 +02:00
|
|
|
|
#include <future>
|
2017-02-01 18:01:02 +01:00
|
|
|
|
#include <map>
|
2018-11-08 21:50:49 +01:00
|
|
|
|
#include <memory>
|
2017-02-01 18:01:02 +01:00
|
|
|
|
|
2018-11-08 21:50:49 +01:00
|
|
|
|
//namespace Botan {
|
|
|
|
|
|
// class Sqlite3_Database;
|
|
|
|
|
|
//}
|
2017-08-24 19:45:00 +02:00
|
|
|
|
|
2017-02-01 18:01:02 +01:00
|
|
|
|
class ConnectionConfig;
|
2017-02-26 19:29:50 +01:00
|
|
|
|
class ConnectionList;
|
2017-02-01 18:01:02 +01:00
|
|
|
|
class ConnectionListModel;
|
|
|
|
|
|
class ConnectionManagerWindow;
|
2018-11-08 21:50:49 +01:00
|
|
|
|
class PasswordManager;
|
2017-02-01 18:01:02 +01:00
|
|
|
|
|
2017-02-01 19:59:07 +01:00
|
|
|
|
/** \brief Controller class responsible for all things global.
|
|
|
|
|
|
*/
|
2017-02-26 19:29:50 +01:00
|
|
|
|
class MasterController : public QObject {
|
2017-02-01 18:01:02 +01:00
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
2018-11-04 11:26:20 +01:00
|
|
|
|
explicit MasterController(QObject *parent = nullptr);
|
2017-02-26 19:29:50 +01:00
|
|
|
|
MasterController(const MasterController&) = delete;
|
|
|
|
|
|
MasterController &operator=(const MasterController&) = delete;
|
2017-02-01 18:01:02 +01:00
|
|
|
|
~MasterController();
|
|
|
|
|
|
|
|
|
|
|
|
void init();
|
|
|
|
|
|
|
|
|
|
|
|
ConnectionListModel *getConnectionListModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_connectionListModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void showConnectionManager();
|
2018-11-04 11:26:20 +01:00
|
|
|
|
void openSqlWindowForConnection(size_t connection_index);
|
2018-11-08 21:50:49 +01:00
|
|
|
|
void openServerWindowForConnection(size_t connection_index);
|
|
|
|
|
|
void openBackupDlgForConnection(size_t connection_index);
|
|
|
|
|
|
|
|
|
|
|
|
// std::shared_ptr<Botan::Sqlite3_Database> getUserConfigDatabase();
|
2017-08-24 19:45:00 +02:00
|
|
|
|
|
2017-02-01 18:01:02 +01:00
|
|
|
|
signals:
|
|
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2017-02-26 19:29:50 +01:00
|
|
|
|
ConnectionList *m_connectionList = nullptr;
|
2017-02-01 18:01:02 +01:00
|
|
|
|
ConnectionListModel *m_connectionListModel = nullptr;
|
|
|
|
|
|
ConnectionManagerWindow *m_connectionManagerWindow = nullptr;
|
2018-11-08 21:50:49 +01:00
|
|
|
|
//std::shared_ptr<Botan::Sqlite3_Database> m_userConfigDatabase;
|
|
|
|
|
|
QSqlDatabase m_userConfigDatabase;
|
|
|
|
|
|
/** Using long lived object so it can remember its master password for sometime
|
|
|
|
|
|
* if the user wishes it.
|
|
|
|
|
|
*/
|
|
|
|
|
|
std::shared_ptr<PasswordManager> m_passwordManager;
|
2018-11-04 11:26:20 +01:00
|
|
|
|
|
|
|
|
|
|
/** Retrieves the connection password from the user (directly or through the psk db)
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
bool retrieveConnectionPassword(ConnectionConfig &cc);
|
|
|
|
|
|
|
|
|
|
|
|
bool getPasswordFromPskdb(const std::string &password_id, std::string &password);
|
|
|
|
|
|
|
|
|
|
|
|
bool storePasswordInPskdb(const std::string &password_id, const std::string password);
|
2018-11-08 21:50:49 +01:00
|
|
|
|
|
|
|
|
|
|
bool UnlockPasswordManagerIfNeeded();
|
|
|
|
|
|
|
|
|
|
|
|
static std::string getPskId(const ConnectionConfig &cc);
|
2017-02-01 18:01:02 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // MASTERCONTROLLER_H
|