1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
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 WXDLLEXPORT wxDDEServer
;
46 class WXDLLEXPORT wxDDEClient
;
48 class WXDLLEXPORT wxDDEConnection
: public wxConnectionBase
50 DECLARE_DYNAMIC_CLASS(wxDDEConnection
)
63 wxDDEConnection(char *buffer
, int size
);
64 wxDDEConnection(void);
65 ~wxDDEConnection(void);
67 // Calls that CLIENT can make
68 virtual bool Execute(char *data
, int size
= -1, int format
= wxCF_TEXT
);
69 virtual bool Execute(const wxString
& str
) { return Execute((char *)(const char *)str
, -1, wxCF_TEXT
); }
70 virtual char *Request(const wxString
& item
, int *size
= NULL
, int format
= wxCF_TEXT
);
71 virtual bool Poke(const wxString
& item
, char *data
, int size
= -1, int format
= wxCF_TEXT
);
72 virtual bool StartAdvise(const wxString
& item
);
73 virtual bool StopAdvise(const wxString
& item
);
75 // Calls that SERVER can make
76 virtual bool Advise(const wxString
& item
, char *data
, int size
= -1, int format
= wxCF_TEXT
);
78 // Calls that both can make
79 virtual bool Disconnect(void);
81 // Callbacks to SERVER - override at will
82 virtual bool OnExecute(const wxString
& topic
, char *data
, int size
, int format
) { return FALSE
; };
83 virtual char *OnRequest(const wxString
& topic
, const wxString
& item
, int *size
, int format
) { return NULL
; };
84 virtual bool OnPoke(const wxString
& topic
, const wxString
& item
, char *data
, int size
, int format
) { return FALSE
; };
85 virtual bool OnStartAdvise(const wxString
& topic
, const wxString
& item
) { return FALSE
; };
86 virtual bool OnStopAdvise(const wxString
& topic
, const wxString
& item
) { return FALSE
; };
88 // Callbacks to CLIENT - override at will
89 virtual bool OnAdvise(const wxString
& topic
, const wxString
& item
, char *data
, int size
, int format
) { return FALSE
; };
93 // Default behaviour is to delete connection and return TRUE
94 virtual bool OnDisconnect(void);
97 class WXDLLEXPORT wxDDEServer
: public wxServerBase
99 DECLARE_DYNAMIC_CLASS(wxDDEServer
)
104 bool Create(const wxString
& server_name
); // Returns FALSE if can't create server (e.g. port
105 // number is already in use)
106 virtual wxConnectionBase
*OnAcceptConnection(const wxString
& topic
);
108 ////////////////////////////////////////////////////////////
111 // Find/delete wxDDEConnection corresponding to the HCONV
112 wxDDEConnection
*FindConnection(WXHCONV conv
);
113 bool DeleteConnection(WXHCONV conv
);
114 inline wxString
& GetServiceName(void) const { return (wxString
&) service_name
; }
115 inline wxList
& GetConnections(void) const { return (wxList
&) connections
; }
119 wxString service_name
;
123 class WXDLLEXPORT wxDDEClient
: public wxClientBase
125 DECLARE_DYNAMIC_CLASS(wxDDEClient
)
129 bool ValidHost(const wxString
& host
);
130 virtual wxConnectionBase
*MakeConnection(const wxString
& host
, const wxString
& server
, const wxString
& topic
);
131 // Call this to make a connection.
132 // Returns NULL if cannot.
133 virtual wxConnectionBase
*OnMakeConnection(void); // Tailor this to return own connection.
135 ////////////////////////////////////////////////////////////
138 // Find/delete wxDDEConnection corresponding to the HCONV
139 wxDDEConnection
*FindConnection(WXHCONV conv
);
140 bool DeleteConnection(WXHCONV conv
);
141 inline wxList
& GetConnections(void) const { return (wxList
&) connections
; }
148 void WXDLLEXPORT
wxDDEInitialize();
149 void WXDLLEXPORT
wxDDECleanUp();
152 #if WXWIN_COMPATIBILITY
153 #define wxServer wxDDEServer
154 #define wxClient wxDDEClient
155 #define wxConnection wxDDEConnection
156 #define wxIPCInitialize wxDDEInitialize
157 #define wxIPCCleanUp wxDDECleanUp