home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / plugin / nsjvm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  6.7 KB  |  213 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. ////////////////////////////////////////////////////////////////////////////////
  20. // NETSCAPE JAVA VM PLUGIN EXTENSIONS
  21. // 
  22. // This interface allows a Java virtual machine to be plugged into
  23. // Communicator to implement the APPLET tag and host applets.
  24. ////////////////////////////////////////////////////////////////////////////////
  25.  
  26. #ifndef nsjvm_h___
  27. #define nsjvm_h___
  28.  
  29. #include "nsplugin.h"
  30. #include "jri.h"        // XXX for now
  31. #include "jni.h"
  32. #include "prthread.h"
  33.  
  34. ////////////////////////////////////////////////////////////////////////////////
  35. // Java VM Plugin Manager
  36. // This interface defines additional entry points that are available
  37. // to JVM plugins for browsers that support JVM plugins.
  38.  
  39. class NPIJVMPluginManager : public NPIPluginManager {
  40. public:
  41.  
  42.     virtual void NP_LOADDS
  43.     BeginWaitCursor(void) = 0;
  44.  
  45.     virtual void NP_LOADDS
  46.     EndWaitCursor(void) = 0;
  47.  
  48.     virtual const char* NP_LOADDS
  49.     GetProgramPath(void) = 0;
  50.  
  51.     virtual const char* NP_LOADDS
  52.     GetTempDirPath(void) = 0;
  53.  
  54.     enum FileNameType { SIGNED_APPLET_DBNAME, TEMP_FILENAME };
  55.  
  56.     virtual nsresult NP_LOADDS
  57.     GetFileName(const char* fn, FileNameType type,
  58.                 char* resultBuf, PRUint32 bufLen) = 0;
  59.  
  60.     virtual nsresult NP_LOADDS
  61.     NewTempFileName(const char* prefix, char* resultBuf, PRUint32 bufLen) = 0;
  62.  
  63.     virtual PRBool NP_LOADDS
  64.     HandOffJSLock(PRThread* oldOwner, PRThread* newOwner) = 0;
  65.  
  66.     ////////////////////////////////////////////////////////////////////////////
  67.     // Debugger Stuff (XXX move to subclass)
  68.  
  69.     virtual PRBool NP_LOADDS
  70.     SetDebugAgentPassword(PRInt32 pwd) = 0;
  71.  
  72. };
  73.  
  74. #define NP_IJVMPLUGINMANAGER_IID                     \
  75. { /* a1e5ed50-aa4a-11d1-85b2-00805f0e4dfe */         \
  76.     0xa1e5ed50,                                      \
  77.     0xaa4a,                                          \
  78.     0x11d1,                                          \
  79.     {0x85, 0xb2, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  80. }
  81.  
  82. ////////////////////////////////////////////////////////////////////////////////
  83.  
  84. enum JVMStatus {
  85.     JVMStatus_Enabled,  // but not Running
  86.     JVMStatus_Disabled, // explicitly disabled
  87.     JVMStatus_Running,  // enabled and started
  88.     JVMStatus_Failed    // enabled but failed to start
  89. };
  90.  
  91. enum JVMError {
  92.     JVMError_Ok                 = NPPluginError_NoError,
  93.     JVMError_Base               = 0x1000,
  94.     JVMError_InternalError      = JVMError_Base,
  95.     JVMError_NoClasses,
  96.     JVMError_WrongClasses,
  97.     JVMError_JavaError,
  98.     JVMError_NoDebugger
  99. };
  100.  
  101. enum JVMDebugPort {
  102.     JVMDebugPort_None           = 0,
  103.     JVMDebugPort_SharedMemory   = -1
  104.     // anything else is a port number
  105. };
  106.  
  107. ////////////////////////////////////////////////////////////////////////////////
  108. // Java VM Plugin Interface
  109. // This interface defines additional entry points that a plugin developer needs
  110. // to implement in order to implement a Java virtual machine plugin. 
  111.  
  112. class NPIJVMPlugin : public NPIPlugin {
  113. public:
  114.  
  115.     virtual JVMStatus NP_LOADDS
  116.     StartupJVM() = 0;
  117.  
  118.     virtual JVMStatus NP_LOADDS
  119.     ShutdownJVM(PRBool fullShutdown = PR_TRUE) = 0;
  120.  
  121.     virtual PRBool NP_LOADDS
  122.     GetJVMEnabled() = 0;
  123.  
  124.     virtual void NP_LOADDS
  125.     SetJVMEnabled(PRBool enable) = 0;
  126.  
  127.     virtual JVMStatus NP_LOADDS
  128.     GetJVMStatus() = 0;
  129.  
  130.     // Find or create a JNIEnv for the specified thread. The thread
  131.     // parameter may be NULL indicating the current thread.
  132.     // XXX JNIEnv*
  133.     virtual JRIEnv* NP_LOADDS
  134.     EnsureExecEnv(PRThread* thread = NULL) = 0;
  135.  
  136.     virtual void NP_LOADDS
  137.     AddToClassPath(const char* dirPath) = 0;
  138.  
  139.     virtual void NP_LOADDS
  140.     ShowConsole() = 0;
  141.  
  142.     virtual void NP_LOADDS
  143.     HideConsole() = 0;
  144.  
  145.     virtual PRBool NP_LOADDS
  146.     IsConsoleVisible() = 0;
  147.  
  148.     virtual void NP_LOADDS
  149.     PrintToConsole(const char* msg) = 0;
  150.  
  151.     ////////////////////////////////////////////////////////////////////////////
  152.     // Debugger Stuff (XXX move to subclass)
  153.  
  154.     virtual JVMError NP_LOADDS
  155.     StartDebugger(JVMDebugPort port) = 0;
  156.     
  157. };
  158.  
  159. #define NP_IJVMPLUGIN_IID                            \
  160. { /* da6f3bc0-a1bc-11d1-85b1-00805f0e4dfe */         \
  161.     0xda6f3bc0,                                      \
  162.     0xa1bc,                                          \
  163.     0x11d1,                                          \
  164.     {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  165. }
  166.  
  167. ////////////////////////////////////////////////////////////////////////////////
  168. // Java VM Plugin Instance Peer Interface
  169. // This interface provides additional hooks into the plugin manager that allow 
  170. // a plugin to implement the plugin manager's Java virtual machine.
  171.  
  172. enum NPTagAttributeName {
  173.     NPTagAttributeName_Width,
  174.     NPTagAttributeName_Height,
  175.     NPTagAttributeName_Classid,
  176.     NPTagAttributeName_Code,
  177.     NPTagAttributeName_Codebase,
  178.     NPTagAttributeName_Docbase,
  179.     NPTagAttributeName_Archive,
  180.     NPTagAttributeName_Name,
  181.     NPTagAttributeName_MayScript
  182. };
  183.  
  184. class NPIJVMPluginInstancePeer : public NPIPluginInstancePeer {
  185. public:
  186.  
  187.     // XXX Does this overlap with GetArgNames/GetArgValues?
  188.     // XXX What happens if someone says something like:
  189.     //     <object codebase=...> <param name=codebase value=...>
  190.     // Which takes precedent?
  191.     virtual char* NP_LOADDS
  192.     GetAttribute(NPTagAttributeName name) = 0;
  193.  
  194.     // XXX reload method?
  195.  
  196.     // Returns a unique id for the current document on which the
  197.     // plugin is displayed.
  198.     virtual PRUint32 NP_LOADDS
  199.     GetDocumentID() = 0;
  200.     
  201. };
  202.  
  203. #define NP_IJVMPLUGININSTANCEPEER_IID                \
  204. { /* 27b42df0-a1bd-11d1-85b1-00805f0e4dfe */         \
  205.     0x27b42df0,                                      \
  206.     0xa1bd,                                          \
  207.     0x11d1,                                          \
  208.     {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  209. }
  210.  
  211. ////////////////////////////////////////////////////////////////////////////////
  212. #endif /* nsjvm_h___ */
  213.