|
21
|
1 |
// |
|
|
2 |
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
|
|
3 |
// |
|
|
4 |
// This program is free software; you can redistribute it and/or modify |
|
|
5 |
// it under the terms of the GNU General Public License as published by |
|
|
6 |
// the Free Software Foundation; either version 3 of the License, or |
|
|
7 |
// (at your option) any later version. |
|
|
8 |
// |
|
|
9 |
// This program is distributed in the hope that it will be useful, |
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
12 |
// GNU General Public License for more details. |
|
|
13 |
// |
|
|
14 |
// You should have received a copy of the GNU General Public License |
|
|
15 |
// along with this program; if not, write to the Free Software |
|
|
16 |
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
|
17 |
// |
|
|
18 |
|
|
|
19 |
//////////////////////////////////////////////////////////// |
|
|
20 |
// |
|
|
21 |
// Implementation of Netscape entry points (NPN_*) |
|
|
22 |
// |
|
|
23 |
|
|
|
24 |
#include "pluginbase.h" |
|
|
25 |
|
|
|
26 |
extern NPNetscapeFuncs NPNFuncs; |
|
|
27 |
|
|
|
28 |
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor) |
|
|
29 |
{ |
|
|
30 |
*plugin_major = NP_VERSION_MAJOR; |
|
|
31 |
*plugin_minor = NP_VERSION_MINOR; |
|
|
32 |
*netscape_major = HIBYTE(NPNFuncs.version); |
|
|
33 |
*netscape_minor = LOBYTE(NPNFuncs.version); |
|
|
34 |
} |
|
|
35 |
|
|
|
36 |
NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData) |
|
|
37 |
{ |
|
|
38 |
int navMinorVers = NPNFuncs.version & 0xFF; |
|
|
39 |
NPError rv = NPERR_NO_ERROR; |
|
|
40 |
|
|
|
41 |
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) |
|
|
42 |
rv = CallNPN_GetURLNotifyProc(NPNFuncs.geturlnotify, instance, url, target, notifyData); |
|
|
43 |
else |
|
|
44 |
rv = NPERR_INCOMPATIBLE_VERSION_ERROR; |
|
|
45 |
|
|
|
46 |
return rv; |
|
|
47 |
} |
|
|
48 |
|
|
|
49 |
NPError NPN_GetURL(NPP instance, const char *url, const char *target) |
|
|
50 |
{ |
|
|
51 |
NPError rv = CallNPN_GetURLProc(NPNFuncs.geturl, instance, url, target); |
|
|
52 |
return rv; |
|
|
53 |
} |
|
|
54 |
|
|
|
55 |
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData) |
|
|
56 |
{ |
|
|
57 |
int navMinorVers = NPNFuncs.version & 0xFF; |
|
|
58 |
NPError rv = NPERR_NO_ERROR; |
|
|
59 |
|
|
|
60 |
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) |
|
|
61 |
rv = CallNPN_PostURLNotifyProc(NPNFuncs.posturlnotify, instance, url, window, len, buf, file, notifyData); |
|
|
62 |
else |
|
|
63 |
rv = NPERR_INCOMPATIBLE_VERSION_ERROR; |
|
|
64 |
|
|
|
65 |
return rv; |
|
|
66 |
} |
|
|
67 |
|
|
|
68 |
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file) |
|
|
69 |
{ |
|
|
70 |
NPError rv = CallNPN_PostURLProc(NPNFuncs.posturl, instance, url, window, len, buf, file); |
|
|
71 |
return rv; |
|
|
72 |
} |
|
|
73 |
|
|
|
74 |
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList) |
|
|
75 |
{ |
|
|
76 |
NPError rv = CallNPN_RequestReadProc(NPNFuncs.requestread, stream, rangeList); |
|
|
77 |
return rv; |
|
|
78 |
} |
|
|
79 |
|
|
|
80 |
NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream) |
|
|
81 |
{ |
|
|
82 |
int navMinorVersion = NPNFuncs.version & 0xFF; |
|
|
83 |
|
|
|
84 |
NPError rv = NPERR_NO_ERROR; |
|
|
85 |
|
|
|
86 |
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) |
|
|
87 |
rv = CallNPN_NewStreamProc(NPNFuncs.newstream, instance, type, target, stream); |
|
|
88 |
else |
|
|
89 |
rv = NPERR_INCOMPATIBLE_VERSION_ERROR; |
|
|
90 |
|
|
|
91 |
return rv; |
|
|
92 |
} |
|
|
93 |
|
|
|
94 |
int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer) |
|
|
95 |
{ |
|
|
96 |
int navMinorVersion = NPNFuncs.version & 0xFF; |
|
|
97 |
int32 rv = 0; |
|
|
98 |
|
|
|
99 |
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) |
|
|
100 |
rv = CallNPN_WriteProc(NPNFuncs.write, instance, stream, len, buffer); |
|
|
101 |
else |
|
|
102 |
rv = -1; |
|
|
103 |
|
|
|
104 |
return rv; |
|
|
105 |
} |
|
|
106 |
|
|
|
107 |
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason) |
|
|
108 |
{ |
|
|
109 |
int navMinorVersion = NPNFuncs.version & 0xFF; |
|
|
110 |
NPError rv = NPERR_NO_ERROR; |
|
|
111 |
|
|
|
112 |
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) |
|
|
113 |
rv = CallNPN_DestroyStreamProc(NPNFuncs.destroystream, instance, stream, reason); |
|
|
114 |
else |
|
|
115 |
rv = NPERR_INCOMPATIBLE_VERSION_ERROR; |
|
|
116 |
|
|
|
117 |
return rv; |
|
|
118 |
} |
|
|
119 |
|
|
|
120 |
void NPN_Status(NPP instance, const char *message) |
|
|
121 |
{ |
|
|
122 |
CallNPN_StatusProc(NPNFuncs.status, instance, message); |
|
|
123 |
} |
|
|
124 |
|
|
|
125 |
const char* NPN_UserAgent(NPP instance) |
|
|
126 |
{ |
|
|
127 |
const char * rv = NULL; |
|
|
128 |
rv = CallNPN_UserAgentProc(NPNFuncs.uagent, instance); |
|
|
129 |
return rv; |
|
|
130 |
} |
|
|
131 |
|
|
|
132 |
void* NPN_MemAlloc(uint32 size) |
|
|
133 |
{ |
|
|
134 |
void * rv = NULL; |
|
|
135 |
rv = CallNPN_MemAllocProc(NPNFuncs.memalloc, size); |
|
|
136 |
return rv; |
|
|
137 |
} |
|
|
138 |
|
|
|
139 |
void NPN_MemFree(void* ptr) |
|
|
140 |
{ |
|
|
141 |
CallNPN_MemFreeProc(NPNFuncs.memfree, ptr); |
|
|
142 |
} |
|
|
143 |
|
|
|
144 |
uint32 NPN_MemFlush(uint32 size) |
|
|
145 |
{ |
|
|
146 |
uint32 rv = CallNPN_MemFlushProc(NPNFuncs.memflush, size); |
|
|
147 |
return rv; |
|
|
148 |
} |
|
|
149 |
|
|
|
150 |
void NPN_ReloadPlugins(NPBool reloadPages) |
|
|
151 |
{ |
|
|
152 |
CallNPN_ReloadPluginsProc(NPNFuncs.reloadplugins, reloadPages); |
|
|
153 |
} |
|
|
154 |
|
|
|
155 |
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value) |
|
|
156 |
{ |
|
|
157 |
NPError rv = CallNPN_GetValueProc(NPNFuncs.getvalue, instance, variable, value); |
|
|
158 |
return rv; |
|
|
159 |
} |
|
|
160 |
|
|
|
161 |
NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value) |
|
|
162 |
{ |
|
|
163 |
NPError rv = CallNPN_SetValueProc(NPNFuncs.setvalue, instance, variable, value); |
|
|
164 |
return rv; |
|
|
165 |
} |
|
|
166 |
|
|
|
167 |
void NPN_InvalidateRect(NPP instance, NPRect *invalidRect) |
|
|
168 |
{ |
|
|
169 |
CallNPN_InvalidateRectProc(NPNFuncs.invalidaterect, instance, invalidRect); |
|
|
170 |
} |
|
|
171 |
|
|
|
172 |
void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion) |
|
|
173 |
{ |
|
|
174 |
CallNPN_InvalidateRegionProc(NPNFuncs.invalidateregion, instance, invalidRegion); |
|
|
175 |
} |
|
|
176 |
|
|
|
177 |
void NPN_ForceRedraw(NPP instance) |
|
|
178 |
{ |
|
|
179 |
CallNPN_ForceRedrawProc(NPNFuncs.forceredraw, instance); |
|
|
180 |
} |
|
|
181 |
|
|
|
182 |
// The following has been copied from a newer version of npn_gate.cpp |
|
|
183 |
|
|
|
184 |
NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name) |
|
|
185 |
{ |
|
|
186 |
return NPNFuncs.getstringidentifier(name); |
|
|
187 |
} |
|
|
188 |
|
|
|
189 |
bool NPN_GetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName, |
|
|
190 |
NPVariant *result) |
|
|
191 |
{ |
|
|
192 |
return NPNFuncs.getproperty(npp, obj, propertyName, result); |
|
|
193 |
} |
|
|
194 |
|
|
|
195 |
void NPN_ReleaseObject(NPObject *obj) |
|
|
196 |
{ |
|
|
197 |
return NPNFuncs.releaseobject(obj); |
|
|
198 |
} |
|
|
199 |
|
|
|
200 |
void NPN_PluginThreadAsyncCall (NPP instance, void (*func)(void *), void *userData) |
|
|
201 |
{ |
|
|
202 |
CallNPN_PluginThreadAsyncCallProc(NPNFuncs.pluginthreadasynccall, |
|
|
203 |
instance, func, userData); |
|
|
204 |
} |