]> git.saurik.com Git - wxWidgets.git/blob - src/os2/gsockpm.cpp
Corrected wxRTTI for wxNotebook so dynamic casting to wxBookCtrlBase works
[wxWidgets.git] / src / os2 / gsockpm.cpp
1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
3 * Name: gsockpm.c
4 * Purpose: GSocket: PM part
5 * Licence: The wxWindows licence
6 * CVSID: $Id$
7 * ------------------------------------------------------------------------- */
8
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
11
12 #if wxUSE_SOCKETS
13
14 #include <stdlib.h>
15 #include "wx/unix/gsockunx.h"
16 #include "wx/gsocket.h"
17 #include "wx/app.h"
18
19 #define wxSockReadMask 0x01
20 #define wxSockWriteMask 0x02
21
22 static void _GSocket_PM_Input(void *data)
23 {
24 GSocket *socket = (GSocket *) data;
25 socket->Detected_Read();
26 }
27
28 static void _GSocket_PM_Output(void *data)
29 {
30 GSocket *socket = (GSocket *) data;
31 socket->Detected_Write();
32 }
33
34 void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket *socket, GSocketEvent event)
35 {
36 int *m_id = (int *)(socket->m_gui_dependent);
37 int c;
38
39 if (socket->m_fd == -1)
40 return;
41
42 switch (event)
43 {
44 case GSOCK_LOST: /* fall-through */
45 case GSOCK_INPUT: c = 0; break;
46 case GSOCK_OUTPUT: c = 1; break;
47 case GSOCK_CONNECTION: c = ((socket->m_server) ? 0 : 1); break;
48 default: return;
49 }
50
51 if (m_id[c] != -1)
52 wxTheApp->RemoveSocketHandler(m_id[c]);
53
54 if (c == 0)
55 {
56 m_id[0] = wxTheApp->AddSocketHandler(socket->m_fd, wxSockReadMask,
57 _GSocket_PM_Input, (void *)socket);
58 }
59 else
60 {
61 m_id[1] = wxTheApp->AddSocketHandler(socket->m_fd, wxSockWriteMask,
62 _GSocket_PM_Output, (void *)socket);
63 }
64 }
65
66 void GSocketGUIFunctionsTableConcrete::Uninstall_Callback(GSocket *socket, GSocketEvent event)
67 {
68 int *m_id = (int *)(socket->m_gui_dependent);
69 int c;
70 switch (event)
71 {
72 case GSOCK_LOST: /* fall-through */
73 case GSOCK_INPUT: c = 0; break;
74 case GSOCK_OUTPUT: c = 1; break;
75 case GSOCK_CONNECTION: c = ((socket->m_server) ? 0 : 1); break;
76 default: return;
77 }
78 if (m_id[c] != -1)
79 wxTheApp->RemoveSocketHandler(m_id[c]);
80
81 m_id[c] = -1;
82 }
83
84 void GSocketGUIFunctionsTableConcrete::Enable_Events(GSocket *socket)
85 {
86 Install_Callback(socket, GSOCK_INPUT);
87 Install_Callback(socket, GSOCK_OUTPUT);
88 }
89
90 void GSocketGUIFunctionsTableConcrete::Disable_Events(GSocket *socket)
91 {
92 Uninstall_Callback(socket, GSOCK_INPUT);
93 Uninstall_Callback(socket, GSOCK_OUTPUT);
94 }
95
96 #else /* !wxUSE_SOCKETS */
97
98 /* some compilers don't like having empty source files */
99 static int wxDummyGsockVar = 0;
100
101 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */