]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/gsockpm.cpp
1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
4 * Purpose: GSocket: PM part
5 * Licence: The wxWindows licence
7 * ------------------------------------------------------------------------- */
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
15 #include "wx/unix/gsockunx.h"
16 #include "wx/gsocket.h"
19 #define wxSockReadMask 0x01
20 #define wxSockWriteMask 0x02
22 static void _GSocket_PM_Input(void *data
)
24 GSocket
*socket
= (GSocket
*) data
;
25 socket
->Detected_Read();
28 static void _GSocket_PM_Output(void *data
)
30 GSocket
*socket
= (GSocket
*) data
;
31 socket
->Detected_Write();
34 void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket
*socket
, GSocketEvent event
)
36 int *m_id
= (int *)(socket
->m_gui_dependent
);
39 if (socket
->m_fd
== -1)
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;
52 wxTheApp
->RemoveSocketHandler(m_id
[c
]);
56 m_id
[0] = wxTheApp
->AddSocketHandler(socket
->m_fd
, wxSockReadMask
,
57 _GSocket_PM_Input
, (void *)socket
);
61 m_id
[1] = wxTheApp
->AddSocketHandler(socket
->m_fd
, wxSockWriteMask
,
62 _GSocket_PM_Output
, (void *)socket
);
66 void GSocketGUIFunctionsTableConcrete::Uninstall_Callback(GSocket
*socket
, GSocketEvent event
)
68 int *m_id
= (int *)(socket
->m_gui_dependent
);
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;
79 wxTheApp
->RemoveSocketHandler(m_id
[c
]);
84 void GSocketGUIFunctionsTableConcrete::Enable_Events(GSocket
*socket
)
86 Install_Callback(socket
, GSOCK_INPUT
);
87 Install_Callback(socket
, GSOCK_OUTPUT
);
90 void GSocketGUIFunctionsTableConcrete::Disable_Events(GSocket
*socket
)
92 Uninstall_Callback(socket
, GSOCK_INPUT
);
93 Uninstall_Callback(socket
, GSOCK_OUTPUT
);
96 #else /* !wxUSE_SOCKETS */
98 /* some compilers don't like having empty source files */
99 static int wxDummyGsockVar
= 0;
101 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */