diff options
author | Tobias Markmann <tm@ayena.de> | 2015-10-27 16:20:09 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2015-10-30 12:34:52 (GMT) |
commit | 0f5ef716a50c8d9761cafda12aacf818cdfd6353 (patch) | |
tree | 4ed80dedc2fa8b04036eb7567282094ea8fe07f1 /Swift/Controllers/Chat/ChatController.cpp | |
parent | 4320235bef1b601856b295a8d6411d1898048802 (diff) | |
download | swift-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.cpp | 22 |
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 @@ -68,13 +68,13 @@ ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQ Presence::ref theirPresence; if (isInMUC) { startMessage = str(format(QT_TRANSLATE_NOOP("", "Starting chat with %1% in chatroom %2%")) % nick % contact.toBare().toString()); theirPresence = presenceOracle->getLastPresence(contact); } else { startMessage = str(format(QT_TRANSLATE_NOOP("", "Starting chat with %1% - %2%")) % nick % contact.toBare().toString()); - theirPresence = contact.isBare() ? presenceOracle->getHighestPriorityPresence(contact.toBare()) : presenceOracle->getLastPresence(contact); + theirPresence = contact.isBare() ? presenceOracle->getAccountPresence(contact) : presenceOracle->getLastPresence(contact); } Idle::ref idle; if (theirPresence && (idle = theirPresence->getPayload<Idle>())) { startMessage += str(format(QT_TRANSLATE_NOOP("", ", who has been idle since %1%")) % dateTimeToLocalString(idle->getSince())); } startMessage += ": " + statusShowTypeToFriendlyName(theirPresence ? theirPresence->getShow() : StatusShow::None); @@ -140,13 +140,13 @@ void ChatController::setToJID(const JID& jid) { chatStateNotifier_->setContact(jid); ChatControllerBase::setToJID(jid); Presence::ref presence; if (isInMUC_) { presence = presenceOracle_->getLastPresence(jid); } else { - presence = jid.isBare() ? presenceOracle_->getHighestPriorityPresence(jid.toBare()) : presenceOracle_->getLastPresence(jid); + presence = jid.isBare() ? presenceOracle_->getAccountPresence(jid.toBare()) : presenceOracle_->getLastPresence(jid); } chatStateNotifier_->setContactIsOnline(presence && presence->getType() == Presence::Available); handleBareJIDCapsChanged(toJID_); } void ChatController::setAvailableServerFeatures(boost::shared_ptr<DiscoInfo> info) { @@ -461,24 +461,24 @@ std::string ChatController::getStatusChangeString(boost::shared_ptr<Presence> pr response += " (" + presence->getStatus() + ")"; } return response + "."; } void ChatController::handlePresenceChange(boost::shared_ptr<Presence> newPresence) { - bool me = false; - if (toJID_.isBare()) { - newPresence = presenceOracle_->getHighestPriorityPresence(toJID_); - if ((newPresence ? newPresence->getShow() : StatusShow::None) != lastShownStatus_) { - me = true; - } - } else if (toJID_.equals(newPresence->getFrom(), JID::WithResource)) { - me = true; + bool relevantPresence = false; + + if (toJID_.equals(newPresence->getFrom(), JID::WithoutResource)) { + // Presence matches ChatController JID. + newPresence = presenceOracle_->getAccountPresence(toJID_); + relevantPresence = true; } - if (!me) { + + if (!relevantPresence) { return; } + if (!newPresence) { newPresence = boost::make_shared<Presence>(); newPresence->setType(Presence::Unavailable); } lastShownStatus_ = newPresence->getShow(); |