]> git.saurik.com Git - wxWidgets.git/blame - src/os2/gsockpm.cpp
non-pch build fix
[wxWidgets.git] / src / os2 / gsockpm.cpp
CommitLineData
05a019a2
DE
1/* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
3 * Name: gsockpm.c
4 * Purpose: GSocket: PM part
65571936 5 * Licence: The wxWindows licence
05a019a2
DE
6 * CVSID: $Id$
7 * ------------------------------------------------------------------------- */
8
6670f564
WS
9// For compilers that support precompilation, includes "wx.h".
10#include "wx/wxprec.h"
11
05a019a2
DE
12#if wxUSE_SOCKETS
13
14#include <stdlib.h>
15#include "wx/unix/gsockunx.h"
16#include "wx/gsocket.h"
621b4574 17#include "wx/app.h"
05a019a2
DE
18
19#define wxSockReadMask 0x01
20#define wxSockWriteMask 0x02
21
22static void _GSocket_PM_Input(void *data)
23{
24 GSocket *socket = (GSocket *) data;
a1ad0f6b 25 socket->Detected_Read();
05a019a2
DE
26}
27
28static void _GSocket_PM_Output(void *data)
29{
30 GSocket *socket = (GSocket *) data;
a1ad0f6b 31 socket->Detected_Write();
05a019a2
DE
32}
33
a1ad0f6b 34void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket *socket, GSocketEvent event)
05a019a2
DE
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)
621b4574 52 wxTheApp->RemoveSocketHandler(m_id[c]);
05a019a2
DE
53
54 if (c == 0)
55 {
621b4574
SN
56 m_id[0] = wxTheApp->AddSocketHandler(socket->m_fd, wxSockReadMask,
57 _GSocket_PM_Input, (void *)socket);
05a019a2
DE
58 }
59 else
60 {
621b4574
SN
61 m_id[1] = wxTheApp->AddSocketHandler(socket->m_fd, wxSockWriteMask,
62 _GSocket_PM_Output, (void *)socket);
05a019a2
DE
63 }
64}
65
a1ad0f6b 66void GSocketGUIFunctionsTableConcrete::Uninstall_Callback(GSocket *socket, GSocketEvent event)
05a019a2
DE
67{
68 int *m_id = (int *)(socket->m_gui_dependent);
69 int c;
70 switch (event)
71 {
6670f564
WS
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;
05a019a2
DE
77 }
78 if (m_id[c] != -1)
621b4574 79 wxTheApp->RemoveSocketHandler(m_id[c]);
05a019a2
DE
80
81 m_id[c] = -1;
82}
83
a1ad0f6b 84void GSocketGUIFunctionsTableConcrete::Enable_Events(GSocket *socket)
05a019a2 85{
a1ad0f6b
DE
86 Install_Callback(socket, GSOCK_INPUT);
87 Install_Callback(socket, GSOCK_OUTPUT);
05a019a2
DE
88}
89
a1ad0f6b 90void GSocketGUIFunctionsTableConcrete::Disable_Events(GSocket *socket)
05a019a2 91{
a1ad0f6b
DE
92 Uninstall_Callback(socket, GSOCK_INPUT);
93 Uninstall_Callback(socket, GSOCK_OUTPUT);
05a019a2
DE
94}
95
96#else /* !wxUSE_SOCKETS */
97
98/* some compilers don't like having empty source files */
99static int wxDummyGsockVar = 0;
100
101#endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */