コード例 #1
0
ファイル: nullplugin.c プロジェクト: amyvmiwei/firefox
/* 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);
}
コード例 #2
0
ファイル: plugin.cpp プロジェクト: MozillaOnline/gecko-dev
void CPlugin::onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags)
{
  if(!readyToRefresh())
    showGetPluginDialog();
  else
    NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self");
}
コード例 #3
0
ファイル: Download.cpp プロジェクト: jimmccurdy/ArchiveGit
bool CDownload::Next()
{
	if (m_List.empty())
		return false;

	DOWNLOAD& Download = m_List.front();
	CString strSrcURL = Download.strSrcURL;
	if (strSrcURL.GetLength() <= 0)
		return false;

	if (m_bShowProgress)
	{
		m_ProgressDialog.SetLineText(1/*dwLine*/, strSrcURL);
	    m_ProgressDialog.UpdateProgress(0, 100/*dwMax*/);
		m_ProgressDialog.ResetTimer();
	}

	if (m_bGoOnline)
	{
		CInternet Internet;
		if (!Internet.GoOnline(strSrcURL, NULL/*hwndParentWindow*/, false/*bForceLANOnlineSilently*/))
			return false;
	}

	#ifdef NETSCAPE
		CCtp* pCtp = (CCtp*)m_lParam;
		NPN_GetURL(pCtp->m_pNPPInstance, strSrcURL, NULL);
	#else
		CBindStatusCallback2<CCtp>::Download(CComBSTR(strSrcURL), this, m_pClientSite);
	#endif NETSCAPE

	return true;
}
コード例 #4
0
ファイル: moz_main.c プロジェクト: Limsik/e17
void pdfmoz_gotouri(pdfmoz_t *moz, fz_obj *uri)
{
    char buf[2048];
    memcpy(buf, fz_tostrbuf(uri), fz_tostrlen(uri));
    buf[fz_tostrlen(uri)] = 0;
    NPN_GetURL(moz->inst, buf, "_blank");
}
コード例 #5
0
ファイル: npsqueak.c プロジェクト: fniephaus/squeak
NPError 
NPP_SetWindow(NPP instance, NPWindow *pNPWindow)
{
  SqueakPlugin *plugin;
  if (!instance)
    return NPERR_INVALID_INSTANCE_ERROR;
  plugin= (SqueakPlugin*) instance->pdata;
  if (!plugin)
    return NPERR_GENERIC_ERROR;
  if (plugin->failureUrl) {
    DPRINT("NP: opening failure URL");
    NPN_GetURL(plugin->instance, plugin->failureUrl, "_self");
    return NPERR_NO_ERROR;
  }
  if (pNPWindow == NULL) 
    return NPERR_NO_ERROR;
  
  if (!plugin->display) {
    /* first time only */
    plugin->display= 
      ((NPSetWindowCallbackStruct *)pNPWindow->ws_info)->display;
  }
  SetWindow(plugin, (Window) pNPWindow->window, 
	    pNPWindow->width, pNPWindow->height);
  if (!plugin->pid)
    Run(plugin);
  return NPERR_NO_ERROR;
}
コード例 #6
0
ファイル: NPSqueak.c プロジェクト: fniephaus/squeak
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);
}
コード例 #7
0
ファイル: plugin.cpp プロジェクト: MozillaOnline/gecko-dev
NPError CPlugin::newStream(NPMIMEType type, NPStream *stream, NPBool seekable, uint16_t *stype)
{
  if (!m_bWaitingStreamFromPFS)
    return NPERR_NO_ERROR;

  m_bWaitingStreamFromPFS = FALSE;
  m_PFSStream = stream;

  if (stream) {
    if (type && !strcmp(type, "application/x-xpinstall"))
      NPN_GetURL(m_pNPInstance, stream->url, "_self");
    else
      NPN_GetURL(m_pNPInstance, stream->url, "_blank");
  }

  return NPERR_NO_ERROR;
}
コード例 #8
0
static int ShowDocument(jint id, char* url, char* target)
{
   PluginInstance* inst;
   inst = GetInstance(id);
   if (!inst) return JNI_FALSE;
   NPN_GetURL(inst->m_peer, url, target);
   return JNI_TRUE;
}
コード例 #9
0
LRESULT CIEDlg::OnUpdateTitle(WPARAM wp, LPARAM lp)
{
	if (m_PluginInst) {
		const char* scriptStr = "javascript:document.title=document.getElementById(\'IETab2\').title;";
		NPN_GetURL( m_PluginInst->getInstance(), scriptStr, NULL );
	}
	return LRESULT(0);
}
コード例 #10
0
ファイル: Download.cpp プロジェクト: jimmccurdy/ArchiveGit
bool CDownload::Next()
{
	if (m_List.empty())
		return false;

	DOWNLOAD& Download = m_List.front();
	CString strSrcURL = Download.strSrcURL;
	if (strSrcURL.GetLength() <= 0)
		return false;

	NPN_GetURL(m_pPlugin->m_pNPPInstance, strSrcURL, NULL);
	return true;
}
コード例 #11
0
ファイル: plugin.cpp プロジェクト: xgc820313/js2n
bool SendEventToJS( const PString& strEvent )
{
	// UF: This might be called from a different thread than the
	// one that created the plugin UI. We should actually post
	// a platform specific Window message so that the call to
	// the hosting browser of this plugin will be made in the
	// same thread that "holds" the plugin UI (be it an NPAPI
	// plugin or ActiveX plugin)

	// This implementation is specific to NPAPI plugins.
	PString strJSCall = "javascript:callback('" + strEvent + "')"; 
	return (NPN_GetURL( g_pNPInstance, strJSCall,"_self") == NPERR_NO_ERROR );
}
コード例 #12
0
void CIEDlg::OnDocumentCompleteIe(LPDISPATCH pDisp, VARIANT* URL)
{
	if (!m_PluginInst) return;

	const char* scriptStr = "javascript:document.title=document.getElementById(\'IETab2\').title;";
	NPN_GetURL( m_PluginInst->getInstance(), scriptStr, NULL );

	CIETabScriptable* pObj = m_PluginInst->getScriptableObject();;
	if (pObj)
	{
		pObj->m_lProgress = -1;
		pObj->requestProgressChange(-1);
	}
}
コード例 #13
0
ファイル: plugin.cpp プロジェクト: MozillaOnline/gecko-dev
void CPlugin::getPluginRegular()
{
  assert(m_bOnline);

  char * szURL = createURLString();

  assert(szURL != NULL);
  if(szURL == NULL)
    return;

  dbgOut3("CPlugin::getPluginRegular(), %#08x '%s'", m_pNPInstance, szURL);

  NPN_GetURL(m_pNPInstance, szURL, NULL);
  m_bWaitingStreamFromPFS = TRUE;
}
コード例 #14
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];
}
コード例 #15
0
/*!
    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;
}
コード例 #16
0
ファイル: npmngplg.c プロジェクト: 03050903/Torque3D
static void ContextMenu(PluginInstance *This, HWND hwnd)
{
	int cmd;
	HMENU menu;
	POINT pt;
	unsigned char buf[MAX_PATH], buf2[200];

	pt.x=0; pt.y=0;
	GetCursorPos(&pt);

	// create context menu dynamically
	menu=CreatePopupMenu();
	if(This->errorflag) {
		AppendMenu(menu,MF_ENABLED,ID_SHOWERROR,"SHOW ERROR MESSAGE");
		AppendMenu(menu,MF_SEPARATOR,0,NULL);
	}

	AppendMenu(menu,(This->loadstate>=STATE_LOADED?MF_ENABLED:MF_GRAYED),ID_SAVEAS,"Save Image &As...");
	AppendMenu(menu,(This->lpdib?MF_ENABLED:MF_GRAYED),ID_COPYIMAGE,"&Copy Image");
	AppendMenu(menu,MF_ENABLED,ID_COPYURL,"Cop&y Image Location");
	if(This->islink) {
		AppendMenu(menu,MF_ENABLED,ID_COPYLINKLOC,"Copy Link Location");
	}

	url2filename(buf,This->url);
	escapeformenu(buf);
	if(lstrlen(buf)) {
		wsprintf(buf2,"View Image (%s)",buf);
	}
	else {
		wsprintf(buf2,"View Image");
	}
	AppendMenu(menu,MF_ENABLED,ID_VIEWIMAGE,buf2);


	AppendMenu(menu,MF_SEPARATOR,0,NULL);
	// AppendMenu(menu,(This->mng?MF_ENABLED:MF_GRAYED),ID_STOPANIM,"Stop Animation");


	AppendMenu(menu,(This->mng?MF_ENABLED:MF_GRAYED)|
		(This->frozen?MF_CHECKED:MF_UNCHECKED),ID_FREEZE,"&Freeze Animation");

	// AppendMenu(menu,(This->mng?MF_ENABLED:MF_GRAYED),ID_RESTARTANIM,"Restart Animation");

	AppendMenu(menu,MF_SEPARATOR,0,NULL);

	AppendMenu(menu,MF_ENABLED,ID_PROPERTIES,"Properties...");

	AppendMenu(menu,MF_ENABLED,ID_ABOUT,"About MNG Plug-in...");

	cmd=TrackPopupMenuEx(menu, TPM_LEFTALIGN|TPM_TOPALIGN|TPM_NONOTIFY|TPM_RETURNCMD|
		TPM_RIGHTBUTTON,pt.x,pt.y,hwnd,NULL);

	DestroyMenu(menu);

	switch(cmd) {

	case ID_STOPANIM:
		if(This->mng) {
			KillTimer(This->fhWnd,1);
			This->timer_set=0;
			mng_display_freeze(This->mng);
		}
		break;

	case ID_FREEZE:
		This->frozen = !This->frozen;
		if(This->frozen) {
			KillTimer(This->fhWnd,1);
			This->timer_set=0;
			mng_display_freeze(This->mng);
		}
		else {
			handle_read_error(This, mng_display_resume(This->mng) );

		}
		break;

	case ID_RESTARTANIM:
		if(!This->frozen) {
			KillTimer(This->fhWnd,1);
			This->timer_set=0;
			mng_display_freeze(This->mng);
		}
		This->frozen=1;
		mng_display_reset(This->mng);
		This->frozen=0;
		handle_read_error(This, mng_display_resume(This->mng) );
		break;

	case ID_SAVEAS:
		SaveImage(This);
		break;
	case ID_COPYIMAGE:
		if(This->lpdib) {
			CopyToClipboard(This,(unsigned char*)This->lpdib,This->dibsize,CF_DIB);
		}
		else {
			warn(This,"No image to copy");
		}
		break;
	case ID_COPYURL:
		CopyToClipboard(This,This->url,lstrlen(This->url)+1,CF_TEXT);
		break;
	case ID_COPYLINKLOC:
		if(This->islink) {
			CopyToClipboard(This,This->linkurl,lstrlen(This->linkurl)+1,CF_TEXT);
		}
		break;
	case ID_VIEWIMAGE:
		if(lstrlen(This->url)) 
			NPN_GetURL(This->instance,This->url,"_self");
		break;
	case ID_PROPERTIES:
		PropDialog(This);
		break;
	case ID_ABOUT:
		AboutDialog(This);
		break;
	case ID_SHOWERROR:
		display_last_error(This);
		break;
	}
}
コード例 #17
0
ファイル: qnp.cpp プロジェクト: kthxbyte/Qt1.45-Linaro
/*!
  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/library/documentation/communicator/plugin/refpgur.htm#npngeturl>
  Netscape: NPN_GetURL method</a>
*/
void QNPInstance::getURL(const char* url, const char* window)
{
    NPN_GetURL( pi->npp, url, window );
}
コード例 #18
0
NPError NPP_DestroyStream(NPP instance, NPStream * stream, NPError reason)
{
#if 1
    log_function();
#endif
    if (!instance)
    {
        return NPERR_INVALID_INSTANCE_ERROR;
    }
    else
    {
        little_shoot_plugin * plugin = reinterpret_cast<little_shoot_plugin *>(
            instance->pdata
        );
    
        if (!plugin)
        {
            return NPERR_INVALID_INSTANCE_ERROR;
        }
        else
        {
            plugin->destroy_stream(stream->url);
            
            if (!plugin->get_stream())
            {
                const char * download_test_url = 
                    "http://www.littleshoot.org/downloadsWindow";

                NPN_GetURL(
                    instance, download_test_url, "_self"
                );
                
                /*
                static bool did_open_download_window = false;
                
                if (!did_open_download_window)
                {
                    did_open_download_window = true;
                    
                    NPN_GetURL(
                        instance, download_test_url, "_blank"
                    );
                }
            
                NPN_GetURL(
                    instance, "javascript:history.go(-1)", "_self"
                );
                 */
//            
//            
//                NPStream * s = plugin->get_stream();
//            
//            NPN_NewStream(instance, "text/html", 0, &s);
//            
//            
//            char html_buf[] = "<html>\n<body>\n\n<h2 align=center>LittleShoot is loading foo.bar...</h2>\n\n</body>\n</html>";
//            
//            int32 written = NPN_Write(instance, s, strlen(html_buf), html_buf);
//                
//                log_debug("Wrote " << written << " bytes.");
            
            }
            
           // NPN_DestroyStream(instance, s, NPRES_DONE);
        }
    }
    return NPERR_NO_ERROR;
}
コード例 #19
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;
}
コード例 #20
0
ファイル: npmngplg.c プロジェクト: 03050903/Torque3D
/*+++++++++++++++++++++++++++++++++++++++++++++++++
 * PluginWindowProc
 * Handle the Windows window-event loop.
 +++++++++++++++++++++++++++++++++++++++++++++++++*/
