Mercurial > simple_npapi_plugin
annotate np_entry.cpp @ 5:6696b6295860 default tip
Decided to abandon this plugin, for now at least. See README for details.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Wed, 30 Apr 2008 23:53:21 -0700 |
parents | 9a9f30dde6c1 |
children |
rev | line source |
---|---|
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 // | |
4
9a9f30dde6c1
Switched to using mozilla-config.h
Atul Varma <varmaa@toolness.com>
parents:
0
diff
changeset
|
42 #include "mozilla-config.h" |
0 | 43 #include "npapi.h" |
44 #include "npupp.h" | |
45 | |
46 #ifndef HIBYTE | |
47 #define HIBYTE(x) ((((uint32)(x)) & 0xff00) >> 8) | |
48 #endif | |
49 | |
50 NPNetscapeFuncs NPNFuncs; | |
51 | |
52 #ifdef XP_WIN | |
53 | |
54 NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs) | |
55 { | |
56 if(pFuncs == NULL) | |
57 return NPERR_INVALID_FUNCTABLE_ERROR; | |
58 | |
59 if(pFuncs->size < sizeof(NPPluginFuncs)) | |
60 return NPERR_INVALID_FUNCTABLE_ERROR; | |
61 | |
62 pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; | |
63 pFuncs->newp = NPP_New; | |
64 pFuncs->destroy = NPP_Destroy; | |
65 pFuncs->setwindow = NPP_SetWindow; | |
66 pFuncs->newstream = NPP_NewStream; | |
67 pFuncs->destroystream = NPP_DestroyStream; | |
68 pFuncs->asfile = NPP_StreamAsFile; | |
69 pFuncs->writeready = NPP_WriteReady; | |
70 pFuncs->write = NPP_Write; | |
71 pFuncs->print = NPP_Print; | |
72 pFuncs->event = NPP_HandleEvent; | |
73 pFuncs->urlnotify = NPP_URLNotify; | |
74 pFuncs->getvalue = NPP_GetValue; | |
75 pFuncs->setvalue = NPP_SetValue; | |
76 pFuncs->javaClass = NULL; | |
77 | |
78 return NPERR_NO_ERROR; | |
79 } | |
80 | |
81 #endif /* XP_WIN */ | |
82 | |
83 char *NPP_GetMIMEDescription(); | |
84 | |
85 char * | |
86 NP_GetMIMEDescription() | |
87 { | |
88 return NPP_GetMIMEDescription(); | |
89 } | |
90 | |
5
6696b6295860
Decided to abandon this plugin, for now at least. See README for details.
Atul Varma <varmaa@toolness.com>
parents:
4
diff
changeset
|
91 #include <stdio.h> |
6696b6295860
Decided to abandon this plugin, for now at least. See README for details.
Atul Varma <varmaa@toolness.com>
parents:
4
diff
changeset
|
92 |
0 | 93 NPError |
94 NP_GetValue(void* future, NPPVariable variable, void *value) | |
95 { | |
96 return NPP_GetValue((NPP_t *)future, variable, value); | |
97 } | |
98 | |
99 NPError OSCALL | |
100 NP_Initialize(NPNetscapeFuncs* pFuncs | |
101 #ifdef XP_UNIX | |
102 , NPPluginFuncs* pluginFuncs | |
103 #endif | |
104 ) | |
105 { | |
106 if(pFuncs == NULL) | |
107 return NPERR_INVALID_FUNCTABLE_ERROR; | |
108 | |
109 if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR) | |
110 return NPERR_INCOMPATIBLE_VERSION_ERROR; | |
111 | |
112 if(pFuncs->size < sizeof(NPNetscapeFuncs)) | |
113 return NPERR_INVALID_FUNCTABLE_ERROR; | |
114 | |
115 NPNFuncs.size = pFuncs->size; | |
116 NPNFuncs.version = pFuncs->version; | |
117 NPNFuncs.geturlnotify = pFuncs->geturlnotify; | |
118 NPNFuncs.geturl = pFuncs->geturl; | |
119 NPNFuncs.posturlnotify = pFuncs->posturlnotify; | |
120 NPNFuncs.posturl = pFuncs->posturl; | |
121 NPNFuncs.requestread = pFuncs->requestread; | |
122 NPNFuncs.newstream = pFuncs->newstream; | |
123 NPNFuncs.write = pFuncs->write; | |
124 NPNFuncs.destroystream = pFuncs->destroystream; | |
125 NPNFuncs.status = pFuncs->status; | |
126 NPNFuncs.uagent = pFuncs->uagent; | |
127 NPNFuncs.memalloc = pFuncs->memalloc; | |
128 NPNFuncs.memfree = pFuncs->memfree; | |
129 NPNFuncs.memflush = pFuncs->memflush; | |
130 NPNFuncs.reloadplugins = pFuncs->reloadplugins; | |
131 NPNFuncs.getJavaEnv = pFuncs->getJavaEnv; | |
132 NPNFuncs.getJavaPeer = pFuncs->getJavaPeer; | |
133 NPNFuncs.getvalue = pFuncs->getvalue; | |
134 NPNFuncs.setvalue = pFuncs->setvalue; | |
135 NPNFuncs.invalidaterect = pFuncs->invalidaterect; | |
136 NPNFuncs.invalidateregion = pFuncs->invalidateregion; | |
137 NPNFuncs.forceredraw = pFuncs->forceredraw; | |
138 NPNFuncs.getstringidentifier = pFuncs->getstringidentifier; | |
139 NPNFuncs.getstringidentifiers = pFuncs->getstringidentifiers; | |
140 NPNFuncs.getintidentifier = pFuncs->getintidentifier; | |
141 NPNFuncs.identifierisstring = pFuncs->identifierisstring; | |
142 NPNFuncs.utf8fromidentifier = pFuncs->utf8fromidentifier; | |
143 NPNFuncs.intfromidentifier = pFuncs->intfromidentifier; | |
144 NPNFuncs.createobject = pFuncs->createobject; | |
145 NPNFuncs.retainobject = pFuncs->retainobject; | |
146 NPNFuncs.releaseobject = pFuncs->releaseobject; | |
147 NPNFuncs.invoke = pFuncs->invoke; | |
148 NPNFuncs.invokeDefault = pFuncs->invokeDefault; | |
149 NPNFuncs.evaluate = pFuncs->evaluate; | |
150 NPNFuncs.getproperty = pFuncs->getproperty; | |
151 NPNFuncs.setproperty = pFuncs->setproperty; | |
152 NPNFuncs.removeproperty = pFuncs->removeproperty; | |
153 NPNFuncs.hasproperty = pFuncs->hasproperty; | |
154 NPNFuncs.hasmethod = pFuncs->hasmethod; | |
155 NPNFuncs.releasevariantvalue = pFuncs->releasevariantvalue; | |
156 NPNFuncs.setexception = pFuncs->setexception; | |
157 | |
158 #ifdef XP_UNIX | |
159 /* | |
160 * Set up the plugin function table that Netscape will use to | |
161 * call us. Netscape needs to know about our version and size | |
162 * and have a UniversalProcPointer for every function we | |
163 * implement. | |
164 */ | |
165 pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR; | |
166 pluginFuncs->size = sizeof(NPPluginFuncs); | |
167 pluginFuncs->newp = NewNPP_NewProc(NPP_New); | |
168 pluginFuncs->destroy = NewNPP_DestroyProc(NPP_Destroy); | |
169 pluginFuncs->setwindow = NewNPP_SetWindowProc(NPP_SetWindow); | |
170 pluginFuncs->newstream = NewNPP_NewStreamProc(NPP_NewStream); | |
171 pluginFuncs->destroystream = NewNPP_DestroyStreamProc(NPP_DestroyStream); | |
172 pluginFuncs->asfile = NewNPP_StreamAsFileProc(NPP_StreamAsFile); | |
173 pluginFuncs->writeready = NewNPP_WriteReadyProc(NPP_WriteReady); | |
174 pluginFuncs->write = NewNPP_WriteProc(NPP_Write); | |
175 pluginFuncs->print = NewNPP_PrintProc(NPP_Print); | |
176 pluginFuncs->urlnotify = NewNPP_URLNotifyProc(NPP_URLNotify); | |
177 pluginFuncs->event = NULL; | |
178 pluginFuncs->getvalue = NewNPP_GetValueProc(NPP_GetValue); | |
179 #ifdef OJI | |
180 pluginFuncs->javaClass = NPP_GetJavaClass(); | |
181 #endif | |
182 | |
183 NPP_Initialize(); | |
184 #endif | |
185 | |
186 return NPERR_NO_ERROR; | |
187 } | |
188 | |
189 NPError OSCALL NP_Shutdown() | |
190 { | |
191 return NPERR_NO_ERROR; | |
192 } | |
5
6696b6295860
Decided to abandon this plugin, for now at least. See README for details.
Atul Varma <varmaa@toolness.com>
parents:
4
diff
changeset
|
193 |
6696b6295860
Decided to abandon this plugin, for now at least. See README for details.
Atul Varma <varmaa@toolness.com>
parents:
4
diff
changeset
|
194 /* This function declaration taken from |
6696b6295860
Decided to abandon this plugin, for now at least. See README for details.
Atul Varma <varmaa@toolness.com>
parents:
4
diff
changeset
|
195 * modules/plugin/samples/default/mac/npmac.cpp. */ |
6696b6295860
Decided to abandon this plugin, for now at least. See README for details.
Atul Varma <varmaa@toolness.com>
parents:
4
diff
changeset
|
196 int main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp); |
6696b6295860
Decided to abandon this plugin, for now at least. See README for details.
Atul Varma <varmaa@toolness.com>
parents:
4
diff
changeset
|
197 |
6696b6295860
Decided to abandon this plugin, for now at least. See README for details.
Atul Varma <varmaa@toolness.com>
parents:
4
diff
changeset
|
198 DEFINE_API_C(int) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp) |
6696b6295860
Decided to abandon this plugin, for now at least. See README for details.
Atul Varma <varmaa@toolness.com>
parents:
4
diff
changeset
|
199 { |
6696b6295860
Decided to abandon this plugin, for now at least. See README for details.
Atul Varma <varmaa@toolness.com>
parents:
4
diff
changeset
|
200 printf("In main().\n"); |
6696b6295860
Decided to abandon this plugin, for now at least. See README for details.
Atul Varma <varmaa@toolness.com>
parents:
4
diff
changeset
|
201 } |