1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 // Implementation of Netscape entry points (NPN_*)
42 extern NPNetscapeFuncs NPNFuncs
;
44 void NPN_Version(int* plugin_major
, int* plugin_minor
, int* netscape_major
, int* netscape_minor
)
46 *plugin_major
= NP_VERSION_MAJOR
;
47 *plugin_minor
= NP_VERSION_MINOR
;
48 *netscape_major
= HIBYTE(NPNFuncs
.version
);
49 *netscape_minor
= LOBYTE(NPNFuncs
.version
);
52 NPError
NPN_GetURLNotify(NPP instance
, const char *url
, const char *target
, void* notifyData
)
54 int navMinorVers
= NPNFuncs
.version
& 0xFF;
55 NPError rv
= NPERR_NO_ERROR
;
57 if (navMinorVers
>= NPVERS_HAS_NOTIFICATION
)
58 rv
= (*NPNFuncs
.geturlnotify
)(instance
, url
, target
, notifyData
);
60 rv
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
65 NPError
NPN_GetURL(NPP instance
, const char *url
, const char *target
)
67 return (*NPNFuncs
.geturl
)(instance
, url
, target
);
70 NPError
NPN_PostURLNotify(NPP instance
, const char* url
, const char* window
, uint32_t len
, const char* buf
, NPBool file
, void* notifyData
)
72 int navMinorVers
= NPNFuncs
.version
& 0xFF;
73 NPError rv
= NPERR_NO_ERROR
;
75 if (navMinorVers
>= NPVERS_HAS_NOTIFICATION
)
76 rv
= (*NPNFuncs
.posturlnotify
)(instance
, url
, window
, len
, buf
, file
, notifyData
);
78 rv
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
83 NPError
NPN_PostURL(NPP instance
, const char* url
, const char* window
, uint32_t len
, const char* buf
, NPBool file
)
85 return (*NPNFuncs
.posturl
)(instance
, url
, window
, len
, buf
, file
);
88 NPError
NPN_RequestRead(NPStream
* stream
, NPByteRange
* rangeList
)
90 return (*NPNFuncs
.requestread
)(stream
, rangeList
);
93 NPError
NPN_NewStream(NPP instance
, NPMIMEType type
, const char* target
, NPStream
** stream
)
95 int navMinorVersion
= NPNFuncs
.version
& 0xFF;
97 NPError rv
= NPERR_NO_ERROR
;
99 if (navMinorVersion
>= NPVERS_HAS_STREAMOUTPUT
)
100 rv
= (*NPNFuncs
.newstream
)(instance
, type
, target
, stream
);
102 rv
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
107 int32_t NPN_Write(NPP instance
, NPStream
*stream
, int32_t len
, void *buffer
)
109 int navMinorVersion
= NPNFuncs
.version
& 0xFF;
112 if (navMinorVersion
>= NPVERS_HAS_STREAMOUTPUT
)
113 rv
= (*NPNFuncs
.write
)(instance
, stream
, len
, buffer
);
120 NPError
NPN_DestroyStream(NPP instance
, NPStream
* stream
, NPError reason
)
122 int navMinorVersion
= NPNFuncs
.version
& 0xFF;
123 NPError rv
= NPERR_NO_ERROR
;
125 if (navMinorVersion
>= NPVERS_HAS_STREAMOUTPUT
)
126 rv
= (*NPNFuncs
.destroystream
)(instance
, stream
, reason
);
128 rv
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
133 void NPN_Status(NPP instance
, const char *message
)
135 (*NPNFuncs
.status
)(instance
, message
);
138 const char* NPN_UserAgent(NPP instance
)
140 return (*NPNFuncs
.uagent
)(instance
);
143 void* NPN_MemAlloc(uint32_t size
)
145 return (*NPNFuncs
.memalloc
)(size
);
148 void NPN_MemFree(void* ptr
)
150 (*NPNFuncs
.memfree
)(ptr
);
153 uint32_t NPN_MemFlush(uint32_t size
)
155 return (*NPNFuncs
.memflush
)(size
);
158 void NPN_ReloadPlugins(NPBool reloadPages
)
160 (*NPNFuncs
.reloadplugins
)(reloadPages
);
163 NPError
NPN_GetValue(NPP instance
, NPNVariable variable
, void *value
)
165 return (*NPNFuncs
.getvalue
)(instance
, variable
, value
);
168 NPError
NPN_SetValue(NPP instance
, NPPVariable variable
, void *value
)
170 return (*NPNFuncs
.setvalue
)(instance
, variable
, value
);
173 void NPN_InvalidateRect(NPP instance
, NPRect
*invalidRect
)
175 (*NPNFuncs
.invalidaterect
)(instance
, invalidRect
);
178 void NPN_InvalidateRegion(NPP instance
, NPRegion invalidRegion
)
180 (*NPNFuncs
.invalidateregion
)(instance
, invalidRegion
);
183 void NPN_ForceRedraw(NPP instance
)
185 (*NPNFuncs
.forceredraw
)(instance
);