not part of the build, bug 105959, add NPN_ReqestRead() support to tester plugin

This commit is contained in:
serge%netscape.com 2002-03-23 02:56:43 +00:00
Родитель ff0b611455
Коммит eaa7ea38ec
5 изменённых файлов: 73 добавлений и 1 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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));

Просмотреть файл

@ -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"
/////////////////////////////////////////////////////////////////////////////