michael@0: /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef npfunctions_h_ michael@0: #define npfunctions_h_ michael@0: michael@0: #include "npapi.h" michael@0: #include "npruntime.h" michael@0: michael@0: #ifdef MOZ_WIDGET_ANDROID michael@0: #include michael@0: #endif michael@0: michael@0: typedef NPError (* NPP_NewProcPtr)(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved); michael@0: typedef NPError (* NPP_DestroyProcPtr)(NPP instance, NPSavedData** save); michael@0: typedef NPError (* NPP_SetWindowProcPtr)(NPP instance, NPWindow* window); michael@0: typedef NPError (* NPP_NewStreamProcPtr)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype); michael@0: typedef NPError (* NPP_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason); michael@0: typedef int32_t (* NPP_WriteReadyProcPtr)(NPP instance, NPStream* stream); michael@0: typedef int32_t (* NPP_WriteProcPtr)(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer); michael@0: typedef void (* NPP_StreamAsFileProcPtr)(NPP instance, NPStream* stream, const char* fname); michael@0: typedef void (* NPP_PrintProcPtr)(NPP instance, NPPrint* platformPrint); michael@0: typedef int16_t (* NPP_HandleEventProcPtr)(NPP instance, void* event); michael@0: typedef void (* NPP_URLNotifyProcPtr)(NPP instance, const char* url, NPReason reason, void* notifyData); michael@0: /* Any NPObjects returned to the browser via NPP_GetValue should be retained michael@0: by the plugin on the way out. The browser is responsible for releasing. */ michael@0: typedef NPError (* NPP_GetValueProcPtr)(NPP instance, NPPVariable variable, void *ret_value); michael@0: typedef NPError (* NPP_SetValueProcPtr)(NPP instance, NPNVariable variable, void *value); michael@0: typedef NPBool (* NPP_GotFocusPtr)(NPP instance, NPFocusDirection direction); michael@0: typedef void (* NPP_LostFocusPtr)(NPP instance); michael@0: typedef void (* NPP_URLRedirectNotifyPtr)(NPP instance, const char* url, int32_t status, void* notifyData); michael@0: typedef NPError (* NPP_ClearSiteDataPtr)(const char* site, uint64_t flags, uint64_t maxAge); michael@0: typedef char** (* NPP_GetSitesWithDataPtr)(void); michael@0: typedef void (* NPP_DidCompositePtr)(NPP instance); michael@0: michael@0: typedef NPError (*NPN_GetValueProcPtr)(NPP instance, NPNVariable variable, void *ret_value); michael@0: typedef NPError (*NPN_SetValueProcPtr)(NPP instance, NPPVariable variable, void *value); michael@0: typedef NPError (*NPN_GetURLNotifyProcPtr)(NPP instance, const char* url, const char* window, void* notifyData); michael@0: typedef NPError (*NPN_PostURLNotifyProcPtr)(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file, void* notifyData); michael@0: typedef NPError (*NPN_GetURLProcPtr)(NPP instance, const char* url, const char* window); michael@0: typedef NPError (*NPN_PostURLProcPtr)(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file); michael@0: typedef NPError (*NPN_RequestReadProcPtr)(NPStream* stream, NPByteRange* rangeList); michael@0: typedef NPError (*NPN_NewStreamProcPtr)(NPP instance, NPMIMEType type, const char* window, NPStream** stream); michael@0: typedef int32_t (*NPN_WriteProcPtr)(NPP instance, NPStream* stream, int32_t len, void* buffer); michael@0: typedef NPError (*NPN_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason); michael@0: typedef void (*NPN_StatusProcPtr)(NPP instance, const char* message); michael@0: /* Browser manages the lifetime of the buffer returned by NPN_UserAgent, don't michael@0: depend on it sticking around and don't free it. */ michael@0: typedef const char* (*NPN_UserAgentProcPtr)(NPP instance); michael@0: typedef void* (*NPN_MemAllocProcPtr)(uint32_t size); michael@0: typedef void (*NPN_MemFreeProcPtr)(void* ptr); michael@0: typedef uint32_t (*NPN_MemFlushProcPtr)(uint32_t size); michael@0: typedef void (*NPN_ReloadPluginsProcPtr)(NPBool reloadPages); michael@0: typedef void* (*NPN_GetJavaEnvProcPtr)(void); michael@0: typedef void* (*NPN_GetJavaPeerProcPtr)(NPP instance); michael@0: typedef void (*NPN_InvalidateRectProcPtr)(NPP instance, NPRect *rect); michael@0: typedef void (*NPN_InvalidateRegionProcPtr)(NPP instance, NPRegion region); michael@0: typedef void (*NPN_ForceRedrawProcPtr)(NPP instance); michael@0: typedef NPIdentifier (*NPN_GetStringIdentifierProcPtr)(const NPUTF8* name); michael@0: typedef void (*NPN_GetStringIdentifiersProcPtr)(const NPUTF8** names, int32_t nameCount, NPIdentifier* identifiers); michael@0: typedef NPIdentifier (*NPN_GetIntIdentifierProcPtr)(int32_t intid); michael@0: typedef bool (*NPN_IdentifierIsStringProcPtr)(NPIdentifier identifier); michael@0: typedef NPUTF8* (*NPN_UTF8FromIdentifierProcPtr)(NPIdentifier identifier); michael@0: typedef int32_t (*NPN_IntFromIdentifierProcPtr)(NPIdentifier identifier); michael@0: typedef NPObject* (*NPN_CreateObjectProcPtr)(NPP npp, NPClass *aClass); michael@0: typedef NPObject* (*NPN_RetainObjectProcPtr)(NPObject *obj); michael@0: typedef void (*NPN_ReleaseObjectProcPtr)(NPObject *obj); michael@0: typedef bool (*NPN_InvokeProcPtr)(NPP npp, NPObject* obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result); michael@0: typedef bool (*NPN_InvokeDefaultProcPtr)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result); michael@0: typedef bool (*NPN_EvaluateProcPtr)(NPP npp, NPObject *obj, NPString *script, NPVariant *result); michael@0: typedef bool (*NPN_GetPropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName, NPVariant *result); michael@0: typedef bool (*NPN_SetPropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName, const NPVariant *value); michael@0: typedef bool (*NPN_RemovePropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName); michael@0: typedef bool (*NPN_HasPropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName); michael@0: typedef bool (*NPN_HasMethodProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName); michael@0: typedef void (*NPN_ReleaseVariantValueProcPtr)(NPVariant *variant); michael@0: typedef void (*NPN_SetExceptionProcPtr)(NPObject *obj, const NPUTF8 *message); michael@0: typedef void (*NPN_PushPopupsEnabledStateProcPtr)(NPP npp, NPBool enabled); michael@0: typedef void (*NPN_PopPopupsEnabledStateProcPtr)(NPP npp); michael@0: typedef bool (*NPN_EnumerateProcPtr)(NPP npp, NPObject *obj, NPIdentifier **identifier, uint32_t *count); michael@0: typedef void (*NPN_PluginThreadAsyncCallProcPtr)(NPP instance, void (*func)(void *), void *userData); michael@0: typedef bool (*NPN_ConstructProcPtr)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result); michael@0: typedef NPError (*NPN_GetValueForURLPtr)(NPP npp, NPNURLVariable variable, const char *url, char **value, uint32_t *len); michael@0: typedef NPError (*NPN_SetValueForURLPtr)(NPP npp, NPNURLVariable variable, const char *url, const char *value, uint32_t len); michael@0: typedef NPError (*NPN_GetAuthenticationInfoPtr)(NPP npp, const char *protocol, const char *host, int32_t port, const char *scheme, const char *realm, char **username, uint32_t *ulen, char **password, uint32_t *plen); michael@0: typedef uint32_t (*NPN_ScheduleTimerPtr)(NPP instance, uint32_t interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32_t timerID)); michael@0: typedef void (*NPN_UnscheduleTimerPtr)(NPP instance, uint32_t timerID); michael@0: typedef NPError (*NPN_PopUpContextMenuPtr)(NPP instance, NPMenu* menu); michael@0: typedef NPBool (*NPN_ConvertPointPtr)(NPP instance, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace); michael@0: typedef NPBool (*NPN_HandleEventPtr)(NPP instance, void *event, NPBool handled); michael@0: typedef NPBool (*NPN_UnfocusInstancePtr)(NPP instance, NPFocusDirection direction); michael@0: typedef void (*NPN_URLRedirectResponsePtr)(NPP instance, void* notifyData, NPBool allow); michael@0: typedef NPError (*NPN_InitAsyncSurfacePtr)(NPP instance, NPSize *size, NPImageFormat format, void *initData, NPAsyncSurface *surface); michael@0: typedef NPError (*NPN_FinalizeAsyncSurfacePtr)(NPP instance, NPAsyncSurface *surface); michael@0: typedef void (*NPN_SetCurrentAsyncSurfacePtr)(NPP instance, NPAsyncSurface *surface, NPRect *changed); michael@0: michael@0: typedef struct _NPPluginFuncs { michael@0: uint16_t size; michael@0: uint16_t version; michael@0: NPP_NewProcPtr newp; michael@0: NPP_DestroyProcPtr destroy; michael@0: NPP_SetWindowProcPtr setwindow; michael@0: NPP_NewStreamProcPtr newstream; michael@0: NPP_DestroyStreamProcPtr destroystream; michael@0: NPP_StreamAsFileProcPtr asfile; michael@0: NPP_WriteReadyProcPtr writeready; michael@0: NPP_WriteProcPtr write; michael@0: NPP_PrintProcPtr print; michael@0: NPP_HandleEventProcPtr event; michael@0: NPP_URLNotifyProcPtr urlnotify; michael@0: void* javaClass; michael@0: NPP_GetValueProcPtr getvalue; michael@0: NPP_SetValueProcPtr setvalue; michael@0: NPP_GotFocusPtr gotfocus; michael@0: NPP_LostFocusPtr lostfocus; michael@0: NPP_URLRedirectNotifyPtr urlredirectnotify; michael@0: NPP_ClearSiteDataPtr clearsitedata; michael@0: NPP_GetSitesWithDataPtr getsiteswithdata; michael@0: NPP_DidCompositePtr didComposite; michael@0: } NPPluginFuncs; michael@0: michael@0: typedef struct _NPNetscapeFuncs { michael@0: uint16_t size; michael@0: uint16_t version; michael@0: NPN_GetURLProcPtr geturl; michael@0: NPN_PostURLProcPtr posturl; michael@0: NPN_RequestReadProcPtr requestread; michael@0: NPN_NewStreamProcPtr newstream; michael@0: NPN_WriteProcPtr write; michael@0: NPN_DestroyStreamProcPtr destroystream; michael@0: NPN_StatusProcPtr status; michael@0: NPN_UserAgentProcPtr uagent; michael@0: NPN_MemAllocProcPtr memalloc; michael@0: NPN_MemFreeProcPtr memfree; michael@0: NPN_MemFlushProcPtr memflush; michael@0: NPN_ReloadPluginsProcPtr reloadplugins; michael@0: NPN_GetJavaEnvProcPtr getJavaEnv; michael@0: NPN_GetJavaPeerProcPtr getJavaPeer; michael@0: NPN_GetURLNotifyProcPtr geturlnotify; michael@0: NPN_PostURLNotifyProcPtr posturlnotify; michael@0: NPN_GetValueProcPtr getvalue; michael@0: NPN_SetValueProcPtr setvalue; michael@0: NPN_InvalidateRectProcPtr invalidaterect; michael@0: NPN_InvalidateRegionProcPtr invalidateregion; michael@0: NPN_ForceRedrawProcPtr forceredraw; michael@0: NPN_GetStringIdentifierProcPtr getstringidentifier; michael@0: NPN_GetStringIdentifiersProcPtr getstringidentifiers; michael@0: NPN_GetIntIdentifierProcPtr getintidentifier; michael@0: NPN_IdentifierIsStringProcPtr identifierisstring; michael@0: NPN_UTF8FromIdentifierProcPtr utf8fromidentifier; michael@0: NPN_IntFromIdentifierProcPtr intfromidentifier; michael@0: NPN_CreateObjectProcPtr createobject; michael@0: NPN_RetainObjectProcPtr retainobject; michael@0: NPN_ReleaseObjectProcPtr releaseobject; michael@0: NPN_InvokeProcPtr invoke; michael@0: NPN_InvokeDefaultProcPtr invokeDefault; michael@0: NPN_EvaluateProcPtr evaluate; michael@0: NPN_GetPropertyProcPtr getproperty; michael@0: NPN_SetPropertyProcPtr setproperty; michael@0: NPN_RemovePropertyProcPtr removeproperty; michael@0: NPN_HasPropertyProcPtr hasproperty; michael@0: NPN_HasMethodProcPtr hasmethod; michael@0: NPN_ReleaseVariantValueProcPtr releasevariantvalue; michael@0: NPN_SetExceptionProcPtr setexception; michael@0: NPN_PushPopupsEnabledStateProcPtr pushpopupsenabledstate; michael@0: NPN_PopPopupsEnabledStateProcPtr poppopupsenabledstate; michael@0: NPN_EnumerateProcPtr enumerate; michael@0: NPN_PluginThreadAsyncCallProcPtr pluginthreadasynccall; michael@0: NPN_ConstructProcPtr construct; michael@0: NPN_GetValueForURLPtr getvalueforurl; michael@0: NPN_SetValueForURLPtr setvalueforurl; michael@0: NPN_GetAuthenticationInfoPtr getauthenticationinfo; michael@0: NPN_ScheduleTimerPtr scheduletimer; michael@0: NPN_UnscheduleTimerPtr unscheduletimer; michael@0: NPN_PopUpContextMenuPtr popupcontextmenu; michael@0: NPN_ConvertPointPtr convertpoint; michael@0: NPN_HandleEventPtr handleevent; michael@0: NPN_UnfocusInstancePtr unfocusinstance; michael@0: NPN_URLRedirectResponsePtr urlredirectresponse; michael@0: NPN_InitAsyncSurfacePtr initasyncsurface; michael@0: NPN_FinalizeAsyncSurfacePtr finalizeasyncsurface; michael@0: NPN_SetCurrentAsyncSurfacePtr setcurrentasyncsurface; michael@0: } NPNetscapeFuncs; michael@0: michael@0: #ifdef XP_MACOSX michael@0: /* michael@0: * Mac OS X version(s) of NP_GetMIMEDescription(const char *) michael@0: * These can be called to retreive MIME information from the plugin dynamically michael@0: * michael@0: * Note: For compatibility with Quicktime, BPSupportedMIMEtypes is another way michael@0: * to get mime info from the plugin only on OSX and may not be supported michael@0: * in furture version -- use NP_GetMIMEDescription instead michael@0: */ michael@0: enum michael@0: { michael@0: kBPSupportedMIMETypesStructVers_1 = 1 michael@0: }; michael@0: typedef struct _BPSupportedMIMETypes michael@0: { michael@0: SInt32 structVersion; /* struct version */ michael@0: Handle typeStrings; /* STR# formated handle, allocated by plug-in */ michael@0: Handle infoStrings; /* STR# formated handle, allocated by plug-in */ michael@0: } BPSupportedMIMETypes; michael@0: OSErr BP_GetSupportedMIMETypes(BPSupportedMIMETypes *mimeInfo, UInt32 flags); michael@0: #define NP_GETMIMEDESCRIPTION_NAME "NP_GetMIMEDescription" michael@0: typedef const char* (*NP_GetMIMEDescriptionProcPtr)(void); michael@0: typedef OSErr (*BP_GetSupportedMIMETypesProcPtr)(BPSupportedMIMETypes*, UInt32); michael@0: #endif michael@0: michael@0: #if defined(_WIN32) michael@0: #define OSCALL WINAPI michael@0: #else michael@0: #define OSCALL michael@0: #endif michael@0: michael@0: #if defined(XP_UNIX) michael@0: /* GCC 3.3 and later support the visibility attribute. */ michael@0: #if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) michael@0: #define NP_VISIBILITY_DEFAULT __attribute__((visibility("default"))) michael@0: #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) michael@0: #define NP_VISIBILITY_DEFAULT __global michael@0: #else michael@0: #define NP_VISIBILITY_DEFAULT michael@0: #endif michael@0: #define NP_EXPORT(__type) NP_VISIBILITY_DEFAULT __type michael@0: #endif michael@0: michael@0: #if defined(_WIN32) michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: /* plugin meta member functions */ michael@0: typedef NPError (OSCALL *NP_GetEntryPointsFunc)(NPPluginFuncs*); michael@0: NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs); michael@0: typedef NPError (OSCALL *NP_InitializeFunc)(NPNetscapeFuncs*); michael@0: NPError OSCALL NP_Initialize(NPNetscapeFuncs* bFuncs); michael@0: typedef NPError (OSCALL *NP_ShutdownFunc)(void); michael@0: NPError OSCALL NP_Shutdown(void); michael@0: typedef const char* (*NP_GetMIMEDescriptionFunc)(void); michael@0: const char* NP_GetMIMEDescription(void); michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif michael@0: #endif michael@0: michael@0: #ifdef XP_UNIX michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: typedef char* (*NP_GetPluginVersionFunc)(void); michael@0: NP_EXPORT(char*) NP_GetPluginVersion(void); michael@0: typedef const char* (*NP_GetMIMEDescriptionFunc)(void); michael@0: NP_EXPORT(const char*) NP_GetMIMEDescription(void); michael@0: #ifdef XP_MACOSX michael@0: typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*); michael@0: NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs); michael@0: typedef NPError (*NP_GetEntryPointsFunc)(NPPluginFuncs*); michael@0: NP_EXPORT(NPError) NP_GetEntryPoints(NPPluginFuncs* pFuncs); michael@0: #else michael@0: #ifdef MOZ_WIDGET_ANDROID michael@0: typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*, JNIEnv* pEnv); michael@0: NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, JNIEnv* pEnv); michael@0: #else michael@0: typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*); michael@0: NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs); michael@0: #endif michael@0: #endif michael@0: typedef NPError (*NP_ShutdownFunc)(void); michael@0: NP_EXPORT(NPError) NP_Shutdown(void); michael@0: typedef NPError (*NP_GetValueFunc)(void *, NPPVariable, void *); michael@0: NP_EXPORT(NPError) NP_GetValue(void *future, NPPVariable aVariable, void *aValue); michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif michael@0: #endif michael@0: michael@0: #endif /* npfunctions_h_ */