bool RoomPool::SetPermisionForIM(int opuser, Permisions permision, int targetuser, const MucRoomIdPtr& roomid){ bool setok = false; MucActiveUserPtr opaptr; MucActiveUserSeq targetseq; JidSeq presenceUsers; RoomInfoPtr riptr; { IceUtil::RWRecMutex::WLock lock(_rwmutex); riptr = GetRoom(roomid); if(riptr){ targetseq = riptr->GetActiveUserSeq(targetuser); setok = riptr->SetPermisionForIM(opuser, permision, targetuser); } else{ return false; } } if(setok){ IceUtil::RWRecMutex::RLock lock(_rwmutex); opaptr = riptr->GetActiveUser(opuser); if(opaptr){ presenceUsers = riptr->GetAllActiveJids(); if(permision == POutcast || permision == PNone){ for(MucActiveUserSeq::iterator it = targetseq.begin(); it != targetseq.end(); ++it){ presenceUsers.push_back((*it)->jid); } } } } if(setok && opaptr && !presenceUsers.empty()){ MucGateAdapter::instance().NotifySetPermision(opaptr, presenceUsers, targetseq, permision); } return setok; }
void RoomPool::ChatSetingChange(int userid, const MucRoomIdPtr& roomid, int set){ RoomInfoPtr riptr; MucActiveUserSeq seq; MCE_DEBUG("RoomPool::ChatSetingChange --> userid = " << userid << " roomid = " << mucRoomIdToString(roomid) << " set = " << set); { IceUtil::RWRecMutex::RLock lock(_rwmutex); riptr = GetRoom(roomid); if(riptr){ seq = riptr->GetActiveUserSeq(userid); } } if(seq.empty()){ MCE_DEBUG("RoomPool::ChatSetingChange --> userid = " << userid << " roomid = " << mucRoomIdToString(roomid) << " set = " << set << " no MucActiveUserSeq"); return; } JidSeq webjids; for(MucActiveUserSeq::iterator ait = seq.begin(); ait != seq.end(); ++ait){ if('W' == (*ait)->jid->endpoint[0]){ webjids.push_back((*ait)->jid); } } if(webjids.empty()){ MCE_DEBUG("RoomPool::ChatSetingChange --> userid = " << userid << " roomid = " << mucRoomIdToString(roomid) << " set = " << set << " no webjids"); return; } try{ MucGateAdapter::instance().NotifyChatSetingChange(roomid, webjids, set); }catch(Ice::Exception& e){ MCE_WARN("RoomPool::ChatSetingChange--> call MucGate.NotifyChatSetingChange ERR line:"<<__LINE__<<" err:"<<e); } catch(std::exception& e){ MCE_WARN("RoomPool::ChatSetingChange--> call MucGate.NotifyChatSetingChange ERR line:"<<__LINE__<<" err:"<<e.what()); } }
void RoomPool::SetPermision(int opuser, Permisions permision, int targetuser, const MucRoomIdPtr& roomid){ MCE_DEBUG("RoomPool::SetPermision --> opuser = "******" permision = " << permision << " targetuser = "******" roomname = " << roomid->roomname); MucActiveUserPtr opaptr; MucActiveUserSeq targetseq; JidSeq presenceUsers; RoomInfoPtr riptr; { IceUtil::RWRecMutex::WLock lock(_rwmutex); riptr = GetRoom(roomid); if(riptr){ targetseq = riptr->GetActiveUserSeq(targetuser); riptr->SetPermision(targetuser, permision); } } if(riptr){ IceUtil::RWRecMutex::RLock lock(_rwmutex); opaptr = riptr->GetActiveUser(opuser); if(opaptr){ presenceUsers = riptr->GetAllActiveJids(); if(permision == POutcast || permision == PNone){ //如果是踢人的话,要把自己加上,notify self for(MucActiveUserSeq::iterator it = targetseq.begin(); it != targetseq.end(); ++it){ presenceUsers.push_back((*it)->jid); } } } } if(riptr && opaptr && !presenceUsers.empty()){ MucGateAdapter::instance().NotifySetPermision(opaptr, presenceUsers, targetseq, permision); } }
MucActiveUserSeq RoomPool::GetUserByPermision(const MucRoomIdPtr& roomid, Permisions permision){ MucActiveUserSeq ans; RoomInfoPtr riptr; IceUtil::RWRecMutex::RLock lock(_rwmutex); riptr = GetRoom(roomid); if(!riptr){ return ans; } ans = riptr->GetActiveUserSeq(permision); return ans; }