Commit 5e4dcd41 authored by Karel Slaný's avatar Karel Slaný
Browse files

Reopen database immediately after storing to disk was altered.

parent e1cd3879
......@@ -180,7 +180,7 @@ bool Accounts::removeAccount(const QString &userName, bool showDialog)
*/
void Accounts::updateAccount(const QString &loginMetod,
const QString &acntName, const QString &userName,
const QString &pwd, bool isTestAccount, bool rememberPwd,
const QString &pwd, bool isTestAccount, bool rememberPwd,
bool storeToDisk, const QString &certPath)
/* ========================================================================= */
{
......@@ -206,7 +206,30 @@ void Accounts::updateAccount(const QString &loginMetod,
acntData.setPassword(pwd.trimmed());
acntData.setTestAccount(isTestAccount);
acntData.setRememberPwd(rememberPwd);
acntData.setstoreToDisk(storeToDisk);
if (acntData.storeToDisk() != storeToDisk) {
MessageDb *mDb = globMessageDbsPtr->accessMessageDb(
globSet.dbsLocation, userName);
FileDb *fDb = globFileDbsPtr->accessFileDb(
globSet.dbsLocation, userName);
if (mDb == NULL || fDb == NULL) {
return;
}
QString mDbFileName(mDb->fileName());
QString fDbFileName(fDb->fileName());
/* Reopen database. */
mDb->openDb(globSet.dbsLocation, storeToDisk);
fDb->openDb(globSet.dbsLocation, storeToDisk);
if (!storeToDisk) {
/* Delete databases from storage. */
QFile::remove(mDbFileName);
QFile::remove(fDbFileName);
}
/* TODO -- Inform the model that message counters have changed. */
}
acntData.setStoreToDisk(storeToDisk);
QUrl url(certPath, QUrl::TolerantMode);
url.toLocalFile();
acntData.setCertPath(url.toLocalFile());
......@@ -249,7 +272,7 @@ bool Accounts::createAccount(const QString &loginMetod,
acntData.setLoginMethod(loginMetod);
acntData.setTestAccount(isTestAccount);
acntData.setRememberPwd(rememberPwd);
acntData.setstoreToDisk(storeToDisk);
acntData.setStoreToDisk(storeToDisk);
QUrl url(certPath, QUrl::TolerantMode);
url.toLocalFile();
acntData.setCertPath(url.toLocalFile());
......
......@@ -84,7 +84,7 @@ public:
*/
Q_INVOKABLE void updateAccount(const QString &loginMetod,
const QString &acntName, const QString &userName,
const QString &pwd, bool isTestAccount, bool rememberPwd,
const QString &pwd, bool isTestAccount, bool rememberPwd,
bool storeToDisk, const QString &certPath);
/*!
......
......@@ -261,7 +261,7 @@ bool AcntData::storeToDisk(void) const
return m_storeToDisk;
}
void AcntData::setstoreToDisk(bool storeToDisk)
void AcntData::setStoreToDisk(bool storeToDisk)
{
m_storeToDisk = storeToDisk;
}
......@@ -396,7 +396,7 @@ AcntData getAcntData(const QSettings &settings, const QString &groupName)
groupName + "/" + TEST_ACCOUNT, "").toBool());
aData.setRememberPwd(settings.value(
groupName + "/" + REMEMBER_PWD, "").toBool());
aData.setstoreToDisk(settings.value(
aData.setStoreToDisk(settings.value(
groupName + "/" + USE_DB, "").toBool());
aData.setCertPath(settings.value(
groupName + "/" + CERT_PATH, "").toString());
......
......@@ -54,7 +54,7 @@ public:
bool rememberPwd(void) const;
void setRememberPwd(bool remember);
bool storeToDisk(void) const;
void setstoreToDisk(bool storeToDisk);
void setStoreToDisk(bool storeToDisk);
QString certPath(void) const;
void setCertPath(const QString &certPath);
QString _passPhrase(void) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment