diff --git a/mozilla/modules/plugin/tools/tester/common/logger.cpp b/mozilla/modules/plugin/tools/tester/common/logger.cpp index 00f13c72ec4..87c5acc5b70 100644 --- a/mozilla/modules/plugin/tools/tester/common/logger.cpp +++ b/mozilla/modules/plugin/tools/tester/common/logger.cpp @@ -203,10 +203,9 @@ Frame: { if(m_bShowImmediately) { - if(m_pStream == NULL) - NPN_NewStream(m_pPluginInstance, m_szStreamType, m_szTarget, &m_pStream); + BOOL dosstyle = (m_pPlugin && m_pPlugin->isStandAlone()); - int iLength = formatLogItem(plis, szOutput, ""); + int iLength = formatLogItem(plis, szOutput, "", dosstyle); // we should fix the output string if it contains symbols isStandAlone()) + { + m_pPlugin->outputToNativeWindow(szOutput); + } + else + { + if(m_pStream == NULL) + NPN_NewStream(m_pPluginInstance, m_szStreamType, m_szTarget, &m_pStream); + + NPN_Write(m_pPluginInstance, m_pStream, iLength, (void *)szOutput); + } delete plis; } else @@ -269,15 +278,23 @@ void CLogger::clearLog() void CLogger::clearTarget() { - if(m_pStream != NULL) - NPN_DestroyStream(m_pPluginInstance, m_pStream, NPRES_DONE); - NPN_NewStream(m_pPluginInstance, m_szStreamType, m_szTarget, &m_pStream); - NPN_Write(m_pPluginInstance, m_pStream, 1, "\n"); - - if(!m_bShowImmediately) + if (m_pPlugin && m_pPlugin->isStandAlone()) { - NPN_DestroyStream(m_pPluginInstance, m_pStream, NPRES_DONE); - m_pStream = NULL; + m_pPlugin->outputToNativeWindow(""); + } + else + { + if(m_pStream != NULL) + NPN_DestroyStream(m_pPluginInstance, m_pStream, NPRES_DONE); + + NPN_NewStream(m_pPluginInstance, m_szStreamType, m_szTarget, &m_pStream); + NPN_Write(m_pPluginInstance, m_pStream, 1, "\n"); + + if(!m_bShowImmediately) + { + NPN_DestroyStream(m_pPluginInstance, m_pStream, NPRES_DONE); + m_pStream = NULL; + } } } @@ -291,24 +308,34 @@ void CLogger::dumpLogToTarget() if(m_pLog == NULL) return; - BOOL bTemporaryStream = ((m_pStream == NULL) && !getShowImmediatelyFlag()); + static char szOutput[1024]; - if(m_pStream == NULL) - NPN_NewStream(m_pPluginInstance, m_szStreamType, m_szTarget, &m_pStream); - - for(LogItemListElement * plile = m_pLog->m_pFirst; plile != NULL; plile = plile->pNext) + if (m_pPlugin && m_pPlugin->isStandAlone()) { - static char szOutput[1024]; - - int iLength = formatLogItem(plile->plis, szOutput, ""); - - NPN_Write(m_pPluginInstance, m_pStream, iLength, (void *)szOutput); + for(LogItemListElement * plile = m_pLog->m_pFirst; plile != NULL; plile = plile->pNext) + { + int iLength = formatLogItem(plile->plis, szOutput, "", TRUE); + m_pPlugin->outputToNativeWindow(szOutput); + } } - - if(bTemporaryStream) + else { - NPN_DestroyStream(m_pPluginInstance, m_pStream, NPRES_DONE); - m_pStream = NULL; + BOOL bTemporaryStream = ((m_pStream == NULL) && !getShowImmediatelyFlag()); + + if(m_pStream == NULL) + NPN_NewStream(m_pPluginInstance, m_szStreamType, m_szTarget, &m_pStream); + + for(LogItemListElement * plile = m_pLog->m_pFirst; plile != NULL; plile = plile->pNext) + { + int iLength = formatLogItem(plile->plis, szOutput, ""); + NPN_Write(m_pPluginInstance, m_pStream, iLength, (void *)szOutput); + } + + if(bTemporaryStream) + { + NPN_DestroyStream(m_pPluginInstance, m_pStream, NPRES_DONE); + m_pStream = NULL; + } } } diff --git a/mozilla/modules/plugin/tools/tester/common/npp_gate.cpp b/mozilla/modules/plugin/tools/tester/common/npp_gate.cpp index 388c9422aaa..48ef36efb93 100644 --- a/mozilla/modules/plugin/tools/tester/common/npp_gate.cpp +++ b/mozilla/modules/plugin/tools/tester/common/npp_gate.cpp @@ -43,6 +43,7 @@ #include "logger.h" extern CLogger * pLogger; + static char szINIFile[] = NPAPI_INI_FILE_NAME; static char szTarget[] = LOGGER_DEFAULT_TARGET; @@ -77,18 +78,24 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, ch pLogger = new CLogger(szTarget); } - pLogger->associate(pPlugin); - char szFileName[_MAX_PATH]; pPlugin->getModulePath(szFileName, sizeof(szFileName)); strcat(szFileName, szINIFile); pLogger->restorePreferences(szFileName); + pLogger->associate(pPlugin); + + if (pPlugin->isStandAlone()) + pPlugin->initStandAlone(); + Return: DWORD dwTickReturn = XP_GetTickCount(); pLogger->appendToLog(action_npp_new, dwTickEnter, dwTickReturn, (DWORD)ret, (DWORD)pluginType, (DWORD)instance, (DWORD)mode, (DWORD)argc, (DWORD)argn, (DWORD)argv, (DWORD)saved); + + pPlugin->autoStartScriptIfNeeded(); + return ret; } @@ -106,6 +113,9 @@ NPError NPP_Destroy (NPP instance, NPSavedData** save) pPlugin = (CPluginBase *)instance->pdata; if(pPlugin) { + if (pPlugin->isStandAlone()) + pPlugin->shutStandAlone(); + pPlugin->shut(); DestroyPlugin(pPlugin); goto Return; @@ -149,39 +159,42 @@ NPError NPP_SetWindow (NPP instance, NPWindow* pNPWindow) goto Return; } - // window just created - if(!pPlugin->isInitialized() && pNPWindow->window) { - if(!pPlugin->init((DWORD)pNPWindow->window)) { - delete pPlugin; - pPlugin = NULL; - ret = NPERR_MODULE_LOAD_FAILED_ERROR; + if (!pPlugin->isStandAlone()) + { + // window just created + if(!pPlugin->isInitialized() && pNPWindow->window) { + if(!pPlugin->init((DWORD)pNPWindow->window)) { + delete pPlugin; + pPlugin = NULL; + ret = NPERR_MODULE_LOAD_FAILED_ERROR; + goto Return; + } + + if(pLogger->getShowImmediatelyFlag()) { + pLogger->dumpLogToTarget(); + pLogger->clearLog(); + } goto Return; } - if(pLogger->getShowImmediatelyFlag()) { - pLogger->dumpLogToTarget(); - pLogger->clearLog(); + // window goes away + if(!pNPWindow->window && pPlugin->isInitialized()) { + pPlugin->shut(); + ret = NPERR_NO_ERROR; + goto Return; } - goto Return; - } - // window goes away - if(!pNPWindow->window && pPlugin->isInitialized()) { - pPlugin->shut(); - ret = NPERR_NO_ERROR; - goto Return; - } + // window resized? + if(pPlugin->isInitialized() && pNPWindow->window) { + ret = NPERR_NO_ERROR; + goto Return; + } - // window resized? - if(pPlugin->isInitialized() && pNPWindow->window) { - ret = NPERR_NO_ERROR; - goto Return; - } - - // this should not happen, nothing to do - if(!pNPWindow->window && !pPlugin->isInitialized()) { - ret = NPERR_NO_ERROR; - goto Return; + // this should not happen, nothing to do + if(!pNPWindow->window && !pPlugin->isInitialized()) { + ret = NPERR_NO_ERROR; + goto Return; + } } Return: diff --git a/mozilla/modules/plugin/tools/tester/common/plugbase.cpp b/mozilla/modules/plugin/tools/tester/common/plugbase.cpp index fcc9d0a2438..e4fba024718 100644 --- a/mozilla/modules/plugin/tools/tester/common/plugbase.cpp +++ b/mozilla/modules/plugin/tools/tester/common/plugbase.cpp @@ -394,3 +394,7 @@ DWORD CPluginBase::makeNPNCall(NPAPI_Action action, DWORD dw1, DWORD dw2, DWORD return dwRet; } + +void CPluginBase::autoStartScriptIfNeeded() +{ +} diff --git a/mozilla/modules/plugin/tools/tester/doc/testerplugin.html b/mozilla/modules/plugin/tools/tester/doc/testerplugin.html index 428815a464d..acbb47e9f23 100644 --- a/mozilla/modules/plugin/tools/tester/doc/testerplugin.html +++ b/mozilla/modules/plugin/tools/tester/doc/testerplugin.html @@ -5,8 +5,8 @@
Tester Plugin
-
Started by: av 11.25.1997
-
Last updated: 04.1.2002
+
Started by: av@netscape.com 11.25.1997
+
Last updated: 02.28.2003

Table of contents

  •     Full Page Mode
  • +
  •     Some Special Provisions
  •     Log File Format
  •     Script File Format
  •     Current Version and Known Issues
  • @@ -100,7 +101,7 @@ when it is appropriate by hand ("Flush" button).
      -
     
    +
     
                                                                 Fig. 1. Screen shots of Auto and Manual modes @@ -127,6 +128,20 @@ file and 'log' extension. This can overridden in preferences profile. See Appendix B on  how to specify log file name in fully automatic mode . +

    Some special provisions + +

    Those were added to enchance the plugin functionality so that it can operate +without fully implemented API in the browser. + +

    First, you can start running script automatically as soon as NPP_New is called on +the plugin. + +

    Second, the plugin can use native pop up window to display its GUI. + +

    Both modes do not rely on the browser capability to create windows/frames/widgets +and layout. See Appendix B on how to turn these +modes on in the preferences file. +

    Log File Format

    Every NPAPI call is logged into a log item which normally consists of @@ -234,7 +249,7 @@ or width=..., height=...

    Current Version and Known Issues -

    Current version is 1.5. +

    Current version is 1.6.

    Issues:

    + +

    The default values for all those settings are "no".

    In Log section the form of separator can be specified using key RecordSeparator. For example: diff --git a/mozilla/modules/plugin/tools/tester/include/plugbase.h b/mozilla/modules/plugin/tools/tester/include/plugbase.h index ab30d234e47..6a50b54986a 100644 --- a/mozilla/modules/plugin/tools/tester/include/plugbase.h +++ b/mozilla/modules/plugin/tools/tester/include/plugbase.h @@ -81,6 +81,10 @@ public: virtual BOOL isInitialized() = 0; // initialized virtual void getModulePath(LPSTR szPath, int iSize) = 0; virtual int messageBox(LPSTR szMessage, LPSTR szTitle, UINT uStyle) = 0; + virtual BOOL isStandAlone() = 0; // is our GUI is in a separate native window + virtual BOOL initStandAlone() = 0; // create separate native window + virtual void shutStandAlone() = 0; // destroy separate native window + virtual void outputToNativeWindow(LPSTR szString) = 0; // used to output log in StandAlone mode // virtuals just in case virtual BOOL initFull(DWORD dwInitData); @@ -88,6 +92,7 @@ public: virtual BOOL init(DWORD dwInitData); virtual void shut(); virtual void getLogFileName(LPSTR szLogFileName, int iSize); + virtual void autoStartScriptIfNeeded(); const NPP getNPInstance(); const WORD getMode(); diff --git a/mozilla/modules/plugin/tools/tester/os2/dlgauto.cpp b/mozilla/modules/plugin/tools/tester/os2/dlgauto.cpp index 35bec3b9bce..3883bb9b216 100644 --- a/mozilla/modules/plugin/tools/tester/os2/dlgauto.cpp +++ b/mozilla/modules/plugin/tools/tester/os2/dlgauto.cpp @@ -80,6 +80,10 @@ static void onCommand(HWND hWnd, int id, HWND hWndCtl, USHORT codeNotify) strcat(szLogFileName, ".log"); WinSetWindowText(WinWindowFromID(WinQueryWindow(hWnd, QW_PARENT), IDC_EDIT_LOG_FILE_NAME), szLogFileName); + // restore + if(p) + *p = '.'; + pPlugin->updatePrefs(gp_scriptfile, FALSE, szString); break; diff --git a/mozilla/modules/plugin/tools/tester/os2/guiprefs.h b/mozilla/modules/plugin/tools/tester/os2/guiprefs.h index d9cd94d56bc..21471886c34 100644 --- a/mozilla/modules/plugin/tools/tester/os2/guiprefs.h +++ b/mozilla/modules/plugin/tools/tester/os2/guiprefs.h @@ -48,6 +48,7 @@ #define KEY_LOADSTATUS_WINDOW "LoadStatusWindow" #define KEY_REMEMBER_LAST_API_CALL "RememberLastAPICall" #define KEY_LAST_API_CALL "LastAPICall" +#define KEY_STAND_ALONE "StandAloneWindow" #define ENTRY_YES "Yes" #define ENTRY_NO "No" diff --git a/mozilla/modules/plugin/tools/tester/os2/plugin.cpp b/mozilla/modules/plugin/tools/tester/os2/plugin.cpp index 41e0176e645..63d17eb5d82 100644 --- a/mozilla/modules/plugin/tools/tester/os2/plugin.cpp +++ b/mozilla/modules/plugin/tools/tester/os2/plugin.cpp @@ -104,6 +104,9 @@ void CPlugin::restorePreferences() XP_GetPrivateProfileString(szSection, KEY_REMEMBER_LAST_API_CALL, ENTRY_YES, sz, sizeof(sz), szFileName); m_Pref_bRememberLastCall = (strcmpi(sz, ENTRY_YES) == 0) ? TRUE : FALSE; + + XP_GetPrivateProfileString(szSection, KEY_STAND_ALONE, ENTRY_NO, sz, sizeof(sz), szFileName); + m_Pref_bStandAlone = (strcmpi(sz, ENTRY_YES) == 0) ? TRUE : FALSE; } void CPlugin::savePreferences() @@ -118,6 +121,7 @@ void CPlugin::savePreferences() XP_WritePrivateProfileString(szSection, KEY_TO_FRAME, m_Pref_bToFrame ? szYes : szNo, szFileName); XP_WritePrivateProfileString(szSection, KEY_FLUSH_NOW, m_Pref_bFlushNow ? szYes : szNo, szFileName); XP_WritePrivateProfileString(szSection, KEY_REMEMBER_LAST_API_CALL, m_Pref_bRememberLastCall ? szYes : szNo, szFileName); + XP_WritePrivateProfileString(szSection, KEY_STAND_ALONE, m_Pref_bStandAlone ? szYes : szNo, szFileName); } void CPlugin::updatePrefs(GUIPrefs prefs, int iValue, char * szValue) @@ -147,6 +151,9 @@ void CPlugin::updatePrefs(GUIPrefs prefs, int iValue, char * szValue) case gp_rememberlast: m_Pref_bRememberLastCall = (BOOL)iValue; break; + case gp_standalone: + m_Pref_bStandAlone = (BOOL)iValue; + break; default: break; } @@ -238,6 +245,24 @@ int CPlugin::messageBox(LPSTR szMessage, LPSTR szTitle, UINT uStyle) return WinMessageBox(HWND_DESKTOP, m_hWnd, szMessage, szTitle, 0, uStyle); } +BOOL CPlugin::isStandAlone() +{ + return FALSE; +} + +BOOL CPlugin::initStandAlone() +{ + return FALSE; +} + +void CPlugin::shutStandAlone() +{ +} + +void CPlugin::outputToNativeWindow(LPSTR szString) +{ +} + void CPlugin::onDestroy() { m_hWnd = NULL; @@ -317,5 +342,5 @@ CPluginBase * CreatePlugin(NPP instance, uint16 mode) void DestroyPlugin(CPluginBase * pPlugin) { if(pPlugin != NULL) - delete (CPluginBase *)pPlugin; + delete (CPlugin *)pPlugin; } diff --git a/mozilla/modules/plugin/tools/tester/os2/plugin.h b/mozilla/modules/plugin/tools/tester/os2/plugin.h index bbf9807b1a5..538d1baa7c3 100644 --- a/mozilla/modules/plugin/tools/tester/os2/plugin.h +++ b/mozilla/modules/plugin/tools/tester/os2/plugin.h @@ -87,6 +87,7 @@ public: BOOL m_Pref_bToFrame; BOOL m_Pref_bFlushNow; BOOL m_Pref_bRememberLastCall; + BOOL m_Pref_bStandAlone; // public interface public: @@ -101,6 +102,10 @@ public: void getModulePath(LPSTR szPath, int iSize); int messageBox(LPSTR szMessage, LPSTR szTitle, UINT uStyle); void getLogFileName(LPSTR szLogFileName, int iSize); + BOOL initStandAlone(); // create separate native window + void shutStandAlone(); // destroy separate native window + BOOL isStandAlone(); // is our GUI is in a separate native window + void outputToNativeWindow(LPSTR szString); // used to output log in StandAlone mode ULONG makeNPNCall(NPAPI_Action = action_invalid, ULONG dw1 = 0L, ULONG dw2 = 0L, diff --git a/mozilla/modules/plugin/tools/tester/windows/dlgauto.cpp b/mozilla/modules/plugin/tools/tester/windows/dlgauto.cpp index d59ae215a99..e4d99a250e3 100644 --- a/mozilla/modules/plugin/tools/tester/windows/dlgauto.cpp +++ b/mozilla/modules/plugin/tools/tester/windows/dlgauto.cpp @@ -80,6 +80,10 @@ static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify) strcat(szLogFileName, ".log"); Edit_SetText(GetDlgItem(GetParent(hWnd), IDC_EDIT_LOG_FILE_NAME), szLogFileName); + // restore + if(p) + *p = '.'; + pPlugin->updatePrefs(gp_scriptfile, FALSE, szString); break; @@ -198,7 +202,8 @@ static BOOL onInitDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam) int iTopMargin = 188; SetWindowPos(hWnd, NULL, 0,iTopMargin, 0,0, SWP_NOZORDER | SWP_NOSIZE); - Edit_SetText(GetDlgItem(hWnd, IDC_EDIT_SCRIPT_FILE_NAME), pPlugin->m_Pref_szScriptFile); + if (pPlugin) + Edit_SetText(GetDlgItem(hWnd, IDC_EDIT_SCRIPT_FILE_NAME), (LPCSTR)pPlugin->m_Pref_szScriptFile); Static_SetText(GetDlgItem(hWnd, IDC_STATIC_REPETITIONS_LEFT), ""); ShowWindow(GetDlgItem(hWnd, IDC_STATIC_REPETITIONS_LABEL), SW_HIDE); diff --git a/mozilla/modules/plugin/tools/tester/windows/guiprefs.h b/mozilla/modules/plugin/tools/tester/windows/guiprefs.h index d9cd94d56bc..f64cbb52d32 100644 --- a/mozilla/modules/plugin/tools/tester/windows/guiprefs.h +++ b/mozilla/modules/plugin/tools/tester/windows/guiprefs.h @@ -48,6 +48,8 @@ #define KEY_LOADSTATUS_WINDOW "LoadStatusWindow" #define KEY_REMEMBER_LAST_API_CALL "RememberLastAPICall" #define KEY_LAST_API_CALL "LastAPICall" +#define KEY_STAND_ALONE "StandAloneWindow" +#define KEY_AUTOSTART_SCRIPT "AutoStartScript" #define ENTRY_YES "Yes" #define ENTRY_NO "No" diff --git a/mozilla/modules/plugin/tools/tester/windows/npapi.dsp b/mozilla/modules/plugin/tools/tester/windows/npapi.dsp index fb045e3c8bc..25af232275c 100644 --- a/mozilla/modules/plugin/tools/tester/windows/npapi.dsp +++ b/mozilla/modules/plugin/tools/tester/windows/npapi.dsp @@ -1,283 +1,287 @@ -# Microsoft Developer Studio Project File - Name="npapi" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=npapi - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "npapi.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "npapi.mak" CFG="npapi - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "npapi - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "npapi - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "npapi - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPAPI_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\include" /I "..\..\..\..\..\dist\include" /I "..\..\..\..\..\dist\include\java" /I "..\..\..\..\..\dist\include\nspr" /D "XP_WIN" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPAPI_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib /nologo /dll /machine:I386 - -!ELSEIF "$(CFG)" == "npapi - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPAPI_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\..\..\..\..\dist\include\plugin" /I "..\..\..\..\..\dist\include\java" /I "..\..\..\..\..\dist\include\nspr" /D "XP_WIN" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPAPI_EXPORTS" /FR /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib /nologo /dll /debug /machine:I386 /out:"../../../../../dist/win32_d.obj/bin/plugins/npapi.dll" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "npapi - Win32 Release" -# Name "npapi - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\dlgauto.cpp -# End Source File -# Begin Source File - -SOURCE=.\dlgman.cpp -# End Source File -# Begin Source File - -SOURCE=.\dlgtstr.cpp -# End Source File -# Begin Source File - -SOURCE=.\guihlp.cpp -# End Source File -# Begin Source File - -SOURCE=.\loadstatus.cpp -# End Source File -# Begin Source File - -SOURCE=..\common\log.cpp -# End Source File -# Begin Source File - -SOURCE=..\common\logfile.cpp -# End Source File -# Begin Source File - -SOURCE=..\common\logger.cpp -# End Source File -# Begin Source File - -SOURCE=..\common\loghlp.cpp -# End Source File -# Begin Source File - -SOURCE=..\common\np_entry.cpp -# End Source File -# Begin Source File - -SOURCE=.\npapi.def -# End Source File -# Begin Source File - -SOURCE=.\npapi.rc -# End Source File -# Begin Source File - -SOURCE=..\common\npn_gate.cpp -# End Source File -# Begin Source File - -SOURCE=..\common\npp_gate.cpp -# End Source File -# Begin Source File - -SOURCE=..\common\plugbase.cpp -# End Source File -# Begin Source File - -SOURCE=.\plugin.cpp -# End Source File -# Begin Source File - -SOURCE=..\common\pplib.cpp -# End Source File -# Begin Source File - -SOURCE=..\common\profile.cpp -# End Source File -# Begin Source File - -SOURCE=..\common\script.cpp -# End Source File -# Begin Source File - -SOURCE=..\common\scripter.cpp -# End Source File -# Begin Source File - -SOURCE=..\common\scrpthlp.cpp -# End Source File -# Begin Source File - -SOURCE=..\common\strconv.cpp -# End Source File -# Begin Source File - -SOURCE=.\winentry.cpp -# End Source File -# Begin Source File - -SOURCE=.\winutils.cpp -# End Source File -# Begin Source File - -SOURCE=..\common\xp.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=..\include\action.h -# End Source File -# Begin Source File - -SOURCE=..\include\comstrs.h -# End Source File -# Begin Source File - -SOURCE=.\guihlp.h -# End Source File -# Begin Source File - -SOURCE=.\guiprefs.h -# End Source File -# Begin Source File - -SOURCE=..\include\helpers.h -# End Source File -# Begin Source File - -SOURCE=..\include\loadstatus.h -# End Source File -# Begin Source File - -SOURCE=..\include\log.h -# End Source File -# Begin Source File - -SOURCE=..\include\logfile.h -# End Source File -# Begin Source File - -SOURCE=..\include\logger.h -# End Source File -# Begin Source File - -SOURCE=..\include\loghlp.h -# End Source File -# Begin Source File - -SOURCE=..\include\plugbase.h -# End Source File -# Begin Source File - -SOURCE=.\plugin.h -# End Source File -# Begin Source File - -SOURCE=..\include\profile.h -# End Source File -# Begin Source File - -SOURCE=.\resource.h -# End Source File -# Begin Source File - -SOURCE=..\include\script.h -# End Source File -# Begin Source File - -SOURCE=..\include\scripter.h -# End Source File -# Begin Source File - -SOURCE=..\include\scrpthlp.h -# End Source File -# Begin Source File - -SOURCE=..\include\strconv.h -# End Source File -# Begin Source File - -SOURCE=.\winutils.h -# End Source File -# Begin Source File - -SOURCE=..\include\xp.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="npapi" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=npapi - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "npapi.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "npapi.mak" CFG="npapi - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "npapi - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "npapi - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "npapi - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPAPI_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\include" /I "..\..\..\..\..\dist\include" /I "..\..\..\..\..\dist\include\java" /I "..\..\..\..\..\dist\include\nspr" /I "..\..\..\..\..\dist\include\plugin" /D "XP_WIN" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPAPI_EXPORTS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib /nologo /dll /machine:I386 /out:"Y:\mb\microbrowser\bin\Win32\Debug\Plugins\npapi.dll" + +!ELSEIF "$(CFG)" == "npapi - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPAPI_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\..\..\..\..\dist\include\plugin" /I "..\..\..\..\..\dist\include\java" /I "..\..\..\..\..\dist\include\nspr" /D "XP_WIN" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPAPI_EXPORTS" /FR /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib /nologo /dll /debug /machine:I386 /out:"Y:\mb\microbrowser\bin\Win32\Debug\Plugins\npapi.dll" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "npapi - Win32 Release" +# Name "npapi - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\dlgauto.cpp +# End Source File +# Begin Source File + +SOURCE=.\dlgman.cpp +# End Source File +# Begin Source File + +SOURCE=.\dlgtstr.cpp +# End Source File +# Begin Source File + +SOURCE=.\guihlp.cpp +# End Source File +# Begin Source File + +SOURCE=.\loadstatus.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\log.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\logfile.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\logger.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\loghlp.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\np_entry.cpp +# End Source File +# Begin Source File + +SOURCE=.\npapi.def +# End Source File +# Begin Source File + +SOURCE=.\npapi.rc +# End Source File +# Begin Source File + +SOURCE=..\common\npn_gate.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\npp_gate.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\plugbase.cpp +# End Source File +# Begin Source File + +SOURCE=.\plugin.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\pplib.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\profile.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\script.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\scripter.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\scrpthlp.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\strconv.cpp +# End Source File +# Begin Source File + +SOURCE=.\winentry.cpp +# End Source File +# Begin Source File + +SOURCE=.\winutils.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\xp.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\include\action.h +# End Source File +# Begin Source File + +SOURCE=..\include\comstrs.h +# End Source File +# Begin Source File + +SOURCE=.\guihlp.h +# End Source File +# Begin Source File + +SOURCE=.\guiprefs.h +# End Source File +# Begin Source File + +SOURCE=..\include\helpers.h +# End Source File +# Begin Source File + +SOURCE=..\include\loadstatus.h +# End Source File +# Begin Source File + +SOURCE=..\include\log.h +# End Source File +# Begin Source File + +SOURCE=..\include\logfile.h +# End Source File +# Begin Source File + +SOURCE=..\include\logger.h +# End Source File +# Begin Source File + +SOURCE=..\include\loghlp.h +# End Source File +# Begin Source File + +SOURCE=..\include\plugbase.h +# End Source File +# Begin Source File + +SOURCE=.\plugin.h +# End Source File +# Begin Source File + +SOURCE=..\include\profile.h +# End Source File +# Begin Source File + +SOURCE=.\resource.h +# End Source File +# Begin Source File + +SOURCE=..\include\script.h +# End Source File +# Begin Source File + +SOURCE=..\include\scripter.h +# End Source File +# Begin Source File + +SOURCE=..\include\scrpthlp.h +# End Source File +# Begin Source File + +SOURCE=..\include\strconv.h +# End Source File +# Begin Source File + +SOURCE=.\winutils.h +# End Source File +# Begin Source File + +SOURCE=..\include\xp.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\icon.ico +# End Source File +# End Group +# End Target +# End Project diff --git a/mozilla/modules/plugin/tools/tester/windows/npapi.rc b/mozilla/modules/plugin/tools/tester/windows/npapi.rc index 8e21b7211e1..e7e130b04d0 100644 --- a/mozilla/modules/plugin/tools/tester/windows/npapi.rc +++ b/mozilla/modules/plugin/tools/tester/windows/npapi.rc @@ -39,11 +39,11 @@ BEGIN GROUPBOX "Log",IDC_STATIC,7,20,105,70 CONTROL "To file:",IDC_CHECK_LOG_TO_FILE,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,13,33,34,10 - EDITTEXT IDC_EDIT_LOG_FILE_NAME,50,31,55,14,ES_AUTOHSCROLL - CONTROL "To frame",IDC_CHECK_LOG_TO_FRAME,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,13,60,41,10 - PUSHBUTTON "Flush",IDC_BUTTON_FLUSH,57,59,24,12 - PUSHBUTTON "Clear",IDC_BUTTON_CLEAR,81,59,24,12 + EDITTEXT IDC_EDIT_LOG_FILE_NAME,50,31,56,14,ES_AUTOHSCROLL + CONTROL "To window",IDC_CHECK_LOG_TO_FRAME,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,13,60,47,10 + PUSHBUTTON "Flush",IDC_BUTTON_FLUSH,63,59,22,12 + PUSHBUTTON "Clear",IDC_BUTTON_CLEAR,85,59,22,12 CONTROL "Flush immediately",IDC_CHECK_SHOW_LOG,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,26,75,71,10 CONTROL "Remember last API call",IDC_CHECK_REMEMBER_LAST,"Button", @@ -104,8 +104,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,5,0,0 - PRODUCTVERSION 1,5,0,0 + FILEVERSION 1,6,0,0 + PRODUCTVERSION 1,6,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x3L @@ -125,7 +125,7 @@ BEGIN VALUE "FileDescription", "32-bit NPAPI test plugin\0" VALUE "FileExtents", "pts\0" VALUE "FileOpenName", "API (*.pts)\0" - VALUE "FileVersion", "1, 5, 0, 0\0" + VALUE "FileVersion", "1, 6, 0, 0\0" VALUE "InternalName", "npapi.dll\0" VALUE "LegalCopyright", "Copyright © 1997-2001\0" VALUE "LegalTrademarks", "\0" @@ -133,7 +133,7 @@ BEGIN VALUE "OriginalFilename", "npapi.dll\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "Netscape NPAPI Tester Plugin\0" - VALUE "ProductVersion", "1, 5, 0, 0\0" + VALUE "ProductVersion", "1, 6, 0, 0\0" VALUE "SpecialBuild", "\0" END END @@ -204,6 +204,15 @@ END #endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_ICON_APP ICON DISCARDABLE "icon.ico" #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/modules/plugin/tools/tester/windows/plugin.cpp b/mozilla/modules/plugin/tools/tester/windows/plugin.cpp index 9cadeebb3ac..c519e93109f 100644 --- a/mozilla/modules/plugin/tools/tester/windows/plugin.cpp +++ b/mozilla/modules/plugin/tools/tester/windows/plugin.cpp @@ -44,6 +44,7 @@ #include "plugin.h" #include "helpers.h" #include "logger.h" +#include "scripter.h" #include "guiprefs.h" #include "winutils.h" @@ -63,15 +64,20 @@ CPlugin::CPlugin(NPP pNPInstance, WORD wMode) : m_hWndManual(NULL), m_hWndAuto(NULL), m_hWndParent(NULL), + m_hWndStandAloneLogWindow(NULL), m_bPluginReady(FALSE), m_hWndLastEditFocus(NULL), m_iWidth(200), m_iHeight(500) { + restorePreferences(); + pLogger->setLogToFileFlag(m_Pref_bToFile); + pLogger->blockDumpToFile(FALSE); } CPlugin::~CPlugin() { + savePreferences(); } static char szSection[] = SECTION_PREFERENCES; @@ -104,6 +110,12 @@ void CPlugin::restorePreferences() XP_GetPrivateProfileString(szSection, KEY_REMEMBER_LAST_API_CALL, ENTRY_YES, sz, sizeof(sz), szFileName); m_Pref_bRememberLastCall = (strcmpi(sz, ENTRY_YES) == 0) ? TRUE : FALSE; + + XP_GetPrivateProfileString(szSection, KEY_STAND_ALONE, ENTRY_NO, sz, sizeof(sz), szFileName); + m_Pref_bStandAlone = (strcmpi(sz, ENTRY_YES) == 0) ? TRUE : FALSE; + + XP_GetPrivateProfileString(szSection, KEY_AUTOSTART_SCRIPT, ENTRY_NO, sz, sizeof(sz), szFileName); + m_Pref_bAutoStartScript = (strcmpi(sz, ENTRY_YES) == 0) ? TRUE : FALSE; } void CPlugin::savePreferences() @@ -118,6 +130,8 @@ void CPlugin::savePreferences() XP_WritePrivateProfileString(szSection, KEY_TO_FRAME, m_Pref_bToFrame ? szYes : szNo, szFileName); XP_WritePrivateProfileString(szSection, KEY_FLUSH_NOW, m_Pref_bFlushNow ? szYes : szNo, szFileName); XP_WritePrivateProfileString(szSection, KEY_REMEMBER_LAST_API_CALL, m_Pref_bRememberLastCall ? szYes : szNo, szFileName); + XP_WritePrivateProfileString(szSection, KEY_STAND_ALONE, m_Pref_bStandAlone ? szYes : szNo, szFileName); + XP_WritePrivateProfileString(szSection, KEY_AUTOSTART_SCRIPT, m_Pref_bAutoStartScript ? szYes : szNo, szFileName); } void CPlugin::updatePrefs(GUIPrefs prefs, int iValue, char * szValue) @@ -147,6 +161,12 @@ void CPlugin::updatePrefs(GUIPrefs prefs, int iValue, char * szValue) case gp_rememberlast: m_Pref_bRememberLastCall = (BOOL)iValue; break; + case gp_standalone: + m_Pref_bStandAlone = (BOOL)iValue; + break; + case gp_autostartscript: + m_Pref_bAutoStartScript = (BOOL)iValue; + break; default: break; } @@ -164,6 +184,8 @@ void CPlugin::getLogFileName(LPSTR szLogFileName, int iSize) char sz[256]; getModulePath(szLogFileName, iSize); Edit_GetText(GetDlgItem(m_hWnd, IDC_EDIT_LOG_FILE_NAME), sz, sizeof(sz)); + if(!strlen(sz)) + strcpy(sz, m_Pref_szLogFile); strcat(szLogFileName, sz); } else @@ -172,14 +194,78 @@ void CPlugin::getLogFileName(LPSTR szLogFileName, int iSize) BOOL CALLBACK NP_LOADDS TesterDlgProc(HWND, UINT, WPARAM, LPARAM); +static BOOL bStandAlone = TRUE; +static char szStandAlonePluginWindowClassName[] = "StandAloneWindowClass"; + +BOOL CPlugin::initStandAlone() +{ + HWND hWndParent = NULL; + + WNDCLASS wc; + wc.style = 0; + wc.lpfnWndProc = DefWindowProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = m_hInst; + wc.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_APP)); + wc.hCursor = LoadCursor(0, IDC_ARROW); + wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); + wc.lpszMenuName = NULL; + wc.lpszClassName = szStandAlonePluginWindowClassName; + + if(RegisterClass(&wc)) + hWndParent = CreateWindow(szStandAlonePluginWindowClassName, + "The Tester Plugin", + WS_POPUPWINDOW | WS_CAPTION | WS_VISIBLE | WS_MINIMIZEBOX, + 0, 0, 800, 600, + GetDesktopWindow(), NULL, m_hInst, NULL); + +// m_hWndStandAloneLogWindow = CreateWindow("LISTBOX", "", + // WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL | LBS_NOINTEGRALHEIGHT, + // 200, 3, 590, 562, + // hWndParent, NULL, m_hInst, NULL); + + m_hWndStandAloneLogWindow = CreateWindow("EDIT", "", + WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_READONLY, + 200, 3, 590, 562, + hWndParent, NULL, m_hInst, NULL); + if(!IsWindow(hWndParent)) + return FALSE; + + m_hWndParent = hWndParent; + + HFONT hFont = GetStockFont(DEFAULT_GUI_FONT); + SetWindowFont(m_hWndStandAloneLogWindow, hFont, FALSE); + + CreateDialogParam(m_hInst, MAKEINTRESOURCE(IDD_DIALOG_TESTER), m_hWndParent, (DLGPROC)TesterDlgProc, (LPARAM)this); + + m_bPluginReady = (m_hWnd != NULL); + + return m_bPluginReady; +} + +void CPlugin::shutStandAlone() +{ + if (isStandAlone() && m_hWndParent) + { + DestroyWindow(m_hWndParent); + UnregisterClass(szStandAlonePluginWindowClassName, m_hInst); + } + + m_bPluginReady = FALSE; +} + BOOL CPlugin::initEmbed(DWORD dwInitData) { - restorePreferences(); + if (m_bPluginReady) + return TRUE; HWND hWndParent = (HWND)dwInitData; - if(IsWindow(hWndParent)) - m_hWndParent = hWndParent; + if(!IsWindow(hWndParent)) + return FALSE; + + m_hWndParent = hWndParent; CreateDialogParam(m_hInst, MAKEINTRESOURCE(IDD_DIALOG_TESTER), m_hWndParent, (DLGPROC)TesterDlgProc, (LPARAM)this); @@ -196,8 +282,6 @@ BOOL CPlugin::initFull(DWORD dwInitData) void CPlugin::shutEmbed() { - savePreferences(); - if(m_hWnd != NULL) { DestroyWindow(m_hWnd); @@ -233,6 +317,75 @@ void CPlugin::onInit(HWND hWnd, HWND hWndManual, HWND hWndAuto) pLogger->setLogToFileFlag(IsDlgButtonChecked(m_hWnd, IDC_CHECK_LOG_TO_FILE) == BST_CHECKED); } +BOOL CPlugin::isStandAlone() +{ + return m_Pref_bStandAlone; +} + +void CPlugin::outputToNativeWindow(LPSTR szString) +{ + if (!m_hWndStandAloneLogWindow) + return; + + // VERSION FOR EDIT BOX + + static char text[16384]; + + if (strlen(szString)) { + int length = Edit_GetTextLength(m_hWndStandAloneLogWindow); + if ((length + strlen(szString)) > sizeof(text)) + strcpy(text, szString); + else { + Edit_GetText(m_hWndStandAloneLogWindow, text, sizeof(text)); + strcat(text, szString); + } + + Edit_SetText(m_hWndStandAloneLogWindow, text); + int lines = Edit_GetLineCount(m_hWndStandAloneLogWindow); + Edit_Scroll(m_hWndStandAloneLogWindow, lines, 0); + } + else + Edit_SetText(m_hWndStandAloneLogWindow, ""); // clear the window + +/* + // VERSION FOR LISTBOX + + // parse the string and add lines to the listbox + char *p = 0; + char *newline = szString; + + for (;;) { + // could be either \r\n or \n, we don't need them at all for the listbox + p = strchr(newline, '\n'); + if (!p) + break; + + if (*(p - 1) == '\r') + *(p - 1) = '\0'; + else + *p = '\0'; + + char line[512]; + strcpy(line, newline); + + ListBox_AddString(m_hWndStandAloneLogWindow, line); + int count = ListBox_GetCount(m_hWndStandAloneLogWindow); + if(count == 32767) + ListBox_ResetContent(m_hWndStandAloneLogWindow); + ListBox_SetCaretIndex(m_hWndStandAloneLogWindow, count - 1); + UpdateWindow(m_hWndStandAloneLogWindow); + + // restore the original + if (*p == '\n') + *(p - 1) = '\r'; + else + *p = '\n'; + + newline = ++p; + } +*/ +} + int CPlugin::messageBox(LPSTR szMessage, LPSTR szTitle, UINT uStyle) { return MessageBox(m_hWnd, szMessage, szTitle, uStyle); @@ -307,6 +460,41 @@ DWORD CPlugin::makeNPNCall(NPAPI_Action action, DWORD dw1, DWORD dw2, DWORD dw3, return dwRet; } +void CPlugin::autoStartScriptIfNeeded() +{ + if (!m_Pref_bAutoStartScript) + return; + + CScripter scripter; + scripter.associate(this); + + char szFileName[_MAX_PATH]; + getModulePath(szFileName, sizeof(szFileName)); + strcat(szFileName, m_Pref_szScriptFile); + + if(scripter.createScriptFromFile(szFileName)) + { + int iRepetitions = scripter.getCycleRepetitions(); + int iDelay = scripter.getCycleDelay(); + if(iDelay < 0) + iDelay = 0; + + assert(pLogger != NULL); + pLogger->resetStartTime(); + + for(int i = 0; i < iRepetitions; i++) + { + scripter.executeScript(); + if(iDelay != 0) + XP_Sleep(iDelay); + } + } + else + { + MessageBox(NULL, "Script file not found or invalid", "", MB_OK | MB_ICONERROR); + } +} + // Creation and destruction CPluginBase * CreatePlugin(NPP instance, uint16 mode) { @@ -317,5 +505,5 @@ CPluginBase * CreatePlugin(NPP instance, uint16 mode) void DestroyPlugin(CPluginBase * pPlugin) { if(pPlugin != NULL) - delete (CPluginBase *)pPlugin; + delete (CPlugin *)pPlugin; } diff --git a/mozilla/modules/plugin/tools/tester/windows/plugin.h b/mozilla/modules/plugin/tools/tester/windows/plugin.h index 1a4641bef2c..5c7aeb25956 100644 --- a/mozilla/modules/plugin/tools/tester/windows/plugin.h +++ b/mozilla/modules/plugin/tools/tester/windows/plugin.h @@ -54,36 +54,13 @@ typedef enum gp_tofile, gp_toframe, gp_flush, - gp_rememberlast + gp_rememberlast, + gp_standalone, + gp_autostartscript }GUIPrefs; class CPlugin : public CPluginBase { -private: - HINSTANCE m_hInst; - HWND m_hWnd; - HWND m_hWndParent; - HWND m_hWndManual; - HWND m_hWndAuto; - BOOL m_bPluginReady; - -// -// some GUI data -// -public: - HWND m_hWndLastEditFocus; - int m_iWidth; - int m_iHeight; - -// GUI preferences - ShowGUI m_Pref_ShowGUI; - char m_Pref_szLogFile[256]; - char m_Pref_szScriptFile[256]; - BOOL m_Pref_bToFile; - BOOL m_Pref_bToFrame; - BOOL m_Pref_bFlushNow; - BOOL m_Pref_bRememberLastCall; - // public interface public: CPlugin(NPP pNPInstance, WORD wMode); @@ -97,6 +74,12 @@ public: void getModulePath(LPSTR szPath, int iSize); int messageBox(LPSTR szMessage, LPSTR szTitle, UINT uStyle); void getLogFileName(LPSTR szLogFileName, int iSize); + BOOL initStandAlone(); // create separate native window + void shutStandAlone(); // destroy separate native window + BOOL isStandAlone(); // is our GUI is in a separate native window + void outputToNativeWindow(LPSTR szString); // used to output log in StandAlone mode + + void autoStartScriptIfNeeded(); DWORD makeNPNCall(NPAPI_Action = action_invalid, DWORD dw1 = 0L, DWORD dw2 = 0L, @@ -125,6 +108,32 @@ public: void onInit(HWND hWnd, HWND hWndManual, HWND hWndAuto); void onDestroy(); void onLogToFile(BOOL bLofToFile); + +private: + HINSTANCE m_hInst; + HWND m_hWnd; + HWND m_hWndParent; + HWND m_hWndStandAloneLogWindow; + HWND m_hWndManual; + HWND m_hWndAuto; + BOOL m_bPluginReady; + +// some GUI data +public: + HWND m_hWndLastEditFocus; + int m_iWidth; + int m_iHeight; + +// GUI preferences + ShowGUI m_Pref_ShowGUI; + char m_Pref_szLogFile[256]; + char m_Pref_szScriptFile[256]; + BOOL m_Pref_bToFile; + BOOL m_Pref_bToFrame; + BOOL m_Pref_bFlushNow; + BOOL m_Pref_bRememberLastCall; + BOOL m_Pref_bStandAlone; + BOOL m_Pref_bAutoStartScript; }; #endif // __PLUGIN_H__ diff --git a/mozilla/modules/plugin/tools/tester/windows/resource.h b/mozilla/modules/plugin/tools/tester/windows/resource.h index 1d5c7a69df0..c6805afe1e9 100644 --- a/mozilla/modules/plugin/tools/tester/windows/resource.h +++ b/mozilla/modules/plugin/tools/tester/windows/resource.h @@ -44,6 +44,7 @@ #define IDC_STATIC_REPETITIONS_LEFT 1044 #define IDC_CHECK_REMEMBER_LAST 1045 #define IDC_STATIC_REPETITIONS_LABEL 1046 +#define IDI_ICON_APP 1047 // Next default values for new objects // @@ -51,7 +52,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 115 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1047 +#define _APS_NEXT_CONTROL_VALUE 1048 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif