-rw-r--r-- | src/plugin/README_plugin.txt | 9 | ||||
-rw-r--r-- | src/plugin/install.rdf | 19 | ||||
-rwxr-xr-x | src/plugin/make_xpi.sh | 22 | ||||
-rw-r--r-- | src/plugin/plugin.c | 199 | ||||
-rw-r--r-- | src/plugin/plugin.h | 29 | ||||
-rw-r--r-- | src/plugin/test.html | 17 |
6 files changed, 295 insertions, 0 deletions
diff --git a/src/plugin/plugin.c b/src/plugin/plugin.c new file mode 100644 index 0000000..300e2f3 --- a/dev/null +++ b/src/plugin/plugin.c | |||
@@ -0,0 +1,199 @@ | |||
1 | #include "plugin.h" | ||
2 | |||
3 | #include <stdlib.h> | ||
4 | #include <string.h> | ||
5 | #include <stdio.h> | ||
6 | |||
7 | /* | ||
8 | * This code is based on the Basic Plugin Example from Mozilla on-line | ||
9 | * at | ||
10 | * http://mxr.mozilla.org/mozilla-central/source/modules/plugin/sdk/samples/basic/unix/BasicPlugin.c. | ||
11 | */ | ||
12 | |||
13 | #define PLUGIN_NAME "Influenza Sequence Mapping Project Visualization Tool" | ||
14 | #define PLUGIN_DESCRIPTION "A tool for data exploration and discovery." | ||
15 | #define PLUGIN_VERSION "0.1" | ||
16 | |||
17 | static NPNetscapeFuncs* sBrowserFuncs = NULL; | ||
18 | |||
19 | typedef struct InstanceData | ||
20 | { | ||
21 | NPP npp; | ||
22 | NPWindow window; | ||
23 | } InstanceData; | ||
24 | |||
25 | static void | ||
26 | fillPluginFunctionTable (NPPluginFuncs* pFuncs) | ||
27 | { | ||
28 | pFuncs->version = 11; | ||
29 | pFuncs->size = sizeof(*pFuncs); | ||
30 | pFuncs->newp = NPP_New; | ||
31 | pFuncs->destroy = NPP_Destroy; | ||
32 | pFuncs->setwindow = NPP_SetWindow; | ||
33 | pFuncs->newstream = NPP_NewStream; | ||
34 | pFuncs->destroystream = NPP_DestroyStream; | ||
35 | pFuncs->asfile = NPP_StreamAsFile; | ||
36 | pFuncs->writeready = NPP_WriteReady; | ||
37 | pFuncs->write = NPP_Write; | ||
38 | pFuncs->print = NPP_Print; | ||
39 | pFuncs->event = NPP_HandleEvent; | ||
40 | pFuncs->urlnotify = NPP_URLNotify; | ||
41 | pFuncs->getvalue = NPP_GetValue; | ||
42 | pFuncs->setvalue = NPP_SetValue; | ||
43 | |||
44 | return; | ||
45 | } | ||
46 | |||
47 | NP_EXPORT(NPError) | ||
48 | NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs) | ||
49 | { | ||
50 | sBrowserFuncs = bFuncs; | ||
51 | |||
52 | fillPluginFunctionTable(pFuncs); | ||
53 | |||
54 | return NPERR_NO_ERROR; | ||
55 | } | ||
56 | |||
57 | NP_EXPORT(char*) | ||
58 | NP_GetPluginVersion() | ||
59 | { | ||
60 | return PLUGIN_VERSION; | ||
61 | } | ||
62 | |||
63 | NP_EXPORT(char*) | ||
64 | NP_GetMIMEDescription() | ||
65 | { | ||
66 | return "application/x-flumap::Visualization Tool"; | ||
67 | } | ||
68 | |||
69 | NP_EXPORT(NPError) | ||
70 | NP_GetValue(void* future, NPPVariable aVariable, void* aValue) | ||
71 | { | ||
72 | switch (aVariable) | ||
73 | { | ||
74 | case NPPVpluginNameString: | ||
75 | *((char**)aValue) = PLUGIN_NAME; | ||
76 | break; | ||
77 | case NPPVpluginDescriptionString: | ||
78 | *((char**)aValue) = PLUGIN_DESCRIPTION; | ||
79 | break; | ||
80 | default: | ||
81 | return NPERR_INVALID_PARAM; | ||
82 | break; | ||
83 | } | ||
84 | |||
85 | return NPERR_NO_ERROR; | ||
86 | } | ||
87 | |||
88 | NP_EXPORT(NPError) | ||
89 | NP_Shutdown() | ||
90 | { | ||
91 | return NPERR_NO_ERROR; | ||
92 | } | ||
93 | |||
94 | NPError | ||
95 | NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved) | ||
96 | { | ||
97 | // Make sure we can render this plugin | ||
98 | NPBool browserSupportsWindowless = false; | ||
99 | sBrowserFuncs->getvalue(instance, NPNVSupportsWindowless, &browserSupportsWindowless); | ||
100 | if (!browserSupportsWindowless) { | ||
101 | printf("Windowless mode not supported by the browser\n"); | ||
102 | return NPERR_GENERIC_ERROR; | ||
103 | } | ||
104 | |||
105 | sBrowserFuncs->setvalue(instance, NPPVpluginWindowBool, (void*)false); | ||
106 | |||
107 | // set up our our instance data | ||
108 | InstanceData* instanceData = (InstanceData*)malloc(sizeof(InstanceData)); | ||
109 | if (!instanceData) | ||
110 | return NPERR_OUT_OF_MEMORY_ERROR; | ||
111 | memset(instanceData, 0, sizeof(InstanceData)); | ||
112 | instanceData->npp = instance; | ||
113 | instance->pdata = instanceData; | ||
114 | |||
115 | return NPERR_NO_ERROR; | ||
116 | } | ||
117 | |||
118 | NPError | ||
119 | NPP_Destroy(NPP instance, NPSavedData** save) | ||
120 | { | ||
121 | InstanceData* instanceData = (InstanceData*)(instance->pdata); | ||
122 | free(instanceData); | ||
123 | return NPERR_NO_ERROR; | ||
124 | } | ||
125 | |||
126 | NPError | ||
127 | NPP_SetWindow(NPP instance, NPWindow* window) | ||
128 | { | ||
129 | InstanceData* instanceData = (InstanceData*)(instance->pdata); | ||
130 | instanceData->window = *window; | ||
131 | return NPERR_NO_ERROR; | ||
132 | } | ||
133 | |||
134 | NPError | ||
135 | NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype) | ||
136 | { | ||
137 | return NPERR_GENERIC_ERROR; | ||
138 | } | ||
139 | |||
140 | NPError | ||
141 | NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason) | ||
142 | { | ||
143 | return NPERR_GENERIC_ERROR; | ||
144 | } | ||
145 | |||
146 | int32_t | ||
147 | NPP_WriteReady(NPP instance, NPStream* stream) | ||
148 | { | ||
149 | return 0; | ||
150 | } | ||
151 | |||
152 | int32_t | ||
153 | NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer) | ||
154 | { | ||
155 | return 0; | ||
156 | } | ||
157 | |||
158 | void | ||
159 | NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname) | ||
160 | { | ||
161 | return; | ||
162 | } | ||
163 | |||
164 | void | ||
165 | NPP_Print(NPP instance, NPPrint* platformPrint) { | ||
166 | return; | ||
167 | } | ||
168 | |||
169 | int16_t | ||
170 | NPP_HandleEvent(NPP instance, void* event) | ||
171 | { | ||
172 | InstanceData *instanceData = (InstanceData*)(instance->pdata); | ||
173 | // XEvent *nativeEvent = (XEvent*)event; | ||
174 | |||
175 | // if (nativeEvent->type != GraphicsExpose) | ||
176 | //return 0; | ||
177 | |||
178 | printf ("In NPP_HandleEvent for the plugin.\n"); | ||
179 | |||
180 | return 1; | ||
181 | } | ||
182 | |||
183 | void | ||
184 | NPP_URLNotify(NPP instance, const char* URL, NPReason reason, void* notifyData) | ||
185 | { | ||
186 | return; | ||
187 | } | ||
188 | |||
189 | NPError | ||
190 | NPP_GetValue(NPP instance, NPPVariable variable, void *value) | ||
191 | { | ||
192 | return NPERR_GENERIC_ERROR; | ||
193 | } | ||
194 | |||
195 | NPError | ||
196 | NPP_SetValue(NPP instance, NPNVariable variable, void *value) | ||
197 | { | ||
198 | return NPERR_GENERIC_ERROR; | ||
199 | } | ||