added iOS source code
[wl-app.git] / iOS / Pods / Realm / include / sync / impl / apple / system_configuration.hpp
1 ////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright 2017 Realm Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 ////////////////////////////////////////////////////////////////////////////
18
19 #ifndef REALM_OS_SYSTEM_CONFIGURATION_HPP
20 #define REALM_OS_SYSTEM_CONFIGURATION_HPP
21
22 #include "sync/impl/network_reachability.hpp"
23
24 #if NETWORK_REACHABILITY_AVAILABLE
25
26 #include <SystemConfiguration/SystemConfiguration.h>
27
28 namespace realm {
29 namespace _impl {
30
31 class SystemConfiguration {
32 public:
33     static SystemConfiguration& shared();
34
35     SCNetworkReachabilityRef network_reachability_create_with_name(CFAllocatorRef allocator,
36                                                                    const char *hostname);
37     SCNetworkReachabilityRef network_reachability_create_with_address(CFAllocatorRef allocator,
38                                                                       const sockaddr *address);
39     bool network_reachability_set_dispatch_queue(SCNetworkReachabilityRef target,
40                                                  dispatch_queue_t queue);
41     bool network_reachability_set_callback(SCNetworkReachabilityRef target,
42                                            SCNetworkReachabilityCallBack callback,
43                                            SCNetworkReachabilityContext *context);
44     bool network_reachability_get_flags(SCNetworkReachabilityRef target,
45                                         SCNetworkReachabilityFlags *flags);
46
47 private:
48     using create_with_name_t = SCNetworkReachabilityRef(*)(CFAllocatorRef, const char*);
49     using create_with_address_t = SCNetworkReachabilityRef(*)(CFAllocatorRef, const sockaddr*);
50     using set_dispatch_queue_t = bool(*)(SCNetworkReachabilityRef, dispatch_queue_t);
51     using set_callback_t = bool(*)(SCNetworkReachabilityRef,
52                                    SCNetworkReachabilityCallBack,
53                                    SCNetworkReachabilityContext*);
54     using get_flags_t = bool(*)(SCNetworkReachabilityRef, SCNetworkReachabilityFlags*);
55
56     SystemConfiguration();
57
58     void* m_framework_handle;
59
60     create_with_name_t m_create_with_name = nullptr;
61     create_with_address_t m_create_with_address = nullptr;
62     set_dispatch_queue_t m_set_dispatch_queue = nullptr;
63     set_callback_t m_set_callback = nullptr;
64     get_flags_t m_get_flags = nullptr;
65 };
66
67 } // namespace _impl
68 } // namespace realm
69
70 #endif // NETWORK_REACHABILITY_AVAILABLE
71
72 #endif // REALM_OS_SYSTEM_CONFIGURATION_HPP