2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dialup.h
|
2008-03-10 15:24:38 +00:00
|
|
|
// Purpose: interface of wxDialUpManager
|
2008-03-08 13:52:38 +00:00
|
|
|
// Author: wxWidgets team
|
2010-07-13 13:29:13 +00:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxDialUpManager
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-04-21 01:40:12 +00:00
|
|
|
This class encapsulates functions dealing with verifying the connection
|
|
|
|
status of the workstation (connected to the Internet via a direct
|
|
|
|
connection, connected through a modem or not connected at all) and to
|
|
|
|
establish this connection if possible/required (i.e. in the case of the
|
|
|
|
modem).
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
The program may also wish to be notified about the change in the connection
|
|
|
|
status (for example, to perform some action when the user connects to the
|
2008-04-21 01:40:12 +00:00
|
|
|
network the next time or, on the contrary, to stop receiving data from the
|
|
|
|
net when the user hangs up the modem). For this, you need to use one of the
|
|
|
|
event macros described below.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-04-21 01:40:12 +00:00
|
|
|
This class is different from other wxWidgets classes in that there is at
|
|
|
|
most one instance of this class in the program accessed via Create() and
|
|
|
|
you can't create the objects of this class directly.
|
|
|
|
|
2009-02-18 17:58:51 +00:00
|
|
|
@beginEventEmissionTable{wxDialUpEvent}
|
2008-04-21 01:40:12 +00:00
|
|
|
@event{EVT_DIALUP_CONNECTED(func)}
|
2009-02-18 17:58:51 +00:00
|
|
|
A connection with the network was established.
|
2008-04-21 01:40:12 +00:00
|
|
|
@event{EVT_DIALUP_DISCONNECTED(func)}
|
2009-02-18 17:58:51 +00:00
|
|
|
The connection with the network was lost.
|
2008-04-21 01:40:12 +00:00
|
|
|
@endEventTable
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxcore}
|
|
|
|
@category{net}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-04-21 01:40:12 +00:00
|
|
|
@see @ref page_samples_dialup, wxDialUpEvent
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
class wxDialUpManager
|
2008-03-08 13:52:38 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 11:21:10 +00:00
|
|
|
virtual ~wxDialUpManager();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-04-21 01:40:12 +00:00
|
|
|
Cancel dialing the number initiated with Dial() with async parameter
|
|
|
|
equal to @true.
|
|
|
|
|
|
|
|
@note This won't result in a DISCONNECTED event being sent.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see IsDialing()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-29 10:52:37 +00:00
|
|
|
virtual bool CancelDialing() = 0;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-04-21 01:40:12 +00:00
|
|
|
This function should create and return the object of the
|
|
|
|
platform-specific class derived from wxDialUpManager. You should delete
|
|
|
|
the pointer when you are done with it.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-27 11:21:10 +00:00
|
|
|
static wxDialUpManager* Create();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Dial the given ISP, use @a username and @a password to authenticate.
|
2008-04-21 01:40:12 +00:00
|
|
|
|
|
|
|
The parameters are only used under Windows currently, for Unix you
|
|
|
|
should use SetConnectCommand() to customize this functions behaviour.
|
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
If no @a nameOfISP is given, the function will select the default one
|
2008-04-21 01:40:12 +00:00
|
|
|
(proposing the user to choose among all connections defined on this
|
|
|
|
machine) and if no username and/or password are given, the function
|
|
|
|
will try to do without them, but will ask the user if really needed.
|
|
|
|
|
|
|
|
If @a async parameter is @false, the function waits until the end of
|
|
|
|
dialing and returns @true upon successful completion.
|
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
If @a async is @true, the function only initiates the connection and
|
2008-04-21 01:40:12 +00:00
|
|
|
returns immediately - the result is reported via events (an event is
|
|
|
|
sent anyhow, but if dialing failed it will be a DISCONNECTED one).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-29 10:52:37 +00:00
|
|
|
virtual bool Dial(const wxString& nameOfISP = wxEmptyString,
|
|
|
|
const wxString& username = wxEmptyString,
|
|
|
|
const wxString& password = wxEmptyString,
|
|
|
|
bool async = true) = 0;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Disable automatic check for connection status change - notice that the
|
|
|
|
@c wxEVT_DIALUP_XXX events won't be sent any more neither.
|
|
|
|
*/
|
2008-09-29 10:52:37 +00:00
|
|
|
virtual void DisableAutoCheckOnlineStatus() = 0;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
Enable automatic checks for the connection status and sending of
|
2011-01-06 19:52:14 +00:00
|
|
|
@c wxEVT_DIALUP_CONNECTED/wxEVT_DIALUP_DISCONNECTED events. The interval
|
2008-04-21 01:40:12 +00:00
|
|
|
parameter is only for Unix where we do the check manually and specifies
|
|
|
|
how often should we repeat the check (each minute by default). Under
|
|
|
|
Windows, the notification about the change of connection status is sent
|
|
|
|
by the system and so we don't do any polling and this parameter is
|
|
|
|
ignored.
|
|
|
|
|
2008-05-11 01:38:53 +00:00
|
|
|
@return @false if couldn't set up automatic check for online status.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-29 10:52:37 +00:00
|
|
|
virtual bool EnableAutoCheckOnlineStatus(size_t nSeconds = 60) = 0;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
This function is only implemented under Windows.
|
2008-04-21 01:40:12 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Fills the array with the names of all possible values for the first
|
2008-04-21 01:40:12 +00:00
|
|
|
parameter to Dial() on this machine and returns their number (may be
|
|
|
|
0).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-29 10:52:37 +00:00
|
|
|
virtual size_t GetISPNames(wxArrayString& names) const = 0;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Hang up the currently active dial up connection.
|
|
|
|
*/
|
2008-09-29 10:52:37 +00:00
|
|
|
virtual bool HangUp() = 0;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2012-12-01 00:14:07 +00:00
|
|
|
Returns @true if the computer has a permanent network connection (i.e.\
|
2008-04-21 01:40:12 +00:00
|
|
|
is on a LAN) and so there is no need to use Dial() function to go
|
|
|
|
online.
|
|
|
|
|
|
|
|
@note This function tries to guess the result and it is not always
|
|
|
|
guaranteed to be correct, so it is better to ask user for
|
|
|
|
confirmation or give him a possibility to override it.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-29 10:52:37 +00:00
|
|
|
virtual bool IsAlwaysOnline() const = 0;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if (async) dialing is in progress.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see Dial()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-29 10:52:37 +00:00
|
|
|
virtual bool IsDialing() const = 0;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the dialup manager was initialized correctly. If this
|
2008-04-21 01:40:12 +00:00
|
|
|
function returns @false, no other functions will work neither, so it is
|
|
|
|
a good idea to call this function and check its result before calling
|
|
|
|
any other wxDialUpManager methods.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-29 10:52:37 +00:00
|
|
|
virtual bool IsOk() const = 0;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-04-21 01:40:12 +00:00
|
|
|
Returns @true if the computer is connected to the network: under
|
|
|
|
Windows, this just means that a RAS connection exists, under Unix we
|
|
|
|
check that the "well-known host" (as specified by SetWellKnownHost())
|
|
|
|
is reachable.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-29 10:52:37 +00:00
|
|
|
virtual bool IsOnline() const = 0;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
This method is for Unix only.
|
2008-04-21 01:40:12 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Sets the commands to start up the network and to hang up again.
|
|
|
|
*/
|
2008-10-27 21:26:54 +00:00
|
|
|
virtual void SetConnectCommand(const wxString& commandDial = "/usr/bin/pon",
|
|
|
|
const wxString& commandHangup = "/usr/bin/poff") = 0;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-04-21 01:40:12 +00:00
|
|
|
Sometimes the built-in logic for determining the online status may
|
|
|
|
fail, so, in general, the user should be allowed to override it. This
|
|
|
|
function allows to forcefully set the online status - whatever our
|
|
|
|
internal algorithm may think about it.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see IsOnline()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-29 10:52:37 +00:00
|
|
|
virtual void SetOnlineStatus(bool isOnline = true) = 0;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
This method is for Unix only.
|
2008-04-21 01:40:12 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Under Unix, the value of well-known host is used to check whether we're
|
2008-04-21 01:40:12 +00:00
|
|
|
connected to the internet. It is unused under Windows, but this
|
|
|
|
function is always safe to call. The default value is
|
|
|
|
@c "www.yahoo.com:80".
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-29 10:52:37 +00:00
|
|
|
virtual void SetWellKnownHost(const wxString& hostname,
|
|
|
|
int portno = 80) = 0;
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxDialUpEvent
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-04-21 01:40:12 +00:00
|
|
|
This is the event class for the dialup events sent by wxDialUpManager.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxcore}
|
|
|
|
@category{events}
|
|
|
|
*/
|
|
|
|
class wxDialUpEvent : public wxEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor is only used by wxDialUpManager.
|
|
|
|
*/
|
|
|
|
wxDialUpEvent(bool isConnected, bool isOwnEvent);
|
|
|
|
|
|
|
|
/**
|
2008-04-21 01:40:12 +00:00
|
|
|
Is this a @c CONNECTED or @c DISCONNECTED event? In other words, does
|
|
|
|
it notify about transition from offline to online state or vice versa?
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool IsConnectedEvent() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2011-04-03 20:31:32 +00:00
|
|
|
Does this event come from wxDialUpManager::Dial() or from some external
|
2008-03-08 13:52:38 +00:00
|
|
|
process (i.e. does it result from our own attempt to establish the
|
|
|
|
connection)?
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool IsOwnEvent() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
2008-03-10 15:24:38 +00:00
|
|
|
|