rename various gsock* files to sock* (except for MSW where this will be done later)
[wxWidgets.git] / src / os2 / sockpm.cpp
1 /* -------------------------------------------------------------------------
2 * Project: wxSocketImpl (Generic Socket) for WX
3 * Name: gsockpm.c
4 * Purpose: wxSocketImpl: 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/private/socket.h"
16 #include "wx/app.h"
17 #include "wx/apptrait.h"
18
19 #define wxSockReadMask 0x01
20 #define wxSockWriteMask 0x02
21
22 static void wxSocket_PM_Input(void *data)
23 {
24 wxSocketImpl *socket = static_cast<wxSocketImpl *>(data);
25
26 socket->Detected_Read();
27 }
28
29 static void wxSocket_PM_Output(void *data)
30 {
31 wxSocketImpl *socket = static_cast<wxSocketImpl *>(data);
32
33 socket->Detected_Write();
34 }
35
36 class PMSocketManager : public wxSocketInputBasedManager
37 {
38 public:
39 virtual int AddInput(wxSocketImpl *socket, SocketDir d)
40 {
41
42 if (d == FD_OUTPUT)
43 return wxTheApp->AddSocketHandler(socket->m_fd, wxSockWriteMask,
44 wxSocket_PM_Output, (void *)socket);
45 else
46 return wxTheApp->AddSocketHandler(socket->m_fd, wxSockReadMask,
47 wxSocket_PM_Input, (void *)socket);
48 }
49
50 virtual void RemoveInput(int fd)
51 {
52 wxTheApp->RemoveSocketHandler(fd);
53 }
54 };
55
56 wxSocketManager *wxGUIAppTraits::GetSocketManager()
57 {
58 static PMSocketManager s_manager;
59 return &s_manager;
60 }
61
62
63 #else /* !wxUSE_SOCKETS */
64
65 /* some compilers don't like having empty source files */
66 static int wxDummyGsockVar = 0;
67
68 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */