0
|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
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 // Main plugin entry point implementation
|
|
41 //
|
|
42 #include "npapi.h"
|
|
43 #include "npupp.h"
|
|
44
|
|
45 #ifndef HIBYTE
|
|
46 #define HIBYTE(x) ((((uint32)(x)) & 0xff00) >> 8)
|
|
47 #endif
|
|
48
|
|
49 NPNetscapeFuncs NPNFuncs;
|
|
50
|
|
51 #ifdef XP_WIN
|
|
52
|
|
53 NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs)
|
|
54 {
|
|
55 if(pFuncs == NULL)
|
|
56 return NPERR_INVALID_FUNCTABLE_ERROR;
|
|
57
|
|
58 if(pFuncs->size < sizeof(NPPluginFuncs))
|
|
59 return NPERR_INVALID_FUNCTABLE_ERROR;
|
|
60
|
|
61 pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
|
|
62 pFuncs->newp = NPP_New;
|
|
63 pFuncs->destroy = NPP_Destroy;
|
|
64 pFuncs->setwindow = NPP_SetWindow;
|
|
65 pFuncs->newstream = NPP_NewStream;
|
|
66 pFuncs->destroystream = NPP_DestroyStream;
|
|
67 pFuncs->asfile = NPP_StreamAsFile;
|
|
68 pFuncs->writeready = NPP_WriteReady;
|
|
69 pFuncs->write = NPP_Write;
|
|
70 pFuncs->print = NPP_Print;
|
|
71 pFuncs->event = NPP_HandleEvent;
|
|
72 pFuncs->urlnotify = NPP_URLNotify;
|
|
73 pFuncs->getvalue = NPP_GetValue;
|
|
74 pFuncs->setvalue = NPP_SetValue;
|
|
75 pFuncs->javaClass = NULL;
|
|
76
|
|
77 return NPERR_NO_ERROR;
|
|
78 }
|
|
79
|
|
80 #endif /* XP_WIN */
|
|
81
|
|
82 char *NPP_GetMIMEDescription();
|
|
83
|
|
84 char *
|
|
85 NP_GetMIMEDescription()
|
|
86 {
|
|
87 return NPP_GetMIMEDescription();
|
|
88 }
|
|
89
|
|
90 NPError
|
|
91 NP_GetValue(void* future, NPPVariable variable, void *value)
|
|
92 {
|
|
93 return NPP_GetValue((NPP_t *)future, variable, value);
|
|
94 }
|
|
95
|
|
96 NPError OSCALL
|
|
97 NP_Initialize(NPNetscapeFuncs* pFuncs
|
|
98 #ifdef XP_UNIX
|
|
99 , NPPluginFuncs* pluginFuncs
|
|
100 #endif
|
|
101 )
|
|
102 {
|
|
103 if(pFuncs == NULL)
|
|
104 return NPERR_INVALID_FUNCTABLE_ERROR;
|
|
105
|
|
106 if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
|
|
107 return NPERR_INCOMPATIBLE_VERSION_ERROR;
|
|
108
|
|
109 if(pFuncs->size < sizeof(NPNetscapeFuncs))
|
|
110 return NPERR_INVALID_FUNCTABLE_ERROR;
|
|
111
|
|
112 NPNFuncs.size = pFuncs->size;
|
|
113 NPNFuncs.version = pFuncs->version;
|
|
114 NPNFuncs.geturlnotify = pFuncs->geturlnotify;
|
|
115 NPNFuncs.geturl = pFuncs->geturl;
|
|
116 NPNFuncs.posturlnotify = pFuncs->posturlnotify;
|
|
117 NPNFuncs.posturl = pFuncs->posturl;
|
|
118 NPNFuncs.requestread = pFuncs->requestread;
|
|
119 NPNFuncs.newstream = pFuncs->newstream;
|
|
120 NPNFuncs.write = pFuncs->write;
|
|
121 NPNFuncs.destroystream = pFuncs->destroystream;
|
|
122 NPNFuncs.status = pFuncs->status;
|
|
123 NPNFuncs.uagent = pFuncs->uagent;
|
|
124 NPNFuncs.memalloc = pFuncs->memalloc;
|
|
125 NPNFuncs.memfree = pFuncs->memfree;
|
|
126 NPNFuncs.memflush = pFuncs->memflush;
|
|
127 NPNFuncs.reloadplugins = pFuncs->reloadplugins;
|
|
128 NPNFuncs.getJavaEnv = pFuncs->getJavaEnv;
|
|
129 NPNFuncs.getJavaPeer = pFuncs->getJavaPeer;
|
|
130 NPNFuncs.getvalue = pFuncs->getvalue;
|
|
131 NPNFuncs.setvalue = pFuncs->setvalue;
|
|
132 NPNFuncs.invalidaterect = pFuncs->invalidaterect;
|
|
133 NPNFuncs.invalidateregion = pFuncs->invalidateregion;
|
|
134 NPNFuncs.forceredraw = pFuncs->forceredraw;
|
|
135 NPNFuncs.getstringidentifier = pFuncs->getstringidentifier;
|
|
136 NPNFuncs.getstringidentifiers = pFuncs->getstringidentifiers;
|
|
137 NPNFuncs.getintidentifier = pFuncs->getintidentifier;
|
|
138 NPNFuncs.identifierisstring = pFuncs->identifierisstring;
|
|
139 NPNFuncs.utf8fromidentifier = pFuncs->utf8fromidentifier;
|
|
140 NPNFuncs.intfromidentifier = pFuncs->intfromidentifier;
|
|
141 NPNFuncs.createobject = pFuncs->createobject;
|
|
142 NPNFuncs.retainobject = pFuncs->retainobject;
|
|
143 NPNFuncs.releaseobject = pFuncs->releaseobject;
|
|
144 NPNFuncs.invoke = pFuncs->invoke;
|
|
145 NPNFuncs.invokeDefault = pFuncs->invokeDefault;
|
|
146 NPNFuncs.evaluate = pFuncs->evaluate;
|
|
147 NPNFuncs.getproperty = pFuncs->getproperty;
|
|
148 NPNFuncs.setproperty = pFuncs->setproperty;
|
|
149 NPNFuncs.removeproperty = pFuncs->removeproperty;
|
|
150 NPNFuncs.hasproperty = pFuncs->hasproperty;
|
|
151 NPNFuncs.hasmethod = pFuncs->hasmethod;
|
|
152 NPNFuncs.releasevariantvalue = pFuncs->releasevariantvalue;
|
|
153 NPNFuncs.setexception = pFuncs->setexception;
|
|
154
|
|
155 #ifdef XP_UNIX
|
|
156 /*
|
|
157 * Set up the plugin function table that Netscape will use to
|
|
158 * call us. Netscape needs to know about our version and size
|
|
159 * and have a UniversalProcPointer for every function we
|
|
160 * implement.
|
|
161 */
|
|
162 pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
|
|
163 pluginFuncs->size = sizeof(NPPluginFuncs);
|
|
164 pluginFuncs->newp = NewNPP_NewProc(NPP_New);
|
|
165 pluginFuncs->destroy = NewNPP_DestroyProc(NPP_Destroy);
|
|
166 pluginFuncs->setwindow = NewNPP_SetWindowProc(NPP_SetWindow);
|
|
167 pluginFuncs->newstream = NewNPP_NewStreamProc(NPP_NewStream);
|
|
168 pluginFuncs->destroystream = NewNPP_DestroyStreamProc(NPP_DestroyStream);
|
|
169 pluginFuncs->asfile = NewNPP_StreamAsFileProc(NPP_StreamAsFile);
|
|
170 pluginFuncs->writeready = NewNPP_WriteReadyProc(NPP_WriteReady);
|
|
171 pluginFuncs->write = NewNPP_WriteProc(NPP_Write);
|
|
172 pluginFuncs->print = NewNPP_PrintProc(NPP_Print);
|
|
173 pluginFuncs->urlnotify = NewNPP_URLNotifyProc(NPP_URLNotify);
|
|
174 pluginFuncs->event = NULL;
|
|
175 pluginFuncs->getvalue = NewNPP_GetValueProc(NPP_GetValue);
|
|
176 #ifdef OJI
|
|
177 pluginFuncs->javaClass = NPP_GetJavaClass();
|
|
178 #endif
|
|
179
|
|
180 NPP_Initialize();
|
|
181 #endif
|
|
182
|
|
183 return NPERR_NO_ERROR;
|
|
184 }
|
|
185
|
|
186 NPError OSCALL NP_Shutdown()
|
|
187 {
|
|
188 return NPERR_NO_ERROR;
|
|
189 }
|