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

📄 minisipmainwindowwidget.cxx

📁 MiniSip Client with DomainKeys Authentication, Sip, Audio communications, Echo Cancel
💻 CXX
📖 第 1 页 / 共 2 页
字号:
void MinisipMainWindowWidget::callPressed(){//	log(LOG_INFO, "Pressed call, text="+text.text());	doCall();}static string getstringViaHTTP(string uri){	string host = uri.substr(0, uri.find("/"));	string path= uri.substr(uri.find("/"));	TCPSocket sock(host, 80);	//FiXME: parse port from addr	sock.write("GET "+path+"\r\n\r\n");		char buf[4096];	string ret;	int n;	while ((n=sock.read(buf,4095))>0){		buf[n]=0;		ret = ret + string(buf); 	}	return ret;}void MinisipMainWindowWidget::addPhoneBook(string filename){//	cerr << "Opening phonebook "<< filename << endl;	if (filename.size()<=7)		return;	XMLParser *parser;	if (filename.substr(0,7)=="file://"){//		cerr << "Creating XML file parser"<< endl;		parser = new XMLFileParser(filename.substr(7));		}else{		if (filename.substr(0,7)=="http://"){			parser = new XMLstringParser( getstringViaHTTP(filename.substr(7)) );		}else{			cerr << "Warning: unknown phone book access method (should start with file:// or http://): "<< filename << endl;			return;		}	}	string phonebook;	int phonebooks=0;	do{		string q = "phonebook["+itoa(phonebooks)+"]/name";//		cerr << "Parsing phonebook "<< q << endl;		phonebook=parser->getValue(q,"");		if (phonebook!=""){			QListViewItem *phonebookparent= new QListViewItem(listView, phonebook.c_str());			string contact;			int contacts=0;			do{				string q = "phonebook["+itoa(phonebooks)+"]/contact["+itoa(contacts)+"]/name";				contact = parser->getValue(q,"");//				cerr << "Parsing contact:"<< q << endl;				if (contact!=""){					QListViewItem *contactparent= new QListViewItem(phonebookparent, contact.c_str());					int pops=0;					string qbase;					string desc;					do{						string qbase = "phonebook["+itoa(phonebooks)+"]/contact["+itoa(contacts)+"]/pop["+itoa(pops)+"]/";						desc = parser->getValue(qbase+"desc","");//						cerr << "Parsed: "<< desc<< endl;						if (desc!=""){							string uri = parser->getValue(qbase+"uri","");							PersonListItem *item = new PersonListItem(contactparent,desc,uri,false, "");//TODO: parse different parts of line and send as arguments						}						pops++;					}while(desc!="");				}				contacts++;			}while(contact!="");		}		phonebooks++;	}while(phonebook!="");	delete parser;}void MinisipMainWindowWidget::displaySettings(){#ifdef OPIE	((QPEApplication *)qApp)->showMainWidget(&settingsDialog);#else	settingsDialog.show();#endif}void MinisipMainWindowWidget::customEvent(QCustomEvent *e){	//	cerr << "Got event in MinisipMainWindowWidget"<< endl;	CommandEvent *ce = /*dynamic_cast<CommandEvent *>*/(CommandEvent *)(e);	if (ce==NULL){		cerr << "WARNING could not convert to customEvent"<<endl;	}else{		//		cerr << "got command "<< ce->getCommand().getOp()<<endl;		CommandString command(ce->getCommand());#ifdef MINISIP_AUTOCALL		if (command.getOp()=="autocall"){			text.setText(sipphone->autoCall.c_str());			doCall();			return;		}#endif//		if (command.getOp()!=CommandString::log)//			log(LOG_INFO, "MinisipMainWindowWidget::customEvent: Received command "+command.getstring());		for (list<CallDialog *>::iterator i=calls.begin(); i != calls.end(); i++)			if ((*i)->handleCommand(command))				return;//		if (command.getOp()==CommandString::register_ok){//			if (statusBar!=NULL)//				statusBar->message(("Registred to proxy "+command.getParam()).c_str(),10000);//			return;//		}		if (command.getOp()==SipCommandString::ask_password){			createRegisterDialog("Registration", command.getDestinationId(), command.getParam());			handleCommand(command);		}				if (command.getOp()==SipCommandString::error_message){			QMessageBox msg("Error message", command.getParam().c_str(), QMessageBox::Warning,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton,this);			msg.exec();			return;		}/*		if (command.getOp()==CommandString::log){#ifdef DEBUG_OUTPUT//			cerr << "LOG: "<<command.getParam2()<< endl;#endif#if (QT_VERSION > 0x030000) && defined DEBUG_OUTPUT			logDialog.log(atoi(command.getParam().c_str()), command.getParam2());#endif			return;		}*/                		if (command.getOp()==SipCommandString::proxy_register){//			return getSipPhone()->enqueueCommand(SipSMCommand(command, SipSMCommand::remote, SipSMCommand::TU));                        //SipSMCommand cmd(command, SipSMCommand::remote, SipSMCommand::TU);			callback->guicb_handleCommand(/*cmd*/ command);			return;		}//		if (command.getOp()==CommandString::register_failed_authentication){//			if (statusBar!=NULL)//				statusBar->message(("Failed registration to proxy."));//			//			logDialog.log(atoi(command.getParam().c_str()), command.getParam2());//			return;//		}		if (command.getOp()==SipCommandString::register_sent){			//createRegisterDialog("Call", command.getCallId(), command.getParam());		}		if (command.getOp()==SipCommandString::incoming_available){			if (statusBar!=NULL)				statusBar->message("Started a call",10000);//			CallDialog *calldialog = new CallDialog(command.getCallId(),this, timeoutProvider, command.getParam(), command.getParam2());//			addCallDialog(calldialog);//			calldialog->show();			createCallDialog("Call", command.getDestinationId(), command.getParam(), command.getParam2() );			return;		}	}}void MinisipMainWindowWidget::handleCommand(CommandString command){//		if (command.getOp()!=CommandString::log)//			log(LOG_INFO, "MinisipMainWindowWidget::handleCommand: Received command "+command.getstring());		CommandEvent *ce = new CommandEvent(command); // Qt will delete the event when done		qApp->postEvent(this,ce);#ifdef OPIE		updateGui();#endif			}void MinisipMainWindowWidget::setStatusBar(QStatusBar *bar){	statusBar = bar;}//#ifdef OPIE//void MinisipMainWindowWidget::setApplication(QPEApplication *app){//#elsevoid MinisipMainWindowWidget::setApplication(QApplication *app){	//#endif	this->qapplication = app;}/*void MinisipMainWindowWidget::log(int type, string msg){	//	logDialog.log(type,msg);	//not thread safe	CommandString log("",CommandString::log,itoa(type), msg);	handleCommand(log);}*/void MinisipMainWindowWidget::addCallDialog(CallDialog *d){	calls.push_back(d);}void MinisipMainWindowWidget::removeCallDialog(string callId){	for (list<CallDialog *>::iterator i=calls.begin(); i!=calls.end(); i++)		if ((*i)->getCallId()==callId){			tabs.removePage(*i);			calls.erase(i);			#if (QT_VERSION < 0x030000)			tabCount--;#endif			return;		}}void MinisipMainWindowWidget::run(){	qtguirun( this );}bool MinisipMainWindowWidget::configDialog( MRef<SipSoftPhoneConfiguration *> conf ){	bool ok;	SettingsDialog * sd = new SettingsDialog();	sd->setConfig( conf );	ok = sd->exec();	delete sd;	return ok;}PersonListItem::PersonListItem( QListViewItem *parent, string name, string uri, bool online, string location)        : QListViewItem( parent ){	this->name = name;	this->uri = uri;	this->online = online;	this->location = location;	string loc;	if (location.length()>0)		loc = "["+location+"] ";	setText(0, (loc+name+", "+uri).c_str()) ;}#if (QT_VERSION > 0x030000)int const PersonListItem::RTTI_VAL=3333;int PersonListItem::rtti(){	return RTTI_VAL;}#endifvoid PersonListItem::paintCell( QPainter *p, const QColorGroup &cg,		int32_t column, int32_t width, int32_t alignment ){	QColorGroup _cg( cg );	QColor c = _cg.text();	if ( /*status == "online"*/ online )		_cg.setColor( QColorGroup::Text, Qt::darkGreen );	//	if ( status == "offline" )	//		_cg.setColor( QColorGroup::Text, Qt::red );	QListViewItem::paintCell( p, _cg, column, width, alignment );	_cg.setColor( QColorGroup::Text, c );}CommandEvent::CommandEvent(CommandString command): QCustomEvent(QEvent::User), command(command){}CommandString CommandEvent::getCommand(){	return command;}

⌨️ 快捷键说明

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