-void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket *socket,
- GSocketEvent event)
-{
- int *m_id = (int *)(socket->m_gui_dependent);
- const int fd = socket->m_fd;
-
- if ( fd == -1 )
- return;
-
- int c;
- switch (event)
- {
- case GSOCK_LOST: /* fall-through */
- case GSOCK_INPUT: c = 0; break;
- case GSOCK_OUTPUT: c = 1; break;
- case GSOCK_CONNECTION: c = ((socket->m_server) ? 0 : 1); break;
- default: return;
- }
-
- wxFDIODispatcher * const dispatcher = wxFDIODispatcher::Get();
- if ( !dispatcher )
- return;
-
- wxGSocketIOHandler *& handler = socket->m_handler;
-
- // we should register the new handlers but modify the existing ones in place
- bool registerHandler;
- if ( handler )
- {
- registerHandler = false;
- }
- else // no existing handler
- {
- registerHandler = true;
- handler = new wxGSocketIOHandler(socket);
- }
-
- if (c == 0)
- {
- m_id[0] = fd;
- handler->AddFlag(wxFDIO_INPUT);
- }
- else
- {
- m_id[1] = fd;
- handler->AddFlag(wxFDIO_OUTPUT);
- }
-
- if ( registerHandler )
- dispatcher->RegisterFD(fd, handler, handler->GetFlags());
- else
- dispatcher->ModifyFD(fd, handler, handler->GetFlags());
-}