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_BASE wxDDEServer
;
42 class WXDLLIMPEXP_BASE wxDDEClient
;
44 class WXDLLIMPEXP_BASE wxDDEConnection
: public wxConnectionBase
46 DECLARE_DYNAMIC_CLASS(wxDDEConnection
)
48 wxDDEConnection(wxChar
*buffer
, int size
); // use external buffer
49 wxDDEConnection(); // use internal buffer
50 ~wxDDEConnection(void);
52 // Calls that CLIENT can make
53 virtual bool Execute(const wxChar
*data
, int size
= -1, wxIPCFormat format
= wxIPC_TEXT
);
54 virtual bool Execute(const wxString
& str
) { return Execute(str
, -1, wxIPC_TEXT
); }
55 virtual wxChar
*Request(const wxString
& item
, int *size
= NULL
, wxIPCFormat format
= wxIPC_TEXT
);
56 virtual bool Poke(const wxString
& item
, wxChar
*data
, int size
= -1, wxIPCFormat format
= wxIPC_TEXT
);
57 virtual bool StartAdvise(const wxString
& item
);
58 virtual bool StopAdvise(const wxString
& item
);
60 // Calls that SERVER can make
61 virtual bool Advise(const wxString
& item
, wxChar
*data
, int size
= -1, wxIPCFormat format
= wxIPC_TEXT
);
63 // Calls that both can make
64 virtual bool Disconnect(void);
66 // Default behaviour is to delete connection and return true
67 virtual bool OnDisconnect(void);
71 wxDDEServer
* m_server
;
72 wxDDEClient
* m_client
;
75 wxChar
* m_sendingData
;
77 wxIPCFormat m_dataType
;
79 DECLARE_NO_COPY_CLASS(wxDDEConnection
)
82 class WXDLLIMPEXP_BASE wxDDEServer
: public wxServerBase
84 DECLARE_DYNAMIC_CLASS(wxDDEServer
)
89 bool Create(const wxString
& server_name
); // Returns false if can't create server (e.g. port
90 // number is already in use)
91 virtual wxConnectionBase
*OnAcceptConnection(const wxString
& topic
);
93 ////////////////////////////////////////////////////////////
96 // Find/delete wxDDEConnection corresponding to the HCONV
97 wxDDEConnection
*FindConnection(WXHCONV conv
);
98 bool DeleteConnection(WXHCONV conv
);
99 inline wxString
& GetServiceName(void) const { return (wxString
&) m_serviceName
; }
100 inline wxDDEConnectionList
& GetConnections(void) const
102 return (wxDDEConnectionList
&) m_connections
;
107 wxString m_serviceName
;
108 wxDDEConnectionList m_connections
;
111 class WXDLLIMPEXP_BASE wxDDEClient
: public wxClientBase
113 DECLARE_DYNAMIC_CLASS(wxDDEClient
)
117 bool ValidHost(const wxString
& host
);
118 virtual wxConnectionBase
*MakeConnection(const wxString
& host
, const wxString
& server
, const wxString
& topic
);
119 // Call this to make a connection.
120 // Returns NULL if cannot.
121 virtual wxConnectionBase
*OnMakeConnection(void); // Tailor this to return own connection.
123 ////////////////////////////////////////////////////////////
126 // Find/delete wxDDEConnection corresponding to the HCONV
127 wxDDEConnection
*FindConnection(WXHCONV conv
);
128 bool DeleteConnection(WXHCONV conv
);
130 inline wxDDEConnectionList
& GetConnections(void) const
132 return (wxDDEConnectionList
&) m_connections
;
137 wxDDEConnectionList m_connections
;
140 void WXDLLIMPEXP_BASE
wxDDEInitialize();
141 void WXDLLIMPEXP_BASE
wxDDECleanUp();