Пример #1
0
bool convert_js_to_mrb_hash(NPP npp, const NPVariant &variant, mrb_state *mrb, mrb_value *result)
{
    NPIdentifier *id_list = NULL;
    uint32_t count;
    NPN_Enumerate(npp, NPVARIANT_TO_OBJECT(variant), &id_list, &count);

    mrb_value ret_hash = mrb_hash_new_capa(mrb, count);
    for (uint32_t i=0; i<count; i++){
        NPVariant item;
        NPN_GetProperty(npp, NPVARIANT_TO_OBJECT(variant), id_list[i], &item);

        mrb_value mrb_item;
        if (!convert_js_to_mrb(npp, item, mrb, &mrb_item)){
            NPN_MemFree(id_list);
            NPN_ReleaseVariantValue(&item);
            return false;
        }
        NPN_ReleaseVariantValue(&item);

        NPUTF8 *key = NPN_UTF8FromIdentifier(id_list[i]);
        mrb_hash_set(mrb, ret_hash, mrb_str_new2(mrb, key), mrb_item);
        NPN_MemFree(key);
    }

    NPN_MemFree(id_list);
    *result = ret_hash;
    return true;
}
Пример #2
0
NPError 
NPP_Destroy(NPP instance, NPSavedData** save)
{

    PluginInstance* This;

    if (instance == NULL)
        return NPERR_INVALID_INSTANCE_ERROR;

    This = (PluginInstance*) instance->pdata;

    if (This != NULL) {
	if (This->dialogBox)
	   destroyWidget(This);
        if (This->type)
            NPN_MemFree(This->type);
        if (This->pluginsPageUrl)
            NPN_MemFree(This->pluginsPageUrl);
        if (This->pluginsFileUrl)
                NPN_MemFree(This->pluginsFileUrl);
        NPN_MemFree(instance->pdata);
        instance->pdata = NULL;
    }

    return NPERR_NO_ERROR;
}
Пример #3
0
void CPlugin::SetURLCookie(const CString& strURL, const CString& strCookie)
{
  char* url = CStringToNPStringCharacters(strURL);
  char* cookie = CStringToNPStringCharacters(strCookie);
  if (NPN_SetValueForURL(m_pNPInstance, NPNURLVCookie, url, cookie, (uint32_t)strlen(cookie)) != NPERR_NO_ERROR)
  {
    TRACE(_T("[CPlugin::SetURLCookie] NPN_SetValueForURL failed! URL: %s"), strURL);
  }
  NPN_MemFree(cookie);
  NPN_MemFree(url);
}
Пример #4
0
CPluginInstancePeer::~CPluginInstancePeer(void) 
{
	if (attribute_list != NULL && values_list != NULL) {
		for (int i = 0; i < attribute_cnt; i++)   {
			NPN_MemFree(attribute_list[i]);
			NPN_MemFree(values_list[i]);
		}

		NPN_MemFree(attribute_list);
		NPN_MemFree(values_list);
	}
}   
Пример #5
0
/* callback function for the OK button */
static void 
DialogOKClicked (GtkButton *button, gpointer data)
{
    PluginInstance* This = (PluginInstance*) data;
    GtkWidget* dialogWindow = g_object_get_data(GTK_OBJECT(button), DIALOGID);
    char *url;

    g_object_set_data(GTK_OBJECT(button), DIALOGID, NULL);

    if (This->pluginsFileUrl != NULL)
    {
        /* Get the JavaScript command string */
        static const char buf[] = 
          "javascript:netscape.softupdate.Trigger.StartSoftwareUpdate(\"%s\")";

        url = NPN_MemAlloc(strlen(This->pluginsFileUrl) + (sizeof(buf) - 2));
        if (url != NULL)
        {
            /* Insert the file URL into the JavaScript command */
            sprintf(url, buf, This->pluginsFileUrl);
            NPN_GetURL(This->instance, url, TARGET);
            NPN_MemFree(url);
        }
    }
    else
    {
        /* If necessary, get the default plug-ins page resource */
        char* address = This->pluginsPageUrl;
        if (address == NULL || *address == 0)
        {
            address = PLUGINSPAGE_URL;
        }

        url = NPN_MemAlloc(strlen(address) + 1 + strlen(This->type)+1);
        if (url != NULL)
        {
            NPN_PushPopupsEnabledState(This->instance, TRUE);
                /* Append the MIME type to the URL */
            sprintf(url, "%s?%s", address, This->type);
            if (strcmp (This->type, JVM_MINETYPE) == 0) 
            {
                NPN_GetURL(This->instance, JVM_SMARTUPDATE_URL , TARGET);
            }
            else 
            {
                NPN_GetURL(This->instance, url, TARGET);
            }
            NPN_MemFree(url);
            NPN_PopPopupsEnabledState(This->instance);
        }
    }
    destroyWidget(This);
}
Пример #6
0
static void
PostUrl(SqueakPlugin *plugin)
{
  char *url, *target, *data;
  int id, urlSize, targetSize, dataSize;

  errno= 0;
  Receive(plugin, &id, 4);
  /* Read URL from pipe */
  Receive(plugin, &urlSize, 4);
  if (urlSize > 0) {
    url= NPN_MemAlloc(urlSize+1);
    Receive(plugin, url, urlSize);
    url[urlSize]= 0;
  } else url= NULL;
  /* Read target from pipe */
  Receive(plugin, &targetSize, 4);
  if (targetSize > 0) {
    target= NPN_MemAlloc(targetSize+1);
    Receive(plugin, target, targetSize);
    target[targetSize]= 0;
  } else target= NULL;
  /* Read post data from pipe */
  Receive(plugin, &dataSize, 4);
  if (dataSize > 0) {
    data= NPN_MemAlloc(dataSize);
    Receive(plugin, data, dataSize);
  } else data= NULL;

  if (errno) {
    perror("Squeak Plugin (PostUrl)");
  } else {
    SqueakStream* notifyData= 
      (SqueakStream*) NPN_MemAlloc(sizeof(SqueakStream));
    if (!notifyData) { 
      fprintf(stderr, "Squeak Plugin (PostUrl): alloc failed\n");
    } else {
      DPRINT("NP: PostURLNotify(%s, id=%i)\n", url, id);
      notifyData->id= id;
      NPN_PostURLNotify(plugin->instance, url, target, 
			dataSize, data, FALSE, notifyData);
    }
  }

  if (url) NPN_MemFree(url);
  if (target) NPN_MemFree(target);
  if (data) NPN_MemFree(data);
}
Пример #7
0
static void
GetUrl(SqueakPlugin *plugin)
{
  char *url, *target;
  int id, urlSize, targetSize;

  errno= 0;
  Receive(plugin, &id, 4);
  /* Read URL from pipe */
  Receive(plugin, &urlSize, 4);
  if (urlSize > 0) {
    url= NPN_MemAlloc(urlSize+1);
    Receive(plugin, url, urlSize);
    url[urlSize]= 0;
  } else url= NULL;
  /* Read target from pipe */
  Receive(plugin, &targetSize, 4);
  if (targetSize > 0) {
    target= NPN_MemAlloc(targetSize+1);
    Receive(plugin, target, targetSize);
    target[targetSize]= 0;
  } else target= NULL;

  if (errno) {
    perror("Squeak Plugin (GetUrl)");
  } else {
    DPRINT("NP: GetUrl(%s, %s)\n", url, target ? target : "NULL");
    if (strcmp(url, plugin->srcUrl)==0) {
      if (plugin->srcFilename)
	DeliverFile(plugin, id, plugin->srcFilename);
      else
	plugin->srcId= id;
    } else {
      SqueakStream* notifyData= 
	(SqueakStream*) NPN_MemAlloc(sizeof(SqueakStream));
      if (!notifyData) { 
	fprintf(stderr, "Squeak Plugin (GetUrl): alloc failed\n");
      } else {
	DPRINT("NP: GetURLNotify(%s, id=%i)\n", url, id);
	notifyData->id= id;
	NPN_GetURLNotify(plugin->instance, url, target, notifyData);
      }
    }
  }

  if (url) NPN_MemFree(url);
  if (target) NPN_MemFree(target);
}
Пример #8
0
static NPError
post_data(NPP instance, const char *url, const char *target, uint32 len,
	  const char *buf, const char *tag)
{
	NPError rv;
	char headers[256], *sendbuf;
	char *content;
	unsigned int content_len, hdrlen, taglen;
	
	taglen = strlen(tag);
	content_len = taglen + len + 1;
	content = (char *) NPN_MemAlloc(content_len);
	if (content == NULL)
		return NPERR_OUT_OF_MEMORY_ERROR;
	memcpy(content, tag, taglen);
	content[taglen] = '=';
	memcpy(content+taglen+1, buf, len);
	
	sprintf(headers, "Content-type: application/x-www-form-urlencoded\r\n"
			 "Content-Length: %u\r\n\r\n", (unsigned int) content_len);
	hdrlen = strlen(headers);
	sendbuf = (char *) NPN_MemAlloc(hdrlen + content_len);
	if (sendbuf == NULL)
		return NPERR_OUT_OF_MEMORY_ERROR;
	memcpy(sendbuf, headers, hdrlen);
	memcpy(sendbuf + hdrlen, content, content_len);
	sendbuf[hdrlen + content_len] = 0;
	NPN_MemFree(content);
	printf("Sending:\n---\n%s---\n", sendbuf);
	printf("Url: '%s', target: '%s', len: %ld\n", url, target, hdrlen + len);
	rv = NPN_PostURL(instance, url, target, hdrlen + content_len, sendbuf, FALSE);

	return rv;
}
Пример #9
0
NPError 
NPP_Destroy(NPP instance, NPSavedData** save)
{
	PluginInstance* This;

	printf("NPP_Destroy()\n");
	if (instance == NULL)
		return NPERR_INVALID_INSTANCE_ERROR;

	This = (PluginInstance*) instance->pdata;

	/* PLUGIN DEVELOPERS:
	 *	If desired, call NP_MemAlloc to create a
	 *	NPSavedDate structure containing any state information
	 *	that you want restored if this plugin instance is later
	 *	recreated.
	 */
	if (This == NULL)
		return NPERR_NO_ERROR;
	
	NPN_MemFree(instance->pdata);
	instance->pdata = NULL;

	return NPERR_NO_ERROR;
}
Пример #10
0
NS_METHOD
CPluginManager::MemFree(void* ptr)
{
    assert( ptr != NULL );

    NPN_MemFree(ptr);
}
Пример #11
0
static mrb_value mrb_js_obj_get(mrb_state *mrb, mrb_value klass)
{
    mrb_value str;
    mrb_get_args(mrb, "S", &str);

    NPObject *window;
    NPN_GetValue(MRB_UD_NPP(mrb), NPNVWindowNPObject, &window);

    NPUTF8 *s = (NPUTF8 *)NPN_MemAlloc(RSTRING_LEN(str));
    std::copy(RSTRING_PTR(str), RSTRING_END(str), s);
    NPString evaluated_str = { s, RSTRING_LEN(str) };

    NPVariant result;
    std::string js_str(RSTRING_PTR(str), RSTRING_LEN(str));
    NPN_Evaluate(MRB_UD_NPP(mrb), window, &evaluated_str, &result);
    NPN_ReleaseObject(window);
    NPN_MemFree(s);

    mrb_value ret;
    if (!convert_js_to_mrb(MRB_UD_NPP(mrb), result, mrb, &ret)){
        return mrb_nil_value();
    }

    return ret;
}
Пример #12
0
bool JsObjectWrapper::getInfo(NPIdentifier name, TypeMemberInfo& info) {
	if(!getTypeInfo())
		return false;

	if(NPN_IdentifierIsString(name)) {
		NPUTF8* id = NPN_UTF8FromIdentifier(name);
		MembersByName_t::const_iterator it = m_byName.find(id);
		NPN_MemFree(id);
		if(it == m_byName.end())
			return false;

		info = it->second;
		return true;
	}
	else if(m_indexerLength >= 0) {
		uint32_t index = NPN_IntFromIdentifier(name);
		if(index < m_indexerLength) {
			info.dispatchType = DT_PropertyGet | DT_PropertySet;
			//info.memberId = index;
			return true;
		}
	}

	return false;
}
Пример #13
0
static gboolean
delFromList(MimeTypeElement **typelist, PluginInstance *This)
{
    if (typelist && This)
    {
        MimeTypeElement *ele_prev;
        MimeTypeElement *ele = *typelist;
        while (ele)
        {
            if (isEqual(ele->pinst->type, This->type))
            {
                if (*typelist == ele)
                {
                    *typelist = ele->next;
                } else {
                    ele_prev->next = ele->next;
                }
                NPN_MemFree(ele);
                return(TRUE);
            }
            ele_prev = ele;
            ele = ele->next;
        }
    }
    return(FALSE);
}
CString NPIdentifierToCString(NPIdentifier npid)
{
	NPUTF8* putf8IdName = NPN_UTF8FromIdentifier(npid);
	NPString npstrIdName = { putf8IdName, (uint32_t)strlen(putf8IdName) };
	CString idName = NPStringToCString(npstrIdName);
	NPN_MemFree(putf8IdName);
	return idName;
}
Пример #15
0
//-----------------------------------------------------------------------------
// NPP_Destroy:
//-----------------------------------------------------------------------------
NPError NP_LOADDS
NPP_Destroy(NPP instance, NPSavedData** save) {
  if ( instance == 0 ) return NPERR_INVALID_INSTANCE_ERROR;

  PluginInstance* This = (PluginInstance*) instance->pdata;

  //
  // *Developers*: If desired, call NP_MemAlloc to create a
  // NPSavedDate structure containing any state information
  // that you want restored if this plugin instance is later
  // recreated.
  //

  if ( This ) {
    // destroy hmf and PS
    if ( This->hmf ) GpiDeleteMetaFile( This->hmf );
    if ( This->hps ) GpiDestroyPS( This->hps );
    // delete buffer
    if ( This->bufMeta ) {
      free( This->bufMeta );
      This->bufMeta=NULL;
      This->cbMeta=0;
      This->offMeta=0;
    }
    // Remove the subclass for the client window
    if ( This->hWnd ) WinSubclassWindow( This->hWnd, This->lpfnOldWndProc );
    // make some saved instance data if necessary
    if ( This->pSavedInstanceData == 0 ) {
      // make a struct header for the data
      This->pSavedInstanceData =
          (NPSavedData*)NPN_MemAlloc(sizeof (struct _NPSavedData));
      // fill in the struct
      if ( This->pSavedInstanceData != 0 ) {
        This->pSavedInstanceData->len = 0;
        This->pSavedInstanceData->buf = 0;

        // replace the def below and references to it with your data
        #define SIDATA "aSavedInstanceDataBlock"

        // the data
        This->pSavedInstanceData->buf = NPN_MemAlloc(sizeof SIDATA);

        if( This->pSavedInstanceData->buf ) {
          strcpy((char*)This->pSavedInstanceData->buf, SIDATA);
          This->pSavedInstanceData->len = sizeof SIDATA;
        }
      }
    }

    // save some instance data
    *save = This->pSavedInstanceData;

    NPN_MemFree(instance->pdata);
    instance->pdata = 0;
  }
  return NPERR_NO_ERROR;
}
Пример #16
0
static void 
Run(SqueakPlugin *plugin)
{
  if (plugin->pid || !plugin->nswindow || !plugin->srcUrl ||plugin->failureUrl)
    return;

  
  plugin->pid= fork();
  
  if (plugin->pid == -1) {
    perror("Squeak fork() failed");
    plugin->pid= 0;
    return;
  }
  DPRINT("NP: fork() -> %i\n", plugin->pid);
  if (plugin->pid == 0) {
    char tmp1[16], tmp2[16];
    plugin->argv[2]= NPN_StrDup(DisplayString(plugin->display));
    sprintf(tmp1, "%i", plugin->pipes[SQUEAK_READ]);
    plugin->argv[4]= NPN_StrDup(tmp1);
    sprintf(tmp2, "%i", plugin->pipes[SQUEAK_WRITE]);
    plugin->argv[5]= NPN_StrDup(tmp2);
    DPRINT("NP(child): Running Squeak VM with arguments\n");
    {
      int i;
      for (i= 1; i<plugin->argc; i++)
	DPRINT("    %s\n", plugin->argv[i]);
    }
    /* this is from the XLib manual ... */
    if ((fcntl(ConnectionNumber(plugin->display), F_SETFD, FD_CLOEXEC)) == -1)
      DPRINT("NP: Cannot disinherit X connection fd\n");
    DPRINT("NP(child): trying %s\n", plugin->vmName);
    execv(plugin->vmName, plugin->argv);
    /* ~/.npsqueak/npsqueakrun could not be executed */
    strcpy(plugin->vmName, SYSTEM_BIN_DIR "/" NPSQUEAKRUN);
    NPN_MemFree(plugin->argv[0]);
    plugin->argv[0]= NPN_StrDup(plugin->vmName);
    DPRINT("NP(child): trying %s\n", plugin->vmName);
    execv(plugin->vmName, plugin->argv);
    /* npsqueakrun could not be executed either */
    fprintf(stderr, "Squeak Plugin: running \"%s\"\n", plugin->vmName);
    perror("Squeak execv() failed");
    _exit(1);
  } else {
    /* establish communication via command pipes */
    XtAppContext app= XtDisplayToApplicationContext(plugin->display);
    plugin->input= XtAppAddInput(app,
				 plugin->pipes[PLUGIN_READ],
				 (XtPointer) XtInputReadMask,
				 (XtInputCallbackProc) InputCallback,
				 plugin);
  
    /* send browser window */
    DPRINT("NP: Sending browser window=0x%X\n", plugin->nswindow);
    SendInt(plugin, plugin->nswindow);
  }
}
bool nsScriptableObjectRawInput::HasMethod(NPIdentifier name) {
#ifdef _DEBUG
  NPUTF8* name_utf8 = NPN_UTF8FromIdentifier(name);
  NPN_MemFree((void*)name_utf8);
#endif

  // does the method exist?
  return ((generic_methods_.find(name) != generic_methods_.end()) || (methods_.find(name) != methods_.end()));
}
bool nsScriptableObjectRawInput::HasProperty(NPIdentifier name) {
#ifdef _DEBUG
  NPUTF8* name_utf8 = NPN_UTF8FromIdentifier(name);
  NPN_MemFree((void*)name_utf8);
#endif

  // does the property exist?
  return (properties_.find(name) != properties_.end());
}
bool nsScriptableObjectOverwolfSample::HasMethod(NPIdentifier name) {
#ifdef _DEBUG
  NPUTF8* name_utf8 = NPN_UTF8FromIdentifier(name);
  NPN_MemFree((void*)name_utf8);
#endif

  // does the method exist?
  return (methods_.find(name) != methods_.end());
}
Пример #20
0
void CPlugin::SetStatus(const CString& text)
{
  if (m_pNPInstance)
  {
    char* message = CStringToNPStringCharacters(text);
    NPN_Status(m_pNPInstance, message);
    NPN_MemFree(message);
  }
}
Пример #21
0
void 
GnashPluginScriptObject::marshalDeallocate (NPObject *npobj)
{
//    log_debug(__PRETTY_FUNCTION__);
#if 0
    NPN_MemFree(reinterpret_cast<void *>(npobj));
#else
    delete (GnashPluginScriptObject *)npobj;
#endif
}
	native_Blender3DPlugin_SendMessage(
		JRIEnv* env, 
		Blender3DPlugin* self,
		struct java_lang_String * to,
		struct java_lang_String * from,
		struct java_lang_String * subject,
		struct java_lang_String * body
		)
{
	
	NPP npp = (NPP)netscape_plugin_Plugin_getPeer(env, self);
	BlenderPluginInstance* inst  = NULL;
	char *to_p, *from_p, *subject_p, *body_p;

	B3D_log_entry("native_Blender3DPlugin_SendMessage");

	inst = (BlenderPluginInstance*) npp->pdata;

	fprintf(stderr, "Doing java stuff for instance %p\n",
		inst);
	fflush(stderr);
	
	to_p = NPN_MemAlloc(JRI_GetStringUTFLength(env, to) + 1);
	from_p = NPN_MemAlloc(JRI_GetStringUTFLength(env, from) + 1);
	subject_p = NPN_MemAlloc(JRI_GetStringUTFLength(env, subject) + 1);
	body_p = NPN_MemAlloc(JRI_GetStringUTFLength(env, body) + 1);

	strcpy(to_p, JRI_GetStringUTFChars(env, to));
	strcpy(from_p, JRI_GetStringUTFChars(env, from));
	strcpy(subject_p, JRI_GetStringUTFChars(env, subject));
	strcpy(body_p, JRI_GetStringUTFChars(env, body));

	PLB_native_SendMessage_func(inst, 
				    to_p, 
				    from_p, 
				    subject_p, 
				    body_p);

	NPN_MemFree(to_p);
	NPN_MemFree(from_p);
	NPN_MemFree(subject_p);
	NPN_MemFree(body_p);
}
Пример #23
0
void
NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
{
  int id= notifyData ? ((SqueakStream*) notifyData)->id : -1;
  int ok= reason == NPRES_DONE;
  SqueakPlugin *plugin= (SqueakPlugin*) instance->pdata;
  DPRINT("NP: URLNotify(%s, id=%i, ok=%i)\n", url, id, ok);
  if (notifyData) NPN_MemFree(notifyData);
  if (!plugin || -1 == id) return;

  DeliverFile(plugin, id, NULL);
}
Пример #24
0
NPError 
NPP_New(NPMIMEType pluginType,
	NPP instance,
	PRUint16 mode,
	int16 argc,
	char* argn[],
	char* argv[],
	NPSavedData* saved)
{
//    TRACE("NPP_New\n");
    
    if (instance == NULL)
        return NPERR_INVALID_INSTANCE_ERROR;

    // Create a new plugin instance and start it.
    nsIPluginInstance* pluginInstance = NULL;
    thePlugin->CreateInstance(NULL, kIPluginInstanceIID, (void**)&pluginInstance);
    if (pluginInstance == NULL) {
        return NPERR_OUT_OF_MEMORY_ERROR;
    } 
    
    // Create a new plugin instance peer,
    // XXX - Since np_instance is not implemented in the 4.0x browser, I
    // XXX - had to save the plugin parameter in the peer class.
    // XXX - Ask Warren about np_instance.
    CPluginInstancePeer* peer = 
        new CPluginInstancePeer(instance, (nsMIMEType)pluginType, 
                                (nsPluginMode)mode, (PRUint16)argc, 
                                (const char** )argn, (const char** )argv);
    assert( peer != NULL );
    if (!peer) return NPERR_OUT_OF_MEMORY_ERROR;
    peer->AddRef();
	IUniqueIdentifier* pInst = NULL;
	if(NS_SUCCEEDED(pluginInstance->QueryInterface(kIUniqueIdentifierIID, (void**)&pInst))) {
		long id = 0;
		if(NULL != saved) {
			id = saved->len;
			NPN_MemFree(saved);
		}
		pInst->SetUniqueId(id);
		pInst->Release();
	}

    pluginInstance->Initialize(peer);
    pluginInstance->Start();
    // Set the user instance and store the peer in npp->pdata.
    instance->pdata = pluginInstance;
    peer->Release();
    UNUSED(saved);

    return NPERR_NO_ERROR;
}
Пример #25
0
NPError 
NPP_Destroy( NPP instance, NPSavedData** save )
{
	BlenderPluginInstance* This;

	log_entry("NPP_Destroy");

	if (instance == NULL)
		return NPERR_INVALID_INSTANCE_ERROR;

	This = (BlenderPluginInstance*) instance->pdata;
	printf("NPP_Destroy ID:  0x%x %d\n", This->window, This->window);

	if (This != NULL) {

		if (This->pID != 0) {
#ifdef WITH_PRIVSEP
			kill(This->pID, SIGTERM);
#else 
			kill(This->pID, SIGKILL); //if I have to kill blenderplayer directly I need to send SIGKILL
#endif
			wait(This->pID);
			unlink(This->temp_mail_file_name);
		}

		// sometimes FF doesn't delete it's own window...
		//printf("%s \n", NPN_UserAgent(instance));
		/*if (This->display != NULL && This->window != 0)
			XDestroyWindow(This->display, This->window);
		*/
		if (This->blend_file) NPN_MemFree(This->blend_file);
		if (This->temp_mail_file_name) NPN_MemFree(This->temp_mail_file_name);
		if (This->main_file_store) NPN_MemFree(This->main_file_store);
		NPN_MemFree(instance->pdata);
		instance->pdata = NULL;
	}	

	return NPERR_NO_ERROR;
}
Пример #26
0
/**
 * Calls the function in the reply with the reply of the function. This has to
 * be done in the browser's main thread, and hence this functions
 *
 * @param reply - Struct containing the callback object, and the reply param.
 */
