summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-10-27 16:20:09 (GMT)
committerTobias Markmann <tm@ayena.de>2015-10-30 12:34:52 (GMT)
commit0f5ef716a50c8d9761cafda12aacf818cdfd6353 (patch)
tree4ed80dedc2fa8b04036eb7567282094ea8fe07f1 /Swift/Controllers/Chat/ChatController.cpp
parent4320235bef1b601856b295a8d6411d1898048802 (diff)
downloadswift-0f5ef716a50c8d9761cafda12aacf818cdfd6353.zip
swift-0f5ef716a50c8d9761cafda12aacf818cdfd6353.tar.bz2
Change bare JID presence lookup code to ignore priorities
Before presence handling code was handled by both, the ContactRosterItem in Swift and the PresenceOracle in Swiften. The ContactRosterItem also considered the presence priority for deciding what presence to show for a bare JID. With this code all full or bare JID presence requests are finally handled by the PresenceOracle. For bare JIDs it is looked up to a presence of one of the available resources of that JID regardless of the priorities. Test-Information: Adjusted tests according to above description and documentation in PresenceOracle. Change-Id: I972a4574f476cdf4d4b5593a035eb1c25ef2f8ba
Diffstat (limited to 'Swift/Controllers/Chat/ChatController.cpp')
-rw-r--r--Swift/Controllers/Chat/ChatController.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp
index bedc427..51c7349 100644
--- a/Swift/Controllers/Chat/ChatController.cpp
+++ b/Swift/Controllers/Chat/ChatController.cpp
@@ -69,11 +69,11 @@ ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQ
69 if (isInMUC) { 69 if (isInMUC) {
70 startMessage = str(format(QT_TRANSLATE_NOOP("", "Starting chat with %1% in chatroom %2%")) % nick % contact.toBare().toString()); 70 startMessage = str(format(QT_TRANSLATE_NOOP("", "Starting chat with %1% in chatroom %2%")) % nick % contact.toBare().toString());
71 theirPresence = presenceOracle->getLastPresence(contact); 71 theirPresence = presenceOracle->getLastPresence(contact);
72 } else { 72 } else {
73 startMessage = str(format(QT_TRANSLATE_NOOP("", "Starting chat with %1% - %2%")) % nick % contact.toBare().toString()); 73 startMessage = str(format(QT_TRANSLATE_NOOP("", "Starting chat with %1% - %2%")) % nick % contact.toBare().toString());
74 theirPresence = contact.isBare() ? presenceOracle->getHighestPriorityPresence(contact.toBare()) : presenceOracle->getLastPresence(contact); 74 theirPresence = contact.isBare() ? presenceOracle->getAccountPresence(contact) : presenceOracle->getLastPresence(contact);
75 } 75 }
76 Idle::ref idle; 76 Idle::ref idle;
77 if (theirPresence && (idle = theirPresence->getPayload<Idle>())) { 77 if (theirPresence && (idle = theirPresence->getPayload<Idle>())) {
78 startMessage += str(format(QT_TRANSLATE_NOOP("", ", who has been idle since %1%")) % dateTimeToLocalString(idle->getSince())); 78 startMessage += str(format(QT_TRANSLATE_NOOP("", ", who has been idle since %1%")) % dateTimeToLocalString(idle->getSince()));
79 } 79 }
@@ -141,11 +141,11 @@ void ChatController::setToJID(const JID& jid) {
141 ChatControllerBase::setToJID(jid); 141 ChatControllerBase::setToJID(jid);
142 Presence::ref presence; 142 Presence::ref presence;
143 if (isInMUC_) { 143 if (isInMUC_) {
144 presence = presenceOracle_->getLastPresence(jid); 144 presence = presenceOracle_->getLastPresence(jid);
145 } else { 145 } else {
146 presence = jid.isBare() ? presenceOracle_->getHighestPriorityPresence(jid.toBare()) : presenceOracle_->getLastPresence(jid); 146 presence = jid.isBare() ? presenceOracle_->getAccountPresence(jid.toBare()) : presenceOracle_->getLastPresence(jid);
147 } 147 }
148 chatStateNotifier_->setContactIsOnline(presence && presence->getType() == Presence::Available); 148 chatStateNotifier_->setContactIsOnline(presence && presence->getType() == Presence::Available);
149 handleBareJIDCapsChanged(toJID_); 149 handleBareJIDCapsChanged(toJID_);
150} 150}
151 151
@@ -462,22 +462,22 @@ std::string ChatController::getStatusChangeString(boost::shared_ptr<Presence> pr
462 } 462 }
463 return response + "."; 463 return response + ".";
464} 464}
465 465
466void ChatController::handlePresenceChange(boost::shared_ptr<Presence> newPresence) { 466void ChatController::handlePresenceChange(boost::shared_ptr<Presence> newPresence) {
467 bool me = false; 467 bool relevantPresence = false;
468 if (toJID_.isBare()) { 468
469 newPresence = presenceOracle_->getHighestPriorityPresence(toJID_); 469 if (toJID_.equals(newPresence->getFrom(), JID::WithoutResource)) {
470 if ((newPresence ? newPresence->getShow() : StatusShow::None) != lastShownStatus_) { 470 // Presence matches ChatController JID.
471 me = true; 471 newPresence = presenceOracle_->getAccountPresence(toJID_);
472 } 472 relevantPresence = true;
473 } else if (toJID_.equals(newPresence->getFrom(), JID::WithResource)) {
474 me = true;
475 } 473 }
476 if (!me) { 474
475 if (!relevantPresence) {
477 return; 476 return;
478 } 477 }
478
479 if (!newPresence) { 479 if (!newPresence) {
480 newPresence = boost::make_shared<Presence>(); 480 newPresence = boost::make_shared<Presence>();
481 newPresence->setType(Presence::Unavailable); 481 newPresence->setType(Presence::Unavailable);
482 } 482 }
483 lastShownStatus_ = newPresence->getShow(); 483 lastShownStatus_ = newPresence->getShow();