|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #ifndef NSNETWORKLINKSERVICEMAC_H_ |
|
6 #define NSNETWORKLINKSERVICEMAC_H_ |
|
7 |
|
8 #include "nsINetworkLinkService.h" |
|
9 #include "nsIObserver.h" |
|
10 |
|
11 #include <SystemConfiguration/SCNetworkReachability.h> |
|
12 |
|
13 class nsNetworkLinkService : public nsINetworkLinkService, |
|
14 public nsIObserver |
|
15 { |
|
16 public: |
|
17 NS_DECL_ISUPPORTS |
|
18 NS_DECL_NSINETWORKLINKSERVICE |
|
19 NS_DECL_NSIOBSERVER |
|
20 |
|
21 nsNetworkLinkService(); |
|
22 virtual ~nsNetworkLinkService(); |
|
23 |
|
24 nsresult Init(); |
|
25 nsresult Shutdown(); |
|
26 |
|
27 private: |
|
28 bool mLinkUp; |
|
29 bool mStatusKnown; |
|
30 |
|
31 SCNetworkReachabilityRef mReachability; |
|
32 CFRunLoopRef mCFRunLoop; |
|
33 |
|
34 void UpdateReachability(); |
|
35 void SendEvent(); |
|
36 static void ReachabilityChanged(SCNetworkReachabilityRef target, |
|
37 SCNetworkConnectionFlags flags, |
|
38 void *info); |
|
39 }; |
|
40 |
|
41 #endif /* NSNETWORKLINKSERVICEMAC_H_ */ |