summaryrefslogtreecommitdiffstats
Unidiff
-rw-r--r--src/plugin/README_plugin.txt9
-rw-r--r--src/plugin/install.rdf19
-rwxr-xr-xsrc/plugin/make_xpi.sh22
-rw-r--r--src/plugin/plugin.c199
-rw-r--r--src/plugin/plugin.h29
-rw-r--r--src/plugin/test.html17
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
17static NPNetscapeFuncs* sBrowserFuncs = NULL;
18
19typedef struct InstanceData
20{
21 NPP npp;
22 NPWindow window;
23} InstanceData;
24
25static void
26fillPluginFunctionTable (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
47NP_EXPORT(NPError)
48NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs)
49{
50 sBrowserFuncs = bFuncs;
51
52 fillPluginFunctionTable(pFuncs);
53
54 return NPERR_NO_ERROR;
55}
56
57NP_EXPORT(char*)
58NP_GetPluginVersion()
59{
60 return PLUGIN_VERSION;
61}
62
63NP_EXPORT(char*)
64NP_GetMIMEDescription()
65{
66 return "application/x-flumap::Visualization Tool";
67}
68
69NP_EXPORT(NPError)
70NP_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
88NP_EXPORT(NPError)
89NP_Shutdown()
90{
91 return NPERR_NO_ERROR;
92}
93
94NPError
95NPP_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
118NPError
119NPP_Destroy(NPP instance, NPSavedData** save)
120{
121 InstanceData* instanceData = (InstanceData*)(instance->pdata);
122 free(instanceData);
123 return NPERR_NO_ERROR;
124}
125
126NPError
127NPP_SetWindow(NPP instance, NPWindow* window)
128{
129 InstanceData* instanceData = (InstanceData*)(instance->pdata);
130 instanceData->window = *window;
131 return NPERR_NO_ERROR;
132}
133
134NPError
135NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype)
136{
137 return NPERR_GENERIC_ERROR;
138}
139
140NPError
141NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason)
142{
143 return NPERR_GENERIC_ERROR;
144}
145
146int32_t
147NPP_WriteReady(NPP instance, NPStream* stream)
148{
149 return 0;
150}
151
152int32_t
153NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer)
154{
155 return 0;
156}
157
158void
159NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
160{
161 return;
162}
163
164void
165NPP_Print(NPP instance, NPPrint* platformPrint) {
166 return;
167}
168
169int16_t
170NPP_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
183void
184NPP_URLNotify(NPP instance, const char* URL, NPReason reason, void* notifyData)
185{
186 return;
187}
188
189NPError
190NPP_GetValue(NPP instance, NPPVariable variable, void *value)
191{
192 return NPERR_GENERIC_ERROR;
193}
194
195NPError
196NPP_SetValue(NPP instance, NPNVariable variable, void *value)
197{
198 return NPERR_GENERIC_ERROR;
199}

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.