SCNetworkConnection.pas 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. {
  2. * Copyright (c) 2003-2006, 2008-2010 Apple Inc. All rights reserved.
  3. *
  4. * @APPLE_LICENSE_HEADER_START@
  5. *
  6. * This file contains Original Code and/or Modifications of Original Code
  7. * as defined in and that are subject to the Apple Public Source License
  8. * Version 2.0 (the 'License'). You may not use this file except in
  9. * compliance with the License. Please obtain a copy of the License at
  10. * http://www.opensource.apple.com/apsl/ and read it before using this
  11. * file.
  12. *
  13. * The Original Code and all software distributed under the License are
  14. * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  15. * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  16. * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  18. * Please see the License for the specific language governing rights and
  19. * limitations under the License.
  20. *
  21. * @APPLE_LICENSE_HEADER_END@
  22. }
  23. { Pascal Translation: Peter N Lewis, <[email protected]>, 2004 }
  24. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2009 }
  25. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2012 }
  26. {
  27. Modified for use with Free Pascal
  28. Version 308
  29. Please report any bugs to <[email protected]>
  30. }
  31. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  32. {$mode macpas}
  33. {$modeswitch cblocks}
  34. {$packenum 1}
  35. {$macro on}
  36. {$inline on}
  37. {$calling mwpascal}
  38. unit SCNetworkConnection;
  39. interface
  40. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  41. {$setc GAP_INTERFACES_VERSION := $0308}
  42. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  43. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  44. {$endc}
  45. {$ifc defined CPUPOWERPC and defined CPUI386}
  46. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  47. {$endc}
  48. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  49. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  50. {$endc}
  51. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  52. {$setc __ppc__ := 1}
  53. {$elsec}
  54. {$setc __ppc__ := 0}
  55. {$endc}
  56. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  57. {$setc __ppc64__ := 1}
  58. {$elsec}
  59. {$setc __ppc64__ := 0}
  60. {$endc}
  61. {$ifc not defined __i386__ and defined CPUI386}
  62. {$setc __i386__ := 1}
  63. {$elsec}
  64. {$setc __i386__ := 0}
  65. {$endc}
  66. {$ifc not defined __x86_64__ and defined CPUX86_64}
  67. {$setc __x86_64__ := 1}
  68. {$elsec}
  69. {$setc __x86_64__ := 0}
  70. {$endc}
  71. {$ifc not defined __arm__ and defined CPUARM}
  72. {$setc __arm__ := 1}
  73. {$elsec}
  74. {$setc __arm__ := 0}
  75. {$endc}
  76. {$ifc not defined __arm64__ and defined CPUAARCH64}
  77. {$setc __arm64__ := 1}
  78. {$elsec}
  79. {$setc __arm64__ := 0}
  80. {$endc}
  81. {$ifc defined cpu64}
  82. {$setc __LP64__ := 1}
  83. {$elsec}
  84. {$setc __LP64__ := 0}
  85. {$endc}
  86. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  87. {$error Conflicting definitions for __ppc__ and __i386__}
  88. {$endc}
  89. {$ifc defined __ppc__ and __ppc__}
  90. {$setc TARGET_CPU_PPC := TRUE}
  91. {$setc TARGET_CPU_PPC64 := FALSE}
  92. {$setc TARGET_CPU_X86 := FALSE}
  93. {$setc TARGET_CPU_X86_64 := FALSE}
  94. {$setc TARGET_CPU_ARM := FALSE}
  95. {$setc TARGET_CPU_ARM64 := FALSE}
  96. {$setc TARGET_OS_MAC := TRUE}
  97. {$setc TARGET_OS_IPHONE := FALSE}
  98. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  99. {$setc TARGET_OS_EMBEDDED := FALSE}
  100. {$elifc defined __ppc64__ and __ppc64__}
  101. {$setc TARGET_CPU_PPC := FALSE}
  102. {$setc TARGET_CPU_PPC64 := TRUE}
  103. {$setc TARGET_CPU_X86 := FALSE}
  104. {$setc TARGET_CPU_X86_64 := FALSE}
  105. {$setc TARGET_CPU_ARM := FALSE}
  106. {$setc TARGET_CPU_ARM64 := FALSE}
  107. {$setc TARGET_OS_MAC := TRUE}
  108. {$setc TARGET_OS_IPHONE := FALSE}
  109. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  110. {$setc TARGET_OS_EMBEDDED := FALSE}
  111. {$elifc defined __i386__ and __i386__}
  112. {$setc TARGET_CPU_PPC := FALSE}
  113. {$setc TARGET_CPU_PPC64 := FALSE}
  114. {$setc TARGET_CPU_X86 := TRUE}
  115. {$setc TARGET_CPU_X86_64 := FALSE}
  116. {$setc TARGET_CPU_ARM := FALSE}
  117. {$setc TARGET_CPU_ARM64 := FALSE}
  118. {$ifc defined iphonesim}
  119. {$setc TARGET_OS_MAC := FALSE}
  120. {$setc TARGET_OS_IPHONE := TRUE}
  121. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  122. {$elsec}
  123. {$setc TARGET_OS_MAC := TRUE}
  124. {$setc TARGET_OS_IPHONE := FALSE}
  125. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  126. {$endc}
  127. {$setc TARGET_OS_EMBEDDED := FALSE}
  128. {$elifc defined __x86_64__ and __x86_64__}
  129. {$setc TARGET_CPU_PPC := FALSE}
  130. {$setc TARGET_CPU_PPC64 := FALSE}
  131. {$setc TARGET_CPU_X86 := FALSE}
  132. {$setc TARGET_CPU_X86_64 := TRUE}
  133. {$setc TARGET_CPU_ARM := FALSE}
  134. {$setc TARGET_CPU_ARM64 := FALSE}
  135. {$ifc defined iphonesim}
  136. {$setc TARGET_OS_MAC := FALSE}
  137. {$setc TARGET_OS_IPHONE := TRUE}
  138. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  139. {$elsec}
  140. {$setc TARGET_OS_MAC := TRUE}
  141. {$setc TARGET_OS_IPHONE := FALSE}
  142. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  143. {$endc}
  144. {$setc TARGET_OS_EMBEDDED := FALSE}
  145. {$elifc defined __arm__ and __arm__}
  146. {$setc TARGET_CPU_PPC := FALSE}
  147. {$setc TARGET_CPU_PPC64 := FALSE}
  148. {$setc TARGET_CPU_X86 := FALSE}
  149. {$setc TARGET_CPU_X86_64 := FALSE}
  150. {$setc TARGET_CPU_ARM := TRUE}
  151. {$setc TARGET_CPU_ARM64 := FALSE}
  152. {$setc TARGET_OS_MAC := FALSE}
  153. {$setc TARGET_OS_IPHONE := TRUE}
  154. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  155. {$setc TARGET_OS_EMBEDDED := TRUE}
  156. {$elifc defined __arm64__ and __arm64__}
  157. {$setc TARGET_CPU_PPC := FALSE}
  158. {$setc TARGET_CPU_PPC64 := FALSE}
  159. {$setc TARGET_CPU_X86 := FALSE}
  160. {$setc TARGET_CPU_X86_64 := FALSE}
  161. {$setc TARGET_CPU_ARM := FALSE}
  162. {$setc TARGET_CPU_ARM64 := TRUE}
  163. {$ifc defined ios}
  164. {$setc TARGET_OS_MAC := FALSE}
  165. {$setc TARGET_OS_IPHONE := TRUE}
  166. {$setc TARGET_OS_EMBEDDED := TRUE}
  167. {$elsec}
  168. {$setc TARGET_OS_MAC := TRUE}
  169. {$setc TARGET_OS_IPHONE := FALSE}
  170. {$setc TARGET_OS_EMBEDDED := FALSE}
  171. {$endc}
  172. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  173. {$elsec}
  174. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  175. {$endc}
  176. {$ifc defined __LP64__ and __LP64__ }
  177. {$setc TARGET_CPU_64 := TRUE}
  178. {$elsec}
  179. {$setc TARGET_CPU_64 := FALSE}
  180. {$endc}
  181. {$ifc defined FPC_BIG_ENDIAN}
  182. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  183. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  184. {$elifc defined FPC_LITTLE_ENDIAN}
  185. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  186. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  187. {$elsec}
  188. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  189. {$endc}
  190. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  191. {$setc CALL_NOT_IN_CARBON := FALSE}
  192. {$setc OLDROUTINENAMES := FALSE}
  193. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  194. {$setc OPAQUE_UPP_TYPES := TRUE}
  195. {$setc OTCARBONAPPLICATION := TRUE}
  196. {$setc OTKERNEL := FALSE}
  197. {$setc PM_USE_SESSION_APIS := TRUE}
  198. {$setc TARGET_API_MAC_CARBON := TRUE}
  199. {$setc TARGET_API_MAC_OS8 := FALSE}
  200. {$setc TARGET_API_MAC_OSX := TRUE}
  201. {$setc TARGET_CARBON := TRUE}
  202. {$setc TARGET_CPU_68K := FALSE}
  203. {$setc TARGET_CPU_MIPS := FALSE}
  204. {$setc TARGET_CPU_SPARC := FALSE}
  205. {$setc TARGET_OS_UNIX := FALSE}
  206. {$setc TARGET_OS_WIN32 := FALSE}
  207. {$setc TARGET_RT_MAC_68881 := FALSE}
  208. {$setc TARGET_RT_MAC_CFM := FALSE}
  209. {$setc TARGET_RT_MAC_MACHO := TRUE}
  210. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  211. {$setc TYPE_BOOL := FALSE}
  212. {$setc TYPE_EXTENDED := FALSE}
  213. {$setc TYPE_LONGLONG := TRUE}
  214. uses MacTypes,MacOSXPosix,CFBase,CFDictionary,CFRunLoop;
  215. {$endc} {not MACOSALLINCLUDE}
  216. {$ALIGN POWER}
  217. {!
  218. @header SCNetworkConnection
  219. @discussion The SCNetworkConnection API contains functions that allow
  220. an application to control connection-oriented services defined
  221. in the system and get connection-status information.
  222. The functions in the SCNetworkConnection API allow you to
  223. control and get information about existing services only.
  224. If you need to create, change, or remove services, you
  225. should use the SCNetworkConfiguration API instead.
  226. Note: Currently, only PPP services can be controlled.
  227. }
  228. {!
  229. @typedef SCNetworkConnectionRef
  230. @discussion This is the handle to manage a connection-oriented service.
  231. }
  232. type
  233. SCNetworkConnectionRef = ^__SCNetworkConnection; { an opaque type }
  234. __SCNetworkConnection = record end;
  235. {!
  236. @typedef SCNetworkConnectionContext
  237. @discussion Structure containing user-specified data and callbacks
  238. for a SCNetworkConnection.
  239. @field version The version number of the structure type being passed
  240. in as a parameter to the SCNetworkConnectionCreateWithServiceID
  241. function. This structure is version 0.
  242. @field info A C pointer to a user-specified block of data.
  243. @field retain The callback used to add a retain for the info field.
  244. If this parameter is not a pointer to a function of the correct
  245. prototype, the behavior is undefined. The value may be NULL.
  246. @field release The calllback used to remove a retain previously added
  247. for the info field. If this parameter is not a pointer to a
  248. function of the correct prototype, the behavior is undefined.
  249. The value may be NULL.
  250. @field copyDescription The callback used to provide a description of
  251. the info field.
  252. }
  253. // AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
  254. type SCNetworkConnectionContext = record
  255. version: CFIndex;
  256. info: Ptr;
  257. retain: function( info: UnivPtr ): UnivPtr;
  258. release: procedure( info: UnivPtr );
  259. copyDescription: function( info: UnivPtr ): CFStringRef;
  260. end;
  261. SCNetworkConnectionContextPtr = ^SCNetworkConnectionContext;
  262. {!
  263. @enum SCNetworkConnectionStatus
  264. @discussion Status of the network connection.
  265. This status is intended to be generic and high level.
  266. An extended status, specific to the type of network
  267. connection is also available for applications that
  268. need additonal information.
  269. @constant kSCNetworkConnectionInvalid
  270. The network connection refers to an invalid service.
  271. @constant kSCNetworkConnectionDisconnected
  272. The network connection is disconnected.
  273. @constant kSCNetworkConnectionConnecting
  274. The network connection is connecting.
  275. @constant kSCNetworkConnectionConnected
  276. The network connection is connected.
  277. @constant kSCNetworkConnectionDisconnecting
  278. The network connection is disconnecting.
  279. }
  280. // AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
  281. const
  282. kSCNetworkConnectionInvalid = -1;
  283. kSCNetworkConnectionDisconnected = 0;
  284. kSCNetworkConnectionConnecting = 1;
  285. kSCNetworkConnectionConnected = 2;
  286. kSCNetworkConnectionDisconnecting = 3;
  287. type
  288. SCNetworkConnectionStatus = SInt32;
  289. {!
  290. @enum SCNetworkConnectionPPPStatus
  291. @discussion PPP-specific status of the network connection.
  292. This status is returned as part of the extended information
  293. for a PPP service.
  294. Note: additional status might be returned in the future.
  295. Your application should be prepared to receive an unknown value.
  296. @constant kSCNetworkConnectionPPPDisconnected
  297. PPP is disconnected.
  298. @constant kSCNetworkConnectionPPPInitializing
  299. PPP is initializing.
  300. @constant kSCNetworkConnectionPPPConnectingLink
  301. PPP is connecting the lower connection layer (for example,
  302. the modem is dialing out).
  303. @constant kSCNetworkConnectionPPPDialOnTraffic
  304. PPP is waiting for networking traffic to automatically
  305. establish the connection.
  306. @constant kSCNetworkConnectionPPPNegotiatingLink
  307. The PPP lower layer is connected and PPP is negotiating the
  308. link layer (LCP protocol).
  309. @constant kSCNetworkConnectionPPPAuthenticating
  310. PPP is authenticating to the server (PAP, CHAP, MS-CHAP or
  311. EAP protocols).
  312. @constant kSCNetworkConnectionPPPWaitingForCallBack
  313. PPP is waiting for the server to call back.
  314. @constant kSCNetworkConnectionPPPNegotiatingNetwork
  315. PPP is now authenticated and negotiating the networking
  316. layer (IPCP or IPv6CP protocols)
  317. @constant kSCNetworkConnectionPPPConnected
  318. PPP is now fully connected for at least one networking layer.
  319. Additional networking protocol might still be negotiating.
  320. @constant kSCNetworkConnectionPPPTerminating
  321. PPP networking and link protocols are terminating.
  322. @constant kSCNetworkConnectionPPPDisconnectingLink
  323. PPP is disconnecting the lower level (for example, the modem
  324. is hanging up).
  325. @constant kSCNetworkConnectionPPPHoldingLinkOff
  326. PPP is disconnected and maintaining the link temporarily off.
  327. @constant kSCNetworkConnectionPPPSuspended
  328. PPP is suspended as a result of the suspend command (for
  329. example, when a V.92 Modem is On Hold).
  330. @constant kSCNetworkConnectionPPPWaitingForRedial
  331. PPP has found a busy server and is waiting for redial.
  332. }
  333. // AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
  334. const
  335. kSCNetworkConnectionPPPDisconnected = 0;
  336. kSCNetworkConnectionPPPInitializing = 1;
  337. kSCNetworkConnectionPPPConnectingLink = 2;
  338. kSCNetworkConnectionPPPDialOnTraffic = 3;
  339. kSCNetworkConnectionPPPNegotiatingLink = 4;
  340. kSCNetworkConnectionPPPAuthenticating = 5;
  341. kSCNetworkConnectionPPPWaitingForCallBack = 6;
  342. kSCNetworkConnectionPPPNegotiatingNetwork = 7;
  343. kSCNetworkConnectionPPPConnected = 8;
  344. kSCNetworkConnectionPPPTerminating = 9;
  345. kSCNetworkConnectionPPPDisconnectingLink = 10;
  346. kSCNetworkConnectionPPPHoldingLinkOff = 11;
  347. kSCNetworkConnectionPPPSuspended = 12;
  348. kSCNetworkConnectionPPPWaitingForRedial = 13;
  349. type
  350. SCNetworkConnectionPPPStatus = SInt32;
  351. {!
  352. @typedef SCNetworkConnectionCallBack
  353. @discussion Type of the callback function used when a
  354. status event is delivered.
  355. @param status The connection status.
  356. @param connection The connection reference.
  357. @param info Application-specific information.
  358. }
  359. type
  360. // AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
  361. SCNetworkConnectionCallBack = procedure( connection: SCNetworkConnectionRef; status: SCNetworkConnectionStatus; info: UnivPtr );
  362. {
  363. Keys for the statistics dictionary
  364. }
  365. {$ifc USE_CFSTR_CONSTANT_MACROS}
  366. {$definec kSCNetworkConnectionBytesIn CFSTRP('BytesIn')}
  367. {$endc} { CFNumber }
  368. {$ifc USE_CFSTR_CONSTANT_MACROS}
  369. {$definec kSCNetworkConnectionBytesOut CFSTRP('BytesOut')}
  370. {$endc} { CFNumber }
  371. {$ifc USE_CFSTR_CONSTANT_MACROS}
  372. {$definec kSCNetworkConnectionPacketsIn CFSTRP('PacketsIn')}
  373. {$endc} { CFNumber }
  374. {$ifc USE_CFSTR_CONSTANT_MACROS}
  375. {$definec kSCNetworkConnectionPacketsOut CFSTRP('PacketsOut')}
  376. {$endc} { CFNumber }
  377. {$ifc USE_CFSTR_CONSTANT_MACROS}
  378. {$definec kSCNetworkConnectionErrorsIn CFSTRP('ErrorsIn')}
  379. {$endc} { CFNumber }
  380. {$ifc USE_CFSTR_CONSTANT_MACROS}
  381. {$definec kSCNetworkConnectionErrorsOut CFSTRP('ErrorsOut')}
  382. {$endc} { CFNumber }
  383. {
  384. Keys for the SCNetworkConnectionCopyUserPreferences() "selectionOptions"
  385. dictionary
  386. }
  387. {!
  388. @define kSCNetworkConnectionSelectionOptionOnDemandHostName
  389. @discussion A host name that will be used to select the
  390. "best" SCNetworkConnection.
  391. }
  392. // #if (__MAC_OS_X_VERSION_MIN_REQUIRED >= 1060) || (__IPHONE_OS_VERSION_MIN_REQUIRED >= 30000) || TARGET_IPHONE_SIMULATOR
  393. // Only on Mac OS X 10.6+, iPhoneOS 3.0+, iPhoneSimulator
  394. {$ifc USE_CFSTR_CONSTANT_MACROS}
  395. {$definec kSCNetworkConnectionSelectionOptionOnDemandHostName CFSTRP('OnDemandHostName')}
  396. {$endc} { CFString }
  397. // #endif
  398. {!
  399. @define kSCNetworkConnectionSelectionOptionOnDemandRetry
  400. @discussion A boolean value used to indicate whether a DNS query has
  401. already been issued for the specified OnDemand host name.
  402. }
  403. // #if (__MAC_OS_X_VERSION_MIN_REQUIRED >= 1060) || (__IPHONE_OS_VERSION_MIN_REQUIRED >= 30000) || TARGET_IPHONE_SIMULATOR
  404. // Only on Mac OS X 10.6+, iPhoneOS 3.0+, iPhoneSimulator
  405. {$ifc USE_CFSTR_CONSTANT_MACROS}
  406. {$definec kSCNetworkConnectionSelectionOptionOnDemandRetry CFSTRP('OnDemandRetry')}
  407. {$endc} { CFBoolean }
  408. // #endif
  409. { until __IPHONE_NA is automatically translated }
  410. {$ifc TARGET_OS_MAC}
  411. {!
  412. @function SCNetworkConnectionGetTypeID
  413. @discussion Returns the type identifier of all SCNetworkConnection
  414. instances.
  415. }
  416. function SCNetworkConnectionGetTypeID: CFTypeID; external name '_SCNetworkConnectionGetTypeID';
  417. (* __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) *)
  418. {!
  419. @function SCNetworkConnectionCopyUserPreferences
  420. @discussion Provides the default service ID and a dictionary of user
  421. options for the connection. Applications can use the
  422. returned serviceID and userOptions values to open a
  423. connection on the fly.
  424. @param selectionOptions Currently unimplemented. Pass NULL for this
  425. version.
  426. @param serviceID Reference to the default serviceID for starting
  427. connections, this value will be returned by the function.
  428. @param userOptions Reference to default userOptions for starting
  429. connections, this will be returned by the function.
  430. @result Returns TRUE if there is a valid service to dial;
  431. FALSE if the function was unable to retrieve a service to dial.
  432. }
  433. function SCNetworkConnectionCopyUserPreferences( selectionOptions: CFDictionaryRef; var serviceID: CFStringRef; var userOptions: CFDictionaryRef ): Boolean; external name '_SCNetworkConnectionCopyUserPreferences';
  434. (* __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) *)
  435. {!
  436. @function SCNetworkConnectionCreateWithServiceID
  437. @discussion Creates a new connection reference to use for getting
  438. the status or for connecting or disconnecting the associated
  439. service.
  440. @param allocator The CFAllocator that should be used to allocate
  441. memory for the connection structure. This parameter may be
  442. NULL in which case the current default CFAllocator is used.
  443. If this reference is not a valid CFAllocator, the behavior
  444. is undefined.
  445. @param serviceID A string that defines the service identifier
  446. of the connection. Service identifiers uniquely identify
  447. services in the system configuration database.
  448. @param callout The function to be called when the status
  449. of the connection changes. If this parameter is NULL, the
  450. application will not receive notifications of status change
  451. and will need to poll for updates.
  452. @param context The SCNetworkConnectionContext associated with the
  453. callout.
  454. @result Returns a reference to the new SCNetworkConnection.
  455. }
  456. function SCNetworkConnectionCreateWithServiceID( allocator: CFAllocatorRef; serviceID: CFStringRef; callout: SCNetworkConnectionCallBack; var context: SCNetworkConnectionContext ): SCNetworkConnectionRef; external name '_SCNetworkConnectionCreateWithServiceID';
  457. (* __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) *)
  458. {!
  459. @function SCNetworkConnectionCopyServiceID
  460. @discussion Returns the service ID associated with the SCNetworkConnection.
  461. @param connection The SCNetworkConnection to obtain status from.
  462. @result Returns the service ID associated with the SCNetworkConnection.
  463. }
  464. function SCNetworkConnectionCopyServiceID( connection: SCNetworkConnectionRef ): CFStringRef; external name '_SCNetworkConnectionCopyServiceID';
  465. (* __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) *)
  466. {!
  467. @function SCNetworkConnectionGetStatus
  468. @discussion Returns the status of the SCNetworkConnection.
  469. A status is one of the following values:
  470. <pre>
  471. @textblock
  472. &#32
  473. kSCNetworkConnectionInvalid
  474. kSCNetworkConnectionDisconnected
  475. kSCNetworkConnectionConnecting
  476. kSCNetworkConnectionDisconnecting
  477. kSCNetworkConnectionConnected
  478. @/textblock
  479. </pre>
  480. @param connection The SCNetworkConnection to obtain status from.
  481. @result Returns the status value.
  482. }
  483. function SCNetworkConnectionGetStatus( connection: SCNetworkConnectionRef ): SCNetworkConnectionStatus; external name '_SCNetworkConnectionGetStatus';
  484. (* __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) *)
  485. {!
  486. @function SCNetworkConnectionCopyExtendedStatus
  487. @discussion Returns the extended status of the connection.
  488. An extended status dictionary contains specific dictionaries
  489. describing the status for each subcomponent of the service.
  490. For example, a status dictionary will contain the following
  491. sub-dictionaries, keys, and values:
  492. <pre>
  493. @textblock
  494. &#32
  495. IPv4 : Addresses : the assigned IP address.
  496. &#32
  497. PPP : Status : the PPP-specific status of type
  498. SCNetworkConnectionPPPStatus.
  499. &#32
  500. LastCause : Available when the status is "Disconnected"
  501. and contains the last error associated with
  502. connecting or disconnecting.
  503. &#32
  504. ConnectTime : the time when the connection was
  505. established.
  506. &#32
  507. Modem : ConnectSpeed : the speed of the modem connection
  508. in bits/second.
  509. &#32
  510. IPSec : Status : the IPSec-specific status of type
  511. SCNetworkConnectionIPSecStatus
  512. &#32
  513. ConnectTime : the time when the connection was
  514. established.
  515. @/textblock
  516. </pre>
  517. Other dictionaries could be present for PPPoE, PPTP, and L2TP.
  518. The status dictionary may be extended in the future to contain
  519. additional information.
  520. @param connection The SCNetworkConnection to obtain status from.
  521. @result Returns the status dictionary.
  522. If NULL is returned, the error can be retrieved using the SCError function.
  523. }
  524. function SCNetworkConnectionCopyExtendedStatus( connection: SCNetworkConnectionRef ): CFDictionaryRef; external name '_SCNetworkConnectionCopyExtendedStatus';
  525. (* __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) *)
  526. {!
  527. @function SCNetworkConnectionCopyStatistics
  528. @discussion Returns the statistics of the SCNetworkConnection.
  529. A statistic dictionary contains specific dictionaries
  530. with statistics for each subcomponent of the service.
  531. For example, a statistics dictionary will contain the following
  532. sub-dictionaries, keys, and values:
  533. <pre>
  534. @textblock
  535. &#32
  536. PPP : BytesIn :
  537. PPP : BytesOut : Contains the number of bytes going up into
  538. (or coming out of) the network stack for
  539. any networking protocol without the PPP
  540. headers and trailers.
  541. &#32
  542. PPP : PacketsIn :
  543. PPP : PacketsOut : Contains the number of packets going up into
  544. (or coming out of) the network stack for
  545. any networking protocol without the PPP
  546. headers and trailers.
  547. &#32
  548. PPP : ErrorsIn :
  549. PPP : ErrorsOut : Contains the number of errors going up into
  550. (or coming out of) the network stack for
  551. any networking protocol without the PPP
  552. headers and trailers.
  553. @/textblock
  554. </pre>
  555. The statistics dictionary may be extended in the future to
  556. contain additional information.
  557. @param connection The SCNetworkConnection to obtained statistics from.
  558. @result Returns the statistics dictionary.
  559. If NULL is returned, the error can be retrieved using the SCError function.
  560. }
  561. function SCNetworkConnectionCopyStatistics( connection: SCNetworkConnectionRef ): CFDictionaryRef; external name '_SCNetworkConnectionCopyStatistics';
  562. (* __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) *)
  563. {!
  564. @function SCNetworkConnectionStart
  565. @discussion Starts the connection for the SCNetworkConnection.
  566. The connection process is asynchronous and the function will
  567. return immediately. The connection status can be obtained
  568. by polling or by callback. The connection is made with the
  569. default settings from the administrator. Some of the settings
  570. can be overridden for the duration of the connection. These
  571. are specified in an options dictionary. The options dictionary
  572. uses the same format as a network service defined in the system
  573. configuration preferences schema.
  574. Note: Starting and stopping of connections is implicitly
  575. arbitrated. Calling SCNetworkConnectionStart on a connection
  576. already started will indicate that the application has
  577. interest in the connection and it shouldn't be stopped by
  578. anyone else.
  579. @param connection The SCNetworkConnection to start.
  580. @param userOptions The options dictionary to start the connection with.
  581. If userOptions is NULL, the default settings will be used.
  582. If userOptions are specified, they must be in the same format
  583. as network services stored in the system configuration
  584. preferences schema. The options will override the default
  585. settings defined for the service.
  586. For security reasons, not all options can be overridden; the
  587. appropriate merging of all settings will be done before the
  588. connection is established, and inappropriate options will be
  589. ignored.
  590. @param linger This parameter indicates whether or not the connection
  591. can stay around when the application no longer has interest
  592. in it. A typical application should pass FALSE, and the
  593. connection will be automatically stopped when the reference
  594. is released or if the application quits. If the application
  595. passes TRUE, the application can release the reference or
  596. exit and the connection will be maintained until a timeout
  597. event, until a specific stop request occurs, or until an
  598. error is encountered.
  599. @result Returns TRUE if the connection was correctly started (the
  600. actual connection is not established yet, and the connection
  601. status needs to be periodically checked); FALSE if the
  602. connection request was not started. The error must be
  603. retrieved from the SCError function.
  604. }
  605. function SCNetworkConnectionStart( connection: SCNetworkConnectionRef; userOptions: CFDictionaryRef; linger: Boolean ): Boolean; external name '_SCNetworkConnectionStart';
  606. (* __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) *)
  607. {!
  608. @function SCNetworkConnectionStop
  609. @discussion Stops the connection for the SCNetworkConnection.
  610. The disconnection process is asynchronous and the function
  611. will return immediately. The connection status can be
  612. obtained by polling or by callback. This function performs
  613. an arbitrated stop of the connection. If several applications
  614. have marked their interest in the connection, by calling
  615. SCNetworkConnectionStart, the call will succeed but the
  616. actual connection will be maintained until the last interested
  617. application calls SCNetworkConnectionStop.
  618. In certain cases, you might want to stop the connection anyway.
  619. In these cases, you set the forceDisconnect argument to TRUE.
  620. @param connection The SCNetworkConnection to stop.
  621. @result Returns TRUE if the disconnection request succeeded;
  622. FALSE if the disconnection request failed.
  623. The error must be retrieved from the SCError function.
  624. }
  625. function SCNetworkConnectionStop( connection: SCNetworkConnectionRef; forceDisconnect: Boolean ): Boolean; external name '_SCNetworkConnectionStop';
  626. (* __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) *)
  627. {!
  628. @function SCNetworkConnectionCopyUserOptions
  629. @discussion Copies the user options used to start the connection.
  630. This is a mechanism a client can use to retrieve the user options
  631. previously passed to the SCNetworkConnectionStart function.
  632. @param connection The SCNetworkConnection to obtain options from.
  633. @result Returns the service dictionary containing the connection options.
  634. The dictionary can be empty if no user options were used.
  635. If NULL is returned, the error can be retrieved using the SCError function.
  636. }
  637. function SCNetworkConnectionCopyUserOptions( connection: SCNetworkConnectionRef ): CFDictionaryRef; external name '_SCNetworkConnectionCopyUserOptions';
  638. (* __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) *)
  639. {!
  640. @function SCNetworkConnectionScheduleWithRunLoop
  641. @discussion Schedules a connection with the run loop.
  642. @param connection The SCNetworkConnection to schedule.
  643. @param runLoop The run loop to schedule with.
  644. @param runLoopMode The run loop mode.
  645. @result Returns TRUE if the connection is scheduled successfully;
  646. FALSE if the scheduling failed.
  647. The error can be retrieved using the SCError function.
  648. }
  649. function SCNetworkConnectionScheduleWithRunLoop( connection: SCNetworkConnectionRef; runLoop: CFRunLoopRef; runLoopMode: CFStringRef ): Boolean; external name '_SCNetworkConnectionScheduleWithRunLoop';
  650. (* __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) *)
  651. {!
  652. @function SCNetworkConnectionUnscheduleFromRunLoop
  653. @discussion Unschedules a connection from the run loop.
  654. @param connection The SCNetworkConnection to unschedule.
  655. @param runLoop The run loop to unschedule from.
  656. @param runLoopMode The run loop mode.
  657. @result Returns TRUE if the connection is unscheduled successfully;
  658. FALSE if the unscheduling failed.
  659. The error can be retrieved using the SCError function.
  660. }
  661. function SCNetworkConnectionUnscheduleFromRunLoop( connection: SCNetworkConnectionRef; runLoop: CFRunLoopRef; runLoopMode: CFStringRef ): Boolean; external name '_SCNetworkConnectionUnscheduleFromRunLoop';
  662. (* __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) *)
  663. {!
  664. @function SCNetworkConnectionSetDispatchQueue
  665. @discussion Caller provides a dispatch queue on which the callback contained in connection will run.
  666. @param connection The SCNetworkConnection to notify.
  667. @param queue The libdispatch queue to run the callback on.
  668. Pass NULL to disable notifications, and release queue.
  669. @result Returns TRUE if the notifications have been enabled/disabled as desired;
  670. FALSE if not.
  671. The error can be retrieved using the SCError function.
  672. }
  673. function SCNetworkConnectionSetDispatchQueue( connection: SCNetworkConnectionRef; queue: dispatch_queue_t ): Boolean; external name '_SCNetworkConnectionSetDispatchQueue';
  674. (* __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA) *)
  675. {$endc} {TARGET_OS_MAC}
  676. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  677. end.
  678. {$endc} {not MACOSALLINCLUDE}