summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/MUC/MUC.cpp7
-rw-r--r--Swiften/MUC/MUCOccupant.cpp4
-rw-r--r--Swiften/MUC/MUCOccupant.h2
3 files changed, 10 insertions, 3 deletions
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 */
};
}