static void 
jsReply (ScriptReply* reply)
{
    if (reply)
    {
        NPVariant result;
        NPN_Invoke(reply->plugin, reply->callb, NPN_GetStringIdentifier("callback"), reply->result, 1, &result);

        NPN_ReleaseObject(reply->callb);
        NPN_MemFree(reply->result);
        free(reply);
    }
}
Пример #27
0
const char* debugName(NPIdentifier name) {
	static char buf[1024];
	if(NPN_IdentifierIsString(name)) {
		NPUTF8* strName = NPN_UTF8FromIdentifier(name);
		sprintf_s(buf, sizeof(buf), "'%s'", strName);
		NPN_MemFree(strName);
	}
	else {
		int intName = NPN_IntFromIdentifier(name);
		sprintf_s(buf, sizeof(buf), "%d", intName);
	}
	return buf;
}
Пример #28
0
void m_strFromNP(char **dst, NPString src) {
	// dst should not be a pointer without initailization
	if (dst == NULL)
		return;
	// free old pointer values
	if (*dst) {
		NPN_MemFree(*dst);
		*dst = NULL;
	}
	int len = src.UTF8Length;
	*dst = (char*) NPN_MemAlloc(len+1);
	memcpy(*dst, src.UTF8Characters, len);
	(*dst)[len] = '\0';
}
Пример #29
0
NPError 
NPP_Destroy(NPP instance, NPSavedData** save)
{
  SqueakPlugin *plugin;
  DPRINT("NP: NPP_Destroy\n");
  if (!instance)
    return NPERR_INVALID_INSTANCE_ERROR;
  plugin= (SqueakPlugin*) instance->pdata;
  if (plugin) {
    int i;
    if (plugin->sqwindow && plugin->display) {
      DPRINT("NP: DestroyWindow %x\n", 
	     plugin->sqwindow);
      XSetErrorHandler(IgnoreErrors);
      XSync(plugin->display,0);
      XKillClient(plugin->display, plugin->sqwindow);
      XSync(plugin->display,0);
    }
    if (plugin->pid) {
      DPRINT("NP: kill 0x%i\n", plugin->pid);
      kill(plugin->pid, SIGTERM);
      plugin->pid= 0;
    }
    if (plugin->input) {
      XtRemoveInput(plugin->input);
    }
    for (i= 0; i < 4; i++)
      if (plugin->pipes[i]) {
	close(plugin->pipes[i]);
	plugin->pipes[i]= 0;
      }
    if (plugin->srcUrl) {
      NPN_MemFree(plugin->srcUrl);
      plugin->srcUrl= NULL;
    }
    if (plugin->srcFilename) {
      NPN_MemFree(plugin->srcFilename);
      plugin->srcFilename= NULL;
    }
    if (plugin->failureUrl) {
      NPN_MemFree(plugin->failureUrl);
      plugin->failureUrl= NULL;
    }
    if (plugin->argv) {
      for (i= 0; i < plugin->argc; i++) {
	if (plugin->argv[i])
	  NPN_MemFree(plugin->argv[i]);
      }
      plugin->argc= 0;
      NPN_MemFree(plugin->argv);
      plugin->argv= NULL;
    }
    NPN_MemFree(plugin);
  }
  instance->pdata= NULL;
  return NPERR_NO_ERROR;
}
Пример #30
0
	void CPlugin::SetStatus(const CString& text)
	{
		if (ShouldShowStatusOurselves())
		{
			FireEvent(_T("IEStatusChanged"), text);
			return;
		}

		if (m_pNPInstance)
		{
			char* message = CStringToNPStringCharacters(text);
			NPN_Status(m_pNPInstance, message);
			NPN_MemFree(message);
		}
	}