Check in some work on the NPAPI; probably abandoned, but why lose the work if we...
[gssweb.git] / npapi / npapi.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <stddef.h>
4 #include <firefox/npapi.h>
5 #include <firefox/nptypes.h>
6 #include <firefox/npfunctions.h>
7
8 /*
9  * Loading and unloading the library 
10  */
11 NPError NP_Initialize(NPNetscapeFuncs *aNPNFuncs, NPPluginFuncs *pFuncs)
12 {
13   
14   /*
15    * Setup - Ensure a sane environment
16    */  
17   if( pFuncs == NULL || 
18       pFuncs->size < sizeof(NPNetscapeFuncs) )
19     return NPERR_INVALID_FUNCTABLE_ERROR;
20
21   if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
22     return NPERR_INCOMPATIBLE_VERSION_ERROR;
23
24   /*
25    * Main body:
26    *   Tell the browser about the API functions we implement
27    */
28   pFuncs->newp = NPP_New;
29   pFuncs->destroy = NPP_Destroy;
30   pFuncs->getvalue = NPP_GetValue;
31
32   return NPERR_NO_ERROR;
33 }
34
35 void NP_Shutdown(void)
36 {
37   return;
38 }
39
40 /*
41  * Create and destroy an instance of the plugin
42  */
43 NPError NPP_New(NPMIMEType    pluginType,
44                 NPP instance, uint16_t mode,
45                 int16_t argc, char *argn[],
46                 char *argv[], NPSavedData *saved)
47 {
48   return(NPERR_NO_ERROR);
49 }
50
51 NPError NPP_Destroy(NPP instance, NPSavedData **save)
52 {
53   return(NPERR_NO_ERROR);
54 }
55
56
57
58 /*
59  * Register the plugin for MIME type, and name, etc.
60  */
61 #define MIME_TYPES_DESCRIPTION "application/gss-web:gssw:Web plugin for the Moonshot GSS-EAP libraries"
62 const char* NP_GetMIMEDescription(void)
63 {
64   return(MIME_TYPES_DESCRIPTION);
65 }
66
67 NPError NP_GetValue(void *instance, 
68                     NPPVariable variable, 
69                     void *value)
70 {
71   // fprintf(stderr, "Called NP_GetValue with variable: %i\n", variable);
72   
73   switch(variable)
74   {
75   case NPPVpluginNameString:
76     *((char **)value) = "GSS-web Plugin\0";
77     break;
78   case NPPVpluginDescriptionString:
79     *((char **)value) = "This plugin facilitates identification of you and authorization to access web resources using GSS-EAP, a standards-compliant mechanism for establishing an identity and access rights within a sophisticated organization.\0";
80     break;
81   default:
82     return NPERR_GENERIC_ERROR;
83   }
84   
85   return NPERR_NO_ERROR;
86 }
87
88 NPError NPP_GetValue(NPP instance,
89                      NPPVariable variable,
90                      void *value)
91 {
92   switch(variable)
93   {
94     case NPPVpluginScriptableNPObject:
95       fprintf(stderr, "Received the scriptable object call!\n");
96       //value = NPN_CreateObject(instance, )
97       break;
98   }
99   fprintf(stderr, "Called NPP_GetValue with %i.\n", variable);
100   return NPERR_NO_ERROR;
101 }