Exemplo n.º 1
0
bool ConfigImporter::importContactsFromV1toV3(const string & fromDir, UserProfile & userProfile) {
	File mDir(fromDir);
	StringList fileList = mDir.getFileList();
	ContactList & contactList = userProfile.getContactList();

	ContactGroup contactGroup( "Classic", EnumGroupType::GroupType_User);	//JRT-GRPS
	contactList.addContactGroup( contactGroup );	///VOXOX - JRT - 2009.05.07 - JRT-GRPS

	IMAccountList imAccountList =
		userProfile.getIMAccountManager().getIMAccountsOfProtocol(EnumIMProtocol::IMProtocolWengo);

	if (!imAccountList.size()) {
		return false;
	}

	for (unsigned i = 0; i < fileList.size(); i++) {
		File mFile(fromDir + fileList[i]);
		string Id = fileList[i].substr(0, fileList[i].find("_", 0));
		vcard_t mVcard;

		initVcard(&mVcard);
		if (!mFile.getExtension().compare("vcf")) {
			if (classicVcardParser(fromDir + fileList[i], &mVcard) == false) {
				continue;
			}

			int extPos = fileList[i].find_last_of('.');
			string fileWoExt = fileList[i].substr(0, extPos + 1);
			classicXMLParser(fromDir + fileWoExt + "xml", &mVcard);

//			IMContact imContact(*imAccountList.begin(), mVcard.id);	//VOXOX - JRT - 2009.04.09 
			IMContact imContact(imAccountList.begin()->second, mVcard.id);
			
			//VOXOX - JRT - 2009.04.26 
//			Contact & contact = contactList.createContact();
//			contact.setGroupId(contactList.getContactGroupIdFromName("Classic"));
//			addContactDetails(contact, &mVcard);
//			contact.addIMContact(imContact);

			Contact* contact = contactList.createContact();
//			contact->setGroupId(contactList.getContactGroupIdFromName("Classic"));
			contact->addToGroup(contactList.getContactGroupIdFromName("Classic"), EnumGroupType::GroupType_User);	//VOXOX - JRT - 2009.05.06 JRT-GRPS
			addContactDetails(*contact, &mVcard);
			contact->addIMContact(imContact);
			contactList.addContact( contact );	//ContactList will delete contact
			//End Voxox
		}
	}
	return true;
}
Exemplo n.º 2
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));
	}
}
Exemplo n.º 3
0
IMContactListHandler::IMContactListHandler(UserProfile & userProfile) 
	: _userProfile(userProfile) 
{
	userProfile.getIMAccountManager().imAccountAddedEvent   += boost::bind(&IMContactListHandler::imAccountAddedEventHandler,   this, _1, _2);
	userProfile.getIMAccountManager().imAccountRemovedEvent += boost::bind(&IMContactListHandler::imAccountRemovedEventHandler, this, _1, _2);
}