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