Exemplo n.º 1
0
void TCPAccountHandler::addBuddy(BuddyPtr pBuddy)
{
	UT_DEBUGMSG(("TCPAccountHandler::addBuddy()\n"));
	UT_return_if_fail(pBuddy);
	
	AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager();
	UT_return_if_fail(pManager);
	
	if (getProperty("allow-all") == "true")
	{
		const UT_GenericVector<AbiCollab *> pSessions = pManager->getSessions();
		for (UT_sint32 i = 0; i < pSessions.size(); i++)
		{
			AbiCollab* pSession = pSessions.getNthItem(i);
			UT_continue_if_fail(pSession);
			
			if (pSession->getAclAccount() != this)
				continue;
			
			pSession->appendAcl(pBuddy->getDescriptor(false).utf8_str());
		}
	}
	
	AccountHandler::addBuddy(pBuddy);
}
// If the current document is already in session, and has buddies in its
// access control list, then the document can't be shared with buddies from
// other accounts. This function returns NULL if no buddies are in the
// current session's ACL, or the document is not shared yet. Otherwise, it
// returns the (only) handler that is allowed to share the document.
AccountHandler* AP_Dialog_CollaborationShare::_getShareableAccountHandler()
{
	AbiCollab* pSession = _getActiveSession();
	if (!pSession)
		return NULL;

	return pSession->getAclAccount();
}
std::vector<std::string> AP_Dialog_CollaborationShare::_getSessionACL()
{
	AbiCollab* pSession = _getActiveSession();
	if (!pSession)
		return std::vector<std::string>();

	AccountHandler* pAclAccount = pSession->getAclAccount();
	UT_return_val_if_fail(pAclAccount, std::vector<std::string>());

	std::vector<std::string> vAcl = pSession->getAcl();
	if (!pAclAccount->getAcl(pSession, vAcl))
	{
		UT_return_val_if_fail(false, vAcl); // TODO; this return is probably not correct
	}
	return vAcl;
}
Exemplo n.º 4
0
bool AbiCollabSessionManager::destroyAccount(AccountHandler* pHandler)
{
	UT_return_val_if_fail(pHandler, false);

	for (UT_uint32 i = 0; i < m_vecAccounts.size(); i++)
	{
		UT_continue_if_fail(m_vecAccounts[i]);
		
		if (pHandler == m_vecAccounts[i])
		{
			UT_DEBUGMSG(("Destroying account handler %s\n", pHandler->getDescription().utf8_str()));

			// TODO: if a number of buddies are connected, then we should ask for confirmation
			
			// drop all buddies that belong to the account that is being deleted
			// from all active sessions
			for (UT_sint32 j = 0; j < m_vecSessions.getItemCount(); j++)
			{
				AbiCollab* pSession = m_vecSessions.getNthItem(j); 
				UT_continue_if_fail(pSession);
				
				// There can only be buddies from 1 account in an active session these days/
				// That means that if this session's account is the account we are destroying,
				// then we can kill off the entire session. Do nothing otherwise.
				if (pSession->getAclAccount() == pHandler)
				{
					UT_DEBUGMSG(("Session %s is running on this account, destroying it!\n", pSession->getSessionId().utf8_str()));
					destroySession(pSession);
				}
			}

			m_vecAccounts.erase(m_vecAccounts.begin() + i, m_vecAccounts.begin() + i + 1);
			_deleteAccount(pHandler);
			return true;
		}
	}
	return false;
}