]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/dde.h
Fixed OS/2 compilation problems.
[wxWidgets.git] / include / wx / msw / dde.h
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 #ifdef __GNUG__
16 #pragma interface "dde.h"
17 #endif
18
19 #include "wx/ipcbase.h"
20
21 /*
22 * Mini-DDE implementation
23
24 Most transactions involve a topic name and an item name (choose these
25 as befits your application).
26
27 A client can:
28
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
34
35 A server can:
36
37 - respond to execute, request, poke and advice start/stop
38 - send advise data to client
39
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.
42 *
43 */
44
45 class WXDLLEXPORT wxDDEServer;
46 class WXDLLEXPORT wxDDEClient;
47
48 class WXDLLEXPORT wxDDEConnection: public wxConnectionBase
49 {
50 DECLARE_DYNAMIC_CLASS(wxDDEConnection)
51 public:
52 wxDDEConnection(char *buffer, int size);
53 wxDDEConnection(void);
54 ~wxDDEConnection(void);
55
56 // Calls that CLIENT can make
57 virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
58 virtual char *Request(const wxString& item, int *size = NULL, wxIPCFormat format = wxIPC_TEXT);
59 virtual bool Poke(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
60 virtual bool StartAdvise(const wxString& item);
61 virtual bool StopAdvise(const wxString& item);
62
63 // Calls that SERVER can make
64 virtual bool Advise(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
65
66 // Calls that both can make
67 virtual bool Disconnect(void);
68
69 // Default behaviour is to delete connection and return TRUE
70 virtual bool OnDisconnect(void);
71
72 public:
73 char* m_bufPtr;
74 wxString m_topicName;
75 int m_bufSize;
76 wxDDEServer* m_server;
77 wxDDEClient* m_client;
78
79 WXHCONV m_hConv;
80 wxChar* m_sendingData;
81 int m_dataSize;
82 wxIPCFormat m_dataType;
83 };
84
85 class WXDLLEXPORT wxDDEServer: public wxServerBase
86 {
87 DECLARE_DYNAMIC_CLASS(wxDDEServer)
88 public:
89
90 wxDDEServer(void);
91 ~wxDDEServer(void);
92 bool Create(const wxString& server_name); // Returns FALSE if can't create server (e.g. port
93 // number is already in use)
94 virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
95
96 ////////////////////////////////////////////////////////////
97 // Implementation
98
99 // Find/delete wxDDEConnection corresponding to the HCONV
100 wxDDEConnection *FindConnection(WXHCONV conv);
101 bool DeleteConnection(WXHCONV conv);
102 inline wxString& GetServiceName(void) const { return (wxString&) m_serviceName; }
103 inline wxList& GetConnections(void) const { return (wxList&) m_connections; }
104
105 protected:
106 int m_lastError;
107 wxString m_serviceName;
108 wxList m_connections;
109 };
110
111 class WXDLLEXPORT wxDDEClient: public wxClientBase
112 {
113 DECLARE_DYNAMIC_CLASS(wxDDEClient)
114 public:
115 wxDDEClient(void);
116 ~wxDDEClient(void);
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.
122
123 ////////////////////////////////////////////////////////////
124 // Implementation
125
126 // Find/delete wxDDEConnection corresponding to the HCONV
127 wxDDEConnection *FindConnection(WXHCONV conv);
128 bool DeleteConnection(WXHCONV conv);
129 inline wxList& GetConnections(void) const { return (wxList&) m_connections; }
130
131 protected:
132 int m_lastError;
133 wxList m_connections;
134 };
135
136 void WXDLLEXPORT wxDDEInitialize();
137 void WXDLLEXPORT wxDDECleanUp();
138
139 #endif
140 // _WX_DDE_H_