OLD | NEW |
| (Empty) |
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |
2 /* ***** BEGIN LICENSE BLOCK ***** | |
3 * Version: NPL 1.1/GPL 2.0/LGPL 2.1 | |
4 * | |
5 * The contents of this file are subject to the Netscape Public License | |
6 * Version 1.1 (the "License"); you may not use this file except in | |
7 * compliance with the License. You may obtain a copy of the License at | |
8 * http://www.mozilla.org/NPL/ | |
9 * | |
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 | |
13 * License. | |
14 * | |
15 * The Original Code is mozilla.org code. | |
16 * | |
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. | |
21 * | |
22 * Contributor(s): | |
23 * | |
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 NPL, 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 NPL, the GPL or the LGPL. | |
35 * | |
36 * ***** END LICENSE BLOCK ***** */ | |
37 | |
38 | |
39 //////////////////////////////////////////////////////////// | |
40 // | |
41 // Implementation of Netscape entry points (NPN_*) | |
42 // | |
43 #include "omaha/plugins/base/npplat.h" | |
44 | |
45 extern NPNetscapeFuncs NPNFuncs; | |
46 | |
47 /* | |
48 void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int*
netscape_minor) | |
49 { | |
50 *plugin_major = NP_VERSION_MAJOR; | |
51 *plugin_minor = NP_VERSION_MINOR; | |
52 *netscape_major = HIBYTE(NPNFuncs.version); | |
53 *netscape_minor = LOBYTE(NPNFuncs.version); | |
54 } | |
55 | |
56 NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void
* notifyData) | |
57 { | |
58 int navMinorVers = NPNFuncs.version & 0xFF; | |
59 NPError rv = NPERR_NO_ERROR; | |
60 | |
61 if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) | |
62 rv = CallNPN_GetURLNotifyProc(NPNFuncs.geturlnotify, instance, url, target,
notifyData); | |
63 else | |
64 rv = NPERR_INCOMPATIBLE_VERSION_ERROR; | |
65 | |
66 return rv; | |
67 } | |
68 | |
69 NPError NPN_GetURL(NPP instance, const char *url, const char *target) | |
70 { | |
71 NPError rv = CallNPN_GetURLProc(NPNFuncs.geturl, instance, url, target); | |
72 return rv; | |
73 } | |
74 | |
75 NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uin
t32 len, const char* buf, NPBool file, void* notifyData) | |
76 { | |
77 int navMinorVers = NPNFuncs.version & 0xFF; | |
78 NPError rv = NPERR_NO_ERROR; | |
79 | |
80 if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) | |
81 rv = CallNPN_PostURLNotifyProc(NPNFuncs.posturlnotify, instance, url, window
, len, buf, file, notifyData); | |
82 else | |
83 rv = NPERR_INCOMPATIBLE_VERSION_ERROR; | |
84 | |
85 return rv; | |
86 } | |
87 | |
88 NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 le
n, const char* buf, NPBool file) | |
89 { | |
90 NPError rv = CallNPN_PostURLProc(NPNFuncs.posturl, instance, url, window, len,
buf, file); | |
91 return rv; | |
92 } | |
93 | |
94 NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList) | |
95 { | |
96 NPError rv = CallNPN_RequestReadProc(NPNFuncs.requestread, stream, rangeList); | |
97 return rv; | |
98 } | |
99 | |
100 NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStrea
m** stream) | |
101 { | |
102 int navMinorVersion = NPNFuncs.version & 0xFF; | |
103 | |
104 NPError rv = NPERR_NO_ERROR; | |
105 | |
106 if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) | |
107 rv = CallNPN_NewStreamProc(NPNFuncs.newstream, instance, type, target, strea
m); | |
108 else | |
109 rv = NPERR_INCOMPATIBLE_VERSION_ERROR; | |
110 | |
111 return rv; | |
112 } | |
113 | |
114 int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer) | |
115 { | |
116 int navMinorVersion = NPNFuncs.version & 0xFF; | |
117 int32 rv = 0; | |
118 | |
119 if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) | |
120 rv = CallNPN_WriteProc(NPNFuncs.write, instance, stream, len, buffer); | |
121 else | |
122 rv = -1; | |
123 | |
124 return rv; | |
125 } | |
126 | |
127 NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason) | |
128 { | |
129 int navMinorVersion = NPNFuncs.version & 0xFF; | |
130 NPError rv = NPERR_NO_ERROR; | |
131 | |
132 if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) | |
133 rv = CallNPN_DestroyStreamProc(NPNFuncs.destroystream, instance, stream, rea
son); | |
134 else | |
135 rv = NPERR_INCOMPATIBLE_VERSION_ERROR; | |
136 | |
137 return rv; | |
138 } | |
139 | |
140 void NPN_Status(NPP instance, const char *message) | |
141 { | |
142 CallNPN_StatusProc(NPNFuncs.status, instance, message); | |
143 } | |
144 | |
145 const char* NPN_UserAgent(NPP instance) | |
146 { | |
147 const char * rv = NULL; | |
148 rv = CallNPN_UserAgentProc(NPNFuncs.uagent, instance); | |
149 return rv; | |
150 } | |
151 */ | |
152 | |
153 void* NPN_MemAlloc(uint32 size) | |
154 { | |
155 void* rv = NULL; | |
156 return NPNFuncs.memalloc(size); | |
157 } | |
158 | |
159 void NPN_MemFree(void* ptr) | |
160 { | |
161 NPNFuncs.memfree(ptr); | |
162 } | |
163 | |
164 /* | |
165 uint32 NPN_MemFlush(uint32 size) | |
166 { | |
167 uint32 rv = CallNPN_MemFlushProc(NPNFuncs.memflush, size); | |
168 return rv; | |
169 } | |
170 | |
171 void NPN_ReloadPlugins(NPBool reloadPages) | |
172 { | |
173 CallNPN_ReloadPluginsProc(NPNFuncs.reloadplugins, reloadPages); | |
174 } | |
175 | |
176 #ifdef OJI | |
177 JRIEnv* NPN_GetJavaEnv(void) | |
178 { | |
179 JRIEnv * rv = NULL; | |
180 rv = CallNPN_GetJavaEnvProc(NPNFuncs.getJavaEnv); | |
181 return rv; | |
182 } | |
183 | |
184 jref NPN_GetJavaPeer(NPP instance) | |
185 { | |
186 jref rv; | |
187 rv = CallNPN_GetJavaPeerProc(NPNFuncs.getJavaPeer, instance); | |
188 return rv; | |
189 } | |
190 #endif | |
191 */ | |
192 | |
193 NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value) | |
194 { | |
195 return NPNFuncs.getvalue(instance, variable, value); | |
196 } | |
197 | |
198 /* | |
199 NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value) | |
200 { | |
201 NPError rv = CallNPN_SetValueProc(NPNFuncs.setvalue, instance, variable, value
); | |
202 return rv; | |
203 } | |
204 | |
205 void NPN_InvalidateRect(NPP instance, NPRect *invalidRect) | |
206 { | |
207 CallNPN_InvalidateRectProc(NPNFuncs.invalidaterect, instance, invalidRect); | |
208 } | |
209 | |
210 void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion) | |
211 { | |
212 CallNPN_InvalidateRegionProc(NPNFuncs.invalidateregion, instance, invalidRegio
n); | |
213 } | |
214 | |
215 void NPN_ForceRedraw(NPP instance) | |
216 { | |
217 CallNPN_ForceRedrawProc(NPNFuncs.forceredraw, instance); | |
218 } | |
219 */ | |
220 | |
221 // Used by the Omaha 3 plugin. | |
222 NPUTF8* NPN_UTF8FromIdentifier(NPIdentifier identifier) { | |
223 return NPNFuncs.utf8fromidentifier(identifier); | |
224 } | |
225 | |
226 NPObject* NPN_RetainObject(NPObject* obj) { | |
227 return NPNFuncs.retainobject(obj); | |
228 } | |
229 | |
230 void NPN_ReleaseObject(NPObject* obj) { | |
231 NPNFuncs.releaseobject(obj); | |
232 } | |
233 | |
234 NPIdentifier NPN_GetStringIdentifier(const NPUTF8* name) { | |
235 return NPNFuncs.getstringidentifier(name); | |
236 } | |
237 | |
238 NPObject* NPN_CreateObject(NPP npp, NPClass* aClass) { | |
239 return NPNFuncs.createobject(npp, aClass); | |
240 } | |
241 | |
242 void NPN_SetException(NPObject* obj, const NPUTF8* message) { | |
243 NPNFuncs.setexception(obj, message); | |
244 } | |
245 | |
246 void NPN_ReleaseVariantValue(NPVariant* variant) { | |
247 NPNFuncs.releasevariantvalue(variant); | |
248 } | |
249 | |
250 bool NPN_GetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName, | |
251 NPVariant* result) { | |
252 return NPNFuncs.getproperty(npp, obj, propertyName, result); | |
253 } | |
254 | |
255 // Some additional stuff that's used by the oneclick plugin | |
256 bool NPN_InvokeDefault(NPP npp, NPObject* obj, const NPVariant* args, | |
257 uint32_t argCount, NPVariant* result) { | |
258 return NPNFuncs.invokeDefault(npp, obj, args, argCount, result); | |
259 } | |
OLD | NEW |