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