]> git.saurik.com Git - wxWidgets.git/blob - include/wx/unix/gsockunx.h
Implement wxBitmapButton::DoGetBestSize() to call wxButtonBase version so
[wxWidgets.git] / include / wx / unix / gsockunx.h
1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
3 * Name: gsockunx.h
4 * Purpose: GSocket Unix header
5 * CVSID: $Id$
6 * -------------------------------------------------------------------------
7 */
8
9 #ifndef __GSOCK_UNX_H
10 #define __GSOCK_UNX_H
11
12 #ifndef __GSOCKET_STANDALONE__
13 #include "wx/setup.h"
14 #endif
15
16 #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
17
18 #ifndef __GSOCKET_STANDALONE__
19 #include "wx/gsocket.h"
20 #else
21 #include "gsocket.h"
22 #endif
23
24 class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable
25 {
26 public:
27 virtual bool OnInit();
28 virtual void OnExit();
29 virtual bool CanUseEventLoop();
30 virtual bool Init_Socket(GSocket *socket);
31 virtual void Destroy_Socket(GSocket *socket);
32 virtual void Install_Callback(GSocket *socket, GSocketEvent event);
33 virtual void Uninstall_Callback(GSocket *socket, GSocketEvent event);
34 virtual void Enable_Events(GSocket *socket);
35 virtual void Disable_Events(GSocket *socket);
36 };
37
38 class GSocket
39 {
40 public:
41 GSocket();
42 virtual ~GSocket();
43 bool IsOk() { return m_ok; }
44 void Close();
45 void Shutdown();
46 GSocketError SetLocal(GAddress *address);
47 GSocketError SetPeer(GAddress *address);
48 GAddress *GetLocal();
49 GAddress *GetPeer();
50 GSocketError SetServer();
51 GSocket *WaitConnection();
52 bool SetReusable();
53 GSocketError Connect(GSocketStream stream);
54 GSocketError SetNonOriented();
55 int Read(char *buffer, int size);
56 int Write(const char *buffer, int size);
57 GSocketEventFlags Select(GSocketEventFlags flags);
58 void SetNonBlocking(bool non_block);
59 void SetTimeout(unsigned long millisec);
60 GSocketError WXDLLIMPEXP_NET GetError();
61 void SetCallback(GSocketEventFlags flags,
62 GSocketCallback callback, char *cdata);
63 void UnsetCallback(GSocketEventFlags flags);
64 GSocketError GetSockOpt(int level, int optname, void *optval, int *optlen);
65 GSocketError SetSockOpt(int level, int optname,
66 const void *optval, int optlen);
67 virtual void Detected_Read();
68 virtual void Detected_Write();
69 protected:
70 void Enable(GSocketEvent event);
71 void Disable(GSocketEvent event);
72 GSocketError Input_Timeout();
73 GSocketError Output_Timeout();
74 int Recv_Stream(char *buffer, int size);
75 int Recv_Dgram(char *buffer, int size);
76 int Send_Stream(const char *buffer, int size);
77 int Send_Dgram(const char *buffer, int size);
78 bool m_ok;
79 public:
80 /* DFE: We can't protect these data member until the GUI code is updated */
81 /* protected: */
82 int m_fd;
83 GAddress *m_local;
84 GAddress *m_peer;
85 GSocketError m_error;
86
87 bool m_non_blocking;
88 bool m_server;
89 bool m_stream;
90 bool m_establishing;
91 bool m_reusable;
92 unsigned long m_timeout;
93
94 /* Callbacks */
95 GSocketEventFlags m_detected;
96 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
97 char *m_data[GSOCK_MAX_EVENT];
98
99 char *m_gui_dependent;
100
101 };
102
103 #ifdef __cplusplus
104 extern "C" {
105 #endif /* __cplusplus */
106 /* Definition of GAddress */
107 struct _GAddress
108 {
109 struct sockaddr *m_addr;
110 size_t m_len;
111
112 GAddressType m_family;
113 int m_realfamily;
114
115 GSocketError m_error;
116 };
117 #ifdef __cplusplus
118 }
119 #endif /* __cplusplus */
120
121
122 #ifdef __cplusplus
123 extern "C" {
124 #endif /* __cplusplus */
125
126
127 /* GAddress */
128
129 GSocketError _GAddress_translate_from(GAddress *address,
130 struct sockaddr *addr, int len);
131 GSocketError _GAddress_translate_to (GAddress *address,
132 struct sockaddr **addr, int *len);
133 GSocketError _GAddress_Init_INET(GAddress *address);
134 GSocketError _GAddress_Init_UNIX(GAddress *address);
135
136
137 #ifdef __cplusplus
138 }
139 #endif /* __cplusplus */
140
141 #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
142
143 #endif /* __GSOCK_UNX_H */