зеркало из https://github.com/mozilla/gecko-dev.git
New default plugin for Mac OS X. b=428973 r/sr=jst
This commit is contained in:
Родитель
395df82dd9
Коммит
ad9bc83b79
|
@ -0,0 +1,252 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Josh Aas <josh@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "npapi.h"
|
||||
#include "npfunctions.h"
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
extern "C"
|
||||
{
|
||||
NPError NP_Initialize(NPNetscapeFuncs *browserFuncs);
|
||||
NPError NP_GetEntryPoints(NPPluginFuncs *pluginFuncs);
|
||||
void NP_Shutdown(void);
|
||||
|
||||
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved);
|
||||
NPError NPP_Destroy(NPP instance, NPSavedData** save);
|
||||
NPError NPP_SetWindow(NPP instance, NPWindow* window);
|
||||
NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype);
|
||||
NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason);
|
||||
int32_t NPP_WriteReady(NPP instance, NPStream* stream);
|
||||
int32_t NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer);
|
||||
void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
|
||||
void NPP_Print(NPP instance, NPPrint* platformPrint);
|
||||
int16_t NPP_HandleEvent(NPP instance, void* event);
|
||||
void NPP_URLNotify(NPP instance, const char* URL, NPReason reason, void* notifyData);
|
||||
NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value);
|
||||
NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value);
|
||||
}
|
||||
#pragma GCC visibility pop
|
||||
|
||||
// structure containing pointers to functions implemented by the browser
|
||||
static NPNetscapeFuncs* browser;
|
||||
|
||||
// data for each instance of this plugin
|
||||
typedef struct PluginInstance {
|
||||
NPP npp;
|
||||
NPWindow window;
|
||||
} PluginInstance;
|
||||
|
||||
void drawPlugin(NPP instance);
|
||||
|
||||
// Symbol called once by the browser to initialize the plugin
|
||||
NPError NP_Initialize(NPNetscapeFuncs* browserFuncs)
|
||||
{
|
||||
// save away browser functions
|
||||
browser = browserFuncs;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// Symbol called by the browser to get the plugin's function list
|
||||
NPError NP_GetEntryPoints(NPPluginFuncs* pluginFuncs)
|
||||
{
|
||||
pluginFuncs->version = 11;
|
||||
pluginFuncs->size = sizeof(pluginFuncs);
|
||||
pluginFuncs->newp = NPP_New;
|
||||
pluginFuncs->destroy = NPP_Destroy;
|
||||
pluginFuncs->setwindow = NPP_SetWindow;
|
||||
pluginFuncs->newstream = NPP_NewStream;
|
||||
pluginFuncs->destroystream = NPP_DestroyStream;
|
||||
pluginFuncs->asfile = NPP_StreamAsFile;
|
||||
pluginFuncs->writeready = NPP_WriteReady;
|
||||
pluginFuncs->write = (NPP_WriteProcPtr)NPP_Write;
|
||||
pluginFuncs->print = NPP_Print;
|
||||
pluginFuncs->event = NPP_HandleEvent;
|
||||
pluginFuncs->urlnotify = NPP_URLNotify;
|
||||
pluginFuncs->getvalue = NPP_GetValue;
|
||||
pluginFuncs->setvalue = NPP_SetValue;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// Symbol called once by the browser to shut down the plugin
|
||||
void NP_Shutdown(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Called to create a new instance of the plugin
|
||||
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved)
|
||||
{
|
||||
PluginInstance *newInstance = (PluginInstance*)malloc(sizeof(PluginInstance));
|
||||
bzero(newInstance, sizeof(PluginInstance));
|
||||
|
||||
newInstance->npp = instance;
|
||||
instance->pdata = newInstance;
|
||||
|
||||
NPBool supportsCoreGraphics;
|
||||
if (browser->getvalue(instance, NPNVsupportsCoreGraphicsBool, &supportsCoreGraphics) != NPERR_NO_ERROR)
|
||||
supportsCoreGraphics = FALSE;
|
||||
|
||||
if (!supportsCoreGraphics)
|
||||
return NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
|
||||
browser->setvalue(instance, NPPVpluginDrawingModel, (void *)NPDrawingModelCoreGraphics);
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// Called to destroy an instance of the plugin
|
||||
NPError NPP_Destroy(NPP instance, NPSavedData** save)
|
||||
{
|
||||
free(instance->pdata);
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// Called to update a plugin instances's NPWindow
|
||||
NPError NPP_SetWindow(NPP instance, NPWindow* window)
|
||||
{
|
||||
PluginInstance* currentInstance = (PluginInstance*)(instance->pdata);
|
||||
|
||||
currentInstance->window = *window;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype)
|
||||
{
|
||||
*stype = NP_ASFILEONLY;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason)
|
||||
{
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t NPP_WriteReady(NPP instance, NPStream* stream)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NPP_Print(NPP instance, NPPrint* platformPrint)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int16_t NPP_HandleEvent(NPP instance, void* event)
|
||||
{
|
||||
EventRecord* carbonEvent = (EventRecord*)event;
|
||||
if (carbonEvent && (carbonEvent->what == updateEvt))
|
||||
drawPlugin(instance);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
|
||||
{
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
|
||||
{
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
void drawPlugin(NPP instance)
|
||||
{
|
||||
PluginInstance* currentInstance = (PluginInstance*)(instance->pdata);
|
||||
CGContextRef cgContext = ((NP_CGContext*)(currentInstance->window.window))->context;
|
||||
|
||||
float windowWidth = currentInstance->window.width;
|
||||
float windowHeight = currentInstance->window.height;
|
||||
|
||||
// save the cgcontext gstate
|
||||
CGContextSaveGState(cgContext);
|
||||
|
||||
// we get a flipped context
|
||||
CGContextTranslateCTM(cgContext, 0.0, windowHeight);
|
||||
CGContextScaleCTM(cgContext, 1.0, -1.0);
|
||||
|
||||
// draw a white background for the plugin
|
||||
CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
|
||||
CGContextSetGrayFillColor(cgContext, 1.0, 1.0);
|
||||
CGContextDrawPath(cgContext, kCGPathFill);
|
||||
|
||||
// draw a blue frame around the plugin
|
||||
CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
|
||||
CGContextSetRGBStrokeColor(cgContext, 0.0, 0.0, 0.5, 1.0);
|
||||
CGContextSetLineWidth(cgContext, 2.0);
|
||||
CGContextStrokePath(cgContext);
|
||||
|
||||
// draw the broken plugin icon
|
||||
CFBundleRef bundle = ::CFBundleGetBundleWithIdentifier(CFSTR("org.mozilla.DefaultPlugin"));
|
||||
CFURLRef imageURL = ::CFBundleCopyResourceURL(bundle, CFSTR("plugin"), CFSTR("png"), NULL);
|
||||
CGDataProviderRef dataProvider = ::CGDataProviderCreateWithURL(imageURL);
|
||||
::CFRelease(imageURL);
|
||||
CGImageRef imageRef = ::CGImageCreateWithPNGDataProvider(dataProvider, NULL, TRUE, kCGRenderingIntentDefault);
|
||||
::CGDataProviderRelease(dataProvider);
|
||||
float imageWidth = ::CGImageGetWidth(imageRef);
|
||||
float imageHeight = ::CGImageGetHeight(imageRef);
|
||||
CGRect drawRect = ::CGRectMake(windowWidth / 2 - imageWidth / 2, windowHeight / 2 - imageHeight / 2, imageWidth, imageHeight);
|
||||
::CGContextDrawImage(cgContext, drawRect, imageRef);
|
||||
::CGImageRelease(imageRef);
|
||||
|
||||
// restore the cgcontext gstate
|
||||
CGContextRestoreGState(cgContext);
|
||||
}
|
Двоичный файл не отображается.
|
@ -3,73 +3,56 @@
|
|||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 42;
|
||||
objectVersion = 45;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
4D1684A00830226300080847 /* DefaultPluginPrefix.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F64AF2C0433C8A200A96652 /* DefaultPluginPrefix.h */; };
|
||||
4D1684A20830226300080847 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; };
|
||||
4D1684A40830226300080847 /* NullPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5E0C34F036A130901A96660 /* NullPlugin.cpp */; };
|
||||
4D1684A50830226300080847 /* npmac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5E0C351036A130E01A96660 /* npmac.cpp */; };
|
||||
4D1684A70830226300080847 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08EA7FFBFE8413EDC02AAC07 /* Carbon.framework */; };
|
||||
4D1684A80830226300080847 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5A7D3AB036E359F01A96660 /* CoreFoundation.framework */; };
|
||||
4D1684AA0830226300080847 /* NullPlugin.rsrc in Rez */ = {isa = PBXBuildFile; fileRef = F5E0C34D036A12DF01A96660 /* NullPlugin.rsrc */; };
|
||||
032267660EAFA4C40059A1E6 /* DefaultPlugin.mm in Sources */ = {isa = PBXBuildFile; fileRef = 032267650EAFA4C40059A1E6 /* DefaultPlugin.mm */; };
|
||||
032267840EAFA62E0059A1E6 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 032267830EAFA62E0059A1E6 /* Carbon.framework */; };
|
||||
032268110EAFB8720059A1E6 /* plugin.png in Resources */ = {isa = PBXBuildFile; fileRef = 032268100EAFB8720059A1E6 /* plugin.png */; };
|
||||
8D576314048677EA00EA77CD /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */; };
|
||||
8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8D5B49A704867FD3000E48DA /* InfoPlist.strings */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
4D1684AB0830226300080847 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 6;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
032267650EAFA4C40059A1E6 /* DefaultPlugin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DefaultPlugin.mm; sourceTree = "<group>"; };
|
||||
032267830EAFA62E0059A1E6 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
|
||||
032268100EAFB8720059A1E6 /* plugin.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = plugin.png; sourceTree = "<group>"; };
|
||||
089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
08EA7FFBFE8413EDC02AAC07 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
|
||||
0F64AF2C0433C8A200A96652 /* DefaultPluginPrefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultPluginPrefix.h; sourceTree = "<group>"; };
|
||||
4D1684AC0830226300080847 /* Info-DefaultPlugin.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-DefaultPlugin.plist"; sourceTree = "<group>"; };
|
||||
4D1684AD0830226300080847 /* Default Plugin.plugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Default Plugin.plugin"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
F5A7D3AB036E359F01A96660 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
|
||||
F5E0C34D036A12DF01A96660 /* NullPlugin.rsrc */ = {isa = PBXFileReference; lastKnownFileType = archive.rsrc; path = NullPlugin.rsrc; sourceTree = SOURCE_ROOT; };
|
||||
F5E0C34F036A130901A96660 /* NullPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = NullPlugin.cpp; sourceTree = SOURCE_ROOT; };
|
||||
F5E0C351036A130E01A96660 /* npmac.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = npmac.cpp; sourceTree = SOURCE_ROOT; };
|
||||
0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
|
||||
8D576316048677EA00EA77CD /* DefaultPlugin.plugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DefaultPlugin.plugin; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8D576317048677EA00EA77CD /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
4D1684A60830226300080847 /* Frameworks */ = {
|
||||
8D576313048677EA00EA77CD /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
4D1684A70830226300080847 /* Carbon.framework in Frameworks */,
|
||||
4D1684A80830226300080847 /* CoreFoundation.framework in Frameworks */,
|
||||
8D576314048677EA00EA77CD /* CoreFoundation.framework in Frameworks */,
|
||||
032267840EAFA62E0059A1E6 /* Carbon.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
089C166AFE841209C02AAC07 /* MRJPlugin */ = {
|
||||
089C166AFE841209C02AAC07 /* DefaultPlugin */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
08FB77ADFE841716C02AAC07 /* Source */,
|
||||
08FB77AFFE84173DC02AAC07 /* Source */,
|
||||
089C167CFE841241C02AAC07 /* Resources */,
|
||||
089C1671FE841209C02AAC07 /* External Frameworks and Libraries */,
|
||||
19C28FB4FE9D528D11CA2CBB /* Products */,
|
||||
4D1684AC0830226300080847 /* Info-DefaultPlugin.plist */,
|
||||
19C28FB6FE9D52B211CA2CBB /* Products */,
|
||||
);
|
||||
name = MRJPlugin;
|
||||
name = DefaultPlugin;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
089C1671FE841209C02AAC07 /* External Frameworks and Libraries */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F5A7D3AB036E359F01A96660 /* CoreFoundation.framework */,
|
||||
08EA7FFBFE8413EDC02AAC07 /* Carbon.framework */,
|
||||
032267830EAFA62E0059A1E6 /* Carbon.framework */,
|
||||
0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */,
|
||||
);
|
||||
name = "External Frameworks and Libraries";
|
||||
sourceTree = "<group>";
|
||||
|
@ -77,62 +60,48 @@
|
|||
089C167CFE841241C02AAC07 /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
089C167DFE841241C02AAC07 /* InfoPlist.strings */,
|
||||
F5E0C34D036A12DF01A96660 /* NullPlugin.rsrc */,
|
||||
032268100EAFB8720059A1E6 /* plugin.png */,
|
||||
8D576317048677EA00EA77CD /* Info.plist */,
|
||||
8D5B49A704867FD3000E48DA /* InfoPlist.strings */,
|
||||
);
|
||||
name = Resources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
08FB77ADFE841716C02AAC07 /* Source */ = {
|
||||
08FB77AFFE84173DC02AAC07 /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0F64AF2C0433C8A200A96652 /* DefaultPluginPrefix.h */,
|
||||
F5E0C34F036A130901A96660 /* NullPlugin.cpp */,
|
||||
F5E0C351036A130E01A96660 /* npmac.cpp */,
|
||||
032267650EAFA4C40059A1E6 /* DefaultPlugin.mm */,
|
||||
);
|
||||
name = Source;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
19C28FB4FE9D528D11CA2CBB /* Products */ = {
|
||||
19C28FB6FE9D52B211CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4D1684AD0830226300080847 /* Default Plugin.plugin */,
|
||||
8D576316048677EA00EA77CD /* DefaultPlugin.plugin */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
4D16849F0830226300080847 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
4D1684A00830226300080847 /* DefaultPluginPrefix.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
4D16849D0830226300080847 /* Default Plugin */ = {
|
||||
8D57630D048677EA00EA77CD /* DefaultPlugin */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 0335A32F0CDD0E2C00E37285 /* Build configuration list for PBXNativeTarget "Default Plugin" */;
|
||||
buildConfigurationList = 1DEB911A08733D790010E9CD /* Build configuration list for PBXNativeTarget "DefaultPlugin" */;
|
||||
buildPhases = (
|
||||
4D16849F0830226300080847 /* Headers */,
|
||||
4D1684A10830226300080847 /* Resources */,
|
||||
4D1684A30830226300080847 /* Sources */,
|
||||
4D1684A60830226300080847 /* Frameworks */,
|
||||
4D1684A90830226300080847 /* Rez */,
|
||||
4D1684AB0830226300080847 /* CopyFiles */,
|
||||
8D57630F048677EA00EA77CD /* Resources */,
|
||||
8D576311048677EA00EA77CD /* Sources */,
|
||||
8D576313048677EA00EA77CD /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "Default Plugin";
|
||||
productName = MRJPlugin;
|
||||
productReference = 4D1684AD0830226300080847 /* Default Plugin.plugin */;
|
||||
name = DefaultPlugin;
|
||||
productInstallPath = "$(HOME)/Library/Bundles";
|
||||
productName = DefaultPlugin;
|
||||
productReference = 8D576316048677EA00EA77CD /* DefaultPlugin.plugin */;
|
||||
productType = "com.apple.product-type.bundle";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
@ -140,186 +109,138 @@
|
|||
/* Begin PBXProject section */
|
||||
089C1669FE841209C02AAC07 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = 0335A3340CDD0E2C00E37285 /* Build configuration list for PBXProject "DefaultPlugin" */;
|
||||
compatibilityVersion = "Xcode 2.4";
|
||||
buildConfigurationList = 1DEB911E08733D790010E9CD /* Build configuration list for PBXProject "DefaultPlugin" */;
|
||||
compatibilityVersion = "Xcode 3.1";
|
||||
hasScannedForEncodings = 1;
|
||||
mainGroup = 089C166AFE841209C02AAC07 /* MRJPlugin */;
|
||||
mainGroup = 089C166AFE841209C02AAC07 /* DefaultPlugin */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
4D16849D0830226300080847 /* Default Plugin */,
|
||||
8D57630D048677EA00EA77CD /* DefaultPlugin */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
4D1684A10830226300080847 /* Resources */ = {
|
||||
8D57630F048677EA00EA77CD /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
4D1684A20830226300080847 /* InfoPlist.strings in Resources */,
|
||||
8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */,
|
||||
032268110EAFB8720059A1E6 /* plugin.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXRezBuildPhase section */
|
||||
4D1684A90830226300080847 /* Rez */ = {
|
||||
isa = PBXRezBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
4D1684AA0830226300080847 /* NullPlugin.rsrc in Rez */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXRezBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
4D1684A30830226300080847 /* Sources */ = {
|
||||
8D576311048677EA00EA77CD /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
4D1684A40830226300080847 /* NullPlugin.cpp in Sources */,
|
||||
4D1684A50830226300080847 /* npmac.cpp in Sources */,
|
||||
032267660EAFA4C40059A1E6 /* DefaultPlugin.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
089C167DFE841241C02AAC07 /* InfoPlist.strings */ = {
|
||||
8D5B49A704867FD3000E48DA /* InfoPlist.strings */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
089C167EFE841241C02AAC07 /* English */,
|
||||
);
|
||||
name = InfoPlist.strings;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
0335A3300CDD0E2C00E37285 /* Development */ = {
|
||||
1DEB911B08733D790010E9CD /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreFoundation.framework\"";
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREFIX_HEADER = DefaultPluginPrefix.h;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"XP_MACOSX=1",
|
||||
"NO_X11=1",
|
||||
"USE_SYSTEM_CONSOLE=1",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
../../../../dist/sdk/xpcom/include,
|
||||
../../../../dist/include/caps,
|
||||
../../../../dist/include/java,
|
||||
../../../../dist/include/js,
|
||||
../../../../dist/include/nspr,
|
||||
../../../../dist/include/nspr/obsolete,
|
||||
../../../../dist/include/oji,
|
||||
../../../../dist/include/plugin,
|
||||
../../../../dist/include/xpcom,
|
||||
../../../../dist/include/xpconnect,
|
||||
../../../../dist/include,
|
||||
/Developer/Headers/FlatCarbon,
|
||||
);
|
||||
INFOPLIST_FILE = "Info-DefaultPlugin.plist";
|
||||
LIBRARY_SEARCH_PATHS = /usr/lib;
|
||||
OTHER_CFLAGS = "";
|
||||
OTHER_LDFLAGS = "";
|
||||
OTHER_REZFLAGS = "";
|
||||
PRODUCT_NAME = "Default Plugin";
|
||||
SECTORDER_FLAGS = "";
|
||||
WARNING_CFLAGS = (
|
||||
"-Wmost",
|
||||
"-Wno-four-char-constants",
|
||||
"-Wno-unknown-pragmas",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = ../../../../dist/include/plugin;
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
INSTALL_PATH = "$(HOME)/Library/Bundles";
|
||||
PRODUCT_NAME = DefaultPlugin;
|
||||
WRAPPER_EXTENSION = plugin;
|
||||
ZERO_LINK = YES;
|
||||
};
|
||||
name = Development;
|
||||
name = Debug;
|
||||
};
|
||||
0335A3310CDD0E2C00E37285 /* Deployment */ = {
|
||||
1DEB911C08733D790010E9CD /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreFoundation.framework\"";
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||
GCC_PREFIX_HEADER = DefaultPluginPrefix.h;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"XP_MACOSX=1",
|
||||
"NO_X11=1",
|
||||
"USE_SYSTEM_CONSOLE=1",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
../../../../dist/sdk/xpcom/include,
|
||||
../../../../dist/include/caps,
|
||||
../../../../dist/include/java,
|
||||
../../../../dist/include/js,
|
||||
../../../../dist/include/nspr,
|
||||
../../../../dist/include/nspr/obsolete,
|
||||
../../../../dist/include/oji,
|
||||
../../../../dist/include/plugin,
|
||||
../../../../dist/include/xpcom,
|
||||
../../../../dist/include/xpconnect,
|
||||
../../../../dist/include,
|
||||
/Developer/Headers/FlatCarbon,
|
||||
);
|
||||
INFOPLIST_FILE = "Info-DefaultPlugin.plist";
|
||||
LIBRARY_SEARCH_PATHS = /usr/lib;
|
||||
OTHER_CFLAGS = "";
|
||||
OTHER_LDFLAGS = "";
|
||||
OTHER_REZFLAGS = "";
|
||||
PRODUCT_NAME = "Default Plugin";
|
||||
SECTORDER_FLAGS = "";
|
||||
WARNING_CFLAGS = (
|
||||
"-Wmost",
|
||||
"-Wno-four-char-constants",
|
||||
"-Wno-unknown-pragmas",
|
||||
);
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_MODEL_TUNING = G5;
|
||||
HEADER_SEARCH_PATHS = ../../../../dist/include/plugin;
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
INSTALL_PATH = "$(HOME)/Library/Bundles";
|
||||
PRODUCT_NAME = DefaultPlugin;
|
||||
WRAPPER_EXTENSION = plugin;
|
||||
ZERO_LINK = NO;
|
||||
};
|
||||
name = Deployment;
|
||||
name = Release;
|
||||
};
|
||||
0335A3350CDD0E2C00E37285 /* Development */ = {
|
||||
1DEB911F08733D790010E9CD /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "XP_MACOSX=1";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = ../../../../dist/include/plugin;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PREBINDING = NO;
|
||||
SDKROOT = macosx10.5;
|
||||
WRAPPER_EXTENSION = plugin;
|
||||
};
|
||||
name = Development;
|
||||
name = Debug;
|
||||
};
|
||||
0335A3360CDD0E2C00E37285 /* Deployment */ = {
|
||||
1DEB912008733D790010E9CD /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "XP_MACOSX=1";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = ../../../../dist/include/plugin;
|
||||
PREBINDING = NO;
|
||||
SDKROOT = macosx10.5;
|
||||
SEPARATE_SYMBOL_EDIT = NO;
|
||||
STRIP_INSTALLED_PRODUCT = YES;
|
||||
WRAPPER_EXTENSION = plugin;
|
||||
};
|
||||
name = Deployment;
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
0335A32F0CDD0E2C00E37285 /* Build configuration list for PBXNativeTarget "Default Plugin" */ = {
|
||||
1DEB911A08733D790010E9CD /* Build configuration list for PBXNativeTarget "DefaultPlugin" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
0335A3300CDD0E2C00E37285 /* Development */,
|
||||
0335A3310CDD0E2C00E37285 /* Deployment */,
|
||||
1DEB911B08733D790010E9CD /* Debug */,
|
||||
1DEB911C08733D790010E9CD /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Development;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
0335A3340CDD0E2C00E37285 /* Build configuration list for PBXProject "DefaultPlugin" */ = {
|
||||
1DEB911E08733D790010E9CD /* Build configuration list for PBXProject "DefaultPlugin" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
0335A3350CDD0E2C00E37285 /* Development */,
|
||||
0335A3360CDD0E2C00E37285 /* Deployment */,
|
||||
1DEB911F08733D790010E9CD /* Debug */,
|
||||
1DEB912008733D790010E9CD /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Development;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#include "mozilla-config.h"
|
Двоичные данные
modules/plugin/default/mac/English.lproj/InfoPlist.strings
Двоичные данные
modules/plugin/default/mac/English.lproj/InfoPlist.strings
Двоичный файл не отображается.
|
@ -2,12 +2,26 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>WebPluginMIMETypes</key>
|
||||
<dict>
|
||||
<key>*</key>
|
||||
<dict>
|
||||
<key>WebPluginExtensions</key>
|
||||
<array>
|
||||
<string>*</string>
|
||||
</array>
|
||||
<key>WebPluginTypeDescription</key>
|
||||
<string>All types</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>WebPluginDescription</key>
|
||||
<string>Gecko default plugin</string>
|
||||
<key>WebPluginName</key>
|
||||
<string>Default Plugin</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>Default Plugin</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.mozilla.DefaultPlugin</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
|
@ -15,8 +29,6 @@
|
|||
<key>CFBundlePackageType</key>
|
||||
<string>NSPL</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0.0.15</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
<string>2.0</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -46,7 +46,7 @@ include $(topsrcdir)/config/rules.mk
|
|||
MODULE = plugin
|
||||
|
||||
ifdef MOZ_DEBUG
|
||||
BUILDSTYLE = Development
|
||||
BUILDSTYLE = Debug
|
||||
else
|
||||
BUILDSTYLE = Deployment
|
||||
endif
|
||||
|
@ -55,9 +55,7 @@ PROJECT=DefaultPlugin.xcodeproj
|
|||
PROJECT_ARG=-project $(PROJECT)
|
||||
PBBUILD_ARG=$(PBBUILD_SETTINGS)
|
||||
|
||||
TARGET = "Default Plugin"
|
||||
|
||||
PACKAGE_FILE = npnul.pkg
|
||||
TARGET = "DefaultPlugin"
|
||||
|
||||
unexport CC CXX
|
||||
|
||||
|
@ -67,20 +65,16 @@ ifneq ($(ABS_topsrcdir),$(MOZ_BUILD_ROOT))
|
|||
export::
|
||||
rsync -a --exclude .DS_Store --exclude "CVS/" $(srcdir)/$(PROJECT) .
|
||||
ln -fs $(srcdir)/English.lproj
|
||||
ln -fs $(srcdir)/DefaultPluginPrefix.h
|
||||
ln -fs $(srcdir)/NullPlugin.cpp
|
||||
ln -fs $(srcdir)/npmac.cpp
|
||||
ln -fs $(srcdir)/Info-*.plist .
|
||||
ln -fs $(srcdir)/NullPlugin.rsrc
|
||||
ln -fs $(srcdir)/DefaultPlugin.mm
|
||||
ln -fs $(srcdir)/Info.plist
|
||||
ln -fs $(srcdir)/plugin.png
|
||||
|
||||
GARBAGE_DIRS += $(PROJECT)
|
||||
GARBAGE += \
|
||||
English.lproj \
|
||||
DefaultPluginPrefix.h \
|
||||
NullPlugin.cpp \
|
||||
npmac.cpp \
|
||||
Info-*.plist \
|
||||
NullPlugin.rsrc \
|
||||
DefaultPlugin.mm \
|
||||
Info.plist \
|
||||
plugin.png \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
|
@ -89,7 +83,7 @@ GARBAGE_DIRS += build
|
|||
libs install:: install-plugin
|
||||
|
||||
install-plugin: build-plugin
|
||||
$(INSTALL) "$(XCODE_PRODUCT_DIR)/Default Plugin.plugin" $(DIST)/bin/plugins
|
||||
$(INSTALL) "$(XCODE_PRODUCT_DIR)/DefaultPlugin.plugin" $(DIST)/bin/plugins
|
||||
|
||||
build-plugin:
|
||||
$(PBBUILD) $(PROJECT_ARG) -target $(TARGET) -buildstyle $(BUILDSTYLE) $(PBBUILD_ARG)
|
||||
$(PBBUILD) $(PROJECT_ARG) -target $(TARGET) -configuration $(BUILDSTYLE) $(PBBUILD_ARG)
|
||||
|
|
|
@ -1,933 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Josh Aas <josh@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
#include "npapi.h"
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define PLUGINFINDER_COMMAND_BEGINNING "javascript:window.open(\""
|
||||
#define PLUGINFINDER_COMMAND_END "\",\"plugin\",\"toolbar=no,status=no,resizable=no,scrollbars=no,height=252,width=626\");"
|
||||
#define PLUGINFINDER_COMMAND_END2 "\",\"plugin\",\"toolbar=no,status=no,resizable=yes,scrollbars=yes,height=252,width=626\");"
|
||||
|
||||
|
||||
// Instance state information about the plugin.
|
||||
class CPlugin
|
||||
{
|
||||
public:
|
||||
enum HiliteState { kUnhilited = 0, kHilited = 1 };
|
||||
|
||||
static NPError Initialize();
|
||||
static void Shutdown();
|
||||
|
||||
// no ctor because CPlugin is allocated and constructed by hand.
|
||||
// ideally, this should use placement |new|.
|
||||
|
||||
void Constructor(NPP instance, NPMIMEType type, uint16_t mode, int16_t argc, char* argn[], char* argv[]);
|
||||
void Destructor();
|
||||
|
||||
void SetWindow(NPWindow* window);
|
||||
void Print(NPPrint* printInfo);
|
||||
Boolean HandleEvent(EventRecord*);
|
||||
|
||||
protected:
|
||||
void Draw(HiliteState hilite);
|
||||
void DrawString(const unsigned char* text, short width, short height, short centerX, Rect drawRect);
|
||||
void MouseDown();
|
||||
|
||||
Boolean FocusDraw();
|
||||
void RestoreDraw();
|
||||
|
||||
void DetermineURL(int16_t argc, char* argn[], char* argv[]);
|
||||
char* MakeDefaultURL(void);
|
||||
void AddMimeTypeToList(StringPtr cTypeString);
|
||||
Boolean CheckMimeTypes();
|
||||
void AskAndLoadURL();
|
||||
void RefreshPluginPage();
|
||||
|
||||
Ptr New(UInt32 size);
|
||||
void Delete(Ptr ptr);
|
||||
|
||||
Boolean IsPluginHidden(int16_t argc, char* argn[], char* argv[]);
|
||||
|
||||
private:
|
||||
static CIconHandle sIconHandle;
|
||||
static CursHandle sHandCursor;
|
||||
static char* sAltText;
|
||||
static char* sInstallCommand;
|
||||
static char* sDefaultPage;
|
||||
static char* sRefreshText;
|
||||
static char* sJavaScriptPage;
|
||||
|
||||
NPP fInstance;
|
||||
NPWindow* fWindow;
|
||||
uint16_t fMode;
|
||||
NPMIMEType fType;
|
||||
char* fPageURL;
|
||||
char* fFileURL;
|
||||
NPBool m_bOffline;
|
||||
NPBool m_bJavaScript;
|
||||
|
||||
GrafPtr fSavePort;
|
||||
RgnHandle fSaveClip;
|
||||
Rect fRevealedRect;
|
||||
short fSavePortTop;
|
||||
short fSavePortLeft;
|
||||
Boolean fUserInstalledPlugin;
|
||||
Boolean fHiddenPlugin;
|
||||
Boolean fAskedLoadURL;
|
||||
};
|
||||
|
||||
CIconHandle CPlugin::sIconHandle = NULL;
|
||||
CursHandle CPlugin::sHandCursor = NULL;
|
||||
char* CPlugin::sAltText = NULL;
|
||||
char* CPlugin::sInstallCommand = NULL;
|
||||
char* CPlugin::sDefaultPage = NULL;
|
||||
char* CPlugin::sRefreshText = NULL;
|
||||
char* CPlugin::sJavaScriptPage = NULL;
|
||||
|
||||
extern short gResFile;
|
||||
|
||||
// 'cicn'
|
||||
const short rBrokenPluginIcon = 326;
|
||||
|
||||
// 'CURS'
|
||||
const short rHandCursor = 128;
|
||||
|
||||
// 'STR '
|
||||
const short rDefaultPluginURL = 128;
|
||||
const short rAltTextString = 129;
|
||||
const short rJavaScriptInstallCommand = 130;
|
||||
const short rRefreshTextString = 131;
|
||||
const short rJavaScriptPageURL = 132;
|
||||
|
||||
// 'STR#'
|
||||
const short rTypeListStrings = 129;
|
||||
|
||||
static const char szPluginFinderCommandBeginning[] = PLUGINFINDER_COMMAND_BEGINNING;
|
||||
static const char szPluginFinderCommandEnd[] = PLUGINFINDER_COMMAND_END;
|
||||
|
||||
|
||||
NPError NPP_Initialize(void)
|
||||
{
|
||||
return CPlugin::Initialize();
|
||||
}
|
||||
|
||||
|
||||
void NPP_Shutdown(void)
|
||||
{
|
||||
CPlugin::Shutdown();
|
||||
}
|
||||
|
||||
|
||||
NPError NPP_New(NPMIMEType type, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData*)
|
||||
{
|
||||
if (!instance)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin* This = (CPlugin*) (char*)NPN_MemAlloc(sizeof(CPlugin));
|
||||
instance->pdata = This;
|
||||
if (This) {
|
||||
This->Constructor(instance, type, mode, argc, argn, argv);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
else {
|
||||
return NPERR_OUT_OF_MEMORY_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NPError NP_LOADDS
|
||||
NPP_Destroy(NPP instance, NPSavedData** /*save*/)
|
||||
{
|
||||
if (!instance)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin* This = (CPlugin*) instance->pdata;
|
||||
if (This) {
|
||||
This->Destructor();
|
||||
NPN_MemFree(This);
|
||||
instance->pdata = NULL;
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
NPError NPP_SetWindow(NPP instance, NPWindow* window)
|
||||
{
|
||||
if (!instance)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin* This = (CPlugin*) instance->pdata;
|
||||
if (This)
|
||||
This->SetWindow(window);
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
NPError NP_LOADDS
|
||||
NPP_NewStream(NPP instance,
|
||||
NPMIMEType /*type*/,
|
||||
NPStream* /*stream*/,
|
||||
NPBool /*seekable*/,
|
||||
uint16_t* /*stype*/)
|
||||
{
|
||||
if (!instance)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
int32_t STREAMBUFSIZE = 0X0FFFFFFF; // If we are reading from a file in NPAsFile
|
||||
// mode so we can take any size stream in our
|
||||
// write call (since we ignore it)
|
||||
|
||||
|
||||
int32_t NP_LOADDS
|
||||
NPP_WriteReady(NPP /*instance*/, NPStream* /*stream*/)
|
||||
{
|
||||
return STREAMBUFSIZE; // Number of bytes ready to accept in NPP_Write()
|
||||
}
|
||||
|
||||
|
||||
int32_t NP_LOADDS
|
||||
NPP_Write(NPP /*instance*/, NPStream* /*stream*/, int32_t /*offset*/, int32_t len, void* /*buffer*/)
|
||||
{
|
||||
return len; // The number of bytes accepted
|
||||
}
|
||||
|
||||
|
||||
NPError NP_LOADDS
|
||||
NPP_DestroyStream(NPP instance, NPStream* /*stream*/, NPError /*reason*/)
|
||||
{
|
||||
if (!instance)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
void NP_LOADDS
|
||||
NPP_StreamAsFile(NPP /*instance*/, NPStream */*stream*/, const char* /*fname*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NP_LOADDS
|
||||
NPP_Print(NPP instance, NPPrint* printInfo)
|
||||
{
|
||||
if (!printInfo)
|
||||
return;
|
||||
|
||||
if (instance) {
|
||||
if (printInfo->mode == NP_FULL) {
|
||||
printInfo->print.fullPrint.pluginPrinted = FALSE; // Do the default
|
||||
}
|
||||
else { // If not fullscreen, we must be embedded
|
||||
CPlugin* This = (CPlugin*)instance->pdata;
|
||||
if (This)
|
||||
This->Print(printInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Mac-only
|
||||
int16_t NPP_HandleEvent(NPP instance, void* event)
|
||||
{
|
||||
if (instance) {
|
||||
CPlugin* This = (CPlugin*) instance->pdata;
|
||||
if (This && event)
|
||||
return This->HandleEvent((EventRecord*) event);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
void NPP_URLNotify(NPP /*instance*/, const char* /*url*/, NPReason /*reason*/, void* /*notifyData*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NPError CPlugin::Initialize()
|
||||
{
|
||||
Handle string;
|
||||
short saveResFile = CurResFile();
|
||||
|
||||
UseResFile(gResFile);
|
||||
|
||||
// Get Resources
|
||||
CPlugin::sIconHandle = GetCIcon(rBrokenPluginIcon);
|
||||
CPlugin::sHandCursor = GetCursor(rHandCursor);
|
||||
|
||||
// Get "alt text" string
|
||||
string = Get1Resource('STR ', rAltTextString);
|
||||
if (string && *string) {
|
||||
short stringLen = (*string)[0];
|
||||
CPlugin::sAltText = (char*)NPN_MemAlloc(stringLen +1);
|
||||
if (CPlugin::sAltText) {
|
||||
short src = 1;
|
||||
short dest = 0;
|
||||
while (src <= stringLen)
|
||||
CPlugin::sAltText[dest++] = (*string)[src++];
|
||||
CPlugin::sAltText[dest++] = 0;
|
||||
}
|
||||
}
|
||||
ReleaseResource(string);
|
||||
|
||||
// Get "refresh text" string
|
||||
string = Get1Resource('STR ', rRefreshTextString);
|
||||
if (string && *string) {
|
||||
short stringLen = (*string)[0];
|
||||
CPlugin::sRefreshText = (char*)NPN_MemAlloc(stringLen + 1);
|
||||
if (CPlugin::sRefreshText) {
|
||||
short src = 1;
|
||||
short dest = 0;
|
||||
while (src <= stringLen)
|
||||
CPlugin::sRefreshText[dest++] = (*string)[src++];
|
||||
CPlugin::sRefreshText[dest++] = 0;
|
||||
}
|
||||
}
|
||||
ReleaseResource(string);
|
||||
|
||||
// Get JavaScript install command string
|
||||
string = Get1Resource('STR ', rJavaScriptInstallCommand);
|
||||
if (string && *string) {
|
||||
short stringLen = (*string)[0];
|
||||
CPlugin::sInstallCommand = (char*)NPN_MemAlloc(stringLen + 1);
|
||||
if (CPlugin::sInstallCommand) {
|
||||
short src = 1;
|
||||
short dest = 0;
|
||||
while (src <= stringLen)
|
||||
CPlugin::sInstallCommand[dest++] = (*string)[src++];
|
||||
CPlugin::sInstallCommand[dest++] = 0;
|
||||
}
|
||||
}
|
||||
ReleaseResource(string);
|
||||
|
||||
// Get default plug-in page URL
|
||||
string = Get1Resource('STR ', rDefaultPluginURL);
|
||||
if (string && *string) {
|
||||
short stringLen = (*string)[0];
|
||||
CPlugin::sDefaultPage = (char*)NPN_MemAlloc(stringLen + 1);
|
||||
if (CPlugin::sDefaultPage) {
|
||||
short src = 1;
|
||||
short dest = 0;
|
||||
while (src <= stringLen)
|
||||
CPlugin::sDefaultPage[dest++] = (*string)[src++];
|
||||
CPlugin::sDefaultPage[dest++] = 0;
|
||||
}
|
||||
}
|
||||
ReleaseResource(string);
|
||||
|
||||
// Get javascript plug-in page URL
|
||||
string = Get1Resource('STR ', rJavaScriptPageURL);
|
||||
if (string && *string) {
|
||||
short stringLen = (*string)[0];
|
||||
CPlugin::sJavaScriptPage = (char*)NPN_MemAlloc(stringLen + 1);
|
||||
if (CPlugin::sJavaScriptPage) {
|
||||
short src = 1;
|
||||
short dest = 0;
|
||||
while (src <= stringLen)
|
||||
CPlugin::sJavaScriptPage[dest++] = (*string)[src++];
|
||||
CPlugin::sJavaScriptPage[dest++] = 0;
|
||||
}
|
||||
}
|
||||
ReleaseResource(string);
|
||||
|
||||
UseResFile(saveResFile);
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
void CPlugin::Shutdown()
|
||||
{
|
||||
if (CPlugin::sIconHandle)
|
||||
::ReleaseResource((Handle) CPlugin::sIconHandle);
|
||||
if (CPlugin::sHandCursor)
|
||||
::ReleaseResource((Handle) CPlugin::sHandCursor);
|
||||
|
||||
if (CPlugin::sAltText)
|
||||
NPN_MemFree(CPlugin::sAltText);
|
||||
if (CPlugin::sInstallCommand)
|
||||
NPN_MemFree(CPlugin::sInstallCommand);
|
||||
if (CPlugin::sDefaultPage)
|
||||
NPN_MemFree(CPlugin::sDefaultPage);
|
||||
if (CPlugin::sRefreshText)
|
||||
NPN_MemFree(CPlugin::sRefreshText);
|
||||
}
|
||||
|
||||
|
||||
void CPlugin::Constructor(NPP instance, NPMIMEType type, uint16_t mode, int16_t argc, char* argn[], char* argv[])
|
||||
{
|
||||
fWindow = NULL;
|
||||
fPageURL = NULL;
|
||||
fFileURL = NULL;
|
||||
fInstance = instance;
|
||||
fMode = mode; // Mode is NP_EMBED, NP_FULL, or NP_BACKGROUND (see npapi.h)
|
||||
fAskedLoadURL = false;
|
||||
fUserInstalledPlugin = false;
|
||||
|
||||
// Save a copy of our mime type string
|
||||
short typeLength = strlen(type);
|
||||
fType = (char*)NPN_MemAlloc(typeLength+1);
|
||||
if (fType)
|
||||
strcpy(fType, type);
|
||||
|
||||
// Make a handy region for use in FocusDraw
|
||||
fSaveClip = NewRgn();
|
||||
|
||||
// determine if the plugin is specified as HIDDEN
|
||||
fHiddenPlugin = IsPluginHidden(argc, argn, argv);
|
||||
|
||||
// Get some information about our environment
|
||||
NPN_GetValue(fInstance, NPNVisOfflineBool, (void *)&m_bOffline);
|
||||
NPN_GetValue(fInstance, NPNVjavascriptEnabledBool, (void *)&m_bJavaScript);
|
||||
|
||||
// Figure out what URL we will go to
|
||||
DetermineURL(argc, argn, argv);
|
||||
}
|
||||
|
||||
|
||||
void CPlugin::Destructor()
|
||||
{
|
||||
if (fSaveClip)
|
||||
DisposeRgn(fSaveClip);
|
||||
|
||||
if (fType)
|
||||
NPN_MemFree(fType);
|
||||
if (fFileURL)
|
||||
NPN_MemFree(fFileURL);
|
||||
if (fPageURL)
|
||||
NPN_MemFree(fPageURL);
|
||||
}
|
||||
|
||||
|
||||
void CPlugin::SetWindow(NPWindow* window)
|
||||
{
|
||||
fWindow = window;
|
||||
}
|
||||
|
||||
|
||||
// To print, we need to retrieve the printing window from the printInfo,
|
||||
// temporarily make it our window, draw into it, and restore the window.
|
||||
void CPlugin::Print(NPPrint* printInfo)
|
||||
{
|
||||
NPWindow* printWindow = &(printInfo->print.embedPrint.window);
|
||||
|
||||
NPWindow* oldWindow = fWindow;
|
||||
fWindow = printWindow;
|
||||
|
||||
if (FocusDraw()) {
|
||||
Draw(kUnhilited);
|
||||
RestoreDraw();
|
||||
}
|
||||
|
||||
fWindow = oldWindow;
|
||||
}
|
||||
|
||||
|
||||
Boolean CPlugin::HandleEvent(EventRecord* ev)
|
||||
{
|
||||
Boolean eventHandled = false;
|
||||
|
||||
switch (ev->what)
|
||||
{
|
||||
case mouseDown:
|
||||
MouseDown();
|
||||
eventHandled = true;
|
||||
break;
|
||||
|
||||
case updateEvt:
|
||||
if (FocusDraw()) {
|
||||
Draw(kUnhilited);
|
||||
RestoreDraw();
|
||||
}
|
||||
eventHandled = true;
|
||||
break;
|
||||
|
||||
case NPEventType_AdjustCursorEvent:
|
||||
if (CPlugin::sHandCursor)
|
||||
SetCursor(*CPlugin::sHandCursor);
|
||||
if (fUserInstalledPlugin) {
|
||||
if (CPlugin::sRefreshText)
|
||||
NPN_Status(fInstance, CPlugin::sRefreshText);
|
||||
}
|
||||
else {
|
||||
if (CPlugin::sAltText)
|
||||
NPN_Status(fInstance, CPlugin::sAltText);
|
||||
}
|
||||
eventHandled = true;
|
||||
break;
|
||||
|
||||
case nullEvent:
|
||||
// NOTE: We have to wait until idle time
|
||||
// to ask the user if they want to visit
|
||||
// the URL to avoid reentering XP code.
|
||||
if (!fAskedLoadURL) {
|
||||
if (CheckMimeTypes())
|
||||
AskAndLoadURL();
|
||||
fAskedLoadURL = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return eventHandled;
|
||||
}
|
||||
|
||||
|
||||
void CPlugin::Draw(HiliteState hilite)
|
||||
{
|
||||
UInt8 *pTheText;
|
||||
SInt32 height = fWindow->height;
|
||||
SInt32 width = fWindow->width;
|
||||
SInt32 centerX = (width) >> 1;
|
||||
SInt32 centerY = (height) >> 1;
|
||||
Rect drawRect;
|
||||
RGBColor black = { 0x0000, 0x0000, 0x0000 };
|
||||
RGBColor white = { 0xFFFF, 0xFFFF, 0xFFFF };
|
||||
RGBColor hiliteColor = { 0x0000, 0x0000, 0x0000 };
|
||||
short transform;
|
||||
|
||||
drawRect.top = 0;
|
||||
drawRect.left = 0;
|
||||
drawRect.bottom = height;
|
||||
drawRect.right = width;
|
||||
|
||||
if (height < 4 && width < 4)
|
||||
return;
|
||||
|
||||
PenNormal();
|
||||
RGBForeColor(&black);
|
||||
RGBBackColor(&white);
|
||||
|
||||
Pattern qdWhite;
|
||||
FillRect(&drawRect, GetQDGlobalsWhite(&qdWhite));
|
||||
|
||||
if (hilite == kHilited) {
|
||||
hiliteColor.red = 0xFFFF;
|
||||
transform = ttSelected;
|
||||
}
|
||||
else {
|
||||
hiliteColor.blue = 0xFFFF;
|
||||
transform = ttNone;
|
||||
}
|
||||
|
||||
RGBForeColor(&hiliteColor);
|
||||
FrameRect(&drawRect);
|
||||
|
||||
if (height > 32 && width > 32 && CPlugin::sIconHandle) {
|
||||
drawRect.top = centerY - 16;
|
||||
drawRect.bottom = centerY + 16;
|
||||
drawRect.left = centerX - 16;
|
||||
drawRect.right = centerX + 16;
|
||||
PlotCIconHandle(&drawRect, atAbsoluteCenter, transform, CPlugin::sIconHandle);
|
||||
}
|
||||
|
||||
if (fUserInstalledPlugin) {
|
||||
pTheText = (unsigned char*)CPlugin::sRefreshText;
|
||||
}
|
||||
else {
|
||||
pTheText = (unsigned char*)CPlugin::sAltText;
|
||||
}
|
||||
DrawString(pTheText, width, height, centerX, drawRect);
|
||||
}
|
||||
|
||||
|
||||
// Track the click in our plugin by drawing the icon enabled or disabled
|
||||
// as the user moves the mouse in and out with the button held down. If
|
||||
// they let up the mouse while still inside, get the URL.
|
||||
void CPlugin::MouseDown()
|
||||
{
|
||||
if (FocusDraw()) {
|
||||
Draw(kHilited);
|
||||
Boolean inside = true;
|
||||
|
||||
// evil CPU-hogging loop on Mac OS X!
|
||||
while (StillDown()) {
|
||||
Point localMouse;
|
||||
GetMouse(&localMouse);
|
||||
Boolean insideNow = ::PtInRect(localMouse, &fRevealedRect);
|
||||
|
||||
if (insideNow != inside) {
|
||||
Draw(insideNow ? kHilited : kUnhilited);
|
||||
inside = insideNow;
|
||||
}
|
||||
}
|
||||
|
||||
if (inside) {
|
||||
Draw(kUnhilited);
|
||||
if (!fUserInstalledPlugin)
|
||||
AskAndLoadURL();
|
||||
else
|
||||
RefreshPluginPage();
|
||||
}
|
||||
|
||||
RestoreDraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Boolean CPlugin::FocusDraw()
|
||||
{
|
||||
if (!fWindow)
|
||||
return false;
|
||||
|
||||
NP_Port* npport = (NP_Port*) fWindow->window;
|
||||
CGrafPtr ourPort = npport->port;
|
||||
|
||||
if (fWindow->clipRect.left < fWindow->clipRect.right) {
|
||||
GetPort(&fSavePort);
|
||||
SetPort((GrafPtr) ourPort);
|
||||
Rect portRect;
|
||||
GetPortBounds(ourPort, &portRect);
|
||||
fSavePortTop = portRect.top;
|
||||
fSavePortLeft = portRect.left;
|
||||
GetClip(fSaveClip);
|
||||
|
||||
fRevealedRect.top = fWindow->clipRect.top + npport->porty;
|
||||
fRevealedRect.left = fWindow->clipRect.left + npport->portx;
|
||||
fRevealedRect.bottom = fWindow->clipRect.bottom + npport->porty;
|
||||
fRevealedRect.right = fWindow->clipRect.right + npport->portx;
|
||||
SetOrigin(npport->portx, npport->porty);
|
||||
ClipRect(&fRevealedRect);
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CPlugin::RestoreDraw()
|
||||
{
|
||||
SetOrigin(fSavePortLeft, fSavePortTop);
|
||||
SetClip(fSaveClip);
|
||||
SetPort(fSavePort);
|
||||
}
|
||||
|
||||
|
||||
// Get a URL from either the parameters passed from the EMBED.
|
||||
// Append "?" and our mime type and save for later use.
|
||||
void CPlugin::DetermineURL(int16_t argc, char* argn[], char* argv[])
|
||||
{
|
||||
char* url;
|
||||
SInt32 additionalLength = 0;
|
||||
SInt32 i;
|
||||
|
||||
// Appended to the URL will be a "?" and the mime type of this instance. This lets the server
|
||||
// do something intelligent with a CGI script.
|
||||
|
||||
if (fType)
|
||||
additionalLength += (strlen(fType) + 1); // Add 1 for '?'
|
||||
|
||||
// The page designer can specify a URL where the plugin for this type can be downloaded. Here
|
||||
// we scan the arguments for this attribute and save it away if we
|
||||
// find it for later use by LoadPluginURL().
|
||||
for (i = 0; i < argc; i++) {
|
||||
if ((strcasecmp(argn[i], "PLUGINSPAGE") == 0) || (strcasecmp(argn[i], "CODEBASE") == 0)) {
|
||||
url = argv[i];
|
||||
fPageURL = (char*)NPN_MemAlloc(strlen(url) + 1 + additionalLength); // Add 1 for '\0'
|
||||
if (fPageURL) {
|
||||
if (additionalLength > 0) {
|
||||
sprintf(fPageURL, "%s?%s", url, fType);
|
||||
}
|
||||
else {
|
||||
strcpy(fPageURL, url);
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else if ((strcasecmp(argn[i], "PLUGINURL") == 0) || (strcasecmp(argn[i], "CLASSID") == 0)) {
|
||||
url = argv[i];
|
||||
if (CPlugin::sInstallCommand) {
|
||||
// Allocate a new string
|
||||
fFileURL = (char*)NPN_MemAlloc(strlen(CPlugin::sInstallCommand) + 1 + strlen(url));
|
||||
if (fFileURL)
|
||||
sprintf(fFileURL, CPlugin::sInstallCommand, url);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Get a URL from our resources. Append "?" and our mime type and save for later use.
|
||||
char *CPlugin::MakeDefaultURL(void)
|
||||
{
|
||||
char *pDefURL = NULL;
|
||||
SInt32 additionalLength = 0;
|
||||
|
||||
// Appended to the URL will be a "?" and the mime type of this instance. This lets the server
|
||||
// do something intelligent with a CGI script.
|
||||
|
||||
if (fType)
|
||||
additionalLength += (strlen(fType) + 1); // Add 1 for '?'
|
||||
|
||||
if (!m_bJavaScript) {
|
||||
if (CPlugin::sDefaultPage) {
|
||||
pDefURL = (char*)NPN_MemAlloc(strlen(CPlugin::sDefaultPage) + 1 + additionalLength);
|
||||
if (pDefURL) {
|
||||
if (additionalLength > 0) {
|
||||
sprintf(pDefURL, "%s?%s", CPlugin::sDefaultPage, fType);
|
||||
}
|
||||
else {
|
||||
strcpy(pDefURL, CPlugin::sDefaultPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (CPlugin::sJavaScriptPage) {
|
||||
pDefURL = (char*)NPN_MemAlloc(strlen(szPluginFinderCommandBeginning) +
|
||||
strlen(CPlugin::sJavaScriptPage) +
|
||||
additionalLength + strlen(szPluginFinderCommandEnd) + 1);
|
||||
if (pDefURL) {
|
||||
sprintf(pDefURL, "%s%s%s%s", szPluginFinderCommandBeginning,
|
||||
CPlugin::sJavaScriptPage, fType, szPluginFinderCommandEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(pDefURL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check the mime type of this instance against our list
|
||||
// of types weÕve seen before. If we find our type in the
|
||||
// list, return false; otherwise, return true.
|
||||
//
|
||||
// type 'STR#' {
|
||||
// integer = $$Countof(StringArray);
|
||||
// array StringArray {
|
||||
// pstring;
|
||||
// };
|
||||
void CPlugin::AddMimeTypeToList(StringPtr cTypeString)
|
||||
{
|
||||
CFStringRef pluginKey = CFSTR("DefaultPluginSeenTypes"); // don't release this
|
||||
CFStringRef mimeType = ::CFStringCreateWithPascalString(kCFAllocatorDefault, cTypeString, kCFStringEncodingASCII);
|
||||
CFArrayRef prefsList = (CFArrayRef)::CFPreferencesCopyAppValue(pluginKey, kCFPreferencesCurrentApplication);
|
||||
Boolean foundType = false;
|
||||
|
||||
if (!prefsList) {
|
||||
CFStringRef stringArray[1];
|
||||
stringArray[0] = mimeType;
|
||||
|
||||
prefsList = ::CFArrayCreate(kCFAllocatorDefault, (const void **)stringArray, 1, &kCFTypeArrayCallBacks);
|
||||
if (prefsList) {
|
||||
::CFPreferencesSetAppValue(pluginKey, prefsList, kCFPreferencesCurrentApplication);
|
||||
::CFRelease(prefsList);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (::CFGetTypeID(prefsList) == ::CFArrayGetTypeID()) {
|
||||
// first make sure it's not in the list
|
||||
CFIndex count = ::CFArrayGetCount(prefsList);
|
||||
for (CFIndex i = 0; i < count; i ++) {
|
||||
CFStringRef item = (CFStringRef)::CFArrayGetValueAtIndex(prefsList, i); // does not retain
|
||||
if (item && (::CFGetTypeID(item) == ::CFStringGetTypeID()) &&
|
||||
(::CFStringCompareWithOptions(item, mimeType,
|
||||
CFRangeMake(0, ::CFStringGetLength(item)), kCFCompareCaseInsensitive) == kCFCompareEqualTo)) {
|
||||
foundType = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundType && !fHiddenPlugin) {
|
||||
CFMutableArrayRef typesArray = ::CFArrayCreateMutableCopy(kCFAllocatorDefault, 0, (CFArrayRef)prefsList);
|
||||
if (typesArray) {
|
||||
::CFArrayAppendValue(typesArray, mimeType);
|
||||
::CFPreferencesSetAppValue(pluginKey, typesArray, kCFPreferencesCurrentApplication);
|
||||
}
|
||||
}
|
||||
}
|
||||
::CFRelease(prefsList);
|
||||
}
|
||||
::CFRelease(mimeType);
|
||||
}
|
||||
|
||||
|
||||
// Check the mime type of this instance against our list
|
||||
// of types weÕve seen before. If we find our type in the
|
||||
// list, return false; otherwise, return true.
|
||||
//
|
||||
// type 'STR#' {
|
||||
// integer = $$Countof(StringArray);
|
||||
// array StringArray {
|
||||
// pstring;
|
||||
// };
|
||||
Boolean CPlugin::CheckMimeTypes()
|
||||
{
|
||||
Boolean failedToFind = true;
|
||||
|
||||
CFStringRef pluginKey = CFSTR("DefaultPluginSeenTypes"); // don't release this
|
||||
CFStringRef mimeType = ::CFStringCreateWithCString(kCFAllocatorDefault, fType, kCFStringEncodingASCII);
|
||||
CFArrayRef prefsList = (CFArrayRef)::CFPreferencesCopyAppValue(pluginKey, kCFPreferencesCurrentApplication);
|
||||
if (prefsList) {
|
||||
if (::CFGetTypeID(prefsList) == ::CFArrayGetTypeID()) {
|
||||
CFIndex count = ::CFArrayGetCount(prefsList);
|
||||
for (CFIndex i = 0; i < count; i ++) {
|
||||
CFStringRef item = (CFStringRef)::CFArrayGetValueAtIndex(prefsList, i); // does not retain
|
||||
if (item &&
|
||||
(::CFGetTypeID(item) == ::CFStringGetTypeID()) &&
|
||||
(::CFStringCompareWithOptions(item, mimeType,
|
||||
CFRangeMake(0, ::CFStringGetLength(item)), kCFCompareCaseInsensitive) == kCFCompareEqualTo)) {
|
||||
failedToFind = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
::CFRelease(prefsList);
|
||||
}
|
||||
::CFRelease(mimeType);
|
||||
return failedToFind;
|
||||
}
|
||||
|
||||
|
||||
void CPlugin::AskAndLoadURL()
|
||||
{
|
||||
char *pTheURL;
|
||||
SInt32 dwLen;
|
||||
Str255 ourType;
|
||||
|
||||
if (!m_bOffline) {
|
||||
// Convert the mime-type C string to a Pascal string.
|
||||
dwLen = strlen(fType);
|
||||
if (dwLen > 255) { // don't blow out the Str255
|
||||
dwLen = 255;
|
||||
}
|
||||
BlockMoveData(fType, &ourType[1], dwLen);
|
||||
ourType[0] = dwLen;
|
||||
|
||||
// NOTE: We need to set the cursor because almost always we will have set it to the
|
||||
// hand cursor before we get here.
|
||||
Cursor qdArrow;
|
||||
SetCursor(GetQDGlobalsArrow(&qdArrow));
|
||||
|
||||
// Now that weÕve queried the user about this mime type,
|
||||
// add it to our list so we wonÕt bug them again.
|
||||
AddMimeTypeToList(ourType);
|
||||
|
||||
// If the user clicked "Get the Plug-in", either execute the
|
||||
// JavaScript file-installation URL, or ask Netscape to open
|
||||
// a new window with the page URL. The title of the window
|
||||
// is arbitrary since it has nothing to do with the actual
|
||||
// window title shown to the user (itÕs only used internally).
|
||||
NPN_PushPopupsEnabledState(fInstance, true);
|
||||
|
||||
if (fFileURL) {
|
||||
(void) NPN_GetURL(fInstance, fFileURL, "_current");
|
||||
}
|
||||
else if (fPageURL) {
|
||||
NPN_GetURL(fInstance, fPageURL, "_blank");
|
||||
}
|
||||
else {
|
||||
pTheURL = MakeDefaultURL();
|
||||
if (!m_bJavaScript)
|
||||
NPN_GetURL(fInstance, pTheURL, "_blank");
|
||||
else
|
||||
NPN_GetURL(fInstance, pTheURL, NULL);
|
||||
NPN_MemFree(pTheURL);
|
||||
}
|
||||
|
||||
NPN_PopPopupsEnabledState(fInstance);
|
||||
|
||||
fUserInstalledPlugin = true;
|
||||
if (FocusDraw()) {
|
||||
Draw(kUnhilited);
|
||||
RestoreDraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CPlugin::RefreshPluginPage()
|
||||
{
|
||||
(void)NPN_GetURL(fInstance, "javascript:navigator.plugins.refresh(true);", "_self");
|
||||
}
|
||||
|
||||
|
||||
void CPlugin::DrawString(const unsigned char* text, short width, short height, short centerX, Rect drawRect)
|
||||
{
|
||||
short length, textHeight, textWidth;
|
||||
|
||||
if (!text)
|
||||
return;
|
||||
|
||||
length = strlen((char*)text);
|
||||
TextFont(20);
|
||||
TextFace(underline);
|
||||
TextMode(srcCopy);
|
||||
TextSize(10);
|
||||
|
||||
FontInfo fontInfo;
|
||||
GetFontInfo(&fontInfo);
|
||||
|
||||
textHeight = fontInfo.ascent + fontInfo.descent + fontInfo.leading;
|
||||
textWidth = TextWidth(text, 0, length);
|
||||
|
||||
if (width > textWidth && height > textHeight + 32) {
|
||||
MoveTo(centerX - (textWidth >> 1), drawRect.bottom + textHeight);
|
||||
DrawText(text, 0, length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Boolean CPlugin::IsPluginHidden(int16_t argc, char* argn[], char* argv[])
|
||||
{
|
||||
for (int i = 0; i < argc; i++) {
|
||||
if (!strcasecmp(argn[i], "HIDDEN")) {
|
||||
if (!strcasecmp(argv[i], "TRUE"))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
Двоичные данные
modules/plugin/default/mac/NullPlugin.rsrc
Двоичные данные
modules/plugin/default/mac/NullPlugin.rsrc
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 1.8 KiB |
|
@ -1,524 +0,0 @@
|
|||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
//
|
||||
// npmac.cpp
|
||||
//
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
#include "npapi.h"
|
||||
#include "npfunctions.h"
|
||||
|
||||
//
|
||||
// Define PLUGIN_TRACE to 1 to have the wrapper functions emit
|
||||
// DebugStr messages whenever they are called.
|
||||
//
|
||||
//#define PLUGIN_TRACE 1
|
||||
|
||||
#if PLUGIN_TRACE
|
||||
#define PLUGINDEBUGSTR(msg) ::DebugStr(msg)
|
||||
#else
|
||||
#define PLUGINDEBUGSTR(msg) ((void) 0)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __ppc__
|
||||
|
||||
// glue for mapping outgoing Macho function pointers to TVectors
|
||||
struct TFPtoTVGlue{
|
||||
void* glue[2];
|
||||
};
|
||||
|
||||
struct pluginFuncsGlueTable {
|
||||
TFPtoTVGlue newp;
|
||||
TFPtoTVGlue destroy;
|
||||
TFPtoTVGlue setwindow;
|
||||
TFPtoTVGlue newstream;
|
||||
TFPtoTVGlue destroystream;
|
||||
TFPtoTVGlue asfile;
|
||||
TFPtoTVGlue writeready;
|
||||
TFPtoTVGlue write;
|
||||
TFPtoTVGlue print;
|
||||
TFPtoTVGlue event;
|
||||
TFPtoTVGlue urlnotify;
|
||||
TFPtoTVGlue getvalue;
|
||||
TFPtoTVGlue setvalue;
|
||||
|
||||
TFPtoTVGlue shutdown;
|
||||
} gPluginFuncsGlueTable;
|
||||
|
||||
static inline void* SetupFPtoTVGlue(TFPtoTVGlue* functionGlue, void* fp)
|
||||
{
|
||||
functionGlue->glue[0] = fp;
|
||||
functionGlue->glue[1] = 0;
|
||||
return functionGlue;
|
||||
}
|
||||
|
||||
#define PLUGIN_TO_HOST_GLUE(name, fp) (SetupFPtoTVGlue(&gPluginFuncsGlueTable.name, (void*)fp))
|
||||
|
||||
// glue for mapping netscape TVectors to Macho function pointers
|
||||
struct TTVtoFPGlue {
|
||||
uint32_t glue[6];
|
||||
};
|
||||
|
||||
struct netscapeFuncsGlueTable {
|
||||
TTVtoFPGlue geturl;
|
||||
TTVtoFPGlue posturl;
|
||||
TTVtoFPGlue requestread;
|
||||
TTVtoFPGlue newstream;
|
||||
TTVtoFPGlue write;
|
||||
TTVtoFPGlue destroystream;
|
||||
TTVtoFPGlue status;
|
||||
TTVtoFPGlue uagent;
|
||||
TTVtoFPGlue memalloc;
|
||||
TTVtoFPGlue memfree;
|
||||
TTVtoFPGlue memflush;
|
||||
TTVtoFPGlue reloadplugins;
|
||||
TTVtoFPGlue getJavaEnv;
|
||||
TTVtoFPGlue getJavaPeer;
|
||||
TTVtoFPGlue geturlnotify;
|
||||
TTVtoFPGlue posturlnotify;
|
||||
TTVtoFPGlue getvalue;
|
||||
TTVtoFPGlue setvalue;
|
||||
TTVtoFPGlue invalidaterect;
|
||||
TTVtoFPGlue invalidateregion;
|
||||
TTVtoFPGlue forceredraw;
|
||||
TTVtoFPGlue pushpopupsenabledstate;
|
||||
TTVtoFPGlue poppopupsenabledstate;
|
||||
} gNetscapeFuncsGlueTable;
|
||||
|
||||
static void* SetupTVtoFPGlue(TTVtoFPGlue* functionGlue, void* tvp)
|
||||
{
|
||||
static const TTVtoFPGlue glueTemplate = { 0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420 };
|
||||
|
||||
memcpy(functionGlue, &glueTemplate, sizeof(TTVtoFPGlue));
|
||||
functionGlue->glue[0] |= ((UInt32)tvp >> 16);
|
||||
functionGlue->glue[1] |= ((UInt32)tvp & 0xFFFF);
|
||||
::MakeDataExecutable(functionGlue, sizeof(TTVtoFPGlue));
|
||||
return functionGlue;
|
||||
}
|
||||
|
||||
#define HOST_TO_PLUGIN_GLUE(name, fp) (SetupTVtoFPGlue(&gNetscapeFuncsGlueTable.name, (void*)fp))
|
||||
|
||||
#else
|
||||
|
||||
#define PLUGIN_TO_HOST_GLUE(name, fp) (fp)
|
||||
#define HOST_TO_PLUGIN_GLUE(name, fp) (fp)
|
||||
|
||||
#endif /* __ppc__ */
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
short gResFile; // Refnum of the pluginÕs resource file
|
||||
NPNetscapeFuncs gNetscapeFuncs; // Function table for procs in Netscape called by plugin
|
||||
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
//
|
||||
// Wrapper functions for all calls from the plugin to Netscape.
|
||||
// These functions let the plugin developer just call the APIs
|
||||
// as documented and defined in npapi.h.
|
||||
//
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
|
||||
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 = gNetscapeFuncs.version >> 8; // Major version is in high byte
|
||||
*netscape_minor = gNetscapeFuncs.version & 0xFF; // Minor version is in low byte
|
||||
}
|
||||
|
||||
NPError NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData)
|
||||
{
|
||||
int navMinorVers = gNetscapeFuncs.version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
|
||||
{
|
||||
err = (*gNetscapeFuncs.geturlnotify)(instance, url, window, notifyData);
|
||||
}
|
||||
else
|
||||
{
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
NPError NPN_GetURL(NPP instance, const char* url, const char* window)
|
||||
{
|
||||
return (*gNetscapeFuncs.geturl)(instance, url, window);
|
||||
}
|
||||
|
||||
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file, void* notifyData)
|
||||
{
|
||||
int navMinorVers = gNetscapeFuncs.version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
|
||||
{
|
||||
err = (*gNetscapeFuncs.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_t len, const char* buf, NPBool file)
|
||||
{
|
||||
return (*gNetscapeFuncs.posturl)(instance, url, window, len, buf, file);
|
||||
}
|
||||
|
||||
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
|
||||
{
|
||||
return (*gNetscapeFuncs.requestread)(stream, rangeList);
|
||||
}
|
||||
|
||||
NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* window, NPStream** stream)
|
||||
{
|
||||
int navMinorVers = gNetscapeFuncs.version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
|
||||
{
|
||||
err = (*gNetscapeFuncs.newstream)(instance, type, window, stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
int32_t NPN_Write(NPP instance, NPStream* stream, int32_t len, void* buffer)
|
||||
{
|
||||
int navMinorVers = gNetscapeFuncs.version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
|
||||
{
|
||||
err = (*gNetscapeFuncs.write)(instance, stream, len, buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
int navMinorVers = gNetscapeFuncs.version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
|
||||
{
|
||||
err = (*gNetscapeFuncs.destroystream)(instance, stream, reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
void NPN_Status(NPP instance, const char* message)
|
||||
{
|
||||
(*gNetscapeFuncs.status)(instance, message);
|
||||
}
|
||||
|
||||
const char* NPN_UserAgent(NPP instance)
|
||||
{
|
||||
return (*gNetscapeFuncs.uagent)(instance);
|
||||
}
|
||||
|
||||
void* NPN_MemAlloc(uint32_t size)
|
||||
{
|
||||
return (*gNetscapeFuncs.memalloc)(size);
|
||||
}
|
||||
|
||||
void NPN_MemFree(void* ptr)
|
||||
{
|
||||
(*gNetscapeFuncs.memfree)(ptr);
|
||||
}
|
||||
|
||||
uint32_t NPN_MemFlush(uint32_t size)
|
||||
{
|
||||
return (*gNetscapeFuncs.memflush)(size);
|
||||
}
|
||||
|
||||
void NPN_ReloadPlugins(NPBool reloadPages)
|
||||
{
|
||||
(*gNetscapeFuncs.reloadplugins)(reloadPages);
|
||||
}
|
||||
|
||||
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
|
||||
{
|
||||
return (*gNetscapeFuncs.getvalue)(instance, variable, value);
|
||||
}
|
||||
|
||||
NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
|
||||
{
|
||||
return (*gNetscapeFuncs.setvalue)(instance, variable, value);
|
||||
}
|
||||
|
||||
void NPN_InvalidateRect(NPP instance, NPRect *rect)
|
||||
{
|
||||
(*gNetscapeFuncs.invalidaterect)(instance, rect);
|
||||
}
|
||||
|
||||
void NPN_InvalidateRegion(NPP instance, NPRegion region)
|
||||
{
|
||||
(*gNetscapeFuncs.invalidateregion)(instance, region);
|
||||
}
|
||||
|
||||
void NPN_ForceRedraw(NPP instance)
|
||||
{
|
||||
(*gNetscapeFuncs.forceredraw)(instance);
|
||||
}
|
||||
|
||||
void NPN_PushPopupsEnabledState(NPP instance, NPBool enabled)
|
||||
{
|
||||
(*gNetscapeFuncs.pushpopupsenabledstate)(instance, enabled);
|
||||
}
|
||||
|
||||
void NPN_PopPopupsEnabledState(NPP instance)
|
||||
{
|
||||
(*gNetscapeFuncs.poppopupsenabledstate)(instance);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
//
|
||||
// Wrapper functions for all calls from Netscape to the plugin.
|
||||
// These functions let the plugin developer just create the APIs
|
||||
// as documented and defined in npapi.h, without needing to
|
||||
// install those functions in the function table or worry about
|
||||
// setting up globals for 68K plugins.
|
||||
//
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
NPError Private_Initialize(void);
|
||||
void Private_Shutdown(void);
|
||||
NPError Private_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved);
|
||||
NPError Private_Destroy(NPP instance, NPSavedData** save);
|
||||
NPError Private_SetWindow(NPP instance, NPWindow* window);
|
||||
NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype);
|
||||
NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason);
|
||||
int32_t Private_WriteReady(NPP instance, NPStream* stream);
|
||||
int32_t Private_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer);
|
||||
void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
|
||||
void Private_Print(NPP instance, NPPrint* platformPrint);
|
||||
int16_t Private_HandleEvent(NPP instance, void* event);
|
||||
void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData);
|
||||
|
||||
|
||||
NPError Private_Initialize(void)
|
||||
{
|
||||
PLUGINDEBUGSTR("\pInitialize;g;");
|
||||
return NPP_Initialize();
|
||||
}
|
||||
|
||||
void Private_Shutdown(void)
|
||||
{
|
||||
PLUGINDEBUGSTR("\pShutdown;g;");
|
||||
NPP_Shutdown();
|
||||
}
|
||||
|
||||
|
||||
NPError Private_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved)
|
||||
{
|
||||
PLUGINDEBUGSTR("\pNew;g;");
|
||||
return NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
|
||||
}
|
||||
|
||||
NPError Private_Destroy(NPP instance, NPSavedData** save)
|
||||
{
|
||||
PLUGINDEBUGSTR("\pDestroy;g;");
|
||||
return NPP_Destroy(instance, save);
|
||||
}
|
||||
|
||||
NPError Private_SetWindow(NPP instance, NPWindow* window)
|
||||
{
|
||||
PLUGINDEBUGSTR("\pSetWindow;g;");
|
||||
return NPP_SetWindow(instance, window);
|
||||
}
|
||||
|
||||
NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype)
|
||||
{
|
||||
PLUGINDEBUGSTR("\pNewStream;g;");
|
||||
return NPP_NewStream(instance, type, stream, seekable, stype);
|
||||
}
|
||||
|
||||
int32_t Private_WriteReady(NPP instance, NPStream* stream)
|
||||
{
|
||||
PLUGINDEBUGSTR("\pWriteReady;g;");
|
||||
return NPP_WriteReady(instance, stream);
|
||||
}
|
||||
|
||||
int32_t Private_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer)
|
||||
{
|
||||
PLUGINDEBUGSTR("\pWrite;g;");
|
||||
return NPP_Write(instance, stream, offset, len, buffer);
|
||||
}
|
||||
|
||||
void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
|
||||
{
|
||||
PLUGINDEBUGSTR("\pStreamAsFile;g;");
|
||||
NPP_StreamAsFile(instance, stream, fname);
|
||||
}
|
||||
|
||||
|
||||
NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
PLUGINDEBUGSTR("\pDestroyStream;g;");
|
||||
return NPP_DestroyStream(instance, stream, reason);
|
||||
}
|
||||
|
||||
int16_t Private_HandleEvent(NPP instance, void* event)
|
||||
{
|
||||
PLUGINDEBUGSTR("\pHandleEvent;g;");
|
||||
return NPP_HandleEvent(instance, event);
|
||||
}
|
||||
|
||||
void Private_Print(NPP instance, NPPrint* platformPrint)
|
||||
{
|
||||
PLUGINDEBUGSTR("\pPrint;g;");
|
||||
NPP_Print(instance, platformPrint);
|
||||
}
|
||||
|
||||
void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
|
||||
{
|
||||
PLUGINDEBUGSTR("\pURLNotify;g;");
|
||||
NPP_URLNotify(instance, url, reason, notifyData);
|
||||
}
|
||||
|
||||
void SetUpQD(void);
|
||||
void SetUpQD(void)
|
||||
{
|
||||
//
|
||||
// Memorize the pluginÕs resource file
|
||||
// refnum for later use.
|
||||
//
|
||||
gResFile = CurResFile();
|
||||
}
|
||||
|
||||
|
||||
int main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownProcPtr* unloadProcPtr);
|
||||
|
||||
DEFINE_API_C(int) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownProcPtr* unloadProcPtr)
|
||||
{
|
||||
PLUGINDEBUGSTR("\pmain");
|
||||
|
||||
NPError err = NPERR_NO_ERROR;
|
||||
|
||||
//
|
||||
// Ensure that everything Netscape passed us is valid!
|
||||
//
|
||||
if ((nsTable == NULL) || (pluginFuncs == NULL) || (unloadProcPtr == NULL))
|
||||
err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
//
|
||||
// Check the ÒmajorÓ version passed in NetscapeÕs function table.
|
||||
// We wonÕt load if the major version is newer than what we expect.
|
||||
// Also check that the function tables passed in are big enough for
|
||||
// all the functions we need (they could be bigger, if Netscape added
|
||||
// new APIs, but thatÕs OK with us -- weÕll just ignore them).
|
||||
//
|
||||
if (err == NPERR_NO_ERROR)
|
||||
{
|
||||
if ((nsTable->version >> 8) > NP_VERSION_MAJOR) // Major version is in high byte
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
|
||||
|
||||
if (err == NPERR_NO_ERROR)
|
||||
{
|
||||
//
|
||||
// Copy all the fields of NetscapeÕs function table into our
|
||||
// copy so we can call back into Netscape later. Note that
|
||||
// we need to copy the fields one by one, rather than assigning
|
||||
// the whole structure, because the Netscape function table
|
||||
// could actually be bigger than what we expect.
|
||||
//
|
||||
|
||||
int navMinorVers = nsTable->version & 0xFF;
|
||||
|
||||
gNetscapeFuncs.version = nsTable->version;
|
||||
gNetscapeFuncs.size = nsTable->size;
|
||||
gNetscapeFuncs.posturl = (NPN_PostURLProcPtr)HOST_TO_PLUGIN_GLUE(posturl, nsTable->posturl);
|
||||
gNetscapeFuncs.geturl = (NPN_GetURLProcPtr)HOST_TO_PLUGIN_GLUE(geturl, nsTable->geturl);
|
||||
gNetscapeFuncs.requestread = (NPN_RequestReadProcPtr)HOST_TO_PLUGIN_GLUE(requestread, nsTable->requestread);
|
||||
gNetscapeFuncs.newstream = (NPN_NewStreamProcPtr)HOST_TO_PLUGIN_GLUE(newstream, nsTable->newstream);
|
||||
gNetscapeFuncs.write = (NPN_WriteProcPtr)HOST_TO_PLUGIN_GLUE(write, nsTable->write);
|
||||
gNetscapeFuncs.destroystream = (NPN_DestroyStreamProcPtr)HOST_TO_PLUGIN_GLUE(destroystream, nsTable->destroystream);
|
||||
gNetscapeFuncs.status = (NPN_StatusProcPtr)HOST_TO_PLUGIN_GLUE(status, nsTable->status);
|
||||
gNetscapeFuncs.uagent = (NPN_UserAgentProcPtr)HOST_TO_PLUGIN_GLUE(uagent, nsTable->uagent);
|
||||
gNetscapeFuncs.memalloc = (NPN_MemAllocProcPtr)HOST_TO_PLUGIN_GLUE(memalloc, nsTable->memalloc);
|
||||
gNetscapeFuncs.memfree = (NPN_MemFreeProcPtr)HOST_TO_PLUGIN_GLUE(memfree, nsTable->memfree);
|
||||
gNetscapeFuncs.memflush = (NPN_MemFlushProcPtr)HOST_TO_PLUGIN_GLUE(memflush, nsTable->memflush);
|
||||
gNetscapeFuncs.reloadplugins = (NPN_ReloadPluginsProcPtr)HOST_TO_PLUGIN_GLUE(reloadplugins, nsTable->reloadplugins);
|
||||
if( navMinorVers >= NPVERS_HAS_LIVECONNECT )
|
||||
{
|
||||
gNetscapeFuncs.getJavaEnv = NULL;
|
||||
gNetscapeFuncs.getJavaPeer = NULL;
|
||||
}
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
|
||||
{
|
||||
gNetscapeFuncs.geturlnotify = (NPN_GetURLNotifyProcPtr)HOST_TO_PLUGIN_GLUE(geturlnotify, nsTable->geturlnotify);
|
||||
gNetscapeFuncs.posturlnotify = (NPN_PostURLNotifyProcPtr)HOST_TO_PLUGIN_GLUE(posturlnotify, nsTable->posturlnotify);
|
||||
}
|
||||
gNetscapeFuncs.getvalue = (NPN_GetValueProcPtr)HOST_TO_PLUGIN_GLUE(getvalue, nsTable->getvalue);
|
||||
gNetscapeFuncs.setvalue = (NPN_SetValueProcPtr)HOST_TO_PLUGIN_GLUE(setvalue, nsTable->setvalue);
|
||||
gNetscapeFuncs.invalidaterect = (NPN_InvalidateRectProcPtr)HOST_TO_PLUGIN_GLUE(invalidaterect, nsTable->invalidaterect);
|
||||
gNetscapeFuncs.invalidateregion = (NPN_InvalidateRegionProcPtr)HOST_TO_PLUGIN_GLUE(invalidateregion, nsTable->invalidateregion);
|
||||
gNetscapeFuncs.forceredraw = (NPN_ForceRedrawProcPtr)HOST_TO_PLUGIN_GLUE(forceredraw, nsTable->forceredraw);
|
||||
gNetscapeFuncs.pushpopupsenabledstate = (NPN_PushPopupsEnabledStateProcPtr)HOST_TO_PLUGIN_GLUE(pushpopupsenabledstate, nsTable->pushpopupsenabledstate);
|
||||
gNetscapeFuncs.poppopupsenabledstate = (NPN_PopPopupsEnabledStateProcPtr)HOST_TO_PLUGIN_GLUE(poppopupsenabledstate, nsTable->poppopupsenabledstate);
|
||||
|
||||
//
|
||||
// Set up the plugin function table that Netscape will use to
|
||||
// call us. Netscape needs to know about our version and size
|
||||
// and have a UniversalProcPointer for every function we implement.
|
||||
//
|
||||
pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
|
||||
pluginFuncs->size = sizeof(NPPluginFuncs);
|
||||
pluginFuncs->newp = (NPP_NewProcPtr)(PLUGIN_TO_HOST_GLUE(newp, Private_New));
|
||||
pluginFuncs->destroy = (NPP_DestroyProcPtr)(PLUGIN_TO_HOST_GLUE(destroy, Private_Destroy));
|
||||
pluginFuncs->setwindow = (NPP_SetWindowProcPtr)(PLUGIN_TO_HOST_GLUE(setwindow, Private_SetWindow));
|
||||
pluginFuncs->newstream = (NPP_NewStreamProcPtr)(PLUGIN_TO_HOST_GLUE(newstream, Private_NewStream));
|
||||
pluginFuncs->destroystream = (NPP_DestroyStreamProcPtr)(PLUGIN_TO_HOST_GLUE(destroystream, Private_DestroyStream));
|
||||
pluginFuncs->asfile = (NPP_StreamAsFileProcPtr)(PLUGIN_TO_HOST_GLUE(asfile, Private_StreamAsFile));
|
||||
pluginFuncs->writeready = (NPP_WriteReadyProcPtr)(PLUGIN_TO_HOST_GLUE(writeready, Private_WriteReady));
|
||||
pluginFuncs->write = (NPP_WriteProcPtr)(PLUGIN_TO_HOST_GLUE(write, Private_Write));
|
||||
pluginFuncs->print = (NPP_PrintProcPtr)(PLUGIN_TO_HOST_GLUE(print, Private_Print));
|
||||
pluginFuncs->event = (NPP_HandleEventProcPtr)(PLUGIN_TO_HOST_GLUE(event, Private_HandleEvent));
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
|
||||
{
|
||||
pluginFuncs->urlnotify = (NPP_URLNotifyProcPtr)(PLUGIN_TO_HOST_GLUE(urlnotify, Private_URLNotify));
|
||||
}
|
||||
if( navMinorVers >= NPVERS_HAS_LIVECONNECT )
|
||||
{
|
||||
pluginFuncs->javaClass = NULL;
|
||||
}
|
||||
*unloadProcPtr = (NPP_ShutdownProcPtr)(PLUGIN_TO_HOST_GLUE(shutdown, Private_Shutdown));
|
||||
|
||||
SetUpQD();
|
||||
err = Private_Initialize();
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
# the null plugin goes in gecko-support because we search for plugins
|
||||
# in the application, not the GRE
|
||||
[gecko-support]
|
||||
dist/bin/plugins/Default\ Plugin.plugin
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 4.5 KiB |
Загрузка…
Ссылка в новой задаче