don't save settings on quit, if readSettings() not finished
This commit is contained in:
parent
8b3752ef47
commit
5862f1552b
@ -27,7 +27,8 @@ Core::Squawk::Squawk(QObject* parent):
|
||||
accounts(),
|
||||
amap(),
|
||||
network(),
|
||||
waitingForAccounts(0)
|
||||
waitingForAccounts(0),
|
||||
isInitialized(false)
|
||||
#ifdef WITH_KWALLET
|
||||
,kwallet()
|
||||
#endif
|
||||
@ -66,39 +67,42 @@ void Core::Squawk::stop()
|
||||
{
|
||||
qDebug("Stopping squawk core..");
|
||||
network.stop();
|
||||
QSettings settings;
|
||||
settings.beginGroup("core");
|
||||
settings.beginWriteArray("accounts");
|
||||
SimpleCrypt crypto(passwordHash);
|
||||
for (std::deque<Account*>::size_type i = 0; i < accounts.size(); ++i) {
|
||||
settings.setArrayIndex(i);
|
||||
Account* acc = accounts[i];
|
||||
|
||||
Shared::AccountPassword ap = acc->getPasswordType();
|
||||
QString password;
|
||||
if (isInitialized) {
|
||||
QSettings settings;
|
||||
settings.beginGroup("core");
|
||||
settings.beginWriteArray("accounts");
|
||||
SimpleCrypt crypto(passwordHash);
|
||||
for (std::deque<Account*>::size_type i = 0; i < accounts.size(); ++i) {
|
||||
settings.setArrayIndex(i);
|
||||
Account* acc = accounts[i];
|
||||
|
||||
switch (ap) {
|
||||
case Shared::AccountPassword::plain:
|
||||
password = acc->getPassword();
|
||||
break;
|
||||
case Shared::AccountPassword::jammed:
|
||||
password = crypto.encryptToString(acc->getPassword());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
Shared::AccountPassword ap = acc->getPasswordType();
|
||||
QString password;
|
||||
|
||||
switch (ap) {
|
||||
case Shared::AccountPassword::plain:
|
||||
password = acc->getPassword();
|
||||
break;
|
||||
case Shared::AccountPassword::jammed:
|
||||
password = crypto.encryptToString(acc->getPassword());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
settings.setValue("name", acc->getName());
|
||||
settings.setValue("server", acc->getServer());
|
||||
settings.setValue("login", acc->getLogin());
|
||||
settings.setValue("password", password);
|
||||
settings.setValue("resource", acc->getResource());
|
||||
settings.setValue("passwordType", static_cast<int>(ap));
|
||||
}
|
||||
settings.endArray();
|
||||
settings.endGroup();
|
||||
|
||||
settings.setValue("name", acc->getName());
|
||||
settings.setValue("server", acc->getServer());
|
||||
settings.setValue("login", acc->getLogin());
|
||||
settings.setValue("password", password);
|
||||
settings.setValue("resource", acc->getResource());
|
||||
settings.setValue("passwordType", static_cast<int>(ap));
|
||||
settings.sync();
|
||||
}
|
||||
settings.endArray();
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
|
||||
emit quit();
|
||||
}
|
||||
@ -108,6 +112,7 @@ void Core::Squawk::start()
|
||||
qDebug("Starting squawk core..");
|
||||
|
||||
readSettings();
|
||||
isInitialized = true;
|
||||
network.start();
|
||||
}
|
||||
|
||||
|
@ -133,6 +133,7 @@ private:
|
||||
Shared::Availability state;
|
||||
NetworkAccess network;
|
||||
uint8_t waitingForAccounts;
|
||||
bool isInitialized;
|
||||
|
||||
#ifdef WITH_KWALLET
|
||||
PSE::KWallet kwallet;
|
||||
|
Loading…
Reference in New Issue
Block a user