]> git.saurik.com Git - cydia.git/blob - Reachability.h
removed uneeded code for cancel/queue ui change
[cydia.git] / Reachability.h
1 /*
2
3 File: Reachability.h
4 Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
5
6 Version: 2.2
7
8 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
9 ("Apple") in consideration of your agreement to the following terms, and your
10 use, installation, modification or redistribution of this Apple software
11 constitutes acceptance of these terms. If you do not agree with these terms,
12 please do not use, install, modify or redistribute this Apple software.
13
14 In consideration of your agreement to abide by the following terms, and subject
15 to these terms, Apple grants you a personal, non-exclusive license, under
16 Apple's copyrights in this original Apple software (the "Apple Software"), to
17 use, reproduce, modify and redistribute the Apple Software, with or without
18 modifications, in source and/or binary forms; provided that if you redistribute
19 the Apple Software in its entirety and without modifications, you must retain
20 this notice and the following text and disclaimers in all such redistributions
21 of the Apple Software.
22 Neither the name, trademarks, service marks or logos of Apple Inc. may be used
23 to endorse or promote products derived from the Apple Software without specific
24 prior written permission from Apple. Except as expressly stated in this notice,
25 no other rights or licenses, express or implied, are granted by Apple herein,
26 including but not limited to any patent rights that may be infringed by your
27 derivative works or by other works in which the Apple Software may be
28 incorporated.
29
30 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
31 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
32 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
34 COMBINATION WITH YOUR PRODUCTS.
35
36 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
37 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
38 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
40 DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
41 CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
42 APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
44 Copyright (C) 2010 Apple Inc. All Rights Reserved.
45
46 */
47
48
49 #import <Foundation/Foundation.h>
50 #import <SystemConfiguration/SystemConfiguration.h>
51
52 typedef enum {
53 NotReachable = 0,
54 ReachableViaWiFi,
55 ReachableViaWWAN
56 } NetworkStatus;
57 #define kReachabilityChangedNotification @"kNetworkReachabilityChangedNotification"
58
59 @interface Reachability: NSObject
60 {
61 BOOL localWiFiRef;
62 SCNetworkReachabilityRef reachabilityRef;
63 }
64
65 //reachabilityWithHostName- Use to check the reachability of a particular host name.
66 + (Reachability*) reachabilityWithHostName: (NSString*) hostName;
67
68 //reachabilityWithAddress- Use to check the reachability of a particular IP address.
69 + (Reachability*) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;
70
71 //reachabilityForInternetConnection- checks whether the default route is available.
72 // Should be used by applications that do not connect to a particular host
73 + (Reachability*) reachabilityForInternetConnection;
74
75 //reachabilityForLocalWiFi- checks whether a local wifi connection is available.
76 + (Reachability*) reachabilityForLocalWiFi;
77
78 //Start listening for reachability notifications on the current run loop
79 - (BOOL) startNotifier;
80 - (void) stopNotifier;
81
82 - (NetworkStatus) currentReachabilityStatus;
83 //WWAN may be available, but not active until a connection has been established.
84 //WiFi may require a connection for VPN on Demand.
85 - (BOOL) connectionRequired;
86 @end
87
88