summaryrefslogtreecommitdiffstats
authorDon Pellegrino <don@drexel.edu>2009-09-01 22:27:23 (GMT)
committer Don Pellegrino <don@drexel.edu>2009-09-01 22:27:23 (GMT)
commit7404e79a6a2c1d98f32b65cc07a10955dfdc7876 (patch) (unidiff)
treebe185982288aff6b29c1866819f132b9e5db68d8
parent79e1ce3c5300ef79e13f17f7e86050755d4b08c5 (diff)
downloadexp005-7404e79a6a2c1d98f32b65cc07a10955dfdc7876.zip
exp005-7404e79a6a2c1d98f32b65cc07a10955dfdc7876.tar.gz
exp005-7404e79a6a2c1d98f32b65cc07a10955dfdc7876.tar.bz2
Added example for building a web browser plugin for distribution.
-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/README_plugin.txt b/src/plugin/README_plugin.txt
new file mode 100644
index 0000000..f7e6818
--- a/dev/null
+++ b/src/plugin/README_plugin.txt
@@ -0,0 +1,9 @@
1The contents of this directory are used to deploy the application as a
2web browser plugin. The following references are relevant to the
3technologies used here:
4
5"Plugins," Mozilla Developer Center, last modified August 23, 2009, https://developer.mozilla.org/en/Plugins.
6
7"Shipping a plugin as an extension," Mozilla Developer Center, last
8modified June 2, 2008,
9https://developer.mozilla.org/en/Shipping_a_plugin_as_an_extension.
diff --git a/src/plugin/install.rdf b/src/plugin/install.rdf
new file mode 100644
index 0000000..552cc56
--- a/dev/null
+++ b/src/plugin/install.rdf
@@ -0,0 +1,19 @@
1<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
2 xmlns:em="http://www.mozilla.org/2004/em-rdf#">
3 <Description about="urn:mozilla:install-manifest">
4 <em:id>vistool@donpellegrino.com</em:id>
5 <em:name>Influenza Sequence Mapping Project Visualization Tool</em:name>
6 <em:version>1.0</em:version>
7 <em:targetApplication>
8 <Description>
9 <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
10 <em:minVersion>1.5</em:minVersion>
11 <em:maxVersion>3.6.*</em:maxVersion>
12 </Description>
13 </em:targetApplication>
14 <em:creator>Don Pellegrino</em:creator>
15 <em:homepageURL>http://cluster.ischool.drexel.edu/~st96wym4/flumap/</em:homepageURL>
16 <em:description>Tool for interactive exploration of data from the Influenza Sequence Mapping Project.</em:description>
17 <!-- Add update links here -->
18 </Description>
19</RDF>
diff --git a/src/plugin/make_xpi.sh b/src/plugin/make_xpi.sh
new file mode 100755
index 0000000..cb206db
--- a/dev/null
+++ b/src/plugin/make_xpi.sh
@@ -0,0 +1,22 @@
1#!/bin/sh
2
3# This script creates a XPI file.
4
5# The structure of an Installable Bundle is documented on-line at:
6# https://developer.mozilla.org/en/Bundles. Note that Iceweasel
7# 3.0.12 on Debian x86 is unable to find the library if gcc4 is used
8# in place of gcc3 or if the library name is not truncated to .so.
9# Also running from the GNOME taskbar does not include the DB2
10# run-time in the LD_LIBRARY_PATH which causes the library to fail to
11# load with no errors reported. Running from a shell with the
12# LD_LIBRARY_PATH set resolves this. DB2 run-time libraries should be
13# statically linked however static verions are not including with DB2
14# v9.5 Express/C.
15cp ../.libs/libflumapplugin.so.0.0.0 \
16platform/Linux_x86-gcc3/plugins/libflumapplugin.so
17
18# ZIP is used make the extension as per the instructions at:
19# https://developer.mozilla.org/en/Extension_Packaging
20zip -r flumap.xpi \
21install.rdf \
22platform/*
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}
diff --git a/src/plugin/plugin.h b/src/plugin/plugin.h
new file mode 100644
index 0000000..2f1d505
--- a/dev/null
+++ b/src/plugin/plugin.h
@@ -0,0 +1,29 @@
1#ifndef PLUGIN_H
2#define PLUGIN_H
3
4/*
5 * Based on Basic Plugin exmaple from Mozilla on-line at
6 * http://mxr.mozilla.org/mozilla-central/source/modules/plugin/sdk/samples/basic/unix/BasicPlugin.h
7 */
8
9#include <npapi.h>
10#include <npupp.h>
11
12NPError NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs);
13NPError NP_Shutdown();
14
15NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved);
16NPError NPP_Destroy(NPP instance, NPSavedData** save);
17NPError NPP_SetWindow(NPP instance, NPWindow* window);
18NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype);
19NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason);
20int32_t NPP_WriteReady(NPP instance, NPStream* stream);
21int32_t NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer);
22void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
23void NPP_Print(NPP instance, NPPrint* platformPrint);
24int16_t NPP_HandleEvent(NPP instance, void* event);
25void NPP_URLNotify(NPP instance, const char* URL, NPReason reason, void* notifyData);
26NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value);
27NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value);
28
29#endif // PLUGIN_H
diff --git a/src/plugin/test.html b/src/plugin/test.html
new file mode 100644
index 0000000..ce35369
--- a/dev/null
+++ b/src/plugin/test.html
@@ -0,0 +1,17 @@
1<html>
2 <body>
3
4 <center><h1>Basic Plugin Example for Mozilla Test Case</h1></center>
5
6 This test case is to demonstrate the Basic Plugin example. You
7 should see the plugin window with the black frame aroung it and
8 the browser user agent string which plugin draws inside the
9 window.
10 <br><br>
11
12 <center>
13 <embed type="application/x-flumap" width=600 height=80>
14 </center>
15
16 </body>
17</html>

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.