summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/Controllers/ProfileController.cpp1
-rw-r--r--Swift/Controllers/ShowProfileController.cpp17
-rw-r--r--Swift/Controllers/ShowProfileController.h4
-rw-r--r--Swift/QtUI/QtProfileWindow.cpp4
-rw-r--r--Swiften/Network/GConfProxyProvider.cpp2
5 files changed, 23 insertions, 5 deletions
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
@@ -21,60 +21,61 @@ ProfileController::ProfileController(VCardManager* vcardManager, ProfileWindowFa
uiEventStream->onUIEvent.connect(boost::bind(&ProfileController::handleUIEvent, this, _1));
}
ProfileController::~ProfileController() {
if (profileWindow) {
vcardManager->onOwnVCardChanged.disconnect(boost::bind(&ProfileController::handleOwnVCardChanged, this, _1));
vcardManager->onVCardRetrievalError.disconnect(boost::bind(&ProfileController::handleVCardRetrievalError, this, _1, _2));
profileWindow->onVCardChangeRequest.disconnect(boost::bind(&ProfileController::handleVCardChangeRequest, this, _1));
profileWindow->onWindowAboutToBeClosed.disconnect(boost::bind(&ProfileController::handleProfileWindowAboutToBeClosed, this, _1));
}
uiEventStream->onUIEvent.disconnect(boost::bind(&ProfileController::handleUIEvent, this, _1));
delete profileWindow;
}
void ProfileController::handleUIEvent(UIEvent::ref event) {
if (!std::dynamic_pointer_cast<RequestProfileEditorUIEvent>(event)) {
return;
}
if (!profileWindow) {
profileWindow = profileWindowFactory->createProfileWindow();
profileWindow->setEditable(true);
profileWindow->onVCardChangeRequest.connect(boost::bind(&ProfileController::handleVCardChangeRequest, this, _1));
profileWindow->onWindowAboutToBeClosed.connect(boost::bind(&ProfileController::handleProfileWindowAboutToBeClosed, this, _1));
vcardManager->onOwnVCardChanged.connect(boost::bind(&ProfileController::handleOwnVCardChanged, this, _1));
vcardManager->onVCardRetrievalError.connect(boost::bind(&ProfileController::handleVCardRetrievalError, this, _1, _2));
}
gettingVCard = true;
updateDialogStatus();
vcardManager->requestOwnVCard();
+ profileWindow->setError("");
profileWindow->show();
}
void ProfileController::handleVCardChangeRequest(VCard::ref vcard) {
assert(!pendingSetVCardRequest);
profileWindow->setError("");
pendingSetVCardRequest = vcardManager->createSetVCardRequest(vcard);
pendingSetVCardRequest->onResponse.connect(boost::bind(&ProfileController::handleSetVCardResponse, this, _2));
pendingSetVCardRequest->send();
updateDialogStatus();
}
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::handleVCardRetrievalError(const JID& jid, ErrorPayload::ref /* error */) {
if ((jid == JID()) && profileWindow) {
profileWindow->setProcessing(false);
profileWindow->setEnabled(false);
profileWindow->setVCard(std::make_shared<VCard>());
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
@@ -1,79 +1,94 @@
/*
* Copyright (c) 2012 Tobias Markmann
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swift/Controllers/ShowProfileController.h>
#include <boost/bind.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#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>
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() {
for (const auto& jidWndPair : openedProfileWindows) {
jidWndPair.second->onWindowAboutToBeClosed.disconnect(boost::bind(&ShowProfileController::handleProfileWindowAboutToBeClosed, this, _1));
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));
}
void ShowProfileController::handleUIEvent(UIEvent::ref event) {
ShowProfileForRosterItemUIEvent::ref showProfileEvent = std::dynamic_pointer_cast<ShowProfileForRosterItemUIEvent>(event);
if (!showProfileEvent) {
return;
}
if (openedProfileWindows.find(showProfileEvent->getJID()) == openedProfileWindows.end()) {
ProfileWindow* newProfileWindow = profileWindowFactory->createProfileWindow();
newProfileWindow->setJID(showProfileEvent->getJID());
newProfileWindow->onWindowAboutToBeClosed.connect(boost::bind(&ShowProfileController::handleProfileWindowAboutToBeClosed, this, _1));
openedProfileWindows[showProfileEvent->getJID()] = newProfileWindow;
VCard::ref vcard = vcardManager->getVCardAndRequestWhenNeeded(showProfileEvent->getJID(), boost::posix_time::minutes(5));
if (vcard) {
newProfileWindow->setVCard(vcard);
} else {
newProfileWindow->setProcessing(true);
}
+ newProfileWindow->setError("");
newProfileWindow->show();
} else {
openedProfileWindows[showProfileEvent->getJID()]->show();
}
}
void ShowProfileController::handleVCardChanged(const JID& jid, VCard::ref vcard) {
if (openedProfileWindows.find(jid) == openedProfileWindows.end()) {
return;
}
ProfileWindow* profileWindow = openedProfileWindows[jid];
profileWindow->setVCard(vcard);
profileWindow->setProcessing(false);
profileWindow->show();
}
void ShowProfileController::handleProfileWindowAboutToBeClosed(const JID& profileJid) {
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
@@ -1,42 +1,44 @@
/*
* Copyright (c) 2012 Tobias Markmann
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
/*
- * 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>
#include <Swift/Controllers/UIEvents/UIEvent.h>
namespace Swift {
class VCardManager;
class ProfileWindow;
class ProfileWindowFactory;
class UIEventStream;
class ShowProfileController {
public:
ShowProfileController(VCardManager* vcardManager, ProfileWindowFactory* profileWindowFactory, UIEventStream* uiEventStream);
~ShowProfileController();
private:
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;
ProfileWindowFactory* profileWindowFactory;
UIEventStream* uiEventStream;
std::map<JID, ProfileWindow*> openedProfileWindows;
};
}
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,32 +1,32 @@
/*
- * Copyright (c) 2011-2016 Isode Limited.
+ * Copyright (c) 2011-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
/*
* Copyright (c) 2012 Tobias Markmann
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
#include <Swift/QtUI/QtProfileWindow.h>
#include <QCloseEvent>
#include <QMovie>
#include <QShortcut>
#include <QTextDocument>
#include <QTimer>
#include <Swift/QtUI/QtSwiftUtil.h>
#include <Swift/QtUI/QtUtilities.h>
#include <Swift/QtUI/ui_QtProfileWindow.h>
namespace Swift {
QtProfileWindow::QtProfileWindow() :
QWidget(),
ui(new Ui::QtProfileWindow) {
ui->setupUi(this);
ui->statusLabel->setText(tr("Retrieving profile information for this user."));
@@ -47,89 +47,89 @@ QtProfileWindow::QtProfileWindow() :
}
QtProfileWindow::~QtProfileWindow() {
delete ui;
}
void QtProfileWindow::setJID(const JID& jid) {
this->jid = jid;
updateTitle();
}
void QtProfileWindow::setVCard(VCard::ref vcard) {
ui->vcard->setVCard(vcard);
if (vcard->isEmpty()) {
ui->vcard->setVisible(false);
ui->emptyLabel->setVisible(true);
} else {
ui->vcard->setVisible(true);
ui->emptyLabel->setVisible(false);
}
updateWindowSize();
}
void QtProfileWindow::setEnabled(bool b) {
ui->vcard->setEnabled(b);
ui->savePushButton->setEnabled(b);
}
void QtProfileWindow::setEditable(bool b) {
ui->throbberLabel->setVisible(b);
- ui->errorLabel->setVisible(b);
ui->savePushButton->setVisible(b);
ui->vcard->setEditable(b);
updateTitle();
updateWindowSize();
}
void QtProfileWindow::setProcessing(bool processing) {
if (processing) {
ui->throbberLabel->movie()->start();
ui->throbberLabel->show();
ui->statusLabel->setVisible(true);
ui->vcard->setVisible(false);
}
else {
ui->throbberLabel->hide();
ui->throbberLabel->movie()->stop();
ui->statusLabel->setVisible(false);
ui->vcard->setVisible(true);
}
}
void QtProfileWindow::setError(const std::string& error) {
if (!error.empty()) {
ui->errorLabel->setText("<font color='red'>" + QtUtilities::htmlEscape(P2QSTRING(error)) + "</font>");
}
else {
ui->errorLabel->setText("");
}
+ ui->errorLabel->setVisible(!error.empty());
}
void QtProfileWindow::show() {
QWidget::showNormal();
QWidget::activateWindow();
QWidget::raise();
}
void QtProfileWindow::hide() {
QWidget::hide();
}
QSize QtProfileWindow::sizeHint() const {
return QWidget::sizeHint();
}
void QtProfileWindow::updateTitle() {
QString jidString;
if (jid.isValid()) {
jidString = QString(" ( %1 )").arg(P2QSTRING(jid.toString()));
}
if (ui->vcard->isEditable()) {
setWindowTitle(tr("Edit Profile") + jidString);
} else {
setWindowTitle(tr("Show Profile") + jidString);
}
}
void QtProfileWindow::updateWindowSize() {
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
@@ -1,50 +1,50 @@
/*
* Copyright (c) 2010-2011 Thilo Cestonaro
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
/*
* Copyright (c) 2016-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/Network/GConfProxyProvider.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>
-export "C" {
+extern "C" {
#include <gconf/gconf-client.h>
}
#include <Swiften/Base/Log.h>
namespace Swift {
GConfProxyProvider::GConfProxyProvider() {
#if !GLIB_CHECK_VERSION(2,35,0)
// Ensure static GLib initialization methods are called
static bool glibInitialized = false;
if (!glibInitialized) {
g_type_init();
glibInitialized = true;
}
#endif
socksProxy = getFromGConf("/system/proxy/socks_host", "/system/proxy/socks_port");
httpProxy = getFromGConf("/system/http_proxy/host", "/system/http_proxy/port");
SWIFT_LOG(debug) << "GConf: SOCKS5 => " << socksProxy.toString() << "; HTTP Connect => " << httpProxy.toString() << std::endl;
}
HostAddressPort GConfProxyProvider::getHTTPConnectProxy() const {
return httpProxy;
}
HostAddressPort GConfProxyProvider::getSOCKS5Proxy() const {
return socksProxy;
}