From eaa7ea38ece7f538ed75928400dbc11a5e0e9a6f Mon Sep 17 00:00:00 2001 From: "serge%netscape.com" Date: Sat, 23 Mar 2002 02:56:43 +0000 Subject: [PATCH] not part of the build, bug 105959, add NPN_ReqestRead() support to tester plugin --- .../plugin/tools/tester/common/npp_gate.cpp | 10 ++++++ .../plugin/tools/tester/common/strconv.cpp | 28 ++++++++++++++++ .../plugin/tools/tester/include/plugbase.h | 1 + .../plugin/tools/tester/windows/guihlp.cpp | 33 +++++++++++++++++++ modules/plugin/tools/tester/windows/npapi.rc | 2 +- 5 files changed, 73 insertions(+), 1 deletion(-) diff --git a/modules/plugin/tools/tester/common/npp_gate.cpp b/modules/plugin/tools/tester/common/npp_gate.cpp index c0a3f9f7f9ab..d9286f0bc6bd 100644 --- a/modules/plugin/tools/tester/common/npp_gate.cpp +++ b/modules/plugin/tools/tester/common/npp_gate.cpp @@ -194,6 +194,9 @@ Return: DWORD dwTickReturn = XP_GetTickCount(); pLogger->appendToLog(action_npp_new_stream, dwTickEnter, dwTickReturn, (DWORD)ret, (DWORD)instance, (DWORD)type, (DWORD)stream, (DWORD)seekable, (DWORD)stype); + if (pPlugin->m_firstAction == action_npn_request_read && seekable) { + *stype = NP_SEEK; + } return ret; } @@ -233,6 +236,13 @@ Return: pLogger->appendToLog(action_npp_write, dwTickEnter, dwTickReturn, (DWORD)ret, (DWORD)instance, (DWORD)stream, (DWORD)offset, (DWORD)len, (DWORD)buffer); + if (pPlugin->m_firstAction == action_npn_request_read) { + if (stream->notifyData) { + NPByteRange* rangeList = (NPByteRange*) stream->notifyData; + NPN_RequestRead(stream, rangeList); + stream->notifyData = 0; + } + } return ret; } diff --git a/modules/plugin/tools/tester/common/strconv.cpp b/modules/plugin/tools/tester/common/strconv.cpp index 638601485dad..30419b3593fb 100644 --- a/modules/plugin/tools/tester/common/strconv.cpp +++ b/modules/plugin/tools/tester/common/strconv.cpp @@ -292,3 +292,31 @@ DWORD convertStringToNPPVariable1(DWORD * pdw1) return dwRet; } + +NPByteRange * convertStringToNPByteRangeList(LPSTR szString) +{ + NPByteRange **brNextFromPrev, *brList = 0; + if(szString) { + int offset = -1, len = -1; + char *p = szString; + while (EOF != sscanf((const char*)p, "%d-%d", &offset, &len)) { + if (offset == -1 || len == -1) + break; + NPByteRange *brCurr = new NPByteRange; + brCurr->offset = offset; + brCurr->length = len; + brCurr->next = 0; + if (!brList) + brList = brCurr; + else + *brNextFromPrev = brCurr; + + brNextFromPrev = &brCurr->next; + + if (!(p = strchr(p, ','))) + break; + while(*(++p) == ' '); // cut off white spaces + } + } + return brList; +} \ No newline at end of file diff --git a/modules/plugin/tools/tester/include/plugbase.h b/modules/plugin/tools/tester/include/plugbase.h index ac029fe088ab..ab30d234e47b 100644 --- a/modules/plugin/tools/tester/include/plugbase.h +++ b/modules/plugin/tools/tester/include/plugbase.h @@ -69,6 +69,7 @@ private: public: void * m_pNPNAlloced; // used by NPN_MemFree/Alloc in manual mode void * m_pValue; // used by NPN_Get/SetValue stuff + NPAPI_Action m_firstAction; // = action_invalid; public: CPluginBase(NPP pNPInstance, WORD wMode); diff --git a/modules/plugin/tools/tester/windows/guihlp.cpp b/modules/plugin/tools/tester/windows/guihlp.cpp index e368407958e0..710e02acc69d 100644 --- a/modules/plugin/tools/tester/windows/guihlp.cpp +++ b/modules/plugin/tools/tester/windows/guihlp.cpp @@ -45,6 +45,8 @@ #include "plugin.h" #include "comstrs.h" +static char szDefaultNPByteRangeList[] = "100-100,200-100,300-100"; + static char szNotImplemented[] = "Currently not implemented"; void EnableWindowNow(HWND hWnd, BOOL bEnable) @@ -253,11 +255,18 @@ void updateUI(HWND hWnd) } else if(strcmp(szString, STRING_NPN_REQUESTREAD) == 0) { +//serge + showArgControls7(hWnd, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE); + enableEdits7(hWnd, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE); + setStaticTexts7(hWnd, "instance:", "URL:", "Range:", "notifyData:", "", "", ""); + setEditTexts7(hWnd, szNPInstance,NS_SAMPLE_URL,szDefaultNPByteRangeList,"0","","",""); + /* EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_GO), FALSE); ShowWindow(GetDlgItem(hWnd, IDC_STATIC_INFO), SW_SHOW); Static_SetText(GetDlgItem(hWnd, IDC_STATIC_INFO), szNotImplemented); showArgControls7(hWnd, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE); ShowWindow(GetDlgItem(hWnd, IDC_BUTTON_PASTE), SW_HIDE); + */ } else if(strcmp(szString, STRING_NPN_DESTROYSTREAM) == 0) { @@ -417,6 +426,14 @@ void updateUI(HWND hWnd) assert(0); } +/* +NPByteRange g_npByteRangeList[] = { + {100, 100, npByteRangeList + 1}, + {200, 100, npByteRangeList + 2}, + {300, 100, 0} +}; +*/ + void onGo(HWND hWnd) { CPlugin * pPlugin = (CPlugin *)GetWindowLong(hWnd, DWL_USER); @@ -459,6 +476,22 @@ void onGo(HWND hWnd) dwTarget = (DWORD)sz2; pPlugin->makeNPNCall(action_npn_get_url_notify, DEFAULT_DWARG_VALUE, (DWORD)sz1, dwTarget, dwData); } + else if(strcmp(szString, STRING_NPN_REQUESTREAD) == 0) + { + extern NPByteRange * convertStringToNPByteRangeList(LPSTR szString); + + Edit_GetText(GetDlgItem(hWnd, IDC_EDIT_ARG2), sz1, sizeof(sz1)); + Edit_GetText(GetDlgItem(hWnd, IDC_EDIT_ARG3), sz2, sizeof(sz2)); + DWORD dwData = (DWORD)GetDlgItemInt(hWnd, IDC_EDIT_ARG4, &bTranslated, FALSE); + DWORD dwTarget = 0L; + NPByteRange *npByteRangeList = convertStringToNPByteRangeList(sz2); + if (!npByteRangeList) { // use default szDefaultNPByteRangeList + npByteRangeList = convertStringToNPByteRangeList(szDefaultNPByteRangeList); + } + pPlugin->m_firstAction = action_npn_request_read; + dwData = (DWORD) npByteRangeList; + pPlugin->makeNPNCall(action_npn_get_url_notify, DEFAULT_DWARG_VALUE, (DWORD)sz1, dwTarget, dwData); + } else if(strcmp(szString, STRING_NPN_POSTURL) == 0) { Edit_GetText(GetDlgItem(hWnd, IDC_EDIT_ARG2), sz1, sizeof(sz1)); diff --git a/modules/plugin/tools/tester/windows/npapi.rc b/modules/plugin/tools/tester/windows/npapi.rc index a7100e792e40..f1b58d253c06 100644 --- a/modules/plugin/tools/tester/windows/npapi.rc +++ b/modules/plugin/tools/tester/windows/npapi.rc @@ -1,12 +1,12 @@ //Microsoft Developer Studio generated resource script. // -#include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // +#include "resource.h" #include "winresrc.h" /////////////////////////////////////////////////////////////////////////////