/[gcjwebplugin]/gcjwebplugin/src/gcjwebplugin.cc
ViewVC logotype

Diff of /gcjwebplugin/src/gcjwebplugin.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by mkoch, Wed Jul 30 05:40:36 2003 UTC revision 1.3 by fitzsim, Mon Sep 15 02:52:00 2003 UTC
# Line 36  exception statement from your version. * Line 36  exception statement from your version. *
36    
37  #include <npapi.h>  #include <npapi.h>
38  #include <npupp.h>  #include <npupp.h>
39    #include <string.h>
 #include <jni.h>  
   
 #include "jniHelp.h"  
40  #include "config.h"  #include "config.h"
41    
42  #define PLUGIN_NAME "GCJ web browser plugin " PACKAGE_VERSION  #define PLUGIN_NAME "GCJ web browser plugin " PACKAGE_VERSION
43  #define PLUGIN_DESC "GCJ web browser plugin executes Java applets in Mozilla and other web browsers"  #define PLUGIN_DESC "GCJ web browser plugin executes Java applets in Mozilla and other web browsers"
44  #define PLUGIN_MIME_TYPE "application/x-java-applet"  #define PLUGIN_MIME_TYPE "application/x-java-applet"
45  #define PLUGIN_MIME_DESC "application/x-java-applet::Java(tm) Plug-in"  #define PLUGIN_MIME_DESC "application/x-java-applet:class,jar:GCJ Java Plugin"
46    #define PLUGIN_FILE_EXTS "class,jar"
47    
48  #define PLUGIN_DEBUG(arg) ;  #define PLUGIN_DEBUG(arg) printf("%s", arg)
49    
50  struct GCJPluginData  struct GCJPluginData
51  {  {
52    JNIEnv* jniEnv;    char *code;
53        char *codebase;
54    jclass embeddedWindow_class;    char *archive;
55    jclass applet_class;    char *documentbase;
56      char *parameters;
57    jobject embeddedWindow;    int width;
58    jobject applet;    int height;
59      int xid;
60  };  };
61    
62  char*  char*
63  NPP_GetMIMEDescription()  NPP_GetMIMEDescription()
64  {  {
65    PLUGIN_DEBUG ("NPP_GetMimeDexcription\n");    PLUGIN_DEBUG ("NPP_GetMimeDescription\n");
66    
67    return PLUGIN_MIME_DESC;    return PLUGIN_MIME_DESC;
68  }  }
# Line 77  NPP_GetValue (NPP instance, NPPVariable Line 76  NPP_GetValue (NPP instance, NPPVariable
76    
77    switch (variable)    switch (variable)
78      {      {
79      case NPPVpluginNameString: // plugin name      case NPPVpluginNameString:
80      case NPPVpluginDescriptionString: // plugin description      case NPPVpluginDescriptionString:
81        *((char**) value) = "GCJ web browser plugin " VERSION;        *((char**) value) = "GCJ web browser plugin " VERSION;
82        break;        break;
83    
84        case NPPVpluginWindowBool:
85          *(PRBool*) value = PR_FALSE;
86          break;
87    
88        case NPPVpluginTransparentBool:
89          *(PRBool*) value = PR_FALSE;
90          break;
91    
92        case NPPVpluginNeedsXEmbed:
93          *(PRBool*) value = PR_TRUE;
94          break;
95    
96      default:      default:
97        result = NPERR_GENERIC_ERROR;        result = NPERR_GENERIC_ERROR;
98        break;        break;
# Line 118  NPP_New (NPMIMEType pluginType, NPP inst Line 129  NPP_New (NPMIMEType pluginType, NPP inst
129    if (!data)    if (!data)
130      return NPERR_OUT_OF_MEMORY_ERROR;      return NPERR_OUT_OF_MEMORY_ERROR;
131    
132    data->jniEnv = NULL;    for (int i = 0; i < argc; i++)
133    data->applet_class = NULL;      {
134    data->embeddedWindow = NULL;        // FIXME: Use glib functions here.
135    data->applet = NULL;        if (!strcmp (argn[i], "code"))
136            data->code = argv[i];
137    JNI_FindClass (data->jniEnv, "gnu/java/awt/EmbeddedWindow",        else if (!strcmp (argn[i], "codebase"))
138                   data->embeddedWindow_class);          data->codebase = argv[i];
139          else if (!strcmp (argn[i], "archive"))
140    jmethodID embeddedWindow_init;          data->archive = argv[i];
141    JNI_GetMethodID (data->jniEnv, data->embeddedWindow_class, "<init>", "(I)V", embeddedWindow_init);        else if (!strcmp (argn[i], "documentbase"))
142            data->documentbase = argv[i];
143          else if (!strcmp (argn[i], "parameters"))
144            // FIXME: need to handle multiple params
145            data->documentbase = argv[i];
146          else if (!strcmp (argn[i], "width"))
147            data->width = atoi (argv[i]);
148          else if (!strcmp (argn[i], "height"))
149            data->width = atoi (argv[i]);
150          else
151            printf ("GCJWebPlugin: unrecognized tag\n");
152        }
153    
   int window_id = 0;  
   JNI_NewObject1 (data->jniEnv, data->embeddedWindow_class, embeddedWindow_init, window_id, data->embeddedWindow);  
     
154    instance->pdata = data;    instance->pdata = data;
155      
156    return NPERR_GENERIC_ERROR;    return NPERR_GENERIC_ERROR;
157  }  }
158    
# Line 154  NPP_SetWindow (NPP instance, NPWindow* w Line 173  NPP_SetWindow (NPP instance, NPWindow* w
173    
174    jmethodID embeddedWindow_init;    jmethodID embeddedWindow_init;
175    GCJPluginData* data = (GCJPluginData*) instance->pdata;    GCJPluginData* data = (GCJPluginData*) instance->pdata;
176      
177    JNI_GetMethodID (data->jniEnv, data->embeddedWindow_class, "<init>", "(I)V",    data->xid = (int) window->window;
178                     embeddedWindow_init);  
   JNI_NewObject1 (data->jniEnv, data->embeddedWindow_class, embeddedWindow_init,  
                   (jint) window->window, data->embeddedWindow);  
     
179    return NPERR_NO_ERROR;    return NPERR_NO_ERROR;
180  }  }
181    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26