//=--------------------------------------------------------------------------=
// CNSAdapter_PluginManager::GetURL
//=--------------------------------------------------------------------------=
// params:  
//
// notes:
//
JD_METHOD
CNSAdapter_PluginManager::GetURL(ISupports* pluginInst,
			         const char* url,
				 const char* target,
				 IPluginStreamListener* sl,
			         const char* altHost,
			         const char* referrer,
			         JDBool forceJSEnabled)
{
    TRACE("CNSAdapter_PluginManager::GetURL\n");

    if (m_pPluginManager == NULL || pluginInst == NULL)
	return JD_ERROR_NULL_POINTER;

    // the streamListener is not null only for Netscape 4.x browser
    if (sl != NULL)
	return JD_ERROR_FAILURE;

    JDSmartPtr<IPluginInstance> inst;
    
    if (JD_FAILED(pluginInst->QueryInterface(jIPluginInstanceIID, (void**)&inst)) )
        return JD_ERROR_FAILURE;

    CNSAdapter_JavaPlugin* pluginAdapterInst = (CNSAdapter_JavaPlugin*)pluginMap.FindElement(inst);
        
    if (pluginAdapterInst == NULL)
	return JD_ERROR_FAILURE;

    return m_pPluginManager->GetURL((nsIJVMPluginInstance*)pluginAdapterInst, url, target, NULL, altHost, referrer, forceJSEnabled);
}
//=--------------------------------------------------------------------------=
// CNSAdapter_JavaPlugin::Start
//=--------------------------------------------------------------------------=
// This call will start Java Plug-in instance
//
// return: NS_OK if call succeed
//
// notes :
//
NS_METHOD
CNSAdapter_JavaPlugin::Start()
{
    TRACE("CNSAdapter_JavaPlugin::Start\n");
    if (m_pJavaPlugin == NULL)
	return NS_ERROR_NULL_POINTER;
    
    nsresult res = NS_OK;
    res = m_pJavaPlugin->Start();
    
    if (NS_SUCCEEDED(res) && pluginMap.FindElement((void*)m_pJavaPlugin) == NULL)
        pluginMap.InsertElement((void*)m_pJavaPlugin, (void*)this);

    return res;
}
//=--------------------------------------------------------------------------=
// CNSAdapter_JavaPlugin::Stop
//=--------------------------------------------------------------------------=
// This call will stop Java Plug-in instance
//
// return: NS_OK if call succeed
//
// notes :
//
NS_METHOD
CNSAdapter_JavaPlugin::Stop()
{
    TRACE("CNSAdapter_JavaPlugin::Stop\n");
    if (m_pJavaPlugin == NULL)
	return NS_ERROR_NULL_POINTER;

    nsresult res = m_pJavaPlugin->Stop();

    // Remove from pluginMap when applet stops
    if (NS_SUCCEEDED(res) && pluginMap.FindElement((void*)m_pJavaPlugin) != NULL)
	pluginMap.InsertElement((void*)m_pJavaPlugin, NULL);

    return res;
}