Auth token is stored in settings and deleted if a request is not authorized (with automatic re-login). Failed request need to be resend.
This commit is contained in:
@ -40,4 +40,48 @@ void SettingsHandler::saveSettings(QVariantMap settingMap, QString group) {
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
void SettingsHandler::deleteSettings(QStringList keys, QString group) {
|
||||
qInfo() << "deleting settings...";
|
||||
|
||||
QSettings settings;
|
||||
if (!group.isEmpty()) {
|
||||
qDebug() << "starting group:" << group;
|
||||
settings.beginGroup(group);
|
||||
}
|
||||
|
||||
foreach (QString key, keys) {
|
||||
qDebug() << "removing:" << key;
|
||||
settings.remove(key);
|
||||
}
|
||||
if (!group.isEmpty()) {
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
QVariantMap SettingsHandler::getChangeset(QVariantMap newSettings, QString group) {
|
||||
const QVariantMap oldSettings = getSettings(group);
|
||||
|
||||
QVariantMap result;
|
||||
|
||||
for (QVariantMap::const_iterator iter = newSettings.begin(); iter != newSettings.end(); ++iter) {
|
||||
qDebug() << iter.key() << iter.value();
|
||||
QString key = iter.key();
|
||||
QVariant newValue = iter.value();
|
||||
QVariant oldValue = oldSettings.value(key);
|
||||
|
||||
if (oldValue == newValue) {
|
||||
qInfo() << "oldValue == newValue -> ignoring...";
|
||||
} else {
|
||||
const QString debugString =
|
||||
QString("oldValue != newValue -> adding '%1' to changeset...").arg(key);
|
||||
qInfo() << debugString;
|
||||
result.insert(key, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SettingsHandler::SettingsHandler() {}
|
||||
|
||||
@ -7,6 +7,9 @@ class SettingsHandler {
|
||||
public:
|
||||
static QVariantMap getSettings(QString group = "");
|
||||
static void saveSettings(QVariantMap settingMap, QString group = "");
|
||||
static void deleteSettings(QStringList keys, QString group = "");
|
||||
|
||||
static QVariantMap getChangeset(QVariantMap newSettings, QString group = "");
|
||||
|
||||
private:
|
||||
SettingsHandler();
|
||||
|
||||
Reference in New Issue
Block a user