Example #1
0
void BuddyDeleteWindow::accept()
{
    QDialog::accept();

    for (auto const &buddy : BuddiesToDelete)
        deleteBuddy(buddy);
    m_buddyManager->ensureStored();
}
Example #2
0
void TCPAccountHandler::handleEvent(boost::shared_ptr<Session> session_ptr)
{
	UT_DEBUGMSG(("TCPAccountHandler::handleEvent()\n"));
	UT_return_if_fail(session_ptr);

	AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager();
	UT_return_if_fail(pManager);

	// make sure we have handled _all_ packets in the queue before checking
	// the disconnected status
	bool disconnected = !session_ptr->isConnected();
	_handleMessages(session_ptr);
	
	// check the connection status
	if (disconnected)
	{
		UT_DEBUGMSG(("Socket is not connected anymore!\n"));
		// drop all buddies that were on this connection
		std::map<TCPBuddyPtr, boost::shared_ptr<Session> >::iterator next;
		for (std::map<TCPBuddyPtr, boost::shared_ptr<Session> >::iterator it = m_clients.begin(); it != m_clients.end(); it = next)
		{
			next = it;
			next++;
		
			UT_continue_if_fail((*it).first);
			UT_continue_if_fail((*it).second);

			TCPBuddyPtr pB = (*it).first;
			
			if ((*it).second == session_ptr)
			{
				UT_DEBUGMSG(("Lost connection to %s buddy %s:%s\n", getProperty("server") == "" ? "client" : "server", pB->getAddress().c_str(), pB->getPort().c_str()));
				// drop this buddy from all sessions
				pManager->removeBuddy(pB, false);
				
				// erase the buddy <-> session mapping
				m_clients.erase(it);
				
				deleteBuddy(pB);
			}
		}

		// if we were connected to a server, then we are basically disconnected now
		if (getProperty("server") != "")
			disconnect();
	}

	// check other things here if needed...
}