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