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.

362 lines
13 KiB

  1. /*
  2. File: NSL.h
  3. Contains: Interface to API for using the NSL User Interface
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 1997-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 __NSL__
  11. #define __NSL__
  12. #ifndef __NSLCORE__
  13. #include <NSLCore.h>
  14. #endif
  15. #ifndef __EVENTS__
  16. #include <Events.h>
  17. #endif
  18. #if PRAGMA_ONCE
  19. #pragma once
  20. #endif
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #if PRAGMA_IMPORT
  25. #pragma import on
  26. #endif
  27. #if PRAGMA_STRUCT_ALIGN
  28. #pragma options align=mac68k
  29. #elif PRAGMA_STRUCT_PACKPUSH
  30. #pragma pack(push, 2)
  31. #elif PRAGMA_STRUCT_PACK
  32. #pragma pack(2)
  33. #endif
  34. typedef UInt32 NSLDialogOptionFlags;
  35. enum {
  36. kNSLDefaultNSLDlogOptions = 0x00000000, /* use defaults for all the options */
  37. kNSLNoURLTEField = 0x00000001, /* don't show url text field for manual entry */
  38. kNSLAddServiceTypes = 0x00000002, /* add the service type if a user enters an incomplete URL */
  39. kNSLClientHandlesRecents = 0x00000004 /* Stops NSLStandardGetURL from adding the selection to the recent items folder */
  40. };
  41. struct NSLDialogOptions {
  42. UInt16 version;
  43. NSLDialogOptionFlags dialogOptionFlags; /* option flags for affecting the dialog's behavior */
  44. Str255 windowTitle;
  45. Str255 actionButtonLabel; /* label of the default button (or null string for default) */
  46. Str255 cancelButtonLabel; /* label of the cancel button (or null string for default) */
  47. Str255 message; /* custom message prompt (or null string for default) */
  48. };
  49. typedef struct NSLDialogOptions NSLDialogOptions;
  50. typedef CALLBACK_API( Boolean , NSLURLFilterProcPtr )(char *url, Str255 displayString);
  51. /* you can provide for calls to NSLStandardGetURL*/
  52. typedef CALLBACK_API( void , NSLEventProcPtr )(EventRecord *newEvent, void *userContext);
  53. typedef STACK_UPP_TYPE(NSLURLFilterProcPtr) NSLURLFilterUPP;
  54. typedef STACK_UPP_TYPE(NSLEventProcPtr) NSLEventUPP;
  55. /*
  56. * NewNSLURLFilterUPP()
  57. *
  58. * Availability:
  59. * Non-Carbon CFM: available as macro/inline
  60. * CarbonLib: in CarbonLib 1.0 and later
  61. * Mac OS X: in version 10.0 and later
  62. */
  63. EXTERN_API_C( NSLURLFilterUPP )
  64. NewNSLURLFilterUPP(NSLURLFilterProcPtr userRoutine);
  65. #if !OPAQUE_UPP_TYPES
  66. enum { uppNSLURLFilterProcInfo = 0x000003D0 }; /* pascal 1_byte Func(4_bytes, 4_bytes) */
  67. #ifdef __cplusplus
  68. inline DEFINE_API_C(NSLURLFilterUPP) NewNSLURLFilterUPP(NSLURLFilterProcPtr userRoutine) { return (NSLURLFilterUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLURLFilterProcInfo, GetCurrentArchitecture()); }
  69. #else
  70. #define NewNSLURLFilterUPP(userRoutine) (NSLURLFilterUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLURLFilterProcInfo, GetCurrentArchitecture())
  71. #endif
  72. #endif
  73. /*
  74. * NewNSLEventUPP()
  75. *
  76. * Availability:
  77. * Non-Carbon CFM: available as macro/inline
  78. * CarbonLib: in CarbonLib 1.0 and later
  79. * Mac OS X: in version 10.0 and later
  80. */
  81. EXTERN_API_C( NSLEventUPP )
  82. NewNSLEventUPP(NSLEventProcPtr userRoutine);
  83. #if !OPAQUE_UPP_TYPES
  84. enum { uppNSLEventProcInfo = 0x000003C0 }; /* pascal no_return_value Func(4_bytes, 4_bytes) */
  85. #ifdef __cplusplus
  86. inline DEFINE_API_C(NSLEventUPP) NewNSLEventUPP(NSLEventProcPtr userRoutine) { return (NSLEventUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLEventProcInfo, GetCurrentArchitecture()); }
  87. #else
  88. #define NewNSLEventUPP(userRoutine) (NSLEventUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLEventProcInfo, GetCurrentArchitecture())
  89. #endif
  90. #endif
  91. /*
  92. * DisposeNSLURLFilterUPP()
  93. *
  94. * Availability:
  95. * Non-Carbon CFM: available as macro/inline
  96. * CarbonLib: in CarbonLib 1.0 and later
  97. * Mac OS X: in version 10.0 and later
  98. */
  99. EXTERN_API_C( void )
  100. DisposeNSLURLFilterUPP(NSLURLFilterUPP userUPP);
  101. #if !OPAQUE_UPP_TYPES
  102. #ifdef __cplusplus
  103. inline DEFINE_API_C(void) DisposeNSLURLFilterUPP(NSLURLFilterUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  104. #else
  105. #define DisposeNSLURLFilterUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  106. #endif
  107. #endif
  108. /*
  109. * DisposeNSLEventUPP()
  110. *
  111. * Availability:
  112. * Non-Carbon CFM: available as macro/inline
  113. * CarbonLib: in CarbonLib 1.0 and later
  114. * Mac OS X: in version 10.0 and later
  115. */
  116. EXTERN_API_C( void )
  117. DisposeNSLEventUPP(NSLEventUPP userUPP);
  118. #if !OPAQUE_UPP_TYPES
  119. #ifdef __cplusplus
  120. inline DEFINE_API_C(void) DisposeNSLEventUPP(NSLEventUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  121. #else
  122. #define DisposeNSLEventUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  123. #endif
  124. #endif
  125. /*
  126. * InvokeNSLURLFilterUPP()
  127. *
  128. * Availability:
  129. * Non-Carbon CFM: available as macro/inline
  130. * CarbonLib: in CarbonLib 1.0 and later
  131. * Mac OS X: in version 10.0 and later
  132. */
  133. EXTERN_API_C( Boolean )
  134. InvokeNSLURLFilterUPP(
  135. char * url,
  136. Str255 displayString,
  137. NSLURLFilterUPP userUPP);
  138. #if !OPAQUE_UPP_TYPES
  139. #ifdef __cplusplus
  140. inline DEFINE_API_C(Boolean) InvokeNSLURLFilterUPP(char * url, Str255 displayString, NSLURLFilterUPP userUPP) { return (Boolean)CALL_TWO_PARAMETER_UPP(userUPP, uppNSLURLFilterProcInfo, url, displayString); }
  141. #else
  142. #define InvokeNSLURLFilterUPP(url, displayString, userUPP) (Boolean)CALL_TWO_PARAMETER_UPP((userUPP), uppNSLURLFilterProcInfo, (url), (displayString))
  143. #endif
  144. #endif
  145. /*
  146. * InvokeNSLEventUPP()
  147. *
  148. * Availability:
  149. * Non-Carbon CFM: available as macro/inline
  150. * CarbonLib: in CarbonLib 1.0 and later
  151. * Mac OS X: in version 10.0 and later
  152. */
  153. EXTERN_API_C( void )
  154. InvokeNSLEventUPP(
  155. EventRecord * newEvent,
  156. void * userContext,
  157. NSLEventUPP userUPP);
  158. #if !OPAQUE_UPP_TYPES
  159. #ifdef __cplusplus
  160. inline DEFINE_API_C(void) InvokeNSLEventUPP(EventRecord * newEvent, void * userContext, NSLEventUPP userUPP) { CALL_TWO_PARAMETER_UPP(userUPP, uppNSLEventProcInfo, newEvent, userContext); }
  161. #else
  162. #define InvokeNSLEventUPP(newEvent, userContext, userUPP) CALL_TWO_PARAMETER_UPP((userUPP), uppNSLEventProcInfo, (newEvent), (userContext))
  163. #endif
  164. #endif
  165. #if CALL_NOT_IN_CARBON || OLDROUTINENAMES
  166. /* support for pre-Carbon UPP routines: New...Proc and Call...Proc */
  167. #define NewNSLURLFilterProc(userRoutine) NewNSLURLFilterUPP(userRoutine)
  168. #define NewNSLEventProc(userRoutine) NewNSLEventUPP(userRoutine)
  169. #define CallNSLURLFilterProc(userRoutine, url, displayString) InvokeNSLURLFilterUPP(url, displayString, userRoutine)
  170. #define CallNSLEventProc(userRoutine, newEvent, userContext) InvokeNSLEventUPP(newEvent, userContext, userRoutine)
  171. #endif /* CALL_NOT_IN_CARBON */
  172. /* <--- function returns OSStatus of the operation. noErr will be returned if valid, kNSLUserCanceled will be returned if the user cancels */
  173. /* ---> dialogOptions */
  174. /* ---> eventProc */
  175. /* ---> eventProcContextPtr */
  176. /* ---> filterProc */
  177. /* ---> serviceTypeList */
  178. /* <--- userSelectedURL */
  179. /* NSLDialogOptions* dialogOptions */
  180. /*
  181. dialogOptions is a user defined structure defining the look, feel and operation of NSLStandardGetURL dialog
  182. default behavior can be achieved by passing in a pointer to a structure that has been filled out by a previous
  183. call to NSLGetDefaultDialogOptions or by passing in NULL.
  184. */
  185. /* NSLEventUPP eventProc */
  186. /*
  187. the eventProc is a callback NSLURLFilterUPP that will
  188. get called with Events that the dialog doesn't handle. If you pass in nil,
  189. you won't get update events while the NSLStandardGetURL dialog is open.
  190. */
  191. /* void* eventProcContextPtr */
  192. /* you can provide a pointer to some contextual data that you want to have sent to your eventProc filter*/
  193. /* NSLURLFilterProcPtr filterProc */
  194. /*
  195. the filter param is a callback NSLURLFilterUPP that
  196. will get called (if not nil) for each url that is going to be displayed in
  197. the dialog's result list. A result of false will not include the url for the
  198. user to select from. You also have the option of handling the way the url looks
  199. in the dialog listing by copying the preferred name into the displayString
  200. parameter. (If left alone, NSLStandardGetURL dialog will strip the service type
  201. portion off the url).
  202. */
  203. /* char* serviceTypeList */
  204. /*
  205. the serviceTypeList parameter is a null terminated string that will
  206. directly affect the contents of the services popup in the dialog.
  207. The structure of this string is a set of tuples as follows:
  208. Name of ServiceType as to be represented in the popup followed by
  209. a comma delimted list of service descriptors (ie http,https) that will
  210. used in the search of that type. Each comma delimited tuple is delimited
  211. by semi-colons.
  212. */
  213. /*
  214. For example:
  215. If you want to search for services of type http (web), https (secure web),
  216. and ftp, you could pass in the string "Web Servers,http,https;FTP Servers,ftp".
  217. This would result in a popup list with two items ("Web Servers" and "FTP Servers")
  218. and searches performed on them will provide results of type http and https for the
  219. first, and ftp for the second.
  220. */
  221. /*
  222. Results list Icons:
  223. NSLStandardGetURL provides icons in its listings for the following types:
  224. "http", "https", "ftp", "afp", "lpr", "LaserWriter", "AFPServer"
  225. any other types will get a generic icon. However, you can provide icons
  226. if you wish by including an '#ics8' resource id at the end of your comma
  227. delimited list. The dialog will then use that icon if found in its results
  228. list. This icon will be used for all types in a tuple.
  229. For example:
  230. The param "Web Servers,http,https;Telnet Servers,telnet;NFS Servers,nfs,129"
  231. would result in lists of http and https services to be shown with their default
  232. icons, telnet servers would be shown with the default misc. icon and nfs
  233. servers would be shown with your icon at resource id 129.
  234. */
  235. /* char** url */
  236. /*
  237. pass in the address of a char* and it will point to the resulting url. If the user
  238. cancels (the function returns false), the pointer will be set to nil. If the function
  239. returns true (user selected a url), then you must call NSLFreeURL on the pointer when
  240. you are done with it.
  241. */
  242. /*
  243. Call this to have the user select a url based service from a dialog.
  244. Function takes on input an optional filter proc, a serviceTypeList, and an address to a Ptr.
  245. Function sets the value of the Ptr to a newly created c-style null terminated string
  246. containing the user's choice of URL.
  247. */
  248. /*
  249. * NSLStandardGetURL()
  250. *
  251. * Availability:
  252. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  253. * CarbonLib: in CarbonLib 1.0 and later
  254. * Mac OS X: in version 10.0 and later
  255. */
  256. EXTERN_API( OSStatus )
  257. NSLStandardGetURL(
  258. NSLDialogOptions * dialogOptions, /* can be NULL */
  259. NSLEventUPP eventProc, /* can be NULL */
  260. void * eventProcContextPtr, /* can be NULL */
  261. NSLURLFilterUPP filterProc, /* can be NULL */
  262. char * serviceTypeList,
  263. char ** userSelectedURL);
  264. /*
  265. * NSLGetDefaultDialogOptions()
  266. *
  267. * Availability:
  268. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  269. * CarbonLib: in CarbonLib 1.0 and later
  270. * Mac OS X: in version 10.0 and later
  271. */
  272. EXTERN_API( OSStatus )
  273. NSLGetDefaultDialogOptions(NSLDialogOptions * dialogOptions);
  274. /* <--- function returns null (useful for setting variable at same time as freeing it */
  275. /* ---> url is memory created by a call to NSLStandardGetURL */
  276. /*
  277. * NSLFreeURL()
  278. *
  279. * Availability:
  280. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  281. * CarbonLib: in CarbonLib 1.0 and later
  282. * Mac OS X: in version 10.0 and later
  283. */
  284. EXTERN_API( char * )
  285. NSLFreeURL(char * url);
  286. /* <--- function returns kNSLErrNullPtrError, file mgr errors, or resource mgr errors */
  287. /* ---> folderSelectorType is one of the well-known folders defined in Folders.h */
  288. /* ---> url is any valid url */
  289. /* ---> userFriendlyName is used for the file name and the display name (in the UI) */
  290. /*
  291. * NSLSaveURLAliasToFolder()
  292. *
  293. * Availability:
  294. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  295. * CarbonLib: not available
  296. * Mac OS X: in version 10.0 and later
  297. */
  298. EXTERN_API( OSErr )
  299. NSLSaveURLAliasToFolder(
  300. OSType folderSelectorType,
  301. const char * url,
  302. const char * userFriendlyName);
  303. #if PRAGMA_STRUCT_ALIGN
  304. #pragma options align=reset
  305. #elif PRAGMA_STRUCT_PACKPUSH
  306. #pragma pack(pop)
  307. #elif PRAGMA_STRUCT_PACK
  308. #pragma pack()
  309. #endif
  310. #ifdef PRAGMA_IMPORT_OFF
  311. #pragma import off
  312. #elif PRAGMA_IMPORT
  313. #pragma import reset
  314. #endif
  315. #ifdef __cplusplus
  316. }
  317. #endif
  318. #endif /* __NSL__ */