summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-01-12 20:15:56 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-01-12 20:15:56 (GMT)
commit694ff33145467a9d8a0f87317124bc5c4251d18d (patch)
tree5d509c082417791add4356e4d512c7526adeeebc /Swiften/Elements
parent52cc4918673a80739ae67c99943273339e848458 (diff)
downloadswift-contrib-694ff33145467a9d8a0f87317124bc5c4251d18d.zip
swift-contrib-694ff33145467a9d8a0f87317124bc5c4251d18d.tar.bz2
Refactored MUC code a bit.
Diffstat (limited to 'Swiften/Elements')
-rw-r--r--Swiften/Elements/MUCOccupant.cpp46
-rw-r--r--Swiften/Elements/MUCOccupant.h41
-rw-r--r--Swiften/Elements/MUCUserPayload.h4
3 files changed, 89 insertions, 2 deletions
diff --git a/Swiften/Elements/MUCOccupant.cpp b/Swiften/Elements/MUCOccupant.cpp
new file mode 100644
index 0000000..0d3773e
--- /dev/null
+++ b/Swiften/Elements/MUCOccupant.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swiften/Elements/MUCOccupant.h"
+
+namespace Swift {
+
+MUCOccupant::MUCOccupant(const String &nick, Role role, Affiliation affiliation) : nick_(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_;
+}
+
+MUCOccupant::Role MUCOccupant::getRole() const {
+ return role_;
+}
+
+MUCOccupant::Affiliation MUCOccupant::getAffiliation() const {
+ return affiliation_;
+}
+
+void MUCOccupant::setRealJID(const JID& realJID) {
+ realJID_ = realJID;
+}
+
+void MUCOccupant::setNick(const String& nick) {
+ nick_ = nick;
+}
+
+
+boost::optional<JID> MUCOccupant::getRealJID() const {
+ return realJID_;
+}
+
+}
diff --git a/Swiften/Elements/MUCOccupant.h b/Swiften/Elements/MUCOccupant.h
new file mode 100644
index 0000000..96ac5ad
--- /dev/null
+++ b/Swiften/Elements/MUCOccupant.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <boost/optional.hpp>
+
+#include "Swiften/Base/String.h"
+#include "Swiften/JID/JID.h"
+
+namespace Swift {
+ class Client;
+
+ class MUCOccupant {
+ public:
+ enum Role {Moderator, Participant, Visitor, NoRole};
+ enum Affiliation {Owner, Admin, Member, Outcast, NoAffiliation};
+
+ MUCOccupant(const String &nick, Role role, Affiliation affiliation);
+ MUCOccupant(const MUCOccupant& other);
+ ~MUCOccupant();
+
+ String getNick() const;
+ Role getRole() const;
+ Affiliation getAffiliation() const;
+ boost::optional<JID> getRealJID() const;
+ void setRealJID(const JID& jid);
+ void setNick(const String& nick);
+
+ private:
+ String nick_;
+ Role role_;
+ Affiliation affiliation_;
+ boost::optional<JID> realJID_;
+ /* If you add a field, remember to update the const copy constructor */
+ };
+}
+
diff --git a/Swiften/Elements/MUCUserPayload.h b/Swiften/Elements/MUCUserPayload.h
index f55c779..2014bc4 100644
--- a/Swiften/Elements/MUCUserPayload.h
+++ b/Swiften/Elements/MUCUserPayload.h
@@ -12,7 +12,7 @@
#include "Swiften/JID/JID.h"
#include "Swiften/Base/String.h"
#include "Swiften/Elements/Payload.h"
-#include "Swiften/MUC/MUCOccupant.h"
+#include "Swiften/Elements/MUCOccupant.h"
namespace Swift {
class MUCUserPayload : public Payload {
@@ -20,7 +20,7 @@ namespace Swift {
typedef boost::shared_ptr<MUCUserPayload> ref;
struct Item {
- Item() : affiliation(MUCOccupant::NoAffiliation), role(MUCOccupant::NoRole) {}
+ Item(MUCOccupant::Affiliation affiliation = MUCOccupant::NoAffiliation, MUCOccupant::Role role = MUCOccupant::NoRole) : affiliation(affiliation), role(role) {}
boost::optional<JID> realJID;
boost::optional<String> nick;
MUCOccupant::Affiliation affiliation;