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"
24 void _GSocket_GDK_Input(gpointer data
,
26 GdkInputCondition condition
)
28 GSocket
*socket
= (GSocket
*)data
;
30 if (condition
& GDK_INPUT_READ
)
31 socket
->Detected_Read();
32 if (condition
& GDK_INPUT_WRITE
)
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
)
52 socket
->m_gui_dependent
= (char *)malloc(sizeof(gint
)*2);
53 m_id
= (gint
*)(socket
->m_gui_dependent
);
61 void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket
*socket
)
63 free(socket
->m_gui_dependent
);
66 void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket
*socket
, GSocketEvent event
)
68 gint
*m_id
= (gint
*)(socket
->m_gui_dependent
);
71 if (socket
->m_fd
== -1)
76 case GSOCK_LOST
: /* fall-through */
77 case GSOCK_INPUT
: c
= 0; break;
78 case GSOCK_OUTPUT
: c
= 1; break;
79 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
84 gdk_input_remove(m_id
[c
]);
86 m_id
[c
] = gdk_input_add(socket
->m_fd
,
87 (c
? GDK_INPUT_WRITE
: GDK_INPUT_READ
),
92 void GSocketGUIFunctionsTableConcrete::Uninstall_Callback(GSocket
*socket
, GSocketEvent event
)
94 gint
*m_id
= (gint
*)(socket
->m_gui_dependent
);
97 assert( m_id
!= NULL
);
101 case GSOCK_LOST
: /* fall-through */
102 case GSOCK_INPUT
: c
= 0; break;
103 case GSOCK_OUTPUT
: c
= 1; break;
104 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
109 gdk_input_remove(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 */