]>
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 bool GSocketGUIFunctionsTableConcrete::CanUseEventLoop() 
  37 bool GSocketGUIFunctionsTableConcrete::OnInit(void) 
  42 void GSocketGUIFunctionsTableConcrete::OnExit(void) 
  46 bool GSocketGUIFunctionsTableConcrete::Init_Socket(GSocket 
*socket
) 
  49     socket
->m_gui_dependent 
= (char *)malloc(sizeof(int)*2); 
  50     m_id 
= (int *)(socket
->m_gui_dependent
); 
  57 void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket 
*socket
) 
  59     free(socket
->m_gui_dependent
); 
  62 void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket 
*socket
, GSocketEvent event
) 
  64     int *m_id 
= (int *)(socket
->m_gui_dependent
); 
  67     if (socket
->m_fd 
== -1) 
  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; 
  80         wxTheApp
->RemoveSocketHandler(m_id
[c
]); 
  84         m_id
[0] = wxTheApp
->AddSocketHandler(socket
->m_fd
, wxSockReadMask
, 
  85                                              _GSocket_PM_Input
, (void *)socket
); 
  89         m_id
[1] = wxTheApp
->AddSocketHandler(socket
->m_fd
, wxSockWriteMask
, 
  90                                              _GSocket_PM_Output
, (void *)socket
); 
  94 void GSocketGUIFunctionsTableConcrete::Uninstall_Callback(GSocket 
*socket
, GSocketEvent event
) 
  96     int *m_id 
= (int *)(socket
->m_gui_dependent
); 
 100         case GSOCK_LOST
:       /* fall-through */ 
 101         case GSOCK_INPUT
:      c 
= 0; break; 
 102         case GSOCK_OUTPUT
:     c 
= 1; break; 
 103         case GSOCK_CONNECTION
: c 
= ((socket
->m_server
) ? 0 : 1); break; 
 107         wxTheApp
->RemoveSocketHandler(m_id
[c
]); 
 112 void GSocketGUIFunctionsTableConcrete::Enable_Events(GSocket 
*socket
) 
 114     Install_Callback(socket
, GSOCK_INPUT
); 
 115     Install_Callback(socket
, GSOCK_OUTPUT
); 
 118 void GSocketGUIFunctionsTableConcrete::Disable_Events(GSocket 
*socket
) 
 120     Uninstall_Callback(socket
, GSOCK_INPUT
); 
 121     Uninstall_Callback(socket
, GSOCK_OUTPUT
); 
 124 #else /* !wxUSE_SOCKETS */ 
 126 /* some compilers don't like having empty source files */ 
 127 static int wxDummyGsockVar 
= 0; 
 129 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */