1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
4 * Purpose: GSocket: GTK part
5 * Licence: The wxWindows licence
7 * -------------------------------------------------------------------------
20 #include "wx/gsocket.h"
21 #include "wx/unix/gsockunx.h"
26 void _GSocket_GDK_Input(gpointer data
,
28 GdkInputCondition condition
)
30 GSocket
*socket
= (GSocket
*)data
;
32 if (condition
& GDK_INPUT_READ
)
33 socket
->Detected_Read();
34 if (condition
& GDK_INPUT_WRITE
)
35 socket
->Detected_Write();
39 bool GSocketGUIFunctionsTableConcrete::CanUseEventLoop()
42 bool GSocketGUIFunctionsTableConcrete::OnInit(void)
47 void GSocketGUIFunctionsTableConcrete::OnExit(void)
51 bool GSocketGUIFunctionsTableConcrete::Init_Socket(GSocket
*socket
)
55 socket
->m_gui_dependent
= (char *)malloc(sizeof(gint
)*2);
56 m_id
= (gint
*)(socket
->m_gui_dependent
);
64 void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket
*socket
)
66 free(socket
->m_gui_dependent
);
69 void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket
*socket
, GSocketEvent event
)
71 gint
*m_id
= (gint
*)(socket
->m_gui_dependent
);
74 if (socket
->m_fd
== -1)
79 case GSOCK_LOST
: /* fall-through */
80 case GSOCK_INPUT
: c
= 0; break;
81 case GSOCK_OUTPUT
: c
= 1; break;
82 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
87 gdk_input_remove(m_id
[c
]);
89 m_id
[c
] = gdk_input_add(socket
->m_fd
,
90 (c
? GDK_INPUT_WRITE
: GDK_INPUT_READ
),
95 void GSocketGUIFunctionsTableConcrete::Uninstall_Callback(GSocket
*socket
, GSocketEvent event
)
97 gint
*m_id
= (gint
*)(socket
->m_gui_dependent
);
100 assert( m_id
!= NULL
);
104 case GSOCK_LOST
: /* fall-through */
105 case GSOCK_INPUT
: c
= 0; break;
106 case GSOCK_OUTPUT
: c
= 1; break;
107 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
113 gdk_input_remove(m_id
[c
]);
118 void GSocketGUIFunctionsTableConcrete::Enable_Events(GSocket
*socket
)
120 Install_Callback(socket
, GSOCK_INPUT
);
121 Install_Callback(socket
, GSOCK_OUTPUT
);
124 void GSocketGUIFunctionsTableConcrete::Disable_Events(GSocket
*socket
)
126 Uninstall_Callback(socket
, GSOCK_INPUT
);
127 Uninstall_Callback(socket
, GSOCK_OUTPUT
);
130 #else /* !wxUSE_SOCKETS */
132 /* some compilers don't like having empty source files */
133 static int wxDummyGsockVar
= 0;
135 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */