]>
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" 
  17 #include "wx/unix/gsockunx.h" 
  18 #include "wx/gsocket.h" 
  21 #define wxSockReadMask  0x01 
  22 #define wxSockWriteMask 0x02 
  24 static void _GSocket_PM_Input(void *data
) 
  26     GSocket 
*socket 
= (GSocket 
*) data
; 
  27     socket
->Detected_Read(); 
  30 static void _GSocket_PM_Output(void *data
) 
  32     GSocket 
*socket 
= (GSocket 
*) data
; 
  33     socket
->Detected_Write(); 
  36 bool GSocketGUIFunctionsTableConcrete::CanUseEventLoop() 
  39 bool GSocketGUIFunctionsTableConcrete::OnInit(void) 
  44 void GSocketGUIFunctionsTableConcrete::OnExit(void) 
  48 bool GSocketGUIFunctionsTableConcrete::Init_Socket(GSocket 
*socket
) 
  51     socket
->m_gui_dependent 
= (char *)malloc(sizeof(int)*2); 
  52     m_id 
= (int *)(socket
->m_gui_dependent
); 
  59 void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket 
*socket
) 
  61     free(socket
->m_gui_dependent
); 
  64 void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket 
*socket
, GSocketEvent event
) 
  66     int *m_id 
= (int *)(socket
->m_gui_dependent
); 
  69     if (socket
->m_fd 
== -1) 
  74         case GSOCK_LOST
:       /* fall-through */ 
  75         case GSOCK_INPUT
:      c 
= 0; break; 
  76         case GSOCK_OUTPUT
:     c 
= 1; break; 
  77         case GSOCK_CONNECTION
: c 
= ((socket
->m_server
) ? 0 : 1); break; 
  82         wxTheApp
->RemoveSocketHandler(m_id
[c
]); 
  86         m_id
[0] = wxTheApp
->AddSocketHandler(socket
->m_fd
, wxSockReadMask
, 
  87                                              _GSocket_PM_Input
, (void *)socket
); 
  91         m_id
[1] = wxTheApp
->AddSocketHandler(socket
->m_fd
, wxSockWriteMask
, 
  92                                              _GSocket_PM_Output
, (void *)socket
); 
  96 void GSocketGUIFunctionsTableConcrete::Uninstall_Callback(GSocket 
*socket
, GSocketEvent event
) 
  98     int *m_id 
= (int *)(socket
->m_gui_dependent
); 
 102         case GSOCK_LOST
:       /* fall-through */ 
 103         case GSOCK_INPUT
:      c 
= 0; break; 
 104         case GSOCK_OUTPUT
:     c 
= 1; break; 
 105         case GSOCK_CONNECTION
: c 
= ((socket
->m_server
) ? 0 : 1); break; 
 109         wxTheApp
->RemoveSocketHandler(m_id
[c
]); 
 114 void GSocketGUIFunctionsTableConcrete::Enable_Events(GSocket 
*socket
) 
 116     Install_Callback(socket
, GSOCK_INPUT
); 
 117     Install_Callback(socket
, GSOCK_OUTPUT
); 
 120 void GSocketGUIFunctionsTableConcrete::Disable_Events(GSocket 
*socket
) 
 122     Uninstall_Callback(socket
, GSOCK_INPUT
); 
 123     Uninstall_Callback(socket
, GSOCK_OUTPUT
); 
 126 #else /* !wxUSE_SOCKETS */ 
 128 /* some compilers don't like having empty source files */ 
 129 static int wxDummyGsockVar 
= 0; 
 131 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */