1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "dde.h"
19 #include "wx/ipcbase.h"
22 * Mini-DDE implementation
24 Most transactions involve a topic name and an item name (choose these
25 as befits your application).
29 - ask the server to execute commands (data) associated with a topic
30 - request data from server by topic and item
31 - poke data into the server
32 - ask the server to start an advice loop on topic/item
33 - ask the server to stop an advice loop
37 - respond to execute, request, poke and advice start/stop
38 - send advise data to client
40 Note that this limits the server in the ways it can send data to the
41 client, i.e. it can't send unsolicited information.
45 class WXDLLIMPEXP_BASE wxDDEServer
;
46 class WXDLLIMPEXP_BASE wxDDEClient
;
48 class WXDLLIMPEXP_BASE wxDDEConnection
: public wxConnectionBase
50 DECLARE_DYNAMIC_CLASS(wxDDEConnection
)
52 wxDDEConnection(wxChar
*buffer
, int size
); // use external buffer
53 wxDDEConnection(); // use internal buffer
54 ~wxDDEConnection(void);
56 // Calls that CLIENT can make
57 virtual bool Execute(const wxChar
*data
, int size
= -1, wxIPCFormat format
= wxIPC_TEXT
);
58 virtual bool Execute(const wxString
& str
) { return Execute(str
, -1, wxIPC_TEXT
); }
59 virtual wxChar
*Request(const wxString
& item
, int *size
= NULL
, wxIPCFormat format
= wxIPC_TEXT
);
60 virtual bool Poke(const wxString
& item
, wxChar
*data
, int size
= -1, wxIPCFormat format
= wxIPC_TEXT
);
61 virtual bool StartAdvise(const wxString
& item
);
62 virtual bool StopAdvise(const wxString
& item
);
64 // Calls that SERVER can make
65 virtual bool Advise(const wxString
& item
, wxChar
*data
, int size
= -1, wxIPCFormat format
= wxIPC_TEXT
);
67 // Calls that both can make
68 virtual bool Disconnect(void);
70 // Default behaviour is to delete connection and return TRUE
71 virtual bool OnDisconnect(void);
75 wxDDEServer
* m_server
;
76 wxDDEClient
* m_client
;
79 wxChar
* m_sendingData
;
81 wxIPCFormat m_dataType
;
83 DECLARE_NO_COPY_CLASS(wxDDEConnection
)
86 class WXDLLIMPEXP_BASE wxDDEServer
: public wxServerBase
88 DECLARE_DYNAMIC_CLASS(wxDDEServer
)
93 bool Create(const wxString
& server_name
); // Returns FALSE if can't create server (e.g. port
94 // number is already in use)
95 virtual wxConnectionBase
*OnAcceptConnection(const wxString
& topic
);
97 ////////////////////////////////////////////////////////////
100 // Find/delete wxDDEConnection corresponding to the HCONV
101 wxDDEConnection
*FindConnection(WXHCONV conv
);
102 bool DeleteConnection(WXHCONV conv
);
103 inline wxString
& GetServiceName(void) const { return (wxString
&) m_serviceName
; }
104 inline wxDDEConnectionList
& GetConnections(void) const
106 return (wxDDEConnectionList
&) m_connections
;
111 wxString m_serviceName
;
112 wxDDEConnectionList m_connections
;
115 class WXDLLIMPEXP_BASE wxDDEClient
: public wxClientBase
117 DECLARE_DYNAMIC_CLASS(wxDDEClient
)
121 bool ValidHost(const wxString
& host
);
122 virtual wxConnectionBase
*MakeConnection(const wxString
& host
, const wxString
& server
, const wxString
& topic
);
123 // Call this to make a connection.
124 // Returns NULL if cannot.
125 virtual wxConnectionBase
*OnMakeConnection(void); // Tailor this to return own connection.
127 ////////////////////////////////////////////////////////////
130 // Find/delete wxDDEConnection corresponding to the HCONV
131 wxDDEConnection
*FindConnection(WXHCONV conv
);
132 bool DeleteConnection(WXHCONV conv
);
134 inline wxDDEConnectionList
& GetConnections(void) const
136 return (wxDDEConnectionList
&) m_connections
;
141 wxDDEConnectionList m_connections
;
144 void WXDLLIMPEXP_BASE
wxDDEInitialize();
145 void WXDLLIMPEXP_BASE
wxDDECleanUp();