summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-10-19 15:02:47 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-10-19 15:36:21 (GMT)
commitd4789216fc8894a5ce3ed359851422acecfe6bdb (patch)
tree1c05ce0551bb89c680b9ff4aa2dd371a4bf62e39 /Swiften
parentcbed358b159626ddc41f5c8b98a705a02f072c35 (diff)
downloadswift-contrib-d4789216fc8894a5ce3ed359851422acecfe6bdb.zip
swift-contrib-d4789216fc8894a5ce3ed359851422acecfe6bdb.tar.bz2
For abnormal MUC parts, give the reason.
Makes abnormals immune to presence folding. Resolves: #1004
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/MUC/MUC.cpp22
-rw-r--r--Swiften/MUC/MUC.h2
2 files changed, 21 insertions, 3 deletions
diff --git a/Swiften/MUC/MUC.cpp b/Swiften/MUC/MUC.cpp
index 78546c8..9f6c7fb 100644
--- a/Swiften/MUC/MUC.cpp
+++ b/Swiften/MUC/MUC.cpp
@@ -145,15 +145,33 @@ void MUC::handleIncomingPresence(Presence::ref presence) {
//170 is room logging to http
//TODO: Nick changes
if (presence->getType() == Presence::Unavailable) {
+ LeavingType type = LeavePart;
+ if (mucPayload) {
+ if (boost::dynamic_pointer_cast<MUCDestroyPayload>(mucPayload->getPayload())) {
+ type = LeaveDestroy;
+ }
+ else foreach (MUCUserPayload::StatusCode status, mucPayload->getStatusCodes()) {
+ if (status.code == 307) {
+ type = LeaveKick;
+ }
+ else if (status.code == 301) {
+ type = LeaveBan;
+ }
+ else if (status.code == 321) {
+ type = LeaveNotMember;
+ }
+ }
+ }
+
if (presence->getFrom() == ownMUCJID) {
- handleUserLeft(Part);
+ handleUserLeft(type);
return;
}
else {
std::map<std::string,MUCOccupant>::iterator i = occupants.find(nick);
if (i != occupants.end()) {
//TODO: part type
- onOccupantLeft(i->second, Part, "");
+ onOccupantLeft(i->second, type, "");
occupants.erase(i);
}
}
diff --git a/Swiften/MUC/MUC.h b/Swiften/MUC/MUC.h
index 39acb22..60ed697 100644
--- a/Swiften/MUC/MUC.h
+++ b/Swiften/MUC/MUC.h
@@ -32,7 +32,7 @@ namespace Swift {
typedef boost::shared_ptr<MUC> ref;
enum JoinResult { JoinSucceeded, JoinFailed };
- enum LeavingType { Part, Disconnect };
+ enum LeavingType { LeavePart, LeaveKick, LeaveBan, LeaveDestroy, LeaveNotMember, Disconnect };
public:
MUC(StanzaChannel* stanzaChannel, IQRouter* iqRouter, DirectedPresenceSender* presenceSender, const JID &muc, MUCRegistry* mucRegistry);