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

📄 calldialog.cxx

📁 MiniSip Client with DomainKeys Authentication, Sip, Audio communications, Echo Cancel
💻 CXX
📖 第 1 页 / 共 2 页
字号:
/* *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program 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 Library General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *//* Copyright (C) 2004  * * Authors: Erik Eliasson <eliasson@it.kth.se> *          Johan Bilien <jobi@via.ecp.fr>*/#include"CallDialog.h"#include<libmsip/SipSMCommand.h>#include<libmsip/SipCommandString.h>#include<libmsip/SipMessageTransport.h>#include"../../../sip/SipSoftPhoneConfiguration.h"#include"../../../sip/DefaultDialogHandler.h"#include"MinisipMainWindowWidget.h"#include<qmessagebox.h>#define config mainWidget->getSipSoftPhoneConfiguration()#ifdef EMBEDDED_CALLDIALOGSCallDialog::CallDialog(string callId, MinisipMainWindowWidget *main, TimeoutProvider<string> *tp): QWidget(0,"Call"), callId(callId), mainWidget(main),#elseCallDialog::CallDialog(string callId, MinisipMainWindowWidget *main, TimeoutProvider<string> *tp): QDialog(0,"Call",FALSE, WDestructiveClose), callId(callId), mainWidget(main),#endif		vlayout(this),		buttonlayout(),		status("Connecting...", this), 		security_status("", this),		checkRecord("Record call", this),		acceptButton("OK", this),		rejectButton("Hang up", this),		timeoutProvider(tp),		bell(NULL){	vlayout.addWidget(&status);	status.setAlignment(AlignCenter);		vlayout.addWidget(&security_status);	security_status.setAlignment(AlignCenter);		vlayout.addWidget(&checkRecord);	buttonlayout.addWidget(&acceptButton);	buttonlayout.addWidget(&rejectButton);	vlayout.addLayout(&buttonlayout);	connect(&acceptButton,SIGNAL(clicked()), this, SLOT(acceptClicked()) );	connect(&rejectButton,SIGNAL(clicked()), this, SLOT(rejectClicked()) );		hideAcceptButton();	//status.setMinimumWidth(250);	bell=NULL;}#ifdef EMBEDDED_CALLDIALOGSCallDialog::CallDialog(string callId, MinisipMainWindowWidget *main, TimeoutProvider<string> *tp,string incomingFrom, string secured): QWidget(0,"Call"), callId(callId), mainWidget(main),#elseCallDialog::CallDialog(string callId, MinisipMainWindowWidget *main, TimeoutProvider<string> *tp,string incomingFrom, string secured): QDialog(0,"Call",FALSE,WDestructiveClose), callId(callId), mainWidget(main),#endif		vlayout(this),		buttonlayout(),		status("Connecting...", this), 		security_status("The call is ", this),		checkRecord("Record call", this),		acceptButton("OK", this),		rejectButton("Hang up", this),		timeoutProvider(tp){	status.setText(("Incoming call\nfrom "+ incomingFrom).c_str());	bell = new Bell(timeoutProvider);        if( bell != NULL ){ 	        bell->start();        }		vlayout.addWidget(&status);	status.setAlignment(AlignCenter);	security_status.setText(("The call is <b>"+secured+"</b>").c_str());	vlayout.addWidget(&security_status);	security_status.setAlignment(AlignCenter);	vlayout.addWidget(&checkRecord);	buttonlayout.addWidget(&acceptButton);	buttonlayout.addWidget(&rejectButton);	vlayout.addLayout(&buttonlayout);	connect(&acceptButton,SIGNAL(clicked()), this, SLOT(acceptClicked()) );	connect(&rejectButton,SIGNAL(clicked()), this, SLOT(rejectClicked()) );}void CallDialog::hideAcceptButton(){	acceptButton.hide();}string CallDialog::getCallId(){	return callId;}void CallDialog::timeout(string c){	mainWidget->handleCommand(CommandString(callId,c));}void CallDialog::acceptClicked(){	CommandString accept(callId, SipCommandString::accept_invite);//        SipSMCommand cmd(accept,SipSMCommand::remote, SipSMCommand::TU);	mainWidget->getCallback()->guicb_handleCommand(/*cmd*/ accept);        if( bell != NULL ){	        bell->stop();	        delete bell;	        bell = NULL;        }}void CallDialog::rejectClicked(){//	cerr << "CallDialog::rejectClicked: clicked"<< endl;	if (rejectButton.text()=="Close"){		timeoutProvider->cancel_request(this, SipCommandString::close_window);		mainWidget->removeCallDialog(callId);		done(0);		return;	}	if (rejectButton.text()=="Hang up"){		mainWidget->removeCallDialog(callId);//		if (status.text()=="Ringing..."){//			SMCommand cncl(callId, SMCommand::cancel);//			mainWidget->log(LOG_INFO, "Sending cancel command for call id " +callId);//			mainWidget->getSipPhone()->doCommand(cncl);////		}else{		CommandString hup(callId, SipCommandString::hang_up);//		mainWidget->log(LOG_INFO, "Sending hang up command for call id " +callId);                //SipSMCommand cmd(hup, SipSMCommand::remote, SipSMCommand::TU);		mainWidget->getCallback()->guicb_handleCommand(/*cmd*/hup);		if( bell != NULL ){			bell->stop();			delete bell;			bell = NULL;		}//		}		done(0);		return;	}	/* Moved to Accept button		if (rejectButton.text()=="Answer"){		CommandString accept(callId, SipCommandString::accept_invite);		mainWidget->getSipPhone()->enqueueCommand(SipSMCommand(accept,SipSMCommand::remote, SipSMCommand::TU));		cerr <<"stopping bell..."<< endl;		bell->stop();		cerr << "deleteing bell"<< endl;		delete bell;	}*/}bool CallDialog::handleCommand(CommandString command){	if (callId == command.getDestinationId()){		if (command.getOp()==SipCommandString::remote_user_not_found){			hideAcceptButton();			status.setText("<b>User not found</b>");			checkRecord.setChecked(false);			checkRecord.setEnabled(false);			rejectButton.setText("Close");//			repaint();//			mainWidget->removeCallDialog(callId); 	// Dialog will still exist until close is 								// clicked - just not receive any SIP commands		}		if (command.getOp()==SipCommandString::invite_ok){			string who;			if (command.getParam().length()>0)				who = " with " + command.getParam();						status.setText(("In call"+who).c_str());						security_status.setText(("The call is "+command.getParam2()).c_str());			hideAcceptButton();			rejectButton.setText("Hang up");//			repaint();					}		if (command.getOp()==SipCommandString::authentication_failed){			status.setText("<b>Authentication failed</b>");			checkRecord.setChecked(false);			checkRecord.setEnabled(false);			rejectButton.setText("Close");			//repaint();			timeoutProvider->request_timeout(5000, this, SipCommandString::close_window);//			mainWidget->removeCallDialog(callId); 	// Dialog will still exist until close is 								// clicked - just not receive any SIP commands		}				if (command.getOp()==SipCommandString::invite_no_reply){			status.setText("No reply");			checkRecord.setChecked(false);			checkRecord.setEnabled(false);			hideAcceptButton();			rejectButton.setText("Close");//			repaint();			timeoutProvider->request_timeout(5000, this, SipCommandString::close_window);//			mainWidget->removeCallDialog(callId); 	// Dialog will still exist until close is 								// clicked - just not receive any SIP commands		}				if (command.getOp()==SipCommandString::transport_error){			status.setText("The call failed due to a network error");			checkRecord.setChecked(false);			checkRecord.setEnabled(false);			rejectButton.setText("Close");//			repaint();			timeoutProvider->request_timeout(5000, this, SipCommandString::close_window);//			mainWidget->removeCallDialog(callId); 	// Dialog will still exist until close is 								// clicked - just not receive any SIP commands		}		if (command.getOp()==SipCommandString::remote_hang_up){			status.setText("Call ended");//			status.repaint();//			checkRecord.setChecked(false);//			checkRecord.setEnabled(false);			security_status.setText("");			rejectButton.setText("Close");//			repaint();			timeoutProvider->request_timeout(5000, this, SipCommandString::close_window);

⌨️ 快捷键说明

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