示例#1
0
void IMContactListHandler::imAccountAddedEventHandler(IMAccountManager & sender, std::string imAccountId) 
{
	IMAccount * imAccount = _userProfile.getIMAccountManager().getIMAccount(imAccountId);

	if (imAccount) 
	{
		IMContactListMap::iterator it = _imContactListMap.find(imAccountId);

		if (it == _imContactListMap.end()) 
		{
			IMContactList * imContactList = IMWrapperFactory::getFactory().createIMContactList(*imAccount);
			if (imContactList) 
			{
				imContactList->newContactAddedEvent		 += boost::bind(&IMContactListHandler::newContactAddedEventHandler,		 this, _1, _2, _3);
				imContactList->contactRemovedEvent		 += boost::bind(&IMContactListHandler::contactRemovedEventHandler,		 this, _1, _2, _3);
				imContactList->contactMovedEvent		 += boost::bind(&IMContactListHandler::contactMovedEventHandler,		 this, _1, _2, _3);
				imContactList->newContactGroupAddedEvent += boost::bind(&IMContactListHandler::newContactGroupAddedEventHandler, this, _1, _2);
				imContactList->contactGroupRemovedEvent  += boost::bind(&IMContactListHandler::contactGroupRemovedEventHandler,  this, _1, _2);

				imContactList->setInitialLoadEvent		 += boost::bind(&IMContactListHandler::setInitialLoadEventHandler,		 this, _1, _2);

				_imContactListMap.insert(std::pair<std::string, IMContactList *>(imAccountId, imContactList));
			} 
			else 
			{
				LOG_DEBUG("cannot create an IMContactList");
			}
		} 
		else 
		{
			LOG_ERROR("this IMAccount has already been added " + imAccount->getLogin());
		}
		OWSAFE_DELETE(imAccount);
	}
}
示例#2
0
void ConnectHandler::connect(const std::string & imAccountId) {
	RecursiveMutex::ScopedLock lock(_mutex);

	Connect * connect = NULL;
	IMAccount * imAccount = _userProfile->getIMAccountManager().getIMAccount(imAccountId);

	if (imAccount) {
		ConnectMap::iterator it = _connectMap.find(imAccountId);
		if (it == _connectMap.end()) {
			connect = new Connect(*imAccount, *_userProfile);

			connect->connectedEvent			 += boost::bind(&ConnectHandler::connectedEventHandler,			 this, _1);
			connect->disconnectedEvent		 += boost::bind(&ConnectHandler::disconnectedEventHandler,		 this, _1, _2, _3, _4);	//VOXOX - JRT - 2009.07.13 
			connect->connectionProgressEvent +=	boost::bind(&ConnectHandler::connectionProgressEventHandler, this, _1, _2, _3, _4);

			_connectMap.insert(std::pair<std::string, Connect*>(imAccountId, connect));
		} else {
			connect = (*it).second;
		}
		
		if (!(imAccount->isConnected())) {
			connect->connect();
		}		
		
		OWSAFE_DELETE(imAccount);
	} else {
		LOG_ERROR("IMAccount " + imAccountId + " not found!");
	}
}
示例#3
0
void WsAccount::parseSet( TiXmlNode* syncNode, IMAccountList& imAccountList )
{
	TiXmlNode*  networkNode = NULL;

	IMAccount imAccount;
	_userProfile.initImAccountParameters( &imAccount );

	IMAccountXMLSerializer serializer( imAccount );
	TiXmlHandle h(syncNode);
	serializer.unserializeWebService(h, imAccount.getIMAccountParameters() );

	//VOXOX - JRT - 2009.06.02  we currently get empty node if no UserNetworks exist on server.
	if ( imAccount.getProtocol() != EnumIMProtocol::IMProtocolUnknown )
	{
		//VOXOX - JRT - 2009.07.13 - HACK to remove old voxox domain accounts.
		if ( !imAccount.isOldVoxOxDomain() )	//Just throw this away.
		{
			imAccountList.Add( &imAccount );
		}
	}
	else
	{
		int xxx = 1;	//TODO: we get here is network already exists and was 'saved' with NID == 0.
	}
}
示例#4
0
void PurpleContactListMngr::UpdateIMContactList(IMAccount &account) {
	RecursiveMutex::ScopedLock lock(_mutex);

	PurpleIMContactListIterator i;
	for (i = _purpleIMContactListList.begin(); i != _purpleIMContactListList.end(); i++)
	{
		if (PurpleIMFactory::equals((*i)->getIMAccount(), account.getLogin(), account.getProtocol()))
		{
			(*i)->setIMAccount(account);
			break;
		}
	}
}
示例#5
0
void GaimPresenceMngr::UpdateIMPresence(IMAccount &account) {
	RecursiveMutex::ScopedLock lock(_mutex);

	GaimIMPresenceIterator it;
	for (it = _gaimIMPresenceList.begin(); it != _gaimIMPresenceList.end(); it++)
	{
		if (GaimIMFactory::equals((*it)->getIMAccount(), account.getLogin(), account.getProtocol()))
		{
			(*it)->setIMAccount(account);
			break;
		}
	}
}
示例#6
0
void GaimChatMngr::UpdateIMChat(IMAccount &account)
{
	RecursiveMutex::ScopedLock lock(_mutex);

	GaimIMChatIterator i;
	for (i = _gaimIMChatList.begin(); i != _gaimIMChatList.end(); i++)
	{
		if (GaimIMFactory::equals((*i)->getIMAccount(), account.getLogin(), account.getProtocol()))
		{
			(*i)->setIMAccount(account);
			break;
		}
	}
}
示例#7
0
IMAccount* IMAccountList::findByKeyAndClone( const std::string& imAccountId )
{
	RecursiveMutex::ScopedLock lock( _mutex );	//VOXOX - JRT - 2009.07.13 

	IMAccount* result = NULL;
	IMAccount* temp = findByKey( imAccountId );

	if ( temp )
	{
		result = temp->clone();		//VOXOX - JRT - 2009.04.10 - TODO - Seems unnecessary to clone this,
	}								//				but it is called in about 180 places in the code!

	return result;
}
示例#8
0
IMAccount * IMAccountManager::getIMAccount( const IMAccount& imAccount ) 
{
	RecursiveMutex::ScopedLock lock(_mutex);

	IMAccount* result = NULL;
	IMAccount* temp = _imAccountList.findByAccount( imAccount );

	if ( temp )
	{
		result = temp->clone();		//VOXOX - JRT - 2009.04.10 - TODO - Seems unnecessary to clone this,
	}								//				but it is called in about 180 places in the code!

	return result;
}
示例#9
0
void PurpleChatMngr::RemoveIMChat(IMAccount &account)
{
	RecursiveMutex::ScopedLock lock(_mutex);

	PurpleIMChatIterator i;
	for (i = _purpleIMChatList.begin(); i != _purpleIMChatList.end(); i++)
	{
		if (PurpleIMFactory::equals((*i)->getIMAccount(), account.getLogin(), account.getProtocol()))
		{
			_purpleIMChatList.erase(i);
			break;
		}
	}
}
示例#10
0
bool IMAccountManager::setImAccountUserSelectedPresenceState( const IMAccount & imAccount )
{
	RecursiveMutex::ScopedLock lock(_mutex);

	bool result = false;
	IMAccount* pAcct = _imAccountList.findByAccount( imAccount );

	if ( pAcct )
	{
		pAcct->updateInitialPresenceState( imAccount.getInitialPresenceState() );
		result = true;
	}

	return result;
}
示例#11
0
bool IMAccountManager::setImAccountUserNetworkId( const IMAccount & imAccount )
{
	RecursiveMutex::ScopedLock lock(_mutex);

	bool result = false;
	IMAccount* pAcct = _imAccountList.findByAccount( imAccount );

	if ( pAcct )
	{
		pAcct->setUserNetworkId( imAccount.getUserNetworkId() );
		result = true;
	}

	return result;
}
示例#12
0
//VOXOX CHANGE CJC ADD FRIEND FROM MYSPACE SERVER
void MultiIMFactory::importContactsFromMySpaceServer(IMAccount imAccount) 
{ 
	if (imAccount.getProtocol() == EnumIMProtocol::IMProtocolMYSPACE)
	{ 
		//This only apply for myspace protocols
		return _purpleIMFactory.importContactsFromMySpaceServer(imAccount);
	}
}
示例#13
0
void WsAccount::parseGet( TiXmlNode* syncNode, IMAccountList& imAccountList )
{
	TiXmlNode* networkNode = syncNode->FirstChild( "NTWK" );

	if ( networkNode )
	{
		std::string nodeData = "";
		nodeData << *networkNode;
	
		IMAccount imAccount;
		_userProfile.initImAccountParameters( &imAccount );

		IMAccountListXMLSerializer serializer( const_cast<IMAccountList&>(imAccountList));
		TiXmlHandle h(networkNode);
		serializer.unserializeWebService(h, imAccount.getIMAccountParameters() );
	}
}
示例#14
0
void GaimConnectMngr::RemoveIMConnect(IMAccount &account)
{
	RecursiveMutex::ScopedLock lock(_mutex);

	GaimIMConnectIterator i;

	if (account.getLogin().empty())
		return;

	for (i = _gaimIMConnectList.begin(); i != _gaimIMConnectList.end(); i++)
	{
		if (GaimIMFactory::equals((*i)->getIMAccount(), account.getLogin(), account.getProtocol()))
		{
			_gaimIMConnectList.erase(i);
			break;
		}
	}
}
示例#15
0
void IMContactListHandler::imAccountRemovedEventHandler(IMAccountManager & sender, std::string imAccountId) 
{
	IMAccount * imAccount = _userProfile.getIMAccountManager().getIMAccount(imAccountId);
	if (imAccount) 
	{
		IMContactListMap::iterator it = _imContactListMap.find(imAccount->getKey());
		if (it != _imContactListMap.end()) 
		{
			delete (*it).second;
			_imContactListMap.erase(it);
		} 
		else 
		{
			LOG_ERROR("this IMAccount has not been added " + imAccount->getLogin());
		}
		OWSAFE_DELETE(imAccount);
	}
}
示例#16
0
void CUserProfile::updateContactThreadSafe(const ContactProfile contactProfile) 
{
	//We need to get the ServerProtocolId or UserNetworkId for the IMAccount.
	IMContact* imContact = contactProfile.getPreferredIMContact();

	if ( imContact )
	{
		IMAccount* imAccount = getUserProfile().getIMAccountManager().getIMAccount( imContact->getIMAccount()->getKey() );

		if ( imAccount )
		{
			imContact->setServerProtocolId( imAccount->getServerProtocolId() );
			imContact->setUserNetworkId   ( imAccount->getUserNetworkId()    );	//VOXOX - JRT - 2009.06.09 

			getCContactList().updateContact(contactProfile);		//This does the update.
		}
	}
}
示例#17
0
void ConnectHandler::connectionIsDownEventHandlerThreadSafe() {
	RecursiveMutex::ScopedLock lock(_mutex);

	for (ConnectMap::const_iterator it = _connectMap.begin();
		it != _connectMap.end();
		++it) {

		IMAccount * imAccount = _userProfile->getIMAccountManager().getIMAccount((*it).first);
		if (imAccount) {
			if (imAccount->isConnected()) {
				(*it).second->disconnect(true);
			}
			OWSAFE_DELETE(imAccount);
		} else {
			LOG_ERROR("IMAccount " + (*it).first + " not found!");
		}
	}
}
示例#18
0
void IMContactListHandler::addIMContact(const std::string & groupName, const IMContact & imContact) 
{
	//VOXOX - JRT - 2009.09.21 - We have two CRs here that indicate imContact::imAccount is NULL.  They both occurred
	//							 for same user on same date.  Let's just keep an eye on it.
	IMAccount * imAccount = _userProfile.getIMAccountManager().getIMAccount(*(const_cast<IMContact&>(imContact).getIMAccount()));
	if (imAccount) {
		IMContactListMap::iterator it = _imContactListMap.find(imAccount->getKey());

		if (it != _imContactListMap.end()) 
		{
			(*it).second->addContact(groupName, imContact.getContactId());
		} 
		else 
		{
			LOG_DEBUG("this IMAccount is not registered: " + imAccount->getLogin());
		}
		OWSAFE_DELETE(imAccount);
	}
}
示例#19
0
void IMContactListHandler::moveContactToGroup(const std::string & newGroupName, const std::string & oldGroupName, const IMContact & imContact) 
{
	IMAccount * imAccount = _userProfile.getIMAccountManager().getIMAccount(imContact.getIMAccountId());

	if (imAccount) 
	{
		IMContactListMap::iterator it = _imContactListMap.find(imAccount->getKey());
		if (it != _imContactListMap.end()) 
		{
			//Update servers via PurpleIMContactList::moveContactToGroup()
			(*it).second->moveContactToGroup(newGroupName, oldGroupName, imContact.getContactId());
		} 
		else 
		{
			LOG_DEBUG("this IMAccount is not registered: "  + imAccount->getLogin());
		}
		OWSAFE_DELETE(imAccount);
	}
}
示例#20
0
//VOXOX CHANGE by Rolando - 2009.08.28 
void IMAccountManager::updateIMAccountLogin(std::string newLogin, IMAccount * imAccount){
	RecursiveMutex::ScopedLock lock(_mutex);

	if ( _imAccountList.contains( *imAccount ) )
	{
		IMAccount * newIMAccount = getIMAccount(*imAccount);
		if(newIMAccount)
		{
			newIMAccount->changeLogin(newLogin);
			IMAccountList::iterator iter = _imAccountList.find(imAccount->getKey() );

			if(iter != _imAccountList.end())
			{
				_imAccountList.Delete(iter->second);
				_imAccountList.Add(const_cast<IMAccount&>(*newIMAccount));
				imAccountUpdatedEvent(*this, newIMAccount->getKey());
			}
		}
	}
}
示例#21
0
void MultiIMFactory::removeIMAccount(IMAccount imAccount) 
{ 
	if (EnumIMProtocol::isSip( imAccount.getProtocol() ) )
	{
		return _phApiFactory.removeIMAccount(imAccount); 
	} 
	else 
	{ 
		return _purpleIMFactory.removeIMAccount(imAccount);
	}
}
示例#22
0
void IMContactListHandler::removeIMContact(const std::string & groupName, const IMContact & imContact) 
{
	IMAccount * imAccount = _userProfile.getIMAccountManager().getIMAccount( *(const_cast<IMContact&>(imContact).getIMAccount()) );
	if (imAccount) 
	{
		IMContactListMap::iterator it = _imContactListMap.find(imAccount->getKey());

		if (it != _imContactListMap.end()) 
		{
			//VOXOX - JRT - 2009.08.09 - In libpurple, this just removes the IMContact from the Group.
			//							 If there are no more groups for this IMContact, then the contact is removed from buddy list.
			(*it).second->removeContact(groupName, imContact.getContactId());
		} 
		else 
		{
			LOG_DEBUG("this IMAccount is not registered: " + imAccount->getLogin());
		}
		OWSAFE_DELETE(imAccount);
	}
}
示例#23
0
void ConnectHandler::connectionIsUpEventHandlerThreadSafe() {
	RecursiveMutex::ScopedLock lock(_mutex);

	for (ConnectMap::const_iterator it = _connectMap.begin();
		it != _connectMap.end();
		++it) {

		IMAccount * imAccount = _userProfile->getIMAccountManager().getIMAccount((*it).first);
		if (imAccount) {
			if (!imAccount->isConnected()) {
				(*it).second->connect();
			}
			OWSAFE_DELETE(imAccount);
		} else {
			LOG_ERROR("IMAccount " + (*it).first + " not found!");
		}
	}
	//VOXOX CHANGE CJC CONNECT IM ACCOUNTS< AFTER CONNECTIONS IS RESTORED< THIS IS NOT HAPPENING
	_userProfile->connect();
}
示例#24
0
void ConnectHandler::disconnectedEventHandlerThreadSafe(std::string imAccountId, bool connectionError, std::string reason, bool fatal)	//VOXOX - JRT - 2009.07.13 
{
	if (_userProfile && !_freeze)	//VOXOX - JRT - 2009.07.11 - potential crash fix.
	{
		IMAccount * imAccount = _userProfile->getIMAccountManager().getIMAccount(imAccountId);
		if (imAccount) 
		{
			LOG_INFO( "Disconnect Reason: " + reason + ", " + imAccountId );

			imAccount->setConnected(false);

			//Some reasons indicate we should not automatically retry.	//VOXOX - JRT - 2009.07.05 
//			bool retry = QtEnumIMProtocolMap::shouldRetryConnect( imAccount->getQtProtocol(), reason );
			imAccount->setAutoReconnect( !fatal );

			_userProfile->updateIMAccount(*imAccount);
			OWSAFE_DELETE(imAccount);
			disconnectedEvent(*this, imAccountId, connectionError, reason);
		}
	}
}
示例#25
0
int PurpleChatMngr::HandleChatInvite( PurpleAccount *gAccount, const char *who, const char* name, const char *message, void *data )
{
	int result = 0;

	const char*		gPrclId = purple_account_get_protocol_id(gAccount);
	IMAccount*		account = _accountMngr->FindIMAccount(purple_account_get_username(gAccount), PurpleIMPrcl::GetEnumIMProtocol(gPrclId));
	PurpleIMChat*	pImChat	= FindIMChat(*account);
		
	if ( pImChat )
	{
		GroupChatInfo gcInfo( true, who, name, message );

		gcInfo.setAccountId( account->getKey() );

		pImChat->getGroupChatInfo() = gcInfo;						//VOXOX - JRT - 2009.10.06 
		pImChat->incomingGroupChatInviteEvent(*pImChat, gcInfo );	//VOXOX - JRT - 2009.10.06 

		result = (gcInfo.acceptedInvite() ? 1 : -1 );
	}

	return result;
}
示例#26
0
void PurpleChatMngr::ChatRemoveUsersCbk(PurpleConversation *conv, GList *users)
{
	GList *l;
	PurpleAccount *gAccount = purple_conversation_get_account(conv);
	const char *gPrclId = purple_account_get_protocol_id(gAccount);
	IMAccount *account = _accountMngr->FindIMAccount(purple_account_get_username(gAccount), PurpleIMPrcl::GetEnumIMProtocol(gPrclId));
	mConvInfo_t *mConv = NULL;
	IMChatSession *chatSession = NULL;
	PurpleIMChat *mChat = FindIMChat(*account);

	if (!mChat)
		LOG_FATAL("Can't find IMChat !");

	mConv		= (mConvInfo_t *) conv->ui_data;
	chatSession = mConv->conv_session;		//VOXOX - JRT - 2009.07.09 

	for (l = users; l != NULL; l = l->next)
	{
		if (strcmp(purple_account_get_username(gAccount), (char *) l->data))
		{
			std::string buddy((char *) l->data);
			IMContact imContact(*account, buddy);

			IMContact* imContact2 = chatSession->getIMContactSet().findBy( account->getKey(), buddy );

//			if (chatSession->getIMContactSet().find(imContact) == chatSession->getIMContactSet().end())
			if ( imContact2 == NULL )
			{
				LOG_ERROR("IMContact for " + imContact.getContactId() + " not in IMContactSet");
			}
			else
			{
				LOG_DEBUG("IMContact " + imContact.getContactId() + " removed from IMContactSet");
				mChat->contactRemovedEvent(*mChat, *chatSession, buddy);
			}
		}
	}
}
示例#27
0
bool IMAccountList::update( IMAccount& imAccount )
{
	bool bUpdated = false;

	IMAccount* pAccount = Lookup( imAccount.getKey() );

	if( pAccount )
	{
		*pAccount = imAccount;
		bUpdated  = true;
	}

	return bUpdated;
}
示例#28
0
void ConnectHandler::connectedEventHandlerThreadSafe(std::string imAccountId, EnumPresenceState::PresenceState initialPresenceState ) 
{
	if (_userProfile && !_freeze) 
	{
		IMAccount * imAccount = _userProfile->getIMAccountManager().getIMAccount(imAccountId);
		if (imAccount) 
		{
			imAccount->setConnected(true);
			imAccount->setPresenceState( initialPresenceState );	//VOXOX - JRT - 2009.09.10 

			//VOXOX - JRT - 2009.09.14 - We now set the initialPresence before we try to connect.
			////TODO: VOXOX CHANGE by Rolando - 2009.05.22 - FIX this: check if each network associated supports invisible presence
			//if(_userProfile->mustLoginInvisible() && imAccount->getProtocol() != EnumIMProtocol::IMProtocolWengo && imAccount->getProtocol() != EnumIMProtocol::IMProtocolSIP)
			//{
			//	//VOXOX CHANGE by Rolando - 2009.05.22 - because user can login as invisible presence we have to change here the presence to be able to do change it
			//	//TODO: Find a way to be able to change the presence to invisible before set connected the imaccount to "true"
			//	//this is provocating that others users can realize that user logged in and later "logged off" 
			//	imAccount->setPresenceState(EnumPresenceState::PresenceStateInvisible);
			//	_userProfile->setPresenceState(EnumPresenceState::PresenceStateInvisible, imAccountId);//VOXOX CHANGE by Rolando - 2009.05.15 
			//}

			EnumPresenceState::PresenceState presenceState = imAccount->getPresenceState();//VOXOX CHANGE by Rolando - 2009.07.15 
			EnumIMProtocol::IMProtocol imProtocol = imAccount->getProtocol();//VOXOX CHANGE by Rolando - 2009.07.15 

			_userProfile->updateIMAccount(*imAccount);
			_userProfile->requestSyncData(*imAccount);	//VOXOX - JRT - 2009.08.03 
			OWSAFE_DELETE(imAccount);			
			connectedEvent(*this, imAccountId);//VOXOX CHANGE by Rolando - 2009.05.15 

			//VOXOX CHANGE by Rolando - 2009.07.15 
			if( QtEnumIMProtocolMap::supportsPresence( imProtocol ) )	//VOXOX - JRT - 2009.08.28 - moved logic to QtEnumIMProtocol 
			{
				_userProfile->setPresenceState(presenceState, imAccountId, false, String::null );//VOXOX CHANGE by Rolando - 2009.07.15 //VOXOX - JRT - 2009.09.14 
			}
		}
	}
}
示例#29
0
bool IMAccountManager::addIMAccount(const IMAccount & imAccount) 
{
	RecursiveMutex::ScopedLock lock(_mutex);

	bool result = false;

	IMAccount* pAcct = _imAccountList.findByAccount( imAccount );
	if ( pAcct == NULL )
	{
		_imAccountList.Add( const_cast<IMAccount&>(imAccount) );
		imAccountAddedEvent(*this, imAccount.getKey() );
		result = true;
	}

	return result;
}
示例#30
0
bool IMAccountManager::addFriendsFromMySpace(const IMAccount & imAccount) 
{
	RecursiveMutex::ScopedLock lock(_mutex);

	bool result = false;

	if ( _imAccountList.contains( imAccount ) )
	{
		IMWrapperFactory::getFactory().importContactsFromMySpaceServer(imAccount);

		imAccountUpdatedEvent(*this, imAccount.getKey());

		result = true;
	}

	return result;
}