1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
14 #include "wx/ipcbase.h"
17 * Mini-DDE implementation
19 Most transactions involve a topic name and an item name (choose these
20 as befits your application).
24 - ask the server to execute commands (data) associated with a topic
25 - request data from server by topic and item
26 - poke data into the server
27 - ask the server to start an advice loop on topic/item
28 - ask the server to stop an advice loop
32 - respond to execute, request, poke and advice start/stop
33 - send advise data to client
35 Note that this limits the server in the ways it can send data to the
36 client, i.e. it can't send unsolicited information.
40 class WXDLLIMPEXP_FWD_BASE wxDDEServer
;
41 class WXDLLIMPEXP_FWD_BASE wxDDEClient
;
43 class WXDLLIMPEXP_BASE wxDDEConnection
: public wxConnectionBase
46 wxDDEConnection(void *buffer
, size_t size
); // use external buffer
47 wxDDEConnection(); // use internal buffer
48 virtual ~wxDDEConnection();
50 // implement base class pure virtual methods
51 virtual const void *Request(const wxString
& item
,
53 wxIPCFormat format
= wxIPC_TEXT
);
54 virtual bool StartAdvise(const wxString
& item
);
55 virtual bool StopAdvise(const wxString
& item
);
56 virtual bool Disconnect();
59 virtual bool DoExecute(const void *data
, size_t size
, wxIPCFormat format
);
60 virtual bool DoPoke(const wxString
& item
, const void *data
, size_t size
,
62 virtual bool DoAdvise(const wxString
& item
, const void *data
, size_t size
,
67 wxDDEServer
* m_server
;
68 wxDDEClient
* m_client
;
71 const void* m_sendingData
;
73 wxIPCFormat m_dataType
;
75 wxDECLARE_NO_COPY_CLASS(wxDDEConnection
);
76 DECLARE_DYNAMIC_CLASS(wxDDEConnection
)
79 class WXDLLIMPEXP_BASE wxDDEServer
: public wxServerBase
83 bool Create(const wxString
& server_name
);
84 virtual ~wxDDEServer();
86 virtual wxConnectionBase
*OnAcceptConnection(const wxString
& topic
);
88 // Find/delete wxDDEConnection corresponding to the HCONV
89 wxDDEConnection
*FindConnection(WXHCONV conv
);
90 bool DeleteConnection(WXHCONV conv
);
91 wxString
& GetServiceName() const { return (wxString
&) m_serviceName
; }
93 wxDDEConnectionList
& GetConnections() const
94 { return (wxDDEConnectionList
&) m_connections
; }
98 wxString m_serviceName
;
99 wxDDEConnectionList m_connections
;
101 DECLARE_DYNAMIC_CLASS(wxDDEServer
)
104 class WXDLLIMPEXP_BASE wxDDEClient
: public wxClientBase
108 virtual ~wxDDEClient();
110 bool ValidHost(const wxString
& host
);
112 // Call this to make a connection. Returns NULL if cannot.
113 virtual wxConnectionBase
*MakeConnection(const wxString
& host
,
114 const wxString
& server
,
115 const wxString
& topic
);
117 // Tailor this to return own connection.
118 virtual wxConnectionBase
*OnMakeConnection();
120 // Find/delete wxDDEConnection corresponding to the HCONV
121 wxDDEConnection
*FindConnection(WXHCONV conv
);
122 bool DeleteConnection(WXHCONV conv
);
124 wxDDEConnectionList
& GetConnections() const
125 { return (wxDDEConnectionList
&) m_connections
; }
129 wxDDEConnectionList m_connections
;
131 DECLARE_DYNAMIC_CLASS(wxDDEClient
)
134 void WXDLLIMPEXP_BASE
wxDDEInitialize();
135 void WXDLLIMPEXP_BASE
wxDDECleanUp();