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

📄 chxclientcontext.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		char* pURLWithQuery = new char[ origURLLength + kQueryStringMaxLength + 1 ];		if ( pURLWithQuery )		{			strcpy( pURLWithQuery, pURL );			INT32 copyIndex = origURLLength;			char concatChar = ( !strstr( pURLWithQuery, "?" ) ) ? '?' : '&';			sprintf( &pURLWithQuery[ copyIndex ], "%c%s%s", concatChar, "rptarget=", kContextPaneTarget );			copyIndex += strlen( &pURLWithQuery[ copyIndex ] );			if ( pParams )			{				if ( SUCCEEDED( pParams->GetPropertyCString( "width", *spBuffer.AsInOutParam() ) ) )				{					sprintf( &pURLWithQuery[ copyIndex ], "&%s%s", "rpcontextwidth=", ( const char* ) spBuffer->GetBuffer() );					copyIndex += strlen( &pURLWithQuery[ copyIndex ] );				}				if ( SUCCEEDED( pParams->GetPropertyCString( "height", *spBuffer.AsInOutParam() ) ) )				{					sprintf( &pURLWithQuery[ copyIndex ], "&%s%s", "rpcontextheight=", ( const char* ) spBuffer->GetBuffer() );					copyIndex += strlen( &pURLWithQuery[ copyIndex ] );				}			}			pURLWithQuery[ copyIndex ] = '\0';			bool handled = CallGoToURLCallback( pURLWithQuery, NULL );			delete [] pURLWithQuery;			return handled ? HXR_OK : HXR_NOTIMPL;		}	}	bool handled = CallGoToURLCallback( pURL, pTargetInstance );	return handled ? HXR_OK : HXR_NOTIMPL;}STDMETHODIMPCHXClientContext::ExecuteWithContext( const char* pURL,									  const char* pTargetInstance,									  const char* pTargetApplication,									  const char* pTargetRegion,									  IHXValues*  pParams,									  IUnknown*   pContext ){	return Execute( pURL, pTargetInstance, pTargetApplication, pTargetRegion, pParams );}/* STDMETHODIMPCHXClientContext::OnNewRequest( IHXRequest* pNewRequest ){	if ( !pNewRequest ) return HXR_INVALID_PARAMETER;		const char* pURL = NULL;	pNewRequest->GetURL( pURL );		return HXR_OK;} */STDMETHODIMPCHXClientContext::RequestUpgrade( IHXUpgradeCollection* pComponents, HXBOOL bBlocking ){	m_hasRequestedUpgrade = true;		if ( !pComponents ) return HXR_INVALID_PARAMETER;	if ( !m_pClientCallbacks->RequestUpgrade ) return HXR_FAIL;	UINT32 numOfComponents = pComponents->GetCount();	if ( numOfComponents <= 0 ) return HXR_INVALID_PARAMETER;		char** componentNames = new char*[ numOfComponents ];	if ( !componentNames ) return HXR_OUTOFMEMORY;		HX_RESULT outResult = HXR_CANCELLED;		char* pURL = NULL;	SPIHXPlayer spIPlayer;	m_pClientPlayer->GetHXPlayer( spIPlayer.AsInOutParam() );	UINT16 sourceCount = spIPlayer.IsValid() ? spIPlayer->GetSourceCount() : 0;	if ( sourceCount > 0 )	{		// Get the last source's URL. This avoids getting the .ram URL when the first URL in the .ram triggers the Upgrade request.		SPIUnknown spUnkSource;		spIPlayer->GetSource( ( sourceCount - 1 ), *spUnkSource.AsInOutParam() );		SPIHXStreamSource spStreamSource = spUnkSource.Ptr();		if ( spStreamSource.IsValid() )		{			const char* pURLToCopy = spStreamSource->GetURL();						// Does this URL have a valid protocol? SDP files, for example, return "helix-sdp:<file contents>" in GetURL().			const char* pProtocolDelims = NULL;			if ( ( NULL != ( pProtocolDelims = strstr( pURLToCopy, "://" ) ) ) &&				 ( ( pProtocolDelims - pURLToCopy ) <= 5 ) ) // Maximum protocol length based on "https://"			{				pURL = new char[ strlen( pURLToCopy ) + 1 ];				if ( pURL )				{					strcpy( pURL, pURLToCopy );				}			}		}	}	if ( !pURL )	{		SPIHXPlayer2 spIPlayer2 = spIPlayer.Ptr();		if ( spIPlayer2.IsValid() )		{			SPIHXRequest spIRequest;			if ( SUCCEEDED( spIPlayer2->GetRequest( *spIRequest.AsInOutParam() ) ) && spIRequest.IsValid() )			{				const char* pURLToCopy = NULL;				if ( SUCCEEDED( spIRequest->GetURL( pURLToCopy ) ) && pURLToCopy && *pURLToCopy )				{					pURL = new char[ strlen( pURLToCopy ) + 1 ];					if ( pURL )					{						strcpy( pURL, pURLToCopy );					}				}			}		}	}	// XXXSEH: Do we need to add in StripOffPrefixes() support as found in upgrdlib/cupgradelogicshell.cpp?	HXUpgradeType upgradeType;	UINT32 majorVersion, minorVersion;	UINT32 index;	UINT32 numOfComponentsToUpgrade = 0;		for ( index = 0; index < numOfComponents; ++index )	{		SPIHXBuffer spPluginId = new CHXClientBuffer;		pComponents->GetAt( index, upgradeType, spPluginId.Ptr(), majorVersion, minorVersion );		UINT32 sizeOfComponentName = spPluginId->GetSize();		if ( ( sizeOfComponentName > 0 ) && ( NULL != spPluginId->GetBuffer() ) )		{			componentNames[ index ] = new char[ sizeOfComponentName ];			if ( !componentNames[ index ] )			{				// outResult = HXR_OUTOFMEMORY; XXXSEH: Don't know that we need to pass this info. on?				goto bail;			}			memcpy( componentNames[ index ], spPluginId->GetBuffer(), sizeOfComponentName );			++numOfComponentsToUpgrade;		}	}	if ( ( numOfComponentsToUpgrade > 0 ) &&		 m_pClientCallbacks->RequestUpgrade( m_UserInfo, pURL, numOfComponentsToUpgrade, ( const char** ) componentNames, ( ( 0 != bBlocking ) ? true : false ) ) )	{		outResult = HXR_OK;	}	bail:	delete [] pURL;		for ( index = 0; index < numOfComponentsToUpgrade; ++index )	{		delete [] componentNames[ index ];	}	delete [] componentNames;		return outResult;}STDMETHODIMPCHXClientContext::HasComponents( IHXUpgradeCollection* pComponents ){	if ( !pComponents ) return HXR_INVALID_PARAMETER;	if ( !m_pClientCallbacks->HasComponent ) return HXR_FAIL;	UINT32 numOfComponents = pComponents->GetCount();	if ( numOfComponents <= 0 ) return HXR_INVALID_PARAMETER;		HXUpgradeType upgradeType;	UINT32 majorVersion, minorVersion;	UINT32 index = numOfComponents;	do	{		--index;				SPIHXBuffer spPluginId = new CHXClientBuffer;		pComponents->GetAt( index, upgradeType, spPluginId.Ptr(), majorVersion, minorVersion );		if ( ( NULL == spPluginId->GetBuffer() ) ||			 m_pClientCallbacks->HasComponent( m_UserInfo, ( const char* ) spPluginId->GetBuffer() ) )		{			pComponents->Remove( index );		}	}	while( index > 0 );		numOfComponents = pComponents->GetCount();	return ( numOfComponents > 0 ) ? HXR_FAIL : HXR_OK;}STDMETHODIMPCHXClientContext::SetStatus( const char* pText ){	if ( m_pClientCallbacks->OnStatusChanged )	{		m_pClientCallbacks->OnStatusChanged( m_UserInfo, pText );	}	return HXR_OK; // What does the return value mean?}STDMETHODIMPCHXClientContext::HandleAuthenticationRequest( IHXAuthenticationManagerResponse* pResponse ){	return HandleAuthenticationRequest2( pResponse, NULL );}STDMETHODIMPCHXClientContext::HandleAuthenticationRequest2( IHXAuthenticationManagerResponse* pResponse, IHXValues* pHeader ){	if ( !pResponse ) return HXR_INVALID_PARAMETER;	if ( !m_pClientCallbacks->RequestAuthentication ) return pResponse->AuthenticationRequestDone( HXR_NOT_AUTHORIZED, NULL, NULL );		bool isProxyServer = false;	SPIHXBuffer spServer, spRealm;	if ( pHeader )	{		SPIHXBuffer spBuffer;		isProxyServer = ( FAILED( pHeader->GetPropertyCString( SERVER_AUTHENTICATE_HEADER, *spBuffer.AsInOutParam() ) ) &&						  SUCCEEDED( pHeader->GetPropertyCString( PROXY_AUTHENTICATE_HEADER, *spBuffer.AsInOutParam() ) ) );				( void ) pHeader->GetPropertyCString( SERVER_HEADER, *spServer.AsInOutParam() );		( void ) pHeader->GetPropertyCString( REALM_HEADER, *spRealm.AsInOutParam() );	}	const char* pServer = spServer.IsValid() ? ( char* ) spServer->GetBuffer() : NULL;	const char* pRealm  = spRealm.IsValid()  ? ( char* ) spRealm->GetBuffer()  : NULL;		m_spPendingAuthManagerResponse = pResponse;	if ( m_pClientCallbacks->RequestAuthentication( m_UserInfo, pServer, pRealm, isProxyServer ) )	{		return HXR_OK;	}	else	{		m_spPendingAuthManagerResponse.Clear();		return pResponse->AuthenticationRequestDone( HXR_NOT_AUTHORIZED, NULL, NULL );	}}HX_RESULTCHXClientContext::Authenticate( bool shouldValidateUser, const char* pUsername, const char* pPassword ){	if ( !m_spPendingAuthManagerResponse.IsValid() ) return HXR_UNEXPECTED;		SPIHXAuthenticationManagerResponse spResponse = m_spPendingAuthManagerResponse.Ptr();	m_spPendingAuthManagerResponse.Clear();		return shouldValidateUser ?		   spResponse->AuthenticationRequestDone( HXR_OK, pUsername, pPassword ) :		   spResponse->AuthenticationRequestDone( HXR_NOT_AUTHORIZED, NULL, NULL );}

⌨️ 快捷键说明

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