Seregon/StratoSDK

StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.

Rust/27.3 KB/No license
crates/strato-ui-renderer/src/platform/mac/objc/reachability.h
StratoSDK / crates / strato-ui-renderer / src / platform / mac / objc / reachability.h
1/*
2 Copyright (c) 2011, Tony Million.
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 
8 1. Redistributions of source code must retain the above copyright notice, this
9 list of conditions and the following disclaimer.
10 
11 2. Redistributions in binary form must reproduce the above copyright notice,
12 this list of conditions and the following disclaimer in the documentation
13 and/or other materials provided with the distribution.
14 
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28#import <Foundation/Foundation.h>
29#import <SystemConfiguration/SystemConfiguration.h>
30 
31//! Project version number for MacOSReachability.
32FOUNDATION_EXPORT double ReachabilityVersionNumber;
33 
34//! Project version string for MacOSReachability.
35FOUNDATION_EXPORT const unsigned char ReachabilityVersionString[];
36 
37/**
38 * Create NS_ENUM macro if it does not exist on the targeted version of iOS or OS X.
39 *
40 * @see http://nshipster.com/ns_enum-ns_options/
41 **/
42#ifndef NS_ENUM
43#define NS_ENUM(_type, _name) \
44 enum _name : _type _name; \
45 enum _name : _type
46#endif
47 
48extern NSString *const kReachabilityChangedNotification;
49 
50typedef NS_ENUM(NSInteger, NetworkStatus) {
51 // Apple NetworkStatus Compatible Names.
52 NotReachable = 0,
53 ReachableViaWiFi = 2,
54 ReachableViaWWAN = 1
55};
56 
57@class Reachability;
58 
59typedef void (^NetworkReachable)(Reachability *reachability);
60typedef void (^NetworkUnreachable)(Reachability *reachability);
61typedef void (^NetworkReachability)(Reachability *reachability, SCNetworkConnectionFlags flags);
62 
63@interface Reachability : NSObject
64 
65@property(nonatomic, copy) NetworkReachable reachableBlock;
66@property(nonatomic, copy) NetworkUnreachable unreachableBlock;
67@property(nonatomic, copy) NetworkReachability reachabilityBlock;
68 
69@property(nonatomic, assign) BOOL reachableOnWWAN;
70 
71+ (instancetype)reachabilityWithHostname:(NSString *)hostname;
72// This is identical to the function above, but is here to maintain
73// compatibility with Apples original code. (see .m)
74+ (instancetype)reachabilityWithHostName:(NSString *)hostname;
75+ (instancetype)reachabilityForInternetConnection;
76+ (instancetype)reachabilityWithAddress:(void *)hostAddress;
77+ (instancetype)reachabilityForLocalWiFi;
78+ (instancetype)reachabilityWithURL:(NSURL *)url;
79 
80- (instancetype)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;
81 
82- (BOOL)startNotifier;
83- (void)stopNotifier;
84 
85- (BOOL)isReachable;
86- (BOOL)isReachableViaWWAN;
87- (BOOL)isReachableViaWiFi;
88 
89// WWAN may be available, but not active until a connection has been established.
90// WiFi may require a connection for VPN on Demand.
91- (BOOL)isConnectionRequired; // Identical DDG variant.
92- (BOOL)connectionRequired; // Apple's routine.
93// Dynamic, on demand connection?
94- (BOOL)isConnectionOnDemand;
95// Is user intervention required?
96- (BOOL)isInterventionRequired;
97 
98- (NetworkStatus)currentReachabilityStatus;
99- (SCNetworkReachabilityFlags)reachabilityFlags;
100- (NSString *)currentReachabilityString;
101- (NSString *)currentReachabilityFlags;
102 
103@end
104