summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/MUC/MUC.cpp48
-rw-r--r--Swiften/MUC/MUC.h8
2 files changed, 56 insertions, 0 deletions
diff --git a/Swiften/MUC/MUC.cpp b/Swiften/MUC/MUC.cpp
index 204fdcc..824ced1 100644
--- a/Swiften/MUC/MUC.cpp
+++ b/Swiften/MUC/MUC.cpp
@@ -241,6 +241,9 @@ void MUC::kickOccupant(const JID& jid) {
changeOccupantRole(jid, MUCOccupant::NoRole);
}
+/**
+ * Call with the room JID, not the real JID.
+ */
void MUC::changeOccupantRole(const JID& jid, MUCOccupant::Role role) {
MUCAdminPayload::ref mucPayload = boost::make_shared<MUCAdminPayload>();
MUCItem item;
@@ -259,6 +262,51 @@ void MUC::handleOccupantRoleChangeResponse(MUCAdminPayload::ref /*unused*/, Erro
}
}
+void MUC::requestAffiliationList(MUCOccupant::Affiliation affiliation) {
+ MUCAdminPayload::ref mucPayload = boost::make_shared<MUCAdminPayload>();
+ MUCItem item;
+ item.affiliation = affiliation;
+ mucPayload->addItem(item);
+ GenericRequest<MUCAdminPayload>* request = new GenericRequest<MUCAdminPayload>(IQ::Get, getJID(), mucPayload, iqRouter_);
+ request->onResponse.connect(boost::bind(&MUC::handleAffiliationListResponse, this, _1, _2, affiliation));
+ request->send();
+}
+
+/**
+ * Must be called with the real JID, not the room JID.
+ */
+void MUC::changeAffiliation(const JID& jid, MUCOccupant::Affiliation affiliation) {
+ MUCAdminPayload::ref mucPayload = boost::make_shared<MUCAdminPayload>();
+ MUCItem item;
+ item.affiliation = affiliation;
+ item.realJID = jid;
+ mucPayload->addItem(item);
+ GenericRequest<MUCAdminPayload>* request = new GenericRequest<MUCAdminPayload>(IQ::Set, getJID(), mucPayload, iqRouter_);
+ request->onResponse.connect(boost::bind(&MUC::handleAffiliationChangeResponse, this, _1, _2, jid, affiliation));
+ request->send();
+}
+
+void MUC::handleAffiliationListResponse(MUCAdminPayload::ref payload, ErrorPayload::ref error, MUCOccupant::Affiliation affiliation) {
+ if (error) {
+ onAffiliationListFailed(error);
+ }
+ else {
+ std::vector<JID> jids;
+ foreach (MUCItem item, payload->getItems()) {
+ if (item.realJID) {
+ jids.push_back(*item.realJID);
+ }
+ }
+ onAffiliationListReceived(affiliation, jids);
+ }
+}
+
+void MUC::handleAffiliationChangeResponse(MUCAdminPayload::ref /*unused*/, ErrorPayload::ref error, const JID& jid, MUCOccupant::Affiliation affiliation) {
+ if (error) {
+ onAffiliationChangeFailed(error, jid, affiliation);
+ }
+}
+
void MUC::changeSubject(const std::string& subject) {
Message::ref message = boost::make_shared<Message>();
message->setSubject(subject);
diff --git a/Swiften/MUC/MUC.h b/Swiften/MUC/MUC.h
index d855033..1070c69 100644
--- a/Swiften/MUC/MUC.h
+++ b/Swiften/MUC/MUC.h
@@ -58,6 +58,8 @@ namespace Swift {
bool hasOccupant(const std::string& nick);
void kickOccupant(const JID& jid);
void changeOccupantRole(const JID& jid, MUCOccupant::Role role);
+ void requestAffiliationList(MUCOccupant::Affiliation);
+ void changeAffiliation(const JID& jid, MUCOccupant::Affiliation affiliation);
void changeSubject(const std::string& subject);
void requestConfigurationForm();
void configureRoom(Form::ref);
@@ -67,17 +69,21 @@ namespace Swift {
void invitePerson(const JID& person, const std::string& reason = "");
void setCreateAsReservedIfNew() {createAsReservedIfNew = true;}
void setPassword(const boost::optional<std::string>& password);
+
public:
boost::signal<void (const std::string& /*nick*/)> onJoinComplete;
boost::signal<void (ErrorPayload::ref)> onJoinFailed;
boost::signal<void (ErrorPayload::ref, const JID&, MUCOccupant::Role)> onRoleChangeFailed;
+ boost::signal<void (ErrorPayload::ref, const JID&, MUCOccupant::Affiliation)> onAffiliationChangeFailed;
boost::signal<void (ErrorPayload::ref)> onConfigurationFailed;
+ boost::signal<void (ErrorPayload::ref)> onAffiliationListFailed;
boost::signal<void (Presence::ref)> onOccupantPresenceChange;
boost::signal<void (const std::string&, const MUCOccupant& /*now*/, const MUCOccupant::Role& /*old*/)> onOccupantRoleChanged;
boost::signal<void (const std::string&, const MUCOccupant::Affiliation& /*new*/, const MUCOccupant::Affiliation& /*old*/)> onOccupantAffiliationChanged;
boost::signal<void (const MUCOccupant&)> onOccupantJoined;
boost::signal<void (const MUCOccupant&, LeavingType, const std::string& /*reason*/)> onOccupantLeft;
boost::signal<void (Form::ref)> onConfigurationFormReceived;
+ boost::signal<void (MUCOccupant::Affiliation, const std::vector<JID>&)> onAffiliationListReceived;
/* boost::signal<void (const MUCInfo&)> onInfoResult; */
/* boost::signal<void (const blah&)> onItemsResult; */
@@ -96,6 +102,8 @@ namespace Swift {
void internalJoin(const std::string& nick);
void handleCreationConfigResponse(MUCOwnerPayload::ref, ErrorPayload::ref);
void handleOccupantRoleChangeResponse(MUCAdminPayload::ref, ErrorPayload::ref, const JID&, MUCOccupant::Role);
+ void handleAffiliationChangeResponse(MUCAdminPayload::ref, ErrorPayload::ref, const JID&, MUCOccupant::Affiliation);
+ void handleAffiliationListResponse(MUCAdminPayload::ref, ErrorPayload::ref, MUCOccupant::Affiliation);
void handleConfigurationFormReceived(MUCOwnerPayload::ref, ErrorPayload::ref);
void handleConfigurationResultReceived(MUCOwnerPayload::ref, ErrorPayload::ref);