コード例 #1
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;
}
コード例 #2
0
ファイル: NPSqueak.c プロジェクト: fniephaus/squeak
void SqueakPluginPostData(void *instance, char *url, char *target, char *data, int id)
{
	NPError err;
	if(ieMode)
		err = NPN_PostURL((NPP)instance, url, target, data ? strlen(data) : 0, data, 0);
	else
		err = NPN_PostURLNotify((NPP)instance, url, target, data ? strlen(data) : 0, data, 0, (void*) id);
}
コード例 #3
0
NS_METHOD
CPluginManager::PostURL(nsISupports* inst, const char* url, const char* target,
                        PRUint32 postDataLen, const char* postData,
                        PRBool isFile, void* notifyData,
                        const char* altHost, const char* referrer,
                        PRBool forceJSEnabled,
                        PRUint32 postHeadersLength, const char* postHeaders)
{
    // assert( npp != NULL );
    // assert( url != NULL );
 	assert( inst != NULL);

    nsIPluginInstance* pPluginInstance = NULL;
    nsIPluginInstancePeer* pPluginInstancePeer = NULL;

    if (NS_FAILED(inst->QueryInterface(kIPluginInstanceIID, (void**) &pPluginInstance)))
    {
        return NS_ERROR_FAILURE;
    }

    if (NS_FAILED(pPluginInstance->GetPeer(&pPluginInstancePeer)))
    {
        pPluginInstance->Release();
        return NS_ERROR_FAILURE;
    }

	CPluginInstancePeer* instancePeer = (CPluginInstancePeer*)pPluginInstancePeer;
	NPP npp = instancePeer->GetNPPInstance();

    pPluginInstance->Release();
    pPluginInstancePeer->Release();
    NPError err;
    // Call the correct PostURL* function.
    // This is determinded by checking notifyData.
    if (notifyData == NULL) {
        err = NPN_PostURL(npp, url, target, postDataLen, postData, isFile);
    } else {
        err = NPN_PostURLNotify(npp, url, target, postDataLen, postData, isFile, notifyData);
    }
    UNUSED(altHost);
    UNUSED(referrer);
    UNUSED(forceJSEnabled);
    UNUSED(postHeadersLength);
    UNUSED(postHeaders);
    return fromNPError[err];
}
コード例 #4
0
ファイル: qnp.cpp プロジェクト: kthxbyte/Qt1.45-Linaro
/*!
  This function is not tested.  It is an interface to the NPN_PostURL
  function of the Netscape Plugin API.

  See also:
  <a href=http://developer.netscape.com/library/documentation/communicator/plugin/refpgur.htm#npnposturl>
  Netscape: NPN_PostURL method</a>
*/
void QNPInstance::postURL(const char* url, const char* window,
	     uint len, const char* buf, bool file)
{
    NPN_PostURL( pi->npp, url, window, len, buf, file );
}
コード例 #5
0
DWORD CPluginBase::makeNPNCall(NPAPI_Action action, DWORD dw1, DWORD dw2, DWORD dw3, 
                           DWORD dw4, DWORD dw5, DWORD dw6, DWORD dw7)
{
  DWORD dwRet = 0L;
  DWORD dwTickEnter = XP_GetTickCount();

  switch (action)
  {
    case action_invalid:
      assert(0);
      break;
    case action_npn_version:
    {
      static int iP_maj = 0;
      static int iP_min = 0;
      static int iN_maj = 0;
      static int iN_min = 0;
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)&iP_maj;
      if(dw2 == DEFAULT_DWARG_VALUE)
        dw2 = (DWORD)&iP_min;
      if(dw3 == DEFAULT_DWARG_VALUE)
        dw3 = (DWORD)&iN_maj;
      if(dw4 == DEFAULT_DWARG_VALUE)
        dw4 = (DWORD)&iN_min;
      NPN_Version((int *)dw1, (int *)dw2, (int *)dw3, (int *)dw4);
      break;
    }
    case action_npn_get_url_notify:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      dwRet = NPN_GetURLNotify((NPP)dw1, (char *)dw2, (char *)dw3, (void *)dw4);
      break;
    case action_npn_get_url:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      dwRet = NPN_GetURL((NPP)dw1, (char *)dw2, (char *)dw3);
      break;
    case action_npn_post_url_notify:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      dwRet = NPN_PostURLNotify((NPP)dw1, (char *)dw2, (char *)dw3, (int32)dw4, (char *)dw5, 
                                (BOOL)dw6, (void *)dw7);
      break;
    case action_npn_post_url:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      dwRet = NPN_PostURL((NPP)dw1, (char *)dw2, (char *)dw3, (int32)dw4, (char *)dw5, (BOOL)dw6);
      break;
    case action_npn_new_stream:
      assert(m_pStream == NULL);
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      if(dw4 == DEFAULT_DWARG_VALUE)
        dw4 = (DWORD)&m_pStream;
      dwRet = NPN_NewStream((NPP)dw1, (char *)dw2, (char *)dw3, (NPStream **)dw4);
      break;
    case action_npn_destroy_stream:
      assert(m_pStream != NULL);
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      if(dw2 == DEFAULT_DWARG_VALUE)
        dw2 = (DWORD)m_pStream;
      dwRet = NPN_DestroyStream((NPP)dw1, (NPStream *)dw2, (NPError)dw3);
      m_pStream = NULL;
      break;
    case action_npn_request_read:
      break;
    case action_npn_write:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      if(dw2 == DEFAULT_DWARG_VALUE)
        dw2 = (DWORD)m_pStream;
      dwRet = NPN_Write((NPP)dw1, (NPStream *)dw2, (int32)dw3, (void *)dw4);
      break;
    case action_npn_status:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      NPN_Status((NPP)dw1, (char *)dw2);
      break;
    case action_npn_user_agent:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      dwRet = (DWORD)NPN_UserAgent((NPP)dw1);
      break;
    case action_npn_mem_alloc:
      assert(m_pNPNAlloced == NULL);
      m_pNPNAlloced = NPN_MemAlloc((int32)dw1);
      dwRet = (DWORD)m_pNPNAlloced;
      if(m_pNPNAlloced != NULL)
      {
        for(int i = 0; i < (int)dw1; i++)
          *(((BYTE *)m_pNPNAlloced) + i) = 255;
      }
      break;
    case action_npn_mem_free:
      assert(m_pNPNAlloced != NULL);
      dw1 = (DWORD)m_pNPNAlloced;
      NPN_MemFree((void *)dw1);
      m_pNPNAlloced = NULL;
      break;
    case action_npn_mem_flush:
      dwRet = (DWORD)NPN_MemFlush((int32)dw1);
      break;
    case action_npn_reload_plugins:
      NPN_ReloadPlugins((NPBool)dw1);
      break;
    case action_npn_get_java_env:
      dwRet = (DWORD)NPN_GetJavaEnv();
      break;
    case action_npn_get_java_peer:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      dwRet = (DWORD)NPN_GetJavaPeer((NPP)dw1);
      break;
    case action_npn_get_value:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      if(dw3 == DEFAULT_DWARG_VALUE)
        dw3 = (DWORD)m_pValue;
      dwRet = (DWORD)NPN_GetValue((NPP)dw1, (NPNVariable)dw2, (void *)dw3);
      break;
    case action_npn_set_value:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      if(dw3 == DEFAULT_DWARG_VALUE)
        dw3 = (DWORD)m_pValue;

      // note that Mozilla expects boolean values not as a pointer to BOOL 
      // but rather as simply null and not null, let's convert
      if((dw2 == NPPVpluginWindowBool) ||
         (dw2 == NPPVpluginTransparentBool) ||
         (dw2 == NPPVpluginKeepLibraryInMemory)) {
        dwRet = (DWORD)NPN_SetValue((NPP)dw1, (NPPVariable)dw2, (void *)(*(BOOL *)dw3));
      } else
        dwRet = (DWORD)NPN_SetValue((NPP)dw1, (NPPVariable)dw2, (void *)dw3);
      break;
    case action_npn_invalidate_rect:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      NPN_InvalidateRect((NPP)dw1, (NPRect *)dw2);
      break;
    case action_npn_invalidate_region:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      NPN_InvalidateRegion((NPP)dw1, (NPRegion)dw2);
      break;
    case action_npn_force_redraw:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      NPN_ForceRedraw((NPP)dw1);
      break;
    default:
      assert(0);
      break;
  }

  DWORD dwTickReturn = XP_GetTickCount();
  pLogger->appendToLog(action, dwTickEnter, dwTickReturn, dwRet, dw1, dw2, dw3, dw4, dw5, dw6, dw7);

  return dwRet;
}