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

📄 callwidget.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, 2005  * * Authors: Erik Eliasson <eliasson@it.kth.se> *          Johan Bilien <jobi@via.ecp.fr>*/#include"CallWidget.h"#include"MainWindow.h"//#include<libminisip/sip/state_machines/SipSMCommand.h>//#include<libminisip/sip/state_machines/SipSoftPhone.h>#include<libmsip/SipSMCommand.h>#include<libmsip/SipCommandString.h>#include<libminisip/gui/Bell.h>#include<libminisip/mediahandler/MediaCommandString.h>#include<libminisip/mediahandler/Session.h>#include<libminisip/mediahandler/MediaStream.h>#ifdef OLDLIBGLADEMM#define SLOT(a,b) SigC::slot(a,b)#define BIND SigC::bind#else#define SLOT(a,b) sigc::mem_fun(a,b)#define BIND sigc::bind#endifusing namespace std;CallWidget::CallWidget( string callId, string remoteUri,                         MainWindow * mw, bool incoming, string secure):		mainWindow( mw ),		status( "", Gtk::ALIGN_LEFT ),		secStatus( "", Gtk::ALIGN_LEFT ),		buttonBox(/*homogenius*/ true ),#ifndef OLDLIBGLADEMM		dtmfArrow( "Dialpad" ),		transferArrow( "Call transfer" ),		transferHBox( false ),		transferButton( "Transfer" ),//		monitoringButton( "Mute microphone" ),//		audioOutSilenceButton( "Silence for my ears"),		monitoringButton( Gtk::StockID( "minisip_record" ), Gtk::StockID( "minisip_norecord" ) ),		audioOutSilenceButton( Gtk::StockID( "minisip_play" ), Gtk::StockID( "minisip_noplay" ) ),#endif		secureImage(),// Gtk::StockID( "minisip_insecure" ), 					//   Gtk::ICON_SIZE_DIALOG ),		insecureImage( Gtk::StockID( "minisip_insecure" ), 		Gtk::ICON_SIZE_DIALOG ),		acceptButton( Gtk::Stock::OK, "Accept" ),		rejectButton( Gtk::Stock::CANCEL, "Reject" ),		bell(),		mainCallId( callId ){	activeCallWidget = false;	bell = NULL;	callIds.push_back( callId );	Gtk::HBox * topBox = manage( new Gtk::HBox );	topBox->pack_start( secureImage, false, false, 5 );	Gtk::VBox * rightTopBox = manage( new Gtk::VBox );	topBox->pack_start( *rightTopBox, false, false, 5 );		rightTopBox->pack_start( status, false, false, 5 );	rightTopBox->pack_start( secStatus, false, false, 5 );		pack_start( *topBox, false, false, 5 );	Pango::AttrList attrList( "<big><b></b></big>" );	status.set_attributes( attrList );	Gtk::HSeparator * separator = manage( new Gtk::HSeparator );	pack_start( *separator, false, false, 5 );	separator->show();//	add( status );//	add( secStatus );	pack_end( buttonBox, false, true );	//buttonBox.set_expand( false );	status.set_use_markup( true );	secStatus.set_use_markup( true );	topBox->show_all();#ifndef OLDLIBGLADEMM	topBox = manage( new Gtk::HBox );	topBox->pack_start( monitoringButton, false, false );	monitoringButton.signal_toggled().connect( 		SLOT( *this, 			&CallWidget::monitorButtonToggled ) );				topBox->pack_start( audioOutSilenceButton, false, false );	audioOutSilenceButton.signal_toggled().connect( 		SLOT( *this, 			&CallWidget::audioOutSilenceButtonToggled ) );		pack_start( *topBox, false, false, 4 );		DtmfWidget * dtmfWidget = manage( new DtmfWidget() );	dtmfWidget->setHandler( this );	dtmfArrow.add( *dtmfWidget ); 	pack_start( dtmfArrow, false, false, 4 );		Gtk::VBox * vbox = manage( new Gtk::VBox );	vbox->add( transferHBox );	vbox->add( transferHBox2 );	transferArrow.add( *vbox );		transferButton.signal_clicked().connect( 					SLOT( *this, &CallWidget::transfer ) );				transferHBox.pack_end( transferButton, false, false ), 	transferHBox.pack_end( transferEntry, true, true ), 		transferHBox2.pack_end( transferProgress, true, true );		pack_start( transferArrow, false, false, 4 );#endif	buttonBox.add( acceptButton );	buttonBox.add( rejectButton );//	status.show();//	secStatus.show();	topBox->show_all();	buttonBox.show_all();//	rejectButton.show();//        acceptButton.hide();	acceptButton.signal_clicked().connect( SLOT( *this, &CallWidget::accept ) );	rejectButton.signal_clicked().connect( SLOT( *this, &CallWidget::reject ) );	if( incoming ){		state = CALL_WIDGET_STATE_INCOMING;//		acceptButton.show();		//Using the markup, when receiving a call (full uri), the < and > make gtk complain ... s		string sanitizedUri = remoteUri;		sanitizedUri.replace( sanitizedUri.find('<'), 1, " " );		sanitizedUri.replace( sanitizedUri.find('>'), 1, " " );		status.set_markup( "<big><b>Incoming call from \n" + sanitizedUri				+ "</b></big>");		// 		status.set_text( "Incoming call from \n" + remoteUri );				secStatus.set_markup( "The call is <b>" + secure +"</b>." );		if( secure == "secure" ){				secureImage.set( Gtk::StockID( "minisip_secure") , Gtk::ICON_SIZE_DIALOG );		}		else{				secureImage.set( Gtk::StockID( "minisip_insecure") , Gtk::ICON_SIZE_DIALOG );		}		startRinging();	}	else{		acceptButton.set_sensitive( false );		state = CALL_WIDGET_STATE_CONNECTING;		status.set_markup( "<big><b>Connecting...</b></big>" );		//secStatus.set_markup( "Security requested" );		rejectButton.set_label( "Cancel" );	}}CallWidget::~CallWidget(){}void CallWidget::accept(){	CommandString * cmd = NULL;	switch( state ){                		case CALL_WIDGET_STATE_INCOMING:			cmd = new CommandString( mainCallId,						SipCommandString::accept_invite );			mainWindow->getCallback()->handleCommand("sip", *cmd );			stopRinging();			break;		case CALL_WIDGET_STATE_INCOMING_TRANSFER:			cmd = new CommandString( mainCallId, SipCommandString::user_transfer_accept );			mainWindow->getCallback()->handleCommand("sip", *cmd );			break;	}	if( cmd ){			delete cmd;	}}void CallWidget::reject(){	CommandString cmdstr("","");	stopRinging();	switch( state ){		case CALL_WIDGET_STATE_TERMINATED:			mainWindow->removeCall( mainCallId );			break;		case CALL_WIDGET_STATE_INCALL:		case CALL_WIDGET_STATE_CONNECTING:		case CALL_WIDGET_STATE_RINGING:			mainWindow->removeCall( mainCallId );			cmdstr = CommandString( mainCallId, SipCommandString::hang_up );			//mainWindow->getCallback()->guicb_handleCommand( cmdstr );			mainWindow->getCallback()->handleCommand("sip", cmdstr );			break;		case CALL_WIDGET_STATE_INCOMING:			mainWindow->removeCall( mainCallId );			cmdstr = CommandString( mainCallId, SipCommandString::reject_invite);			//mainWindow->getCallback()->guicb_handleCommand( cmdstr );			mainWindow->getCallback()->handleCommand("sip", cmdstr );			break;		case CALL_WIDGET_STATE_INCOMING_TRANSFER:			cmdstr = CommandString( mainCallId, SipCommandString::user_transfer_refuse );			//mainWindow->getCallback()->guicb_handleCommand( cmdstr );			mainWindow->getCallback()->handleCommand("sip", cmdstr );			status.set_markup( "<big><b>In call</b></big>" );			state = CALL_WIDGET_STATE_INCALL; 			break;	}}void CallWidget::monitorButtonToggled () {#ifndef OLDLIBGLADEMM	string param2;	if( monitoringButton.get_active() ) {		param2 = "OFF";	} else {		param2 = "ON";	}	CommandString cmdstr( getMainCallId(), 			MediaCommandString::set_session_sound_settings,			"senders", param2 );	//mainWindow->getCallback()->guicb_handleMediaCommand( cmdstr );	mainWindow->getCallback()->handleCommand("media", cmdstr );#endif}void CallWidget::audioOutSilenceButtonToggled () {#ifndef OLDLIBGLADEMM	string param2;	if( audioOutSilenceButton.get_active() ) {		param2 = "OFF";	} else {		param2 = "ON";	}	CommandString cmdstr( getMainCallId(), 			MediaCommandString::set_session_sound_settings,			"receivers", param2 );	//mainWindow->getCallback()->guicb_handleMediaCommand( cmdstr );	mainWindow->getCallback()->handleCommand("media", cmdstr );#endif}void CallWidget::hideAcceptButton(){	acceptButton.set_sensitive( false );}bool CallWidget::handleCommand( CommandString command ){	if( handlesCallId( command.getDestinationId() ) ){		if( command.getOp() == SipCommandString::remote_user_not_found ){			hideAcceptButton();			status.set_markup( "<b>User not found</b>" );			rejectButton.set_label( "Close" );			state = CALL_WIDGET_STATE_TERMINATED;		}		if( command.getOp() == SipCommandString::invite_ok ){			string who;			if( command.getParam().length() > 0 ){				who = " with " + command.getParam();			}			status.set_markup( "<big><b>In call" + who + "</b></big>" );#ifndef OLDLIBGLADEMM			monitoringButton.show();			audioOutSilenceButton.show();			transferArrow.show_all();			dtmfArrow.show_all();#endif			secStatus.set_markup( "The call is <b>" + 					command.getParam2() + "</b>" );			if( command.getParam2() == "secure" ){

⌨️ 快捷键说明

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