]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/dde.h
binary insertion
[wxWidgets.git] / include / wx / msw / dde.h
CommitLineData
2bda0e17
KB
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$
bbcdf8bc
JS
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_DDE_H_
13#define _WX_DDE_H_
2bda0e17
KB
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
45class WXDLLEXPORT wxDDEServer;
46class WXDLLEXPORT wxDDEClient;
47
48class WXDLLEXPORT wxDDEConnection: public wxConnectionBase
49{
50 DECLARE_DYNAMIC_CLASS(wxDDEConnection)
b3324be2 51public:
2bda0e17
KB
52 wxDDEConnection(char *buffer, int size);
53 wxDDEConnection(void);
54 ~wxDDEConnection(void);
55
56 // Calls that CLIENT can make
0d2a2b60
RR
57 virtual bool Execute(char *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
58 virtual bool Execute(const wxString& str) { return Execute((char *)(const char *)str, -1, wxIPC_TEXT); }
59 virtual char *Request(const wxString& item, int *size = NULL, wxIPCFormat format = wxIPC_TEXT);
60 virtual bool Poke(const wxString& item, char *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
2bda0e17
KB
61 virtual bool StartAdvise(const wxString& item);
62 virtual bool StopAdvise(const wxString& item);
63
64 // Calls that SERVER can make
0d2a2b60 65 virtual bool Advise(const wxString& item, char *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
2bda0e17
KB
66
67 // Calls that both can make
68 virtual bool Disconnect(void);
69
70 // Callbacks to SERVER - override at will
0d2a2b60
RR
71 virtual bool OnExecute(const wxString& topic, char *data, int size, wxIPCFormat format) { return FALSE; };
72 virtual char *OnRequest(const wxString& topic, const wxString& item, int *size, wxIPCFormat format) { return NULL; };
73 virtual bool OnPoke(const wxString& topic, const wxString& item, char *data, int size, wxIPCFormat format) { return FALSE; };
2bda0e17
KB
74 virtual bool OnStartAdvise(const wxString& topic, const wxString& item) { return FALSE; };
75 virtual bool OnStopAdvise(const wxString& topic, const wxString& item) { return FALSE; };
76
77 // Callbacks to CLIENT - override at will
0d2a2b60 78 virtual bool OnAdvise(const wxString& topic, const wxString& item, char *data, int size, wxIPCFormat format) { return FALSE; };
2bda0e17
KB
79
80 // Callbacks to BOTH
81
82 // Default behaviour is to delete connection and return TRUE
83 virtual bool OnDisconnect(void);
b3324be2
JS
84
85 public:
86 char* m_bufPtr;
87 wxString m_topicName;
88 int m_bufSize;
89 wxDDEServer* m_server;
90 wxDDEClient* m_client;
91
92 WXHCONV m_hConv;
93 char* m_sendingData;
94 int m_dataSize;
0d2a2b60 95 wxIPCFormat m_dataType;
2bda0e17
KB
96};
97
98class WXDLLEXPORT wxDDEServer: public wxServerBase
99{
100 DECLARE_DYNAMIC_CLASS(wxDDEServer)
101 public:
102
103 wxDDEServer(void);
104 ~wxDDEServer(void);
105 bool Create(const wxString& server_name); // Returns FALSE if can't create server (e.g. port
106 // number is already in use)
107 virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
108
109 ////////////////////////////////////////////////////////////
110 // Implementation
111
112 // Find/delete wxDDEConnection corresponding to the HCONV
113 wxDDEConnection *FindConnection(WXHCONV conv);
114 bool DeleteConnection(WXHCONV conv);
b3324be2
JS
115 inline wxString& GetServiceName(void) const { return (wxString&) m_serviceName; }
116 inline wxList& GetConnections(void) const { return (wxList&) m_connections; }
2bda0e17
KB
117
118 protected:
b3324be2
JS
119 int m_lastError;
120 wxString m_serviceName;
121 wxList m_connections;
2bda0e17
KB
122};
123
124class WXDLLEXPORT wxDDEClient: public wxClientBase
125{
126 DECLARE_DYNAMIC_CLASS(wxDDEClient)
127 public:
128 wxDDEClient(void);
129 ~wxDDEClient(void);
130 bool ValidHost(const wxString& host);
131 virtual wxConnectionBase *MakeConnection(const wxString& host, const wxString& server, const wxString& topic);
132 // Call this to make a connection.
133 // Returns NULL if cannot.
134 virtual wxConnectionBase *OnMakeConnection(void); // Tailor this to return own connection.
135
136 ////////////////////////////////////////////////////////////
137 // Implementation
138
139 // Find/delete wxDDEConnection corresponding to the HCONV
140 wxDDEConnection *FindConnection(WXHCONV conv);
141 bool DeleteConnection(WXHCONV conv);
b3324be2 142 inline wxList& GetConnections(void) const { return (wxList&) m_connections; }
2bda0e17
KB
143
144 protected:
b3324be2
JS
145 int m_lastError;
146 wxList m_connections;
2bda0e17
KB
147};
148
149void WXDLLEXPORT wxDDEInitialize();
150void WXDLLEXPORT wxDDECleanUp();
151
152// Compatibility
153#if WXWIN_COMPATIBILITY
154#define wxServer wxDDEServer
155#define wxClient wxDDEClient
156#define wxConnection wxDDEConnection
157#define wxIPCInitialize wxDDEInitialize
158#define wxIPCCleanUp wxDDECleanUp
159#endif
160
161#endif
bbcdf8bc 162 // _WX_DDE_H_