]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/dde.h
added some wxMSW stuff
[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 and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __DDEH__
13 #define __DDEH__
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 char *buf_ptr;
53 wxString topic_name;
54 int buf_size;
55 wxDDEServer *server;
56 wxDDEClient *client;
57
58 WXHCONV hConv;
59 char *sending_data;
60 int data_size;
61 int data_type;
62
63 wxDDEConnection(char *buffer, int size);
64 wxDDEConnection(void);
65 ~wxDDEConnection(void);
66
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);
74
75 // Calls that SERVER can make
76 virtual bool Advise(const wxString& item, char *data, int size = -1, int format = wxCF_TEXT);
77
78 // Calls that both can make
79 virtual bool Disconnect(void);
80
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; };
87
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; };
90
91 // Callbacks to BOTH
92
93 // Default behaviour is to delete connection and return TRUE
94 virtual bool OnDisconnect(void);
95 };
96
97 class WXDLLEXPORT wxDDEServer: public wxServerBase
98 {
99 DECLARE_DYNAMIC_CLASS(wxDDEServer)
100 public:
101
102 wxDDEServer(void);
103 ~wxDDEServer(void);
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);
107
108 ////////////////////////////////////////////////////////////
109 // Implementation
110
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; }
116
117 protected:
118 int lastError;
119 wxString service_name;
120 wxList connections;
121 };
122
123 class WXDLLEXPORT wxDDEClient: public wxClientBase
124 {
125 DECLARE_DYNAMIC_CLASS(wxDDEClient)
126 public:
127 wxDDEClient(void);
128 ~wxDDEClient(void);
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.
134
135 ////////////////////////////////////////////////////////////
136 // Implementation
137
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; }
142
143 protected:
144 int lastError;
145 wxList connections;
146 };
147
148 void WXDLLEXPORT wxDDEInitialize();
149 void WXDLLEXPORT wxDDECleanUp();
150
151 // Compatibility
152 #if WXWIN_COMPATIBILITY
153 #define wxServer wxDDEServer
154 #define wxClient wxDDEClient
155 #define wxConnection wxDDEConnection
156 #define wxIPCInitialize wxDDEInitialize
157 #define wxIPCCleanUp wxDDECleanUp
158 #endif
159
160 #endif
161 // __DDEH__