summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/Controllers/ProfileController.cpp10
-rw-r--r--Swift/Controllers/ProfileController.h8
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp3
3 files changed, 12 insertions, 9 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;
};
}
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp b/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
index 79360d8..ac087ed 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
@@ -10,13 +10,12 @@
* See the COPYING file for more information.
*/
#include <Swift/QtUI/QtVCardWidget/QtVCardWidget.h>
#include <Swift/QtUI/QtVCardWidget/ui_QtVCardWidget.h>
-#include <QDebug>
#include <QLineEdit>
#include <QMenu>
#include <Swift/QtUI/QtSwiftUtil.h>
#include <Swift/QtUI/QtVCardWidget/QtVCardAddressField.h>
#include <Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.h>
@@ -109,13 +108,13 @@ void QtVCardWidget::setEditable(bool editable) {
editableChanged(editable);
}
void QtVCardWidget::setVCard(VCard::ref vcard) {
clearFields();
- this->vcard = vcard;
+ this->vcard = boost::make_shared<VCard>(*vcard);
ui->photoAndName->setFormattedName(P2QSTRING(vcard->getFullName()));
ui->photoAndName->setNickname(P2QSTRING(vcard->getNickname()));
ui->photoAndName->setPrefix(P2QSTRING(vcard->getPrefix()));
ui->photoAndName->setGivenName(P2QSTRING(vcard->getGivenName()));
ui->photoAndName->setMiddleName(P2QSTRING(vcard->getMiddleName()));
ui->photoAndName->setFamilyName(P2QSTRING(vcard->getFamilyName()));