Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

423 lines
11 KiB

  1. /*
  2. File: JavaApplet.h
  3. Contains: interface to embedding a Java Applet in a Carbon Control
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 2000-2001 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __MACTYPES__
  11. #include <MacTypes.h>
  12. #endif
  13. #ifndef __CFDICTIONARY__
  14. #include <CFDictionary.h>
  15. #endif
  16. #ifndef __CFSTRING__
  17. #include <CFString.h>
  18. #endif
  19. #ifndef __CFURL__
  20. #include <CFURL.h>
  21. #endif
  22. #ifndef __JAVACONTROL__
  23. #include <JavaControl.h>
  24. #endif
  25. #if PRAGMA_ONCE
  26. #pragma once
  27. #endif
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #if PRAGMA_IMPORT
  32. #pragma import on
  33. #endif
  34. #if PRAGMA_STRUCT_ALIGN
  35. #pragma options align=mac68k
  36. #elif PRAGMA_STRUCT_PACKPUSH
  37. #pragma pack(push, 2)
  38. #elif PRAGMA_STRUCT_PACK
  39. #pragma pack(2)
  40. #endif
  41. #if PRAGMA_ENUM_ALWAYSINT
  42. #if defined(__fourbyteints__) && !__fourbyteints__
  43. #define __JAVAAPPLET__RESTORE_TWOBYTEINTS
  44. #pragma fourbyteints on
  45. #endif
  46. #pragma enumsalwaysint on
  47. #elif PRAGMA_ENUM_OPTIONS
  48. #pragma option enum=int
  49. #elif PRAGMA_ENUM_PACK
  50. #if __option(pack_enums)
  51. #define __JAVAAPPLET__RESTORE_PACKED_ENUMS
  52. #pragma options(!pack_enums)
  53. #endif
  54. #endif
  55. /*
  56. * AppletDescriptor
  57. *
  58. * Discussion:
  59. * The structure for describing applet. This is used as the
  60. * definition of the applet to create when you call CreateJavaApplet.
  61. */
  62. struct AppletDescriptor {
  63. CFURLRef docBase;
  64. CFURLRef codeBase;
  65. /*
  66. * The attributes found in the <applet ...> tag formatted as a
  67. * CFDictionary of CFStrings. For attributes like height and width
  68. * they should be in screen coordinates. some Applets define them as
  69. * % (for example 90%) and should be converted to pixels before put
  70. * into the dictionary.
  71. */
  72. CFDictionaryRef htmlAttrs;
  73. /*
  74. * The parameters to the applet formatted as a CFDictionary of
  75. * CFStrings. These are typically found in <param ...> tags inside of
  76. * the applet tag.
  77. */
  78. CFDictionaryRef appletParams;
  79. };
  80. typedef struct AppletDescriptor AppletDescriptor;
  81. /*
  82. * AppletArena
  83. *
  84. * Discussion:
  85. * This is an opaque type that represents an AppletArena - an applet
  86. * arena represents a single classloader, so all applets that share
  87. * an arena share a common classloader.
  88. */
  89. typedef struct OpaqueAppletArena* AppletArena;
  90. /*
  91. kUniqueArena is the value to pass to CreateJavaApplet if you want the applet to be created
  92. in a unique arena. A unique arena is one which is guaranteed not to be shared with
  93. any other applet running in this Java VM. This is the appropriate default value to
  94. pass to CreateJavaApplet.
  95. */
  96. #define kUniqueArena ((AppletArena)NULL)
  97. /*
  98. * JE_ShowDocumentCallback
  99. *
  100. * Discussion:
  101. * Type of a callback function used for show document (link) message
  102. * from an applet.
  103. *
  104. * Parameters:
  105. *
  106. * applet:
  107. * The applet which sent this show document message.
  108. *
  109. * url:
  110. * The url to load.
  111. *
  112. * windowName:
  113. * A string definition of where to open the url. Null means open
  114. * in place, other strings are defined in the HTML spec, like
  115. * "_top" means the parent window of the applet if it happens to
  116. * be in a frame, etc.
  117. *
  118. * userData:
  119. * Data specified when this callback was registered using
  120. * RegisterShowDocumentCallback.
  121. */
  122. typedef CALLBACK_API_C( void , JE_ShowDocumentCallback )(jobject applet, CFURLRef url, CFStringRef windowName, void *userData);
  123. /*
  124. * JE_SetStatusCallback
  125. *
  126. * Discussion:
  127. * Type of a callback function used for a status message from an
  128. * applet.
  129. *
  130. * Parameters:
  131. *
  132. * applet:
  133. * The applet which sent this status message.
  134. *
  135. * statusMessage:
  136. * The message to be displayed.
  137. *
  138. * userData:
  139. * Data specified when this callback was registered using
  140. * RegisterStatusCallback.
  141. */
  142. typedef CALLBACK_API_C( void , JE_SetStatusCallback )(jobject applet, CFStringRef statusMessage, void *userData);
  143. /*
  144. * GetEmbeddingVMParams()
  145. *
  146. * Discussion:
  147. * Gets a set of VM params that can be passed to JNI_CreateJavaVM.
  148. * These params are optimized for Java embedding, and also contain
  149. * all user-specified options.
  150. *
  151. * Parameters:
  152. *
  153. * ioJavaVMInitArgs:
  154. * A Java VM initialization argument structure that you create.
  155. * This function will clear any fields set in the structure and
  156. * filled in with new data on completion.
  157. *
  158. * Availability:
  159. * Non-Carbon CFM: not available
  160. * CarbonLib: not available
  161. * Mac OS X: in version 10.1 and later
  162. */
  163. EXTERN_API_C( OSStatus )
  164. GetEmbeddingVMParams(JavaVMInitArgs * ioJavaVMInitArgs);
  165. /*
  166. * CreateAppletArena()
  167. *
  168. * Discussion:
  169. * Create an applet arena. By default each applet you create will
  170. * have its own "arena". By creating an applet arena, and passing
  171. * that arena into two or more CreateJavaApplet calls, those applets
  172. * will share a single classloader and thus be able to communicate
  173. * with each other through static objects.
  174. *
  175. * Parameters:
  176. *
  177. * outNewArena:
  178. * The newly created applet arena.
  179. *
  180. * Availability:
  181. * Non-Carbon CFM: not available
  182. * CarbonLib: not available
  183. * Mac OS X: in version 10.1 and later
  184. */
  185. EXTERN_API_C( OSStatus )
  186. CreateAppletArena(AppletArena * outNewArena);
  187. /*
  188. * CreateJavaApplet()
  189. *
  190. * Discussion:
  191. * Creates a java applet from a descriptor.
  192. *
  193. * Parameters:
  194. *
  195. * env:
  196. * The JNI environment for the current thread.
  197. *
  198. * applet:
  199. * A full descriptor of the applet being loaded. See
  200. * AppletDescriptor.
  201. *
  202. * trusted:
  203. * Whether this applet should be loaded as trusted.
  204. *
  205. * arena:
  206. * The arena for this applet. If this is set to null then a new
  207. * arena will be created. This is the typcial case for applets.
  208. *
  209. * outJavaFrame:
  210. * Returns JNI global ref. Used for registering callbacks and
  211. * creating controls. Call env->DeleteGlobalRef() on it when done.
  212. *
  213. * Availability:
  214. * Non-Carbon CFM: not available
  215. * CarbonLib: not available
  216. * Mac OS X: in version 10.1 and later
  217. */
  218. EXTERN_API_C( OSStatus )
  219. CreateJavaApplet(
  220. JNIEnv * env,
  221. AppletDescriptor applet,
  222. Boolean trusted,
  223. AppletArena arena, /* can be NULL */
  224. jobject * outJavaFrame);
  225. /*
  226. * AppletState
  227. *
  228. * Summary:
  229. * Constants that are passed to SetJavaAppletState.
  230. */
  231. enum AppletState {
  232. kAppletStart = 1, /* Starts the applet processing 3.*/
  233. kAppletStop = 2, /* Halts the applet, but it can be started again.*/
  234. kAppletDestroy = 4 /* Tears down the applet.*/
  235. };
  236. typedef enum AppletState AppletState;
  237. /*
  238. * SetJavaAppletState()
  239. *
  240. * Discussion:
  241. * Sets the state of the current applet as defined by the applet
  242. * spec. Applets can be started and stopped many times, but
  243. * destroying them is final.
  244. *
  245. * Parameters:
  246. *
  247. * env:
  248. * The JNI environment for the current VM and thread.
  249. *
  250. * inAppletFrame:
  251. * The applet to register the status callback (from
  252. * CreateJavaApplet).
  253. *
  254. * inNewState:
  255. * Host defined data passed into showStatusFunction.
  256. *
  257. * Availability:
  258. * Non-Carbon CFM: not available
  259. * CarbonLib: not available
  260. * Mac OS X: in version 10.1 and later
  261. */
  262. EXTERN_API_C( OSStatus )
  263. SetJavaAppletState(
  264. JNIEnv * env,
  265. jobject inAppletFrame,
  266. AppletState inNewState);
  267. /*
  268. * RegisterStatusCallback()
  269. *
  270. * Discussion:
  271. * Registers your function that will be called to update the
  272. * applet's status area. Status typically is put in a web browser as
  273. * a text area at the bottom of the page.
  274. *
  275. * Note that this callback will be called from a preemptive thread,
  276. * and if the host application is using cooperative threads they
  277. * will need to push this into their own event system in order to
  278. * handle this correctly.
  279. *
  280. * Parameters:
  281. *
  282. * env:
  283. * The JNI environment for the current VM and thread.
  284. *
  285. * inJavaFrame:
  286. * The applet to register the status callback (from
  287. * CreateJavaApplet).
  288. *
  289. * showStatusFunction:
  290. * The function that will be called when the applet calls
  291. * showStatus(...).
  292. *
  293. * userData:
  294. * Host defined data passed into showStatusFunction.
  295. *
  296. * Availability:
  297. * Non-Carbon CFM: not available
  298. * CarbonLib: not available
  299. * Mac OS X: in version 10.1 and later
  300. */
  301. EXTERN_API_C( OSStatus )
  302. RegisterStatusCallback(
  303. JNIEnv * env,
  304. jobject inJavaFrame,
  305. JE_SetStatusCallback showStatusFunction,
  306. void * userData);
  307. /*
  308. * RegisterShowDocumentCallback()
  309. *
  310. * Discussion:
  311. * Registers your function that will be called when the applet
  312. * behaves like a hyperlink. This will be called to move an
  313. * embedding host application to a new URL.
  314. *
  315. * Note that this callback will be called from a preemptive thread,
  316. * and if the host application is using cooperative threads they
  317. * will need to push this into their own event system in order to
  318. * handle this correctly.
  319. *
  320. * Parameters:
  321. *
  322. * env:
  323. * The JNI environment for the current VM and thread.
  324. *
  325. * inJavaFrame:
  326. * The applet to register the show document callback (from
  327. * CreateJavaApplet).
  328. *
  329. * showDocumentFunction:
  330. * The function that will be called when the applet calls
  331. * showDocument().
  332. *
  333. * userData:
  334. * Host defined data passed into showDocumentFunction.
  335. *
  336. * Result:
  337. * An operating system status code.
  338. *
  339. * Availability:
  340. * Non-Carbon CFM: not available
  341. * CarbonLib: not available
  342. * Mac OS X: in version 10.1 and later
  343. */
  344. EXTERN_API_C( OSStatus )
  345. RegisterShowDocumentCallback(
  346. JNIEnv * env,
  347. jobject inJavaFrame,
  348. JE_ShowDocumentCallback showDocumentFunction,
  349. void * userData);
  350. #if PRAGMA_ENUM_ALWAYSINT
  351. #pragma enumsalwaysint reset
  352. #ifdef __JAVAAPPLET__RESTORE_TWOBYTEINTS
  353. #pragma fourbyteints off
  354. #endif
  355. #elif PRAGMA_ENUM_OPTIONS
  356. #pragma option enum=reset
  357. #elif defined(__JAVAAPPLET__RESTORE_PACKED_ENUMS)
  358. #pragma options(pack_enums)
  359. #endif
  360. #if PRAGMA_STRUCT_ALIGN
  361. #pragma options align=reset
  362. #elif PRAGMA_STRUCT_PACKPUSH
  363. #pragma pack(pop)
  364. #elif PRAGMA_STRUCT_PACK
  365. #pragma pack()
  366. #endif
  367. #ifdef PRAGMA_IMPORT_OFF
  368. #pragma import off
  369. #elif PRAGMA_IMPORT
  370. #pragma import reset
  371. #endif
  372. #ifdef __cplusplus
  373. }
  374. #endif