]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dialup.h
Removed non-theme related defs
[wxWidgets.git] / include / wx / dialup.h
CommitLineData
09884325 1/////////////////////////////////////////////////////////////////////////////
a0b4c98b 2// Name: wx/dialup.h
77ffb593 3// Purpose: Network related wxWidgets classes and functions
09884325
VZ
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 07.07.99
7// RCS-ID: $Id$
8// Copyright: (c) Vadim Zeitlin
65571936 9// Licence: wxWindows licence
09884325
VZ
10/////////////////////////////////////////////////////////////////////////////
11
4285fbca
GD
12#ifndef _WX_DIALUP_H
13#define _WX_DIALUP_H
09884325 14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
5e0201ea
JS
16 #pragma interface "dialup.h"
17#endif
18
09884325
VZ
19#if wxUSE_DIALUP_MANAGER
20
c640e407
VZ
21#include "wx/event.h"
22
a0b4c98b 23// ----------------------------------------------------------------------------
2690830e 24// misc
a0b4c98b
VZ
25// ----------------------------------------------------------------------------
26
62a9d04c 27class WXDLLIMPEXP_BASE wxArrayString;
2690830e 28
223d09f6 29#define WXDIALUP_MANAGER_DEFAULT_BEACONHOST wxT("www.yahoo.com")
a0b4c98b 30
09884325
VZ
31// ----------------------------------------------------------------------------
32// A class which groups functions dealing with connecting to the network from a
33// workstation using dial-up access to the net. There is at most one instance
34// of this class in the program accessed via GetDialUpManager().
35// ----------------------------------------------------------------------------
36
37/* TODO
38 *
39 * 1. more configurability for Unix: i.e. how to initiate the connection, how
40 * to check for online status, &c.
a0b4c98b
VZ
41 * 2. a function to enumerate all connections (ISPs) and show a dialog in
42 * Dial() allowing to choose between them if no ISP given
09884325
VZ
43 * 3. add an async version of dialing functions which notify the caller about
44 * the progress (or may be even start another thread to monitor it)
45 * 4. the static creation/accessor functions are not MT-safe - but is this
46 * really crucial? I think we may suppose they're always called from the
47 * main thread?
48 */
49
50class WXDLLEXPORT wxDialUpManager
51{
52public:
1c8515f9
KB
53 // this function should create and return the object of the
54 // platform-specific class derived from wxDialUpManager. It's implemented
55 // in the platform-specific source files.
56 static wxDialUpManager *Create();
09884325
VZ
57
58 // could the dialup manager be initialized correctly? If this function
68379eaf 59 // returns false, no other functions will work neither, so it's a good idea
09884325
VZ
60 // to call this function and check its result before calling any other
61 // wxDialUpManager methods
62 virtual bool IsOk() const = 0;
63
64 // virtual dtor for any base class
65 virtual ~wxDialUpManager() { }
66
67 // operations
68 // ----------
69
2690830e
VZ
70 // fills the array with the names of all possible values for the first
71 // parameter to Dial() on this machine and returns their number (may be 0)
72 virtual size_t GetISPNames(wxArrayString& names) const = 0;
73
a0b4c98b
VZ
74 // dial the given ISP, use username and password to authentificate
75 //
2690830e
VZ
76 // if no nameOfISP is given, the function will select the default one
77 //
78 // if no username/password are given, the function will try to do without
79 // them, but will ask the user if really needed
80 //
68379eaf
WS
81 // if async parameter is false, the function waits until the end of dialing
82 // and returns true upon successful completion.
83 // if async is true, the function only initiates the connection and returns
a0b4c98b
VZ
84 // immediately - the result is reported via events (an event is sent
85 // anyhow, but if dialing failed it will be a DISCONNECTED one)
86 virtual bool Dial(const wxString& nameOfISP = wxEmptyString,
87 const wxString& username = wxEmptyString,
88 const wxString& password = wxEmptyString,
68379eaf 89 bool async = true) = 0;
a0b4c98b 90
68379eaf 91 // returns true if (async) dialing is in progress
e90c1d2a 92 virtual bool IsDialing() const = 0;
a0b4c98b 93
68379eaf 94 // cancel dialing the number initiated with Dial(async = true)
a0b4c98b
VZ
95 // NB: this won't result in DISCONNECTED event being sent
96 virtual bool CancelDialing() = 0;
09884325
VZ
97
98 // hang up the currently active dial up connection
99 virtual bool HangUp() = 0;
100
101 // online status
102 // -------------
103
68379eaf 104 // returns true if the computer has a permanent network connection (i.e. is
2690830e
VZ
105 // on a LAN) and so there is no need to use Dial() function to go online
106 //
107 // NB: this functions tries to guess the result and it is not always
108 // guaranteed to be correct, so it's better to ask user for
109 // confirmation or give him a possibility to override it
110 virtual bool IsAlwaysOnline() const = 0;
111
68379eaf 112 // returns true if the computer is connected to the network: under Windows,
09884325
VZ
113 // this just means that a RAS connection exists, under Unix we check that
114 // the "well-known host" (as specified by SetWellKnownHost) is reachable
1c8515f9 115 virtual bool IsOnline() const = 0;
09884325
VZ
116
117 // sometimes the built-in logic for determining the online status may fail,
118 // so, in general, the user should be allowed to override it. This function
119 // allows to forcefully set the online status - whatever our internal
120 // algorithm may think about it.
68379eaf 121 virtual void SetOnlineStatus(bool isOnline = true) = 0;
09884325
VZ
122
123 // set misc wxDialUpManager options
124 // --------------------------------
125
126 // enable automatical checks for the connection status and sending of
127 // wxEVT_DIALUP_CONNECTED/wxEVT_DIALUP_DISCONNECTED events. The interval
128 // parameter is only for Unix where we do the check manually: under
129 // Windows, the notification about the change of connection status is
130 // instantenous.
131 //
68379eaf 132 // Returns false if couldn't set up automatic check for online status.
09884325
VZ
133 virtual bool EnableAutoCheckOnlineStatus(size_t nSeconds = 60) = 0;
134
135 // disable automatic check for connection status change - notice that the
136 // wxEVT_DIALUP_XXX events won't be sent any more neither.
137 virtual void DisableAutoCheckOnlineStatus() = 0;
138
a0b4c98b
VZ
139 // additional Unix-only configuration
140 // ----------------------------------
141
09884325
VZ
142 // under Unix, the value of well-known host is used to check whether we're
143 // connected to the internet. It's unused under Windows, but this function
144 // is always safe to call. The default value is www.yahoo.com.
1c8515f9
KB
145 virtual void SetWellKnownHost(const wxString& hostname,
146 int portno = 80) = 0;
a0b4c98b
VZ
147
148 // Sets the commands to start up the network and to hang up again. Used by
149 // the Unix implementations only.
150 virtual void
223d09f6
KB
151 SetConnectCommand(const wxString& commandDial = wxT("/usr/bin/pon"),
152 const wxString& commandHangup = wxT("/usr/bin/poff")) = 0;
09884325
VZ
153};
154
155// ----------------------------------------------------------------------------
2e4df4bf 156// wxDialUpManager events
09884325
VZ
157// ----------------------------------------------------------------------------
158
41618285
VZ
159BEGIN_DECLARE_EVENT_TYPES()
160 DECLARE_EVENT_TYPE(wxEVT_DIALUP_CONNECTED, 450)
161 DECLARE_EVENT_TYPE(wxEVT_DIALUP_DISCONNECTED, 451)
162END_DECLARE_EVENT_TYPES()
163
09884325
VZ
164// the event class for the dialup events
165class WXDLLEXPORT wxDialUpEvent : public wxEvent
166{
167public:
a0b4c98b 168 wxDialUpEvent(bool isConnected, bool isOwnEvent) : wxEvent(isOwnEvent)
09884325
VZ
169 {
170 SetEventType(isConnected ? wxEVT_DIALUP_CONNECTED
171 : wxEVT_DIALUP_DISCONNECTED);
172 }
173
174 // is this a CONNECTED or DISCONNECTED event?
a0b4c98b
VZ
175 bool IsConnectedEvent() const
176 { return GetEventType() == wxEVT_DIALUP_CONNECTED; }
177
178 // does this event come from wxDialUpManager::Dial() or from some extrenal
179 // process (i.e. does it result from our own attempt to establish the
180 // connection)?
181 bool IsOwnEvent() const { return m_id != 0; }
acd15a3f
VZ
182
183 // implement the base class pure virtual
184 virtual wxEvent *Clone() const { return new wxDialUpEvent(*this); }
2eb10e2a
VZ
185
186private:
a6cbc4db 187 DECLARE_NO_ASSIGN_CLASS(wxDialUpEvent)
09884325
VZ
188};
189
190// the type of dialup event handler function
69d16e3e 191typedef void (wxEvtHandler::*wxDialUpEventFunction)(wxDialUpEvent&);
09884325 192
7fa03f04 193#define wxDialUpEventHandler(func) \
d94c09cd 194 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDialUpEventFunction, &func)
7fa03f04 195
09884325 196// macros to catch dialup events
82a5f02c 197#define EVT_DIALUP_CONNECTED(func) \
7fa03f04 198 wx__DECLARE_EVT0(wxEVT_DIALUP_CONNECTED, wxDialUpEventHandler(func))
82a5f02c 199#define EVT_DIALUP_DISCONNECTED(func) \
7fa03f04 200 wx__DECLARE_EVT0(wxEVT_DIALUP_DISCONNECTED, wxDialUpEventHandler(func))
09884325 201
89be8239 202
09884325
VZ
203#endif // wxUSE_DIALUP_MANAGER
204
4285fbca 205#endif // _WX_DIALUP_H