From 72824c12ab6c15501e6e17c15465d9b27c6f7e1b Mon Sep 17 00:00:00 2001 From: Tobias Markmann <tm@ayena.de> Date: Tue, 7 Feb 2017 14:03:53 +0100 Subject: Display error message in profile window if vCard request failed Also fixed an typo error in GConfProxyProvider.cpp that prevented compilation on Linux. Test-Information: Tested with an XMPP server with vCard support disabled and also with vCard support enabled. Tested profile window and profile editor window. The profile window will show cached vCard data if present and the error message. The profile editor window will only show the error message in case of an error. Tested profile window and profile editor window in a scenario where vCard support is first enabled in the server, then disabled, and finally enabled again, and opening the editors in between. Potential error messages were always correctly cleared before showing the dialog. Tested on macOS 10.12.3 with Qt 5.7.1. Change-Id: I3958c35286f6f0096d1605c29816f666530aae03 diff --git a/Swift/Controllers/ProfileController.cpp b/Swift/Controllers/ProfileController.cpp index d000164..1a92f29 100644 --- a/Swift/Controllers/ProfileController.cpp +++ b/Swift/Controllers/ProfileController.cpp @@ -48,6 +48,7 @@ void ProfileController::handleUIEvent(UIEvent::ref event) { gettingVCard = true; updateDialogStatus(); vcardManager->requestOwnVCard(); + profileWindow->setError(""); profileWindow->show(); } diff --git a/Swift/Controllers/ShowProfileController.cpp b/Swift/Controllers/ShowProfileController.cpp index b379141..a7d7d04 100644 --- a/Swift/Controllers/ShowProfileController.cpp +++ b/Swift/Controllers/ShowProfileController.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -17,6 +17,7 @@ #include <Swiften/VCards/VCardManager.h> +#include <Swift/Controllers/Intl.h> #include <Swift/Controllers/UIEvents/ShowProfileForRosterItemUIEvent.h> #include <Swift/Controllers/UIEvents/UIEventStream.h> #include <Swift/Controllers/UIInterfaces/ProfileWindowFactory.h> @@ -26,6 +27,7 @@ namespace Swift { ShowProfileController::ShowProfileController(VCardManager* vcardManager, ProfileWindowFactory* profileWindowFactory, UIEventStream* uiEventStream) : vcardManager(vcardManager), profileWindowFactory(profileWindowFactory), uiEventStream(uiEventStream) { uiEventStream->onUIEvent.connect(boost::bind(&ShowProfileController::handleUIEvent, this, _1)); vcardManager->onVCardChanged.connect(boost::bind(&ShowProfileController::handleVCardChanged, this, _1, _2)); + vcardManager->onVCardRetrievalError.connect(boost::bind(&ShowProfileController::handleVCardRetrievalError, this, _1, _2)); } ShowProfileController::~ShowProfileController() { @@ -34,6 +36,7 @@ ShowProfileController::~ShowProfileController() { delete jidWndPair.second; } + vcardManager->onVCardRetrievalError.disconnect(boost::bind(&ShowProfileController::handleVCardRetrievalError, this, _1, _2)); vcardManager->onVCardChanged.disconnect(boost::bind(&ShowProfileController::handleVCardChanged, this, _1, _2)); uiEventStream->onUIEvent.disconnect(boost::bind(&ShowProfileController::handleUIEvent, this, _1)); } @@ -55,6 +58,7 @@ void ShowProfileController::handleUIEvent(UIEvent::ref event) { } else { newProfileWindow->setProcessing(true); } + newProfileWindow->setError(""); newProfileWindow->show(); } else { openedProfileWindows[showProfileEvent->getJID()]->show(); @@ -76,4 +80,15 @@ void ShowProfileController::handleProfileWindowAboutToBeClosed(const JID& profil openedProfileWindows.erase(profileJid); } +void ShowProfileController::handleVCardRetrievalError(const JID& jid, ErrorPayload::ref /* error */) { + if (openedProfileWindows.find(jid) == openedProfileWindows.end()) { + return; + } + + auto profileWindow = openedProfileWindows[jid]; + profileWindow->setError(QT_TRANSLATE_NOOP("", "Failed to retrieve recent profile for user.")); + profileWindow->setProcessing(false); + profileWindow->show(); +} + } diff --git a/Swift/Controllers/ShowProfileController.h b/Swift/Controllers/ShowProfileController.h index 4f23c19..0d01ba1 100644 --- a/Swift/Controllers/ShowProfileController.h +++ b/Swift/Controllers/ShowProfileController.h @@ -5,13 +5,14 @@ */ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once +#include <Swiften/Elements/ErrorPayload.h> #include <Swiften/Elements/VCard.h> #include <Swiften/JID/JID.h> @@ -32,6 +33,7 @@ namespace Swift { void handleUIEvent(UIEvent::ref event); void handleVCardChanged(const JID&, VCard::ref); void handleProfileWindowAboutToBeClosed(const JID& profileJid); + void handleVCardRetrievalError(const JID& jid, ErrorPayload::ref error); private: VCardManager* vcardManager; diff --git a/Swift/QtUI/QtProfileWindow.cpp b/Swift/QtUI/QtProfileWindow.cpp index 80e275b..10326bb 100644 --- a/Swift/QtUI/QtProfileWindow.cpp +++ b/Swift/QtUI/QtProfileWindow.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -74,7 +74,6 @@ void QtProfileWindow::setEnabled(bool b) { void QtProfileWindow::setEditable(bool b) { ui->throbberLabel->setVisible(b); - ui->errorLabel->setVisible(b); ui->savePushButton->setVisible(b); ui->vcard->setEditable(b); updateTitle(); @@ -103,6 +102,7 @@ void QtProfileWindow::setError(const std::string& error) { else { ui->errorLabel->setText(""); } + ui->errorLabel->setVisible(!error.empty()); } void QtProfileWindow::show() { diff --git a/Swiften/Network/GConfProxyProvider.cpp b/Swiften/Network/GConfProxyProvider.cpp index 40cd97c..eade450 100644 --- a/Swiften/Network/GConfProxyProvider.cpp +++ b/Swiften/Network/GConfProxyProvider.cpp @@ -17,7 +17,7 @@ #include <iostream> -export "C" { +extern "C" { #include <gconf/gconf-client.h> } -- cgit v0.10.2-6-g49f6