diff options
author | Tobias Markmann <tm@ayena.de> | 2015-06-09 21:29:20 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2015-07-07 13:00:23 (GMT) |
commit | 2598ef4efcd74d5e9e701c62337bf84829572508 (patch) | |
tree | c60d7337a9f8932ed4a1d70e606d1ce2787f866f /Swift/Controllers | |
parent | f10c9618f8ccd9e44c9a45a69179883b39a445f5 (diff) | |
download | swift-2598ef4efcd74d5e9e701c62337bf84829572508.zip swift-2598ef4efcd74d5e9e701c62337bf84829572508.tar.bz2 |
Show old vCard in UI if vCard update is rejected by server
Previously QtVCardWidget would work on a shared copy of a VCard and
modify the shared version. Now when setting the vCard on the widget
it creates its own copy and works on that.
The ProfileController holds a reference to the VCard it sets on the UI.
If the server rejects an update it can reset the UI to this VCard.
Test-Information:
Tested against a XMPP server that rejects all vCard updates
(mod_readonly).
Change-Id: Iaa8eed6406f2dc6cc7ac5434194a7dae4f879b33
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/ProfileController.cpp | 10 | ||||
-rw-r--r-- | Swift/Controllers/ProfileController.h | 8 |
2 files changed, 11 insertions, 7 deletions
diff --git a/Swift/Controllers/ProfileController.cpp b/Swift/Controllers/ProfileController.cpp index be7b72c..7df8036 100644 --- a/Swift/Controllers/ProfileController.cpp +++ b/Swift/Controllers/ProfileController.cpp @@ -1,22 +1,22 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/Controllers/ProfileController.h> #include <boost/bind.hpp> +#include <Swiften/VCards/VCardManager.h> + +#include <Swift/Controllers/Intl.h> #include <Swift/Controllers/UIEvents/RequestProfileEditorUIEvent.h> #include <Swift/Controllers/UIEvents/UIEventStream.h> #include <Swift/Controllers/UIInterfaces/ProfileWindowFactory.h> -#include <Swiften/VCards/VCardManager.h> -#include <Swift/Controllers/Intl.h> - namespace Swift { ProfileController::ProfileController(VCardManager* vcardManager, ProfileWindowFactory* profileWindowFactory, UIEventStream* uiEventStream) : vcardManager(vcardManager), profileWindowFactory(profileWindowFactory), uiEventStream(uiEventStream), available(true), profileWindow(NULL), gettingVCard(false) { uiEventStream->onUIEvent.connect(boost::bind(&ProfileController::handleUIEvent, this, _1)); } @@ -58,23 +58,25 @@ void ProfileController::handleVCardChangeRequest(VCard::ref vcard) { } void ProfileController::handleSetVCardResponse(ErrorPayload::ref error) { pendingSetVCardRequest.reset(); updateDialogStatus(); if (error) { + profileWindow->setVCard(vcardBeforeEdit); profileWindow->setError(QT_TRANSLATE_NOOP("", "There was an error publishing your profile data")); } else { profileWindow->setError(""); profileWindow->hide(); } } void ProfileController::handleOwnVCardChanged(VCard::ref vcard) { if (profileWindow) { profileWindow->setVCard(vcard); + vcardBeforeEdit = vcard; gettingVCard = false; updateDialogStatus(); } } void ProfileController::handleProfileWindowAboutToBeClosed(const JID&) { diff --git a/Swift/Controllers/ProfileController.h b/Swift/Controllers/ProfileController.h index 466834f..c6f5420 100644 --- a/Swift/Controllers/ProfileController.h +++ b/Swift/Controllers/ProfileController.h @@ -1,19 +1,20 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <Swift/Controllers/UIEvents/UIEvent.h> -#include <Swiften/Elements/VCard.h> #include <Swiften/Elements/ErrorPayload.h> +#include <Swiften/Elements/VCard.h> #include <Swiften/VCards/SetVCardRequest.h> +#include <Swift/Controllers/UIEvents/UIEvent.h> + namespace Swift { class UIEventStream; class ProfileWindowFactory; class ProfileWindow; class VCardManager; @@ -37,9 +38,10 @@ namespace Swift { ProfileWindowFactory* profileWindowFactory; UIEventStream* uiEventStream; bool available; SetVCardRequest::ref pendingSetVCardRequest; ProfileWindow* profileWindow; bool gettingVCard; + VCard::ref vcardBeforeEdit; }; } |