2019-08-24 20:47:32 +02:00
|
|
|
|
#ifndef CONNECTIONCONTROLLER_H
|
|
|
|
|
|
#define CONNECTIONCONTROLLER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
|
|
|
|
class MasterController;
|
|
|
|
|
|
class ConnectionConfig;
|
|
|
|
|
|
class ConnectionList;
|
|
|
|
|
|
class ConnectionListModel;
|
2019-08-25 15:33:51 +02:00
|
|
|
|
class ConnectionTreeModel;
|
2019-08-24 20:47:32 +02:00
|
|
|
|
class ConnectionManagerWindow;
|
|
|
|
|
|
class PasswordManager;
|
|
|
|
|
|
|
|
|
|
|
|
class ConnectionController : public QObject {
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
|
|
|
|
explicit ConnectionController(MasterController *parent = nullptr);
|
|
|
|
|
|
~ConnectionController();
|
|
|
|
|
|
|
|
|
|
|
|
void init();
|
|
|
|
|
|
|
|
|
|
|
|
ConnectionListModel *getConnectionListModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_connectionListModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-25 15:33:51 +02:00
|
|
|
|
ConnectionTreeModel *getConnectionTreeModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_connectionTreeModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-24 20:47:32 +02:00
|
|
|
|
void showConnectionManager();
|
|
|
|
|
|
void openSqlWindowForConnection(int connection_index);
|
|
|
|
|
|
void openServerWindowForConnection(int connection_index);
|
|
|
|
|
|
void openBackupDlgForConnection(int connection_index);
|
|
|
|
|
|
|
|
|
|
|
|
/// Starts the form for creating a new conncetion.
|
|
|
|
|
|
/// This function returns immidiatly!
|
|
|
|
|
|
void createConnection();
|
|
|
|
|
|
/// Starts the form for editing a conncetion.
|
|
|
|
|
|
/// This function returns immidiatly!
|
|
|
|
|
|
void editConnection(int connection_index);
|
|
|
|
|
|
private:
|
|
|
|
|
|
MasterController *m_masterController;
|
|
|
|
|
|
ConnectionList *m_connectionList = nullptr;
|
|
|
|
|
|
ConnectionListModel *m_connectionListModel = nullptr;
|
2019-08-25 15:33:51 +02:00
|
|
|
|
ConnectionTreeModel *m_connectionTreeModel = nullptr;
|
2019-08-24 20:47:32 +02:00
|
|
|
|
ConnectionManagerWindow *m_connectionManagerWindow = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
/** Using long lived object so it can remember its master password for sometime
|
|
|
|
|
|
* if the user wishes it.
|
|
|
|
|
|
*/
|
|
|
|
|
|
std::shared_ptr<PasswordManager> m_passwordManager;
|
|
|
|
|
|
|
|
|
|
|
|
/** 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);
|
|
|
|
|
|
|
|
|
|
|
|
bool UnlockPasswordManagerIfNeeded();
|
|
|
|
|
|
|
|
|
|
|
|
static std::string getPskId(const ConnectionConfig &cc);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // CONNECTIONCONTROLLER_H
|