Example #1
0
bool IMAccountList::update( IMAccount& imAccount )
{
	bool bUpdated = false;

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

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

	return bUpdated;
}
Example #2
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;
}
Example #3
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;
}
Example #4
0
bool IMAccountManager::updateIMAccount(const IMAccount & imAccount) 
{
	LOG_DEBUG("updating IMAccount");
	RecursiveMutex::ScopedLock lock(_mutex);

	bool result = false;

	IMAccount* pAcct = _imAccountList.findByAccount( imAccount );
	if ( pAcct )
	{
		*pAcct = imAccount;
		IMWrapperFactory::getFactory().imAccountUpdated(imAccount);
		imAccountUpdatedEvent(*this, imAccount.getKey());
		result = true;
	}

	return result;
}
Example #5
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);
	}
}
Example #6
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);
	}
}
Example #7
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);
	}
}
Example #8
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());
			}
		}
	}
}
Example #9
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);
	}
}
Example #10
0
bool IMAccountManager::removeIMAccount(const IMAccount & imAccount) 
{
	RecursiveMutex::ScopedLock lock(_mutex);

	bool result = false;

	//JRT - TODO: just Delete() and check result?
	IMAccount* pAcct = _imAccountList.findByAccount( imAccount );

	if ( pAcct )
	{
		// TODO: Hack. See IMWrapperFactory::removeIMAccount doc
		IMWrapperFactory::getFactory().removeIMAccount(imAccount);

		imAccountRemovedEvent(*this, imAccount.getKey() );
		_imAccountList.Delete( *pAcct );

		result = true;
	}

	return result;
}
Example #11
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;
}
Example #12
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);
			}
		}
	}
}
Example #13
0
void CommandServer::incomingRequestEventHandler(ServerSocket & sender, const std::string & connectionId, const std::string & data) 
{
	LOG_DEBUG("incoming request connectionId=" + connectionId + " data=" + data);
	String query = String(data);

	if (query == QueryStatus) 
	{
		//Find the phoneline status and answer
		UserProfile * userprofile = _wengoPhone.getUserProfileHandler().getCurrentUserProfile();
		if (userprofile) {
			IPhoneLine * phoneLine = userprofile->getActivePhoneLine();
			if (phoneLine && phoneLine->isConnected()) {
				_serverSocket->writeToClient(connectionId, QueryStatus + "|1");
			} else {
				_serverSocket->writeToClient(connectionId, QueryStatus + "|0");
			}
		}

	} 
	else if (query == QueryBringToFront) 
	{
		bringMainWindowToFrontEvent();
	} 
	else if (query.beginsWith(QueryCall)) 
	{
		//Extract the number from query & place the call
		StringList l = query.split("/");

		if (l.size() == 2) 
		{
			LOG_DEBUG("call peer=" + l[1]);
			UserProfile * userprofile = _wengoPhone.getUserProfileHandler().getCurrentUserProfile();
			if (userprofile) 
			{
				IPhoneLine * phoneLine = userprofile->getActivePhoneLine();
				if (phoneLine && phoneLine->isConnected()) 
				{
					phoneLine->makeCall(l[1]);
					_serverSocket->writeToClient(connectionId, data + "|1");
					return;
				}
			}
		}

		_serverSocket->writeToClient(connectionId, data + "|0");
	} 
	else if (query.beginsWith(QuerySms)) 
	{
		LOG_WARN("not yet implemented");

	} 
	else if (query.contains(QueryChat)) 
	{
		UserProfile * userProfile = _wengoPhone.getUserProfileHandler().getCurrentUserProfile();
		if (userProfile) 
		{
			IPhoneLine * phoneLine = userProfile->getActivePhoneLine();
			if (phoneLine && phoneLine->isConnected()) 
			{
				// extract the nickname from 1|o|chat/pseudo=value&sip=value
				StringList l = query.split("/");
				std::string nickname;
				if (l.size() == 2) 
				{
					int sepPos = l[1].find("&");
					nickname = l[1].substr(7, sepPos - 7);
				}
				////

				// get THE Wengo account
				IMAccountList imAccountList = userProfile->getIMAccountManager().getIMAccountsOfProtocol(EnumIMProtocol::IMProtocolWengo);
				////

				// create the IMContactSet
				IMAccount *imAccount = userProfile->getIMAccountManager().getIMAccount( imAccountList.begin()->second );	//VOXOX - JRT - 2009.04.24 
				IMContact imContact(*imAccount, nickname);
				IMContactSet imContactSet;
				imContactSet.insert(imContact);
				////

				// create the chat session
				std::string temp = "";
				ChatHandler & chatHandler = userProfile->getChatHandler();
				chatHandler.createSession(imAccount->getKey(), imContactSet, IMChat::Chat, temp );	//VOXOX - JRT - 2009.04.24
				////
				
				OWSAFE_DELETE(imAccount);
			}
		}
		// failed
		_serverSocket->writeToClient(connectionId, QueryChat + "|0");

	} else if (query.beginsWith(QueryAddContact)) {

		UserProfile * userProfile = _wengoPhone.getUserProfileHandler().getCurrentUserProfile();
		if (userProfile) {

			ContactInfo contactInfo;
			String tmp = query.substr(QueryAddContact.size(), query.size() - 1);

			StringList args = tmp.split("&");
			for (unsigned i = 0; i < args.size(); i++) {

				String tmp = args[i];
				if (!tmp.size()) {
					continue;
				}

				StringList list = tmp.split("=");
				if ((!(list.size() == 2)) || list[0].empty()) {
					continue;
				}

				// remove the first and the last quote if any
				String value = list[1];

				if (list[0] == NICKNAME_STR) {
					contactInfo.wengoName = value;
				} else if (list[0] == SIP_STR) {
					contactInfo.sip = value;
				} else if (list[0] == FIRSTNAME_STR) {
					contactInfo.firstname = value;
				} else if (list[0] == LASTNAME_STR) {
					contactInfo.lastname = value;
				} else if (list[0] == COUNTRY_STR) {
					contactInfo.country = value;
				} else if (list[0] == CITY_STR) {
					contactInfo.city = value;
				} else if (list[0] == STATE_STR) {
					contactInfo.state = value;
				} else if (list[0] == GROUP_STR) {
					contactInfo.group = value;
				} else if (list[0] == WDEALSERVICETITLE_STR) {
					contactInfo.wdealServiceTitle = value;
				} else if (list[0] == URL_STR) {
					if (value.beginsWith("\"")) {
						value = value.substr(1, value.size() - 2);
					}
					contactInfo.website = value;
				}
			}

			showAddContactEvent(contactInfo);
		}

	} else {

		Config & config = ConfigManager::getInstance().getCurrentConfig();

		//"emulate" a http server. Needed for Flash sockets
		std::string tmp = "<?xml version=\"1.0\"?>\n"
			"<!DOCTYPE cross-domain-policy SYSTEM \"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\">\n"
			"<cross-domain-policy>\n";
		StringList domains = config.getCmdServerAuthorizedDomains();
		StringList::const_iterator it = domains.begin(), end = domains.end();
		for (;it!=end; ++it) {
			tmp += "<allow-access-from domain=\"" + *it + "\" to-ports=\"*\" />\n";
		}
		tmp += "<allow-access-from domain=\"localhost\" to-ports=\"*\" />\n"
				"</cross-domain-policy>";
		_serverSocket->writeToClient(connectionId, buildHttpForFlash(tmp));
	}
}