void AbiCollab::addCollaborator(BuddyPtr pCollaborator) { UT_DEBUGMSG(("AbiCollab::addCollaborator()\n")); UT_return_if_fail(pCollaborator) // check if this buddy is in the access control list if we are hosting // this session if (isLocallyControlled()) { AccountHandler* pAccount = pCollaborator->getHandler(); UT_return_if_fail(pAccount); if (!pAccount->hasAccess(m_vAcl, pCollaborator)) { UT_ASSERT(UT_NOT_IMPLEMENTED); return; } } // check for duplicates (as long as we assume a collaborator can only be part of a collaboration session once) std::map<BuddyPtr, std::string>::iterator it = m_vCollaborators.find(pCollaborator); if (it != m_vCollaborators.end()) { UT_DEBUGMSG(("Attempting to add buddy '%s' twice to a collaboration session!", pCollaborator->getDescription().utf8_str())); UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); return; } m_vCollaborators[pCollaborator] = ""; // will fill the remote document UUID later once we receive a packet from this buddy }
// should we move this to AbiCollab.cpp ? void AbiCollabSessionManager::updateAcl(AbiCollab* pSession, AccountHandler* pAccount, const std::vector<std::string> vAcl) { UT_return_if_fail(pSession); UT_return_if_fail(pAccount); // check if all current collaborators are still allowed to collaborate; if not, // then remove them from the session const std::map<BuddyPtr, std::string> collaborators = pSession->getCollaborators(); for (std::map<BuddyPtr, std::string>::const_iterator cit = collaborators.begin(); cit != collaborators.end(); cit++) { BuddyPtr pBuddy = (*cit).first; UT_continue_if_fail(pBuddy); AccountHandler* pBuddyAccount = pBuddy->getHandler(); UT_continue_if_fail(pBuddyAccount); UT_continue_if_fail(pBuddyAccount == pAccount); if (!pBuddyAccount->hasAccess(vAcl, pBuddy)) { // this current collaborator has been banned from the session, so // disconnect him UT_ASSERT_HARMLESS(UT_NOT_IMPLEMENTED); } } // set the new ACL on the account handler pAccount->setAcl(pSession, vAcl); // set the new access control list on the session pSession->setAcl(vAcl); }