Version: 3.0.2
wxDialUpManager Class Referenceabstract

#include <wx/dialup.h>

Detailed Description

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).

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 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.

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.

Events emitted by this class

The following event handler macros redirect the events to member function handlers 'func' with prototypes like:

void handlerFuncName(wxDialUpEvent& event)

Event macros for events emitted by this class:

  • EVT_DIALUP_CONNECTED(func):
    A connection with the network was established.
  • EVT_DIALUP_DISCONNECTED(func):
    The connection with the network was lost.

Library:  wxCore
Category:  Networking
See Also
Dialup Sample, wxDialUpEvent

Public Member Functions

virtual ~wxDialUpManager ()
 Destructor.
 
virtual bool CancelDialing ()=0
 Cancel dialing the number initiated with Dial() with async parameter equal to true.
 
virtual bool Dial (const wxString &nameOfISP=wxEmptyString, const wxString &username=wxEmptyString, const wxString &password=wxEmptyString, bool async=true)=0
 Dial the given ISP, use username and password to authenticate.
 
virtual void DisableAutoCheckOnlineStatus ()=0
 Disable automatic check for connection status change - notice that the wxEVT_DIALUP_XXX events won't be sent any more neither.
 
virtual bool EnableAutoCheckOnlineStatus (size_t nSeconds=60)=0
 Enable automatic checks for the connection status and sending of wxEVT_DIALUP_CONNECTED/wxEVT_DIALUP_DISCONNECTED events.
 
virtual size_t GetISPNames (wxArrayString &names) const =0
 This function is only implemented under Windows.
 
virtual bool HangUp ()=0
 Hang up the currently active dial up connection.
 
virtual bool IsAlwaysOnline () const =0
 Returns true if the computer has a permanent network connection (i.e.
 
virtual bool IsDialing () const =0
 Returns true if (async) dialing is in progress.
 
virtual bool IsOk () const =0
 Returns true if the dialup manager was initialized correctly.
 
virtual bool IsOnline () const =0
 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.
 
virtual void SetConnectCommand (const wxString &commandDial="/usr/bin/pon", const wxString &commandHangup="/usr/bin/poff")=0
 This method is for Unix only.
 
virtual void SetOnlineStatus (bool isOnline=true)=0
 Sometimes the built-in logic for determining the online status may fail, so, in general, the user should be allowed to override it.
 
virtual void SetWellKnownHost (const wxString &hostname, int portno=80)=0
 This method is for Unix only.
 

Static Public Member Functions

static wxDialUpManagerCreate ()
 This function should create and return the object of the platform-specific class derived from wxDialUpManager.
 

Constructor & Destructor Documentation

virtual wxDialUpManager::~wxDialUpManager ( )
virtual

Destructor.

Member Function Documentation

virtual bool wxDialUpManager::CancelDialing ( )
pure virtual

Cancel dialing the number initiated with Dial() with async parameter equal to true.

Note
This won't result in a DISCONNECTED event being sent.
See Also
IsDialing()
static wxDialUpManager* wxDialUpManager::Create ( )
static

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.

virtual bool wxDialUpManager::Dial ( const wxString nameOfISP = wxEmptyString,
const wxString username = wxEmptyString,
const wxString password = wxEmptyString,
bool  async = true 
)
pure virtual

Dial the given ISP, use username and password to authenticate.

The parameters are only used under Windows currently, for Unix you should use SetConnectCommand() to customize this functions behaviour.

If no nameOfISP is given, the function will select the default one (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 async parameter is false, the function waits until the end of dialing and returns true upon successful completion.

If async is true, the function only initiates the connection and returns immediately - the result is reported via events (an event is sent anyhow, but if dialing failed it will be a DISCONNECTED one).

virtual void wxDialUpManager::DisableAutoCheckOnlineStatus ( )
pure virtual

Disable automatic check for connection status change - notice that the wxEVT_DIALUP_XXX events won't be sent any more neither.

virtual bool wxDialUpManager::EnableAutoCheckOnlineStatus ( size_t  nSeconds = 60)
pure virtual

Enable automatic checks for the connection status and sending of wxEVT_DIALUP_CONNECTED/wxEVT_DIALUP_DISCONNECTED events.

The interval 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.

Returns
false if couldn't set up automatic check for online status.
virtual size_t wxDialUpManager::GetISPNames ( wxArrayString names) const
pure virtual

This function is only implemented under Windows.

Fills the array with the names of all possible values for the first parameter to Dial() on this machine and returns their number (may be 0).

virtual bool wxDialUpManager::HangUp ( )
pure virtual

Hang up the currently active dial up connection.

virtual bool wxDialUpManager::IsAlwaysOnline ( ) const
pure virtual

Returns true if the computer has a permanent network connection (i.e.

\ 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.
virtual bool wxDialUpManager::IsDialing ( ) const
pure virtual

Returns true if (async) dialing is in progress.

See Also
Dial()
virtual bool wxDialUpManager::IsOk ( ) const
pure virtual

Returns true if the dialup manager was initialized correctly.

If this 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.

virtual bool wxDialUpManager::IsOnline ( ) const
pure virtual

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.

virtual void wxDialUpManager::SetConnectCommand ( const wxString commandDial = "/usr/bin/pon",
const wxString commandHangup = "/usr/bin/poff" 
)
pure virtual

This method is for Unix only.

Sets the commands to start up the network and to hang up again.

virtual void wxDialUpManager::SetOnlineStatus ( bool  isOnline = true)
pure virtual

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.

See Also
IsOnline()
virtual void wxDialUpManager::SetWellKnownHost ( const wxString hostname,
int  portno = 80 
)
pure virtual

This method is for Unix only.

Under Unix, the value of well-known host is used to check whether we're connected to the internet. It is unused under Windows, but this function is always safe to call. The default value is "www.yahoo.com:80".