summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swiften/MUC/MUCImpl.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/Swiften/MUC/MUCImpl.cpp b/Swiften/MUC/MUCImpl.cpp
index 99789c0..a1854e3 100644
--- a/Swiften/MUC/MUCImpl.cpp
+++ b/Swiften/MUC/MUCImpl.cpp
@@ -207,228 +207,228 @@ void MUCImpl::handleIncomingPresence(Presence::ref presence) {
if (isJoin) {
onOccupantJoined(result.first->second);
}
onOccupantPresenceChange(presence);
}
if (mucPayload && !joinComplete_) {
bool isLocked = false;
foreach (MUCUserPayload::StatusCode status, mucPayload->getStatusCodes()) {
if (status.code == 110) {
/* Simply knowing this is your presence is enough, 210 doesn't seem to be necessary. */
joinComplete_ = true;
if (ownMUCJID != presence->getFrom()) {
presenceSender->removeDirectedPresenceReceiver(ownMUCJID, DirectedPresenceSender::DontSendPresence);
ownMUCJID = presence->getFrom();
presenceSender->addDirectedPresenceReceiver(ownMUCJID, DirectedPresenceSender::AndSendPresence);
}
onJoinComplete(getOwnNick());
}
if (status.code == 201) {
isLocked = true;
/* Room is created and locked */
/* Currently deal with this by making an instant room */
if (ownMUCJID != presence->getFrom()) {
presenceSender->removeDirectedPresenceReceiver(ownMUCJID, DirectedPresenceSender::DontSendPresence);
ownMUCJID = presence->getFrom();
presenceSender->addDirectedPresenceReceiver(ownMUCJID, DirectedPresenceSender::AndSendPresence);
}
if (createAsReservedIfNew) {
unlocking = true;
requestConfigurationForm();
}
else {
MUCOwnerPayload::ref mucPayload(new MUCOwnerPayload());
presenceSender->addDirectedPresenceReceiver(ownMUCJID, DirectedPresenceSender::DontSendPresence);
mucPayload->setPayload(boost::make_shared<Form>(Form::SubmitType));
- GenericRequest<MUCOwnerPayload>* request = new GenericRequest<MUCOwnerPayload>(IQ::Set, getJID(), mucPayload, iqRouter_);
+ boost::shared_ptr< GenericRequest<MUCOwnerPayload> > request = boost::make_shared< GenericRequest<MUCOwnerPayload> >(IQ::Set, getJID(), mucPayload, iqRouter_);
request->onResponse.connect(boost::bind(&MUCImpl::handleCreationConfigResponse, this, _1, _2));
request->send();
}
}
}
if (!isLocked && !isUnlocked_ && (presence->getFrom() == ownMUCJID)) {
isUnlocked_ = true;
onUnlocked();
}
}
}
void MUCImpl::handleCreationConfigResponse(MUCOwnerPayload::ref /*unused*/, ErrorPayload::ref error) {
unlocking = false;
if (error) {
presenceSender->removeDirectedPresenceReceiver(ownMUCJID, DirectedPresenceSender::AndSendPresence);
onJoinFailed(error);
} else {
onJoinComplete(getOwnNick()); /* Previously, this wasn't needed here, as the presence duplication bug caused an emit elsewhere. */
isUnlocked_ = true;
onUnlocked();
}
}
bool MUCImpl::hasOccupant(const std::string& nick) {
return occupants.find(nick) != occupants.end();
}
const MUCOccupant& MUCImpl::getOccupant(const std::string& nick) {
return occupants.find(nick)->second;
}
void MUCImpl::kickOccupant(const JID& jid) {
changeOccupantRole(jid, MUCOccupant::NoRole);
}
/**
* Call with the room JID, not the real JID.
*/
void MUCImpl::changeOccupantRole(const JID& jid, MUCOccupant::Role role) {
MUCAdminPayload::ref mucPayload = boost::make_shared<MUCAdminPayload>();
MUCItem item;
item.role = role;
item.nick = jid.getResource();
mucPayload->addItem(item);
- GenericRequest<MUCAdminPayload>* request = new GenericRequest<MUCAdminPayload>(IQ::Set, getJID(), mucPayload, iqRouter_);
+ boost::shared_ptr<GenericRequest<MUCAdminPayload> > request = boost::make_shared<GenericRequest<MUCAdminPayload> >(IQ::Set, getJID(), mucPayload, iqRouter_);
request->onResponse.connect(boost::bind(&MUCImpl::handleOccupantRoleChangeResponse, this, _1, _2, jid, role));
request->send();
}
void MUCImpl::handleOccupantRoleChangeResponse(MUCAdminPayload::ref /*unused*/, ErrorPayload::ref error, const JID& jid, MUCOccupant::Role role) {
if (error) {
onRoleChangeFailed(error, jid, role);
}
}
void MUCImpl::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_);
+ boost::shared_ptr<GenericRequest<MUCAdminPayload> > request = boost::make_shared< GenericRequest<MUCAdminPayload> >(IQ::Get, getJID(), mucPayload, iqRouter_);
request->onResponse.connect(boost::bind(&MUCImpl::handleAffiliationListResponse, this, _1, _2, affiliation));
request->send();
}
/**
* Must be called with the real JID, not the room JID.
*/
void MUCImpl::changeAffiliation(const JID& jid, MUCOccupant::Affiliation affiliation) {
MUCAdminPayload::ref mucPayload = boost::make_shared<MUCAdminPayload>();
MUCItem item;
item.affiliation = affiliation;
item.realJID = jid.toBare();
mucPayload->addItem(item);
- GenericRequest<MUCAdminPayload>* request = new GenericRequest<MUCAdminPayload>(IQ::Set, getJID(), mucPayload, iqRouter_);
+ boost::shared_ptr<GenericRequest<MUCAdminPayload> > request = boost::make_shared<GenericRequest<MUCAdminPayload> >(IQ::Set, getJID(), mucPayload, iqRouter_);
request->onResponse.connect(boost::bind(&MUCImpl::handleAffiliationChangeResponse, this, _1, _2, jid, affiliation));
request->send();
}
void MUCImpl::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 MUCImpl::handleAffiliationChangeResponse(MUCAdminPayload::ref /*unused*/, ErrorPayload::ref error, const JID& jid, MUCOccupant::Affiliation affiliation) {
if (error) {
onAffiliationChangeFailed(error, jid, affiliation);
}
}
void MUCImpl::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);
}
void MUCImpl::requestConfigurationForm() {
MUCOwnerPayload::ref mucPayload(new MUCOwnerPayload());
- GenericRequest<MUCOwnerPayload>* request = new GenericRequest<MUCOwnerPayload>(IQ::Get, getJID(), mucPayload, iqRouter_);
+ boost::shared_ptr<GenericRequest<MUCOwnerPayload> > request = boost::make_shared<GenericRequest<MUCOwnerPayload> >(IQ::Get, getJID(), mucPayload, iqRouter_);
request->onResponse.connect(boost::bind(&MUCImpl::handleConfigurationFormReceived, this, _1, _2));
request->send();
}
void MUCImpl::cancelConfigureRoom() {
MUCOwnerPayload::ref mucPayload(new MUCOwnerPayload());
mucPayload->setPayload(boost::make_shared<Form>(Form::CancelType));
- GenericRequest<MUCOwnerPayload>* request = new GenericRequest<MUCOwnerPayload>(IQ::Set, getJID(), mucPayload, iqRouter_);
+ boost::shared_ptr<GenericRequest<MUCOwnerPayload> > request = boost::make_shared<GenericRequest<MUCOwnerPayload> >(IQ::Set, getJID(), mucPayload, iqRouter_);
request->send();
}
void MUCImpl::handleConfigurationFormReceived(MUCOwnerPayload::ref payload, ErrorPayload::ref error) {
Form::ref form;
if (payload) {
form = payload->getForm();
}
if (error || !form) {
onConfigurationFailed(error);
} else {
onConfigurationFormReceived(form);
}
}
void MUCImpl::handleConfigurationResultReceived(MUCOwnerPayload::ref /*payload*/, ErrorPayload::ref error) {
if (error) {
onConfigurationFailed(error);
}
}
void MUCImpl::configureRoom(Form::ref form) {
MUCOwnerPayload::ref mucPayload(new MUCOwnerPayload());
mucPayload->setPayload(form);
- GenericRequest<MUCOwnerPayload>* request = new GenericRequest<MUCOwnerPayload>(IQ::Set, getJID(), mucPayload, iqRouter_);
+ boost::shared_ptr<GenericRequest<MUCOwnerPayload> > request = boost::make_shared<GenericRequest<MUCOwnerPayload> >(IQ::Set, getJID(), mucPayload, iqRouter_);
if (unlocking) {
request->onResponse.connect(boost::bind(&MUCImpl::handleCreationConfigResponse, this, _1, _2));
}
else {
request->onResponse.connect(boost::bind(&MUCImpl::handleConfigurationResultReceived, this, _1, _2));
}
request->send();
}
void MUCImpl::destroyRoom() {
MUCOwnerPayload::ref mucPayload = boost::make_shared<MUCOwnerPayload>();
MUCDestroyPayload::ref mucDestroyPayload = boost::make_shared<MUCDestroyPayload>();
mucPayload->setPayload(mucDestroyPayload);
- GenericRequest<MUCOwnerPayload>* request = new GenericRequest<MUCOwnerPayload>(IQ::Set, getJID(), mucPayload, iqRouter_);
+ boost::shared_ptr< GenericRequest<MUCOwnerPayload> > request = boost::make_shared<GenericRequest<MUCOwnerPayload> >(IQ::Set, getJID(), mucPayload, iqRouter_);
request->onResponse.connect(boost::bind(&MUCImpl::handleConfigurationResultReceived, this, _1, _2));
request->send();
}
void MUCImpl::invitePerson(const JID& person, const std::string& reason, bool isImpromptu, bool isReuseChat) {
Message::ref message = boost::make_shared<Message>();
message->setTo(person);
message->setType(Message::Normal);
MUCInvitationPayload::ref invite = boost::make_shared<MUCInvitationPayload>();
invite->setReason(reason);
invite->setJID(ownMUCJID.toBare());
invite->setIsImpromptu(isImpromptu);
invite->setIsContinuation(isReuseChat);
message->addPayload(invite);
stanzaChannel->sendMessage(message);
}
//TODO: Invites(direct/mediated)
//TODO: requesting membership
//TODO: get member list
//TODO: request voice
//TODO: moderator use cases
//TODO: Admin use cases
//TODO: Owner use cases
}