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

📄 sipdialogmanagement.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-5 * * Authors: Cesc Santasusana <cesc dot santa at gmail dot com>*//* Name * 	SipDialogManagement.h * Author * 	Cesc Santasusana <cesc dot santa at gmail dot com> * Purpose * 	Control exhisting dialogs in the sip stack and perform *		operations on them.*/#include<config.h>#include<libmsip/SipDialogManagement.h>#ifdef DEBUG_OUTPUT#include<libmutil/dbg.h>#endif//#include<libmsip/SipDialogContainer.h>#include<libmsip/SipCommandString.h>#include<libmsip/SipSMCommand.h>#include<libmsip/SipTransactionUtils.h>using namespace std;//all timeouts in miliseconds, please//the max total time it will take to shutdown (given you come up with problems),//it is SHUTDOWN_CALLS_TIMEOUT + SHUTDOWN_DEREGISTER_TIMEOUT. Pick these values //adequately to fit your needs.#define SHUTDOWN_CALLS_TIMEOUT 3000 #define SHUTDOWN_DEREGISTER_TIMEOUT 3000 //START OF SHUTDOWN RELATED FUNCTIONSbool SipDialogManagement::a0_start_startShutdown_startShutdown( const SipSMCommand &command) {	bool ret = false;	if (transitionMatch(command, 				SipCommandString::sip_stack_shutdown,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer)) {		pendingHangUps = pendingDeRegs = 0;		merr << end;		merr << "MiniSIP's SipStack is shutting down ... " << end;		merr << "     ... it won't take long to finish, be patient. Thanks!" << end;		SipSMCommand cmd( CommandString( "", SipCommandString::terminate_all_calls),			SipSMCommand::dispatcher,			SipSMCommand::dispatcher);		sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/);		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::a10_startSh_terminateCallsSh_terminateAll( const SipSMCommand &command) {	bool ret = false;	if (transitionMatch(command, 				SipCommandString::terminate_all_calls,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer)) {		terminateAllCalls();		requestTimeout( SHUTDOWN_CALLS_TIMEOUT, "timer_terminate_calls" );		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::a11_terminateCallsSh_callTerminatedEarly( const SipSMCommand &command) {	bool ret = false;	if (transitionMatch(command, 				SipCommandString::call_terminated_early,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {		receivedCallTerminateEarly();		//mdbg << "shutdown: call terminated early: " << command.getCommandString().getDestinationId() << end;			ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::a12_terminateCallsSh_timeIsUp( const SipSMCommand &command) {	bool ret = false;	if (transitionMatch(command, 				"timer_terminate_calls",				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {				SipSMCommand cmd( CommandString( "", SipCommandString::unregister_all_identities),			SipSMCommand::dispatcher,			SipSMCommand::dispatcher);		sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/);		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::a13_terminateCallsSh_allTerminated( const SipSMCommand &command) {	bool ret = false;	if (transitionMatch(command, 				SipCommandString::terminate_all_calls_done,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {				cancelTimeout( "timer_terminate_calls" );		SipSMCommand cmd( CommandString( "", SipCommandString::unregister_all_identities),			SipSMCommand::dispatcher,			SipSMCommand::dispatcher);		sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/);		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::a20_terminateCallsSh_deRegAllSh_allTerminated( const SipSMCommand &command) {	bool ret = false;	if (transitionMatch(command, 				SipCommandString::unregister_all_identities,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {		requestTimeout( SHUTDOWN_DEREGISTER_TIMEOUT, "timer_deRegisterAll" );		deRegisterAll();		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::a21_deRegAllSh_callTerminatedEarly( const SipSMCommand &command) {	bool ret = false;	if (transitionMatch(command, 				SipCommandString::call_terminated_early,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {		receivedCallTerminateEarly();		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::a22_deRegAllSh_registerOk( const SipSMCommand &command) {	bool ret = false;	if (transitionMatch(command, 				SipCommandString::register_ok,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {				receivedRegisterOk(true); //we are deregistering ...		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::a23_deRegAllSh_timeIsUp( const SipSMCommand &command) {	bool ret = false;	if (transitionMatch(command, 				"timer_deRegisterAll",				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {				shutdownDone( true ); //force shutdown done message		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::a24_deRegAllSh_deRegAlldone( const SipSMCommand &command) {	bool ret = false;	if (transitionMatch(command, 				SipCommandString::unregister_all_identities_done,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {				shutdownDone( false ); //check if finished ... don't force		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::a25_deRegAllSh_allTerminated( const SipSMCommand &command) {	bool ret = false;	if (transitionMatch(command, 				SipCommandString::terminate_all_calls_done,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {				shutdownDone( false ); //check if finished ... don't force		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::a30_deRegAllSh_terminated_timeIsUp( const SipSMCommand &command) {	//This transition is quite useless ... sip stack is finished anyway and this	//"dialog" ain't going anyway, be in terminated or not.	//But we do it anyway.	bool ret = false;	if (transitionMatch(command, 				SipCommandString::sip_stack_shutdown_done,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {		ret = true;	} else {		ret = false;	}	return ret;}//END OF SHUTDOWN RELATED FUNCTIONS//START OF CALLS TERMINATION RELATED FUNCTIONSbool SipDialogManagement::b0_start_terminateCallsOps_terminateAll( const SipSMCommand &command){	bool ret = false;	if (transitionMatch(command, 				SipCommandString::terminate_all_calls,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer)) {				pendingHangUps = pendingDeRegs = 0;		terminateAllCalls();		requestTimeout( SHUTDOWN_CALLS_TIMEOUT, "timer_terminate_calls" );		ret = true;	} else {		ret = false;	}	return ret;} bool SipDialogManagement::b11_terminateCallsOps_terminateEarly( const SipSMCommand &command){	bool ret = false;	if (transitionMatch(command, 				SipCommandString::call_terminated_early,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {		receivedCallTerminateEarly();		//mdbg << "shutdown: call terminated early: " << command.getCommandString().getDestinationId() << end;			ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::b12_terminateCallsOps_timeIsUp( const SipSMCommand &command){ 	bool ret = false;	if (transitionMatch(command, 				"timer_terminate_calls",				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {				SipSMCommand cmd( CommandString( "", SipCommandString::unregister_all_identities),			SipSMCommand::dispatcher,			SipSMCommand::dispatcher);		sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/);		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::b30_terminateCallsOps_start_terminateAllDone( const SipSMCommand &command){	bool ret = false;	if (transitionMatch(command, 				SipCommandString::terminate_all_calls_done,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {		cancelTimeout( "timer_terminate_calls" );		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::c0_start_deRegAllOps_deRegAll( const SipSMCommand &command){	bool ret = false;	if (transitionMatch(command, 				SipCommandString::unregister_all_identities,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {		pendingHangUps = pendingDeRegs = 0;		requestTimeout( SHUTDOWN_DEREGISTER_TIMEOUT, "timer_deRegisterAll" );		deRegisterAll();		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::c11_deRegAllOps_registerOk( const SipSMCommand &command){	bool ret = false;	if (transitionMatch(command, 				SipCommandString::register_ok,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {		receivedRegisterOk(true); //we are deregistering ...		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::c12_deRegAllOps_timeIsUp( const SipSMCommand &command){	bool ret = false;	if (transitionMatch(command, 				"timer_deRegisterAll",				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::c30_deRegAllOps_start_deRegAllDone( const SipSMCommand &command){	bool ret = false;	if (transitionMatch(command, 				SipCommandString::unregister_all_identities_done,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {		cancelTimeout( "timer_deRegisterAll" );		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::d0_start_regAllOps_regAll( const SipSMCommand &command){	bool ret = false;	if (transitionMatch(command, 				SipCommandString::register_all_identities,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {		pendingHangUps = pendingDeRegs = 0;		requestTimeout( SHUTDOWN_DEREGISTER_TIMEOUT, "timer_registerAll" );		registerAll();		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::d11_regAllOps_registerOk( const SipSMCommand &command){	bool ret = false;	if (transitionMatch(command, 				SipCommandString::register_ok,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {		receivedRegisterOk(false); //we are NOT deregistering ...		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::d12_regAllOps_timeIsUp( const SipSMCommand &command){	bool ret = false;	if (transitionMatch(command, 				"timer_registerAll",				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {		ret = true;	} else {		ret = false;	}	return ret;}bool SipDialogManagement::d30_regAllOps_start_regAllDone( const SipSMCommand &command){	bool ret = false;	if (transitionMatch(command, 				SipCommandString::register_all_identities_done,				SipSMCommand::dispatcher,				SipSMCommand::dialog_layer) ) {		cancelTimeout( "timer_registerAll" );		ret = true;	} else {		ret = false;	}	return ret;}//END OF CALLS/REGISTER RELATED FUNCTIONS

⌨️ 快捷键说明

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