summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-01-01 00:33:24 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-01-01 00:33:24 (GMT)
commit52cc4918673a80739ae67c99943273339e848458 (patch)
tree1ec9a779155e1984b54a8e4c3442fcf720648fad /Swift
parent76f88b50f0ff2e194f0c246989072b93e87962ce (diff)
downloadswift-52cc4918673a80739ae67c99943273339e848458.zip
swift-52cc4918673a80739ae67c99943273339e848458.tar.bz2
Use the PresenceOracle for getting chat window presence lines.
Now instead of having its own logic for listening to presence updates, it checks if it's the same full JID, if the controller is bound, else it looks for changes in the highest priority resource. Combined with the previous commit, hopefully: Resolves: #718
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/Chat/ChatController.cpp17
-rw-r--r--Swift/Controllers/Chat/ChatController.h1
2 files changed, 14 insertions, 4 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp
index 90764ae..e4a76fa 100644
--- a/Swift/Controllers/Chat/ChatController.cpp
+++ b/Swift/Controllers/Chat/ChatController.cpp
@@ -50,6 +50,7 @@ ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQ
if (theirPresence && !theirPresence->getStatus().isEmpty()) {
startMessage += " (" + theirPresence->getStatus() + ")";
}
+ lastShownStatus_ = theirPresence ? theirPresence->getShow() : StatusShow::None;
chatStateNotifier_->setContactIsOnline(theirPresence && theirPresence->getType() == Presence::Available);
startMessage += ".";
chatWindow_->addSystemMessage(startMessage);
@@ -148,7 +149,7 @@ String ChatController::senderDisplayNameFromMessage(const JID& from) {
String ChatController::getStatusChangeString(boost::shared_ptr<Presence> presence) {
String nick = senderDisplayNameFromMessage(presence->getFrom());
String response = nick;
- if (presence->getType() == Presence::Unavailable || presence->getType() == Presence::Error) {
+ if (!presence || presence->getType() == Presence::Unavailable || presence->getType() == Presence::Error) {
response += " has gone offline";
} else if (presence->getType() == Presence::Available) {
StatusShow::Type show = presence->getShow();
@@ -167,11 +168,19 @@ String ChatController::getStatusChangeString(boost::shared_ptr<Presence> presenc
}
void ChatController::handlePresenceChange(boost::shared_ptr<Presence> newPresence) {
- if ((!toJID_.equals(newPresence->getFrom(), toJID_.isBare() ? JID::WithoutResource : JID::WithResource))
- ||
- (newPresence->getType() != Presence::Available && newPresence->getType() != Presence::Unavailable && newPresence->getType() != Presence::Error)) {
+ 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;
+ }
+ if (!me) {
return;
}
+ lastShownStatus_ = newPresence->getShow();
chatStateTracker_->handlePresenceChange(newPresence);
chatStateNotifier_->setContactIsOnline(newPresence->getType() == Presence::Available);
diff --git a/Swift/Controllers/Chat/ChatController.h b/Swift/Controllers/Chat/ChatController.h
index f9c686b..c013387 100644
--- a/Swift/Controllers/Chat/ChatController.h
+++ b/Swift/Controllers/Chat/ChatController.h
@@ -43,6 +43,7 @@ namespace Swift {
bool lastWasPresence_;
String lastStatusChangeString_;
std::map<boost::shared_ptr<Stanza>, String> unackedStanzas_;
+ StatusShow::Type lastShownStatus_;
};
}