2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dde.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxDDEConnection
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxDDEConnection
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
A wxDDEConnection object represents the connection between a client and a
|
2008-04-20 19:50:56 -04:00
|
|
|
server. It can be created by making a connection using a wxDDEClient
|
2008-11-15 06:37:43 -05:00
|
|
|
object, or by the acceptance of a connection by a wxDDEServer object.
|
|
|
|
The bulk of a DDE (Dynamic Data Exchange) conversation is controlled by calling
|
2008-04-20 19:50:56 -04:00
|
|
|
members in a wxDDEConnection object or by overriding its members.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
An application should normally derive a new connection class from
|
2008-04-20 19:50:56 -04:00
|
|
|
wxDDEConnection, in order to override the communication event handlers to
|
|
|
|
do something interesting.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
This DDE-based implementation is available on Windows only, but a
|
|
|
|
platform-independent, socket-based version of this API is available using
|
|
|
|
wxTCPConnection.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
2008-04-20 19:50:56 -04:00
|
|
|
@category{ipc}
|
2008-11-15 06:37:43 -05:00
|
|
|
@onlyfor{wxmsw}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
@see wxConnectionBase, wxDDEClient, wxDDEServer, @ref overview_ipc
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-20 19:50:56 -04:00
|
|
|
class wxDDEConnection : public wxConnectionBase
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructs a connection object. If no user-defined connection object is
|
|
|
|
to be derived from wxDDEConnection, then the constructor should not be
|
2008-04-20 19:50:56 -04:00
|
|
|
called directly, since the default connection object will be provided
|
|
|
|
on requesting (or accepting) a connection. However, if the user defines
|
|
|
|
his or her own derived connection object, the
|
|
|
|
wxDDEServer::OnAcceptConnection() and/or
|
|
|
|
wxDDEClient::OnMakeConnection() members should be replaced by functions
|
|
|
|
which construct the new connection object.
|
|
|
|
|
|
|
|
A default buffer will be associated with this connection.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxDDEConnection();
|
2008-04-20 19:50:56 -04:00
|
|
|
/**
|
|
|
|
Constructs a connection object. If no user-defined connection object is
|
|
|
|
to be derived from wxDDEConnection, then the constructor should not be
|
|
|
|
called directly, since the default connection object will be provided
|
|
|
|
on requesting (or accepting) a connection. However, if the user defines
|
|
|
|
his or her own derived connection object, the
|
|
|
|
wxDDEServer::OnAcceptConnection() and/or
|
|
|
|
wxDDEClient::OnMakeConnection() members should be replaced by functions
|
|
|
|
which construct the new connection object.
|
|
|
|
|
|
|
|
@param buffer
|
|
|
|
Buffer for this connection object to use in transactions.
|
|
|
|
@param size
|
|
|
|
Size of the buffer given.
|
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxDDEConnection(void* buffer, size_t size);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Called by the server application to advise the client of a change in
|
2008-04-20 19:50:56 -04:00
|
|
|
the data associated with the given item. Causes the client connection's
|
|
|
|
OnAdvise() member to be called.
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if successful.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool Advise(const wxString& item, const void* data, size_t size,
|
|
|
|
wxIPCFormat format = wxIPC_PRIVATE);
|
2008-03-08 09:43:31 -05:00
|
|
|
bool Advise(const wxString& item, const char* data);
|
|
|
|
bool Advise(const wxString& item, const wchar_t* data);
|
|
|
|
bool Advise(const wxString& item, const wxString data);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Called by the client or server application to disconnect from the other
|
2008-04-20 19:50:56 -04:00
|
|
|
program; it causes the OnDisconnect() message to be sent to the
|
|
|
|
corresponding connection object in the other program. The default
|
|
|
|
behaviour of OnDisconnect() is to delete the connection, but the
|
|
|
|
calling application must explicitly delete its side of the connection
|
|
|
|
having called Disconnect().
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if successful.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool Disconnect();
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Called by the client application to execute a command on the server.
|
|
|
|
Can also be used to transfer arbitrary data to the server (similar to
|
|
|
|
Poke() in that respect). Causes the server connection's OnExecute()
|
|
|
|
member to be called.
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if successful.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool Execute(const void* data, size_t size,
|
|
|
|
wxIPCFormat format = wxIPC_PRIVATE);
|
2008-03-08 09:43:31 -05:00
|
|
|
bool Execute(const char* data);
|
|
|
|
bool Execute(const wchar_t* data);
|
|
|
|
bool Execute(const wxString data);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Message sent to the client application when the server notifies it of a
|
|
|
|
change in the data associated with the given item.
|
|
|
|
*/
|
2008-04-20 19:50:56 -04:00
|
|
|
virtual bool OnAdvise(const wxString& topic, const wxString& item,
|
|
|
|
const void* data, size_t size, wxIPCFormat format);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Message sent to the client or server application when the other
|
|
|
|
application notifies it to delete the connection. Default behaviour is
|
|
|
|
to delete the connection object.
|
|
|
|
*/
|
|
|
|
virtual bool OnDisconnect();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Message sent to the server application when the client notifies it to
|
|
|
|
execute the given data. Note that there is no item associated with
|
|
|
|
this message.
|
|
|
|
*/
|
|
|
|
virtual bool OnExecute(const wxString& topic, const void* data,
|
2008-04-20 19:50:56 -04:00
|
|
|
size_t size, wxIPCFormat format);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Message sent to the server application when the client notifies it to
|
|
|
|
accept the given data.
|
|
|
|
*/
|
|
|
|
virtual bool OnPoke(const wxString& topic, const wxString& item,
|
2008-04-20 19:50:56 -04:00
|
|
|
const void* data, size_t size, wxIPCFormat format);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Message sent to the server application when the client calls Request().
|
|
|
|
The server should respond by returning a character string from
|
|
|
|
OnRequest(), or @NULL to indicate no data.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
virtual const void* OnRequest(const wxString& topic,
|
2008-04-20 19:50:56 -04:00
|
|
|
const wxString& item, size_t* size,
|
2008-03-08 08:52:38 -05:00
|
|
|
wxIPCFormat format);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Message sent to the server application by the client, when the client
|
2008-04-20 19:50:56 -04:00
|
|
|
wishes to start an "advise loop" for the given topic and item. The
|
2008-03-08 08:52:38 -05:00
|
|
|
server can refuse to participate by returning @false.
|
|
|
|
*/
|
2008-04-20 19:50:56 -04:00
|
|
|
virtual bool OnStartAdvise(const wxString& topic, const wxString& item);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Message sent to the server application by the client, when the client
|
2008-04-20 19:50:56 -04:00
|
|
|
wishes to stop an "advise loop" for the given topic and item. The
|
2008-03-08 08:52:38 -05:00
|
|
|
server can refuse to stop the advise loop by returning @false, although
|
|
|
|
this doesn't have much meaning in practice.
|
|
|
|
*/
|
2008-04-20 19:50:56 -04:00
|
|
|
virtual bool OnStopAdvise(const wxString& topic, const wxString& item);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Called by the client application to poke data into the server. Can be
|
|
|
|
used to transfer arbitrary data to the server. Causes the server
|
2008-04-20 19:50:56 -04:00
|
|
|
connection's OnPoke() member to be called.
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if successful.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool Poke(const wxString& item, const void* data, size_t size,
|
|
|
|
wxIPCFormat format = wxIPC_PRIVATE);
|
2008-03-08 09:43:31 -05:00
|
|
|
bool Poke(const wxString& item, const char* data);
|
|
|
|
bool Poke(const wxString& item, const wchar_t* data);
|
|
|
|
bool Poke(const wxString& item, const wxString data);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Called by the client application to request data from the server.
|
|
|
|
Causes the server connection's OnRequest() member to be called.
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return A character string (actually a pointer to the connection's
|
2008-04-20 19:50:56 -04:00
|
|
|
buffer) if successful, @NULL otherwise.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
const void* Request(const wxString& item, size_t* size,
|
2008-03-08 08:52:38 -05:00
|
|
|
wxIPCFormat format = wxIPC_TEXT);
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Called by the client application to ask if an advise loop can be
|
|
|
|
started with the server. Causes the server connection's OnStartAdvise()
|
|
|
|
member to be called.
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the server okays it, @false otherwise.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool StartAdvise(const wxString& item);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Called by the client application to ask if an advise loop can be
|
2008-04-20 19:50:56 -04:00
|
|
|
stopped. Causes the server connection's OnStopAdvise() member to be
|
|
|
|
called.
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the server okays it, @false otherwise.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool StopAdvise(const wxString& item);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxDDEClient
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
A wxDDEClient object represents the client part of a client-server DDE
|
|
|
|
(Dynamic Data Exchange) conversation.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
To create a client which can communicate with a suitable server, you need
|
|
|
|
to derive a class from wxDDEConnection and another from wxDDEClient. The
|
|
|
|
custom wxDDEConnection class will intercept communications in a
|
|
|
|
"conversation" with a server, and the custom wxDDEServer is required so
|
|
|
|
that a user-overridden OnMakeConnection() member can return a
|
|
|
|
wxDDEConnection of the required class, when a connection is made.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
This DDE-based implementation is available on Windows only, but a
|
|
|
|
platform-independent, socket-based version of this API is available using
|
|
|
|
wxTCPClient.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
2008-04-20 19:50:56 -04:00
|
|
|
@category{ipc}
|
2008-11-15 06:37:43 -05:00
|
|
|
@onlyfor{wxmsw}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
@see wxDDEServer, wxDDEConnection, @ref overview_ipc
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxDDEClient : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructs a client object.
|
|
|
|
*/
|
|
|
|
wxDDEClient();
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Tries to make a connection with a server specified by the host (machine
|
|
|
|
name under UNIX, ignored under Windows), service name (must contain an
|
|
|
|
integer port number under UNIX), and topic string. If the server allows
|
|
|
|
a connection, a wxDDEConnection object will be returned.
|
|
|
|
|
|
|
|
The type of wxDDEConnection returned can be altered by overriding the
|
|
|
|
OnMakeConnection() member to return your own derived connection object.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxConnectionBase* MakeConnection(const wxString& host,
|
|
|
|
const wxString& service,
|
|
|
|
const wxString& topic);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
The type of wxDDEConnection returned from a MakeConnection() call can
|
2008-04-20 19:50:56 -04:00
|
|
|
be altered by deriving the OnMakeConnection() member to return your own
|
|
|
|
derived connection object. By default, a wxDDEConnection object is
|
|
|
|
returned.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
The advantage of deriving your own connection class is that it will
|
2008-04-20 19:50:56 -04:00
|
|
|
enable you to intercept messages initiated by the server, such as
|
|
|
|
wxDDEConnection::OnAdvise(). You may also want to store
|
|
|
|
application-specific data in instances of the new class.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxConnectionBase* OnMakeConnection();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Returns @true if this is a valid host name, @false otherwise. This
|
|
|
|
always returns @true under MS Windows.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool ValidHost(const wxString& host);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxDDEServer
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
A wxDDEServer object represents the server part of a client-server DDE
|
|
|
|
(Dynamic Data Exchange) conversation.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
This DDE-based implementation is available on Windows only, but a
|
|
|
|
platform-independent, socket-based version of this API is available using
|
|
|
|
wxTCPServer.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
2008-04-20 19:50:56 -04:00
|
|
|
@category{ipc}
|
2008-11-15 06:37:43 -05:00
|
|
|
@onlyfor{wxmsw}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
@see wxDDEClient, wxDDEConnection, @ref overview_ipc
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
class wxDDEServer
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructs a server object.
|
|
|
|
*/
|
|
|
|
wxDDEServer();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Registers the server using the given service name. Under UNIX, the
|
|
|
|
string must contain an integer id which is used as an Internet port
|
2008-04-20 19:50:56 -04:00
|
|
|
number. @false is returned if the call failed (for example, if the port
|
2008-03-08 08:52:38 -05:00
|
|
|
number is already in use).
|
|
|
|
*/
|
|
|
|
bool Create(const wxString& service);
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
When a client calls wxDDEClient::MakeConnection(), the server receives
|
|
|
|
the message and this member is called. The application should derive a
|
2008-03-08 08:52:38 -05:00
|
|
|
member to intercept this message and return a connection object of
|
2008-04-20 19:50:56 -04:00
|
|
|
either the standard wxDDEConnection type, or of a user-derived type.
|
|
|
|
|
|
|
|
If the @a topic is "STDIO", the application may wish to refuse the
|
|
|
|
connection. Under UNIX, when a server is created the
|
|
|
|
OnAcceptConnection() message is always sent for standard input and
|
|
|
|
output, but in the context of DDE messages it doesn't make a lot of
|
|
|
|
sense.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
virtual wxConnectionBase* OnAcceptConnection(const wxString& topic);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
// ============================================================================
|
|
|
|
// Global functions/macros
|
|
|
|
// ============================================================================
|
|
|
|
|
2009-01-05 15:48:06 -05:00
|
|
|
/** @addtogroup group_funcmacro_misc */
|
2008-03-23 14:24:32 -04:00
|
|
|
//@{
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-03-23 14:24:32 -04:00
|
|
|
Called when wxWidgets exits, to clean up the DDE system. This no longer
|
|
|
|
needs to be called by the application.
|
|
|
|
|
|
|
|
@see wxDDEInitialize()
|
|
|
|
|
|
|
|
@header{wx/dde.h}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void wxDDECleanUp();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Initializes the DDE system. May be called multiple times without harm.
|
2008-03-23 14:24:32 -04:00
|
|
|
|
|
|
|
This no longer needs to be called by the application: it will be called by
|
|
|
|
wxWidgets if necessary.
|
|
|
|
|
|
|
|
@see wxDDEServer, wxDDEClient, wxDDEConnection, wxDDECleanUp()
|
|
|
|
|
|
|
|
@header{wx/dde.h}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void wxDDEInitialize();
|
|
|
|
|
2008-03-23 14:24:32 -04:00
|
|
|
//@}
|
|
|
|
|