Fix storage location of config files

This commit is contained in:
Cameron Gutman
2018-05-05 15:57:57 -07:00
parent 351c5c7849
commit b4947f1f81
3 changed files with 11 additions and 4 deletions

View File

@@ -6,14 +6,21 @@
#include <QTextStream> #include <QTextStream>
#include <QSslCertificate> #include <QSslCertificate>
#include <QSslKey> #include <QSslKey>
#include <QStandardPaths>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/rsa.h> #include <openssl/rsa.h>
#include <openssl/pkcs12.h> #include <openssl/pkcs12.h>
IdentityManager::IdentityManager(QDir directory) IdentityManager::IdentityManager()
{ {
QFile uniqueIdFile(directory.filePath("uniqueid")); m_RootDirectory = QDir(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation));
if (!m_RootDirectory.exists())
{
m_RootDirectory.mkpath(".");
}
QFile uniqueIdFile(m_RootDirectory.filePath("uniqueid"));
if (uniqueIdFile.open(QIODevice::ReadOnly)) if (uniqueIdFile.open(QIODevice::ReadOnly))
{ {
m_CachedUniqueId = QTextStream(&uniqueIdFile).readAll(); m_CachedUniqueId = QTextStream(&uniqueIdFile).readAll();

View File

@@ -5,7 +5,7 @@
class IdentityManager class IdentityManager
{ {
public: public:
IdentityManager(QDir directory); IdentityManager();
QString QString
getUniqueId(); getUniqueId();

View File

@@ -52,7 +52,7 @@ void MainWindow::on_newHostBtn_clicked()
QString hostname = popupmanager::getHostnameDialog(this); QString hostname = popupmanager::getHostnameDialog(this);
if (!hostname.isEmpty()) { if (!hostname.isEmpty()) {
IdentityManager im = IdentityManager(QDir(QDir::current())); IdentityManager im = IdentityManager();
NvPairingManager pm(hostname, im); NvPairingManager pm(hostname, im);
QString pin = pm.generatePinString(); QString pin = pm.generatePinString();