]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dialup.h | |
e54c96f1 | 3 | // Purpose: interface of wxDialUpManager |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxDialUpManager | |
7c913512 | 11 | |
bc85d676 BP |
12 | This class encapsulates functions dealing with verifying the connection |
13 | status of the workstation (connected to the Internet via a direct | |
14 | connection, connected through a modem or not connected at all) and to | |
15 | establish this connection if possible/required (i.e. in the case of the | |
16 | modem). | |
7c913512 | 17 | |
23324ae1 FM |
18 | The program may also wish to be notified about the change in the connection |
19 | status (for example, to perform some action when the user connects to the | |
bc85d676 BP |
20 | network the next time or, on the contrary, to stop receiving data from the |
21 | net when the user hangs up the modem). For this, you need to use one of the | |
22 | event macros described below. | |
7c913512 | 23 | |
bc85d676 BP |
24 | This class is different from other wxWidgets classes in that there is at |
25 | most one instance of this class in the program accessed via Create() and | |
26 | you can't create the objects of this class directly. | |
27 | ||
28 | @beginEventTable{wxDialUpEvent} | |
29 | @event{EVT_DIALUP_CONNECTED(func)} | |
30 | A connection with the network was established. | |
31 | @event{EVT_DIALUP_DISCONNECTED(func)} | |
32 | The connection with the network was lost. | |
33 | @endEventTable | |
7c913512 | 34 | |
23324ae1 FM |
35 | @library{wxcore} |
36 | @category{net} | |
7c913512 | 37 | |
bc85d676 | 38 | @see @ref page_samples_dialup, wxDialUpEvent |
23324ae1 | 39 | */ |
7c913512 | 40 | class wxDialUpManager |
23324ae1 FM |
41 | { |
42 | public: | |
43 | /** | |
44 | Destructor. | |
45 | */ | |
adaaa686 | 46 | virtual ~wxDialUpManager(); |
23324ae1 FM |
47 | |
48 | /** | |
bc85d676 BP |
49 | Cancel dialing the number initiated with Dial() with async parameter |
50 | equal to @true. | |
51 | ||
52 | @note This won't result in a DISCONNECTED event being sent. | |
3c4f71cc | 53 | |
4cc4bfaf | 54 | @see IsDialing() |
23324ae1 | 55 | */ |
b91c4601 | 56 | virtual bool CancelDialing() = 0; |
23324ae1 FM |
57 | |
58 | /** | |
bc85d676 BP |
59 | This function should create and return the object of the |
60 | platform-specific class derived from wxDialUpManager. You should delete | |
61 | the pointer when you are done with it. | |
23324ae1 | 62 | */ |
adaaa686 | 63 | static wxDialUpManager* Create(); |
23324ae1 FM |
64 | |
65 | /** | |
4cc4bfaf | 66 | Dial the given ISP, use @a username and @a password to authenticate. |
bc85d676 BP |
67 | |
68 | The parameters are only used under Windows currently, for Unix you | |
69 | should use SetConnectCommand() to customize this functions behaviour. | |
70 | ||
4cc4bfaf | 71 | If no @a nameOfISP is given, the function will select the default one |
bc85d676 BP |
72 | (proposing the user to choose among all connections defined on this |
73 | machine) and if no username and/or password are given, the function | |
74 | will try to do without them, but will ask the user if really needed. | |
75 | ||
76 | If @a async parameter is @false, the function waits until the end of | |
77 | dialing and returns @true upon successful completion. | |
78 | ||
4cc4bfaf | 79 | If @a async is @true, the function only initiates the connection and |
bc85d676 BP |
80 | returns immediately - the result is reported via events (an event is |
81 | sent anyhow, but if dialing failed it will be a DISCONNECTED one). | |
23324ae1 | 82 | */ |
b91c4601 FM |
83 | virtual bool Dial(const wxString& nameOfISP = wxEmptyString, |
84 | const wxString& username = wxEmptyString, | |
85 | const wxString& password = wxEmptyString, | |
86 | bool async = true) = 0; | |
23324ae1 FM |
87 | |
88 | /** | |
89 | Disable automatic check for connection status change - notice that the | |
90 | @c wxEVT_DIALUP_XXX events won't be sent any more neither. | |
91 | */ | |
b91c4601 | 92 | virtual void DisableAutoCheckOnlineStatus() = 0; |
23324ae1 FM |
93 | |
94 | /** | |
7c913512 | 95 | Enable automatic checks for the connection status and sending of |
bc85d676 BP |
96 | wxEVT_DIALUP_CONNECTED/wxEVT_DIALUP_DISCONNECTED events. The interval |
97 | parameter is only for Unix where we do the check manually and specifies | |
98 | how often should we repeat the check (each minute by default). Under | |
99 | Windows, the notification about the change of connection status is sent | |
100 | by the system and so we don't do any polling and this parameter is | |
101 | ignored. | |
102 | ||
d29a9a8a | 103 | @return @false if couldn't set up automatic check for online status. |
23324ae1 | 104 | */ |
b91c4601 | 105 | virtual bool EnableAutoCheckOnlineStatus(size_t nSeconds = 60) = 0; |
23324ae1 FM |
106 | |
107 | /** | |
108 | This function is only implemented under Windows. | |
bc85d676 | 109 | |
23324ae1 | 110 | Fills the array with the names of all possible values for the first |
bc85d676 BP |
111 | parameter to Dial() on this machine and returns their number (may be |
112 | 0). | |
23324ae1 | 113 | */ |
b91c4601 | 114 | virtual size_t GetISPNames(wxArrayString& names) const = 0; |
23324ae1 FM |
115 | |
116 | /** | |
117 | Hang up the currently active dial up connection. | |
118 | */ | |
b91c4601 | 119 | virtual bool HangUp() = 0; |
23324ae1 FM |
120 | |
121 | /** | |
bc85d676 BP |
122 | Returns @true if the computer has a permanent network connection (i.e. |
123 | is on a LAN) and so there is no need to use Dial() function to go | |
124 | online. | |
125 | ||
126 | @note This function tries to guess the result and it is not always | |
127 | guaranteed to be correct, so it is better to ask user for | |
128 | confirmation or give him a possibility to override it. | |
23324ae1 | 129 | */ |
b91c4601 | 130 | virtual bool IsAlwaysOnline() const = 0; |
23324ae1 FM |
131 | |
132 | /** | |
133 | Returns @true if (async) dialing is in progress. | |
3c4f71cc | 134 | |
4cc4bfaf | 135 | @see Dial() |
23324ae1 | 136 | */ |
b91c4601 | 137 | virtual bool IsDialing() const = 0; |
23324ae1 FM |
138 | |
139 | /** | |
140 | Returns @true if the dialup manager was initialized correctly. If this | |
bc85d676 BP |
141 | function returns @false, no other functions will work neither, so it is |
142 | a good idea to call this function and check its result before calling | |
143 | any other wxDialUpManager methods. | |
23324ae1 | 144 | */ |
b91c4601 | 145 | virtual bool IsOk() const = 0; |
23324ae1 FM |
146 | |
147 | /** | |
bc85d676 BP |
148 | Returns @true if the computer is connected to the network: under |
149 | Windows, this just means that a RAS connection exists, under Unix we | |
150 | check that the "well-known host" (as specified by SetWellKnownHost()) | |
151 | is reachable. | |
23324ae1 | 152 | */ |
b91c4601 | 153 | virtual bool IsOnline() const = 0; |
23324ae1 FM |
154 | |
155 | /** | |
23324ae1 | 156 | This method is for Unix only. |
bc85d676 | 157 | |
23324ae1 FM |
158 | Sets the commands to start up the network and to hang up again. |
159 | */ | |
bc85d676 BP |
160 | void SetConnectCommand(const wxString& commandDial = "/usr/bin/pon", |
161 | const wxString& commandHangup = "/usr/bin/poff") const; | |
23324ae1 FM |
162 | |
163 | /** | |
bc85d676 BP |
164 | Sometimes the built-in logic for determining the online status may |
165 | fail, so, in general, the user should be allowed to override it. This | |
166 | function allows to forcefully set the online status - whatever our | |
167 | internal algorithm may think about it. | |
3c4f71cc | 168 | |
4cc4bfaf | 169 | @see IsOnline() |
23324ae1 | 170 | */ |
b91c4601 | 171 | virtual void SetOnlineStatus(bool isOnline = true) = 0; |
23324ae1 FM |
172 | |
173 | /** | |
174 | This method is for Unix only. | |
bc85d676 | 175 | |
23324ae1 | 176 | Under Unix, the value of well-known host is used to check whether we're |
bc85d676 BP |
177 | connected to the internet. It is unused under Windows, but this |
178 | function is always safe to call. The default value is | |
179 | @c "www.yahoo.com:80". | |
23324ae1 | 180 | */ |
b91c4601 FM |
181 | virtual void SetWellKnownHost(const wxString& hostname, |
182 | int portno = 80) = 0; | |
23324ae1 FM |
183 | }; |
184 | ||
185 | ||
e54c96f1 | 186 | |
23324ae1 FM |
187 | /** |
188 | @class wxDialUpEvent | |
7c913512 | 189 | |
bc85d676 | 190 | This is the event class for the dialup events sent by wxDialUpManager. |
7c913512 | 191 | |
23324ae1 FM |
192 | @library{wxcore} |
193 | @category{events} | |
194 | */ | |
195 | class wxDialUpEvent : public wxEvent | |
196 | { | |
197 | public: | |
198 | /** | |
199 | Constructor is only used by wxDialUpManager. | |
200 | */ | |
201 | wxDialUpEvent(bool isConnected, bool isOwnEvent); | |
202 | ||
203 | /** | |
bc85d676 BP |
204 | Is this a @c CONNECTED or @c DISCONNECTED event? In other words, does |
205 | it notify about transition from offline to online state or vice versa? | |
23324ae1 | 206 | */ |
328f5751 | 207 | bool IsConnectedEvent() const; |
23324ae1 FM |
208 | |
209 | /** | |
210 | Does this event come from wxDialUpManager::Dial() or from some extrenal | |
211 | process (i.e. does it result from our own attempt to establish the | |
212 | connection)? | |
213 | */ | |
328f5751 | 214 | bool IsOwnEvent() const; |
23324ae1 | 215 | }; |
e54c96f1 | 216 |