Example #1
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	nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
{
	NPError rv = NPERR_NO_ERROR;

	switch (aVariable) {
	case NPPVpluginScriptableInstance: {
		// addref happens in getter, so we don't addref here
		nsIDimdimControl * scriptablePeer = getScriptablePeer();
		if (scriptablePeer) {
			*(nsISupports **)aValue = scriptablePeer;
		} else
			rv = NPERR_OUT_OF_MEMORY_ERROR;
									   }
									   break;

	case NPPVpluginScriptableIID: {
		static nsIID scriptableIID = NS_IDIMDIMCONTROL_IID;
		nsIID* ptr = (nsIID *)NPN_MemAlloc(sizeof(nsIID));
		if (ptr) {
			*ptr = scriptableIID;
			*(nsIID **)aValue = ptr;
		} else
			rv = NPERR_OUT_OF_MEMORY_ERROR;
								  }
								  break;

	default:
		break;
	}

	return rv;
}
Example #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  nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
{
   NPError rv = NPERR_NO_ERROR;

   if (aVariable == NPPVpluginScriptableInstance) {
      nsIIETabPlugin * scriptablePeer = getScriptablePeer();
      if (scriptablePeer) {
         *(nsISupports **)aValue = scriptablePeer;
      } else
         rv = NPERR_OUT_OF_MEMORY_ERROR;
   }
   else if (aVariable == NPPVpluginScriptableIID) {
      static nsIID scriptableIID = NS_IIETABPLUGIN_IID;
      nsIID* ptr = (nsIID *)NPN_MemAlloc(sizeof(nsIID));
      if (ptr) {
         *ptr = scriptableIID;
         *(nsIID **)aValue = ptr;
      } else
         rv = NPERR_OUT_OF_MEMORY_ERROR;
   }
   return rv;
}
Example #3
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	nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
{
  NPError rv = NPERR_NO_ERROR;

  if (aVariable == NPPVpluginScriptableInstance) {
      // addref happens in getter, so we don't addref here
    nsIScriptablePluginSample * scriptablePeer = getScriptablePeer();
      if (scriptablePeer) {
        *(nsISupports **)aValue = scriptablePeer;
      } else
        rv = NPERR_OUT_OF_MEMORY_ERROR;
    }
  else if (aVariable == NPPVpluginScriptableIID) {
    static nsIID scriptableIID =  NS_ISCRIPTABLEPLUGINSAMPLE_IID;
      nsIID* ptr = (nsIID *)NPN_MemAlloc(sizeof(nsIID));
      if (ptr) {
          *ptr = scriptableIID;
          *(nsIID **)aValue = ptr;
      } else
        rv = NPERR_OUT_OF_MEMORY_ERROR;
  }

  return rv;
}