/packages/univint/src/SCNetworkConnection.pas

https://github.com/slibre/freepascal · Pascal · 714 lines · 55 code · 60 blank · 599 comment · 0 complexity · c72ef1785b3caa11159e7516a5904de0 MD5 · raw file

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