NS_METHOD CPluginManager::MemFlush(PRUint32 size) { #ifdef XP_MAC return NPN_MemFlush(size); #else return 0; #endif }
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; }