]> git.saurik.com Git - wxWidgets.git/blob - include/wx/sckipc.h
Fix compilation of wxIconBundle in some particular minimal builds.
[wxWidgets.git] / include / wx / sckipc.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: sckipc.h
3 // Purpose: Interprocess communication implementation (wxSocket version)
4 // Author: Julian Smart
5 // Modified by: Guilhem Lavaux (big rewrite) May 1997, 1998
6 // Guillermo Rodriguez (updated for wxSocket v2) Jan 2000
7 // (callbacks deprecated) Mar 2000
8 // Created: 1993
9 // RCS-ID: $Id$
10 // Copyright: (c) Julian Smart 1993
11 // (c) Guilhem Lavaux 1997, 1998
12 // (c) 2000 Guillermo Rodriguez <guille@iies.es>
13 // Licence: wxWindows licence
14 /////////////////////////////////////////////////////////////////////////////
15
16 #ifndef _WX_SCKIPC_H
17 #define _WX_SCKIPC_H
18
19 #include "wx/defs.h"
20
21 #if wxUSE_SOCKETS && wxUSE_IPC
22
23 #include "wx/ipcbase.h"
24 #include "wx/socket.h"
25 #include "wx/sckstrm.h"
26 #include "wx/datstrm.h"
27
28 /*
29 * Mini-DDE implementation
30
31 Most transactions involve a topic name and an item name (choose these
32 as befits your application).
33
34 A client can:
35
36 - ask the server to execute commands (data) associated with a topic
37 - request data from server by topic and item
38 - poke data into the server
39 - ask the server to start an advice loop on topic/item
40 - ask the server to stop an advice loop
41
42 A server can:
43
44 - respond to execute, request, poke and advice start/stop
45 - send advise data to client
46
47 Note that this limits the server in the ways it can send data to the
48 client, i.e. it can't send unsolicited information.
49 *
50 */
51
52 class WXDLLIMPEXP_FWD_NET wxTCPServer;
53 class WXDLLIMPEXP_FWD_NET wxTCPClient;
54
55 class wxIPCSocketStreams;
56
57 class WXDLLIMPEXP_NET wxTCPConnection : public wxConnectionBase
58 {
59 public:
60 wxTCPConnection() { Init(); }
61 wxTCPConnection(void *buffer, size_t size)
62 : wxConnectionBase(buffer, size)
63 {
64 Init();
65 }
66
67 virtual ~wxTCPConnection();
68
69 // implement base class pure virtual methods
70 virtual const void *Request(const wxString& item,
71 size_t *size = NULL,
72 wxIPCFormat format = wxIPC_TEXT);
73 virtual bool StartAdvise(const wxString& item);
74 virtual bool StopAdvise(const wxString& item);
75 virtual bool Disconnect(void);
76
77 // Will be used in the future to enable the compression but does nothing
78 // for now.
79 void Compress(bool on);
80
81
82 protected:
83 virtual bool DoExecute(const void *data, size_t size, wxIPCFormat format);
84 virtual bool DoPoke(const wxString& item, const void *data, size_t size,
85 wxIPCFormat format);
86 virtual bool DoAdvise(const wxString& item, const void *data, size_t size,
87 wxIPCFormat format);
88
89
90 // notice that all the members below are only initialized once the
91 // connection is made, i.e. in MakeConnection() for the client objects and
92 // after OnAcceptConnection() in the server ones
93
94 // the underlying socket (wxSocketClient for IPC client and wxSocketServer
95 // for IPC server)
96 wxSocketBase *m_sock;
97
98 // various streams that we use
99 wxIPCSocketStreams *m_streams;
100
101 // the topic of this connection
102 wxString m_topic;
103
104 private:
105 // common part of both ctors
106 void Init();
107
108 friend class wxTCPServer;
109 friend class wxTCPClient;
110 friend class wxTCPEventHandler;
111
112 wxDECLARE_NO_COPY_CLASS(wxTCPConnection);
113 DECLARE_DYNAMIC_CLASS(wxTCPConnection)
114 };
115
116 class WXDLLIMPEXP_NET wxTCPServer : public wxServerBase
117 {
118 public:
119 wxTCPServer();
120 virtual ~wxTCPServer();
121
122 // Returns false on error (e.g. port number is already in use)
123 virtual bool Create(const wxString& serverName);
124
125 virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
126
127 protected:
128 wxSocketServer *m_server;
129
130 #ifdef __UNIX_LIKE__
131 // the name of the file associated to the Unix domain socket, may be empty
132 wxString m_filename;
133 #endif // __UNIX_LIKE__
134
135 wxDECLARE_NO_COPY_CLASS(wxTCPServer);
136 DECLARE_DYNAMIC_CLASS(wxTCPServer)
137 };
138
139 class WXDLLIMPEXP_NET wxTCPClient : public wxClientBase
140 {
141 public:
142 wxTCPClient();
143
144 virtual bool ValidHost(const wxString& host);
145
146 // Call this to make a connection. Returns NULL if cannot.
147 virtual wxConnectionBase *MakeConnection(const wxString& host,
148 const wxString& server,
149 const wxString& topic);
150
151 // Callbacks to CLIENT - override at will
152 virtual wxConnectionBase *OnMakeConnection();
153
154 private:
155 DECLARE_DYNAMIC_CLASS(wxTCPClient)
156 };
157
158 #endif // wxUSE_SOCKETS && wxUSE_IPC
159
160 #endif // _WX_SCKIPC_H