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

📄 sipsoftphoneconfiguration.cxx

📁 MiniSip Client with DomainKeys Authentication, Sip, Audio communications, Echo Cancel
💻 CXX
📖 第 1 页 / 共 2 页
字号:
/* Copyright (C) 2004-2006 the Minisip Team  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.  You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA *//* Copyright (C) 2004, 2005 * * Name * 	SipSoftPhoneConfiguration.cxx * * Authors: Erik Eliasson <eliasson@it.kth.se> *          Johan Bilien <jobi@via.ecp.fr> *          Cesc Santasusana < cesc Dot santa at@ gmail dOT com> * Purpose *          Read and write from the configuration file.  **//**************************************************** * IF YOU MODIFY THE CONFIG FILE, UPDATE THE VERSION #define * (see below) *!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/#include<config.h>#include<libminisip/sip/SipSoftPhoneConfiguration.h>#include<libminisip/soundcard/SoundIO.h>#include<libminisip/mediahandler/MediaHandler.h>#include<libminisip/contactdb/PhoneBook.h>#include<libminisip/contactdb/MXmlPhoneBookIo.h>#include<libminisip/configbackend/ConfBackend.h>#include<libminisip/configbackend/UserConfig.h>#include<fstream>#include<libminisip/soundcard/AudioMixer.h>#ifdef _WIN32_WCE#	include<stdlib.h>#	include"../include/minisip_wce_extra_includes.h"#endif#include<libmutil/dbg.h>#include<libmutil/massert.h>//update both!!!! the str define is to avoid including itoa.h#define CONFIG_FILE_VERSION_REQUIRED 2#define CONFIG_FILE_VERSION_REQUIRED_STR "2"using namespace std;SipSoftPhoneConfiguration::SipSoftPhoneConfiguration(): 	securityConfig(),//	dialogContainer(NULL),	sip(NULL),//	pstnProxy(NULL),//	pstnProxyPort(0),//	pstnNumber(string("")),	useSTUN(false),	stunServerPort(0),	findStunServerFromSipUri(false),	findStunServerFromDomain(false),	stunDomain(""),	useUserDefinedStunServer(false),	proxyConnection(NULL),//	use_gw_ip(false),//	doRegister(false),//	doRegisterPSTN(false),	soundDevice(""),	videoDevice(""),	usePSTNProxy(false),	tcp_server(false),	tls_server(false),	ringtone(""),	p2tGroupListServerPort(0){	inherited = new SipCommonConfig;}SipSoftPhoneConfiguration::~SipSoftPhoneConfiguration(){// 	cerr << "~SipSoftPhoneConfiguration" << endl;}void SipSoftPhoneConfiguration::save(){	massert(backend); // This will happen if save() is done without first 			 // having done a load() (bug).			 	//Set the version of the file ... 	backend->save( "version", CONFIG_FILE_VERSION_REQUIRED );		backend->save( "local_udp_port", inherited->localUdpPort );	backend->save( "local_tcp_port", inherited->localTcpPort );	backend->save( "local_tls_port", inherited->localTlsPort );	backend->save( "auto_answer", inherited->autoAnswer?"yes":"no");	securityConfig.save( backend );		list< MRef<SipIdentity *> >::iterator iIdent;	uint32_t ii = 0;	string accountPath;	for( iIdent = identities.begin(); iIdent != identities.end(); ii++, iIdent ++){		//cerr << "Saving identity: " << (*iIdent)->getDebugString() << endl;		accountPath = string("account[")+itoa(ii)+"]/";				(*iIdent)->lock();		backend->save( accountPath + "account_name", (*iIdent)->identityIdentifier );				backend->save( accountPath + "sip_uri", (*iIdent)->sipUsername + "@" + (*iIdent)->sipDomain );				if( (*iIdent)->getSipProxy()->autodetectSettings ) {			backend->save( accountPath + "auto_detect_proxy", "yes" );		} else {			backend->save( accountPath + "auto_detect_proxy", "no");					backend->save( accountPath + "proxy_addr", (*iIdent)->getSipProxy()->sipProxyAddressString );			backend->save( accountPath + "proxy_port", (*iIdent)->getSipProxy()->sipProxyPort );		}		if( (*iIdent)->getSipProxy()->sipProxyUsername != "" ){			backend->save( accountPath + "proxy_username", (*iIdent)->getSipProxy()->sipProxyUsername );					backend->save( accountPath + "proxy_password", (*iIdent)->getSipProxy()->sipProxyPassword );		}		if( (*iIdent) == pstnIdentity ){			backend->save( accountPath + "pstn_account", "yes" );		}		if( (*iIdent) == inherited->sipIdentity ){			backend->save( accountPath + "default_account", "yes" );		}				if( (*iIdent)->registerToProxy ) {			backend->save( accountPath + "register", "yes" );			backend->save( accountPath + "register_expires", (*iIdent)->getSipProxy()->getDefaultExpires() );		} else {			backend->save( accountPath + "register", "no");			backend->save( accountPath + "register_expires", (*iIdent)->getSipProxy()->getDefaultExpires() );		}		string transport = (*iIdent)->getSipProxy()->getTransport();				if( transport == "TCP" ){			backend->save( accountPath + "transport", "TCP" );		}		else if( transport == "TLS" ){			backend->save( accountPath + "transport", "TLS" );		}		else{			backend->save( accountPath + "transport", "UDP" );		}		(*iIdent)->unlock();	}		accountPath = "account[" + itoa( ii ) + "]/";	/* Remove old identities remaining */	while( backend->loadString( accountPath + "account_name" ) != "" ){		backend->reset( accountPath + "account_name" );		backend->reset( accountPath + "sip_uri" );		backend->reset( accountPath + "proxy_addr" );		backend->reset( accountPath + "auto_detect_proxy" );		backend->reset( accountPath + "proxy_username" );		backend->reset( accountPath + "proxy_password" );		backend->reset( accountPath + "pstn_account" );		backend->reset( accountPath + "default_account" );		backend->reset( accountPath + "register" );		backend->reset( accountPath + "register_expires" );		backend->reset( accountPath + "transport" );		accountPath = "account[" + itoa( ++ii ) + "]/";	}		backend->save( "sound_device", soundDevice );	// 	backend->save( "mute_all_but_one", muteAllButOne? "yes":"no" ); //not used anymore		backend->save( "mixer_type", soundIOmixerType );	//Save the startup commands	list<string>::iterator iter; 	int idx;	for( idx=0,  iter = startupActions.begin();			iter != startupActions.end();			iter++, idx++ ) {		int pos; 		string cmdActionsPath = string("startup_cmd[")+itoa(idx)+"]/";		pos = (*iter).find(' ');		string cmd = (*iter).substr( 0, pos );		backend->save( cmdActionsPath + "command", cmd );		pos ++; //advance to the start of the params ...		string params = (*iter).substr( pos, (*iter).size() - pos );		backend->save( cmdActionsPath + "params", params );	}		#ifdef VIDEO_SUPPORT	backend->save( "video_device", videoDevice );	backend->save( "frame_width", frameWidth );	backend->save( "frame_height", frameHeight );#endif	list<string>::iterator iCodec;	uint8_t iC = 0;	for( iCodec = audioCodecs.begin(); iCodec != audioCodecs.end(); iCodec ++, iC++ ){		backend->save( "codec[" + itoa( iC ) + "]", *iCodec );	}	/************************************************************	 * PhoneBooks	 ************************************************************/		ii = 0;	list< MRef<PhoneBook *> >::iterator iPb;	for( iPb = phonebooks.begin(); iPb != phonebooks.end(); ii++, iPb ++ ){		backend->save( "phonebook[" + itoa(ii) + "]", 				     (*iPb)->getPhoneBookId() );	}	/************************************************************	 * STUN settings	 ************************************************************/	backend->save("use_stun", (useSTUN ? "yes" : "no") );	backend->save("stun_server_autodetect", findStunServerFromSipUri?"yes":"no");	if (findStunServerFromDomain){		backend->save("stun_server_domain", stunDomain );	}	else{		backend->save("stun_server_domain", "");	}	backend->save("stun_manual_server", userDefinedStunServer);		/************************************************************	 * Advanced settings	 ************************************************************/	backend->save("tcp_server", tcp_server? "yes":"no");	backend->save("tls_server", tls_server? "yes":"no");	backend->save("ringtone", ringtone);		//add code to load the default network interface	//<network_interface> into networkInterfaceName	//We are not saving the interface name of the current localIP ...	backend->save( "network_interface", networkInterfaceName );	backend->commit();}string SipSoftPhoneConfiguration::load( MRef<ConfBackend *> be ){	backend = be;	//installConfigFile( this->configFileName );	proxyConnection = NULL;	usePSTNProxy = false;	string ret = "";	string account;	int ii = 0;	/* Check version first of all! */	int32_t fileVersion;	string fileVersion_str;	fileVersion = backend->loadInt("version", 0);		//get the string version also ... don't use the itoa.h//	fileVersion_str = backend->loadString("version", "0");	if( !checkVersion( fileVersion /*, fileVersion_str*/ ) ) {		//check version prints a message ... 		//here, deal with the error//		ret = "ERROR";		saveDefault( backend );//		return ret;	}		do{		string accountPath = string("account[")+itoa(ii)+"]/";		account = backend->loadString(accountPath+"account_name");		if( account == "" ){			break;		}

⌨️ 快捷键说明

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