]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: wx/msw/dde.h |
2bda0e17 KB |
3 | // Purpose: DDE class |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
bbcdf8bc | 7 | // Copyright: (c) Julian Smart |
65571936 | 8 | // Licence: wxWindows licence |
2bda0e17 KB |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
bbcdf8bc JS |
11 | #ifndef _WX_DDE_H_ |
12 | #define _WX_DDE_H_ | |
2bda0e17 | 13 | |
2bda0e17 KB |
14 | #include "wx/ipcbase.h" |
15 | ||
16 | /* | |
17 | * Mini-DDE implementation | |
18 | ||
19 | Most transactions involve a topic name and an item name (choose these | |
20 | as befits your application). | |
21 | ||
22 | A client can: | |
23 | ||
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 | |
29 | ||
30 | A server can: | |
31 | ||
32 | - respond to execute, request, poke and advice start/stop | |
33 | - send advise data to client | |
34 | ||
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. | |
37 | * | |
38 | */ | |
39 | ||
b5dbe15d VS |
40 | class WXDLLIMPEXP_FWD_BASE wxDDEServer; |
41 | class WXDLLIMPEXP_FWD_BASE wxDDEClient; | |
2bda0e17 | 42 | |
50c549b9 | 43 | class WXDLLIMPEXP_BASE wxDDEConnection : public wxConnectionBase |
2bda0e17 | 44 | { |
b3324be2 | 45 | public: |
50c549b9 | 46 | wxDDEConnection(void *buffer, size_t size); // use external buffer |
b814b812 | 47 | wxDDEConnection(); // use internal buffer |
50c549b9 VZ |
48 | virtual ~wxDDEConnection(); |
49 | ||
50 | // implement base class pure virtual methods | |
51 | virtual const void *Request(const wxString& item, | |
52 | size_t *size = NULL, | |
53 | wxIPCFormat format = wxIPC_TEXT); | |
2bda0e17 KB |
54 | virtual bool StartAdvise(const wxString& item); |
55 | virtual bool StopAdvise(const wxString& item); | |
50c549b9 | 56 | virtual bool Disconnect(); |
2bda0e17 | 57 | |
50c549b9 VZ |
58 | protected: |
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, | |
61 | wxIPCFormat format); | |
62 | virtual bool DoAdvise(const wxString& item, const void *data, size_t size, | |
63 | wxIPCFormat format); | |
b3324be2 | 64 | |
50c549b9 | 65 | public: |
b3324be2 | 66 | wxString m_topicName; |
b3324be2 JS |
67 | wxDDEServer* m_server; |
68 | wxDDEClient* m_client; | |
69 | ||
70 | WXHCONV m_hConv; | |
50c549b9 | 71 | const void* m_sendingData; |
b3324be2 | 72 | int m_dataSize; |
1e0f0a90 | 73 | wxIPCFormat m_dataType; |
22f3361e | 74 | |
c0c133e1 | 75 | wxDECLARE_NO_COPY_CLASS(wxDDEConnection); |
50c549b9 | 76 | DECLARE_DYNAMIC_CLASS(wxDDEConnection) |
2bda0e17 KB |
77 | }; |
78 | ||
50c549b9 | 79 | class WXDLLIMPEXP_BASE wxDDEServer : public wxServerBase |
2bda0e17 | 80 | { |
50c549b9 VZ |
81 | public: |
82 | wxDDEServer(); | |
83 | bool Create(const wxString& server_name); | |
84 | virtual ~wxDDEServer(); | |
85 | ||
86 | virtual wxConnectionBase *OnAcceptConnection(const wxString& topic); | |
87 | ||
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; } | |
92 | ||
93 | wxDDEConnectionList& GetConnections() const | |
94 | { return (wxDDEConnectionList&) m_connections; } | |
d162a7ee VZ |
95 | |
96 | protected: | |
97 | int m_lastError; | |
98 | wxString m_serviceName; | |
99 | wxDDEConnectionList m_connections; | |
50c549b9 VZ |
100 | |
101 | DECLARE_DYNAMIC_CLASS(wxDDEServer) | |
2bda0e17 KB |
102 | }; |
103 | ||
bddd7a8d | 104 | class WXDLLIMPEXP_BASE wxDDEClient: public wxClientBase |
2bda0e17 | 105 | { |
50c549b9 VZ |
106 | public: |
107 | wxDDEClient(); | |
108 | virtual ~wxDDEClient(); | |
109 | ||
110 | bool ValidHost(const wxString& host); | |
111 | ||
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); | |
116 | ||
117 | // Tailor this to return own connection. | |
118 | virtual wxConnectionBase *OnMakeConnection(); | |
119 | ||
120 | // Find/delete wxDDEConnection corresponding to the HCONV | |
121 | wxDDEConnection *FindConnection(WXHCONV conv); | |
122 | bool DeleteConnection(WXHCONV conv); | |
123 | ||
124 | wxDDEConnectionList& GetConnections() const | |
125 | { return (wxDDEConnectionList&) m_connections; } | |
d162a7ee VZ |
126 | |
127 | protected: | |
128 | int m_lastError; | |
129 | wxDDEConnectionList m_connections; | |
50c549b9 VZ |
130 | |
131 | DECLARE_DYNAMIC_CLASS(wxDDEClient) | |
2bda0e17 KB |
132 | }; |
133 | ||
bddd7a8d VZ |
134 | void WXDLLIMPEXP_BASE wxDDEInitialize(); |
135 | void WXDLLIMPEXP_BASE wxDDECleanUp(); | |
2bda0e17 | 136 | |
50c549b9 | 137 | #endif // _WX_DDE_H_ |