summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers/ProfileController.cpp')
-rw-r--r--Swift/Controllers/ProfileController.cpp126
1 files changed, 63 insertions, 63 deletions
diff --git a/Swift/Controllers/ProfileController.cpp b/Swift/Controllers/ProfileController.cpp
index a1aa5f9..756aaff 100644
--- a/Swift/Controllers/ProfileController.cpp
+++ b/Swift/Controllers/ProfileController.cpp
@@ -18,97 +18,97 @@
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));
+ 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;
+ 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 (!boost::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->show();
+ if (!boost::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->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();
+ 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();
- }
+ 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(boost::make_shared<VCard>());
- profileWindow->setError(QT_TRANSLATE_NOOP("", "There was an error fetching your current profile data"));
- }
+ if ((jid == JID()) && profileWindow) {
+ profileWindow->setProcessing(false);
+ profileWindow->setEnabled(false);
+ profileWindow->setVCard(boost::make_shared<VCard>());
+ profileWindow->setError(QT_TRANSLATE_NOOP("", "There was an error fetching your current profile data"));
+ }
}
void ProfileController::handleOwnVCardChanged(VCard::ref vcard) {
- if (profileWindow) {
- profileWindow->setVCard(vcard);
- vcardBeforeEdit = vcard;
- gettingVCard = false;
- updateDialogStatus();
- }
+ if (profileWindow) {
+ profileWindow->setVCard(vcard);
+ vcardBeforeEdit = vcard;
+ gettingVCard = false;
+ updateDialogStatus();
+ }
}
void ProfileController::handleProfileWindowAboutToBeClosed(const JID&) {
- profileWindow = NULL;
+ profileWindow = NULL;
}
void ProfileController::setAvailable(bool b) {
- available = b;
- if (!available) {
- pendingSetVCardRequest.reset();
- }
- updateDialogStatus();
+ available = b;
+ if (!available) {
+ pendingSetVCardRequest.reset();
+ }
+ updateDialogStatus();
}
void ProfileController::updateDialogStatus() {
- if (profileWindow) {
- profileWindow->setEnabled(available && !gettingVCard && !pendingSetVCardRequest);
- profileWindow->setProcessing(gettingVCard || pendingSetVCardRequest);
- }
+ if (profileWindow) {
+ profileWindow->setEnabled(available && !gettingVCard && !pendingSetVCardRequest);
+ profileWindow->setProcessing(gettingVCard || pendingSetVCardRequest);
+ }
}
}