2017-01-14 20:07:12 +01:00
|
|
|
|
#ifndef CONNECTION_H
|
|
|
|
|
|
#define CONNECTION_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
2017-03-05 21:23:36 +01:00
|
|
|
|
|
2017-01-14 20:07:12 +01:00
|
|
|
|
enum class SslMode {
|
|
|
|
|
|
disable=0,
|
|
|
|
|
|
allow=1,
|
|
|
|
|
|
prefer=2,
|
|
|
|
|
|
require=3,
|
|
|
|
|
|
verify_ca=4,
|
|
|
|
|
|
verify_full=5
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2017-02-26 19:29:50 +01:00
|
|
|
|
enum class PasswordMode {
|
|
|
|
|
|
Unsave,
|
|
|
|
|
|
Encrypted,
|
|
|
|
|
|
DontSave
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2017-03-05 21:23:36 +01:00
|
|
|
|
class QProcessEnvironment;
|
|
|
|
|
|
class QString;
|
|
|
|
|
|
|
2017-01-14 20:07:12 +01:00
|
|
|
|
class ConnectionConfig {
|
|
|
|
|
|
public:
|
|
|
|
|
|
ConnectionConfig();
|
|
|
|
|
|
|
2017-01-15 12:27:36 +01:00
|
|
|
|
void setName(std::string desc);
|
|
|
|
|
|
const std::string& name() const;
|
2017-01-14 20:07:12 +01:00
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
2017-02-01 18:01:02 +01:00
|
|
|
|
bool isSameDatabase(const ConnectionConfig &rhs) const;
|
2017-02-26 19:29:50 +01:00
|
|
|
|
|
2017-03-05 21:23:36 +01:00
|
|
|
|
void writeToEnvironment(QProcessEnvironment &env) const;
|
|
|
|
|
|
|
2017-02-26 19:29:50 +01:00
|
|
|
|
bool dirty() const;
|
|
|
|
|
|
void clean();
|
2017-01-14 20:07:12 +01:00
|
|
|
|
private:
|
2017-01-15 12:27:36 +01:00
|
|
|
|
std::string m_name;
|
2017-01-14 20:07:12 +01:00
|
|
|
|
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;
|
|
|
|
|
|
|
2017-02-26 19:29:50 +01:00
|
|
|
|
bool m_dirty = false;
|
|
|
|
|
|
|
2017-03-05 21:23:36 +01:00
|
|
|
|
static void strToEnv(QProcessEnvironment &env, const QString &var, const std::string &val);
|
|
|
|
|
|
|
2017-01-14 20:07:12 +01:00
|
|
|
|
static std::vector<const char*> s_keywords;
|
|
|
|
|
|
mutable std::vector<const char*> m_values;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // CONNECTION_H
|