From f7c5948693e8eb2fc257e92eb9ddf72399a5a89b Mon Sep 17 00:00:00 2001 From: "av%netscape.com" Date: Sun, 31 Mar 2002 02:58:00 +0000 Subject: [PATCH] Bug 133662 -- update Tester plugin, not part of the build git-svn-id: svn://10.0.0.236/trunk@117761 18797224-902f-48f8-a5cc-f745e15eee43 --- .../plugin/tools/tester/include/loadstatus.h | 48 ++++++++ .../plugin/tools/tester/windows/guiprefs.h | 53 +++++++++ .../tools/tester/windows/loadstatus.cpp | 109 ++++++++++++++++++ .../plugin/tools/tester/windows/npapi.dsp | 96 +++++++++++++-- .../plugin/tools/tester/windows/plugin.cpp | 23 +--- .../plugin/tools/tester/windows/plugin.h | 11 -- .../plugin/tools/tester/windows/winentry.cpp | 19 +++ .../plugin/tools/tester/windows/winutils.cpp | 64 ++++++++++ .../plugin/tools/tester/windows/winutils.h | 44 +++++++ 9 files changed, 428 insertions(+), 39 deletions(-) diff --git a/mozilla/modules/plugin/tools/tester/include/loadstatus.h b/mozilla/modules/plugin/tools/tester/include/loadstatus.h index e69de29bb2d..7247672aabb 100644 --- a/mozilla/modules/plugin/tools/tester/include/loadstatus.h +++ b/mozilla/modules/plugin/tools/tester/include/loadstatus.h @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef __LOADSTATUS_H__ +#define __LOADSTATUS_H__ + +#ifdef XP_WIN + +HWND ShowLoadStatus(char * aMessage); +void DestroyLoadStatus(HWND ahWnd); + +#endif // XP_WIN + +#endif // __LOADSTATUS_H__ diff --git a/mozilla/modules/plugin/tools/tester/windows/guiprefs.h b/mozilla/modules/plugin/tools/tester/windows/guiprefs.h index e69de29bb2d..9a871488e06 100644 --- a/mozilla/modules/plugin/tools/tester/windows/guiprefs.h +++ b/mozilla/modules/plugin/tools/tester/windows/guiprefs.h @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef __GUIPREFS_H__ +#define __GUIPREFS_H__ + +#define SECTION_PREFERENCES "Preferences" +#define KEY_AUTO_MODE "AutoMode" +#define KEY_LOG_FILE "LogFile" +#define KEY_SCRIPT_FILE "ScriptFile" +#define KEY_TO_FILE "LogToFile" +#define KEY_TO_FRAME "LogToFrame" +#define KEY_FLUSH_NOW "FlushImmediately" +#define KEY_LOADSTATUS_WINDOW "LoadStatusWindow" + +#define ENTRY_YES "Yes" +#define ENTRY_NO "No" + +#endif // __GUIPREFS_H__ diff --git a/mozilla/modules/plugin/tools/tester/windows/loadstatus.cpp b/mozilla/modules/plugin/tools/tester/windows/loadstatus.cpp index e69de29bb2d..5ffb6eff4bf 100644 --- a/mozilla/modules/plugin/tools/tester/windows/loadstatus.cpp +++ b/mozilla/modules/plugin/tools/tester/windows/loadstatus.cpp @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include +#include + +extern HINSTANCE hInst; +static char szClassName[] = "LoadStatusWindowClass"; +HBRUSH hBrushBackground = NULL; + +HWND ShowLoadStatus(char * aMessage) +{ + if (!aMessage) + return NULL; + + LOGBRUSH lb; + lb.lbStyle = BS_SOLID; + lb.lbColor = RGB(255,255,0); + lb.lbHatch = NULL; + hBrushBackground = CreateBrushIndirect(&lb); + + WNDCLASS wc; + wc.style = 0; + wc.lpfnWndProc = DefWindowProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInst; + wc.hIcon = NULL; + wc.hCursor = NULL; + wc.hbrBackground = hBrushBackground ? hBrushBackground : (HBRUSH)(COLOR_BTNFACE + 1); + wc.lpszMenuName = NULL; + wc.lpszClassName = szClassName; + + if(!RegisterClass(&wc)) { + DeleteBrush(hBrushBackground); + return NULL; + } + + HWND hWnd = CreateWindowEx(WS_EX_TOOLWINDOW, szClassName, "", + WS_POPUP | WS_VISIBLE | WS_DISABLED, + 0,0,0,0, NULL, NULL, hInst, NULL); + if (!hWnd) { + UnregisterClass(szClassName, hInst); + DeleteBrush(hBrushBackground); + return NULL; + } + + HDC hDC = GetDC(hWnd); + if (!hDC) { + DestroyWindow(hWnd); + UnregisterClass(szClassName, hInst); + DeleteBrush(hBrushBackground); + return NULL; + } + + HFONT hFont = GetStockFont(DEFAULT_GUI_FONT); + HFONT hFontOld = SelectFont(hDC, hFont); + SIZE size; + GetTextExtentPoint32(hDC, aMessage, strlen(aMessage), &size); + SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, size.cx + 4, size.cy + 2, SWP_SHOWWINDOW); + SetBkMode(hDC, TRANSPARENT); + TextOut(hDC, 2, 1, aMessage, strlen(aMessage)); + ReleaseDC(hWnd, hDC); + + return hWnd; +} + +void DestroyLoadStatus(HWND ahWnd) +{ + if (ahWnd) + DestroyWindow(ahWnd); + + UnregisterClass(szClassName, hInst); + DeleteBrush(hBrushBackground); +} diff --git a/mozilla/modules/plugin/tools/tester/windows/npapi.dsp b/mozilla/modules/plugin/tools/tester/windows/npapi.dsp index a55ec8a976a..fb045e3c8bc 100644 --- a/mozilla/modules/plugin/tools/tester/windows/npapi.dsp +++ b/mozilla/modules/plugin/tools/tester/windows/npapi.dsp @@ -79,7 +79,7 @@ BSC32=bscmake.exe # 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 /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 @@ -108,7 +108,7 @@ SOURCE=.\guihlp.cpp # End Source File # Begin Source File -SOURCE=.\guihlp.h +SOURCE=.\loadstatus.cpp # End Source File # Begin Source File @@ -156,10 +156,6 @@ SOURCE=.\plugin.cpp # End Source File # Begin Source File -SOURCE=.\plugin.h -# End Source File -# Begin Source File - SOURCE=..\common\pplib.cpp # End Source File # Begin Source File @@ -168,10 +164,6 @@ SOURCE=..\common\profile.cpp # End Source File # Begin Source File -SOURCE=.\resource.h -# End Source File -# Begin Source File - SOURCE=..\common\script.cpp # End Source File # Begin Source File @@ -192,12 +184,96 @@ 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" diff --git a/mozilla/modules/plugin/tools/tester/windows/plugin.cpp b/mozilla/modules/plugin/tools/tester/windows/plugin.cpp index fa87e4aa34b..bd770a361ba 100644 --- a/mozilla/modules/plugin/tools/tester/windows/plugin.cpp +++ b/mozilla/modules/plugin/tools/tester/windows/plugin.cpp @@ -44,6 +44,8 @@ #include "plugin.h" #include "helpers.h" #include "logger.h" +#include "guiprefs.h" +#include "winutils.h" extern HINSTANCE hInst; extern CLogger * pLogger; @@ -72,7 +74,6 @@ CPlugin::~CPlugin() { } -static char szINIFile[] = NPAPI_INI_FILE_NAME; static char szSection[] = SECTION_PREFERENCES; static char szYes[] = ENTRY_YES; static char szNo[] = ENTRY_NO; @@ -80,8 +81,7 @@ static char szNo[] = ENTRY_NO; void CPlugin::restorePreferences() { char szFileName[_MAX_PATH]; - getModulePath(szFileName, sizeof(szFileName)); - strcat(szFileName, szINIFile); + GetINIFileName(m_hInst, szFileName, sizeof(szFileName)); char sz[256]; XP_GetPrivateProfileString(szSection, KEY_AUTO_MODE, ENTRY_NO, sz, sizeof(sz), szFileName); @@ -106,8 +106,7 @@ void CPlugin::restorePreferences() void CPlugin::savePreferences() { char szFileName[_MAX_PATH]; - getModulePath(szFileName, sizeof(szFileName)); - strcat(szFileName, szINIFile); + GetINIFileName(m_hInst, szFileName, sizeof(szFileName)); XP_WritePrivateProfileString(szSection, KEY_AUTO_MODE, (m_Pref_ShowGUI == sg_auto) ? szYes : szNo, szFileName); XP_WritePrivateProfileString(szSection, KEY_LOG_FILE, m_Pref_szLogFile, szFileName); @@ -148,19 +147,7 @@ void CPlugin::updatePrefs(GUIPrefs prefs, int iValue, char * szValue) void CPlugin::getModulePath(LPSTR szPath, int iSize) { - char sz[_MAX_PATH]; - GetModuleFileName(m_hInst, sz, sizeof(sz)); - char * p = strrchr(sz, '\\'); - if(p != NULL) - { - *++p = '\0'; - if((int)strlen(sz) < iSize) - strcpy(szPath, sz); - else - strcpy(szPath, ""); - } - else - strcpy(szPath, ""); + GetModulePath(m_hInst, szPath, iSize); } void CPlugin::getLogFileName(LPSTR szLogFileName, int iSize) diff --git a/mozilla/modules/plugin/tools/tester/windows/plugin.h b/mozilla/modules/plugin/tools/tester/windows/plugin.h index 974fefe9b8d..8859a1369de 100644 --- a/mozilla/modules/plugin/tools/tester/windows/plugin.h +++ b/mozilla/modules/plugin/tools/tester/windows/plugin.h @@ -125,15 +125,4 @@ public: void onLogToFile(BOOL bLofToFile); }; -#define SECTION_PREFERENCES "Preferences" -#define KEY_AUTO_MODE "AutoMode" -#define KEY_LOG_FILE "LogFile" -#define KEY_SCRIPT_FILE "ScriptFile" -#define KEY_TO_FILE "LogToFile" -#define KEY_TO_FRAME "LogToFrame" -#define KEY_FLUSH_NOW "FlushImmediately" - -#define ENTRY_YES "Yes" -#define ENTRY_NO "No" - #endif // __PLUGIN_H__ diff --git a/mozilla/modules/plugin/tools/tester/windows/winentry.cpp b/mozilla/modules/plugin/tools/tester/windows/winentry.cpp index 37823ae165d..594bad0350e 100644 --- a/mozilla/modules/plugin/tools/tester/windows/winentry.cpp +++ b/mozilla/modules/plugin/tools/tester/windows/winentry.cpp @@ -42,7 +42,13 @@ /*********************************************************/ #include +#include "xp.h" +#include "guiprefs.h" +#include "loadstatus.h" +#include "winutils.h" + HINSTANCE hInst = NULL; +HWND hWndLoadStatus = NULL; BOOL WINAPI DllMain(HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved) { @@ -50,8 +56,21 @@ BOOL WINAPI DllMain(HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved) switch (dwReason) { case DLL_PROCESS_ATTACH: + { + char szFileName[_MAX_PATH]; + GetINIFileName(hInst, szFileName, sizeof(szFileName)); + char sz[256]; + XP_GetPrivateProfileString(SECTION_PREFERENCES, KEY_LOADSTATUS_WINDOW, ENTRY_NO, sz, sizeof(sz), szFileName); + if (strcmpi(sz, ENTRY_YES) == 0) + hWndLoadStatus = ShowLoadStatus("Tester dll is loaded"); + break; + } case DLL_THREAD_ATTACH: + break; case DLL_PROCESS_DETACH: + if (hWndLoadStatus) + DestroyLoadStatus(hWndLoadStatus); + break; case DLL_THREAD_DETACH: break; default: diff --git a/mozilla/modules/plugin/tools/tester/windows/winutils.cpp b/mozilla/modules/plugin/tools/tester/windows/winutils.cpp index e69de29bb2d..b7b5fa203e3 100644 --- a/mozilla/modules/plugin/tools/tester/windows/winutils.cpp +++ b/mozilla/modules/plugin/tools/tester/windows/winutils.cpp @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include + +#include "plugbase.h" + +void GetModulePath(HINSTANCE aInstance, char * aPath, int aSize) +{ + char sz[_MAX_PATH]; + GetModuleFileName(aInstance, sz, sizeof(sz)); + char * p = strrchr(sz, '\\'); + if(p != NULL) { + *++p = '\0'; + if((int)strlen(sz) < aSize) + strcpy(aPath, sz); + else + strcpy(aPath, ""); + } + else + strcpy(aPath, ""); +} + +static char szINIFile[] = NPAPI_INI_FILE_NAME; + +void GetINIFileName(HINSTANCE aInstance, char * aName, int aSize) +{ + GetModulePath(aInstance, aName, aSize); + strcat(aName, szINIFile); +} diff --git a/mozilla/modules/plugin/tools/tester/windows/winutils.h b/mozilla/modules/plugin/tools/tester/windows/winutils.h index e69de29bb2d..a5e9762b195 100644 --- a/mozilla/modules/plugin/tools/tester/windows/winutils.h +++ b/mozilla/modules/plugin/tools/tester/windows/winutils.h @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef __WINUTILS_H__ +#define __WINUTILS_H__ + +void GetModulePath(HINSTANCE aInstance, char * aPath, int aSize); +void GetINIFileName(HINSTANCE aInstance, char * aName, int aSize); + +#endif // __WINUTILS_H__ \ No newline at end of file