static LRESULT CALLBACK PluginWindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	PluginInstance* This;
	HDC hdc;
	RECT rect;
		
	This = (PluginInstance*) GetProp(hWnd, gInstanceLookupString);

	if(!This) return DefWindowProc( hWnd, Msg, wParam, lParam);

	switch(Msg) {

	case WM_ERASEBKGND:
		{
			HBRUSH br;
			hdc= (HDC)wParam;

			if(This->bkgdbrush)
				br=This->bkgdbrush;
			else
				br=GetStockObject(GRAY_BRUSH);

			GetClientRect(hWnd,&rect);
			FillRect(hdc,&rect,br);
			return 1;
		}

	case WM_HSCROLL:
	case WM_VSCROLL:
		scrollmsg(This,Msg,(int)(LOWORD(wParam)),(short int)(HIWORD(wParam)));
		return 0;

	case WM_SIZE:
		find_window_size(This);
		set_scrollbars(This);
		return 0;


	case WM_CONTEXTMENU: case WM_RBUTTONUP:
		ContextMenu(This, hWnd);
		return 0;


	case WM_SETCURSOR:
		if(LOWORD(lParam)==HTCLIENT) {
			if(This->islink) {
				SetCursor(This->linkcursor);
				return 1;
			}
		}
		break;

	case WM_LBUTTONDOWN:
		SetCapture(This->fhWnd);
		This->mouse_captured=1;

		if(This->dynamicmng && This->mng && !This->errorflag) {
			DynamicMNG_FireEvent(This,4,MAKEPOINTS(lParam));
		}
		return 0;
		
	case WM_LBUTTONUP:
		{
			RECT rc;
			POINT pt;

			if(This->mouse_captured) {
				ReleaseCapture();
				This->mouse_captured=0;
			}
			if(This->dynamicmng && This->mng && !This->errorflag) {
				DynamicMNG_FireEvent(This,5,MAKEPOINTS(lParam));
			}

			// if mouse is not over image, don't follow links, etc.
			GetWindowRect(This->fhWnd,&rc);
			GetCursorPos(&pt);
			if(!PtInRect(&rc,pt)) return 0;

			if(This->islink) {
				NPN_GetURL(This->instance,This->linkurl,This->linktarget);
				return 0;
			}
			else if(This->errorflag) {
				display_last_error(This);
			}
		}
		return 0;

	case WM_MOUSEMOVE:

		if(This->dynamicmng && This->mng && This->lpdib && !This->errorflag) {
			POINTS pos;
			int overimage;

			pos=MAKEPOINTS(lParam);
			overimage=0;
			if(pos.x>=0 && pos.x<This->lpdibinfo->biWidth && pos.y>=0 && pos.y<This->lpdibinfo->biHeight) {
				overimage=1;
			}

			if(overimage) {
				if(This->mouse_over_mng) {
					// mouse is still over image: mouse move event
					DynamicMNG_FireEvent(This,2,pos);  // 2=mouse move
				}
				else {
					// mouse wasn't over the image but now it is: mouse-enter event
					DynamicMNG_FireEvent(This,1,pos); // mouse enter
				}
			}
			else { // mouse not now over image
				if(This->mouse_over_mng) { // ... but it used to be
					pos.x=0; pos.y=0;
					DynamicMNG_FireEvent(This,3,pos); // 3=mouse leave
				}
			}

			This->mouse_over_mng=overimage; // remember for next time

			if(This->mouse_over_mng && (This->dynamicmng==1) ) {
#define MOUSE_POLL_INTERVAL  100    // milliseconds
				SetTimer(This->fhWnd,2,MOUSE_POLL_INTERVAL,NULL);
				This->timer2_set=0;
			}
		}
		return 0;

	case WM_PAINT:
		{
			PAINTSTRUCT paintStruct;
			HDC hdc;
			RECT rect2;

			hdc = BeginPaint( hWnd, &paintStruct );
			SetWindowOrgEx(hdc,This->xscrollpos,This->yscrollpos,NULL);

			GetClientRect(hWnd,&rect);
			if(This) {
				if(This->errorflag || !This->lpdib) {
					SelectObject(hdc,hfontMsg);
					Rectangle(hdc,rect.left,rect.top,rect.right,rect.bottom);
					rect2.left=rect.left+2;
					rect2.top=rect.top+2;
					rect2.right=rect.right-2;
					rect2.bottom=rect.bottom-2;
					if(This->errorflag) {
						DrawText(hdc,"MNG PLUG-IN ERROR!",-1,&rect2,DT_LEFT|DT_WORDBREAK);
					}
					else {
						if(This->loadstate>=STATE_LOADING) {
							DrawText(hdc,"MNG image loading...",-1,&rect2,DT_LEFT|DT_WORDBREAK);
						}
						else {
							DrawText(hdc,"MNG plug-in",-1,&rect2,DT_LEFT|DT_WORDBREAK);
						}
					}
				}
				else if(This->lpdib) {
					StretchDIBits(hdc,
						0,0,This->lpdibinfo->biWidth,This->lpdibinfo->biHeight,
						0,0,This->lpdibinfo->biWidth,This->lpdibinfo->biHeight,
						&((BYTE*)(This->lpdib))[sizeof(BITMAPINFOHEADER)],
						(LPBITMAPINFO)This->lpdib,DIB_RGB_COLORS,SRCCOPY);
				}
			}


			EndPaint( hWnd, &paintStruct );
		}
		return 0;

	case WM_TIMER:
		switch(wParam) {
		case 1: // the main animation timer
			KillTimer(hWnd,1);
			This->timer_set=0;

#ifdef MNGPLG_TRACE
			fprintf(tracefile,"WM_TIMER display_resume bytesloaded=%d\n",This->bytesloaded);
#endif

			if(This->mng) {
				if(!This->needresume) {
					handle_read_error(This, mng_display_resume(This->mng) );
				}
			}
			return 0;

		case 2: // timer for polling mouse position
			{
				RECT rc;
				POINT pt;
				POINTS pos;

				GetWindowRect(hWnd,&rc);
				GetCursorPos(&pt);
				if(!PtInRect(&rc,pt)) {
					KillTimer(hWnd,2);
					pos.x=0; pos.y=0;
					DynamicMNG_FireEvent(This,3,pos); // 3=mouse leave
					This->mouse_over_mng=0;
				}
			}
			return 0;
		}
		break;

	}

	/* Forward unprocessed messages on to their original destination
	 * (the window proc we replaced) */
	return This->fDefaultWindowProc(hWnd, Msg, wParam, lParam);
}