]>
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 * ------------------------------------------------------------------------- */
14 #include "wx/unix/gsockunx.h"
15 #include "wx/gsocket.h"
18 #define wxSockReadMask 0x01
19 #define wxSockWriteMask 0x02
21 static void _GSocket_PM_Input(void *data
)
23 GSocket
*socket
= (GSocket
*) data
;
24 socket
->Detected_Read();
27 static void _GSocket_PM_Output(void *data
)
29 GSocket
*socket
= (GSocket
*) data
;
30 socket
->Detected_Write();
33 bool GSocketGUIFunctionsTableConcrete::CanUseEventLoop()
36 bool GSocketGUIFunctionsTableConcrete::OnInit(void)
41 void GSocketGUIFunctionsTableConcrete::OnExit(void)
45 bool GSocketGUIFunctionsTableConcrete::Init_Socket(GSocket
*socket
)
48 socket
->m_gui_dependent
= (char *)malloc(sizeof(int)*2);
49 m_id
= (int *)(socket
->m_gui_dependent
);
56 void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket
*socket
)
58 free(socket
->m_gui_dependent
);
61 void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket
*socket
, GSocketEvent event
)
63 int *m_id
= (int *)(socket
->m_gui_dependent
);
66 if (socket
->m_fd
== -1)
71 case GSOCK_LOST
: /* fall-through */
72 case GSOCK_INPUT
: c
= 0; break;
73 case GSOCK_OUTPUT
: c
= 1; break;
74 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
79 wxTheApp
->RemoveSocketHandler(m_id
[c
]);
83 m_id
[0] = wxTheApp
->AddSocketHandler(socket
->m_fd
, wxSockReadMask
,
84 _GSocket_PM_Input
, (void *)socket
);
88 m_id
[1] = wxTheApp
->AddSocketHandler(socket
->m_fd
, wxSockWriteMask
,
89 _GSocket_PM_Output
, (void *)socket
);
93 void GSocketGUIFunctionsTableConcrete::Uninstall_Callback(GSocket
*socket
, GSocketEvent event
)
95 int *m_id
= (int *)(socket
->m_gui_dependent
);
99 case GSOCK_LOST
: /* fall-through */
100 case GSOCK_INPUT
: c
= 0; break;
101 case GSOCK_OUTPUT
: c
= 1; break;
102 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
106 wxTheApp
->RemoveSocketHandler(m_id
[c
]);
111 void GSocketGUIFunctionsTableConcrete::Enable_Events(GSocket
*socket
)
113 Install_Callback(socket
, GSOCK_INPUT
);
114 Install_Callback(socket
, GSOCK_OUTPUT
);
117 void GSocketGUIFunctionsTableConcrete::Disable_Events(GSocket
*socket
)
119 Uninstall_Callback(socket
, GSOCK_INPUT
);
120 Uninstall_Callback(socket
, GSOCK_OUTPUT
);
123 #else /* !wxUSE_SOCKETS */
125 /* some compilers don't like having empty source files */
126 static int wxDummyGsockVar
= 0;
128 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */