📄 callwidget.cxx
字号:
secureImage.set( Gtk::StockID( "minisip_secure") , Gtk::ICON_SIZE_DIALOG ); } else{ secureImage.set( Gtk::StockID( "minisip_insecure") , Gtk::ICON_SIZE_DIALOG ); } rejectButton.set_label( "Hang up" ); hideAcceptButton(); stopRinging(); state = CALL_WIDGET_STATE_INCALL; //activate this source CommandString cmdstr( getMainCallId(), MediaCommandString::set_session_sound_settings, "senders", "ON" ); mainWindow->getCallback()->handleCommand("media", cmdstr ); } if( command.getOp() == SipCommandString::authentication_failed ){ status.set_markup( "<b>Authentication failed</b>" ); rejectButton.set_label( "Close" ); state = CALL_WIDGET_STATE_TERMINATED; } if( command.getOp() == SipCommandString::invite_no_reply ){ status.set_text( "No reply" ); hideAcceptButton(); rejectButton.set_label( "Close" ); state = CALL_WIDGET_STATE_TERMINATED; } if( command.getOp() == SipCommandString::transport_error ){ status.set_text( "The call failed due to a network error" ); hideAcceptButton(); rejectButton.set_label( "Close" ); state = CALL_WIDGET_STATE_TERMINATED; } if( command.getOp() == SipCommandString::remote_unacceptable ){ status.set_text( "The remote user could not\nhandle the call." ); if( command.getParam() != "" ){ secStatus.set_markup( "<small>" + command.getParam() + "</small>" ); } hideAcceptButton(); rejectButton.set_label( "Close" ); state = CALL_WIDGET_STATE_TERMINATED; } if( command.getOp() == SipCommandString::remote_hang_up ){ stopRinging(); callIds.remove( command.getDestinationId() ); if( command.getDestinationId() == mainCallId ){ status.set_markup( "<b><big>Call ended</big></b>" ); secStatus.set_text( "" ); rejectButton.set_label( "Close" ); state = CALL_WIDGET_STATE_TERMINATED;#ifndef OLDLIBGLADEMM monitoringButton.hide(); audioOutSilenceButton.hide(); transferArrow.hide(); dtmfArrow.hide();#endif } } if( command.getOp() == SipCommandString::call_terminated_early ){ stopRinging(); callIds.remove( command.getDestinationId() ); if( command.getDestinationId() == mainCallId ){ status.set_markup( "<b><big>Call Terminated</big></b>" );// secStatus.set_text( "" ); rejectButton.set_label( "Close" ); state = CALL_WIDGET_STATE_TERMINATED;#ifndef OLDLIBGLADEMM monitoringButton.hide(); audioOutSilenceButton.hide(); transferArrow.hide(); dtmfArrow.hide();#endif } } if( command.getOp() == SipCommandString::remote_reject ){ status.set_text( "Remote side rejected the call" ); secStatus.set_text( "" ); rejectButton.set_label( "Close" ); state = CALL_WIDGET_STATE_TERMINATED; } if( command.getOp() == SipCommandString::remote_cancelled_invite ){ stopRinging(); status.set_text( "Remote side cancelled the call" ); rejectButton.set_label( "Close" ); state = CALL_WIDGET_STATE_TERMINATED; secStatus.set_text( "" ); hideAcceptButton(); } if( command.getOp() == SipCommandString::remote_ringing ){ status.set_markup( "<b><big>Ringing...</big></b>" ); rejectButton.set_label( "Hang up" ); state = CALL_WIDGET_STATE_RINGING; } if( command.getOp() == SipCommandString::temp_unavail ){ status.set_text( "The user is reported temporary unavailable" ); rejectButton.set_label("Close"); state = CALL_WIDGET_STATE_TERMINATED; } if( command.getOp() == SipCommandString::cancel_ok ){ status.set_text( "Call canceled" ); rejectButton.set_label( "Close" ); state = CALL_WIDGET_STATE_TERMINATED; } if( command.getOp() == SipCommandString::security_failed ){ stopRinging(); secStatus.set_text( "Security is not handled by the receiver" );// secStatus.set_text( "" ); rejectButton.set_label( "Close" ); state = CALL_WIDGET_STATE_TERMINATED; } if( command.getOp() == SipCommandString::transfer_requested ){ status.set_text( "Accept transfer to " + command.getParam() + "?" ); secStatus.set_text( "" ); acceptButton.show(); acceptButton.set_sensitive( true ); acceptButton.set_label( "Accept" ); rejectButton.set_label( "Reject" ); state = CALL_WIDGET_STATE_INCOMING_TRANSFER; } if( command.getOp() == SipCommandString::call_transferred ){ /* Change the callId so that we get next commands */ mainCallId = command.getParam(); callIds.push_back( mainCallId ); status.set_text( "Call transferred... "); } if( command.getOp() == SipCommandString::transfer_pending ){#ifndef OLDLIBGLADEMM transferProgress.set_text( "Transfer accepted..." );#endif //transferProgress.pulse(); } if( command.getOp() == SipCommandString::transfer_refused ){#ifndef OLDLIBGLADEMM transferProgress.set_text( "Transfer rejected." ); transferEntry.set_sensitive( true ); transferButton.set_sensitive( true );#endif } return true; } return false;}void CallWidget::startRinging(){ if(!bell){ bell = new Bell(); } bell->start(); CommandString cmdstr = CommandString( "", MediaCommandString::start_ringing ); //mainWindow->getCallback()->guicb_handleMediaCommand( cmdstr ); mainWindow->getCallback()->handleCommand("media", cmdstr );}void CallWidget::stopRinging(){ if (bell){ bell->stop(); bell=NULL; } CommandString cmdstr = CommandString( "", MediaCommandString::stop_ringing ); mainWindow->getCallback()->handleCommand("media", cmdstr );}#ifndef OLDLIBGLADEMMvoid CallWidget::transfer(){ string uri = Glib::locale_from_utf8( transferEntry.get_text() ); if( uri.size() > 0 ){ CommandString transfer( mainCallId, SipCommandString::user_transfer, uri ); //mainWindow->getCallback()->guicb_handleCommand( transfer ); mainWindow->getCallback()->handleCommand("sip", transfer ); transferEntry.set_sensitive( false ); transferButton.set_sensitive( false ); transferProgress.set_text( "Transfer requested..." ); //transferProgress.pulse(); }}void CallWidget::dtmfPressed( uint8_t symbol ){ MRef<Session *> session = Session::registry->getSession( mainCallId ); if( session ){ session->sendDtmf( symbol ); }}#endifstring CallWidget::getMainCallId(){ return mainCallId;}bool CallWidget::handlesCallId( string callId ){ list<string>::iterator iCallId; for( iCallId = callIds.begin(); iCallId != callIds.end(); iCallId++ ){ if( *iCallId == callId ){ return true; } } return false;}StockButton::StockButton( Gtk::StockID stockId, Glib::ustring text ): box( 2 ), image( stockId, Gtk::ICON_SIZE_SMALL_TOOLBAR ), label( text ){ box.pack_start( image, false, false ); box.pack_end( label, true, true ); add( box ); show_all();}void StockButton::set_label (const Glib::ustring& label){ this->label.set_text( label );}void CallWidget::activeWidgetChanged( bool isActive, int currentActive ) { if( isActive == activeCallWidget ) {#ifdef DEBUG_OUTPUT// cerr << "CallWidget::activeCall - nothing to do here (no active state change)" << endl;#endif return; } else { activeCallWidget = isActive; } //our status has changed ... do something? if( !isActive ) {#ifdef DEBUG_OUTPUT// cerr << "CallWidget::activeCall - We were active ... not anymore" << endl;#endif CommandString cmdstr( getMainCallId(), MediaCommandString::set_session_sound_settings, "senders", "OFF" ); //mainWindow->getCallback()->guicb_handleMediaCommand( cmdstr ); mainWindow->getCallback()->handleCommand("media", cmdstr ); return; } else {#ifdef DEBUG_OUTPUT// cerr << "CallWidget::activeCall - We active!" << endl;#endif if( getState() == CALL_WIDGET_STATE_INCALL #ifndef OLDLIBGLADEMM && ! monitoringButton.get_active() #endif ){ CommandString cmdstr( getMainCallId(), MediaCommandString::set_session_sound_settings, "senders", "ON" ); //mainWindow->getCallback()->guicb_handleMediaCommand( cmdstr ); mainWindow->getCallback()->handleCommand("media", cmdstr ); } else {#ifdef DEBUG_OUTPUT// fprintf( stderr, "CallWidget::onTabChange ... doing nothing (call widget state)!\n" );#endif } }}IconToggleButton::IconToggleButton( Gtk::StockID id1, Gtk::StockID id2 ): image1( id1, Gtk::ICON_SIZE_BUTTON ),image2( id2, Gtk::ICON_SIZE_BUTTON ){ set_relief( Gtk::RELIEF_NONE ); add( image1 ); image1.show_all(); image2.show_all();}void IconToggleButton::on_toggled(){ if( get_active() ){ remove(); add( image2 );// image1.show_all(); } else{ remove(); add( image1 );// image2.show_all(); } Gtk::ToggleButton::on_toggled();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -