]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/sockgtk.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/sockgtk.cpp
3 // Purpose: implementation of wxGTK-specific socket event handling
4 // Author: Guilhem Lavaux, Vadim Zeitlin
7 // Copyright: (c) 1999, 2007 wxWidgets dev team
8 // (c) 2009 Vadim Zeitlin
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #if wxUSE_SOCKETS && defined(__UNIX__)
17 #include "wx/apptrait.h"
18 #include "wx/private/fdiomanager.h"
23 static gboolean
wxSocket_Input(GIOChannel
*, GIOCondition condition
, gpointer data
)
25 wxFDIOHandler
* const handler
= static_cast<wxFDIOHandler
*>(data
);
27 if (condition
& G_IO_IN
)
29 handler
->OnReadWaiting();
31 // we could have lost connection while reading in which case we
32 // shouldn't call OnWriteWaiting() as the socket is now closed and it
34 if ( !handler
->IsOk() )
38 if (condition
& G_IO_OUT
)
39 handler
->OnWriteWaiting();
45 class GTKFDIOManager
: public wxFDIOManager
48 virtual int AddInput(wxFDIOHandler
*handler
, int fd
, Direction d
)
50 return g_io_add_watch(
51 g_io_channel_unix_new(fd
),
52 d
== OUTPUT
? G_IO_OUT
: G_IO_IN
,
58 RemoveInput(wxFDIOHandler
* WXUNUSED(handler
), int fd
, Direction
WXUNUSED(d
))
64 wxFDIOManager
*wxGUIAppTraits::GetFDIOManager()
66 static GTKFDIOManager s_manager
;
70 #endif // wxUSE_SOCKETS && __UNIX__