示例#1
0
int NPPluginExec(const char *var_list)
{
	char  *wurl = NULL;
	uint16_t stype = NP_NORMAL;
	char *svar_list = strdup(var_list);
	char *argn[100], *argv[100];
	int count = ParseVarList(svar_list, argn, argv, 100);

#ifdef VIEWER
	for (int i = 0; i < count; i++)
		if (stricmp("src", argn[i]) == 0)
			wurl = argv[i];

	fprintf(stderr, "count: %s\n", wurl);
	if (count == 0 || wurl == NULL) {
		free(svar_list);
		return 0;
	}

	fprintf(stderr, "URL: %s\n", wurl);
	NPPlugin * plugin = new NPPlugin(__netscape_hwnd);
	__plugin_instance_list.insert(plugin);
	memset(plugin, 0, sizeof(NPP_t));
	__pluginfunc.newp("application/x-shockwave-flash",
			plugin, 1, count, argn, argv, NULL);
	plugin->SetWindow();
	plugin->AttachWindow();
	NPN_GetURLNotify(plugin, wurl, NULL, NULL);
#endif
	free(svar_list);
	return 0;
}
示例#2
0
void SqueakPluginRequestStream(void *instance, char *url, char *target, int id)
{
	NPError err;
	if(ieMode)
		err = NPN_GetURL((NPP)instance, url, target);
	else
		err = NPN_GetURLNotify((NPP)instance, url, target, (void*) id);
}
示例#3
0
文件: qnp.cpp 项目: aroraujjwal/qt3
/*!
    Requests that the given \a url be retrieved and sent to
    the named \a window. See Netscape's JavaScript documentation for
    an explanation of window names. Passes the arguments including \a
    data to NPN_GetURLNotify.

    \sa
    \link http://developer.netscape.com/docs/manuals/communicator/plugin/refpgur.htm#npngeturlnotify
    Netscape: NPN_GetURLNotify method\endlink
*/
void QNPInstance::getURLNotify(const char* url, const char* window, void*data)
{
#ifdef Q_WS_WIN // Only on Windows?
    NPN_GetURLNotify( pi->npp, url, window, data );
#else
    Q_UNUSED( url );
    Q_UNUSED( window );
    Q_UNUSED( data );
#endif
}
示例#4
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);
}
示例#5
0
// (Corresponds to NPN_GetURL and NPN_GetURLNotify.)
//   notifyData: When present, URLNotify is called passing the notifyData back
//          to the client. When NULL, this call behaves like NPN_GetURL.
// New arguments:
//   peer:  A plugin instance peer. The peer's window will be used to display
//          progress information. If NULL, the load happens in the background.
//   altHost: An IP-address string that will be used instead of the host
//          specified in the URL. This is used to prevent DNS-spoofing attacks.
//          Can be defaulted to NULL meaning use the host in the URL.
//   referrer: 
//   forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs,
//          even if the user currently has JavaScript disabled. 
NS_METHOD
CPluginManager::GetURL(nsISupports* inst, const char* url, const char* target,
                       void* notifyData, const char* altHost,
                       const char* referrer, PRBool forceJSEnabled)
{
    // 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 GetURL* function.
    // This is determinded by checking notifyData.
    if (notifyData == NULL) {
        err = NPN_GetURL(npp, url, target);
    } else {
        err = NPN_GetURLNotify(npp, url, target, notifyData);
    }
    UNUSED(altHost);
    UNUSED(referrer);
    UNUSED(forceJSEnabled);
    return fromNPError[err];
}
/*!
    Requests that the \a url be retrieved and sent to the named \a window (or
    a new window if \a window is empty), and returns the ID of the request that is
    delivered to transferComplete() when the get-operation has finished. Returns 0 when
    the browser or the system doesn't support notification, or -1 when an error occurred.

    \code
    void MyPlugin::aboutTrolltech()
    {
        openUrl("http://www.trolltech.com");
    }
    \endcode

    See Netscape's JavaScript documentation for an explanation of window names.

    \sa transferComplete() uploadData() uploadFile()
*/
int QtNPBindable::openUrl(const QString &url, const QString &window)
{
    if (!pi)
        return -1;
    QString wnd = window;
    if (wnd.isEmpty())
        wnd = "_blank";

    qint32 id = pi->getNotificationSeqNum();
    NPError err = NPN_GetURLNotify(pi->npp, url.toLocal8Bit().constData(), wnd.toLocal8Bit().constData(), reinterpret_cast<void*>(id));
    if (err != NPERR_NO_ERROR)
        id = -1;

    if (err == NPERR_INCOMPATIBLE_VERSION_ERROR) {
        err = NPN_GetURL(pi->npp, url.toLocal8Bit().constData(), wnd.toLocal8Bit().constData());
        if (NPERR_NO_ERROR == err)
            id = 0;
        else
            id = -1;
    }
    return id;
}
void CJavaInstanceCB::javascriptRequest(char * buff) {
    NPN_GetURLNotify(m_npp, buff, NULL, (void*) JA_JSR);
}
示例#8
0
/*!
  Print the instance full-page.  By default, this returns FALSE, causing the
  browser to call the (embedded) print() function instead.
  Requests that the given URL be retrieved and sent to the named
  window.  See Netscape's JavaScript documentation for an explanation
  of window names.

  See also:
  <a href=http://developer.netscape.com/docs/manuals/communicator/plugin/refpgur.htm#npngeturlnotify>
  Netscape: NPN_GetURLNotify method</a>
*/
void QNPInstance::getURLNotify(const char* url, const char* window, void*data)
{
#ifdef _WS_WIN_ // Only on Windows?
    NPN_GetURLNotify( pi->npp, url, window, data );
#endif
}
示例#9
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;
}