diff options
Diffstat (limited to 'Swiften')
-rw-r--r-- | Swiften/Elements/SecurityLabelsCatalog.h | 6 | ||||
-rw-r--r-- | Swiften/MUC/MUC.cpp | 15 | ||||
-rw-r--r-- | Swiften/MUC/MUC.h | 7 |
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 @@ -15,39 +15,39 @@ #include <Swiften/Elements/SecurityLabel.h> namespace Swift { class SecurityLabelsCatalog : public Payload { public: typedef boost::shared_ptr<SecurityLabelsCatalog> ref; 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; } const std::string& getSelector() const { return selector_; } void setSelector(const std::string& selector) { selector_ = selector; } bool getIsDefault() const { return default_; } void setIsDefault(bool isDefault) { default_ = isDefault; } private: - boost::shared_ptr<SecurityLabel> label_; + SecurityLabel::ref label_; std::string selector_; bool default_; }; SecurityLabelsCatalog(const JID& to = JID()) : to_(to) {} const std::vector<Item>& getItems() const { return items_; } 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 @@ -231,32 +231,37 @@ void MUC::handleCreationConfigResponse(MUCOwnerPayload::ref /*unused*/, ErrorPay bool MUC::hasOccupant(const std::string& nick) { return occupants.find(nick) != occupants.end(); } 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); } } void MUC::changeSubject(const std::string& subject) { Message::ref message = boost::make_shared<Message>(); message->setSubject(subject); message->setType(Message::Groupchat); message->setTo(ownMUCJID.toBare()); stanzaChannel->sendMessage(message); 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 @@ -50,32 +50,33 @@ namespace Swift { /*void queryRoomItems(); */ std::string getCurrentNick(); void part(); void handleIncomingMessage(Message::ref message); /** Expose public so it can be called when e.g. user goes offline */ void handleUserLeft(LeavingType); /** 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); void cancelConfigureRoom(); void destroyRoom(); /** Send an invite for the person to join the MUC */ 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&)> 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; 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 (const MUCInfo&)> onInfoResult; */ /* boost::signal<void (const blah&)> onItemsResult; */ @@ -88,19 +89,19 @@ namespace Swift { const std::string& getOwnNick() const { return ownMUCJID.getResource(); } private: 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); private: JID ownMUCJID; StanzaChannel* stanzaChannel; IQRouter* iqRouter_; DirectedPresenceSender* presenceSender; MUCRegistry* mucRegistry; |