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

📄 settingsdialog.cxx

📁 这是一个开源码的sip用户代理 写的都很清楚是用C++语言开发的 对于研究sip协议的朋友绝对是有很好的参考价值
💻 CXX
📖 第 1 页 / 共 2 页
字号:
		buttonAdd("Add", this),		listPhoneBooks(this){	listPhoneBooks.setAllColumnsShowFocus(true);//	listPhoneBooks.addColumn("Description");	listPhoneBooks.addColumn("URL");#if (QT_VERSION > 0x030000)        listPhoneBooks.setResizeMode(QListView::AllColumns);#endif//	hLayout.addWidget(&labelDesc);//	hLayout.addWidget(&editDesc);	hLayout.addWidget(&labelPath);	hLayout.addWidget(&editPath);	hLayout.addWidget(&buttonAdd);		vLayout.addLayout(&hLayout);	vLayout.addWidget(&listPhoneBooks);	tabDialog = (SettingsDialog *)parent;	}void PhoneBooksWidget::setConfig(MRef<SipSoftPhoneConfiguration *> config){	this->config = config;		list<string> phonebooks = config->phonebooks;	for (list<string>::iterator i=phonebooks.begin(); i!=phonebooks.end(); i++)		listPhoneBooks.insertItem(new QListViewItem(&listPhoneBooks, (*i).c_str()));		connect(&buttonAdd, SIGNAL(clicked()), this, SLOT(addClicked()));}void PhoneBooksWidget::addClicked(){	listPhoneBooks.insertItem(new QListViewItem(&listPhoneBooks/*, editDesc.text()*/, editPath.text()));//	editDesc.setText("");	editPath.setText("");}string PhoneBooksWidget::apply(){	QListViewItem *cur = listPhoneBooks.firstChild();	list<string> phonebooks = config->phonebooks;	while (cur!=NULL){		//cerr << cur->text(0)<< endl;		string s = cur->text(0).ascii();		list<string>::iterator i;		bool found=false;		for (i=phonebooks.begin(); i!=phonebooks.end(); i++){			if (*i==s)				found=true;		}		if (!found){			parser->addValue("phonebook",s);		}				cur = cur->nextSibling();	}	//	return "PhoneBookWidget::apply(): unimplemented\n";//	return "(phone book settings are not applied - unimplemented\n";	return "";}#endif///////////////////////////////StunTabWidget::StunTabWidget(QWidget *parent, const char *name):QWidget(parent, name), 		layout( this, 2, 1),		groupboxStun(2,Qt::Horizontal,"STUN", this),				checkUseStun("Use STUN to detect NAT", &groupboxStun),		labelEmpty1("", &groupboxStun),		checkFromUri("Autodetect STUN server from SIP address", &groupboxStun),		labelEmpty2("", &groupboxStun),				checkFromDomain("Detect STUN server for domain:",&groupboxStun),		editFromDomain(&groupboxStun),		checkSpecifyServer("Use STUN server:",&groupboxStun),		editServer(&groupboxStun){	layout.addWidget(&groupboxStun, 0, 0);	tabDialog = (SettingsDialog *)parent;}StunTabWidget::~StunTabWidget(){}void StunTabWidget::setConfig(MRef<SipSoftPhoneConfiguration *> config){	this->config = config;		checkUseStun.setChecked(config->useSTUN);	checkFromUri.setChecked(config->findStunServerFromSipUri);	checkFromDomain.setChecked(config->findStunServerFromDomain);	editFromDomain.setText(config->stunDomain.c_str());	checkSpecifyServer.setChecked(config->useUserDefinedStunServer);	editServer.setText(config->userDefinedStunServer.c_str());	connect(&checkUseStun, SIGNAL(stateChanged(int)), this, SLOT(useStunPressed(int)) );	connect(&checkFromDomain, SIGNAL(stateChanged(int)), this, SLOT(domainPressed(int)) );	connect(&checkSpecifyServer, SIGNAL(stateChanged(int)), this, SLOT(serverPressed(int)) );		checkStates();}void StunTabWidget::backupSettings(){	backupUseStun = checkUseStun.isChecked();	backupFromUri = checkFromUri.isChecked();	backupDoFromDomain = checkFromDomain.isChecked();	backupDomain = editFromDomain.text().ascii();	backupDoSpecify = checkSpecifyServer.isChecked();	backupServer = editServer.text().ascii();}void StunTabWidget::restoreSettings(){	checkUseStun.setChecked(backupUseStun);	checkFromUri.setChecked(backupFromUri);	checkFromDomain.setChecked(backupDoFromDomain);	editFromDomain.setText(backupDomain.c_str());	checkSpecifyServer.setChecked(backupDoSpecify);	editServer.setText(backupServer.c_str());}string StunTabWidget::apply(){	string ret="";		if (checkUseStun.isChecked() != backupUseStun){		config->useSTUN = checkUseStun.isChecked();		ret = ret + "WARNING: Changing STUN settings requires restarting the application for them to have any effect.\n";	}		if (checkFromUri.isChecked() != backupFromUri){		config->findStunServerFromSipUri = checkFromUri.isChecked();		ret = ret + "WARNING: Enabling and disabling STUN autodetect from SIP address requires restarting minisip\n";	}		if (checkFromDomain.isChecked() != backupDoFromDomain){		config->stunDomain = editFromDomain.text().ascii();		config->findStunServerFromDomain = config->stunDomain!="";		ret = ret + "WARNING: Enabling and disabling STUN server detect from domain requires restarting minisip\n";	}		if (checkSpecifyServer.isChecked() != backupDoSpecify){		config->useUserDefinedStunServer = checkSpecifyServer.isChecked();		if (checkSpecifyServer.isChecked()){			config->userDefinedStunServer = editServer.text().ascii();		}else{			config->userDefinedStunServer = "";		}		ret = ret + "WARNING: Enabling and disabling STUN manual server requires restarting minisip\n";	}	return ret;}void StunTabWidget::useStunPressed(int state){	checkStates();}void StunTabWidget::domainPressed(int state){	checkStates();}void StunTabWidget::serverPressed(int state){	checkStates();}void StunTabWidget::checkStates(){	bool useStun = checkUseStun.isChecked();	checkFromUri.setEnabled(useStun);		checkFromDomain.setEnabled(useStun);	editFromDomain.setEnabled(useStun && checkFromDomain.isChecked());		checkSpecifyServer.setEnabled(useStun);	editServer.setEnabled(useStun && checkSpecifyServer.isChecked());}////////////////////////////AdvancedTabWidget::AdvancedTabWidget(QWidget *parent, const char *name):		QWidget(parent, name), 		layout( this, 2, 1),		groupboxTransport(2,Qt::Horizontal,"SIP Transport", this),				labelUdpPort("Local UDP port (0 for any)", &groupboxTransport),		spinUdpPort(0,65535,1,&groupboxTransport),				checkTcp("Enable TCP on local port:",&groupboxTransport),		spinTcpPort(1024,65535,1,&groupboxTransport),		checkTls("Enable TLS on local port:",&groupboxTransport),		spinTlsPort(1024,65535,1,&groupboxTransport),		buttonCert( "Certificate settings...", &groupboxTransport ),		emptyLabel( &groupboxTransport, "" ),		labelTransport("Preferred transport protocol:",&groupboxTransport),		comboboxTransport(&groupboxTransport),		#ifndef OPIE//		checkGwIp("Use this public IP (NAT):",&groupboxTransport),//		editGwIp(&groupboxTransport),#endif///		labelMediaPort("Local (S)RTP port (0 for any)", this),		///		editMediaPort(this),		groupboxPstn(2,Qt::Horizontal,"PSTN calls", this),		usePstnProxy("Proxy for PSTN calls", &groupboxPstn),		labelEmpty1("", &groupboxPstn),			labelPSTNProxy("    PSTN proxy:",&groupboxPstn),		editPSTNProxy(&groupboxPstn),				labelPSTNNumber("    PSTN proxy number:",&groupboxPstn),		editPSTNNumber(&groupboxPstn),				labelPSTNUsername("    PSTN proxy username:",&groupboxPstn),		editPSTNUsername(&groupboxPstn),		labelPSTNPassword("    PSTN proxy password:",&groupboxPstn),		editPSTNPassword(&groupboxPstn),				checkRegisterPSTN("Register",&groupboxPstn){	layout.addWidget(&groupboxTransport, 0, 0);	tabDialog = (SettingsDialog *)parent;}AdvancedTabWidget::~AdvancedTabWidget(){}void AdvancedTabWidget::setConfig(MRef<SipSoftPhoneConfiguration *> config){	this->config = config;		spinUdpPort.setValue(config->inherited.localUdpPort);		checkTcp.setChecked(config->tcp_server);	connect(&checkTcp, SIGNAL(stateChanged(int)), this, SLOT(checkTcpPressed(int)) );	spinTcpPort.setValue(config->inherited.localTcpPort);		checkTls.setChecked(config->tls_server);	connect(&checkTls, SIGNAL(stateChanged(int)), this, SLOT(checkTlsPressed(int)) );	spinTlsPort.setValue(config->inherited.localTlsPort);		connect(&buttonCert, SIGNAL(clicked()), tabDialog, 		SLOT( showCertDialog() ) );#ifndef OPIE//	checkGwIp.setChecked(config->use_gw_ip);//	connect(&checkGwIp, SIGNAL(stateChanged(int)), this, SLOT(checkGwIpPressed(int)) );#endif		layout.addWidget(&groupboxPstn, 1, 0);	usePstnProxy.setChecked(config->usePSTNProxy);	connect(&usePstnProxy, SIGNAL(stateChanged(int)), this, SLOT(usePstnPressed(int)) );#ifndef OPIE	editPSTNProxy.setMinimumWidth(250);#endif		if(config->pstnProxy != NULL)		editPSTNProxy.setText(config->pstnProxy->getString().c_str());	editPSTNNumber.setText(config->pstnNumber.c_str());		editPSTNUsername.setText(config->pstnProxyUsername.c_str());	editPSTNPassword.setEchoMode(QLineEdit::Password);	editPSTNPassword.setText(config->pstnProxyPassword.c_str());		checkRegisterPSTN.setChecked(config->doRegisterPSTN);		checkStates();#if (QT_VERSION > 0x030000)	comboboxTransport.setCurrentText(QString(config->inherited.transport.c_str()));#endif}void AdvancedTabWidget::backupSettings(){	usePstnProxyBool = usePstnProxy.isChecked();	pstnProxystring = editPSTNProxy.text();	pstnProxyNumberstring = editPSTNNumber.text();	pstnProxyUsernamestring = editPSTNUsername.text();	pstnProxyPasswordstring = editPSTNPassword.text();	doRegisterPSTN = checkRegisterPSTN.isChecked();	doTcp = checkTcp.isChecked();	doTls = checkTls.isChecked();	udpPort = spinUdpPort.value();	tcpPort = spinTcpPort.value();	tlsPort = spinTlsPort.value();	transport = comboboxTransport.currentItem();#ifndef OPIE//	useGwIp = checkGwIp.isChecked();//	gwIpstring = editGwIp.text();#endif	}void AdvancedTabWidget::restoreSettings(){	usePstnProxy.setChecked(usePstnProxyBool);	editPSTNProxy.setText(pstnProxystring);	editPSTNNumber.setText(pstnProxyNumberstring);	editPSTNUsername.setText(pstnProxyUsernamestring);	editPSTNPassword.setText(pstnProxyPasswordstring);		checkRegisterPSTN.setChecked(doRegisterPSTN);	checkTcp.setChecked(doTcp);	checkTls.setChecked(doTls);	spinUdpPort.setValue(udpPort);	spinTcpPort.setValue(tcpPort);	spinTlsPort.setValue(tlsPort);	comboboxTransport.setCurrentItem(transport);#ifndef OPIE//	checkGwIp.setChecked(useGwIp);//	editGwIp.setText(gwIpstring);#endif}string AdvancedTabWidget::apply(){	string ret;		if (spinUdpPort.value() != udpPort){		config->inherited.localUdpPort = spinUdpPort.value();		ret = ret + "WARNING: Changing local UDP port requires restarting the application.\n";	}		if (checkTcp.isChecked()){		if (spinTcpPort.value() != tcpPort){			config->inherited.localTcpPort = spinTcpPort.value();			ret = ret + "WARNING: Changing local TCP port requires restarting the application.\n";		}		if (!doTcp){			config->tcp_server = true;			ret = ret + "WARNING: Enabling TCP requires restarting the application.\n";		}	}	else{		if (doTcp){			config->tcp_server = false;			ret = ret + "WARNING: Disabling TCP requires restarting the application.\n";		}	}	if (checkTls.isChecked()){		if (spinTlsPort.value() != tlsPort){			config->inherited.localTlsPort = spinTlsPort.value();			ret = ret + "WARNING: Changing local TLS port requires restarting the application.\n";		}		if (!doTls){			config->tls_server = true;			ret = ret + "WARNING: Enabling TLS requires restarting the application.\n";		}	}	else{		if (doTls){			config->tls_server = false;			ret = ret + "WARNING: Disabling TLS requires restarting the application.\n";		}	}		if (spinTlsPort.value() != tlsPort){//		if (!dynamicSipPort.isChecked())		config->inherited.localTlsPort = spinTlsPort.value();		ret = ret + "WARNING: Changing local TLS port requires restarting the application.\n";	}		if( comboboxTransport.currentText().ascii() != config->inherited.transport ){		config->inherited.transport =  comboboxTransport.currentText().ascii();		ret += "WARNING: Changing the preferred transport requires restarting the application.\n";	}#ifndef OPIE//	if (checkGwIp.isChecked() != useGwIp){//		config->use_gw_ip = checkGwIp.isChecked();//		if (checkGwIp.isChecked()){//			if (editGwIp.text() != gwIpstring){//				config->inherited.localIpString = editGwIp.text().ascii();//			}//		}//	}#endif			if (usePstnProxy.isChecked() != usePstnProxyBool){		config->usePSTNProxy = usePstnProxy.isChecked();	}		if (editPSTNProxy.text() != pstnProxystring){		config->pstnProxyString = editPSTNProxy.text().ascii();	}	if (editPSTNNumber.text() != pstnProxyNumberstring){		config->pstnNumber = editPSTNNumber.text().ascii();			}	if (editPSTNUsername.text() != pstnProxyUsernamestring){		config->pstnProxyUsername= editPSTNUsername.text().ascii();	}	if (editPSTNPassword.text() != pstnProxyPasswordstring){		config->pstnProxyPassword = editPSTNPassword.text().ascii();	}		if (checkRegisterPSTN.isChecked()!= doRegisterPSTN){		config->doRegisterPSTN = checkRegisterPSTN.isChecked();		if (config->doRegisterPSTN){			CommandString reg("",SipCommandString::proxy_register);			//if (!config->dialogContainer.isNull()){			if (!config->sip.isNull()){                                SipSMCommand cmd(reg, SipSMCommand::remote, SipSMCommand::TU);				//config->dialogContainer->handleCommand(cmd);				config->sip->handleCommand(cmd);			}		}	}		return ret;	}void AdvancedTabWidget::usePstnPressed(int state){	int32_t toState=false;	switch(state){		case QButton::On:			toState=true;			break;		case QButton::Off:			toState=false;			break;		case QButton::NoChange:		default:			return;	}		labelPSTNProxy.setEnabled(toState);	editPSTNProxy.setEnabled(toState);		labelPSTNNumber.setEnabled(toState);	editPSTNNumber.setEnabled(toState);		labelPSTNUsername.setEnabled(toState);	editPSTNUsername.setEnabled(toState);	labelPSTNPassword.setEnabled(toState);	editPSTNPassword.setEnabled(toState);	checkRegisterPSTN.setEnabled(toState);}void AdvancedTabWidget::checkTcpPressed(int state){	checkStates();}void AdvancedTabWidget::checkTlsPressed(int state){	checkStates();}void AdvancedTabWidget::checkGwIpPressed(int state){	checkStates();}void AdvancedTabWidget::checkStates(){		bool pstnproxy = usePstnProxy.isChecked();	bool tcp = checkTcp.isChecked();	bool tls = checkTls.isChecked();#ifndef OPIE//	bool gw = checkGwIp.isChecked();#endif	spinTcpPort.setEnabled(tcp);	spinTlsPort.setEnabled(tls);		comboboxTransport.clear();	comboboxTransport.insertItem("UDP");	if( tcp )		comboboxTransport.insertItem("TCP");	if( tls )		comboboxTransport.insertItem("TLS");#ifndef OPIE//	editGwIp.setEnabled(gw);#endif	comboboxTransport.setEnabled( tcp || tls );	labelTransport.setEnabled( tcp || tls );		labelPSTNProxy.setEnabled(pstnproxy);	editPSTNProxy.setEnabled(pstnproxy);		labelPSTNNumber.setEnabled(pstnproxy);	editPSTNNumber.setEnabled(pstnproxy);		labelPSTNUsername.setEnabled(pstnproxy);	editPSTNUsername.setEnabled(pstnproxy);	labelPSTNPassword.setEnabled(pstnproxy);	editPSTNPassword.setEnabled(pstnproxy);	checkRegisterPSTN.setEnabled(pstnproxy);}

⌨️ 快捷键说明

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