pgLab/pglab/ConnectionController.h
eelke d489f11e52 Store encrypted passwords with connections.
Closes #22 as encrypted password is now deleted as part of the connection record.
2019-09-01 14:07:58 +02:00

66 lines
1.9 KiB
C++

#ifndef CONNECTIONCONTROLLER_H
#define CONNECTIONCONTROLLER_H
#include <QObject>
class MasterController;
class ConnectionConfig;
class ConnectionList;
class ConnectionTreeModel;
class ConnectionManagerWindow;
class PasswordManager;
class ConnectionController : public QObject {
Q_OBJECT
public:
explicit ConnectionController(MasterController *parent = nullptr);
~ConnectionController();
void init();
ConnectionTreeModel *getConnectionTreeModel()
{
return m_connectionTreeModel;
}
void showConnectionManager();
void openSqlWindowForConnection(QModelIndex index);
void openServerWindowForConnection(QModelIndex index);
void openBackupDlgForConnection(QModelIndex 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(QModelIndex index);
void addGroup();
void removeGroup(QModelIndex index);
std::shared_ptr<PasswordManager> passwordManager();
private:
MasterController *m_masterController;
ConnectionList *m_connectionList = nullptr;
ConnectionTreeModel *m_connectionTreeModel = nullptr;
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 decodePassword(const std::string &password_id, const std::string &enc_password, std::string &password);
bool encodePassword(const std::string &password_id, const std::string &password, std::string &enc_password);
bool UnlockPasswordManagerIfNeeded();
static std::string getPskId(const ConnectionConfig &cc);
};
#endif // CONNECTIONCONTROLLER_H