Ejemplo n.º 1
0
void PhoneLineStateTimeout::execute(IPhoneLine & phoneLine) {
	phoneLine.getSipAccount().setConnected(false);

	// Restart connection.
	phoneLine.disconnect(true);
	phoneLine.connect();
}
Ejemplo n.º 2
0
PhoneCall * WenboxPlugin::getActivePhoneCall() const {
	IPhoneLine * phoneLine = _userProfile.getActivePhoneLine();
	PhoneCall * phoneCall = NULL;
	if (phoneLine) {
		phoneCall = phoneLine->getActivePhoneCall();
	}
	return phoneCall;
}
Ejemplo n.º 3
0
PhoneCall * CUserProfile::getActivePhoneCall() const 
{
	PhoneCall * result = NULL;

	//FIXME: model must not be used directly by the GUI
	IPhoneLine * phoneLine = _userProfile.getActivePhoneLine();
	if (phoneLine) {
		result = phoneLine->getActivePhoneCall();
	}

	return result;
}
Ejemplo n.º 4
0
void DtmfTheme::playTone(const std::string & key) const {

	const Tone * tone = getTone(key);
	if (!tone) {
		LOG_WARN("Could not find a tone for key '" + key + "'");
		return;
	}

	Config & config = ConfigManager::getInstance().getCurrentConfig();
	std::string soundfile = _repertory + tone->getSoundFile();

	if (tone->getLocalAction() == Tone::Play) {
		Sound::play(File::convertPathSeparators(soundfile),
					config.getAudioRingerDeviceId()
		);
	}

	if (tone->getRemoteAction() == Tone::Play) {
		UserProfile * userprofile =
			_wengoPhone.getUserProfileHandler().getCurrentUserProfile();
		if (userprofile) {
			IPhoneLine * iphoneline = userprofile->getActivePhoneLine();
			if (iphoneline) {
				PhoneCall * phonecall = iphoneline->getActivePhoneCall();
				if (phonecall) {
					
					if (tone->getAudioFormat() == Tone::Dtmf) {
						iphoneline->playDtmf(
							phonecall->getCallId(),
							(char)tone->getKey()[0]
						);
					} else {
						iphoneline->playSoundFile(
							phonecall->getCallId(),
							File::convertPathSeparators(soundfile)
						);
					}
				}
			}
		}
	}
}
Ejemplo n.º 5
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));
	}
}