summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-10-03 16:27:38 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-10-03 16:27:38 (GMT)
commitd9a1a47e107bba107499db0fc970ac774fac79e9 (patch)
tree5d000fb457b75035c1768486a1c0592047ac7d74
parenta719c9898cba1e5a618996ae506256a0c2556cc4 (diff)
downloadswift-contrib-d9a1a47e107bba107499db0fc970ac774fac79e9.zip
swift-contrib-d9a1a47e107bba107499db0fc970ac774fac79e9.tar.bz2
Don't get confused when people change roles in a MUC.
Resolves: #529 Release-Notes: Being in a MUC with someone who has their role changed will no longer cause them to appear several times in the occupant list.
-rw-r--r--Swift/QtUI/QtChatWindow.h1
-rw-r--r--Swift/QtUI/QtTabbable.h1
-rw-r--r--Swiften/MUC/MUC.cpp7
-rw-r--r--Swiften/MUC/MUCOccupant.cpp4
-rw-r--r--Swiften/MUC/MUCOccupant.h2
5 files changed, 11 insertions, 4 deletions
diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h
index 2b64f83..20c8685 100644
--- a/Swift/QtUI/QtChatWindow.h
+++ b/Swift/QtUI/QtChatWindow.h
@@ -57,7 +57,6 @@ namespace Swift {
signals:
void geometryChanged();
- void requestFlash();
protected slots:
void qAppFocusChanged(QWidget* old, QWidget* now);
diff --git a/Swift/QtUI/QtTabbable.h b/Swift/QtUI/QtTabbable.h
index 1a1170f..e236a0b 100644
--- a/Swift/QtUI/QtTabbable.h
+++ b/Swift/QtUI/QtTabbable.h
@@ -30,5 +30,6 @@ namespace Swift {
void requestPreviousTab();
void requestNextTab();
void requestActiveTab();
+ void requestFlash();
};
}
diff --git a/Swiften/MUC/MUC.cpp b/Swiften/MUC/MUC.cpp
index bcc9e6f..3446849 100644
--- a/Swiften/MUC/MUC.cpp
+++ b/Swiften/MUC/MUC.cpp
@@ -6,8 +6,6 @@
#include "Swiften/MUC/MUC.h"
-#include <iostream>
-
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
@@ -110,10 +108,12 @@ void MUC::handleIncomingPresence(boost::shared_ptr<Presence> presence) {
} else if (presence->getType() == Presence::Available) {
std::map<String, MUCOccupant>::iterator it = occupants.find(nick);
MUCOccupant occupant(nick, role, affiliation);
+ bool isJoin = true;
if (realJID) {
occupant.setRealJID(realJID.get());
}
if (it != occupants.end()) {
+ isJoin = false;
MUCOccupant oldOccupant = it->second;
if (oldOccupant.getRole() != role) {
onOccupantRoleChanged(nick, occupant, oldOccupant.getRole());
@@ -121,9 +121,10 @@ void MUC::handleIncomingPresence(boost::shared_ptr<Presence> presence) {
if (oldOccupant.getAffiliation() != affiliation) {
onOccupantAffiliationChanged(nick, affiliation, oldOccupant.getAffiliation());
}
+ occupants.erase(it);
}
std::pair<std::map<String, MUCOccupant>::iterator, bool> result = occupants.insert(std::make_pair(nick, occupant));
- if (result.second) {
+ if (isJoin) {
onOccupantJoined(result.first->second);
}
onOccupantPresenceChange(presence);
diff --git a/Swiften/MUC/MUCOccupant.cpp b/Swiften/MUC/MUCOccupant.cpp
index 3e907ab..33a5fcc 100644
--- a/Swiften/MUC/MUCOccupant.cpp
+++ b/Swiften/MUC/MUCOccupant.cpp
@@ -14,6 +14,10 @@ MUCOccupant::MUCOccupant(const String &nick, Role role, Affiliation affiliation)
MUCOccupant::~MUCOccupant() {
}
+MUCOccupant::MUCOccupant(const MUCOccupant& other) : nick_(other.getNick()), role_(other.getRole()), affiliation_(other.getAffiliation()), realJID_(other.getRealJID()) {
+
+}
+
String MUCOccupant::getNick() const {
return nick_;
}
diff --git a/Swiften/MUC/MUCOccupant.h b/Swiften/MUC/MUCOccupant.h
index c9551de..96ac5ad 100644
--- a/Swiften/MUC/MUCOccupant.h
+++ b/Swiften/MUC/MUCOccupant.h
@@ -20,6 +20,7 @@ namespace Swift {
enum Affiliation {Owner, Admin, Member, Outcast, NoAffiliation};
MUCOccupant(const String &nick, Role role, Affiliation affiliation);
+ MUCOccupant(const MUCOccupant& other);
~MUCOccupant();
String getNick() const;
@@ -34,6 +35,7 @@ namespace Swift {
Role role_;
Affiliation affiliation_;
boost::optional<JID> realJID_;
+ /* If you add a field, remember to update the const copy constructor */
};
}