netwerk/base/src/nsAutodialWin.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:9aa1e59bbd4d
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 nsAutodialWin_h__
6 #define nsAutodialWin_h__
7
8 #include <windows.h>
9 #include <ras.h>
10 #include <rasdlg.h>
11 #include <raserror.h>
12 #include "nscore.h"
13 #include "nspr.h"
14
15 // For Windows NT 4, 2000, and XP, we sometimes want to open the RAS dialup
16 // window ourselves, since those versions aren't very nice about it.
17 // See bug 93002. If the RAS autodial service is running, (Remote Access
18 // Auto Connection Manager, aka RasAuto) we will force it to dial
19 // on network error by adding the target address to the autodial
20 // database. If the service is not running, we will open the RAS dialogs
21 // instead.
22 //
23 // The OS can be configured to always dial, or dial when there is no
24 // connection. We implement both by dialing when a network error occurs.
25 //
26 // An object of this class checks with the OS when it is constructed and
27 // remembers those settings. If required, it can be resynced with
28 // the OS at anytime with the Init() method. At the time of implementation,
29 // the caller creates an object of this class each time a network error occurs.
30 // In this case, the initialization overhead is not significant, and it will
31 // guaranteed to be in sync with OS.
32 //
33 // To use, create an instance and call ShouldDialOnNetworkError() to determine
34 // if you should dial or not. That function only return true for the
35 // target OS's so the caller doesn't have to deal with OS version checking.
36 //
37
38 class nsAutodial
39 {
40 private:
41
42 //
43 // Some helper functions to query the OS for autodial configuration.
44 //
45
46 // Determine if the autodial service is running on this PC.
47 bool IsAutodialServiceRunning();
48
49 // Get the number of RAS connection entries configured from the OS.
50 int NumRASEntries();
51
52 // Get the name of the default connection from the OS.
53 nsresult GetDefaultEntryName(wchar_t* entryName, int bufferSize);
54
55 // Get the name of the first RAS dial entry from the OS.
56 nsresult GetFirstEntryName(wchar_t* entryName, int bufferSize);
57
58 // Check to see if RAS already has a dialup connection going.
59 bool IsRASConnected();
60
61 // Get the autodial behavior from the OS.
62 int QueryAutodialBehavior();
63
64 // Add the specified address to the autodial directory.
65 bool AddAddressToAutodialDirectory(char16ptr_t hostName);
66
67 // Get the current TAPI dialing location.
68 int GetCurrentLocation();
69
70 // See if autodial is enabled for specified location.
71 bool IsAutodialServiceEnabled(int location);
72
73 //
74 // Autodial behavior. This comes from the Windows registry, set in the ctor.
75 // Object won't pick up changes to the registry automatically, but can be
76 // refreshed at anytime by calling Init(). So if the user changed the
77 // autodial settings, they wouldn't be noticed unless Init() is called.
78 int mAutodialBehavior;
79
80 int mAutodialServiceDialingLocation;
81
82 enum { AUTODIAL_NEVER = 1 }; // Never autodial.
83 enum { AUTODIAL_ALWAYS = 2 }; // Always autodial as set in Internet Options.
84 enum { AUTODIAL_ON_NETWORKERROR = 3 }; // Autodial when a connection error occurs as set in Internet Options.
85 enum { AUTODIAL_USE_SERVICE = 4 }; // Use the RAS autodial service to dial.
86
87 // Number of RAS connection entries in the phonebook.
88 int mNumRASConnectionEntries;
89
90 // Default connection entry name.
91 wchar_t mDefaultEntryName[RAS_MaxEntryName + 1];
92
93 // Don't try to dial again within a few seconds of when user pressed cancel.
94 static PRIntervalTime mDontRetryUntil;
95
96 public:
97
98 // ctor
99 nsAutodial();
100
101 // dtor
102 virtual ~nsAutodial();
103
104 // Get the autodial info from the OS and init this obj with it. Call it any
105 // time to refresh the object's settings from the OS.
106 nsresult Init();
107
108 // Dial the default RAS dialup connection.
109 nsresult DialDefault(const char16_t* hostName);
110
111 // Should we try to dial on network error?
112 bool ShouldDialOnNetworkError();
113 };
114
115 #endif // !nsAutodialWin_h__
116

mercurial