|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* vim:set et sw=4 ts=4: */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 #ifndef NSNOTIFYADDRLISTENER_H_ |
|
7 #define NSNOTIFYADDRLISTENER_H_ |
|
8 |
|
9 #include <windows.h> |
|
10 #include <winsock2.h> |
|
11 #include <iptypes.h> |
|
12 #include "nsINetworkLinkService.h" |
|
13 #include "nsIRunnable.h" |
|
14 #include "nsIObserver.h" |
|
15 #include "nsThreadUtils.h" |
|
16 #include "nsCOMPtr.h" |
|
17 |
|
18 class nsNotifyAddrListener : public nsINetworkLinkService, |
|
19 public nsIRunnable, |
|
20 public nsIObserver |
|
21 { |
|
22 public: |
|
23 NS_DECL_THREADSAFE_ISUPPORTS |
|
24 NS_DECL_NSINETWORKLINKSERVICE |
|
25 NS_DECL_NSIRUNNABLE |
|
26 NS_DECL_NSIOBSERVER |
|
27 |
|
28 nsNotifyAddrListener(); |
|
29 virtual ~nsNotifyAddrListener(); |
|
30 |
|
31 nsresult Init(void); |
|
32 |
|
33 protected: |
|
34 class ChangeEvent : public nsRunnable { |
|
35 public: |
|
36 NS_DECL_NSIRUNNABLE |
|
37 ChangeEvent(nsINetworkLinkService *aService, const char *aEventID) |
|
38 : mService(aService), mEventID(aEventID) { |
|
39 } |
|
40 private: |
|
41 nsCOMPtr<nsINetworkLinkService> mService; |
|
42 const char *mEventID; |
|
43 }; |
|
44 |
|
45 bool mLinkUp; |
|
46 bool mStatusKnown; |
|
47 bool mCheckAttempted; |
|
48 |
|
49 nsresult Shutdown(void); |
|
50 nsresult SendEventToUI(const char *aEventID); |
|
51 |
|
52 DWORD CheckAdaptersAddresses(void); |
|
53 bool CheckIsGateway(PIP_ADAPTER_ADDRESSES aAdapter); |
|
54 bool CheckICSStatus(PWCHAR aAdapterName); |
|
55 void CheckLinkStatus(void); |
|
56 |
|
57 nsCOMPtr<nsIThread> mThread; |
|
58 |
|
59 HANDLE mShutdownEvent; |
|
60 }; |
|
61 |
|
62 #endif /* NSNOTIFYADDRLISTENER_H_ */ |