1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
3 * Name: src/gtk1/gsockgtk.cpp
4 * Purpose: GSocket: GTK part
5 * Licence: The wxWindows licence
7 * -------------------------------------------------------------------------
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
21 #include "wx/gsocket.h"
22 #include "wx/unix/gsockunx.h"
27 void _GSocket_GDK_Input(gpointer data
,
29 GdkInputCondition condition
)
31 GSocket
*socket
= (GSocket
*)data
;
33 if (condition
& GDK_INPUT_READ
)
34 socket
->Detected_Read();
35 if (condition
& GDK_INPUT_WRITE
)
36 socket
->Detected_Write();
40 bool GSocketGUIFunctionsTableConcrete::CanUseEventLoop()
43 bool GSocketGUIFunctionsTableConcrete::OnInit(void)
48 void GSocketGUIFunctionsTableConcrete::OnExit(void)
52 bool GSocketGUIFunctionsTableConcrete::Init_Socket(GSocket
*socket
)
56 socket
->m_gui_dependent
= (char *)malloc(sizeof(gint
)*2);
57 m_id
= (gint
*)(socket
->m_gui_dependent
);
65 void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket
*socket
)
67 free(socket
->m_gui_dependent
);
70 void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket
*socket
, GSocketEvent event
)
72 gint
*m_id
= (gint
*)(socket
->m_gui_dependent
);
75 if (socket
->m_fd
== -1)
80 case GSOCK_LOST
: /* fall-through */
81 case GSOCK_INPUT
: c
= 0; break;
82 case GSOCK_OUTPUT
: c
= 1; break;
83 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
88 gdk_input_remove(m_id
[c
]);
90 m_id
[c
] = gdk_input_add(socket
->m_fd
,
91 (c
? GDK_INPUT_WRITE
: GDK_INPUT_READ
),
96 void GSocketGUIFunctionsTableConcrete::Uninstall_Callback(GSocket
*socket
, GSocketEvent event
)
98 gint
*m_id
= (gint
*)(socket
->m_gui_dependent
);
101 assert( m_id
!= NULL
);
105 case GSOCK_LOST
: /* fall-through */
106 case GSOCK_INPUT
: c
= 0; break;
107 case GSOCK_OUTPUT
: c
= 1; break;
108 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
114 gdk_input_remove(m_id
[c
]);
119 void GSocketGUIFunctionsTableConcrete::Enable_Events(GSocket
*socket
)
121 Install_Callback(socket
, GSOCK_INPUT
);
122 Install_Callback(socket
, GSOCK_OUTPUT
);
125 void GSocketGUIFunctionsTableConcrete::Disable_Events(GSocket
*socket
)
127 Uninstall_Callback(socket
, GSOCK_INPUT
);
128 Uninstall_Callback(socket
, GSOCK_OUTPUT
);
131 #else /* !wxUSE_SOCKETS */
133 /* some compilers don't like having empty source files */
134 static int wxDummyGsockVar
= 0;
136 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */