コード例 #1
0
ファイル: GMPChild.cpp プロジェクト: Kunden/gecko-dev
bool
GMPChild::Init(const std::string& aPluginPath,
               base::ProcessHandle aParentProcessHandle,
               MessageLoop* aIOLoop,
               IPC::Channel* aChannel)
{
  return LoadPluginLibrary(aPluginPath) &&
         Open(aChannel, aParentProcessHandle, aIOLoop);
}
コード例 #2
0
ファイル: GMPChild.cpp プロジェクト: chsrivast/gecko-dev
bool
GMPChild::Init(const std::string& aPluginPath,
               base::ProcessHandle aParentProcessHandle,
               MessageLoop* aIOLoop,
               IPC::Channel* aChannel)
{
  if (!Open(aChannel, aParentProcessHandle, aIOLoop)) {
    return false;
  }

#ifdef MOZ_CRASHREPORTER
  SendPCrashReporterConstructor(CrashReporter::CurrentThreadId());
#endif
#if defined(XP_WIN)
  mozilla::SandboxTarget::Instance()->StartSandbox();
#endif

  return LoadPluginLibrary(aPluginPath);
}
コード例 #3
0
bool NFCPluginManager::Awake()
{
	LoadPluginConfig();

	PluginNameMap::iterator it = mPluginNameMap.begin();
	for (it; it != mPluginNameMap.end(); ++it)
	{
#ifdef NF_DYNAMIC_PLUGIN
		LoadPluginLibrary(it->first);
#else
		LoadStaticPlugin(it->first);
#endif
	}


	PluginInstanceMap::iterator itAfterInstance = mPluginInstanceMap.begin();
	for (itAfterInstance; itAfterInstance != mPluginInstanceMap.end(); itAfterInstance++)
	{
		itAfterInstance->second->Awake();
	}

	return true;
}
コード例 #4
0
//=--------------------------------------------------------------------------=
// CNS4Adapter::NPP_Initialize
//=--------------------------------------------------------------------------=
// Provides global initialization for a plug-in, and returns an error value. 
//
// This function is called once when a plug-in is loaded, before the first instance
// is created. m_pPluginManager and m_pPlugin are both initialized.
//
//
NPError
CNS4Adapter::NPP_Initialize(void)
{
    TRACE("CNS4Adapter::NPP_Initialize\n");

    ASSERT(m_pINS4AdapterPeer != NULL);

    // Only call initialize the plugin if it hasn't been created.
    // This could happen if GetJavaClass() is called before
    // NPP Initialize.  
    if (m_pPluginManager == NULL) 
    {
        // Create the plugin manager and plugin classes.
        m_pPluginManager = new CNS4Adapter_PluginManager(m_pINS4AdapterPeer);	
     
        if (m_pPluginManager == NULL) 
            return NPERR_OUT_OF_MEMORY_ERROR;  

        m_pPluginManager->AddRef();
    }

    JDresult error = JD_OK;  
    
    // On UNIX the plugin might have been created when calling NPP_GetMIMEType.
    if (m_pPlugin == NULL) 
    {
        // create IPlugin factory from ns4 adapter
	static NSGetFactoryProc pProc = NULL;

	if (pProc == NULL)
	{
	    // Load jpins32.dll
            HINSTANCE hDLL = NULL;
	    if (LoadPluginLibrary(JPINS_SERVER_NAME, &hDLL) != ERROR_SUCCESS)
		return (NPError)JD_ERROR_FAILURE;

		// Get the proc address of NSGetFactory(IPluginServiceProvider*, IFactory**);	
		pProc = (NSGetFactoryProc)
			GetProcAddress(hDLL, NSGetFactory_NAME );
                if (pProc == NULL)
                    return NPERR_GENERIC_ERROR;
	}

	JDSmartPtr<IFactory> spIFactory;
	JDSmartPtr<IPluginServiceProvider> spPluginServiceProvider(new CPluginServiceProvider(m_pPluginManager));
    
	if (spPluginServiceProvider == NULL)
	    return (NPError)JD_ERROR_OUT_OF_MEMORY;

	// Calling NSGetFactory to get a Factory object
	error = pProc(spPluginServiceProvider, &spIFactory);
    
	if (JD_SUCCEEDED(error) && spIFactory)
	{
	    // Query IPlugin
	    error = spIFactory->QueryInterface(jIPluginIID, (void**)&m_pPlugin);
	    if (JD_SUCCEEDED(error) && m_pPlugin)
		m_pPlugin->Initialize();
	}

    }
    return (NPError) error;	
}
コード例 #5
0
ファイル: sphinxplugin.cpp プロジェクト: 1m69/sphinx
bool sphPluginReload ( const char * sName, CSphString & sError )
{
#if !HAVE_DLOPEN
	sError = "no dlopen(), no plugins";
	return false;
#else
	// find all plugins from the given library
	CSphScopedLock<CSphMutex> tLock ( g_tPluginMutex );

	CSphVector<PluginKey_t> dKeys;
	CSphVector<PluginDesc_c*> dPlugins;

	g_hPlugins.IterateStart();
	while ( g_hPlugins.IterateNext() )
	{
		PluginDesc_c * v = g_hPlugins.IterateGet();
		if ( v->GetLibName()==sName )
		{
			dKeys.Add ( g_hPlugins.IterateGetKey() );
			dPlugins.Add ( g_hPlugins.IterateGet() );
		}
	}

	// no plugins loaded? oops
	if ( dPlugins.GetLength()==0 )
	{
		sError.SetSprintf ( "no active plugins loaded from %s", sName );
		return false;
	}

	// load new library and check every plugin
#if !USE_WINDOWS
	PluginLib_c * pNewLib = LoadPluginLibrary ( sName, sError, true );
#else
	PluginLib_c * pNewLib = LoadPluginLibrary ( sName, sError );
#endif
	if ( !pNewLib )
		return false;

	// load all plugins
	CSphVector<PluginDesc_c*> dNewPlugins;
	ARRAY_FOREACH ( i, dPlugins )
	{
		PluginDesc_c * pDesc = NULL;
		const SymbolDesc_t * pSym = NULL;
		switch ( dKeys[i].m_eType )
		{
			case PLUGIN_RANKER:					pDesc = new PluginRanker_c ( pNewLib ); pSym = g_dSymbolsRanker; break;
			case PLUGIN_INDEX_TOKEN_FILTER:		pDesc = new PluginTokenFilter_c ( pNewLib ); pSym = g_dSymbolsTokenFilter; break;
			case PLUGIN_QUERY_TOKEN_FILTER:		pDesc = new PluginQueryTokenFilter_c ( pNewLib ); pSym = g_dSymbolsQueryTokenFilter; break;
			case PLUGIN_FUNCTION:				pDesc = new PluginUDF_c ( pNewLib, dPlugins[i]->GetUdfRetType() ); pSym = g_dSymbolsUDF; break;
			default:
				sphDie ( "INTERNAL ERROR: unknown plugin type %d in sphPluginReload()", (int)dKeys[i].m_eType );
				return false;
		}

		if ( !PluginLoadSymbols ( pDesc, pSym, pNewLib->GetHandle(), dKeys[i].m_sName.cstr(), sError ) )
		{
			pDesc->Release();
			break;
		}

		dNewPlugins.Add ( pDesc );
	}
コード例 #6
0
ファイル: sphinxplugin.cpp プロジェクト: 1m69/sphinx
bool sphPluginCreate ( const char * szLib, PluginType_e eType, const char * sName, ESphAttr eUDFRetType, CSphString & sError )
{
#if !HAVE_DLOPEN
	sError = "no dlopen(), no plugins";
	return false;
#else
	if ( !g_bPluginsEnabled )
	{
		sError = "plugin support disabled (requires a valid plugin_dir)";
		return false;
	}

	// validate library name
	for ( const char * p = szLib; *p; p++ )
		if ( *p=='/' || *p=='\\' )
	{
		sError = "restricted character (path delimiter) in a library file name";
		return false;
	}

	CSphString sLib = szLib;
	sLib.ToLower();

	// FIXME? preregister known rankers instead?
	if ( eType==PLUGIN_RANKER )
	{
		for ( int i=0; i<SPH_RANK_TOTAL; i++ )
		{
			const char * r = sphGetRankerName ( ESphRankMode(i) );
			if ( r && strcasecmp ( sName, r )==0 )
			{
				sError.SetSprintf ( "%s is a reserved ranker name", r );
				return false;
			}
		}
	}

	// from here, we need a lock (we intend to update the plugin hash)
	CSphScopedLock<CSphMutex> tLock ( g_tPluginMutex );

	// validate function name
	PluginKey_t k ( eType, sName );
	if ( g_hPlugins(k) )
	{
		sError.SetSprintf ( "plugin '%s' already exists", k.m_sName.cstr() );
		return false;
	}

	// lookup or load library
	PluginLib_c * pLib = NULL;
	if ( g_hPluginLibs ( sLib ) )
	{
		pLib = g_hPluginLibs [ sLib ];
		pLib->AddRef();
	} else
	{
		pLib = LoadPluginLibrary ( sLib.cstr(), sError );
		if ( !pLib )
			return false;
	}
	assert ( pLib->GetHandle() );

	PluginDesc_c * pPlugin = NULL;
	const SymbolDesc_t * pSym = NULL;
	switch ( eType )
	{
		case PLUGIN_RANKER:					pPlugin = new PluginRanker_c ( pLib ); pSym = g_dSymbolsRanker; break;
		case PLUGIN_INDEX_TOKEN_FILTER:		pPlugin = new PluginTokenFilter_c ( pLib ); pSym = g_dSymbolsTokenFilter; break;
		case PLUGIN_QUERY_TOKEN_FILTER:		pPlugin = new PluginQueryTokenFilter_c ( pLib ); pSym = g_dSymbolsQueryTokenFilter; break;
		case PLUGIN_FUNCTION:				pPlugin = new PluginUDF_c ( pLib, eUDFRetType ); pSym = g_dSymbolsUDF; break;
		default:
			sError.SetSprintf ( "INTERNAL ERROR: unknown plugin type %d in CreatePlugin()", (int)eType );
			pLib->Release();
			return false;
	}

	// release the refcount that this very function is holding
	// or in other words, transfer the refcount to newly created plugin instance (it does its own addref)
	pLib->Release();

	if ( !PluginLoadSymbols ( pPlugin, pSym, pLib->GetHandle(), k.m_sName.cstr(), sError ) )
	{
		sError.SetSprintf ( "%s in %s", sError.cstr(), sLib.cstr() );
		pPlugin->Release();
		return false;
	}

	// add library if needed
	if ( !g_hPluginLibs ( sLib ) )
	{
		Verify ( g_hPluginLibs.Add ( pLib, pLib->GetName() ) );
		pLib->AddRef(); // the hash reference
	}

	// add function
	Verify ( g_hPlugins.Add ( pPlugin, k ) );
	pPlugin->GetLib()->m_iHashedPlugins++;
	return true;
#endif // HAVE_DLOPEN
}