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

📄 plghand2.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
#if !defined(HELIX_CONFIG_NOSTATICS)    /* Check to see if we wish to use the 'faster' prefs.     * This means using VERY long strings to store the     * plugin information. Windows supports this but     * discourages the practice.     */    IHXBuffer* pBuffer = NULL;    if (m_pPreferences)    {        if (ReadPrefBOOL(m_pPreferences, "UseFasterPref", zm_bFasterPrefs) != HXR_OK)        {#if !defined (_WINCE)            zm_bFasterPrefs = TRUE;#else            zm_bFasterPrefs = FALSE;#endif        }    }#endif /* #if !defined(HELIX_CONFIG_NOSTATICS) */#endif /* HELIX_FEATURE_PREFERENCES */    return HXR_OK;}STDMETHODIMPPlugin2Handler::AddPluginMountPoint( const char* pName, UINT32 majorVersion, UINT32 minorVersion, IHXBuffer* pPath ){    HX_LOG_BLOCK( "Plugin2Handler::AddPluginMountPoint" );    const char* pMPKey = pName ? pName : (const char*) pPath->GetBuffer();    // Make sure this mount point is in the list    PluginMountPoint* pMountPoint = NULL;    if( !m_MountPoints.Lookup( pMPKey, (void*&) pMountPoint ) )    {	// Create new mount point	pMountPoint = new PluginMountPoint( this, pName, majorVersion, minorVersion, pPath );	pMountPoint->AddRef();	// Put new mount point in list	m_MountPoints.SetAt( pMPKey, pMountPoint );    }    // Increment client count    pMountPoint->AddClient();    // Load information from registry, and sync DLLs that aren't up to date    return RefreshPluginInfo( pMountPoint );}STDMETHODIMPPlugin2Handler::RefreshPluginMountPoint( const char* pName ){    HX_RESULT result = HXR_FAIL;    // If this mount point is in the list, refresh it    PluginMountPoint* pMountPoint = NULL;    if( m_MountPoints.Lookup( pName, (void*&) pMountPoint ) )    {	result = RefreshPluginInfo( pMountPoint );    }    return result;}STDMETHODIMPPlugin2Handler::RemovePluginMountPoint( const char* pName ){    HX_RESULT result = HXR_FAIL;    // Make sure this is a valid mount point    PluginMountPoint* pMountPoint = NULL;    if( m_MountPoints.Lookup( pName, (void*&) pMountPoint ) )    {	// If this was the last client, do the clean up stuff	if( !pMountPoint->RemoveClient() )	{	    // Clean up plugins	    if( m_PluginList.GetCount() )	    {		LISTPOSITION listPos = m_PluginList.GetHeadPosition();		while( listPos )		{		    // Save off current position for delete		    LISTPOSITION posAt = listPos;		    // Get current item, and increment position		    Plugin2Handler::Plugin* pPlugin = (Plugin2Handler::Plugin*) m_PluginList.GetNext( listPos );		    // If this plugin belongs to the mountpoint, remove it.		    if( pPlugin && ( pPlugin->GetDLL()->GetMountPoint() == pMountPoint ) )		    {			// Remove plugin from indices			RemovePluginFromIndices( pPlugin );			// Delete from the saved position			m_PluginList.RemoveAt( posAt );			HX_RELEASE( pPlugin );		    }		}	    }	    // Clean up dlls	    if (m_PluginDLLList.GetCount())	    {		LISTPOSITION listPos = m_PluginDLLList.GetHeadPosition();		while( listPos )		{		    // Save off current position for delete		    LISTPOSITION posAt = listPos;		    // Get current item, and increment position		    Plugin2Handler::PluginDLL* pPluginDLL = (Plugin2Handler::PluginDLL*) m_PluginDLLList.GetNext( listPos );		    // If this plugin belongs to the mountpoint, remove it.		    if( pPluginDLL && ( pPluginDLL->GetMountPoint() == pMountPoint ) )		    {			// Remove from filename map			IHXBuffer* pBuffer = pPluginDLL->GetFileName();			m_FileNameMap.RemoveKey( (char*) pBuffer->GetBuffer() );			HX_RELEASE( pBuffer );			// Remove from the LRU			RemoveFromLRU(pPluginDLL);			// Delete from the saved position			m_PluginDLLList.RemoveAt( posAt );			HX_RELEASE( pPluginDLL );		    }		}	    }	    // Clean up OtherDLL	    if (m_MiscDLLList.GetCount())	    {		LISTPOSITION listPos = m_MiscDLLList.GetHeadPosition();		while( listPos )		{		    // Save off current position for delete		    LISTPOSITION posAt = listPos;		    // Get current item, and increment position		    Plugin2Handler::OtherDLL* pOtherDLL = (Plugin2Handler::OtherDLL*) m_MiscDLLList.GetNext( listPos );		    // If this plugin belongs to the mountpoint, remove it.		    if( pOtherDLL && ( pOtherDLL->m_pMountPoint == pMountPoint ) )		    {			// Delete from the saved position			m_MiscDLLList.RemoveAt( posAt );			HX_DELETE( pOtherDLL );		    }		}	    }	    // Clean up supported GUIDs	    if (m_GUIDtoSupportList.GetCount())	    {		CHXMapStringToOb::Iterator k;		for(k = m_GUIDtoSupportList.Begin(); k!=m_GUIDtoSupportList.End(); ++k)		{		    CHXSimpleList* pSupportedList = (CHXSimpleList*) *k;		    LISTPOSITION listPos = pSupportedList->GetHeadPosition();		    while( listPos )		    {			// Save off current position for delete			LISTPOSITION posAt = listPos;			// Get current item, and increment position			PluginSupportingGUID* pSupportItem = (PluginSupportingGUID*) pSupportedList->GetNext( listPos );			// If this plugin belongs to the mountpoint, remove it.			if( pSupportItem && ( pSupportItem->m_pMountPoint == pMountPoint ) )			{			    // Delete from the saved position			    pSupportedList->RemoveAt( posAt );			    HX_DELETE( pSupportItem );			}		    }		    // XXXND Remove the list from m_GUIDtoSupportList if it's empty		}	    }	    // Remove mount point from list	    m_MountPoints.RemoveKey( pName );            if (pMountPoint)            {                pMountPoint->Release();                pMountPoint = NULL;            }	}    }    return result;}STDMETHODIMPPlugin2Handler::FindImplementationFromClassID( REFGUID GUIDClassID, REF(IUnknown*) pIUnknownInstance,						IUnknown* pIUnkOuter, IUnknown* pContext ){    // Look though the Component plugins    HX_RESULT result = HXR_FAIL;    if( FAILED( result = CreatePluginViaIndex( PLUGIN_COMPONENT_CLSID, &GUIDClassID, &pIUnknownInstance, pIUnkOuter ) ) )    {	// XXXND FIX Try doing a manual lookup (FindPluginUsingValues)	// Couldn't find it with the new method, try the old one.	result = FindImplementationFromClassIDInternal( GUIDClassID, pIUnknownInstance, pContext );    }    return result;}STDMETHODIMPPlugin2Handler::FindCLSIDFromName( const char* pName, REF(IHXBuffer*) pCLSID ){    HX_SETUP_CHECKPOINTLIST( "Plugin2Handler::FindCLSIDFromName()" );    HX_PRIME_ACCUMULATOR( 'idfn', "Looking up CLSID from name" );    HX_ACCUMULATE( 'idfc', "Number of CLSIDs looked up", 1 );    // Initialize out params    pCLSID = NULL;    HX_RESULT result = HXR_FAIL;    IHXValues* pIValues = NULL;    if( SUCCEEDED( FindPluginInfoViaIndex( PLUGIN_COMPONENT_NAME, (char*) pName, &pIValues ) ) )    {	pIValues->GetPropertyBuffer( PLUGIN_COMPONENT_CLSID, pCLSID );	HX_RELEASE( pIValues );	result = HXR_OK;    }    else    {	// XXXND  FIX  Try using FindPluginUsingString    }    HX_UPDATE_ACCUMULATOR( 'idfn' );    return result;}STDMETHODIMPPlugin2Handler::FindGroupOfPluginsUsingValues( IHXValues* pValues,				REF(IHXPluginSearchEnumerator*) pIEnumerator){    // Initialize out params    pIEnumerator = NULL;    // Use the internal function to build up an enumerator object    CPluginEnumerator* pEnumerator = NULL;    HX_RESULT result = FindGroupOfPluginsUsingValues( pValues, pEnumerator );    // If we have our enumerator, get the appropriate interface    if( SUCCEEDED( result ) )    {	result = pEnumerator->QueryInterface( IID_IHXPluginSearchEnumerator,						(void**) &pIEnumerator );    }    return result;}STDMETHODIMPPlugin2Handler::FindGroupOfPluginsUsingStrings( char* PropName1, char* PropVal1,				char* PropName2, char* PropVal2,				char* PropName3, char* PropVal3,				REF(IHXPluginSearchEnumerator*) pIEnumerator){    // Initialize out params    pIEnumerator = NULL;    // Use the internal function to build up an enumerator object    CPluginEnumerator* pEnumerator = NULL;    HX_RESULT result = FindGroupOfPluginsUsingStrings( PropName1, PropVal1,			    PropName2, PropVal2, PropName3, PropVal3, pEnumerator );    // If we have our enumerator, get the appropriate interface    if( SUCCEEDED( result ) )    {	result = pEnumerator->QueryInterface( IID_IHXPluginSearchEnumerator,						(void**) &pIEnumerator );    }    return result;}void Plugin2Handler::ReportError( UINT8 severity, const char* pDLLName, const char* pDesc ){    if (m_pErrorMessages)    {        int nErrorTempLength;	char *pErrorTemp;        nErrorTempLength = strlen(pDLLName) + strlen(pDesc) + 2;        pErrorTemp = new char[nErrorTempLength];        if(pErrorTemp)        {            SafeSprintf(pErrorTemp, nErrorTempLength, "%s %s", pDLLName, pDesc );            m_pErrorMessages->Report( severity, 0, 0, pErrorTemp, NULL );            delete [] pErrorTemp;        }        else        {            m_pErrorMessages->Report( HXLOG_ERR, HXR_OUTOFMEMORY, 0, NULL, NULL );        }    }}STDMETHODIMPPlugin2Handler::FindPluginUsingValues( IHXValues* pCriteria,					REF(IUnknown*) pIUnkResult,					IUnknown* pIUnkOuter ){    HX_SETUP_CHECKPOINTLIST( "Plugin2Handler::FindPluginUsingValues()" );    HX_PRIME_ACCUMULATOR( 'fpuv', "Plugin lookup with IHXValues" );    // Initialize out params    pIUnkResult = NULL;    CHXSimpleList   PossibleValues;    IHXValues*	    pPluginValues = NULL;    IHXBuffer*	    pBuffer = NULL;    CHXSimpleList::Iterator i = m_PluginList.Begin();    for(; i!= m_PluginList.End(); ++i)    {	Plugin2Handler::Plugin* pPlugin = (Plugin2Handler::Plugin*) *i;	if (pPlugin->DoesMatch(pCriteria))	{	    PossibleValues.AddTail(pPlugin);	}    }    HX_UPDATE_ACCUMULATOR( 'fpuv' );    if (PossibleValues.Begin() == PossibleValues.End())    {	pIUnkResult = 0;	return HXR_FAIL;    }    /****************************************************************    ** Presently when we arrive at this spot with more than one    ** plugin which matches the search criteria, we simply take    ** the first one found. If this is not satisfactory then    ** some method can be added which will process the list based    ** upon some criteria.    ****************************************************************/    // if there are multiple plugins found, we will pick the one whose    // plugin description contains "RealNetworks"    if (PossibleValues.GetCount() > 1)    {	for(i = PossibleValues.Begin(); i!= PossibleValues.End(); ++i)	{	    Plugin2Handler::Plugin* pPlugin = (Plugin2Handler::Plugin*) *i;	    if (HXR_OK == pPlugin->GetPluginInfo(pPluginValues) && pPluginValues)	    {		if (HXR_OK == pPluginValues->GetPropertyCString(PLUGIN_DESCRIPTION2, pBuffer) &&		    pBuffer)		{		    if (strstr((const char*)pBuffer->GetBuffer(), "RealNetworks"))		    {			HX_RELEASE(pBuffer);			if ( NO_ERRORS == pPlugin->GetInstance( pIUnkResult, pIUnkOuter ))			{			    return HXR_OK;			}			else			{			    return HXR_FAIL;			}		    }		}		HX_RELEASE(pBuffer);	    }	}    }    Plugin2Handler::Plugin* pPlug = (Plugin2Handler::Plugin*) *(PossibleValues.Begin());    Errors retVal = pPlug->GetInstance( pIUnkResult, pIUnkOuter );    return ( retVal == NO_ERRORS ) ? HXR_OK : HXR_FAIL;}STDMETHODIMPPlugin2Handler::FindPluginUsingStrings( char* PropName1, char* PropVal1,					char* PropName2, char* PropVal2,					char* PropName3, char* PropVal3,					REF(IUnknown*) pIUnkResult,					IUnknown* pIUnkOuter ){    // Initialize out params    pIUnkResult = NULL;    // PropName and PropVal have to to valid tuple    if ((PropName1 && !PropVal1)    ||	(PropName2 && !PropVal2)    ||	(PropName3 && !PropVal3)    ||	(!PropName1 && PropVal1)    ||	(!PropName2 && PropVal2)    ||	(!PropName3 && PropVal3))	return HXR_FAIL;    IHXValues* pValues;    HX_RESULT   retVal = HXR_FAIL;    CHXHeader* pHeader = new CHXHeader();    pHeader->QueryInterface(IID_IHXValues,  (void**)&pValues);    AddToValues(pValues, PropName1, PropVal1, eString);    AddToValues(pValues, PropName2, PropVal2, eString);    AddToValues(pValues, PropName3, PropVal3, eString);    retVal = FindPluginUsingValues( pValues, pIUnkResult, pIUnkOuter );    pValues->Release();    return retVal;}STDMETHODIMPPlugin2Handler::GetPlugin( ULONG32 ulIndex, REF(IUnknown*) pIUnkResult,					    IUnknown* pIUnkOuter ){    if( ulIndex <= (ULONG32)(m_PluginList.GetCount()-1) && m_PluginList.GetCount() )    {	LISTPOSITION pPos = m_PluginList.FindIndex( ulIndex );	if (pPos)	{	    Plugin2Handler::Plugin* pPlugin = (Plugin2Handler::Plugin*) m_PluginList.GetAt( pPos );	    if( pPlugin )	    {		if (NO_ERRORS == pPlugin->GetInstance( pIUnkResult, pIUnkOuter ))		{		    return HXR_OK;		}		else		{		    return HXR_FAIL;		}	    }	}    }    return HXR_FAIL;}

⌨️ 快捷键说明

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