]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/msw/dde.h
made strings used in wxIPC methods const as a temporary compilation fix (they will...
[wxWidgets.git] / include / wx / msw / dde.h
... / ...
CommitLineData
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
41class WXDLLIMPEXP_FWD_BASE wxDDEServer;
42class WXDLLIMPEXP_FWD_BASE wxDDEClient;
43
44class WXDLLIMPEXP_BASE wxDDEConnection: public wxConnectionBase
45{
46 DECLARE_DYNAMIC_CLASS(wxDDEConnection)
47public:
48 wxDDEConnection(wxChar *buffer, int size); // use external buffer
49 wxDDEConnection(); // use internal buffer
50 virtual ~wxDDEConnection(void);
51
52 // Calls that CLIENT can make
53 virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
54 // FIXME-UTF8: change Execute() to DoExecute() to avoid having to do this;
55 // don't use c_str() below after removing ANSI build
56 virtual bool Execute(const wxString& str)
57 { return Execute(str.c_str(), -1, wxIPC_TEXT); }
58 virtual wxChar *Request(const wxString& item, int *size = NULL, wxIPCFormat format = wxIPC_TEXT);
59 virtual bool Poke(const wxString& item, const 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, const 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 wxString m_topicName;
74 wxDDEServer* m_server;
75 wxDDEClient* m_client;
76
77 WXHCONV m_hConv;
78 const wxChar* m_sendingData;
79 int m_dataSize;
80 wxIPCFormat m_dataType;
81
82 DECLARE_NO_COPY_CLASS(wxDDEConnection)
83};
84
85class WXDLLIMPEXP_BASE wxDDEServer: public wxServerBase
86{
87 DECLARE_DYNAMIC_CLASS(wxDDEServer)
88 public:
89
90 wxDDEServer(void);
91 virtual ~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 wxDDEConnectionList& GetConnections(void) const
104 {
105 return (wxDDEConnectionList&) m_connections;
106 }
107
108protected:
109 int m_lastError;
110 wxString m_serviceName;
111 wxDDEConnectionList m_connections;
112};
113
114class WXDLLIMPEXP_BASE wxDDEClient: public wxClientBase
115{
116 DECLARE_DYNAMIC_CLASS(wxDDEClient)
117 public:
118 wxDDEClient(void);
119 virtual ~wxDDEClient(void);
120 bool ValidHost(const wxString& host);
121 virtual wxConnectionBase *MakeConnection(const wxString& host, const wxString& server, const wxString& topic);
122 // Call this to make a connection.
123 // Returns NULL if cannot.
124 virtual wxConnectionBase *OnMakeConnection(void); // Tailor this to return own connection.
125
126 ////////////////////////////////////////////////////////////
127 // Implementation
128
129 // Find/delete wxDDEConnection corresponding to the HCONV
130 wxDDEConnection *FindConnection(WXHCONV conv);
131 bool DeleteConnection(WXHCONV conv);
132
133 inline wxDDEConnectionList& GetConnections(void) const
134 {
135 return (wxDDEConnectionList&) m_connections;
136 }
137
138protected:
139 int m_lastError;
140 wxDDEConnectionList m_connections;
141};
142
143void WXDLLIMPEXP_BASE wxDDEInitialize();
144void WXDLLIMPEXP_BASE wxDDECleanUp();
145
146#endif
147 // _WX_DDE_H_