1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #include "wx/ipcbase.h"
18 * Mini-DDE implementation
20 Most transactions involve a topic name and an item name (choose these
21 as befits your application).
25 - ask the server to execute commands (data) associated with a topic
26 - request data from server by topic and item
27 - poke data into the server
28 - ask the server to start an advice loop on topic/item
29 - ask the server to stop an advice loop
33 - respond to execute, request, poke and advice start/stop
34 - send advise data to client
36 Note that this limits the server in the ways it can send data to the
37 client, i.e. it can't send unsolicited information.
41 class WXDLLIMPEXP_FWD_BASE wxDDEServer
;
42 class WXDLLIMPEXP_FWD_BASE wxDDEClient
;
44 class WXDLLIMPEXP_BASE wxDDEConnection
: public wxConnectionBase
47 wxDDEConnection(void *buffer
, size_t size
); // use external buffer
48 wxDDEConnection(); // use internal buffer
49 virtual ~wxDDEConnection();
51 // implement base class pure virtual methods
52 virtual const void *Request(const wxString
& item
,
54 wxIPCFormat format
= wxIPC_TEXT
);
55 virtual bool StartAdvise(const wxString
& item
);
56 virtual bool StopAdvise(const wxString
& item
);
57 virtual bool Disconnect();
60 virtual bool DoExecute(const void *data
, size_t size
, wxIPCFormat format
);
61 virtual bool DoPoke(const wxString
& item
, const void *data
, size_t size
,
63 virtual bool DoAdvise(const wxString
& item
, const void *data
, size_t size
,
68 wxDDEServer
* m_server
;
69 wxDDEClient
* m_client
;
72 const void* m_sendingData
;
74 wxIPCFormat m_dataType
;
76 DECLARE_NO_COPY_CLASS(wxDDEConnection
)
77 DECLARE_DYNAMIC_CLASS(wxDDEConnection
)
80 class WXDLLIMPEXP_BASE wxDDEServer
: public wxServerBase
84 bool Create(const wxString
& server_name
);
85 virtual ~wxDDEServer();
87 virtual wxConnectionBase
*OnAcceptConnection(const wxString
& topic
);
89 // Find/delete wxDDEConnection corresponding to the HCONV
90 wxDDEConnection
*FindConnection(WXHCONV conv
);
91 bool DeleteConnection(WXHCONV conv
);
92 wxString
& GetServiceName() const { return (wxString
&) m_serviceName
; }
94 wxDDEConnectionList
& GetConnections() const
95 { return (wxDDEConnectionList
&) m_connections
; }
99 wxString m_serviceName
;
100 wxDDEConnectionList m_connections
;
102 DECLARE_DYNAMIC_CLASS(wxDDEServer
)
105 class WXDLLIMPEXP_BASE wxDDEClient
: public wxClientBase
109 virtual ~wxDDEClient();
111 bool ValidHost(const wxString
& host
);
113 // Call this to make a connection. Returns NULL if cannot.
114 virtual wxConnectionBase
*MakeConnection(const wxString
& host
,
115 const wxString
& server
,
116 const wxString
& topic
);
118 // Tailor this to return own connection.
119 virtual wxConnectionBase
*OnMakeConnection();
121 // Find/delete wxDDEConnection corresponding to the HCONV
122 wxDDEConnection
*FindConnection(WXHCONV conv
);
123 bool DeleteConnection(WXHCONV conv
);
125 wxDDEConnectionList
& GetConnections() const
126 { return (wxDDEConnectionList
&) m_connections
; }
130 wxDDEConnectionList m_connections
;
132 DECLARE_DYNAMIC_CLASS(wxDDEClient
)
135 void WXDLLIMPEXP_BASE
wxDDEInitialize();
136 void WXDLLIMPEXP_BASE
wxDDECleanUp();