Password is no longer saved with the connection list. Password is not entered along with other connection credentials. Password is now asked for when required. Still working on saving the password and auto retrieving it from the password manager.
107 lines
2 KiB
C++
107 lines
2 KiB
C++
#ifndef CONNECTION_H
|
|
#define CONNECTION_H
|
|
|
|
#include <QUuid>
|
|
#include <vector>
|
|
#include <string>
|
|
|
|
|
|
enum class SslMode {
|
|
disable=0,
|
|
allow=1,
|
|
prefer=2,
|
|
require=3,
|
|
verify_ca=4,
|
|
verify_full=5
|
|
};
|
|
|
|
enum class PasswordMode {
|
|
Unsave,
|
|
Encrypted,
|
|
DontSave
|
|
};
|
|
|
|
class QProcessEnvironment;
|
|
class QString;
|
|
|
|
class ConnectionConfig {
|
|
public:
|
|
ConnectionConfig();
|
|
|
|
void setUuid(const QUuid &uuid);
|
|
const QUuid &uuid() const;
|
|
|
|
void setName(std::string desc);
|
|
const std::string& name() const;
|
|
|
|
void setHost(std::string host);
|
|
const std::string& host() const;
|
|
|
|
void setHostAddr(std::string v);
|
|
const std::string& hostAddr() const;
|
|
|
|
void setPort(unsigned short port);
|
|
unsigned short port() const;
|
|
|
|
void setUser(std::string v);
|
|
const std::string& user() const;
|
|
|
|
void setPassword(std::string v);
|
|
const std::string& password() const;
|
|
|
|
void setDbname(std::string v);
|
|
const std::string& dbname() const;
|
|
|
|
void setSslMode(SslMode m);
|
|
SslMode sslMode() const;
|
|
|
|
void setSslCert(std::string v);
|
|
const std::string& sslCert() const;
|
|
|
|
void setSslKey(std::string v);
|
|
const std::string& sslKey() const;
|
|
|
|
void setSslRootCert(std::string v);
|
|
const std::string& sslRootCert() const;
|
|
|
|
void setSslCrl(std::string v);
|
|
const std::string& sslCrl() const;
|
|
|
|
const char * const * getKeywords() const;
|
|
const char * const * getValues() const;
|
|
|
|
bool isSameDatabase(const ConnectionConfig &rhs) const;
|
|
|
|
void writeToEnvironment(QProcessEnvironment &env) const;
|
|
|
|
bool dirty() const;
|
|
void clean();
|
|
private:
|
|
QUuid m_uuid;
|
|
std::string m_name;
|
|
std::string m_host;
|
|
std::string m_hostaddr;
|
|
std::string m_port = "5432";
|
|
|
|
std::string m_user;
|
|
std::string m_password;
|
|
std::string m_dbname;
|
|
|
|
std::string m_sslMode;
|
|
std::string m_sslCert;
|
|
std::string m_sslKey;
|
|
std::string m_sslRootCert;
|
|
std::string m_sslCrl;
|
|
|
|
std::string m_applicationName;
|
|
|
|
bool m_dirty = false;
|
|
|
|
static void strToEnv(QProcessEnvironment &env, const QString &var, const std::string &val);
|
|
|
|
static std::vector<const char*> s_keywords;
|
|
mutable std::vector<const char*> m_values;
|
|
};
|
|
|
|
|
|
#endif // CONNECTION_H
|