⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sipsoftphoneconfiguration.cxx

📁 MiniSip Client with DomainKeys Authentication, Sip, Audio communications, Echo Cancel
💻 CXX
📖 第 1 页 / 共 2 页
字号:
		MRef<SipIdentity*> ident= new SipIdentity();		ident->setIdentityName(account);		if( ii == 0 ){			inherited->sipIdentity = ident;		}		ii++;		string uri = backend->loadString(accountPath + "sip_uri");		ident->setSipUri(uri);				bool autodetect = ( backend->loadString(accountPath + "auto_detect_proxy","no") == "yes" );				//these two values we collect them, but if autodetect is true, they are not used		string proxy = backend->loadString(accountPath + "proxy_addr","");		if( proxy == "" ) {			#ifdef DEBUG_OUTPUT			cerr << "SipSoftPhoneConfig::load - empty proxy address ... setting autodetect = true " << endl;			#endif			autodetect = true; //empty proxy .. then autodetect ... just doing some checks ...		}		uint16_t proxyPort = (uint16_t)backend->loadInt(accountPath +"proxy_port", 5060);		ident->setDoRegister(backend->loadString(accountPath + "register","")=="yes");				string preferredTransport = backend->loadString(accountPath +"transport", "UDP");				string proxret = ident->setSipProxy( autodetect, uri,  preferredTransport, proxy, proxyPort );				if( proxret != "" ) {			ret += "\n" + proxret ;			#ifdef DEBUG_OUTPUT			cerr << "SipSoftConfig::load - Identity::setSipProxy return = " << proxret << endl;			#endif		}				string proxyUser = backend->loadString(accountPath +"proxy_username", "");		ident->getSipProxy()->sipProxyUsername = proxyUser;		string proxyPass = backend->loadString(accountPath +"proxy_password", "");		ident->getSipProxy()->sipProxyPassword = proxyPass;		string registerExpires = backend->loadString(accountPath +"register_expires", "");		if (registerExpires != ""){			ident->getSipProxy()->setRegisterExpires( registerExpires );			//set the default value ... do not change this value anymore			ident->getSipProxy()->setDefaultExpires( registerExpires ); 		} #ifdef DEBUG_OUTPUT		else {			//cerr << "CESC: SipSoftPhoneConf::load : NO ident expires" << endl;		}		//cerr << "CESC: SipSoftPhoneConf::load : ident expires every (seconds) " << ident->getSipProxy()->getRegisterExpires() << endl;		//cerr << "CESC: SipSoftPhoneConf::load : ident expires every (seconds) [default] " << ident->getSipProxy()->getDefaultExpires() << endl;#endif		if (backend->loadString(accountPath + "pstn_account","")=="yes"){			pstnIdentity = ident;			usePSTNProxy = true;			ident->securitySupport = false;		}		if (backend->loadString(accountPath + "default_account","")=="yes"){			inherited->sipIdentity = ident;		}		identities.push_back(ident);	}while( true );	tcp_server = backend->loadString("tcp_server", "yes") == "yes";	tls_server = backend->loadString("tls_server", "no") == "yes";	soundDevice =  backend->loadString("sound_device","");		soundIOmixerType = backend->loadString("mixer_type", "spatial");// 	cerr << "sipconfigfile : soundiomixertype = " << soundIOmixerType << endl << endl;	//Load the startup commands ... there may be more than one	//cmd entry may not contain white spaces (anything after the space is considered	// 	as a param	//params list is a white space separated list of parameters:	//Ex.	//	call user@domain	//	im user@domain message (the message is the last param, and may contain spaces)	ii = 0;	do{		string cmdActionsPath = string("startup_cmd[")+itoa(ii)+"]/";		string cmd = backend->loadString(cmdActionsPath + "command");		if( cmd == "" ) {			break;		}		string params = backend->loadString(cmdActionsPath + "params");		startupActions.push_back( cmd + " " + params );// 		cerr << "CONFIG: startup command: " << cmd << " " << params << endl;		ii++;	}while( true );	#ifdef VIDEO_SUPPORT	videoDevice = backend->loadString( "video_device", "" );	cerr << "Loaded video_device" << videoDevice << endl;	frameWidth = backend->loadInt( "frame_width", 176 );	frameHeight = backend->loadInt( "frame_height", 144 );#endif	useSTUN = backend->loadString("use_stun","no")=="yes";	findStunServerFromSipUri = backend->loadString("stun_server_autodetect","no")==string("yes");	findStunServerFromDomain = backend->loadString("stun_server_domain","")!="";	stunDomain = backend->loadString("stun_server_domain","");	useUserDefinedStunServer = backend->loadString("stun_manual_server","")!="";	userDefinedStunServer = backend->loadString("stun_manual_server","");	phonebooks.clear();	int i=0;	string s;	do{		s = backend->loadString("phonebook["+itoa(i)+"]","");		if (s!=""){			MRef<PhoneBook *> pb;			if (s.substr(0,7)=="file://"){				pb = PhoneBook::create(new MXmlPhoneBookIo(s.substr(7)));			}			// FIXME http and other cases should go here			if( !pb.isNull() ){				phonebooks.push_back(pb);			} else{				merr << "Could not open the phonebook " << end;			}		}		i++;	}while(s!="");	ringtone = backend->loadString("ringtone","");	inherited->localUdpPort = backend->loadInt("local_udp_port",5060);	inherited->externalContactUdpPort = inherited->localUdpPort; //?	inherited->localTcpPort = backend->loadInt("local_tcp_port",5060);	inherited->localTlsPort = backend->loadInt("local_tls_port",5061);	inherited->autoAnswer = backend->loadString("auto_answer", "no") == "yes";	securityConfig.load( backend );	// FIXME: per identity security	if( inherited->sipIdentity){		inherited->sipIdentity->securitySupport = securityConfig.secured;	}	audioCodecs.clear();	int iCodec = 0;	string codec = backend->loadString("codec["+ itoa( iCodec ) + "]","");	while( codec != "" && iCodec < 256 ){		audioCodecs.push_back( codec );		codec = backend->loadString("codec["+ itoa( ++iCodec ) +"]","");	}	if( audioCodecs.size() == 0 ) { //MEEC!! Error!		//This is an error. It can happen, for example, if someone manually		//edited the .minisip.conf file, or if it is using an older version		mout << "ERROR! ********************************************" << end 			<< "***  No codec was found in the .minisip.conf configuration file" << end 			<< "***  Adding default G.711 ..." << end			<< "ERROR! ********************************************" << end;		audioCodecs.push_back( "G.711" );		be->save( "codec[0]", "G.711" ); //save the changes ... 	}	//add code to load the default network interface	//<network_interface> into networkInterfaceName	networkInterfaceName = backend->loadString("network_interface", "");		return ret;}void SipSoftPhoneConfiguration::saveDefault( MRef<ConfBackend *> be ){	//be->save( "version", CONFIG_FILE_VERSION_REQUIRED_STR );	be->save( "version", CONFIG_FILE_VERSION_REQUIRED );	#ifdef WIN32	be->save( "network_interface", "{12345678-1234-1234-12345678}" );#else	be->save( "network_interface", "eth0" );#endif		be->save( "account[0]/account_name", "My account" );	be->save( "account[0]/sip_uri", "username@domain.example" );	be->save( "account[0]/proxy_addr", "sip.domain.example" );	be->save( "account[0]/register", "yes" );	be->save( "account[0]/proxy_port", 5060 );	be->save( "account[0]/proxy_username", "user" );	be->save( "account[0]/proxy_password", "password" );	be->save( "account[0]/pstn_account", "no" );	be->save( "account[0]/default_account", "yes" );		be->save( "tcp_server", "yes" );	be->save( "tls_server", "no" );	be->save( "secured", "no" );	be->save( "ka_type", "psk" );	be->save( "psk", "Unspecified PSK" );	be->save( "certificate", "" );	be->save( "private_key", "" );	be->save( "ca_certificate", "" );	be->save( "dh_enabled", "no" );	be->save( "psk_enabled", "no" );	be->save( "check_cert", "yes" );	be->save( "local_udp_port", 5060 );	be->save( "local_tcp_port", 5060 );	be->save( "local_tls_port", 5061 );#ifdef WIN32	be->save( "sound_device", "dsound:0" );#else	be->save( "sound_device", "/dev/dsp" );#endif		be->save( "mixer_type", "spatial" );#if defined HAS_SPEEX && defined HAS_GSM	be->save( "codec[0]", "speex" );	be->save( "codec[1]", "G.711" );	be->save( "codec[2]", "GSM" );#elif defined HAS_SPEEX	be->save( "codec[0]", "speex" );	be->save( "codec[1]", "G.711" );#elif defined HAS_GSM	be->save( "codec[0]", "G.711" );	be->save( "codec[1]", "GSM" );#else	be->save( "codec[0]", "G.711" );#endif	be->save( "phonebook[0]", "file://" + getDefaultPhoneBookFilename() );//we can save startup commands ... but do nothing by default ...//<startup_cmd><command>call</command><params>uri</params></startup_cmd>		be->commit();	}string SipSoftPhoneConfiguration::getDefaultPhoneBookFilename() {	return UserConfig::getFileName( "minisip.addr" );}bool SipSoftPhoneConfiguration::checkVersion( uint32_t fileVersion/* , string fileVersion_str */) {	string str="";	bool ret = false;	if( fileVersion != CONFIG_FILE_VERSION_REQUIRED ) {		cerr << "ERROR? Your config file is an old version (some things may not work)" << endl			<< "    If you delete it (or rename it), next time you open minisip" << endl			<< "    a valid one will be created (you will have to reenter your settings" << endl;		ret = false;	} else {#ifdef DEBUG_OUTPUT		str += "Config file version checked ok!\n";#endif		cerr << str;		ret = true;	}	return ret;}MRef<SipIdentity *> SipSoftPhoneConfiguration::getIdentity( string id ) {	list< MRef<SipIdentity*> >::iterator it;	for( it = identities.begin(); it!=identities.end(); it++ ) {		if( (*it)->getId() == id ) {			return (*it);		}	}	return NULL;}MRef<SipIdentity *> SipSoftPhoneConfiguration::getIdentity( SipUri &uri ) {	list< MRef<SipIdentity*> >::iterator it;		for( it = identities.begin(); it!=identities.end(); it++ ) {		(*it)->lock();		if( (*it)->sipUsername == uri.getUserName() && 				(*it)->sipDomain == uri.getIp() ) {			(*it)->unlock();			return (*it);		}		(*it)->unlock();	}	return NULL;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -