예제 #1
0
// during this call we know when the plugin window is ready or
// is about to be destroyed so we can do some gui specific
// initialization and shutdown
NPError NPP_SetWindow (NPP instance, NPWindow *pNPWindow)
{   
	if(instance == NULL)
	{
		return NPERR_INVALID_INSTANCE_ERROR;
	}
	
	NPError rv = NPERR_NO_ERROR;

	if(pNPWindow == NULL)
	{
		return NPERR_GENERIC_ERROR;
	}
	
	CPlugin * pPlugin = (CPlugin *)instance->pdata;

	if(pPlugin == NULL) 
	{
		return NPERR_GENERIC_ERROR;
	}
	
	// window just created
	if(!pPlugin->isInitialized() && (pNPWindow->window != NULL)) 
	{ 
		if(!pPlugin->init(pNPWindow))
		{
			delete pPlugin;
			pPlugin = NULL;
			return NPERR_MODULE_LOAD_FAILED_ERROR;
		}
	}

	// window goes away
	if((pNPWindow->window == NULL) && pPlugin->isInitialized())
	{
		return NPERR_NO_ERROR;
	}
	
	// window resized
	if(pPlugin->isInitialized() && (pNPWindow->window != NULL))
	{
		return NPERR_NO_ERROR;
	}
	
	// this should not happen, nothing to do
	if((pNPWindow->window == NULL) && !pPlugin->isInitialized())
	{
		return NPERR_NO_ERROR;
	}

	return rv;
}
예제 #2
0
// ==============================
// ! Scriptability related code !
// ==============================
//
// here the plugin is asked by Mozilla to tell if it is scriptable
// we should return a valid interface id and a pointer to 
// nsScriptablePeer interface which we should have implemented
// and which should be defined in the corressponding *.xpt file
// in the bin/components folder
NPError	NPP_GetValue(NPP instance, NPPVariable variable, void *value)
{
	if(instance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  NPError rv = NPERR_NO_ERROR;

  if(instance == NULL)
    return NPERR_GENERIC_ERROR;

  CPlugin * plugin = (CPlugin *)instance->pdata;
  if(plugin == NULL)
    return NPERR_GENERIC_ERROR;

  switch (variable) 
	{
		case NPPVpluginWindowBool:
			*((PRBool *)value) = PR_TRUE;
			break;
	
		case NPPVpluginNameString:
			*((char **)value) = "Boilerplate Plugin";
			break;
  
		case NPPVpluginDescriptionString:
			*((char **)value) = "Boilerplate web plugin";
			break;

		case NPPVpluginScriptableNPObject:
		
			if (!plugin->isInitialized())
			{
				return NPERR_GENERIC_ERROR;
			}
			
			*((NPObject **)value) = plugin->GetScriptableObject();

			break;
  
		default:
			rv = NPERR_GENERIC_ERROR;
			break;
  }

  return rv;
}
예제 #3
0
// during this call we know when the plugin window is ready or
// is about to be destroyed so we can do some gui specific
// initialization and shutdown
NPError NPP_SetWindow (NPP instance, NPWindow* pNPWindow)
{    
	if(instance == NULL)
		return NPERR_INVALID_INSTANCE_ERROR;

	NPError rv = NPERR_NO_ERROR;

	if(pNPWindow == NULL)
		return NPERR_GENERIC_ERROR;

	CPlugin * pPlugin = (CPlugin *)instance->pdata;

	if(pPlugin == NULL) 
		return NPERR_GENERIC_ERROR;
	
	// window just created
	if(!pPlugin->isInitialized()) 
	{ 
		if(!pPlugin->init(pNPWindow)) 
		{
			return NPERR_MODULE_LOAD_FAILED_ERROR;
		}
		return NPERR_NO_ERROR;
	}
	else
	{
		// window goes away
		if(pNPWindow->window == NULL)
			return NPERR_NO_ERROR;

		// window resized
		if(pNPWindow->window != NULL)
		{
			pPlugin->SetWindow(pNPWindow);
			return NPERR_NO_ERROR;
		}
	}

	return rv;
}