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

📄 sipcall.cpp

📁 kphone-4.2,SHELL协议的VOIP电话
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	    authstate == authState_AuthenticationRequiredWithNewPassword ) ) {		if( authtype == ProxyDigestAuthenticationRequired ) {			proxyauthresponse = Sip::getDigestResponse(				username, password, "INVITE", getContactUri().uri(), proxyauthstr );		} else if( authtype == ProxyBasicAuthenticationRequired ) {			proxyauthresponse = Sip::getBasicResponse( username, password );		}		local = call->newRequest( this, Sip::INVITE, localsessiondesc, localsessiontype,			SipUri::null, proxyauthresponse, localExpiresTime );	} else {		local = call->newRequest( this, Sip::INVITE, localsessiondesc, localsessiontype,			SipUri::null, QString::null, localExpiresTime );	}	if( localExpiresTime > 0 ) {		timer->start( localExpiresTime * 900, TRUE );	}	if( local ) {		op = opRequest;		if( authstate == authState_AuthenticationRequired ||		    authstate == authState_AuthenticationRequiredWithNewPassword ) {			authstate = authState_AuthenticationTryingWithPassword;		} else {			authstate = authState_AuthenticationTrying;		}		connect( local, SIGNAL( statusUpdated() ), this, SLOT( localStatusUpdated() ) );	}}void SipCallMember::requestAuthInvite( void ){	statusUpdated( this );}void SipCallMember::handlingInviteResponse( void ){	QString authstrtemp;	if( state == state_Connected ) {		if( local->getStatus().getCode() >= 200 ) {			if( local->getStatus().getCode() == 200 ) {				statusdesc = tr("Response: ") + tr(local->getStatus().getReasonPhrase());				statusUpdated( this );			} else if( local->getStatus().getCode() == 407 ) {				proxyauthstr = local->getFinalProxyAuthString();				authstrtemp = proxyauthstr.lower();				if( authstrtemp.contains( "digest" ) ) {					authtype = ProxyDigestAuthenticationRequired;				} else {					authtype = ProxyBasicAuthenticationRequired;				} 				requestAuthInvite();				return;			} else {				state = state_Disconnected;				statusdesc = tr("Response: ") + tr(local->getStatus().getReasonPhrase());			}			op = opIdle;			local = 0;		}	} else if( state == state_Disconnecting ) {		if( local->getStatus().getCode() >= 200 ) {			if( local->getStatus().getCode() == 407 ) {				proxyauthstr = local->getFinalProxyAuthString();				authstrtemp = proxyauthstr.lower();				if( authstrtemp.contains( "digest" ) ) {					authtype = ProxyDigestAuthenticationRequired;				} else {					authtype = ProxyBasicAuthenticationRequired;				} 				requestDisconnect();				return;			} else {				state = state_Disconnected;				statusdesc = tr("Response: ") + tr(local->getStatus().getReasonPhrase());			}			op = opIdle;			local = 0;		}	} else if( state == state_CancelPending ) {		if( local->getStatus().getCode() == 200 ) {			local = 0;			requestDisconnect();		} else if( local->getStatus().getCode() > 100 ) {			local->cancelRequest();			local = 0;		}		state = state_Disconnected;	} else {		if( local->wasCancelled() ) {			state = state_Disconnected;			op = opIdle;			local = 0;		} else if( local->getStatus().getCode() >= 200 ) {  // final response			if( local->getStatus().getCode() < 300 ) {				call->setCallStatus( SipCall::callInProgress );				state = state_Connected;				statusdesc = tr("Connected: ") + tr(local->getStatus().getReasonPhrase());			} else if( local->getStatus().getCode() < 400 ) {				state = state_Redirected;				statusdesc = tr("Redirected: ") + tr(local->getStatus().getReasonPhrase());				redirectlist = local->getFinalContactList();			} else {				if(local->getStatus().getCode() == 407){					proxyauthstr = local->getFinalProxyAuthString();					authstrtemp = proxyauthstr.lower();					if( authstrtemp.contains( "digest" ) ) {						authtype = ProxyDigestAuthenticationRequired;					} else {						authtype = ProxyBasicAuthenticationRequired;					}					if( authstate == authState_AuthenticationTryingWithPassword ||					    authstate == authState_AuthenticationRequiredWithNewPassword ) {						authstate = authState_AuthenticationRequiredWithNewPassword;					} else {						authstate = authState_AuthenticationRequired;					}					requestAuthInvite();					return;				} else {					state = state_Disconnected;					statusdesc = "!!" + tr("Call Failed: ") + tr(local->getStatus().getReasonPhrase());				}			}			op = opIdle;			local = 0;		} else {			statusdesc = tr(local->getStatus().getReasonPhrase());			if( local->getStatus().getCode() != 100 ) {				state = state_EarlyDialog;			}		}	}}// Byevoid SipCallMember::requestDisconnect( void ){	if( local ) {		local->cancelRequest();		disconnect( local, 0, this, 0 );	}	state = state_Disconnecting;	statusdesc = tr("Disconnecting");	local = call->newRequest( this, Sip::BYE );	if( local ) {		connect( local, SIGNAL( statusUpdated() ), this, SLOT( localStatusUpdated() ) );	}}void SipCallMember::requestTransfer( const SipUri &transferto,	const QString &body, const MimeContentType &bodytype ){	if( state == state_Disconnected ) return;	state = state_Disconnecting;	statusdesc = tr("Transfering");	local = call->newRequest( this, Sip::REFER, body, bodytype, transferto );	connect( local, SIGNAL( statusUpdated() ), this, SLOT( localStatusUpdated() ) );	state = state_Disconnecting;	statusdesc = tr("Disconnecting");	local = call->newRequest( this, Sip::BYE );	if( local ) {		connect( local, SIGNAL( statusUpdated() ), this, SLOT( localStatusUpdated() ) );	}	statusUpdated( this );}void SipCallMember::requestOptions( const QString &body, const MimeContentType &bodytype ){	if( local ) {		local->cancelRequest();		disconnect( local, 0, this, 0 );	}	statusdesc = tr("Querying options");	local = call->newRequest( this, Sip::OPTIONS, body, bodytype );	connect( local, SIGNAL( statusUpdated() ), this, SLOT( localStatusUpdated() ) );	statusUpdated( this );}void SipCallMember::acceptInvite( const QString &body, const MimeContentType &bodytype ){	if( !remote ) return;	if( body != QString::null ) {		localsessiondesc = body;		localsessiontype = bodytype;	}	remote->sendResponse( SipStatus( 200 ), body, bodytype );	state = state_Connected;	statusdesc = "Connected";	statusUpdated( this );	call->setCallStatus( SipCall::callInProgress );}void SipCallMember::notAcceptableHere( void ){	if( !remote ) return;	remote->sendResponse( SipStatus( 488 ) );	state = state_Disconnected;	statusdesc = "Not Acceptable Here";	statusUpdated( this );}void SipCallMember::declineInvite( const QString &body, const MimeContentType &bodytype ){	if( !remote ) return;	remote->sendResponse( SipStatus( 603 ), body, bodytype );	state = state_Disconnected;	statusdesc = "Rejecting call invitation";	statusUpdated( this );}void SipCallMember::localStatusUpdated( void ){	QString authstrtemp;	MimeContentType mtype;	SipStatus sipstatus;	if( !local ) {		printf( "SipCallMember: Received what was likely a retransmission, badly ignoring...\n" );		return;	}	printf( "SipCallMember: localStatusUpdated: %d\n", local->getStatus().getCode() );	mtype = local->getFinalContentType();	if( mtype == MimeContentType( "application/sdp" ) ) {		sessiondesc = local->getFinalMessageBody();		localsessiontype = mtype;	} else {		recentbody = local->getFinalMessageBody();		recentbodytype = mtype;	}	if( callMemberType == Invite ) {		handlingInviteResponse();	} else if( callMemberType == Message ) {		handlingMessageResponse();	} else if( callMemberType == Subscribe ) {		handlingSubscribeResponse();	} else if( callMemberType == Notify ) {		handlingNotifyResponse();	} else {		return;	}	statusUpdated( this );}void SipCallMember::incomingTransaction( SipTransaction *newtrans ){	MimeContentType mtype;	remote = newtrans;	if( remote->getRequest()->getMethod() == Sip::INVITE ) {		connect( remote, SIGNAL( statusUpdated() ), this, SLOT( remoteStatusUpdated() ) );		if( state == state_Disconnected ) {			state = state_RequestingInvite;			statusdesc = "Invitation received";			remote->sendResponse( SipStatus( 180 )); 		} else {			state = state_RequestingReInvite;			statusdesc = "Session update requested";		}		mtype = remote->getRequestMessageContentType();		if( mtype == MimeContentType( "application/sdp" ) ) {			sessiontype = mtype;			sessiondesc = remote->getRequestMessageBody();		} else {			recentbodytype = mtype;			recentbody = remote->getRequestMessageBody();		}	} else if( remote->getRequest()->getMethod() == Sip::BYE ) {		state = state_Disconnected;		statusdesc = "Remote end disconnected";		call->hideCallWidget();	} else if( remote->getRequest()->getMethod() == Sip::REFER ) {		if( state == state_Refer ) {			printf( "SipCallMember: Received what was likely a retransmission, badly ignoring...\n" );			return;		}		remote->sendResponse( SipStatus( 202 ) );		state = state_Refer;		statusdesc = "Refer";		redirectlist = SipUriList( remote->getRequest()->getHeaderData( SipHeader::Refer_To ) );	}	statusUpdated( this );}void SipCallMember::remoteStatusUpdated( void ){	if( state == state_RequestingInvite ) {		if( remote->wasCancelled() ) {			state = state_Disconnected;			statusdesc = "Request cancelled";			statusUpdated( this );		}	}}void SipCallMember::cancelTransaction( void ){	if( local ) {		if( state == state_EarlyDialog ) {			local->cancelRequest();			state = state_Disconnected;		} else {			state = state_CancelPending;		}	}}QString SipCallMember::getSubject( void ){	return call->getSubject();}void SipCallMember::call_timeout(){	if( call->getCallType() == SipCall::outSubscribeCall ) {		requestSubscribe();	} else if( call->getCallType() == SipCall::inSubscribeCall ) {		contactUpdate( false );	};}void SipCallMember::contactUpdate( bool active, QString presence ){	call->setPresenceStatus( presence );	if( active ) {		call->setCallStatus( SipCall::callInProgress );	} else {		if( call->getCallStatus() != SipCall::callDead ) {			call->setCallStatus( SipCall::callUnconnected );		}		memberuri.setTag( QString::null );	}	statusUpdated( this );}void SipCallMember::timerStart( int time ){	timer->start( time );}//------------------------------//           SipCall//------------------------------SipCall::SipCall( SipUser *local, const QString &id, SipCall::CallType ctype ){	callstatus = callUnconnected;	if ( id == QString::null ) {		callid = SipMessage::createCallId();	} else {		callid = id;	}	// Remember to nuke all members and transactions	members.setAutoDelete( true );	transactions.setAutoDelete( true );	struct timeval tv;	gettimeofday( &tv, NULL );	srand( tv.tv_usec );	lastseq = rand() % 8000;	parent = local->parent();	calltype = ctype;	hasroute = false;	localuri = local->getUri();	localuri.generateTag();	parent->addCall( this );	presenceStatus = "";	bodyMask = QString::null;	contactstr = "";	hasrecordroute = false;}SipCall::~SipCall( void )

⌨️ 快捷键说明

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