don't offer login reset from CrashHandler

This commit is contained in:
Stephen Birarda 2016-02-22 13:56:33 -08:00
parent 90e9089e85
commit d444d5dd18
2 changed files with 8 additions and 30 deletions

View file

@ -22,11 +22,8 @@
#include <QStandardPaths> #include <QStandardPaths>
#include <QVBoxLayout> #include <QVBoxLayout>
#include "DataServerAccountInfo.h"
#include "Menu.h" #include "Menu.h"
Q_DECLARE_METATYPE(DataServerAccountInfo)
static const QString RUNNING_MARKER_FILENAME = "Interface.running"; static const QString RUNNING_MARKER_FILENAME = "Interface.running";
void CrashHandler::checkForAndHandleCrash() { void CrashHandler::checkForAndHandleCrash() {
@ -57,7 +54,7 @@ CrashHandler::Action CrashHandler::promptUserForAction() {
layout->addWidget(label); layout->addWidget(label);
QRadioButton* option1 = new QRadioButton("Reset all my settings"); QRadioButton* option1 = new QRadioButton("Reset all my settings");
QRadioButton* option2 = new QRadioButton("Reset my settings but retain login and avatar info."); QRadioButton* option2 = new QRadioButton("Reset my settings but retain avatar info.");
QRadioButton* option3 = new QRadioButton("Continue with my current settings"); QRadioButton* option3 = new QRadioButton("Continue with my current settings");
option3->setChecked(true); option3->setChecked(true);
layout->addWidget(option1); layout->addWidget(option1);
@ -79,7 +76,7 @@ CrashHandler::Action CrashHandler::promptUserForAction() {
return CrashHandler::DELETE_INTERFACE_INI; return CrashHandler::DELETE_INTERFACE_INI;
} }
if (option2->isChecked()) { if (option2->isChecked()) {
return CrashHandler::RETAIN_LOGIN_AND_AVATAR_INFO; return CrashHandler::RETAIN_AVATAR_INFO;
} }
} }
@ -88,7 +85,7 @@ CrashHandler::Action CrashHandler::promptUserForAction() {
} }
void CrashHandler::handleCrash(CrashHandler::Action action) { void CrashHandler::handleCrash(CrashHandler::Action action) {
if (action != CrashHandler::DELETE_INTERFACE_INI && action != CrashHandler::RETAIN_LOGIN_AND_AVATAR_INFO) { if (action != CrashHandler::DELETE_INTERFACE_INI && action != CrashHandler::RETAIN_AVATAR_INFO) {
// CrashHandler::DO_NOTHING or unexpected value // CrashHandler::DO_NOTHING or unexpected value
return; return;
} }
@ -101,18 +98,13 @@ void CrashHandler::handleCrash(CrashHandler::Action action) {
const QString DISPLAY_NAME_KEY = "displayName"; const QString DISPLAY_NAME_KEY = "displayName";
const QString FULL_AVATAR_URL_KEY = "fullAvatarURL"; const QString FULL_AVATAR_URL_KEY = "fullAvatarURL";
const QString FULL_AVATAR_MODEL_NAME_KEY = "fullAvatarModelName"; const QString FULL_AVATAR_MODEL_NAME_KEY = "fullAvatarModelName";
const QString ACCOUNTS_GROUP = "accounts";
QString displayName; QString displayName;
QUrl fullAvatarURL; QUrl fullAvatarURL;
QString fullAvatarModelName; QString fullAvatarModelName;
QUrl address; QUrl address;
QMap<QString, DataServerAccountInfo> accounts;
if (action == CrashHandler::RETAIN_LOGIN_AND_AVATAR_INFO) { if (action == CrashHandler::RETAIN_AVATAR_INFO) {
// Read login and avatar info // Read avatar info
qRegisterMetaType<DataServerAccountInfo>("DataServerAccountInfo");
qRegisterMetaTypeStreamOperators<DataServerAccountInfo>("DataServerAccountInfo");
// Location and orientation // Location and orientation
settings.beginGroup(ADDRESS_MANAGER_GROUP); settings.beginGroup(ADDRESS_MANAGER_GROUP);
@ -125,13 +117,6 @@ void CrashHandler::handleCrash(CrashHandler::Action action) {
fullAvatarURL = settings.value(FULL_AVATAR_URL_KEY).toUrl(); fullAvatarURL = settings.value(FULL_AVATAR_URL_KEY).toUrl();
fullAvatarModelName = settings.value(FULL_AVATAR_MODEL_NAME_KEY).toString(); fullAvatarModelName = settings.value(FULL_AVATAR_MODEL_NAME_KEY).toString();
settings.endGroup(); settings.endGroup();
// Accounts
settings.beginGroup(ACCOUNTS_GROUP);
foreach(const QString& key, settings.allKeys()) {
accounts.insert(key, settings.value(key).value<DataServerAccountInfo>());
}
settings.endGroup();
} }
// Delete Interface.ini // Delete Interface.ini
@ -140,8 +125,8 @@ void CrashHandler::handleCrash(CrashHandler::Action action) {
settingsFile.remove(); settingsFile.remove();
} }
if (action == CrashHandler::RETAIN_LOGIN_AND_AVATAR_INFO) { if (action == CrashHandler::RETAIN_AVATAR_INFO) {
// Write login and avatar info // Write avatar info
// Location and orientation // Location and orientation
settings.beginGroup(ADDRESS_MANAGER_GROUP); settings.beginGroup(ADDRESS_MANAGER_GROUP);
@ -154,13 +139,6 @@ void CrashHandler::handleCrash(CrashHandler::Action action) {
settings.setValue(FULL_AVATAR_URL_KEY, fullAvatarURL); settings.setValue(FULL_AVATAR_URL_KEY, fullAvatarURL);
settings.setValue(FULL_AVATAR_MODEL_NAME_KEY, fullAvatarModelName); settings.setValue(FULL_AVATAR_MODEL_NAME_KEY, fullAvatarModelName);
settings.endGroup(); settings.endGroup();
// Accounts
settings.beginGroup(ACCOUNTS_GROUP);
foreach(const QString& key, accounts.keys()) {
settings.setValue(key, QVariant::fromValue(accounts.value(key)));
}
settings.endGroup();
} }
} }

View file

@ -25,7 +25,7 @@ public:
private: private:
enum Action { enum Action {
DELETE_INTERFACE_INI, DELETE_INTERFACE_INI,
RETAIN_LOGIN_AND_AVATAR_INFO, RETAIN_AVATAR_INFO,
DO_NOTHING DO_NOTHING
}; };