NSL.pas 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. {
  2. File: NSL.p
  3. Contains: Interface to API for using the NSL User Interface
  4. Version: Technology: Mac OS X
  5. Release: Universal Interfaces 3.4.2
  6. Copyright: © 1985-2002 by Apple Computer, Inc., all rights reserved
  7. Bugs?: For bug reports, consult the following page on
  8. the World Wide Web:
  9. http://www.freepascal.org/bugs.html
  10. }
  11. {
  12. Modified for use with Free Pascal
  13. Version 200
  14. Please report any bugs to <[email protected]>
  15. }
  16. {$mode macpas}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$CALLING MWPASCAL}
  21. unit NSL;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  24. {$setc GAP_INTERFACES_VERSION := $0200}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __i386__ and defined CPUI386}
  40. {$setc __i386__ := 1}
  41. {$elsec}
  42. {$setc __i386__ := 0}
  43. {$endc}
  44. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  45. {$error Conflicting definitions for __ppc__ and __i386__}
  46. {$endc}
  47. {$ifc defined __ppc__ and __ppc__}
  48. {$setc TARGET_CPU_PPC := TRUE}
  49. {$setc TARGET_CPU_X86 := FALSE}
  50. {$elifc defined __i386__ and __i386__}
  51. {$setc TARGET_CPU_PPC := FALSE}
  52. {$setc TARGET_CPU_X86 := TRUE}
  53. {$elsec}
  54. {$error Neither __ppc__ nor __i386__ is defined.}
  55. {$endc}
  56. {$setc TARGET_CPU_PPC_64 := FALSE}
  57. {$ifc defined FPC_BIG_ENDIAN}
  58. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  59. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  60. {$elifc defined FPC_LITTLE_ENDIAN}
  61. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  62. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  63. {$elsec}
  64. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  65. {$endc}
  66. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  67. {$setc CALL_NOT_IN_CARBON := FALSE}
  68. {$setc OLDROUTINENAMES := FALSE}
  69. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  70. {$setc OPAQUE_UPP_TYPES := TRUE}
  71. {$setc OTCARBONAPPLICATION := TRUE}
  72. {$setc OTKERNEL := FALSE}
  73. {$setc PM_USE_SESSION_APIS := TRUE}
  74. {$setc TARGET_API_MAC_CARBON := TRUE}
  75. {$setc TARGET_API_MAC_OS8 := FALSE}
  76. {$setc TARGET_API_MAC_OSX := TRUE}
  77. {$setc TARGET_CARBON := TRUE}
  78. {$setc TARGET_CPU_68K := FALSE}
  79. {$setc TARGET_CPU_MIPS := FALSE}
  80. {$setc TARGET_CPU_SPARC := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_UNIX := FALSE}
  83. {$setc TARGET_OS_WIN32 := FALSE}
  84. {$setc TARGET_RT_MAC_68881 := FALSE}
  85. {$setc TARGET_RT_MAC_CFM := FALSE}
  86. {$setc TARGET_RT_MAC_MACHO := TRUE}
  87. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  88. {$setc TYPE_BOOL := FALSE}
  89. {$setc TYPE_EXTENDED := FALSE}
  90. {$setc TYPE_LONGLONG := TRUE}
  91. uses MacTypes,Events,NSLCore;
  92. {$ALIGN MAC68K}
  93. type
  94. NSLDialogOptionFlags = UInt32;
  95. const
  96. kNSLDefaultNSLDlogOptions = $00000000; { use defaults for all the options }
  97. kNSLNoURLTEField = $00000001; { don't show url text field for manual entry }
  98. kNSLAddServiceTypes = $00000002; { add the service type if a user enters an incomplete URL }
  99. kNSLClientHandlesRecents = $00000004; { Stops NSLStandardGetURL from adding the selection to the recent items folder }
  100. type
  101. NSLDialogOptionsPtr = ^NSLDialogOptions;
  102. NSLDialogOptions = record
  103. version: UInt16;
  104. dialogOptionFlags: NSLDialogOptionFlags; { option flags for affecting the dialog's behavior }
  105. windowTitle: Str255;
  106. actionButtonLabel: Str255; { label of the default button (or null string for default) }
  107. cancelButtonLabel: Str255; { label of the cancel button (or null string for default) }
  108. message: Str255; { custom message prompt (or null string for default) }
  109. end;
  110. {$ifc TYPED_FUNCTION_POINTERS}
  111. NSLURLFilterProcPtr = function(url: CStringPtr; var displayString: Str255): boolean;
  112. {$elsec}
  113. NSLURLFilterProcPtr = ProcPtr;
  114. {$endc}
  115. { you can provide for calls to NSLStandardGetURL }
  116. {$ifc TYPED_FUNCTION_POINTERS}
  117. NSLEventProcPtr = procedure(var newEvent: EventRecord; userContext: UnivPtr);
  118. {$elsec}
  119. NSLEventProcPtr = ProcPtr;
  120. {$endc}
  121. {$ifc OPAQUE_UPP_TYPES}
  122. NSLURLFilterUPP = ^SInt32; { an opaque UPP }
  123. {$elsec}
  124. NSLURLFilterUPP = UniversalProcPtr;
  125. {$endc}
  126. {$ifc OPAQUE_UPP_TYPES}
  127. NSLEventUPP = ^SInt32; { an opaque UPP }
  128. {$elsec}
  129. NSLEventUPP = UniversalProcPtr;
  130. {$endc}
  131. const
  132. uppNSLURLFilterProcInfo = $000003D0;
  133. uppNSLEventProcInfo = $000003C0;
  134. {
  135. * NewNSLURLFilterUPP()
  136. *
  137. * Availability:
  138. * Non-Carbon CFM: available as macro/inline
  139. * CarbonLib: in CarbonLib 1.0 and later
  140. * Mac OS X: in version 10.0 and later
  141. }
  142. function NewNSLURLFilterUPP(userRoutine: NSLURLFilterProcPtr): NSLURLFilterUPP; external name '_NewNSLURLFilterUPP'; { old name was NewNSLURLFilterProc }
  143. {
  144. * NewNSLEventUPP()
  145. *
  146. * Availability:
  147. * Non-Carbon CFM: available as macro/inline
  148. * CarbonLib: in CarbonLib 1.0 and later
  149. * Mac OS X: in version 10.0 and later
  150. }
  151. function NewNSLEventUPP(userRoutine: NSLEventProcPtr): NSLEventUPP; external name '_NewNSLEventUPP'; { old name was NewNSLEventProc }
  152. {
  153. * DisposeNSLURLFilterUPP()
  154. *
  155. * Availability:
  156. * Non-Carbon CFM: available as macro/inline
  157. * CarbonLib: in CarbonLib 1.0 and later
  158. * Mac OS X: in version 10.0 and later
  159. }
  160. procedure DisposeNSLURLFilterUPP(userUPP: NSLURLFilterUPP); external name '_DisposeNSLURLFilterUPP';
  161. {
  162. * DisposeNSLEventUPP()
  163. *
  164. * Availability:
  165. * Non-Carbon CFM: available as macro/inline
  166. * CarbonLib: in CarbonLib 1.0 and later
  167. * Mac OS X: in version 10.0 and later
  168. }
  169. procedure DisposeNSLEventUPP(userUPP: NSLEventUPP); external name '_DisposeNSLEventUPP';
  170. {
  171. * InvokeNSLURLFilterUPP()
  172. *
  173. * Availability:
  174. * Non-Carbon CFM: available as macro/inline
  175. * CarbonLib: in CarbonLib 1.0 and later
  176. * Mac OS X: in version 10.0 and later
  177. }
  178. function InvokeNSLURLFilterUPP(url: CStringPtr; var displayString: Str255; userRoutine: NSLURLFilterUPP): boolean; external name '_InvokeNSLURLFilterUPP'; { old name was CallNSLURLFilterProc }
  179. {
  180. * InvokeNSLEventUPP()
  181. *
  182. * Availability:
  183. * Non-Carbon CFM: available as macro/inline
  184. * CarbonLib: in CarbonLib 1.0 and later
  185. * Mac OS X: in version 10.0 and later
  186. }
  187. procedure InvokeNSLEventUPP(var newEvent: EventRecord; userContext: UnivPtr; userRoutine: NSLEventUPP); external name '_InvokeNSLEventUPP'; { old name was CallNSLEventProc }
  188. { <--- function returns OSStatus of the operation. noErr will be returned if valid, kNSLUserCanceled will be returned if the user cancels }
  189. { ---> dialogOptions }
  190. { ---> eventProc }
  191. { ---> eventProcContextPtr }
  192. { ---> filterProc }
  193. { ---> serviceTypeList }
  194. { <--- userSelectedURL }
  195. { NSLDialogOptions* dialogOptions }
  196. {
  197. dialogOptions is a user defined structure defining the look, feel and operation of NSLStandardGetURL dialog
  198. default behavior can be achieved by passing in a pointer to a structure that has been filled out by a previous
  199. call to NSLGetDefaultDialogOptions or by passing in NULL.
  200. }
  201. { NSLEventUPP eventProc }
  202. {
  203. the eventProc is a callback NSLURLFilterUPP that will
  204. get called with Events that the dialog doesn't handle. If you pass in nil,
  205. you won't get update events while the NSLStandardGetURL dialog is open.
  206. }
  207. { void* eventProcContextPtr }
  208. { you can provide a pointer to some contextual data that you want to have sent to your eventProc filter }
  209. { NSLURLFilterProcPtr filterProc }
  210. {
  211. the filter param is a callback NSLURLFilterUPP that
  212. will get called (if not nil) for each url that is going to be displayed in
  213. the dialog's result list. A result of false will not include the url for the
  214. user to select from. You also have the option of handling the way the url looks
  215. in the dialog listing by copying the preferred name into the displayString
  216. parameter. (If left alone, NSLStandardGetURL dialog will strip the service type
  217. portion off the url).
  218. }
  219. { char* serviceTypeList }
  220. {
  221. the serviceTypeList parameter is a null terminated string that will
  222. directly affect the contents of the services popup in the dialog.
  223. The structure of this string is a set of tuples as follows:
  224. Name of ServiceType as to be represented in the popup followed by
  225. a comma delimted list of service descriptors (ie http,https) that will
  226. used in the search of that type. Each comma delimited tuple is delimited
  227. by semi-colons.
  228. }
  229. {
  230. For example:
  231. If you want to search for services of type http (web), https (secure web),
  232. and ftp, you could pass in the string "Web Servers,http,https;FTP Servers,ftp".
  233. This would result in a popup list with two items ("Web Servers" and "FTP Servers")
  234. and searches performed on them will provide results of type http and https for the
  235. first, and ftp for the second.
  236. }
  237. {
  238. Results list Icons:
  239. NSLStandardGetURL provides icons in its listings for the following types:
  240. "http", "https", "ftp", "afp", "lpr", "LaserWriter", "AFPServer"
  241. any other types will get a generic icon. However, you can provide icons
  242. if you wish by including an '#ics8' resource id at the end of your comma
  243. delimited list. The dialog will then use that icon if found in its results
  244. list. This icon will be used for all types in a tuple.
  245. For example:
  246. The param "Web Servers,http,https;Telnet Servers,telnet;NFS Servers,nfs,129"
  247. would result in lists of http and https services to be shown with their default
  248. icons, telnet servers would be shown with the default misc. icon and nfs
  249. servers would be shown with your icon at resource id 129.
  250. }
  251. { char** url }
  252. {
  253. pass in the address of a char* and it will point to the resulting url. If the user
  254. cancels (the function returns false), the pointer will be set to nil. If the function
  255. returns true (user selected a url), then you must call NSLFreeURL on the pointer when
  256. you are done with it.
  257. }
  258. {
  259. Call this to have the user select a url based service from a dialog.
  260. Function takes on input an optional filter proc, a serviceTypeList, and an address to a Ptr.
  261. Function sets the value of the Ptr to a newly created c-style null terminated string
  262. containing the user's choice of URL.
  263. }
  264. {
  265. * NSLStandardGetURL()
  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. function NSLStandardGetURL(dialogOptions: NSLDialogOptionsPtr; eventProc: NSLEventUPP; eventProcContextPtr: UnivPtr; filterProc: NSLURLFilterUPP; serviceTypeList: CStringPtr; var userSelectedURL: CStringPtr): OSStatus; external name '_NSLStandardGetURL';
  273. {
  274. * NSLGetDefaultDialogOptions()
  275. *
  276. * Availability:
  277. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  278. * CarbonLib: in CarbonLib 1.0 and later
  279. * Mac OS X: in version 10.0 and later
  280. }
  281. function NSLGetDefaultDialogOptions(var dialogOptions: NSLDialogOptions): OSStatus; external name '_NSLGetDefaultDialogOptions';
  282. { <--- function returns null (useful for setting variable at same time as freeing it }
  283. { ---> url is memory created by a call to NSLStandardGetURL }
  284. {
  285. * NSLFreeURL()
  286. *
  287. * Availability:
  288. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  289. * CarbonLib: in CarbonLib 1.0 and later
  290. * Mac OS X: in version 10.0 and later
  291. }
  292. function NSLFreeURL(url: CStringPtr): CStringPtr; external name '_NSLFreeURL';
  293. { <--- function returns kNSLErrNullPtrError, file mgr errors, or resource mgr errors }
  294. { ---> folderSelectorType is one of the well-known folders defined in Folders.h }
  295. { ---> url is any valid url }
  296. { ---> userFriendlyName is used for the file name and the display name (in the UI) }
  297. {
  298. * NSLSaveURLAliasToFolder()
  299. *
  300. * Availability:
  301. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  302. * CarbonLib: not available
  303. * Mac OS X: in version 10.0 and later
  304. }
  305. function NSLSaveURLAliasToFolder(folderSelectorType: OSType; url: ConstCStringPtr; userFriendlyName: ConstCStringPtr): OSErr; external name '_NSLSaveURLAliasToFolder';
  306. {$ALIGN MAC68K}
  307. end.