]> git.saurik.com Git - wxWidgets.git/blob - src/os2/gsockpm.cpp
added self-assignment check to wxListItem::operator=()
[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/gsocket.h"
16 #include "wx/app.h"
17 #include "wx/apptrait.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 class PMSocketManager : public GSocketInputBasedManager
35 {
36 public:
37 virtual int AddInput(GSocket *socket, SocketDir d)
38 {
39
40 if (d == FD_OUTPUT)
41 return wxTheApp->AddSocketHandler(socket->m_fd, wxSockWriteMask,
42 _GSocket_PM_Output, (void *)socket);
43 else
44 return wxTheApp->AddSocketHandler(socket->m_fd, wxSockReadMask,
45 _GSocket_PM_Input, (void *)socket);
46 }
47
48 virtual void RemoveInput(int fd)
49 {
50 wxTheApp->RemoveSocketHandler(fd);
51 }
52 };
53
54 GSocketManager *wxGUIAppTraits::GetSocketManager()
55 {
56 static PMSocketManager s_manager;
57 return &s_manager;
58 }
59
60
61 #else /* !wxUSE_SOCKETS */
62
63 /* some compilers don't like having empty source files */
64 static int wxDummyGsockVar = 0;
65
66 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */