]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/os2/sockpm.cpp | |
3 | // Purpose: implementation of OS-2-specific handler event handling | |
4 | // Author: Guilhem Lavaux, Vadim Zeitlin | |
5 | // Created: 1999 | |
6 | // Copyright: (c) 1999-2008 wxWidgets dev team | |
7 | // Licence: wxWindows licence | |
8 | /////////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | // For compilers that support precompilation, includes "wx.h". | |
11 | #include "wx/wxprec.h" | |
12 | ||
13 | #if wxUSE_SOCKETS | |
14 | ||
15 | #include <stdlib.h> | |
16 | #include "wx/private/socket.h" | |
17 | #include "wx/app.h" | |
18 | #include "wx/apptrait.h" | |
19 | ||
20 | #define wxSockReadMask 0x01 | |
21 | #define wxSockWriteMask 0x02 | |
22 | ||
23 | static void wxSocket_PM_Input(void *data) | |
24 | { | |
25 | wxFDIOHandler *handler = static_cast<wxSocketImplUnix *>(data); | |
26 | ||
27 | handler->OnReadWaiting(); | |
28 | } | |
29 | ||
30 | static void wxSocket_PM_Output(void *data) | |
31 | { | |
32 | wxFDIOHandler *handler = static_cast<wxSocketImplUnix *>(data); | |
33 | ||
34 | handler->OnWriteWaiting(); | |
35 | } | |
36 | ||
37 | class PMFDIOManager : public wxFDIOManager | |
38 | { | |
39 | public: | |
40 | virtual int AddInput(wxFDIOHandler *handler, | |
41 | int fd, | |
42 | wxFDIOManager::Direction d) | |
43 | { | |
44 | if (d == FD_OUTPUT) | |
45 | return wxTheApp->AddSocketHandler(fd, wxSockWriteMask, | |
46 | wxSocket_PM_Output, handler); | |
47 | else | |
48 | return wxTheApp->AddSocketHandler(fd, wxSockReadMask, | |
49 | wxSocket_PM_Input, handler); | |
50 | } | |
51 | ||
52 | virtual void | |
53 | RemoveInput(wxFDIOHandler * WXUNUSED(handler), | |
54 | int fd, | |
55 | wxFDIOManager::Direction WXUNUSED(dir)) | |
56 | { | |
57 | wxTheApp->RemoveSocketHandler(fd); | |
58 | } | |
59 | }; | |
60 | ||
61 | wxFDIOManager *wxGUIAppTraits::GetFDIOManager() | |
62 | { | |
63 | static PMFDIOManager s_manager; | |
64 | return &s_manager; | |
65 | } | |
66 | ||
67 | ||
68 | #else /* !wxUSE_SOCKETS */ | |
69 | ||
70 | /* some compilers don't like having empty source files */ | |
71 | static int wxDummyGsockVar = 0; | |
72 | ||
73 | #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */ |