зеркало из https://github.com/mozilla/gecko-dev.git
Not part of the build yet. Default plugin.
This commit is contained in:
Родитель
1c4c72fe63
Коммит
fd2b832699
|
@ -0,0 +1,157 @@
|
|||
# Microsoft Developer Studio Project File - Name="Npnul32" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=Npnul32 - Win32 Release
|
||||
!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 "Npnul32.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 "Npnul32.mak" CFG="Npnul32 - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Npnul32 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "Npnul32 - 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)" == "Npnul32 - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\WinRel"
|
||||
# PROP BASE Intermediate_Dir ".\WinRel"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FR /YX /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\include" /I "..\..\..\..\sun-java\stubs\include" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /FD /c
|
||||
# SUBTRACT CPP /Fr /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /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 /nologo /subsystem:windows /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib /nologo /subsystem:windows /dll /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "Npnul32 - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\WinDebug"
|
||||
# PROP BASE Intermediate_Dir ".\WinDebug"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\include" /I "..\..\..\..\sun-java\stubs\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /FD /c
|
||||
# SUBTRACT CPP /Fr /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /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 /nologo /subsystem:windows /dll /debug /machine:I386
|
||||
# ADD 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 /subsystem:windows /dll /debug /machine:I386 /out:"Y:\mozilla\dist\WIN32_D.OBJ\bin\Plugins\Npnul32.dll"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Npnul32 - Win32 Release"
|
||||
# Name "Npnul32 - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dbg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dialogs.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\maindll.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\npnul32.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\npnul32.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\npshell.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\npwin.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\plugin.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\utils.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dbg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dialogs.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\plugin.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\utils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\plugicon.ico
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
|
@ -0,0 +1,44 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
extern char szAppName[];
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
void __cdecl dbgOut(LPSTR format, ...) {
|
||||
static char buf[1024];
|
||||
lstrcpy(buf, szAppName);
|
||||
lstrcat(buf, ": ");
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
wvsprintf(&buf[lstrlen(buf)], format, va);
|
||||
va_end(va);
|
||||
lstrcat(buf, "\n");
|
||||
OutputDebugString(buf);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,51 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef __DBG_HPP_
|
||||
#define __DBG_HPP_
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
void __cdecl dbgOut(LPSTR format, ...);
|
||||
#define dbgOut1(x) dbgOut(x)
|
||||
#define dbgOut2(x,y) dbgOut(x, y)
|
||||
#define dbgOut3(x,y,z) dbgOut(x, y, z)
|
||||
#define dbgOut4(x,y,z,t) dbgOut(x, y, z, t)
|
||||
#define dbgOut5(x,y,z,t,u) dbgOut(x, y, z, t, u)
|
||||
#define dbgOut6(x,y,z,t,u,v) dbgOut(x, y, z, t, u, v)
|
||||
#define dbgOut7(x,y,z,t,u,v, a) dbgOut(x, y, z, t, u, v, a)
|
||||
#define dbgOut8(x,y,z,t,u,v, a, b) dbgOut(x, y, z, t, u, v, a, b)
|
||||
|
||||
#else
|
||||
|
||||
#define dbgOut1(x) ((void)0)
|
||||
#define dbgOut2(x,y) ((void)0)
|
||||
#define dbgOut3(x,y,z) ((void)0)
|
||||
#define dbgOut4(x,y,z,t) ((void)0)
|
||||
#define dbgOut5(x,y,z,t,u) ((void)0)
|
||||
#define dbgOut6(x,y,z,t,u,v) ((void)0)
|
||||
#define dbgOut7(x,y,z,t,u,v,a) ((void)0)
|
||||
#define dbgOut8(x,y,z,t,u,v,a,b) ((void)0)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,165 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "plugin.h"
|
||||
#include "utils.h"
|
||||
|
||||
static char szDefaultPluginFinderURL[] = DEFAULT_PLUGINFINDER_URL;
|
||||
|
||||
static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case IDC_GET_PLUGIN:
|
||||
EndDialog(hWnd, IDC_GET_PLUGIN);
|
||||
break;
|
||||
case IDCANCEL:
|
||||
case IDC_BUTTON_CANCEL:
|
||||
EndDialog(hWnd, IDCANCEL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL onInitDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam)
|
||||
{
|
||||
CPlugin * pPlugin = (CPlugin *)lParam;
|
||||
assert(pPlugin != NULL);
|
||||
if(pPlugin == NULL)
|
||||
return TRUE;
|
||||
|
||||
char szString[512];
|
||||
LoadString(hInst, IDS_TITLE, szString, sizeof(szString));
|
||||
SetWindowText(hWnd, szString);
|
||||
|
||||
LoadString(hInst, IDS_INFO, szString, sizeof(szString));
|
||||
SetDlgItemText(hWnd, IDC_STATIC_INFO, szString);
|
||||
|
||||
SetDlgItemText(hWnd, IDC_STATIC_INFOTYPE, (LPSTR)pPlugin->m_pNPMIMEType);
|
||||
|
||||
LoadString(hInst, IDS_LOCATION, szString, sizeof(szString));
|
||||
SetDlgItemText(hWnd, IDC_STATIC_LOCATION, szString);
|
||||
|
||||
char contentTypeIsJava = 0;
|
||||
|
||||
if (NULL != pPlugin->m_pNPMIMEType) {
|
||||
contentTypeIsJava = (0 == strcmp("application/x-java-vm",
|
||||
pPlugin->m_pNPMIMEType)) ? 1 : 0;
|
||||
}
|
||||
|
||||
if(pPlugin->m_szPageURL == NULL || contentTypeIsJava)
|
||||
LoadString(hInst, IDS_FINDER_PAGE, szString, sizeof(szString));
|
||||
else
|
||||
strncpy(szString, pPlugin->m_szPageURL,511); // defect #362738
|
||||
|
||||
SetDlgItemTextWrapped(hWnd, IDC_STATIC_URL, szString);
|
||||
|
||||
LoadString(hInst, IDS_QUESTION, szString, sizeof(szString));
|
||||
SetDlgItemText(hWnd, IDC_STATIC_QUESTION, szString);
|
||||
|
||||
SetDlgItemText(hWnd, IDC_STATIC_WARNING, "");
|
||||
|
||||
if(!pPlugin->m_bOnline)
|
||||
{
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_GET_PLUGIN), FALSE);
|
||||
LoadString(hInst, IDS_WARNING_OFFLINE, szString, sizeof(szString));
|
||||
SetDlgItemText(hWnd, IDC_STATIC_WARNING, szString);
|
||||
SetDlgItemText(hWnd, IDC_STATIC_QUESTION, "");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if((!pPlugin->m_bJava) || (!pPlugin->m_bJavaScript) || (!pPlugin->m_bSmartUpdate))
|
||||
{
|
||||
LoadString(hInst, IDS_WARNING_JS, szString, sizeof(szString));
|
||||
SetDlgItemText(hWnd, IDC_STATIC_WARNING, szString);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_WARNING), SW_HIDE);
|
||||
|
||||
RECT rc;
|
||||
GetWindowRect(GetDlgItem(hWnd, IDC_STATIC_WARNING), &rc);
|
||||
int iHeight = rc.bottom - rc.top;
|
||||
GetWindowRect(hWnd, &rc);
|
||||
SetWindowPos(hWnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top - iHeight, SWP_NOZORDER | SWP_NOMOVE);
|
||||
|
||||
HWND hWndQuestion = GetDlgItem(hWnd, IDC_STATIC_QUESTION);
|
||||
HWND hWndButtonGetPlugin = GetDlgItem(hWnd, IDC_GET_PLUGIN);
|
||||
HWND hWndButtonCancel = GetDlgItem(hWnd, IDC_BUTTON_CANCEL);
|
||||
|
||||
POINT pt;
|
||||
|
||||
GetWindowRect(hWndQuestion, &rc);
|
||||
pt.x = rc.left;
|
||||
pt.y = rc.top;
|
||||
ScreenToClient(hWnd, &pt);
|
||||
SetWindowPos(hWndQuestion, NULL, pt.x, pt.y - iHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
|
||||
|
||||
GetWindowRect(hWndButtonGetPlugin, &rc);
|
||||
pt.x = rc.left;
|
||||
pt.y = rc.top;
|
||||
ScreenToClient(hWnd, &pt);
|
||||
SetWindowPos(hWndButtonGetPlugin, NULL, pt.x, pt.y - iHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
|
||||
|
||||
GetWindowRect(hWndButtonCancel, &rc);
|
||||
pt.x = rc.left;
|
||||
pt.y = rc.top;
|
||||
ScreenToClient(hWnd, &pt);
|
||||
SetWindowPos(hWndButtonCancel, NULL, pt.x, pt.y - iHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
|
||||
|
||||
if(pPlugin->m_bHidden)
|
||||
SetForegroundWindow(hWnd);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void onDestroy(HWND hWnd)
|
||||
{
|
||||
}
|
||||
|
||||
BOOL CALLBACK NP_LOADDS GetPluginDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
return (BOOL)HANDLE_WM_INITDIALOG(hWnd, wParam, lParam, onInitDialog);
|
||||
case WM_COMMAND:
|
||||
HANDLE_WM_COMMAND(hWnd, wParam, lParam, onCommand);
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
HANDLE_WM_DESTROY(hWnd, wParam, lParam, onDestroy);
|
||||
break;
|
||||
case WM_CLOSE:
|
||||
EndDialog(hWnd, IDCANCEL);
|
||||
break;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef __DIALOGS_H__
|
||||
#define __DIALOGS_H__
|
||||
|
||||
BOOL CALLBACK NP_LOADDS GetPluginDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#endif __DIALOGS_H__
|
|
@ -0,0 +1,31 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
HINSTANCE hInst; // global
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
hInst = hDLL;
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
#!nmake
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
DLLNAME = npnul32
|
||||
RESFILE = npnul32.res
|
||||
DEFFILE = npnul32.def
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
MODULE=npnul32
|
||||
|
||||
DEFINES =-D_IMPL_NS_PLUGIN -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\maindll.obj \
|
||||
.\$(OBJDIR)\plugin.obj \
|
||||
.\$(OBJDIR)\dbg.obj \
|
||||
.\$(OBJDIR)\dialogs.obj \
|
||||
.\$(OBJDIR)\npshell.obj \
|
||||
.\$(OBJDIR)\npwin.obj \
|
||||
.\$(OBJDIR)\utils.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
-D_IMPL_NS_PLUGIN \
|
||||
-GX \
|
||||
$(NULL)
|
||||
|
||||
WIN_LIBS = \
|
||||
version.lib
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
it:
|
||||
echo $(LLIBS)
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\plugins
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\$(DLLNAME).dll
|
|
@ -0,0 +1,6 @@
|
|||
LIBRARY NPNUL32
|
||||
|
||||
EXPORTS
|
||||
NP_GetEntryPoints @1
|
||||
NP_Initialize @2
|
||||
NP_Shutdown @3
|
|
@ -0,0 +1,29 @@
|
|||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Npnul32"=.\Npnul32.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_PLUGIN_DOWNLOAD DIALOG DISCARDABLE 0, 0, 225, 148
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Title"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LTEXT "Information on this page requires a plug-in for:",
|
||||
IDC_STATIC_INFO,7,7,211,10
|
||||
LTEXT "Communicator can retrieve the plug-in for you from:",
|
||||
IDC_STATIC_LOCATION,7,32,211,8
|
||||
CTEXT "What would you like to do?",IDC_STATIC_QUESTION,7,113,
|
||||
211,9
|
||||
DEFPUSHBUTTON "Get the Plug-in",IDC_GET_PLUGIN,41,127,64,14
|
||||
PUSHBUTTON "Cancel",IDC_BUTTON_CANCEL,109,127,64,14
|
||||
CTEXT "type/x-type",IDC_STATIC_INFOTYPE,7,18,211,8
|
||||
LTEXT "The SmartUpdate feature makes it easy to install new plug-ins. To take advantage of SmartUpdate, you must enable Java, JavaScript and AutoInstall in the Advanced panel of the Preferences, then click the plug-in icon on the page.",
|
||||
IDC_STATIC_WARNING,7,74,211,35
|
||||
LTEXT "Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static ",
|
||||
IDC_STATIC_URL,7,43,211,24
|
||||
END
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,15
|
||||
PRODUCTVERSION 1,0,0,15
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "Comments", "\0"
|
||||
VALUE "CompanyName", "Netscape Communications, Inc.\0"
|
||||
VALUE "FileDescription", "Default Plug-in\0"
|
||||
VALUE "FileExtents", "*\0"
|
||||
VALUE "FileOpenName", "Netscape Default Plug-in (*.*)\0"
|
||||
VALUE "FileVersion", "1, 0, 0, 15\0"
|
||||
VALUE "InternalName", "DEFPLUGIN\0"
|
||||
VALUE "LegalCopyright", "Copyright © 1995-1997\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "MIMEType", "*\0"
|
||||
VALUE "OriginalFilename", "NPNUL32.DLL\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "Netscape Default Plug-in\0"
|
||||
VALUE "ProductVersion", "1, 0, 0, 15\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_PLUGICON ICON DISCARDABLE "plugicon.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_PLUGIN_DOWNLOAD, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 218
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 141
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_INFO "Information on this page requires a plug-in for:"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_LOCATION "Navigator can retrieve the plug-in for you from:"
|
||||
IDS_TITLE "Plug-in Not Loaded"
|
||||
IDS_QUESTION "What would you like to do?"
|
||||
IDS_WARNING_JS "The SmartUpdate feature makes it easy to install new plug-ins. To take advantage of SmartUpdate, you must enable Java, JavaScript and AutoInstall in the Advanced panel of the Preferences, then click the plug-in icon on the page."
|
||||
IDS_WARNING_OFFLINE "However, you are currently offline. If you would like to get the plug-in, click Cancel, select ""Go Online"" from the File menu, then click the plug-in icon on the page."
|
||||
IDS_FINDER_PAGE "Netscape's Plug-in Finder page"
|
||||
IDS_CLICK_TO_GET "Click here to get the plugin"
|
||||
IDS_CLICK_WHEN_DONE "Click here after installing the plugin"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
|
@ -0,0 +1,305 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "Plugin.h" // this includes npapi.h
|
||||
#include "utils.h"
|
||||
#include "dbg.h"
|
||||
|
||||
char szAppName[] = "NPNULL";
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_Initialize:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NPP_Initialize(void)
|
||||
{
|
||||
RegisterNullPluginWindowClass();
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_Shutdown:
|
||||
//---------------------------------------------------------------------------
|
||||
void NPP_Shutdown(void)
|
||||
{
|
||||
UnregisterNullPluginWindowClass();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_New:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NP_LOADDS NPP_New(NPMIMEType pluginType,
|
||||
NPP pInstance,
|
||||
uint16 mode,
|
||||
int16 argc,
|
||||
char* argn[],
|
||||
char* argv[],
|
||||
NPSavedData* saved)
|
||||
{
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
// See if the content provider specified from where to fetch the plugin
|
||||
char * szPageURL = NULL;
|
||||
char * szFileURL = NULL;
|
||||
char * szFileExtension = NULL;
|
||||
char * buf = NULL;
|
||||
BOOL bHidden = FALSE;
|
||||
|
||||
for(int i = 0; i < argc; i++)
|
||||
{
|
||||
if(lstrcmpi(argn[i],"pluginspage") == 0 && argv[i] != NULL)
|
||||
szPageURL = (char *)argv[i];
|
||||
else if(lstrcmpi(argn[i],"codebase") == 0 && argv[i] != NULL)
|
||||
szPageURL = (char *)argv[i];
|
||||
else if(lstrcmpi(argn[i],"pluginurl") == 0 && argv[i] != NULL)
|
||||
szFileURL = (char *)argv[i];
|
||||
else if(lstrcmpi(argn[i],"classid") == 0 && argv[i] != NULL)
|
||||
szFileURL = (char *)argv[i];
|
||||
else if(lstrcmpi(argn[i],"SRC") == 0 && argv[i] != NULL)
|
||||
buf = (char *)argv[i];
|
||||
else if(lstrcmpi(argn[i],"HIDDEN") == 0 && argv[i] != NULL)
|
||||
bHidden = (lstrcmp((char *)argv[i], "TRUE") == 0);
|
||||
}
|
||||
|
||||
/* some post-processing on the filename to attempt to extract the extension: */
|
||||
if(buf != NULL)
|
||||
{
|
||||
buf = strrchr(buf, '.');
|
||||
szFileExtension = ++buf;
|
||||
}
|
||||
|
||||
CPlugin * pPlugin = new CPlugin(hInst,
|
||||
pInstance,
|
||||
mode,
|
||||
pluginType,
|
||||
szPageURL,
|
||||
szFileURL,
|
||||
szFileExtension,
|
||||
bHidden);
|
||||
if(pPlugin == NULL)
|
||||
return NPERR_OUT_OF_MEMORY_ERROR;
|
||||
|
||||
if(bHidden)
|
||||
{
|
||||
if(!pPlugin->init(NULL))
|
||||
{
|
||||
delete pPlugin;
|
||||
pPlugin = NULL;
|
||||
return NPERR_MODULE_LOAD_FAILED_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
pInstance->pdata = (void *)pPlugin;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_Destroy:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NP_LOADDS
|
||||
NPP_Destroy(NPP pInstance, NPSavedData** save)
|
||||
{
|
||||
dbgOut1("NPP_Destroy");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
if(pPlugin != NULL)
|
||||
{
|
||||
pPlugin->shut();
|
||||
delete pPlugin;
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_SetWindow:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NP_LOADDS NPP_SetWindow(NPP pInstance, NPWindow * pNPWindow)
|
||||
{
|
||||
if(pInstance == NULL)
|
||||
{
|
||||
dbgOut1("NPP_SetWindow returns NPERR_INVALID_INSTANCE_ERROR");
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
}
|
||||
|
||||
if(pNPWindow == NULL)
|
||||
{
|
||||
dbgOut1("NPP_SetWindow returns NPERR_GENERIC_ERROR");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
HWND hWnd = (HWND)(DWORD)pNPWindow->window;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
if(pPlugin == NULL)
|
||||
{
|
||||
dbgOut1("NPP_SetWindow returns NPERR_GENERIC_ERROR");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
if((hWnd == NULL) && (pPlugin->getWindow() == NULL)) // spurious entry
|
||||
{
|
||||
dbgOut1("NPP_SetWindow just returns with NPERR_NO_ERROR");
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
if((hWnd == NULL) && (pPlugin->getWindow() != NULL))
|
||||
{ // window went away
|
||||
dbgOut1("NPP_SetWindow, going away...");
|
||||
pPlugin->shut();
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
if((pPlugin->getWindow() == NULL) && (hWnd != NULL))
|
||||
{ // First time in -- no window created by plugin yet
|
||||
dbgOut1("NPP_SetWindow, first time");
|
||||
|
||||
if(!pPlugin->init(hWnd))
|
||||
{
|
||||
delete pPlugin;
|
||||
pPlugin = NULL;
|
||||
return NPERR_MODULE_LOAD_FAILED_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if((pPlugin->getWindow() != NULL) && (hWnd != NULL))
|
||||
{ // Netscape window has been resized
|
||||
dbgOut1("NPP_SetWindow, resizing");
|
||||
pPlugin->resize();
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_NewStream:
|
||||
//------------------------------------------------------------------------------------
|
||||
NPError NP_LOADDS
|
||||
NPP_NewStream(NPP pInstance,
|
||||
NPMIMEType type,
|
||||
NPStream *stream,
|
||||
NPBool seekable,
|
||||
uint16 *stype)
|
||||
{
|
||||
dbgOut1("NPP_NewStream");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_WriteReady:
|
||||
//------------------------------------------------------------------------------------
|
||||
int32 NP_LOADDS
|
||||
NPP_WriteReady(NPP pInstance, NPStream *stream)
|
||||
{
|
||||
dbgOut1("NPP_WriteReady");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
return -1L; // dont accept any bytes in NPP_Write()
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_Write:
|
||||
//------------------------------------------------------------------------------------
|
||||
int32 NP_LOADDS
|
||||
NPP_Write(NPP pInstance, NPStream *stream, int32 offset, int32 len, void *buffer)
|
||||
{
|
||||
//dbgOut1("NPP_Write");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
return -1; // tell Nav to abort the stream, don't need it
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_DestroyStream:
|
||||
//------------------------------------------------------------------------------------
|
||||
NPError NP_LOADDS
|
||||
NPP_DestroyStream(NPP pInstance, NPStream *stream, NPError reason)
|
||||
{
|
||||
dbgOut1("NPP_DestroyStream");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_StreamAsFile:
|
||||
//------------------------------------------------------------------------------------
|
||||
void NP_LOADDS
|
||||
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
|
||||
{
|
||||
dbgOut1("NPP_StreamAsFile");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_Print:
|
||||
//------------------------------------------------------------------------------------
|
||||
void NP_LOADDS NPP_Print(NPP pInstance, NPPrint * printInfo)
|
||||
{
|
||||
dbgOut2("NPP_Print, printInfo = %#08x", printInfo);
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
pPlugin->print(printInfo);
|
||||
}
|
||||
|
||||
void NP_LOADDS NPP_URLNotify(NPP pInstance, const char* url, NPReason reason, void* notifyData)
|
||||
{
|
||||
dbgOut2("NPP_URLNotify, URL '%s'", url);
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
pPlugin->URLNotify(url);
|
||||
}
|
||||
|
||||
jref NP_LOADDS NPP_GetJavaClass(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
|
@ -0,0 +1,333 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef _NPAPI_H_
|
||||
#include "npapi.h"
|
||||
#endif
|
||||
#ifndef _NPUPP_H_
|
||||
#include "npupp.h"
|
||||
#endif
|
||||
|
||||
//\\// DEFINE
|
||||
#define NP_EXPORT
|
||||
|
||||
//\\// GLOBAL DATA
|
||||
NPNetscapeFuncs* g_pNavigatorFuncs = 0;
|
||||
JRIGlobalRef Private_GetJavaClass(void);
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// Private_GetJavaClass (global function)
|
||||
//
|
||||
// Given a Java class reference (thru NPP_GetJavaClass) inform JRT
|
||||
// of this class existence
|
||||
//
|
||||
JRIGlobalRef
|
||||
Private_GetJavaClass(void)
|
||||
{
|
||||
jref clazz = NPP_GetJavaClass();
|
||||
if (clazz) {
|
||||
JRIEnv* env = NPN_GetJavaEnv();
|
||||
return JRI_NewGlobalRef(env, clazz);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// PLUGIN DLL entry points
|
||||
//
|
||||
// These are the Windows specific DLL entry points. They must be exoprted
|
||||
//
|
||||
|
||||
// we need these to be global since we have to fill one of its field
|
||||
// with a data (class) which requires knowlwdge of the navigator
|
||||
// jump-table. This jump table is known at Initialize time (NP_Initialize)
|
||||
// which is called after NP_GetEntryPoint
|
||||
static NPPluginFuncs* g_pluginFuncs;
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// NP_GetEntryPoints
|
||||
//
|
||||
// fills in the func table used by Navigator to call entry points in
|
||||
// plugin DLL. Note that these entry points ensure that DS is loaded
|
||||
// by using the NP_LOADDS macro, when compiling for Win16
|
||||
//
|
||||
NPError WINAPI NP_EXPORT
|
||||
NP_GetEntryPoints(NPPluginFuncs* pFuncs)
|
||||
{
|
||||
// trap a NULL ptr
|
||||
if(pFuncs == NULL)
|
||||
return NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
// if the plugin's function table is smaller than the plugin expects,
|
||||
// then they are incompatible, and should return an error
|
||||
|
||||
pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
|
||||
pFuncs->newp = NPP_New;
|
||||
pFuncs->destroy = NPP_Destroy;
|
||||
pFuncs->setwindow = NPP_SetWindow;
|
||||
pFuncs->newstream = NPP_NewStream;
|
||||
pFuncs->destroystream = NPP_DestroyStream;
|
||||
pFuncs->asfile = NPP_StreamAsFile;
|
||||
pFuncs->writeready = NPP_WriteReady;
|
||||
pFuncs->write = NPP_Write;
|
||||
pFuncs->print = NPP_Print;
|
||||
pFuncs->event = 0; /// reserved
|
||||
|
||||
g_pluginFuncs = pFuncs;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// NP_Initialize
|
||||
//
|
||||
// called immediately after the plugin DLL is loaded
|
||||
//
|
||||
NPError WINAPI NP_EXPORT
|
||||
NP_Initialize(NPNetscapeFuncs* pFuncs)
|
||||
{
|
||||
// trap a NULL ptr
|
||||
if(pFuncs == NULL)
|
||||
return NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
g_pNavigatorFuncs = pFuncs; // save it for future reference
|
||||
|
||||
// if the plugin's major ver level is lower than the Navigator's,
|
||||
// then they are incompatible, and should return an error
|
||||
if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
|
||||
return NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
|
||||
// We have to defer these assignments until g_pNavigatorFuncs is set
|
||||
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
|
||||
g_pluginFuncs->urlnotify = NPP_URLNotify;
|
||||
}
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_LIVECONNECT ) {
|
||||
g_pluginFuncs->javaClass = Private_GetJavaClass();
|
||||
}
|
||||
|
||||
// NPP_Initialize is a standard (cross-platform) initialize function.
|
||||
return NPP_Initialize();
|
||||
}
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// NP_Shutdown
|
||||
//
|
||||
// called immediately before the plugin DLL is unloaded.
|
||||
// This functio shuold check for some ref count on the dll to see if it is
|
||||
// unloadable or it needs to stay in memory.
|
||||
//
|
||||
NPError WINAPI NP_EXPORT
|
||||
NP_Shutdown()
|
||||
{
|
||||
NPP_Shutdown();
|
||||
g_pNavigatorFuncs = NULL;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// END - PLUGIN DLL entry points
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
|
||||
/* NAVIGATOR Entry points */
|
||||
|
||||
/* These entry points expect to be called from within the plugin. The
|
||||
noteworthy assumption is that DS has already been set to point to the
|
||||
plugin's DLL data segment. Don't call these functions from outside
|
||||
the plugin without ensuring DS is set to the DLLs data segment first,
|
||||
typically using the NP_LOADDS macro
|
||||
*/
|
||||
|
||||
/* returns the major/minor version numbers of the Plugin API for the plugin
|
||||
and the Navigator
|
||||
*/
|
||||
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
|
||||
{
|
||||
*plugin_major = NP_VERSION_MAJOR;
|
||||
*plugin_minor = NP_VERSION_MINOR;
|
||||
*netscape_major = HIBYTE(g_pNavigatorFuncs->version);
|
||||
*netscape_minor = LOBYTE(g_pNavigatorFuncs->version);
|
||||
}
|
||||
|
||||
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *result)
|
||||
{
|
||||
return g_pNavigatorFuncs->getvalue(instance, variable, result);
|
||||
}
|
||||
|
||||
|
||||
/* causes the specified URL to be fetched and streamed in
|
||||
*/
|
||||
NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
|
||||
|
||||
{
|
||||
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
|
||||
err = g_pNavigatorFuncs->geturlnotify(instance, url, target, notifyData);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
|
||||
{
|
||||
return g_pNavigatorFuncs->geturl(instance, url, target);
|
||||
}
|
||||
|
||||
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
|
||||
{
|
||||
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
|
||||
err = g_pNavigatorFuncs->posturlnotify(instance, url, window, len, buf, file, notifyData);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
|
||||
{
|
||||
return g_pNavigatorFuncs->posturl(instance, url, window, len, buf, file);
|
||||
}
|
||||
|
||||
/* Requests that a number of bytes be provided on a stream. Typically
|
||||
this would be used if a stream was in "pull" mode. An optional
|
||||
position can be provided for streams which are seekable.
|
||||
*/
|
||||
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
|
||||
{
|
||||
return g_pNavigatorFuncs->requestread(stream, rangeList);
|
||||
}
|
||||
|
||||
/* Creates a new stream of data from the plug-in to be interpreted
|
||||
by Netscape in the current window.
|
||||
*/
|
||||
NPError NPN_NewStream(NPP instance, NPMIMEType type,
|
||||
const char* target, NPStream** stream)
|
||||
{
|
||||
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
|
||||
err = g_pNavigatorFuncs->newstream(instance, type, target, stream);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Provides len bytes of data.
|
||||
*/
|
||||
int32 NPN_Write(NPP instance, NPStream *stream,
|
||||
int32 len, void *buffer)
|
||||
{
|
||||
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
|
||||
int32 result;
|
||||
|
||||
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
|
||||
result = g_pNavigatorFuncs->write(instance, stream, len, buffer);
|
||||
}
|
||||
else {
|
||||
result = -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Closes a stream object.
|
||||
reason indicates why the stream was closed.
|
||||
*/
|
||||
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
|
||||
err = g_pNavigatorFuncs->destroystream(instance, stream, reason);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Provides a text status message in the Netscape client user interface
|
||||
*/
|
||||
void NPN_Status(NPP instance, const char *message)
|
||||
{
|
||||
g_pNavigatorFuncs->status(instance, message);
|
||||
}
|
||||
|
||||
/* returns the user agent string of Navigator, which contains version info
|
||||
*/
|
||||
const char* NPN_UserAgent(NPP instance)
|
||||
{
|
||||
return g_pNavigatorFuncs->uagent(instance);
|
||||
}
|
||||
|
||||
/* allocates memory from the Navigator's memory space. Necessary so that
|
||||
saved instance data may be freed by Navigator when exiting.
|
||||
*/
|
||||
|
||||
|
||||
void* NPN_MemAlloc(uint32 size)
|
||||
{
|
||||
return g_pNavigatorFuncs->memalloc(size);
|
||||
}
|
||||
|
||||
/* reciprocal of MemAlloc() above
|
||||
*/
|
||||
void NPN_MemFree(void* ptr)
|
||||
{
|
||||
g_pNavigatorFuncs->memfree(ptr);
|
||||
}
|
||||
|
||||
/* private function to Netscape. do not use!
|
||||
*/
|
||||
void NPN_ReloadPlugins(NPBool reloadPages)
|
||||
{
|
||||
g_pNavigatorFuncs->reloadplugins(reloadPages);
|
||||
}
|
||||
|
||||
JRIEnv* NPN_GetJavaEnv(void)
|
||||
{
|
||||
return g_pNavigatorFuncs->getJavaEnv();
|
||||
}
|
||||
|
||||
jref NPN_GetJavaPeer(NPP instance)
|
||||
{
|
||||
return g_pNavigatorFuncs->getJavaPeer(instance);
|
||||
}
|
||||
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 766 B |
|
@ -0,0 +1,648 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "plugin.h"
|
||||
#include "utils.h"
|
||||
#include "dialogs.h"
|
||||
#include "dbg.h"
|
||||
|
||||
static char szNullPluginWindowClassName[] = CLASS_NULL_PLUGIN;
|
||||
|
||||
static LRESULT CALLBACK NP_LOADDS PluginWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
static char szDefaultPluginFinderURL[] = DEFAULT_PLUGINFINDER_URL;
|
||||
static char szPageUrlForJavaScript[] = PAGE_URL_FOR_JAVASCRIPT;
|
||||
static char szPageUrlForJVM[] = JVM_SMARTUPDATE_URL;
|
||||
//static char szPluginFinderCommandFormatString[] = PLUGINFINDER_COMMAND;
|
||||
static char szPluginFinderCommandBeginning[] = PLUGINFINDER_COMMAND_BEGINNING;
|
||||
static char szPluginFinderCommandEnd[] = PLUGINFINDER_COMMAND_END;
|
||||
static char szDefaultFileExt[] = "*";
|
||||
|
||||
BOOL RegisterNullPluginWindowClass()
|
||||
{
|
||||
assert(hInst != NULL);
|
||||
|
||||
WNDCLASS wc;
|
||||
|
||||
memset(&wc, 0, sizeof(wc));
|
||||
|
||||
wc.lpfnWndProc = (WNDPROC)PluginWndProc;
|
||||
wc.cbWndExtra = sizeof(DWORD);
|
||||
wc.hInstance = hInst;
|
||||
wc.hIcon = LoadIcon(hInst, IDI_APPLICATION);
|
||||
wc.hCursor = NULL;
|
||||
wc.hbrBackground = HBRUSH(COLOR_WINDOW + 1);
|
||||
wc.lpszClassName = szNullPluginWindowClassName;
|
||||
|
||||
ATOM aRet = RegisterClass(&wc);
|
||||
return (aRet != NULL);
|
||||
}
|
||||
|
||||
void UnregisterNullPluginWindowClass()
|
||||
{
|
||||
assert(hInst != NULL);
|
||||
UnregisterClass(szNullPluginWindowClassName, hInst);
|
||||
}
|
||||
|
||||
/*********************************************/
|
||||
/* */
|
||||
/* CPlugin class implementation */
|
||||
/* */
|
||||
/*********************************************/
|
||||
|
||||
CPlugin::CPlugin(HINSTANCE hInst,
|
||||
NPP pNPInstance,
|
||||
WORD wMode,
|
||||
NPMIMEType pluginType,
|
||||
LPSTR szPageURL,
|
||||
LPSTR szFileURL,
|
||||
LPSTR szFileExtension,
|
||||
BOOL bHidden) :
|
||||
m_pNPInstance(pNPInstance),
|
||||
m_wMode(wMode),
|
||||
m_hInst(hInst),
|
||||
m_hWnd(NULL),
|
||||
m_hWndParent(NULL),
|
||||
m_hIcon(NULL),
|
||||
m_pNPMIMEType(NULL),
|
||||
m_szPageURL(NULL),
|
||||
m_szFileURL(NULL),
|
||||
m_szFileExtension(NULL),
|
||||
m_bOnline(TRUE),
|
||||
m_bJava(TRUE),
|
||||
m_bJavaScript(TRUE),
|
||||
m_bSmartUpdate(TRUE),
|
||||
m_szURLString(NULL),
|
||||
m_szCommandMessage(NULL),
|
||||
m_bHidden(bHidden)
|
||||
{
|
||||
dbgOut1("CPlugin::CPlugin()");
|
||||
assert(m_hInst != NULL);
|
||||
assert(m_pNPInstance != NULL);
|
||||
|
||||
if((pluginType != NULL) && (lstrlen((LPSTR)pluginType) != 0))
|
||||
{
|
||||
m_pNPMIMEType = (NPMIMEType)new char[lstrlen((LPSTR)pluginType) + 1];
|
||||
if(m_pNPMIMEType != NULL)
|
||||
lstrcpy((LPSTR)m_pNPMIMEType, pluginType);
|
||||
}
|
||||
|
||||
if((szPageURL != NULL) && (lstrlen(szPageURL) != 0))
|
||||
{
|
||||
m_szPageURL = new char[lstrlen(szPageURL) + 1];
|
||||
if(m_szPageURL != NULL)
|
||||
lstrcpy(m_szPageURL, szPageURL);
|
||||
}
|
||||
|
||||
if((szFileURL != NULL) && (lstrlen(szFileURL) != 0))
|
||||
{
|
||||
m_szFileURL = new char[lstrlen(szFileURL) + 1];
|
||||
if(m_szFileURL != NULL)
|
||||
lstrcpy(m_szFileURL, szFileURL);
|
||||
}
|
||||
|
||||
if((szFileExtension != NULL) && (lstrlen(szFileExtension) != 0))
|
||||
{
|
||||
m_szFileExtension = new char[lstrlen(szFileExtension) + 1];
|
||||
if(m_szFileExtension != NULL)
|
||||
lstrcpy(m_szFileExtension, szFileExtension);
|
||||
}
|
||||
|
||||
m_hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_PLUGICON));
|
||||
|
||||
char szString[1024] = {'\0'};
|
||||
LoadString(m_hInst, IDS_CLICK_TO_GET, szString, sizeof(szString));
|
||||
if(lstrlen(szString) != 0)
|
||||
{
|
||||
m_szCommandMessage = new char[lstrlen(szString) + 1];
|
||||
if(m_szCommandMessage != NULL)
|
||||
lstrcpy(m_szCommandMessage, szString);
|
||||
}
|
||||
}
|
||||
|
||||
CPlugin::~CPlugin()
|
||||
{
|
||||
dbgOut1("CPlugin::~CPlugin()");
|
||||
|
||||
if(m_pNPMIMEType != NULL)
|
||||
{
|
||||
delete [] m_pNPMIMEType;
|
||||
m_pNPMIMEType = NULL;
|
||||
}
|
||||
|
||||
if(m_szPageURL != NULL)
|
||||
{
|
||||
delete [] m_szPageURL;
|
||||
m_szPageURL = NULL;
|
||||
}
|
||||
|
||||
if(m_szFileURL != NULL)
|
||||
{
|
||||
delete [] m_szFileURL;
|
||||
m_szFileURL = NULL;
|
||||
}
|
||||
|
||||
if(m_szFileExtension != NULL)
|
||||
{
|
||||
delete [] m_szFileExtension;
|
||||
m_szFileExtension = NULL;
|
||||
}
|
||||
|
||||
if(m_szURLString != NULL)
|
||||
{
|
||||
delete [] m_szURLString;
|
||||
m_szURLString = NULL;
|
||||
}
|
||||
|
||||
if(m_hIcon != NULL)
|
||||
{
|
||||
DestroyIcon(m_hIcon);
|
||||
m_hIcon = NULL;
|
||||
}
|
||||
|
||||
if(m_szCommandMessage != NULL)
|
||||
{
|
||||
delete [] m_szCommandMessage;
|
||||
m_szCommandMessage = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CPlugin::init(HWND hWndParent)
|
||||
{
|
||||
dbgOut1("CPlugin::init()");
|
||||
|
||||
if(!m_bHidden)
|
||||
{
|
||||
assert(IsWindow(hWndParent));
|
||||
|
||||
if(IsWindow(hWndParent))
|
||||
m_hWndParent = hWndParent;
|
||||
|
||||
RECT rcParent;
|
||||
GetClientRect(m_hWndParent, &rcParent);
|
||||
|
||||
CreateWindow(szNullPluginWindowClassName,
|
||||
"NULL Plugin",
|
||||
WS_CHILD,
|
||||
0,0, rcParent.right, rcParent.bottom,
|
||||
m_hWndParent,
|
||||
(HMENU)NULL,
|
||||
m_hInst,
|
||||
(LPVOID)this);
|
||||
|
||||
assert(m_hWnd != NULL);
|
||||
if((m_hWnd == NULL) || (!IsWindow(m_hWnd)))
|
||||
return FALSE;
|
||||
|
||||
UpdateWindow(m_hWnd);
|
||||
ShowWindow(m_hWnd, SW_SHOW);
|
||||
}
|
||||
|
||||
if(IsNewMimeType((LPSTR)m_pNPMIMEType) || m_bHidden)
|
||||
showGetPluginDialog();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CPlugin::shut()
|
||||
{
|
||||
dbgOut1("CPlugin::shut()");
|
||||
|
||||
if(m_hWnd != NULL)
|
||||
{
|
||||
DestroyWindow(m_hWnd);
|
||||
m_hWnd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
HWND CPlugin::getWindow()
|
||||
{
|
||||
return m_hWnd;
|
||||
}
|
||||
|
||||
BOOL CPlugin::useDefaultURL_P()
|
||||
{
|
||||
if((m_szPageURL == NULL) && (m_szFileURL == NULL))
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CPlugin::doSmartUpdate_P()
|
||||
{
|
||||
// due to current JavaScript problems never do it smart for now 5.1.98
|
||||
return FALSE;
|
||||
|
||||
if(m_bOnline && m_bJava && m_bJavaScript && m_bSmartUpdate && useDefaultURL_P())
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LPSTR CPlugin::createURLString()
|
||||
{
|
||||
if(m_szURLString != NULL)
|
||||
{
|
||||
delete [] m_szURLString;
|
||||
m_szURLString = NULL;
|
||||
}
|
||||
|
||||
// check if there is file URL first
|
||||
if(m_szFileURL != NULL)
|
||||
{
|
||||
m_szURLString = new char[lstrlen(m_szFileURL) + 1];
|
||||
if(m_szURLString == NULL)
|
||||
return NULL;
|
||||
lstrcpy(m_szURLString, m_szFileURL);
|
||||
return m_szURLString;
|
||||
}
|
||||
|
||||
// if not get the page URL
|
||||
char * szAddress = NULL;
|
||||
char *urlToOpen = NULL;
|
||||
char contentTypeIsJava = 0;
|
||||
|
||||
if (NULL != m_pNPMIMEType) {
|
||||
contentTypeIsJava = (0 == strcmp("application/x-java-vm",
|
||||
m_pNPMIMEType)) ? 1 : 0;
|
||||
}
|
||||
|
||||
if(m_szPageURL != NULL && !contentTypeIsJava)
|
||||
{
|
||||
szAddress = new char[lstrlen(m_szPageURL) + 1];
|
||||
if(szAddress == NULL)
|
||||
return NULL;
|
||||
lstrcpy(szAddress, m_szPageURL);
|
||||
|
||||
m_szURLString = new char[lstrlen(szAddress) + 1 + lstrlen((LPSTR)m_pNPMIMEType) + 1];
|
||||
|
||||
if(m_szURLString == NULL)
|
||||
return NULL;
|
||||
|
||||
// Append the MIME type to the URL
|
||||
wsprintf(m_szURLString, "%s?%s", szAddress, (LPSTR)m_pNPMIMEType);
|
||||
}
|
||||
else // default
|
||||
{
|
||||
if(!m_bJavaScript)
|
||||
{
|
||||
urlToOpen = szDefaultPluginFinderURL;
|
||||
|
||||
if (contentTypeIsJava) {
|
||||
urlToOpen = szPageUrlForJVM;
|
||||
}
|
||||
|
||||
szAddress = new char[lstrlen(urlToOpen) + 1];
|
||||
if(szAddress == NULL)
|
||||
return NULL;
|
||||
lstrcpy(szAddress, urlToOpen);
|
||||
|
||||
m_szURLString = new char[lstrlen(szAddress) + 1 + lstrlen((LPSTR)m_pNPMIMEType) + 1];
|
||||
|
||||
if(m_szURLString == NULL)
|
||||
return NULL;
|
||||
|
||||
// Append the MIME type to the URL
|
||||
wsprintf(m_szURLString, "%s?%s", szAddress, (LPSTR)m_pNPMIMEType);
|
||||
}
|
||||
else
|
||||
{
|
||||
urlToOpen = szPageUrlForJavaScript;
|
||||
|
||||
if (contentTypeIsJava) {
|
||||
urlToOpen = szPageUrlForJVM;
|
||||
}
|
||||
|
||||
m_szURLString = new char[lstrlen(szPluginFinderCommandBeginning) + lstrlen(urlToOpen) + 10 +
|
||||
lstrlen((LPSTR)m_pNPMIMEType) + lstrlen(szPluginFinderCommandEnd) + 1];
|
||||
wsprintf(m_szURLString, "%s%s?mimetype=%s%s",
|
||||
szPluginFinderCommandBeginning, urlToOpen,
|
||||
(LPSTR)m_pNPMIMEType, szPluginFinderCommandEnd);
|
||||
}
|
||||
}
|
||||
|
||||
if(szAddress != NULL)
|
||||
delete [] szAddress;
|
||||
|
||||
return m_szURLString;
|
||||
}
|
||||
|
||||
void CPlugin::getPluginRegular()
|
||||
{
|
||||
assert(m_bOnline);
|
||||
|
||||
char * szURL = createURLString();
|
||||
|
||||
assert(szURL != NULL);
|
||||
if(szURL == NULL)
|
||||
return;
|
||||
|
||||
dbgOut3("CPlugin::getPluginRegular(), %#08x '%s'", m_pNPInstance, szURL);
|
||||
|
||||
if(m_szFileURL != NULL)
|
||||
NPN_GetURL(m_pNPInstance, szURL, "_current");
|
||||
else if(m_szPageURL != NULL)
|
||||
NPN_GetURL(m_pNPInstance, szURL, "_blank");
|
||||
else if(m_bJavaScript)
|
||||
NPN_GetURL(m_pNPInstance, szURL, NULL);
|
||||
else
|
||||
NPN_GetURL(m_pNPInstance, szURL, "_blank");
|
||||
}
|
||||
|
||||
void CPlugin::getPluginSmart()
|
||||
{
|
||||
/*
|
||||
static char szJSString[2048];
|
||||
|
||||
wsprintf(szJSString,
|
||||
szPluginFinderCommandFormatString,
|
||||
szDefaultPluginFinderURL,
|
||||
m_pNPMIMEType,
|
||||
(m_szFileExtension != NULL) ? m_szFileExtension : szDefaultFileExt);
|
||||
|
||||
dbgOut3("%#08x '%s'", m_pNPInstance, szJSString);
|
||||
|
||||
assert(lstrlen(szJSString) > 0);
|
||||
|
||||
NPN_GetURL(m_pNPInstance, szJSString, "smartupdate_plugin_finder");
|
||||
*/
|
||||
}
|
||||
|
||||
void CPlugin::showGetPluginDialog()
|
||||
{
|
||||
assert(m_pNPMIMEType != NULL);
|
||||
if(m_pNPMIMEType == NULL)
|
||||
return;
|
||||
|
||||
// Get environment
|
||||
BOOL bOffline = FALSE;
|
||||
|
||||
NPN_GetValue(m_pNPInstance, NPNVisOfflineBool, (void *)&bOffline);
|
||||
NPN_GetValue(m_pNPInstance, NPNVjavascriptEnabledBool, (void *)&m_bJavaScript);
|
||||
NPN_GetValue(m_pNPInstance, NPNVasdEnabledBool, (void *)&m_bSmartUpdate);
|
||||
|
||||
m_bOnline = !bOffline;
|
||||
|
||||
if(m_bOnline && m_bJavaScript && m_bSmartUpdate && useDefaultURL_P())
|
||||
{
|
||||
JRIEnv *penv = NPN_GetJavaEnv();
|
||||
m_bJava = (penv != NULL);
|
||||
}
|
||||
|
||||
dbgOut1("Environment:");
|
||||
dbgOut2("%s", m_bOnline ? "On-line" : "Off-line");
|
||||
dbgOut2("Java %s", m_bJava ? "Enabled" : "Disabled");
|
||||
dbgOut2("JavaScript %s", m_bJavaScript ? "Enabled" : "Disabled");
|
||||
dbgOut2("SmartUpdate %s", m_bSmartUpdate ? "Enabled" : "Disabled");
|
||||
|
||||
if((m_szPageURL != NULL) || (m_szFileURL != NULL) || !m_bJavaScript)
|
||||
{
|
||||
int iRet = DialogBoxParam(m_hInst, MAKEINTRESOURCE(IDD_PLUGIN_DOWNLOAD), m_hWnd,
|
||||
(DLGPROC)GetPluginDialogProc, (LPARAM)this);
|
||||
if(iRet != IDC_GET_PLUGIN)
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_szCommandMessage != NULL)
|
||||
{
|
||||
delete [] m_szCommandMessage;
|
||||
m_szCommandMessage = NULL;
|
||||
}
|
||||
|
||||
char szString[1024] = {'\0'};
|
||||
LoadString(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString));
|
||||
if(lstrlen(szString) != 0)
|
||||
{
|
||||
m_szCommandMessage = new char[lstrlen(szString) + 1];
|
||||
if(m_szCommandMessage != NULL)
|
||||
lstrcpy(m_szCommandMessage, szString);
|
||||
}
|
||||
|
||||
InvalidateRect(m_hWnd, NULL, TRUE);
|
||||
UpdateWindow(m_hWnd);
|
||||
|
||||
getPluginRegular();
|
||||
}
|
||||
|
||||
//*******************
|
||||
// NP API handles
|
||||
//*******************
|
||||
void CPlugin::resize()
|
||||
{
|
||||
dbgOut1("CPlugin::resize()");
|
||||
}
|
||||
|
||||
void CPlugin::print(NPPrint * pNPPrint)
|
||||
{
|
||||
dbgOut1("CPlugin::print()");
|
||||
|
||||
if(pNPPrint == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
void CPlugin::URLNotify(const char * szURL)
|
||||
{
|
||||
dbgOut2("CPlugin::URLNotify(), URL '%s'", szURL);
|
||||
|
||||
NPStream * pStream = NULL;
|
||||
char buf[256];
|
||||
|
||||
assert(m_hInst != NULL);
|
||||
assert(m_pNPInstance != NULL);
|
||||
|
||||
int iSize = LoadString(m_hInst, IDS_GOING2HTML, buf, sizeof(buf));
|
||||
|
||||
NPError rc = NPN_NewStream(m_pNPInstance, "text/html", "asd_plugin_finder", &pStream);
|
||||
|
||||
//char buf[] = "<html>\n<body>\n\n<h2 align=center>NPN_NewStream / NPN_Write - This seems to work.</h2>\n\n</body>\n</html>";
|
||||
|
||||
int32 iBytes = NPN_Write(m_pNPInstance, pStream, lstrlen(buf), buf);
|
||||
|
||||
NPN_DestroyStream(m_pNPInstance, pStream, NPRES_DONE);
|
||||
}
|
||||
|
||||
BOOL CPlugin::readyToRefresh()
|
||||
{
|
||||
char szString[1024] = {'\0'};
|
||||
LoadString(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString));
|
||||
if(m_szCommandMessage == NULL)
|
||||
return FALSE;
|
||||
|
||||
return (lstrcmp(m_szCommandMessage, szString) == 0);
|
||||
}
|
||||
|
||||
//***************************
|
||||
// Windows message handlers
|
||||
//***************************
|
||||
void CPlugin::onCreate(HWND hWnd)
|
||||
{
|
||||
m_hWnd = hWnd;
|
||||
}
|
||||
|
||||
void CPlugin::onLButtonUp(HWND hWnd, int x, int y, UINT keyFlags)
|
||||
{
|
||||
if(!readyToRefresh())
|
||||
showGetPluginDialog();
|
||||
else
|
||||
NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self");
|
||||
}
|
||||
|
||||
void CPlugin::onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags)
|
||||
{
|
||||
if(!readyToRefresh())
|
||||
showGetPluginDialog();
|
||||
else
|
||||
NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self");
|
||||
}
|
||||
|
||||
static void DrawCommandMessage(HDC hDC, LPSTR szString, LPRECT lprc)
|
||||
{
|
||||
if(szString == NULL)
|
||||
return;
|
||||
|
||||
HFONT hFont = GetStockFont(DEFAULT_GUI_FONT);
|
||||
if(hFont == NULL)
|
||||
return;
|
||||
|
||||
HFONT hFontOld = SelectFont(hDC, hFont);
|
||||
SIZE sz;
|
||||
GetTextExtentPoint32(hDC, szString, lstrlen(szString), &sz);
|
||||
POINT pt;
|
||||
pt.x = sz.cx;
|
||||
pt.y = sz.cy;
|
||||
LPtoDP(hDC, &pt, 1);
|
||||
|
||||
int iY = (lprc->bottom / 2) - ((32) / 2) + 36;
|
||||
int iX = 0;
|
||||
|
||||
if(lprc->right > pt.x)
|
||||
iX = lprc->right/2 - pt.x/2;
|
||||
else
|
||||
iX = 1;
|
||||
|
||||
RECT rcText;
|
||||
rcText.left = iX;
|
||||
rcText.right = rcText.left + pt.x;
|
||||
rcText.top = iY;
|
||||
rcText.bottom = rcText.top + pt.y;
|
||||
|
||||
int iModeOld = SetBkMode(hDC, TRANSPARENT);
|
||||
COLORREF crColorOld = SetTextColor(hDC, RGB(0,0,0));
|
||||
DrawText(hDC, szString, lstrlen(szString), &rcText, DT_CENTER|DT_VCENTER);
|
||||
SetTextColor(hDC, crColorOld);
|
||||
SetBkMode(hDC, iModeOld);
|
||||
SelectFont(hDC, hFontOld);
|
||||
}
|
||||
|
||||
void CPlugin::onPaint(HWND hWnd)
|
||||
{
|
||||
RECT rc;
|
||||
HDC hDC;
|
||||
PAINTSTRUCT ps;
|
||||
int x, y;
|
||||
|
||||
hDC = BeginPaint(hWnd, &ps);
|
||||
GetClientRect(hWnd, &rc);
|
||||
|
||||
x = (rc.right / 2) - (32 / 2);
|
||||
y = (rc.bottom / 2) - ((32) / 2);
|
||||
|
||||
if(rc.right > 34 && rc.bottom > 34)
|
||||
{
|
||||
if(m_hIcon != NULL)
|
||||
DrawIcon(hDC, x, y, m_hIcon);
|
||||
|
||||
POINT pt[5];
|
||||
|
||||
// left vert and top horiz highlight
|
||||
pt[0].x = 1; pt[0].y = rc.bottom-1;
|
||||
pt[1].x = 1; pt[1].y = 1;
|
||||
pt[2].x = rc.right-1; pt[2].y = 1;
|
||||
|
||||
SelectObject(hDC, (HGDIOBJ)CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DLIGHT)));
|
||||
Polyline(hDC, pt, 3);
|
||||
|
||||
// left vert and top horiz shadow
|
||||
pt[0].x = 2; pt[0].y = rc.bottom-3;
|
||||
pt[1].x = 2; pt[1].y = 2;
|
||||
pt[2].x = rc.right-2; pt[2].y = 2;
|
||||
SelectObject(hDC, (HGDIOBJ)CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW)));
|
||||
Polyline(hDC, pt, 3);
|
||||
|
||||
// right vert and bottom horiz highlight
|
||||
pt[0].x = rc.right-3; pt[0].y = 2;
|
||||
pt[1].x = rc.right-3; pt[1].y = rc.bottom-3;
|
||||
pt[2].x = 2; pt[2].y = rc.bottom-3;
|
||||
SelectObject(hDC, (HGDIOBJ) CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DLIGHT)));
|
||||
Polyline(hDC, pt, 3);
|
||||
|
||||
// right vert and bottom horiz shadow
|
||||
pt[0].x = rc.right-1; pt[0].y = 1;
|
||||
pt[1].x = rc.right-1; pt[1].y = rc.bottom-1;
|
||||
pt[2].x = 0; pt[2].y = rc.bottom-1;
|
||||
SelectObject(hDC, (HGDIOBJ)CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DDKSHADOW)));
|
||||
Polyline(hDC, pt, 3);
|
||||
}
|
||||
|
||||
DrawCommandMessage(hDC, m_szCommandMessage, &rc);
|
||||
|
||||
EndPaint (hWnd, &ps);
|
||||
}
|
||||
|
||||
//**************************
|
||||
// Plugin window procedure
|
||||
//**************************
|
||||
static LRESULT CALLBACK NP_LOADDS PluginWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
CPlugin *pPlugin = (CPlugin *)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
|
||||
switch(message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
pPlugin = (CPlugin *)(((CREATESTRUCT FAR*)lParam)->lpCreateParams);
|
||||
assert(pPlugin != NULL);
|
||||
SetWindowLong(hWnd, GWL_USERDATA, (LONG)pPlugin);
|
||||
pPlugin->onCreate(hWnd);
|
||||
return 0L;
|
||||
case WM_LBUTTONUP:
|
||||
HANDLE_WM_LBUTTONUP(hWnd, wParam, lParam, pPlugin->onLButtonUp);
|
||||
return 0L;
|
||||
case WM_RBUTTONUP:
|
||||
HANDLE_WM_RBUTTONUP(hWnd, wParam, lParam, pPlugin->onRButtonUp);
|
||||
return 0L;
|
||||
case WM_PAINT:
|
||||
HANDLE_WM_PAINT(hWnd, wParam, lParam, pPlugin->onPaint);
|
||||
return 0L;
|
||||
case WM_MOUSEMOVE:
|
||||
dbgOut1("MouseMove");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return(DefWindowProc(hWnd, message, wParam, lParam));
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef __PLUGIN_HPP__
|
||||
#define __PLUGIN_HPP__
|
||||
|
||||
#include "npapi.h"
|
||||
|
||||
class CPlugin
|
||||
{
|
||||
private:
|
||||
HINSTANCE m_hInst;
|
||||
NPP m_pNPInstance;
|
||||
WORD m_wMode;
|
||||
HWND m_hWnd;
|
||||
HWND m_hWndParent;
|
||||
HICON m_hIcon;
|
||||
char * m_szURLString;
|
||||
|
||||
char * m_szCommandMessage;
|
||||
|
||||
public:
|
||||
BOOL m_bHidden;
|
||||
NPMIMEType m_pNPMIMEType;
|
||||
LPSTR m_szPageURL; // Location of plug-in HTML page
|
||||
LPSTR m_szFileURL; // Location of plug-in JAR file
|
||||
LPSTR m_szFileExtension; // File extension associated with the of the unknown mimetype
|
||||
|
||||
// environment
|
||||
BOOL m_bOnline;
|
||||
BOOL m_bJava;
|
||||
BOOL m_bJavaScript;
|
||||
BOOL m_bSmartUpdate;
|
||||
|
||||
private:
|
||||
BOOL useDefaultURL_P();
|
||||
BOOL doSmartUpdate_P();
|
||||
LPSTR createURLString();
|
||||
void getPluginSmart();
|
||||
void getPluginRegular();
|
||||
|
||||
public:
|
||||
CPlugin(HINSTANCE hInst,
|
||||
NPP pNPInstance,
|
||||
WORD wMode,
|
||||
NPMIMEType pluginType,
|
||||
LPSTR szPageURL,
|
||||
LPSTR szFileURL,
|
||||
LPSTR szFileExtension,
|
||||
BOOL bHidden);
|
||||
~CPlugin();
|
||||
|
||||
BOOL init(HWND hWnd);
|
||||
void shut();
|
||||
HWND getWindow();
|
||||
void showGetPluginDialog();
|
||||
BOOL readyToRefresh();
|
||||
|
||||
// NP API handlers
|
||||
void resize();
|
||||
void print(NPPrint * pNPPrint);
|
||||
void URLNotify(const char * szURL);
|
||||
|
||||
// Windows message handlers
|
||||
void onCreate(HWND hWnd);
|
||||
void onLButtonUp(HWND hWnd, int x, int y, UINT keyFlags);
|
||||
void onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags);
|
||||
void onPaint(HWND hWnd);
|
||||
};
|
||||
|
||||
|
||||
#define PAGE_URL_FOR_JAVASCRIPT "http://cgi.netscape.com/cgi-bin/plugins/get_plugin.cgi"
|
||||
|
||||
#define PLUGINFINDER_COMMAND_BEGINNING "javascript:window.open(\""
|
||||
#define PLUGINFINDER_COMMAND_END "\",\"plugin\",\"toolbar=no,status=no,resizeable=no,scrollbars=no,height=252,width=626\");"
|
||||
#define DEFAULT_PLUGINFINDER_URL "http://cgi.netscape.com/cgi-bin/plug-in_finder.cgi"
|
||||
#define JVM_SMARTUPDATE_URL "http://home.netscape.com/plugins/jvm.html"
|
||||
|
||||
#ifdef WIN32
|
||||
#define REGISTRY_PLACE "Software\\Netscape\\Netscape Navigator\\Default Plugin"
|
||||
#else
|
||||
#define GWL_USERDATA 0
|
||||
#define COLOR_3DSHADOW COLOR_BTNFACE
|
||||
#define COLOR_3DLIGHT COLOR_BTNHIGHLIGHT
|
||||
#define COLOR_3DDKSHADOW COLOR_BTNSHADOW
|
||||
#endif
|
||||
|
||||
#define CLASS_NULL_PLUGIN "NullPluginClass"
|
||||
|
||||
BOOL RegisterNullPluginWindowClass();
|
||||
void UnregisterNullPluginWindowClass();
|
||||
|
||||
extern HINSTANCE hInst;
|
||||
|
||||
#endif // __PLUGIN_HPP__
|
|
@ -0,0 +1,48 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by Npnul32.rc
|
||||
//
|
||||
#define IDD_PLUGIN_DOWNLOAD 301
|
||||
#define IDI_PLUGICON 302
|
||||
#define IDS_INFO 303
|
||||
#define IDS_DEFAULT_URL 304
|
||||
#define IDS_INSTALL_COMMAND 305
|
||||
#define IDS_GET_PLUGIN_MSG2 306
|
||||
#define IDS_LOCATION 306
|
||||
#define IDS_TITLE 307
|
||||
#define IDS_QUESTION 308
|
||||
#define IDS_JS_DISABLED 309
|
||||
#define IDS_ASDFINDER 310
|
||||
#define IDS_ASDSIMP 311
|
||||
#define IDS_QUERY_TEST 312
|
||||
#define IDS_BLANK_JS 313
|
||||
#define IDS_GOING2HTML 314
|
||||
#define IDS_WARNING_JS 315
|
||||
#define IDS_WARNING_OFFLINE 316
|
||||
#define IDS_DEFAULT_URL_OLD 317
|
||||
#define IDS_FINDER_PAGE 317
|
||||
#define IDS_CLICK_TO_GET 318
|
||||
#define IDS_CLICK_WHEN_DONE 319
|
||||
#define IDC_JS_DIS_TEXT 2003
|
||||
#define IDC_CONTINUE 2004
|
||||
#define IDC_CONT_NOJS 2005
|
||||
#define IDC_STATIC_INFO 2009
|
||||
#define IDC_STATIC_LOCATION 2010
|
||||
#define IDC_STATIC_QUESTION 2011
|
||||
#define IDC_GET_PLUGIN 2012
|
||||
#define IDC_BUTTON_CANCEL 2013
|
||||
#define IDC_STATIC_URL 2014
|
||||
#define IDC_STATIC_INFOTYPE 2015
|
||||
#define IDC_STATIC_WARNING 2016
|
||||
#define IDC_EDIT_URL 2017
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 308
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 2018
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,156 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
// open the registry, create if necessary
|
||||
HKEY openRegistry()
|
||||
{
|
||||
HKEY phkResult;
|
||||
|
||||
if(RegCreateKey(HKEY_CURRENT_USER, REGISTRY_PLACE, &phkResult) != ERROR_SUCCESS)
|
||||
MessageBox(0, "Error creating Default Plugin registry key", "Default Plugin", MB_OK);
|
||||
|
||||
return phkResult;
|
||||
}
|
||||
|
||||
// return TRUE if we've never seen this MIME type before
|
||||
BOOL IsNewMimeType(LPSTR mime)
|
||||
{
|
||||
HKEY hkey = openRegistry();
|
||||
DWORD dwType, keysize = 512;
|
||||
char keybuf[512];
|
||||
|
||||
if(RegQueryValueEx(hkey, mime, 0, &dwType, (LPBYTE) &keybuf, &keysize) == ERROR_SUCCESS)
|
||||
{
|
||||
// key exists, must have already been here...
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(RegSetValueEx(hkey, mime, 0, REG_SZ, (LPBYTE) "(none)", 7) != ERROR_SUCCESS)
|
||||
MessageBox(0, "Error adding MIME type value", "Default Plugin", MB_OK);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// string length in pixels for the specific window (selected font)
|
||||
static int getWindowStringLength(HWND hWnd, LPSTR lpsz)
|
||||
{
|
||||
SIZE sz;
|
||||
HDC hDC = GetDC(hWnd);
|
||||
HFONT hWindowFont = GetWindowFont(hWnd);
|
||||
HFONT hFontOld = SelectFont(hDC, hWindowFont);
|
||||
GetTextExtentPoint32(hDC, lpsz, lstrlen(lpsz), &sz);
|
||||
POINT pt;
|
||||
pt.x = sz.cx;
|
||||
pt.y = sz.cy;
|
||||
LPtoDP(hDC, &pt, 1);
|
||||
SelectFont(hDC, hFontOld);
|
||||
ReleaseDC(hWnd, hDC);
|
||||
return (int)pt.x;
|
||||
}
|
||||
|
||||
/****************************************************************/
|
||||
/* */
|
||||
/* void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText) */
|
||||
/* */
|
||||
/* helper to wrap long lines in a static control, which do not */
|
||||
/* wrap automatically if they do not have space characters */
|
||||
/* */
|
||||
/****************************************************************/
|
||||
void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText)
|
||||
{
|
||||
HWND hWndStatic = GetDlgItem(hWnd, iID);
|
||||
if((szText == NULL) || (lstrlen(szText) == 0))
|
||||
{
|
||||
SetDlgItemText(hWnd, iID, "");
|
||||
return;
|
||||
}
|
||||
|
||||
RECT rc;
|
||||
GetClientRect(hWndStatic, &rc);
|
||||
|
||||
int iStaticLength = rc.right - rc.left;
|
||||
int iStringLength = getWindowStringLength(hWndStatic, szText);
|
||||
|
||||
if(iStringLength <= iStaticLength)
|
||||
{
|
||||
SetDlgItemText(hWnd, iID, szText);
|
||||
return;
|
||||
}
|
||||
|
||||
int iBreaks = iStringLength/iStaticLength;
|
||||
if(iBreaks <= 0)
|
||||
return;
|
||||
|
||||
char * pBuf = new char[iStringLength + iBreaks + 1];
|
||||
if(pBuf == NULL)
|
||||
return;
|
||||
|
||||
lstrcpy(pBuf, "");
|
||||
|
||||
int iStart = 0;
|
||||
int iLines = 0;
|
||||
for(int i = 0; i < iStringLength; i++)
|
||||
{
|
||||
char * sz = &szText[iStart];
|
||||
int iIndex = i - iStart;
|
||||
char ch = sz[iIndex + 1];
|
||||
|
||||
sz[iIndex + 1] = '\0';
|
||||
|
||||
int iLength = getWindowStringLength(hWndStatic, sz);
|
||||
|
||||
if(iLength < iStaticLength)
|
||||
{
|
||||
sz[iIndex + 1] = ch;
|
||||
if(iLines == iBreaks)
|
||||
{
|
||||
lstrcat(pBuf, sz);
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
sz[iIndex + 1] = ch; // restore zeroed element
|
||||
i--; // go one step back
|
||||
|
||||
ch = sz[iIndex];
|
||||
sz[iIndex] = '\0'; // terminate string one char shorter
|
||||
|
||||
lstrcat(pBuf, sz); // append the string
|
||||
lstrcat(pBuf, " "); // append space character for successful wrapping
|
||||
|
||||
iStart += lstrlen(sz);// shift new start position
|
||||
sz[iIndex] = ch; // restore zeroed element
|
||||
iLines++; // count lines
|
||||
}
|
||||
|
||||
SetDlgItemText(hWnd, iID, pBuf);
|
||||
|
||||
delete [] pBuf;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef __UTILS_H__
|
||||
#define __UTILS_H__
|
||||
|
||||
HKEY openRegistry();
|
||||
BOOL IsNewMimeType(LPSTR szMimeType);
|
||||
void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText);
|
||||
|
||||
#endif // __UTILS_H__
|
|
@ -0,0 +1,157 @@
|
|||
# Microsoft Developer Studio Project File - Name="Npnul32" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=Npnul32 - Win32 Release
|
||||
!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 "Npnul32.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 "Npnul32.mak" CFG="Npnul32 - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Npnul32 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "Npnul32 - 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)" == "Npnul32 - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\WinRel"
|
||||
# PROP BASE Intermediate_Dir ".\WinRel"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FR /YX /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\include" /I "..\..\..\..\sun-java\stubs\include" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /FD /c
|
||||
# SUBTRACT CPP /Fr /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /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 /nologo /subsystem:windows /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib /nologo /subsystem:windows /dll /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "Npnul32 - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\WinDebug"
|
||||
# PROP BASE Intermediate_Dir ".\WinDebug"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\include" /I "..\..\..\..\sun-java\stubs\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /FD /c
|
||||
# SUBTRACT CPP /Fr /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /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 /nologo /subsystem:windows /dll /debug /machine:I386
|
||||
# ADD 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 /subsystem:windows /dll /debug /machine:I386 /out:"Y:\mozilla\dist\WIN32_D.OBJ\bin\Plugins\Npnul32.dll"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Npnul32 - Win32 Release"
|
||||
# Name "Npnul32 - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dbg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dialogs.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\maindll.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\npnul32.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\npnul32.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\npshell.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\npwin.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\plugin.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\utils.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dbg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dialogs.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\plugin.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\utils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\plugicon.ico
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
|
@ -0,0 +1,44 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
extern char szAppName[];
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
void __cdecl dbgOut(LPSTR format, ...) {
|
||||
static char buf[1024];
|
||||
lstrcpy(buf, szAppName);
|
||||
lstrcat(buf, ": ");
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
wvsprintf(&buf[lstrlen(buf)], format, va);
|
||||
va_end(va);
|
||||
lstrcat(buf, "\n");
|
||||
OutputDebugString(buf);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,51 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef __DBG_HPP_
|
||||
#define __DBG_HPP_
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
void __cdecl dbgOut(LPSTR format, ...);
|
||||
#define dbgOut1(x) dbgOut(x)
|
||||
#define dbgOut2(x,y) dbgOut(x, y)
|
||||
#define dbgOut3(x,y,z) dbgOut(x, y, z)
|
||||
#define dbgOut4(x,y,z,t) dbgOut(x, y, z, t)
|
||||
#define dbgOut5(x,y,z,t,u) dbgOut(x, y, z, t, u)
|
||||
#define dbgOut6(x,y,z,t,u,v) dbgOut(x, y, z, t, u, v)
|
||||
#define dbgOut7(x,y,z,t,u,v, a) dbgOut(x, y, z, t, u, v, a)
|
||||
#define dbgOut8(x,y,z,t,u,v, a, b) dbgOut(x, y, z, t, u, v, a, b)
|
||||
|
||||
#else
|
||||
|
||||
#define dbgOut1(x) ((void)0)
|
||||
#define dbgOut2(x,y) ((void)0)
|
||||
#define dbgOut3(x,y,z) ((void)0)
|
||||
#define dbgOut4(x,y,z,t) ((void)0)
|
||||
#define dbgOut5(x,y,z,t,u) ((void)0)
|
||||
#define dbgOut6(x,y,z,t,u,v) ((void)0)
|
||||
#define dbgOut7(x,y,z,t,u,v,a) ((void)0)
|
||||
#define dbgOut8(x,y,z,t,u,v,a,b) ((void)0)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,165 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "plugin.h"
|
||||
#include "utils.h"
|
||||
|
||||
static char szDefaultPluginFinderURL[] = DEFAULT_PLUGINFINDER_URL;
|
||||
|
||||
static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case IDC_GET_PLUGIN:
|
||||
EndDialog(hWnd, IDC_GET_PLUGIN);
|
||||
break;
|
||||
case IDCANCEL:
|
||||
case IDC_BUTTON_CANCEL:
|
||||
EndDialog(hWnd, IDCANCEL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL onInitDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam)
|
||||
{
|
||||
CPlugin * pPlugin = (CPlugin *)lParam;
|
||||
assert(pPlugin != NULL);
|
||||
if(pPlugin == NULL)
|
||||
return TRUE;
|
||||
|
||||
char szString[512];
|
||||
LoadString(hInst, IDS_TITLE, szString, sizeof(szString));
|
||||
SetWindowText(hWnd, szString);
|
||||
|
||||
LoadString(hInst, IDS_INFO, szString, sizeof(szString));
|
||||
SetDlgItemText(hWnd, IDC_STATIC_INFO, szString);
|
||||
|
||||
SetDlgItemText(hWnd, IDC_STATIC_INFOTYPE, (LPSTR)pPlugin->m_pNPMIMEType);
|
||||
|
||||
LoadString(hInst, IDS_LOCATION, szString, sizeof(szString));
|
||||
SetDlgItemText(hWnd, IDC_STATIC_LOCATION, szString);
|
||||
|
||||
char contentTypeIsJava = 0;
|
||||
|
||||
if (NULL != pPlugin->m_pNPMIMEType) {
|
||||
contentTypeIsJava = (0 == strcmp("application/x-java-vm",
|
||||
pPlugin->m_pNPMIMEType)) ? 1 : 0;
|
||||
}
|
||||
|
||||
if(pPlugin->m_szPageURL == NULL || contentTypeIsJava)
|
||||
LoadString(hInst, IDS_FINDER_PAGE, szString, sizeof(szString));
|
||||
else
|
||||
strncpy(szString, pPlugin->m_szPageURL,511); // defect #362738
|
||||
|
||||
SetDlgItemTextWrapped(hWnd, IDC_STATIC_URL, szString);
|
||||
|
||||
LoadString(hInst, IDS_QUESTION, szString, sizeof(szString));
|
||||
SetDlgItemText(hWnd, IDC_STATIC_QUESTION, szString);
|
||||
|
||||
SetDlgItemText(hWnd, IDC_STATIC_WARNING, "");
|
||||
|
||||
if(!pPlugin->m_bOnline)
|
||||
{
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_GET_PLUGIN), FALSE);
|
||||
LoadString(hInst, IDS_WARNING_OFFLINE, szString, sizeof(szString));
|
||||
SetDlgItemText(hWnd, IDC_STATIC_WARNING, szString);
|
||||
SetDlgItemText(hWnd, IDC_STATIC_QUESTION, "");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if((!pPlugin->m_bJava) || (!pPlugin->m_bJavaScript) || (!pPlugin->m_bSmartUpdate))
|
||||
{
|
||||
LoadString(hInst, IDS_WARNING_JS, szString, sizeof(szString));
|
||||
SetDlgItemText(hWnd, IDC_STATIC_WARNING, szString);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_WARNING), SW_HIDE);
|
||||
|
||||
RECT rc;
|
||||
GetWindowRect(GetDlgItem(hWnd, IDC_STATIC_WARNING), &rc);
|
||||
int iHeight = rc.bottom - rc.top;
|
||||
GetWindowRect(hWnd, &rc);
|
||||
SetWindowPos(hWnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top - iHeight, SWP_NOZORDER | SWP_NOMOVE);
|
||||
|
||||
HWND hWndQuestion = GetDlgItem(hWnd, IDC_STATIC_QUESTION);
|
||||
HWND hWndButtonGetPlugin = GetDlgItem(hWnd, IDC_GET_PLUGIN);
|
||||
HWND hWndButtonCancel = GetDlgItem(hWnd, IDC_BUTTON_CANCEL);
|
||||
|
||||
POINT pt;
|
||||
|
||||
GetWindowRect(hWndQuestion, &rc);
|
||||
pt.x = rc.left;
|
||||
pt.y = rc.top;
|
||||
ScreenToClient(hWnd, &pt);
|
||||
SetWindowPos(hWndQuestion, NULL, pt.x, pt.y - iHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
|
||||
|
||||
GetWindowRect(hWndButtonGetPlugin, &rc);
|
||||
pt.x = rc.left;
|
||||
pt.y = rc.top;
|
||||
ScreenToClient(hWnd, &pt);
|
||||
SetWindowPos(hWndButtonGetPlugin, NULL, pt.x, pt.y - iHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
|
||||
|
||||
GetWindowRect(hWndButtonCancel, &rc);
|
||||
pt.x = rc.left;
|
||||
pt.y = rc.top;
|
||||
ScreenToClient(hWnd, &pt);
|
||||
SetWindowPos(hWndButtonCancel, NULL, pt.x, pt.y - iHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
|
||||
|
||||
if(pPlugin->m_bHidden)
|
||||
SetForegroundWindow(hWnd);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void onDestroy(HWND hWnd)
|
||||
{
|
||||
}
|
||||
|
||||
BOOL CALLBACK NP_LOADDS GetPluginDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
return (BOOL)HANDLE_WM_INITDIALOG(hWnd, wParam, lParam, onInitDialog);
|
||||
case WM_COMMAND:
|
||||
HANDLE_WM_COMMAND(hWnd, wParam, lParam, onCommand);
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
HANDLE_WM_DESTROY(hWnd, wParam, lParam, onDestroy);
|
||||
break;
|
||||
case WM_CLOSE:
|
||||
EndDialog(hWnd, IDCANCEL);
|
||||
break;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef __DIALOGS_H__
|
||||
#define __DIALOGS_H__
|
||||
|
||||
BOOL CALLBACK NP_LOADDS GetPluginDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#endif __DIALOGS_H__
|
|
@ -0,0 +1,31 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
HINSTANCE hInst; // global
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
hInst = hDLL;
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
#!nmake
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
DLLNAME = npnul32
|
||||
RESFILE = npnul32.res
|
||||
DEFFILE = npnul32.def
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
MODULE=npnul32
|
||||
|
||||
DEFINES =-D_IMPL_NS_PLUGIN -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\maindll.obj \
|
||||
.\$(OBJDIR)\plugin.obj \
|
||||
.\$(OBJDIR)\dbg.obj \
|
||||
.\$(OBJDIR)\dialogs.obj \
|
||||
.\$(OBJDIR)\npshell.obj \
|
||||
.\$(OBJDIR)\npwin.obj \
|
||||
.\$(OBJDIR)\utils.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
-D_IMPL_NS_PLUGIN \
|
||||
-GX \
|
||||
$(NULL)
|
||||
|
||||
WIN_LIBS = \
|
||||
version.lib
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
it:
|
||||
echo $(LLIBS)
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\plugins
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\$(DLLNAME).dll
|
|
@ -0,0 +1,6 @@
|
|||
LIBRARY NPNUL32
|
||||
|
||||
EXPORTS
|
||||
NP_GetEntryPoints @1
|
||||
NP_Initialize @2
|
||||
NP_Shutdown @3
|
|
@ -0,0 +1,29 @@
|
|||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Npnul32"=.\Npnul32.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_PLUGIN_DOWNLOAD DIALOG DISCARDABLE 0, 0, 225, 148
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Title"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LTEXT "Information on this page requires a plug-in for:",
|
||||
IDC_STATIC_INFO,7,7,211,10
|
||||
LTEXT "Communicator can retrieve the plug-in for you from:",
|
||||
IDC_STATIC_LOCATION,7,32,211,8
|
||||
CTEXT "What would you like to do?",IDC_STATIC_QUESTION,7,113,
|
||||
211,9
|
||||
DEFPUSHBUTTON "Get the Plug-in",IDC_GET_PLUGIN,41,127,64,14
|
||||
PUSHBUTTON "Cancel",IDC_BUTTON_CANCEL,109,127,64,14
|
||||
CTEXT "type/x-type",IDC_STATIC_INFOTYPE,7,18,211,8
|
||||
LTEXT "The SmartUpdate feature makes it easy to install new plug-ins. To take advantage of SmartUpdate, you must enable Java, JavaScript and AutoInstall in the Advanced panel of the Preferences, then click the plug-in icon on the page.",
|
||||
IDC_STATIC_WARNING,7,74,211,35
|
||||
LTEXT "Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static ",
|
||||
IDC_STATIC_URL,7,43,211,24
|
||||
END
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,15
|
||||
PRODUCTVERSION 1,0,0,15
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "Comments", "\0"
|
||||
VALUE "CompanyName", "Netscape Communications, Inc.\0"
|
||||
VALUE "FileDescription", "Default Plug-in\0"
|
||||
VALUE "FileExtents", "*\0"
|
||||
VALUE "FileOpenName", "Netscape Default Plug-in (*.*)\0"
|
||||
VALUE "FileVersion", "1, 0, 0, 15\0"
|
||||
VALUE "InternalName", "DEFPLUGIN\0"
|
||||
VALUE "LegalCopyright", "Copyright © 1995-1997\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "MIMEType", "*\0"
|
||||
VALUE "OriginalFilename", "NPNUL32.DLL\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "Netscape Default Plug-in\0"
|
||||
VALUE "ProductVersion", "1, 0, 0, 15\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_PLUGICON ICON DISCARDABLE "plugicon.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_PLUGIN_DOWNLOAD, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 218
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 141
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_INFO "Information on this page requires a plug-in for:"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_LOCATION "Navigator can retrieve the plug-in for you from:"
|
||||
IDS_TITLE "Plug-in Not Loaded"
|
||||
IDS_QUESTION "What would you like to do?"
|
||||
IDS_WARNING_JS "The SmartUpdate feature makes it easy to install new plug-ins. To take advantage of SmartUpdate, you must enable Java, JavaScript and AutoInstall in the Advanced panel of the Preferences, then click the plug-in icon on the page."
|
||||
IDS_WARNING_OFFLINE "However, you are currently offline. If you would like to get the plug-in, click Cancel, select ""Go Online"" from the File menu, then click the plug-in icon on the page."
|
||||
IDS_FINDER_PAGE "Netscape's Plug-in Finder page"
|
||||
IDS_CLICK_TO_GET "Click here to get the plugin"
|
||||
IDS_CLICK_WHEN_DONE "Click here after installing the plugin"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
|
@ -0,0 +1,305 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "Plugin.h" // this includes npapi.h
|
||||
#include "utils.h"
|
||||
#include "dbg.h"
|
||||
|
||||
char szAppName[] = "NPNULL";
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_Initialize:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NPP_Initialize(void)
|
||||
{
|
||||
RegisterNullPluginWindowClass();
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_Shutdown:
|
||||
//---------------------------------------------------------------------------
|
||||
void NPP_Shutdown(void)
|
||||
{
|
||||
UnregisterNullPluginWindowClass();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_New:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NP_LOADDS NPP_New(NPMIMEType pluginType,
|
||||
NPP pInstance,
|
||||
uint16 mode,
|
||||
int16 argc,
|
||||
char* argn[],
|
||||
char* argv[],
|
||||
NPSavedData* saved)
|
||||
{
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
// See if the content provider specified from where to fetch the plugin
|
||||
char * szPageURL = NULL;
|
||||
char * szFileURL = NULL;
|
||||
char * szFileExtension = NULL;
|
||||
char * buf = NULL;
|
||||
BOOL bHidden = FALSE;
|
||||
|
||||
for(int i = 0; i < argc; i++)
|
||||
{
|
||||
if(lstrcmpi(argn[i],"pluginspage") == 0 && argv[i] != NULL)
|
||||
szPageURL = (char *)argv[i];
|
||||
else if(lstrcmpi(argn[i],"codebase") == 0 && argv[i] != NULL)
|
||||
szPageURL = (char *)argv[i];
|
||||
else if(lstrcmpi(argn[i],"pluginurl") == 0 && argv[i] != NULL)
|
||||
szFileURL = (char *)argv[i];
|
||||
else if(lstrcmpi(argn[i],"classid") == 0 && argv[i] != NULL)
|
||||
szFileURL = (char *)argv[i];
|
||||
else if(lstrcmpi(argn[i],"SRC") == 0 && argv[i] != NULL)
|
||||
buf = (char *)argv[i];
|
||||
else if(lstrcmpi(argn[i],"HIDDEN") == 0 && argv[i] != NULL)
|
||||
bHidden = (lstrcmp((char *)argv[i], "TRUE") == 0);
|
||||
}
|
||||
|
||||
/* some post-processing on the filename to attempt to extract the extension: */
|
||||
if(buf != NULL)
|
||||
{
|
||||
buf = strrchr(buf, '.');
|
||||
szFileExtension = ++buf;
|
||||
}
|
||||
|
||||
CPlugin * pPlugin = new CPlugin(hInst,
|
||||
pInstance,
|
||||
mode,
|
||||
pluginType,
|
||||
szPageURL,
|
||||
szFileURL,
|
||||
szFileExtension,
|
||||
bHidden);
|
||||
if(pPlugin == NULL)
|
||||
return NPERR_OUT_OF_MEMORY_ERROR;
|
||||
|
||||
if(bHidden)
|
||||
{
|
||||
if(!pPlugin->init(NULL))
|
||||
{
|
||||
delete pPlugin;
|
||||
pPlugin = NULL;
|
||||
return NPERR_MODULE_LOAD_FAILED_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
pInstance->pdata = (void *)pPlugin;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_Destroy:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NP_LOADDS
|
||||
NPP_Destroy(NPP pInstance, NPSavedData** save)
|
||||
{
|
||||
dbgOut1("NPP_Destroy");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
if(pPlugin != NULL)
|
||||
{
|
||||
pPlugin->shut();
|
||||
delete pPlugin;
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_SetWindow:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NP_LOADDS NPP_SetWindow(NPP pInstance, NPWindow * pNPWindow)
|
||||
{
|
||||
if(pInstance == NULL)
|
||||
{
|
||||
dbgOut1("NPP_SetWindow returns NPERR_INVALID_INSTANCE_ERROR");
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
}
|
||||
|
||||
if(pNPWindow == NULL)
|
||||
{
|
||||
dbgOut1("NPP_SetWindow returns NPERR_GENERIC_ERROR");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
HWND hWnd = (HWND)(DWORD)pNPWindow->window;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
if(pPlugin == NULL)
|
||||
{
|
||||
dbgOut1("NPP_SetWindow returns NPERR_GENERIC_ERROR");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
if((hWnd == NULL) && (pPlugin->getWindow() == NULL)) // spurious entry
|
||||
{
|
||||
dbgOut1("NPP_SetWindow just returns with NPERR_NO_ERROR");
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
if((hWnd == NULL) && (pPlugin->getWindow() != NULL))
|
||||
{ // window went away
|
||||
dbgOut1("NPP_SetWindow, going away...");
|
||||
pPlugin->shut();
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
if((pPlugin->getWindow() == NULL) && (hWnd != NULL))
|
||||
{ // First time in -- no window created by plugin yet
|
||||
dbgOut1("NPP_SetWindow, first time");
|
||||
|
||||
if(!pPlugin->init(hWnd))
|
||||
{
|
||||
delete pPlugin;
|
||||
pPlugin = NULL;
|
||||
return NPERR_MODULE_LOAD_FAILED_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if((pPlugin->getWindow() != NULL) && (hWnd != NULL))
|
||||
{ // Netscape window has been resized
|
||||
dbgOut1("NPP_SetWindow, resizing");
|
||||
pPlugin->resize();
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_NewStream:
|
||||
//------------------------------------------------------------------------------------
|
||||
NPError NP_LOADDS
|
||||
NPP_NewStream(NPP pInstance,
|
||||
NPMIMEType type,
|
||||
NPStream *stream,
|
||||
NPBool seekable,
|
||||
uint16 *stype)
|
||||
{
|
||||
dbgOut1("NPP_NewStream");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_WriteReady:
|
||||
//------------------------------------------------------------------------------------
|
||||
int32 NP_LOADDS
|
||||
NPP_WriteReady(NPP pInstance, NPStream *stream)
|
||||
{
|
||||
dbgOut1("NPP_WriteReady");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
return -1L; // dont accept any bytes in NPP_Write()
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_Write:
|
||||
//------------------------------------------------------------------------------------
|
||||
int32 NP_LOADDS
|
||||
NPP_Write(NPP pInstance, NPStream *stream, int32 offset, int32 len, void *buffer)
|
||||
{
|
||||
//dbgOut1("NPP_Write");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
return -1; // tell Nav to abort the stream, don't need it
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_DestroyStream:
|
||||
//------------------------------------------------------------------------------------
|
||||
NPError NP_LOADDS
|
||||
NPP_DestroyStream(NPP pInstance, NPStream *stream, NPError reason)
|
||||
{
|
||||
dbgOut1("NPP_DestroyStream");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_StreamAsFile:
|
||||
//------------------------------------------------------------------------------------
|
||||
void NP_LOADDS
|
||||
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
|
||||
{
|
||||
dbgOut1("NPP_StreamAsFile");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_Print:
|
||||
//------------------------------------------------------------------------------------
|
||||
void NP_LOADDS NPP_Print(NPP pInstance, NPPrint * printInfo)
|
||||
{
|
||||
dbgOut2("NPP_Print, printInfo = %#08x", printInfo);
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
pPlugin->print(printInfo);
|
||||
}
|
||||
|
||||
void NP_LOADDS NPP_URLNotify(NPP pInstance, const char* url, NPReason reason, void* notifyData)
|
||||
{
|
||||
dbgOut2("NPP_URLNotify, URL '%s'", url);
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
pPlugin->URLNotify(url);
|
||||
}
|
||||
|
||||
jref NP_LOADDS NPP_GetJavaClass(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
|
@ -0,0 +1,333 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef _NPAPI_H_
|
||||
#include "npapi.h"
|
||||
#endif
|
||||
#ifndef _NPUPP_H_
|
||||
#include "npupp.h"
|
||||
#endif
|
||||
|
||||
//\\// DEFINE
|
||||
#define NP_EXPORT
|
||||
|
||||
//\\// GLOBAL DATA
|
||||
NPNetscapeFuncs* g_pNavigatorFuncs = 0;
|
||||
JRIGlobalRef Private_GetJavaClass(void);
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// Private_GetJavaClass (global function)
|
||||
//
|
||||
// Given a Java class reference (thru NPP_GetJavaClass) inform JRT
|
||||
// of this class existence
|
||||
//
|
||||
JRIGlobalRef
|
||||
Private_GetJavaClass(void)
|
||||
{
|
||||
jref clazz = NPP_GetJavaClass();
|
||||
if (clazz) {
|
||||
JRIEnv* env = NPN_GetJavaEnv();
|
||||
return JRI_NewGlobalRef(env, clazz);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// PLUGIN DLL entry points
|
||||
//
|
||||
// These are the Windows specific DLL entry points. They must be exoprted
|
||||
//
|
||||
|
||||
// we need these to be global since we have to fill one of its field
|
||||
// with a data (class) which requires knowlwdge of the navigator
|
||||
// jump-table. This jump table is known at Initialize time (NP_Initialize)
|
||||
// which is called after NP_GetEntryPoint
|
||||
static NPPluginFuncs* g_pluginFuncs;
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// NP_GetEntryPoints
|
||||
//
|
||||
// fills in the func table used by Navigator to call entry points in
|
||||
// plugin DLL. Note that these entry points ensure that DS is loaded
|
||||
// by using the NP_LOADDS macro, when compiling for Win16
|
||||
//
|
||||
NPError WINAPI NP_EXPORT
|
||||
NP_GetEntryPoints(NPPluginFuncs* pFuncs)
|
||||
{
|
||||
// trap a NULL ptr
|
||||
if(pFuncs == NULL)
|
||||
return NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
// if the plugin's function table is smaller than the plugin expects,
|
||||
// then they are incompatible, and should return an error
|
||||
|
||||
pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
|
||||
pFuncs->newp = NPP_New;
|
||||
pFuncs->destroy = NPP_Destroy;
|
||||
pFuncs->setwindow = NPP_SetWindow;
|
||||
pFuncs->newstream = NPP_NewStream;
|
||||
pFuncs->destroystream = NPP_DestroyStream;
|
||||
pFuncs->asfile = NPP_StreamAsFile;
|
||||
pFuncs->writeready = NPP_WriteReady;
|
||||
pFuncs->write = NPP_Write;
|
||||
pFuncs->print = NPP_Print;
|
||||
pFuncs->event = 0; /// reserved
|
||||
|
||||
g_pluginFuncs = pFuncs;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// NP_Initialize
|
||||
//
|
||||
// called immediately after the plugin DLL is loaded
|
||||
//
|
||||
NPError WINAPI NP_EXPORT
|
||||
NP_Initialize(NPNetscapeFuncs* pFuncs)
|
||||
{
|
||||
// trap a NULL ptr
|
||||
if(pFuncs == NULL)
|
||||
return NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
g_pNavigatorFuncs = pFuncs; // save it for future reference
|
||||
|
||||
// if the plugin's major ver level is lower than the Navigator's,
|
||||
// then they are incompatible, and should return an error
|
||||
if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
|
||||
return NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
|
||||
// We have to defer these assignments until g_pNavigatorFuncs is set
|
||||
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
|
||||
g_pluginFuncs->urlnotify = NPP_URLNotify;
|
||||
}
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_LIVECONNECT ) {
|
||||
g_pluginFuncs->javaClass = Private_GetJavaClass();
|
||||
}
|
||||
|
||||
// NPP_Initialize is a standard (cross-platform) initialize function.
|
||||
return NPP_Initialize();
|
||||
}
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// NP_Shutdown
|
||||
//
|
||||
// called immediately before the plugin DLL is unloaded.
|
||||
// This functio shuold check for some ref count on the dll to see if it is
|
||||
// unloadable or it needs to stay in memory.
|
||||
//
|
||||
NPError WINAPI NP_EXPORT
|
||||
NP_Shutdown()
|
||||
{
|
||||
NPP_Shutdown();
|
||||
g_pNavigatorFuncs = NULL;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// END - PLUGIN DLL entry points
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
|
||||
/* NAVIGATOR Entry points */
|
||||
|
||||
/* These entry points expect to be called from within the plugin. The
|
||||
noteworthy assumption is that DS has already been set to point to the
|
||||
plugin's DLL data segment. Don't call these functions from outside
|
||||
the plugin without ensuring DS is set to the DLLs data segment first,
|
||||
typically using the NP_LOADDS macro
|
||||
*/
|
||||
|
||||
/* returns the major/minor version numbers of the Plugin API for the plugin
|
||||
and the Navigator
|
||||
*/
|
||||
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
|
||||
{
|
||||
*plugin_major = NP_VERSION_MAJOR;
|
||||
*plugin_minor = NP_VERSION_MINOR;
|
||||
*netscape_major = HIBYTE(g_pNavigatorFuncs->version);
|
||||
*netscape_minor = LOBYTE(g_pNavigatorFuncs->version);
|
||||
}
|
||||
|
||||
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *result)
|
||||
{
|
||||
return g_pNavigatorFuncs->getvalue(instance, variable, result);
|
||||
}
|
||||
|
||||
|
||||
/* causes the specified URL to be fetched and streamed in
|
||||
*/
|
||||
NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
|
||||
|
||||
{
|
||||
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
|
||||
err = g_pNavigatorFuncs->geturlnotify(instance, url, target, notifyData);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
|
||||
{
|
||||
return g_pNavigatorFuncs->geturl(instance, url, target);
|
||||
}
|
||||
|
||||
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
|
||||
{
|
||||
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
|
||||
err = g_pNavigatorFuncs->posturlnotify(instance, url, window, len, buf, file, notifyData);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
|
||||
{
|
||||
return g_pNavigatorFuncs->posturl(instance, url, window, len, buf, file);
|
||||
}
|
||||
|
||||
/* Requests that a number of bytes be provided on a stream. Typically
|
||||
this would be used if a stream was in "pull" mode. An optional
|
||||
position can be provided for streams which are seekable.
|
||||
*/
|
||||
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
|
||||
{
|
||||
return g_pNavigatorFuncs->requestread(stream, rangeList);
|
||||
}
|
||||
|
||||
/* Creates a new stream of data from the plug-in to be interpreted
|
||||
by Netscape in the current window.
|
||||
*/
|
||||
NPError NPN_NewStream(NPP instance, NPMIMEType type,
|
||||
const char* target, NPStream** stream)
|
||||
{
|
||||
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
|
||||
err = g_pNavigatorFuncs->newstream(instance, type, target, stream);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Provides len bytes of data.
|
||||
*/
|
||||
int32 NPN_Write(NPP instance, NPStream *stream,
|
||||
int32 len, void *buffer)
|
||||
{
|
||||
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
|
||||
int32 result;
|
||||
|
||||
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
|
||||
result = g_pNavigatorFuncs->write(instance, stream, len, buffer);
|
||||
}
|
||||
else {
|
||||
result = -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Closes a stream object.
|
||||
reason indicates why the stream was closed.
|
||||
*/
|
||||
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
|
||||
err = g_pNavigatorFuncs->destroystream(instance, stream, reason);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Provides a text status message in the Netscape client user interface
|
||||
*/
|
||||
void NPN_Status(NPP instance, const char *message)
|
||||
{
|
||||
g_pNavigatorFuncs->status(instance, message);
|
||||
}
|
||||
|
||||
/* returns the user agent string of Navigator, which contains version info
|
||||
*/
|
||||
const char* NPN_UserAgent(NPP instance)
|
||||
{
|
||||
return g_pNavigatorFuncs->uagent(instance);
|
||||
}
|
||||
|
||||
/* allocates memory from the Navigator's memory space. Necessary so that
|
||||
saved instance data may be freed by Navigator when exiting.
|
||||
*/
|
||||
|
||||
|
||||
void* NPN_MemAlloc(uint32 size)
|
||||
{
|
||||
return g_pNavigatorFuncs->memalloc(size);
|
||||
}
|
||||
|
||||
/* reciprocal of MemAlloc() above
|
||||
*/
|
||||
void NPN_MemFree(void* ptr)
|
||||
{
|
||||
g_pNavigatorFuncs->memfree(ptr);
|
||||
}
|
||||
|
||||
/* private function to Netscape. do not use!
|
||||
*/
|
||||
void NPN_ReloadPlugins(NPBool reloadPages)
|
||||
{
|
||||
g_pNavigatorFuncs->reloadplugins(reloadPages);
|
||||
}
|
||||
|
||||
JRIEnv* NPN_GetJavaEnv(void)
|
||||
{
|
||||
return g_pNavigatorFuncs->getJavaEnv();
|
||||
}
|
||||
|
||||
jref NPN_GetJavaPeer(NPP instance)
|
||||
{
|
||||
return g_pNavigatorFuncs->getJavaPeer(instance);
|
||||
}
|
||||
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 766 B |
|
@ -0,0 +1,648 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "plugin.h"
|
||||
#include "utils.h"
|
||||
#include "dialogs.h"
|
||||
#include "dbg.h"
|
||||
|
||||
static char szNullPluginWindowClassName[] = CLASS_NULL_PLUGIN;
|
||||
|
||||
static LRESULT CALLBACK NP_LOADDS PluginWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
static char szDefaultPluginFinderURL[] = DEFAULT_PLUGINFINDER_URL;
|
||||
static char szPageUrlForJavaScript[] = PAGE_URL_FOR_JAVASCRIPT;
|
||||
static char szPageUrlForJVM[] = JVM_SMARTUPDATE_URL;
|
||||
//static char szPluginFinderCommandFormatString[] = PLUGINFINDER_COMMAND;
|
||||
static char szPluginFinderCommandBeginning[] = PLUGINFINDER_COMMAND_BEGINNING;
|
||||
static char szPluginFinderCommandEnd[] = PLUGINFINDER_COMMAND_END;
|
||||
static char szDefaultFileExt[] = "*";
|
||||
|
||||
BOOL RegisterNullPluginWindowClass()
|
||||
{
|
||||
assert(hInst != NULL);
|
||||
|
||||
WNDCLASS wc;
|
||||
|
||||
memset(&wc, 0, sizeof(wc));
|
||||
|
||||
wc.lpfnWndProc = (WNDPROC)PluginWndProc;
|
||||
wc.cbWndExtra = sizeof(DWORD);
|
||||
wc.hInstance = hInst;
|
||||
wc.hIcon = LoadIcon(hInst, IDI_APPLICATION);
|
||||
wc.hCursor = NULL;
|
||||
wc.hbrBackground = HBRUSH(COLOR_WINDOW + 1);
|
||||
wc.lpszClassName = szNullPluginWindowClassName;
|
||||
|
||||
ATOM aRet = RegisterClass(&wc);
|
||||
return (aRet != NULL);
|
||||
}
|
||||
|
||||
void UnregisterNullPluginWindowClass()
|
||||
{
|
||||
assert(hInst != NULL);
|
||||
UnregisterClass(szNullPluginWindowClassName, hInst);
|
||||
}
|
||||
|
||||
/*********************************************/
|
||||
/* */
|
||||
/* CPlugin class implementation */
|
||||
/* */
|
||||
/*********************************************/
|
||||
|
||||
CPlugin::CPlugin(HINSTANCE hInst,
|
||||
NPP pNPInstance,
|
||||
WORD wMode,
|
||||
NPMIMEType pluginType,
|
||||
LPSTR szPageURL,
|
||||
LPSTR szFileURL,
|
||||
LPSTR szFileExtension,
|
||||
BOOL bHidden) :
|
||||
m_pNPInstance(pNPInstance),
|
||||
m_wMode(wMode),
|
||||
m_hInst(hInst),
|
||||
m_hWnd(NULL),
|
||||
m_hWndParent(NULL),
|
||||
m_hIcon(NULL),
|
||||
m_pNPMIMEType(NULL),
|
||||
m_szPageURL(NULL),
|
||||
m_szFileURL(NULL),
|
||||
m_szFileExtension(NULL),
|
||||
m_bOnline(TRUE),
|
||||
m_bJava(TRUE),
|
||||
m_bJavaScript(TRUE),
|
||||
m_bSmartUpdate(TRUE),
|
||||
m_szURLString(NULL),
|
||||
m_szCommandMessage(NULL),
|
||||
m_bHidden(bHidden)
|
||||
{
|
||||
dbgOut1("CPlugin::CPlugin()");
|
||||
assert(m_hInst != NULL);
|
||||
assert(m_pNPInstance != NULL);
|
||||
|
||||
if((pluginType != NULL) && (lstrlen((LPSTR)pluginType) != 0))
|
||||
{
|
||||
m_pNPMIMEType = (NPMIMEType)new char[lstrlen((LPSTR)pluginType) + 1];
|
||||
if(m_pNPMIMEType != NULL)
|
||||
lstrcpy((LPSTR)m_pNPMIMEType, pluginType);
|
||||
}
|
||||
|
||||
if((szPageURL != NULL) && (lstrlen(szPageURL) != 0))
|
||||
{
|
||||
m_szPageURL = new char[lstrlen(szPageURL) + 1];
|
||||
if(m_szPageURL != NULL)
|
||||
lstrcpy(m_szPageURL, szPageURL);
|
||||
}
|
||||
|
||||
if((szFileURL != NULL) && (lstrlen(szFileURL) != 0))
|
||||
{
|
||||
m_szFileURL = new char[lstrlen(szFileURL) + 1];
|
||||
if(m_szFileURL != NULL)
|
||||
lstrcpy(m_szFileURL, szFileURL);
|
||||
}
|
||||
|
||||
if((szFileExtension != NULL) && (lstrlen(szFileExtension) != 0))
|
||||
{
|
||||
m_szFileExtension = new char[lstrlen(szFileExtension) + 1];
|
||||
if(m_szFileExtension != NULL)
|
||||
lstrcpy(m_szFileExtension, szFileExtension);
|
||||
}
|
||||
|
||||
m_hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_PLUGICON));
|
||||
|
||||
char szString[1024] = {'\0'};
|
||||
LoadString(m_hInst, IDS_CLICK_TO_GET, szString, sizeof(szString));
|
||||
if(lstrlen(szString) != 0)
|
||||
{
|
||||
m_szCommandMessage = new char[lstrlen(szString) + 1];
|
||||
if(m_szCommandMessage != NULL)
|
||||
lstrcpy(m_szCommandMessage, szString);
|
||||
}
|
||||
}
|
||||
|
||||
CPlugin::~CPlugin()
|
||||
{
|
||||
dbgOut1("CPlugin::~CPlugin()");
|
||||
|
||||
if(m_pNPMIMEType != NULL)
|
||||
{
|
||||
delete [] m_pNPMIMEType;
|
||||
m_pNPMIMEType = NULL;
|
||||
}
|
||||
|
||||
if(m_szPageURL != NULL)
|
||||
{
|
||||
delete [] m_szPageURL;
|
||||
m_szPageURL = NULL;
|
||||
}
|
||||
|
||||
if(m_szFileURL != NULL)
|
||||
{
|
||||
delete [] m_szFileURL;
|
||||
m_szFileURL = NULL;
|
||||
}
|
||||
|
||||
if(m_szFileExtension != NULL)
|
||||
{
|
||||
delete [] m_szFileExtension;
|
||||
m_szFileExtension = NULL;
|
||||
}
|
||||
|
||||
if(m_szURLString != NULL)
|
||||
{
|
||||
delete [] m_szURLString;
|
||||
m_szURLString = NULL;
|
||||
}
|
||||
|
||||
if(m_hIcon != NULL)
|
||||
{
|
||||
DestroyIcon(m_hIcon);
|
||||
m_hIcon = NULL;
|
||||
}
|
||||
|
||||
if(m_szCommandMessage != NULL)
|
||||
{
|
||||
delete [] m_szCommandMessage;
|
||||
m_szCommandMessage = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CPlugin::init(HWND hWndParent)
|
||||
{
|
||||
dbgOut1("CPlugin::init()");
|
||||
|
||||
if(!m_bHidden)
|
||||
{
|
||||
assert(IsWindow(hWndParent));
|
||||
|
||||
if(IsWindow(hWndParent))
|
||||
m_hWndParent = hWndParent;
|
||||
|
||||
RECT rcParent;
|
||||
GetClientRect(m_hWndParent, &rcParent);
|
||||
|
||||
CreateWindow(szNullPluginWindowClassName,
|
||||
"NULL Plugin",
|
||||
WS_CHILD,
|
||||
0,0, rcParent.right, rcParent.bottom,
|
||||
m_hWndParent,
|
||||
(HMENU)NULL,
|
||||
m_hInst,
|
||||
(LPVOID)this);
|
||||
|
||||
assert(m_hWnd != NULL);
|
||||
if((m_hWnd == NULL) || (!IsWindow(m_hWnd)))
|
||||
return FALSE;
|
||||
|
||||
UpdateWindow(m_hWnd);
|
||||
ShowWindow(m_hWnd, SW_SHOW);
|
||||
}
|
||||
|
||||
if(IsNewMimeType((LPSTR)m_pNPMIMEType) || m_bHidden)
|
||||
showGetPluginDialog();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CPlugin::shut()
|
||||
{
|
||||
dbgOut1("CPlugin::shut()");
|
||||
|
||||
if(m_hWnd != NULL)
|
||||
{
|
||||
DestroyWindow(m_hWnd);
|
||||
m_hWnd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
HWND CPlugin::getWindow()
|
||||
{
|
||||
return m_hWnd;
|
||||
}
|
||||
|
||||
BOOL CPlugin::useDefaultURL_P()
|
||||
{
|
||||
if((m_szPageURL == NULL) && (m_szFileURL == NULL))
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CPlugin::doSmartUpdate_P()
|
||||
{
|
||||
// due to current JavaScript problems never do it smart for now 5.1.98
|
||||
return FALSE;
|
||||
|
||||
if(m_bOnline && m_bJava && m_bJavaScript && m_bSmartUpdate && useDefaultURL_P())
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LPSTR CPlugin::createURLString()
|
||||
{
|
||||
if(m_szURLString != NULL)
|
||||
{
|
||||
delete [] m_szURLString;
|
||||
m_szURLString = NULL;
|
||||
}
|
||||
|
||||
// check if there is file URL first
|
||||
if(m_szFileURL != NULL)
|
||||
{
|
||||
m_szURLString = new char[lstrlen(m_szFileURL) + 1];
|
||||
if(m_szURLString == NULL)
|
||||
return NULL;
|
||||
lstrcpy(m_szURLString, m_szFileURL);
|
||||
return m_szURLString;
|
||||
}
|
||||
|
||||
// if not get the page URL
|
||||
char * szAddress = NULL;
|
||||
char *urlToOpen = NULL;
|
||||
char contentTypeIsJava = 0;
|
||||
|
||||
if (NULL != m_pNPMIMEType) {
|
||||
contentTypeIsJava = (0 == strcmp("application/x-java-vm",
|
||||
m_pNPMIMEType)) ? 1 : 0;
|
||||
}
|
||||
|
||||
if(m_szPageURL != NULL && !contentTypeIsJava)
|
||||
{
|
||||
szAddress = new char[lstrlen(m_szPageURL) + 1];
|
||||
if(szAddress == NULL)
|
||||
return NULL;
|
||||
lstrcpy(szAddress, m_szPageURL);
|
||||
|
||||
m_szURLString = new char[lstrlen(szAddress) + 1 + lstrlen((LPSTR)m_pNPMIMEType) + 1];
|
||||
|
||||
if(m_szURLString == NULL)
|
||||
return NULL;
|
||||
|
||||
// Append the MIME type to the URL
|
||||
wsprintf(m_szURLString, "%s?%s", szAddress, (LPSTR)m_pNPMIMEType);
|
||||
}
|
||||
else // default
|
||||
{
|
||||
if(!m_bJavaScript)
|
||||
{
|
||||
urlToOpen = szDefaultPluginFinderURL;
|
||||
|
||||
if (contentTypeIsJava) {
|
||||
urlToOpen = szPageUrlForJVM;
|
||||
}
|
||||
|
||||
szAddress = new char[lstrlen(urlToOpen) + 1];
|
||||
if(szAddress == NULL)
|
||||
return NULL;
|
||||
lstrcpy(szAddress, urlToOpen);
|
||||
|
||||
m_szURLString = new char[lstrlen(szAddress) + 1 + lstrlen((LPSTR)m_pNPMIMEType) + 1];
|
||||
|
||||
if(m_szURLString == NULL)
|
||||
return NULL;
|
||||
|
||||
// Append the MIME type to the URL
|
||||
wsprintf(m_szURLString, "%s?%s", szAddress, (LPSTR)m_pNPMIMEType);
|
||||
}
|
||||
else
|
||||
{
|
||||
urlToOpen = szPageUrlForJavaScript;
|
||||
|
||||
if (contentTypeIsJava) {
|
||||
urlToOpen = szPageUrlForJVM;
|
||||
}
|
||||
|
||||
m_szURLString = new char[lstrlen(szPluginFinderCommandBeginning) + lstrlen(urlToOpen) + 10 +
|
||||
lstrlen((LPSTR)m_pNPMIMEType) + lstrlen(szPluginFinderCommandEnd) + 1];
|
||||
wsprintf(m_szURLString, "%s%s?mimetype=%s%s",
|
||||
szPluginFinderCommandBeginning, urlToOpen,
|
||||
(LPSTR)m_pNPMIMEType, szPluginFinderCommandEnd);
|
||||
}
|
||||
}
|
||||
|
||||
if(szAddress != NULL)
|
||||
delete [] szAddress;
|
||||
|
||||
return m_szURLString;
|
||||
}
|
||||
|
||||
void CPlugin::getPluginRegular()
|
||||
{
|
||||
assert(m_bOnline);
|
||||
|
||||
char * szURL = createURLString();
|
||||
|
||||
assert(szURL != NULL);
|
||||
if(szURL == NULL)
|
||||
return;
|
||||
|
||||
dbgOut3("CPlugin::getPluginRegular(), %#08x '%s'", m_pNPInstance, szURL);
|
||||
|
||||
if(m_szFileURL != NULL)
|
||||
NPN_GetURL(m_pNPInstance, szURL, "_current");
|
||||
else if(m_szPageURL != NULL)
|
||||
NPN_GetURL(m_pNPInstance, szURL, "_blank");
|
||||
else if(m_bJavaScript)
|
||||
NPN_GetURL(m_pNPInstance, szURL, NULL);
|
||||
else
|
||||
NPN_GetURL(m_pNPInstance, szURL, "_blank");
|
||||
}
|
||||
|
||||
void CPlugin::getPluginSmart()
|
||||
{
|
||||
/*
|
||||
static char szJSString[2048];
|
||||
|
||||
wsprintf(szJSString,
|
||||
szPluginFinderCommandFormatString,
|
||||
szDefaultPluginFinderURL,
|
||||
m_pNPMIMEType,
|
||||
(m_szFileExtension != NULL) ? m_szFileExtension : szDefaultFileExt);
|
||||
|
||||
dbgOut3("%#08x '%s'", m_pNPInstance, szJSString);
|
||||
|
||||
assert(lstrlen(szJSString) > 0);
|
||||
|
||||
NPN_GetURL(m_pNPInstance, szJSString, "smartupdate_plugin_finder");
|
||||
*/
|
||||
}
|
||||
|
||||
void CPlugin::showGetPluginDialog()
|
||||
{
|
||||
assert(m_pNPMIMEType != NULL);
|
||||
if(m_pNPMIMEType == NULL)
|
||||
return;
|
||||
|
||||
// Get environment
|
||||
BOOL bOffline = FALSE;
|
||||
|
||||
NPN_GetValue(m_pNPInstance, NPNVisOfflineBool, (void *)&bOffline);
|
||||
NPN_GetValue(m_pNPInstance, NPNVjavascriptEnabledBool, (void *)&m_bJavaScript);
|
||||
NPN_GetValue(m_pNPInstance, NPNVasdEnabledBool, (void *)&m_bSmartUpdate);
|
||||
|
||||
m_bOnline = !bOffline;
|
||||
|
||||
if(m_bOnline && m_bJavaScript && m_bSmartUpdate && useDefaultURL_P())
|
||||
{
|
||||
JRIEnv *penv = NPN_GetJavaEnv();
|
||||
m_bJava = (penv != NULL);
|
||||
}
|
||||
|
||||
dbgOut1("Environment:");
|
||||
dbgOut2("%s", m_bOnline ? "On-line" : "Off-line");
|
||||
dbgOut2("Java %s", m_bJava ? "Enabled" : "Disabled");
|
||||
dbgOut2("JavaScript %s", m_bJavaScript ? "Enabled" : "Disabled");
|
||||
dbgOut2("SmartUpdate %s", m_bSmartUpdate ? "Enabled" : "Disabled");
|
||||
|
||||
if((m_szPageURL != NULL) || (m_szFileURL != NULL) || !m_bJavaScript)
|
||||
{
|
||||
int iRet = DialogBoxParam(m_hInst, MAKEINTRESOURCE(IDD_PLUGIN_DOWNLOAD), m_hWnd,
|
||||
(DLGPROC)GetPluginDialogProc, (LPARAM)this);
|
||||
if(iRet != IDC_GET_PLUGIN)
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_szCommandMessage != NULL)
|
||||
{
|
||||
delete [] m_szCommandMessage;
|
||||
m_szCommandMessage = NULL;
|
||||
}
|
||||
|
||||
char szString[1024] = {'\0'};
|
||||
LoadString(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString));
|
||||
if(lstrlen(szString) != 0)
|
||||
{
|
||||
m_szCommandMessage = new char[lstrlen(szString) + 1];
|
||||
if(m_szCommandMessage != NULL)
|
||||
lstrcpy(m_szCommandMessage, szString);
|
||||
}
|
||||
|
||||
InvalidateRect(m_hWnd, NULL, TRUE);
|
||||
UpdateWindow(m_hWnd);
|
||||
|
||||
getPluginRegular();
|
||||
}
|
||||
|
||||
//*******************
|
||||
// NP API handles
|
||||
//*******************
|
||||
void CPlugin::resize()
|
||||
{
|
||||
dbgOut1("CPlugin::resize()");
|
||||
}
|
||||
|
||||
void CPlugin::print(NPPrint * pNPPrint)
|
||||
{
|
||||
dbgOut1("CPlugin::print()");
|
||||
|
||||
if(pNPPrint == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
void CPlugin::URLNotify(const char * szURL)
|
||||
{
|
||||
dbgOut2("CPlugin::URLNotify(), URL '%s'", szURL);
|
||||
|
||||
NPStream * pStream = NULL;
|
||||
char buf[256];
|
||||
|
||||
assert(m_hInst != NULL);
|
||||
assert(m_pNPInstance != NULL);
|
||||
|
||||
int iSize = LoadString(m_hInst, IDS_GOING2HTML, buf, sizeof(buf));
|
||||
|
||||
NPError rc = NPN_NewStream(m_pNPInstance, "text/html", "asd_plugin_finder", &pStream);
|
||||
|
||||
//char buf[] = "<html>\n<body>\n\n<h2 align=center>NPN_NewStream / NPN_Write - This seems to work.</h2>\n\n</body>\n</html>";
|
||||
|
||||
int32 iBytes = NPN_Write(m_pNPInstance, pStream, lstrlen(buf), buf);
|
||||
|
||||
NPN_DestroyStream(m_pNPInstance, pStream, NPRES_DONE);
|
||||
}
|
||||
|
||||
BOOL CPlugin::readyToRefresh()
|
||||
{
|
||||
char szString[1024] = {'\0'};
|
||||
LoadString(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString));
|
||||
if(m_szCommandMessage == NULL)
|
||||
return FALSE;
|
||||
|
||||
return (lstrcmp(m_szCommandMessage, szString) == 0);
|
||||
}
|
||||
|
||||
//***************************
|
||||
// Windows message handlers
|
||||
//***************************
|
||||
void CPlugin::onCreate(HWND hWnd)
|
||||
{
|
||||
m_hWnd = hWnd;
|
||||
}
|
||||
|
||||
void CPlugin::onLButtonUp(HWND hWnd, int x, int y, UINT keyFlags)
|
||||
{
|
||||
if(!readyToRefresh())
|
||||
showGetPluginDialog();
|
||||
else
|
||||
NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self");
|
||||
}
|
||||
|
||||
void CPlugin::onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags)
|
||||
{
|
||||
if(!readyToRefresh())
|
||||
showGetPluginDialog();
|
||||
else
|
||||
NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self");
|
||||
}
|
||||
|
||||
static void DrawCommandMessage(HDC hDC, LPSTR szString, LPRECT lprc)
|
||||
{
|
||||
if(szString == NULL)
|
||||
return;
|
||||
|
||||
HFONT hFont = GetStockFont(DEFAULT_GUI_FONT);
|
||||
if(hFont == NULL)
|
||||
return;
|
||||
|
||||
HFONT hFontOld = SelectFont(hDC, hFont);
|
||||
SIZE sz;
|
||||
GetTextExtentPoint32(hDC, szString, lstrlen(szString), &sz);
|
||||
POINT pt;
|
||||
pt.x = sz.cx;
|
||||
pt.y = sz.cy;
|
||||
LPtoDP(hDC, &pt, 1);
|
||||
|
||||
int iY = (lprc->bottom / 2) - ((32) / 2) + 36;
|
||||
int iX = 0;
|
||||
|
||||
if(lprc->right > pt.x)
|
||||
iX = lprc->right/2 - pt.x/2;
|
||||
else
|
||||
iX = 1;
|
||||
|
||||
RECT rcText;
|
||||
rcText.left = iX;
|
||||
rcText.right = rcText.left + pt.x;
|
||||
rcText.top = iY;
|
||||
rcText.bottom = rcText.top + pt.y;
|
||||
|
||||
int iModeOld = SetBkMode(hDC, TRANSPARENT);
|
||||
COLORREF crColorOld = SetTextColor(hDC, RGB(0,0,0));
|
||||
DrawText(hDC, szString, lstrlen(szString), &rcText, DT_CENTER|DT_VCENTER);
|
||||
SetTextColor(hDC, crColorOld);
|
||||
SetBkMode(hDC, iModeOld);
|
||||
SelectFont(hDC, hFontOld);
|
||||
}
|
||||
|
||||
void CPlugin::onPaint(HWND hWnd)
|
||||
{
|
||||
RECT rc;
|
||||
HDC hDC;
|
||||
PAINTSTRUCT ps;
|
||||
int x, y;
|
||||
|
||||
hDC = BeginPaint(hWnd, &ps);
|
||||
GetClientRect(hWnd, &rc);
|
||||
|
||||
x = (rc.right / 2) - (32 / 2);
|
||||
y = (rc.bottom / 2) - ((32) / 2);
|
||||
|
||||
if(rc.right > 34 && rc.bottom > 34)
|
||||
{
|
||||
if(m_hIcon != NULL)
|
||||
DrawIcon(hDC, x, y, m_hIcon);
|
||||
|
||||
POINT pt[5];
|
||||
|
||||
// left vert and top horiz highlight
|
||||
pt[0].x = 1; pt[0].y = rc.bottom-1;
|
||||
pt[1].x = 1; pt[1].y = 1;
|
||||
pt[2].x = rc.right-1; pt[2].y = 1;
|
||||
|
||||
SelectObject(hDC, (HGDIOBJ)CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DLIGHT)));
|
||||
Polyline(hDC, pt, 3);
|
||||
|
||||
// left vert and top horiz shadow
|
||||
pt[0].x = 2; pt[0].y = rc.bottom-3;
|
||||
pt[1].x = 2; pt[1].y = 2;
|
||||
pt[2].x = rc.right-2; pt[2].y = 2;
|
||||
SelectObject(hDC, (HGDIOBJ)CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW)));
|
||||
Polyline(hDC, pt, 3);
|
||||
|
||||
// right vert and bottom horiz highlight
|
||||
pt[0].x = rc.right-3; pt[0].y = 2;
|
||||
pt[1].x = rc.right-3; pt[1].y = rc.bottom-3;
|
||||
pt[2].x = 2; pt[2].y = rc.bottom-3;
|
||||
SelectObject(hDC, (HGDIOBJ) CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DLIGHT)));
|
||||
Polyline(hDC, pt, 3);
|
||||
|
||||
// right vert and bottom horiz shadow
|
||||
pt[0].x = rc.right-1; pt[0].y = 1;
|
||||
pt[1].x = rc.right-1; pt[1].y = rc.bottom-1;
|
||||
pt[2].x = 0; pt[2].y = rc.bottom-1;
|
||||
SelectObject(hDC, (HGDIOBJ)CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DDKSHADOW)));
|
||||
Polyline(hDC, pt, 3);
|
||||
}
|
||||
|
||||
DrawCommandMessage(hDC, m_szCommandMessage, &rc);
|
||||
|
||||
EndPaint (hWnd, &ps);
|
||||
}
|
||||
|
||||
//**************************
|
||||
// Plugin window procedure
|
||||
//**************************
|
||||
static LRESULT CALLBACK NP_LOADDS PluginWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
CPlugin *pPlugin = (CPlugin *)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
|
||||
switch(message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
pPlugin = (CPlugin *)(((CREATESTRUCT FAR*)lParam)->lpCreateParams);
|
||||
assert(pPlugin != NULL);
|
||||
SetWindowLong(hWnd, GWL_USERDATA, (LONG)pPlugin);
|
||||
pPlugin->onCreate(hWnd);
|
||||
return 0L;
|
||||
case WM_LBUTTONUP:
|
||||
HANDLE_WM_LBUTTONUP(hWnd, wParam, lParam, pPlugin->onLButtonUp);
|
||||
return 0L;
|
||||
case WM_RBUTTONUP:
|
||||
HANDLE_WM_RBUTTONUP(hWnd, wParam, lParam, pPlugin->onRButtonUp);
|
||||
return 0L;
|
||||
case WM_PAINT:
|
||||
HANDLE_WM_PAINT(hWnd, wParam, lParam, pPlugin->onPaint);
|
||||
return 0L;
|
||||
case WM_MOUSEMOVE:
|
||||
dbgOut1("MouseMove");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return(DefWindowProc(hWnd, message, wParam, lParam));
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef __PLUGIN_HPP__
|
||||
#define __PLUGIN_HPP__
|
||||
|
||||
#include "npapi.h"
|
||||
|
||||
class CPlugin
|
||||
{
|
||||
private:
|
||||
HINSTANCE m_hInst;
|
||||
NPP m_pNPInstance;
|
||||
WORD m_wMode;
|
||||
HWND m_hWnd;
|
||||
HWND m_hWndParent;
|
||||
HICON m_hIcon;
|
||||
char * m_szURLString;
|
||||
|
||||
char * m_szCommandMessage;
|
||||
|
||||
public:
|
||||
BOOL m_bHidden;
|
||||
NPMIMEType m_pNPMIMEType;
|
||||
LPSTR m_szPageURL; // Location of plug-in HTML page
|
||||
LPSTR m_szFileURL; // Location of plug-in JAR file
|
||||
LPSTR m_szFileExtension; // File extension associated with the of the unknown mimetype
|
||||
|
||||
// environment
|
||||
BOOL m_bOnline;
|
||||
BOOL m_bJava;
|
||||
BOOL m_bJavaScript;
|
||||
BOOL m_bSmartUpdate;
|
||||
|
||||
private:
|
||||
BOOL useDefaultURL_P();
|
||||
BOOL doSmartUpdate_P();
|
||||
LPSTR createURLString();
|
||||
void getPluginSmart();
|
||||
void getPluginRegular();
|
||||
|
||||
public:
|
||||
CPlugin(HINSTANCE hInst,
|
||||
NPP pNPInstance,
|
||||
WORD wMode,
|
||||
NPMIMEType pluginType,
|
||||
LPSTR szPageURL,
|
||||
LPSTR szFileURL,
|
||||
LPSTR szFileExtension,
|
||||
BOOL bHidden);
|
||||
~CPlugin();
|
||||
|
||||
BOOL init(HWND hWnd);
|
||||
void shut();
|
||||
HWND getWindow();
|
||||
void showGetPluginDialog();
|
||||
BOOL readyToRefresh();
|
||||
|
||||
// NP API handlers
|
||||
void resize();
|
||||
void print(NPPrint * pNPPrint);
|
||||
void URLNotify(const char * szURL);
|
||||
|
||||
// Windows message handlers
|
||||
void onCreate(HWND hWnd);
|
||||
void onLButtonUp(HWND hWnd, int x, int y, UINT keyFlags);
|
||||
void onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags);
|
||||
void onPaint(HWND hWnd);
|
||||
};
|
||||
|
||||
|
||||
#define PAGE_URL_FOR_JAVASCRIPT "http://cgi.netscape.com/cgi-bin/plugins/get_plugin.cgi"
|
||||
|
||||
#define PLUGINFINDER_COMMAND_BEGINNING "javascript:window.open(\""
|
||||
#define PLUGINFINDER_COMMAND_END "\",\"plugin\",\"toolbar=no,status=no,resizeable=no,scrollbars=no,height=252,width=626\");"
|
||||
#define DEFAULT_PLUGINFINDER_URL "http://cgi.netscape.com/cgi-bin/plug-in_finder.cgi"
|
||||
#define JVM_SMARTUPDATE_URL "http://home.netscape.com/plugins/jvm.html"
|
||||
|
||||
#ifdef WIN32
|
||||
#define REGISTRY_PLACE "Software\\Netscape\\Netscape Navigator\\Default Plugin"
|
||||
#else
|
||||
#define GWL_USERDATA 0
|
||||
#define COLOR_3DSHADOW COLOR_BTNFACE
|
||||
#define COLOR_3DLIGHT COLOR_BTNHIGHLIGHT
|
||||
#define COLOR_3DDKSHADOW COLOR_BTNSHADOW
|
||||
#endif
|
||||
|
||||
#define CLASS_NULL_PLUGIN "NullPluginClass"
|
||||
|
||||
BOOL RegisterNullPluginWindowClass();
|
||||
void UnregisterNullPluginWindowClass();
|
||||
|
||||
extern HINSTANCE hInst;
|
||||
|
||||
#endif // __PLUGIN_HPP__
|
|
@ -0,0 +1,48 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by Npnul32.rc
|
||||
//
|
||||
#define IDD_PLUGIN_DOWNLOAD 301
|
||||
#define IDI_PLUGICON 302
|
||||
#define IDS_INFO 303
|
||||
#define IDS_DEFAULT_URL 304
|
||||
#define IDS_INSTALL_COMMAND 305
|
||||
#define IDS_GET_PLUGIN_MSG2 306
|
||||
#define IDS_LOCATION 306
|
||||
#define IDS_TITLE 307
|
||||
#define IDS_QUESTION 308
|
||||
#define IDS_JS_DISABLED 309
|
||||
#define IDS_ASDFINDER 310
|
||||
#define IDS_ASDSIMP 311
|
||||
#define IDS_QUERY_TEST 312
|
||||
#define IDS_BLANK_JS 313
|
||||
#define IDS_GOING2HTML 314
|
||||
#define IDS_WARNING_JS 315
|
||||
#define IDS_WARNING_OFFLINE 316
|
||||
#define IDS_DEFAULT_URL_OLD 317
|
||||
#define IDS_FINDER_PAGE 317
|
||||
#define IDS_CLICK_TO_GET 318
|
||||
#define IDS_CLICK_WHEN_DONE 319
|
||||
#define IDC_JS_DIS_TEXT 2003
|
||||
#define IDC_CONTINUE 2004
|
||||
#define IDC_CONT_NOJS 2005
|
||||
#define IDC_STATIC_INFO 2009
|
||||
#define IDC_STATIC_LOCATION 2010
|
||||
#define IDC_STATIC_QUESTION 2011
|
||||
#define IDC_GET_PLUGIN 2012
|
||||
#define IDC_BUTTON_CANCEL 2013
|
||||
#define IDC_STATIC_URL 2014
|
||||
#define IDC_STATIC_INFOTYPE 2015
|
||||
#define IDC_STATIC_WARNING 2016
|
||||
#define IDC_EDIT_URL 2017
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 308
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 2018
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,156 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
// open the registry, create if necessary
|
||||
HKEY openRegistry()
|
||||
{
|
||||
HKEY phkResult;
|
||||
|
||||
if(RegCreateKey(HKEY_CURRENT_USER, REGISTRY_PLACE, &phkResult) != ERROR_SUCCESS)
|
||||
MessageBox(0, "Error creating Default Plugin registry key", "Default Plugin", MB_OK);
|
||||
|
||||
return phkResult;
|
||||
}
|
||||
|
||||
// return TRUE if we've never seen this MIME type before
|
||||
BOOL IsNewMimeType(LPSTR mime)
|
||||
{
|
||||
HKEY hkey = openRegistry();
|
||||
DWORD dwType, keysize = 512;
|
||||
char keybuf[512];
|
||||
|
||||
if(RegQueryValueEx(hkey, mime, 0, &dwType, (LPBYTE) &keybuf, &keysize) == ERROR_SUCCESS)
|
||||
{
|
||||
// key exists, must have already been here...
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(RegSetValueEx(hkey, mime, 0, REG_SZ, (LPBYTE) "(none)", 7) != ERROR_SUCCESS)
|
||||
MessageBox(0, "Error adding MIME type value", "Default Plugin", MB_OK);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// string length in pixels for the specific window (selected font)
|
||||
static int getWindowStringLength(HWND hWnd, LPSTR lpsz)
|
||||
{
|
||||
SIZE sz;
|
||||
HDC hDC = GetDC(hWnd);
|
||||
HFONT hWindowFont = GetWindowFont(hWnd);
|
||||
HFONT hFontOld = SelectFont(hDC, hWindowFont);
|
||||
GetTextExtentPoint32(hDC, lpsz, lstrlen(lpsz), &sz);
|
||||
POINT pt;
|
||||
pt.x = sz.cx;
|
||||
pt.y = sz.cy;
|
||||
LPtoDP(hDC, &pt, 1);
|
||||
SelectFont(hDC, hFontOld);
|
||||
ReleaseDC(hWnd, hDC);
|
||||
return (int)pt.x;
|
||||
}
|
||||
|
||||
/****************************************************************/
|
||||
/* */
|
||||
/* void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText) */
|
||||
/* */
|
||||
/* helper to wrap long lines in a static control, which do not */
|
||||
/* wrap automatically if they do not have space characters */
|
||||
/* */
|
||||
/****************************************************************/
|
||||
void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText)
|
||||
{
|
||||
HWND hWndStatic = GetDlgItem(hWnd, iID);
|
||||
if((szText == NULL) || (lstrlen(szText) == 0))
|
||||
{
|
||||
SetDlgItemText(hWnd, iID, "");
|
||||
return;
|
||||
}
|
||||
|
||||
RECT rc;
|
||||
GetClientRect(hWndStatic, &rc);
|
||||
|
||||
int iStaticLength = rc.right - rc.left;
|
||||
int iStringLength = getWindowStringLength(hWndStatic, szText);
|
||||
|
||||
if(iStringLength <= iStaticLength)
|
||||
{
|
||||
SetDlgItemText(hWnd, iID, szText);
|
||||
return;
|
||||
}
|
||||
|
||||
int iBreaks = iStringLength/iStaticLength;
|
||||
if(iBreaks <= 0)
|
||||
return;
|
||||
|
||||
char * pBuf = new char[iStringLength + iBreaks + 1];
|
||||
if(pBuf == NULL)
|
||||
return;
|
||||
|
||||
lstrcpy(pBuf, "");
|
||||
|
||||
int iStart = 0;
|
||||
int iLines = 0;
|
||||
for(int i = 0; i < iStringLength; i++)
|
||||
{
|
||||
char * sz = &szText[iStart];
|
||||
int iIndex = i - iStart;
|
||||
char ch = sz[iIndex + 1];
|
||||
|
||||
sz[iIndex + 1] = '\0';
|
||||
|
||||
int iLength = getWindowStringLength(hWndStatic, sz);
|
||||
|
||||
if(iLength < iStaticLength)
|
||||
{
|
||||
sz[iIndex + 1] = ch;
|
||||
if(iLines == iBreaks)
|
||||
{
|
||||
lstrcat(pBuf, sz);
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
sz[iIndex + 1] = ch; // restore zeroed element
|
||||
i--; // go one step back
|
||||
|
||||
ch = sz[iIndex];
|
||||
sz[iIndex] = '\0'; // terminate string one char shorter
|
||||
|
||||
lstrcat(pBuf, sz); // append the string
|
||||
lstrcat(pBuf, " "); // append space character for successful wrapping
|
||||
|
||||
iStart += lstrlen(sz);// shift new start position
|
||||
sz[iIndex] = ch; // restore zeroed element
|
||||
iLines++; // count lines
|
||||
}
|
||||
|
||||
SetDlgItemText(hWnd, iID, pBuf);
|
||||
|
||||
delete [] pBuf;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef __UTILS_H__
|
||||
#define __UTILS_H__
|
||||
|
||||
HKEY openRegistry();
|
||||
BOOL IsNewMimeType(LPSTR szMimeType);
|
||||
void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText);
|
||||
|
||||
#endif // __UTILS_H__
|
Загрузка…
Ссылка в новой задаче