summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-10-05 13:39:47 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-10-05 13:39:47 (GMT)
commit16a895e7d64b71d1aa7a971d77e8daf6591e9c56 (patch)
tree9c1c71eb1a80dd0fd813ea6ba42d1d4c7d4889ed /Swiften
parent8159071adb232b68c2ce79479145fbcd04979245 (diff)
downloadswift-16a895e7d64b71d1aa7a971d77e8daf6591e9c56.zip
swift-16a895e7d64b71d1aa7a971d77e8daf6591e9c56.tar.bz2
Allow role changing in MUCs.
Resolves: #987
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Elements/SecurityLabelsCatalog.h6
-rw-r--r--Swiften/MUC/MUC.cpp15
-rw-r--r--Swiften/MUC/MUC.h7
3 files changed, 17 insertions, 11 deletions
diff --git a/Swiften/Elements/SecurityLabelsCatalog.h b/Swiften/Elements/SecurityLabelsCatalog.h
index b9419a9..5498fcf 100644
--- a/Swiften/Elements/SecurityLabelsCatalog.h
+++ b/Swiften/Elements/SecurityLabelsCatalog.h
@@ -21,11 +21,11 @@ namespace Swift {
class Item {
public:
Item() : default_(false) {}
- const boost::shared_ptr<SecurityLabel> getLabel() const {
+ SecurityLabel::ref getLabel() const {
return label_;
}
- void setLabel(boost::shared_ptr<SecurityLabel> label) {
+ void setLabel(SecurityLabel::ref label) {
label_ = label;
}
@@ -41,7 +41,7 @@ namespace Swift {
default_ = isDefault;
}
private:
- boost::shared_ptr<SecurityLabel> label_;
+ SecurityLabel::ref label_;
std::string selector_;
bool default_;
};
diff --git a/Swiften/MUC/MUC.cpp b/Swiften/MUC/MUC.cpp
index 15355ad..204fdcc 100644
--- a/Swiften/MUC/MUC.cpp
+++ b/Swiften/MUC/MUC.cpp
@@ -237,20 +237,25 @@ MUCOccupant MUC::getOccupant(const std::string& nick) {
return occupants.find(nick)->second;
}
-void MUC::kickUser(const JID& jid) {
+void MUC::kickOccupant(const JID& jid) {
+ changeOccupantRole(jid, MUCOccupant::NoRole);
+}
+
+void MUC::changeOccupantRole(const JID& jid, MUCOccupant::Role role) {
MUCAdminPayload::ref mucPayload = boost::make_shared<MUCAdminPayload>();
MUCItem item;
- item.role = MUCOccupant::NoRole;
+ item.role = role;
item.nick = jid.getResource();
mucPayload->addItem(item);
GenericRequest<MUCAdminPayload>* request = new GenericRequest<MUCAdminPayload>(IQ::Set, getJID(), mucPayload, iqRouter_);
- request->onResponse.connect(boost::bind(&MUC::handleKickResponse, this, _1, _2, jid));
+ request->onResponse.connect(boost::bind(&MUC::handleOccupantRoleChangeResponse, this, _1, _2, jid, role));
request->send();
+
}
-void MUC::handleKickResponse(MUCAdminPayload::ref /*unused*/, ErrorPayload::ref error, const JID& jid) {
+void MUC::handleOccupantRoleChangeResponse(MUCAdminPayload::ref /*unused*/, ErrorPayload::ref error, const JID& jid, MUCOccupant::Role role) {
if (error) {
- onKickFailed(error, jid);
+ onRoleChangeFailed(error, jid, role);
}
}
diff --git a/Swiften/MUC/MUC.h b/Swiften/MUC/MUC.h
index a9b42b8..d855033 100644
--- a/Swiften/MUC/MUC.h
+++ b/Swiften/MUC/MUC.h
@@ -56,7 +56,8 @@ namespace Swift {
/** Get occupant information*/
MUCOccupant getOccupant(const std::string& nick);
bool hasOccupant(const std::string& nick);
- void kickUser(const JID& jid);
+ void kickOccupant(const JID& jid);
+ void changeOccupantRole(const JID& jid, MUCOccupant::Role role);
void changeSubject(const std::string& subject);
void requestConfigurationForm();
void configureRoom(Form::ref);
@@ -69,7 +70,7 @@ namespace Swift {
public:
boost::signal<void (const std::string& /*nick*/)> onJoinComplete;
boost::signal<void (ErrorPayload::ref)> onJoinFailed;
- boost::signal<void (ErrorPayload::ref, const JID&)> onKickFailed;
+ boost::signal<void (ErrorPayload::ref, const JID&, MUCOccupant::Role)> onRoleChangeFailed;
boost::signal<void (ErrorPayload::ref)> onConfigurationFailed;
boost::signal<void (Presence::ref)> onOccupantPresenceChange;
boost::signal<void (const std::string&, const MUCOccupant& /*now*/, const MUCOccupant::Role& /*old*/)> onOccupantRoleChanged;
@@ -94,7 +95,7 @@ namespace Swift {
void handleIncomingPresence(Presence::ref presence);
void internalJoin(const std::string& nick);
void handleCreationConfigResponse(MUCOwnerPayload::ref, ErrorPayload::ref);
- void handleKickResponse(MUCAdminPayload::ref, ErrorPayload::ref, const JID&);
+ void handleOccupantRoleChangeResponse(MUCAdminPayload::ref, ErrorPayload::ref, const JID&, MUCOccupant::Role);
void handleConfigurationFormReceived(MUCOwnerPayload::ref, ErrorPayload::ref);
void handleConfigurationResultReceived(MUCOwnerPayload::ref, ErrorPayload::ref);