📄 plghand2.cpp
字号:
} } } else { bRegIsDirty = TRUE; } } pszDllName = pFileFinder->FindNext(); } // now get the bandwidth data on all renderer plugins IHXValues* pVal = new CHXHeader(); pVal->AddRef(); IHXBuffer* pBuffer = new CHXBuffer(); pBuffer->AddRef(); pBuffer->Set((const UCHAR*)PLUGIN_RENDERER_TYPE, strlen(PLUGIN_RENDERER_TYPE)+1); pVal->SetPropertyCString(PLUGIN_CLASS, pBuffer); HX_RELEASE(pBuffer); for(CHXSimpleList::Iterator i = m_PluginList.Begin(); i!=m_PluginList.End(); ++i) { Plugin2Handler::Plugin* pPlug = (Plugin2Handler::Plugin*)*i; if (pPlug->DoesInfoNeedsRefresh() && pPlug->DoesMatch(pVal)) { pPlug->GetBandwidthInfo(); } } HX_RELEASE(pVal); if (bRegIsDirty) { // Pass the MountPoint to this so it can write the // specific plugins to the correct place WritePluginInfo( pMountPoint ); } HX_RELEASE(pPathBuffer); HX_DELETE(pFileFinder); return HXR_OK;}STDMETHODIMP Plugin2Handler::FindIndexUsingValues (IHXValues* pValues, REF(UINT32) unIndex){ CHXSimpleList PossibleValues; CHXSimpleList PossibleIndexes; UINT32 j = 0; IHXValues* pPluginValues = NULL; IHXBuffer* pBuffer = NULL; CHXSimpleList::Iterator i = m_PluginList.Begin(); for(; i!= m_PluginList.End(); ++i, j++) { Plugin2Handler::Plugin* pPlugin = (Plugin2Handler::Plugin*) *i; if (pPlugin->DoesMatch(pValues)) { PossibleValues.AddTail(pPlugin); PossibleIndexes.AddTail((void*)j); } } if (PossibleValues.Begin() == PossibleValues.End()) { unIndex = 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) { j = 0; for(i = PossibleValues.Begin(); i!= PossibleValues.End(); ++i, j++) { 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")) { LISTPOSITION pos = PossibleIndexes.FindIndex(j); unIndex = (UINT32)(PTR_INT)PossibleIndexes.GetAt(pos); HX_RELEASE(pBuffer); return HXR_OK; } } HX_RELEASE(pBuffer); } } } i = PossibleIndexes.Begin(); unIndex = (UINT32)(PTR_INT)*i; return HXR_OK;}STDMETHODIMP Plugin2Handler::GetInstance (UINT32 index, REF(IUnknown*) pUnknown){ pUnknown = NULL; LISTPOSITION pPos = m_PluginList.FindIndex(index); if (pPos) { Plugin2Handler::Plugin* pPlugin = (Plugin2Handler::Plugin*) m_PluginList.GetAt(pPos); if (pPlugin) { Errors retVal = pPlugin->GetInstance(pUnknown); if (retVal== NO_ERRORS) { return HXR_OK; } } } return HXR_FAIL;}STDMETHODIMP Plugin2Handler::FindIndexUsingStrings (char* PropName1, char* PropVal1, char* PropName2, char* PropVal2, char* PropName3, char* PropVal3, REF(UINT32) unIndex){ unIndex = 0; // 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 = FindIndexUsingValues(pValues, unIndex); pValues->Release(); return retVal;}STDMETHODIMP Plugin2Handler::FindPluginUsingValues (IHXValues* pValues, REF(IUnknown*) pUnk){ return FindPluginUsingValues( pValues, pUnk, NULL );}HX_RESULT Plugin2Handler::FindGroupOfPluginsUsingStrings(char* PropName1, char* PropVal1, char* PropName2, char* PropVal2, char* PropName3, char* PropVal3, REF(CPluginEnumerator*) pEnumerator){ // 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 = FindGroupOfPluginsUsingValues(pValues, pEnumerator); pValues->Release(); return retVal;}HX_RESULT Plugin2Handler::FindGroupOfPluginsUsingValues(IHXValues* pValues, REF(CPluginEnumerator*) pEnumerator){ CHXSimpleList::Iterator i = m_PluginList.Begin(); pEnumerator = NULL; for(; i!= m_PluginList.End(); ++i) { Plugin2Handler::Plugin* pPlugin = (Plugin2Handler::Plugin*) *i; if (pPlugin->DoesMatch(pValues)) { if (!pEnumerator) { pEnumerator = new CPluginEnumerator(); } pEnumerator->Add(pPlugin); } } if (!pEnumerator) { return HXR_FAIL; } return HXR_OK;}STDMETHODIMP Plugin2Handler::GetNumPluginsSupporting(REFIID iid, REF(UINT32) nNumPlugins){ CHXString sGUID; CHXSimpleList* pSupportList; CHXuuid::HXUuidToString( (uuid_tt*) &iid, &sGUID); if (!m_GUIDtoSupportList.Lookup(sGUID, (void*&)pSupportList)) { return HXR_FAIL; } nNumPlugins = pSupportList->GetCount(); return HXR_OK;}STDMETHODIMP Plugin2Handler::GetPluginIndexSupportingIID(REFIID iid, UINT32 nPluginIndex, REF(UINT32) nIndexOut){ CHXString sGUID; CHXSimpleList* pSupportList; CHXuuid::HXUuidToString( (uuid_tt*) &iid, &sGUID); if (m_GUIDtoSupportList.Lookup(sGUID, (void*&)pSupportList)) { if (nPluginIndex < (UINT32)pSupportList->GetCount()) { LISTPOSITION pPos = pSupportList->FindIndex(nPluginIndex); PluginSupportingGUID* pSupportItem = (PluginSupportingGUID*) pSupportList->GetAt(pPos); if (FindPlugin(pSupportItem ->m_filename, pSupportItem->m_nIndexInDLL, nIndexOut)) { return HXR_OK; } } } return HXR_FAIL;}STDMETHODIMP Plugin2Handler::AddSupportedIID(REFIID iid){ //1st scan to see if this GUID is already supported... CHXString sGUID; CHXSimpleList* pSupportList; CHXuuid::HXUuidToString( (uuid_tt*) &iid, &sGUID); if (m_GUIDtoSupportList.Lookup(sGUID, (void*&)pSupportList)) {#ifdef _MACINTOSH // the preferences are getting messed up on the mac. // so here we have to validate that the list of plugins we are about to // send over is valid. void* pGarbage; if (!m_GUIDSupportListIsValid.Lookup(sGUID, pGarbage)) { // to validate we will load all of the plugins within this list and // QI them. BOOL bListIsInvalid = FALSE; for(LISTPOSITION pPos = pSupportList->GetHeadPosition(); pPos!=NULL;) { BOOL IsValid = FALSE; UINT32 nTestPluginIndex; IUnknown* pTestUnk; PluginSupportingGUID* pSupportItemToTest = (PluginSupportingGUID*) pSupportList->GetAt(pPos); if (FindPlugin(pSupportItemToTest->m_filename, pSupportItemToTest->m_nIndexInDLL, nTestPluginIndex)) { if (HXR_OK == GetInstance(nTestPluginIndex, pTestUnk)) { IUnknown* pTempUnk; if (HXR_OK == pTestUnk->QueryInterface(iid, (void**)&pTempUnk)) { // ohhh we are in trouble now. We HAVE to assume one of the two following // statements: // (1) All interfaces have derive from IUnknown. // (2) All of our interfaces support aggeration correctly. // I guess we'll have to assume (1) since I KNOW (2) is incorrect. HX_RELEASE(pTempUnk); IsValid = TRUE; } HX_RELEASE (pTestUnk); } } HX_ASSERT(IsValid); if (!IsValid) { // Should not be part of this list. Delete this node. pSupportList->RemoveAt(pPos); bListIsInvalid = TRUE; } else { pSupportList->GetNext(pPos); } } m_GUIDSupportListIsValid.SetAt(sGUID, NULL); // at this point we should rewrite the prefs file if bListIsInvalid // however, I do not believe that we have an interface for removing // enteries from the preferences. hmmmm... }#endif return HXR_FAIL; // hey! it is already in! }#ifndef _MACINTOSH if (!zm_bFasterPrefs) { // Write this out for each mount point for(CHXMapStringToOb::Iterator mp = m_MountPoints.Begin(); mp!=m_MountPoints.End(); ++mp) { PluginMountPoint* pMountPoint = (PluginMountPoint*) *mp; IHXPreferences* pIPrefs = pMountPoint->Prefs(); if( pIPrefs ) { PreferenceEnumerator* pPrefEnum = new PreferenceEnumerator( pIPrefs ); HX_VERIFY( HXR_OK == pPrefEnum->BeginSubPref(PLUGIN_REGKEY_ROOT)); HX_VERIFY( HXR_OK == pPrefEnum->BeginSubPref(PLUGIN_GUIDINFO)); IHXBuffer* pIndexBuffer = new CHXBuffer(); pIndexBuffer->AddRef(); pIndexBuffer->Set((UCHAR*)"",1); pPrefEnum->WriteSubPref((const char*)sGUID, pIndexBuffer); pIndexBuffer->Release(); pPrefEnum->EndSubPref(); // XXXAH these may not be necessary. pPrefEnum->EndSubPref(); // XXXAH these may not be necessary. delete pPrefEnum; HX_RELEASE( pIPrefs ); } } }#endif // Now create the new structure. CHXSimpleList* pSimpleList = new CHXSimpleList(); m_GUIDtoSupportList.SetAt(sGUID, pSimpleList); // now scan all of the Plugins to see if any of them support this interface, for(CHXSimpleList::Iterator i = m_PluginList.Begin(); i!=m_PluginList.End(); ++i) { IUnknown* pUnk; IUnknown* pQuery; Plugin2Handler::Plugin* pPlugin = (Plugin2Handler::Plugin*) *i; if (HXR_OK == pPlugin->GetPlugin(pUnk)) { if(HXR_OK == pUnk->QueryInterface(iid, (void**)&pQuery)) { PluginSupportingGUID* pSupportItem = new PluginSupportingGUID(); IHXBuffer* pBuffer = pPlugin->GetFileName(); pSupportItem->m_filename = (char*) pBuffer->GetBuffer(); HX_RELEASE( pBuffer ); pSupportItem->m_pMountPoint = pPlugin->GetDLL()->GetMountPoint(); pSupportItem->m_nIndexInDLL = pPlugin->GetIndex(); pSimpleList->AddTail((void*)pSupportItem); // now write this info the registry char IndexArray[16]; /* Flawfinder: ignore */ sprintf(IndexArray, "%d", (int) pSupportItem->m_nIndexInDLL); /* Flawfinder: ignore */ IHXBuffer* pIndexBuffer = new CHXBuffer(); pIndexBuffer->AddRef(); pIndexBuffer->Set((const UCHAR*)IndexArray, strlen(IndexArray)+1); if (!zm_bFasterPrefs) { IHXPreferences* pIPrefs = pPlugin->GetDLL()->GetMountPoint()->Prefs(); if( pIPrefs ) { PreferenceEnumerator* pPrefEnum = new PreferenceEnumerator( pIPrefs ); HX_VERIFY(HXR_OK == pPrefEnum->BeginSubPref(PLUGIN_REGKEY_ROOT)); HX_VERIFY(HXR_OK == pPrefEnum->BeginSubPref(PLUGIN_GUIDINFO)); HX_VERIFY(HXR_OK == pPrefEnum->BeginSubPref((const char*)sGUID)); pPrefEnum->WriteSubPref((const char*)pSupportItem->m_filename, pIndexBuffer); pPrefEnum->EndSubPref(); // XXXAH these may not be necessary. pPrefEnum->EndSubPref(); // XXXAH these may not be necessary. pPrefEnum->EndSubPref(); // XXXAH these may not be necessary. delete pPrefEnum; HX_RELEASE( pIPrefs ); } } HX_RELEASE(pIndexBuffer); HX_RELEASE(pQuery); } HX_RELEASE(pUnk); } } WriteSupportedGUIDs(); return HXR_OK;}/********************************************************************** IHXPluginHandler3*********************************************************************/STDMETHODIMPPlugin2Handler::RegisterContext( IUnknown* pContext ){ if( !pContext ) { return INVALID_CONTEXT; } if( m_pContext ) { return HXR_UNEXPECTED; } m_pContext = pContext; m_pContext->AddRef(); if ( FAILED( m_pContext->QueryInterface( IID_IHXScheduler, (void**) &m_pIScheduler ) ) ) { return( INVALID_CONTEXT ); } // Set up scheduler to ping us. m_hScheduler = m_pIScheduler->RelativeEnter( this, kPingDuration ); if (HXR_OK != m_pContext->QueryInterface(IID_IHXPreferences, (void**) &m_pPreferences)) { return INVALID_CONTEXT; } /* We don't check errors because it's ok not to have this available. */ m_pContext->QueryInterface(IID_IHXErrorMessages, (void**) &m_pErrorMessages);#if defined(HELIX_FEATURE_PREFERENCES)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -