diff options
author | Kevin Smith <git@kismith.co.uk> | 2011-02-11 11:25:42 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2011-02-11 11:25:42 (GMT) |
commit | b8a73b1d16afd4f3aa0e8e39447024ec541df4c8 (patch) | |
tree | 503acb56c355ac0cca5dc13d89a9e4a3804ab813 /Swift | |
parent | 4dde3a55c46c95d89a7564738e132ad23bc946ee (diff) | |
download | swift-b8a73b1d16afd4f3aa0e8e39447024ec541df4c8.zip swift-b8a73b1d16afd4f3aa0e8e39447024ec541df4c8.tar.bz2 |
Allow deletion of items from login list.
Resolves: #711
Release-Notes: Highlighting an item in the login account list and pressing detele will now prompt you to remove the cached credentials for that account.
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/Controllers/MainController.cpp | 6 | ||||
-rw-r--r-- | Swift/Controllers/MainController.h | 1 | ||||
-rw-r--r-- | Swift/Controllers/Settings/DummySettingsProvider.h | 1 | ||||
-rw-r--r-- | Swift/Controllers/Settings/SettingsProvider.h | 1 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/LoginWindow.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtLoginWindow.cpp | 22 | ||||
-rw-r--r-- | Swift/QtUI/QtLoginWindow.h | 1 | ||||
-rw-r--r-- | Swift/QtUI/QtSettingsProvider.cpp | 12 | ||||
-rw-r--r-- | Swift/QtUI/QtSettingsProvider.h | 1 |
9 files changed, 46 insertions, 1 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 98599bb..31a1d5a 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -137,6 +137,7 @@ MainController::MainController( loginWindow_->selectUser(selectedLoginJID); loginWindow_->setLoginAutomatically(loginAutomatically); loginWindow_->onLoginRequest.connect(boost::bind(&MainController::handleLoginRequest, this, _1, _2, _3, _4, _5)); + loginWindow_->onPurgeSavedLoginRequest.connect(boost::bind(&MainController::handlePurgeSavedLoginRequest, this, _1)); loginWindow_->onCancelLoginRequest.connect(boost::bind(&MainController::handleCancelLoginRequest, this)); loginWindow_->onQuitRequest.connect(boost::bind(&MainController::handleQuitRequest, this)); @@ -367,6 +368,11 @@ void MainController::handleLoginRequest(const String &username, const String &pa performLoginFromCachedCredentials(); } +void MainController::handlePurgeSavedLoginRequest(const String& username) { + settings_->removeProfile(username); + loginWindow_->removeAvailableAccount(username); +} + void MainController::performLoginFromCachedCredentials() { /* If we logged in with a bare JID, and we have a full bound JID, re-login with the * bound JID to try and keep dynamically assigned resources */ diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index 09f17d2..07bf661 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -92,6 +92,7 @@ namespace Swift { void handleEventQueueLengthChange(int count); void handleVCardReceived(const JID& j, VCard::ref vCard); void handleUIEvent(boost::shared_ptr<UIEvent> event); + void handlePurgeSavedLoginRequest(const String& username); void sendPresence(boost::shared_ptr<Presence> presence); void handleInputIdleChanged(bool); void logout(); diff --git a/Swift/Controllers/Settings/DummySettingsProvider.h b/Swift/Controllers/Settings/DummySettingsProvider.h index 6c3dd52..631b68d 100644 --- a/Swift/Controllers/Settings/DummySettingsProvider.h +++ b/Swift/Controllers/Settings/DummySettingsProvider.h @@ -21,6 +21,7 @@ class DummySettingsProvider : public SettingsProvider { virtual void storeInt(const String &, int ) {} virtual std::vector<String> getAvailableProfiles() {return std::vector<String>();} virtual void createProfile(const String& ) {} + virtual void removeProfile(const String& ) {} }; } diff --git a/Swift/Controllers/Settings/SettingsProvider.h b/Swift/Controllers/Settings/SettingsProvider.h index 7ddf789..a2cdad4 100644 --- a/Swift/Controllers/Settings/SettingsProvider.h +++ b/Swift/Controllers/Settings/SettingsProvider.h @@ -24,6 +24,7 @@ class SettingsProvider { virtual void storeInt(const String &settingPath, int settingValue) = 0; virtual std::vector<String> getAvailableProfiles() = 0; virtual void createProfile(const String& profile) = 0; + virtual void removeProfile(const String& profile) = 0; }; } diff --git a/Swift/Controllers/UIInterfaces/LoginWindow.h b/Swift/Controllers/UIInterfaces/LoginWindow.h index a25cdb9..fc28424 100644 --- a/Swift/Controllers/UIInterfaces/LoginWindow.h +++ b/Swift/Controllers/UIInterfaces/LoginWindow.h @@ -23,6 +23,7 @@ namespace Swift { virtual void setMessage(const String&) = 0; virtual void setIsLoggingIn(bool loggingIn) = 0; virtual void addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) = 0; + virtual void removeAvailableAccount(const String& jid) = 0; boost::signal<void (const String&, const String&, const String& /* certificateFile */, bool /* remember password*/, bool /* login automatically */)> onLoginRequest; virtual void setLoginAutomatically(bool loginAutomatically) = 0; virtual void quit() = 0; @@ -31,5 +32,6 @@ namespace Swift { boost::signal<void ()> onCancelLoginRequest; boost::signal<void ()> onQuitRequest; + boost::signal<void (const String&)> onPurgeSavedLoginRequest; }; } diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp index a3e52dc..c3fdac2 100644 --- a/Swift/QtUI/QtLoginWindow.cpp +++ b/Swift/QtUI/QtLoginWindow.cpp @@ -193,7 +193,11 @@ bool QtLoginWindow::eventFilter(QObject *obj, QEvent *event) { if (obj == username_->view() && event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); if (keyEvent->key() == Qt::Key_Delete || keyEvent->key() == Qt::Key_Backspace) { - QMessageBox::information(this, "Remove profile", "Remove the profile '" + username_->view()->currentIndex().data().toString() + "'?"); + QString jid(username_->view()->currentIndex().data().toString()); + int result = QMessageBox::question(this, "Remove profile", "Remove the profile '" + jid + "'?", QMessageBox::Yes | QMessageBox::No); + if (result == QMessageBox::Yes) { + onPurgeSavedLoginRequest(Q2PSTRING(jid)); + } return true; } } @@ -221,6 +225,22 @@ void QtLoginWindow::selectUser(const String& username) { } } +void QtLoginWindow::removeAvailableAccount(const String& jid) { + QString username = P2QSTRING(jid); + int index = -1; + for (int i = 0; i < usernames_.count(); i++) { + if (username == usernames_[i]) { + index = i; + } + } + if (index >= 0) { + usernames_.removeAt(index); + passwords_.removeAt(index); + certificateFiles_.removeAt(index); + username_->removeItem(index); + } +} + void QtLoginWindow::addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) { QString username = P2QSTRING(defaultJID); int index = -1; diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h index 90defd1..6987906 100644 --- a/Swift/QtUI/QtLoginWindow.h +++ b/Swift/QtUI/QtLoginWindow.h @@ -34,6 +34,7 @@ namespace Swift { virtual void loggedOut(); virtual void setMessage(const String& message); virtual void addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate); + virtual void removeAvailableAccount(const String& jid); virtual void setLoginAutomatically(bool loginAutomatically); virtual void setIsLoggingIn(bool loggingIn); void selectUser(const String& user); diff --git a/Swift/QtUI/QtSettingsProvider.cpp b/Swift/QtUI/QtSettingsProvider.cpp index ea0013a..4bddce3 100644 --- a/Swift/QtUI/QtSettingsProvider.cpp +++ b/Swift/QtUI/QtSettingsProvider.cpp @@ -60,6 +60,18 @@ void QtSettingsProvider::createProfile(const String& profile) { settings_.setValue("profileList", stringList); } +void QtSettingsProvider::removeProfile(const String& profile) { + QString profileStart(P2QSTRING(profile) + ":"); + foreach (QString key, settings_.allKeys()) { + if (key.startsWith(profileStart)) { + settings_.remove(key); + } + } + QStringList stringList = settings_.value("profileList").toStringList(); + stringList.removeAll(P2QSTRING(profile)); + settings_.setValue("profileList", stringList); +} + QSettings* QtSettingsProvider::getQSettings() { return &settings_; } diff --git a/Swift/QtUI/QtSettingsProvider.h b/Swift/QtUI/QtSettingsProvider.h index 5cdafd5..d1dbc5e 100644 --- a/Swift/QtUI/QtSettingsProvider.h +++ b/Swift/QtUI/QtSettingsProvider.h @@ -25,6 +25,7 @@ class QtSettingsProvider : public SettingsProvider { virtual void storeInt(const String &settingPath, int settingValue); virtual std::vector<String> getAvailableProfiles(); virtual void createProfile(const String& profile); + virtual void removeProfile(const String& profile); QSettings* getQSettings(); private: QSettings settings_; |