|
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 |
#ifndef PLUGINBASE_H_ |
|
|
20 |
#define PLUGINBASE_H_ |
|
|
21 |
|
|
|
22 |
#include <npapi.h> |
|
|
23 |
#include <npupp.h> |
|
|
24 |
#include <npruntime.h> |
|
|
25 |
|
|
|
26 |
#ifndef HIBYTE |
|
|
27 |
#define HIBYTE(i) (i >> 8) |
|
|
28 |
#endif |
|
|
29 |
|
|
|
30 |
#ifndef LOBYTE |
|
|
31 |
#define LOBYTE(i) (i & 0xff) |
|
|
32 |
#endif |
|
|
33 |
|
|
|
34 |
struct nsPluginCreateData |
|
|
35 |
{ |
|
|
36 |
NPP instance; |
|
|
37 |
NPMIMEType type; |
|
|
38 |
uint16 mode; |
|
|
39 |
int16 argc; |
|
|
40 |
char** argn; |
|
|
41 |
char** argv; |
|
|
42 |
NPSavedData* saved; |
|
|
43 |
}; |
|
|
44 |
|
|
|
45 |
class nsPluginInstanceBase |
|
|
46 |
{ |
|
|
47 |
public: |
|
|
48 |
virtual ~nsPluginInstanceBase() { return; } |
|
|
49 |
|
|
|
50 |
// these three methods must be implemented in the derived |
|
|
51 |
// class platform specific way |
|
|
52 |
virtual NPBool init(NPWindow* aWindow) = 0; |
|
|
53 |
virtual void shut() = 0; |
|
|
54 |
virtual NPBool isInitialized() = 0; |
|
|
55 |
|
|
|
56 |
// implement all or part of those methods in the derived |
|
|
57 |
// class as needed |
|
|
58 |
virtual NPError SetWindow(NPWindow* /*pNPWindow*/) { return NPERR_NO_ERROR; } |
|
|
59 |
virtual NPError WriteStatus(const char* /*msg*/) const { return NPERR_NO_ERROR; } |
|
|
60 |
virtual NPError NewStream(NPMIMEType /*type*/, NPStream* /*stream*/, |
|
|
61 |
NPBool /*seekable*/, uint16* /*stype*/) { return NPERR_NO_ERROR; } |
|
|
62 |
virtual NPError DestroyStream(NPStream* /*stream*/, NPError /*reason*/) { return NPERR_NO_ERROR; } |
|
|
63 |
virtual void StreamAsFile(NPStream* /*stream*/, const char* /*fname*/) { return; } |
|
|
64 |
virtual int32_t WriteReady(NPStream* /*stream*/) { return 0x0fffffff; } |
|
|
65 |
virtual int32 Write(NPStream* /*stream*/, int32 /*offset*/, |
|
|
66 |
int32 len, void* /*buffer*/) { return len; } |
|
|
67 |
virtual void Print(NPPrint* /*printInfo*/) { return; } |
|
|
68 |
virtual uint16 HandleEvent(void* /*event*/) { return 0; } |
|
|
69 |
virtual void URLNotify(const char* /*url*/, NPReason /*reason*/, |
|
|
70 |
void* /*notifyData*/) { return; } |
|
|
71 |
virtual NPError GetValue(NPPVariable /*variable*/, void* /*value*/) { return NPERR_NO_ERROR; } |
|
|
72 |
virtual NPError SetValue(NPNVariable /*variable*/, void* /*value*/) { return NPERR_NO_ERROR; } |
|
|
73 |
}; |
|
|
74 |
|
|
|
75 |
// functions that should be implemented for each specific plugin |
|
|
76 |
|
|
|
77 |
// creation and destruction of the object of the derived class |
|
|
78 |
nsPluginInstanceBase * NS_NewPluginInstance(nsPluginCreateData * aCreateDataStruct); |
|
|
79 |
void NS_DestroyPluginInstance(nsPluginInstanceBase * aPlugin); |
|
|
80 |
|
|
|
81 |
// global plugin initialization and shutdown |
|
|
82 |
NPError NS_PluginInitialize(); |
|
|
83 |
void NS_PluginShutdown(); |
|
|
84 |
|
|
|
85 |
// FIXME #ifdef XP_UNIX |
|
|
86 |
// global to get plugins name & description |
|
|
87 |
NPError NS_PluginGetValue(NPPVariable aVariable, void *aValue); |
|
|
88 |
// FIXME #endif |
|
|
89 |
|
|
|
90 |
#endif // __PLUGININSTANCEBASE_H__ |