/* * call-seq: * xc.io_in_handle -> nil * * Retrieves one incoming (from server) clientlib command if there are any in * the buffer. */ static VALUE c_io_in_handle (VALUE self) { RbXmmsClient *xmms = NULL; Data_Get_Struct (self, RbXmmsClient, xmms); CHECK_DELETED (xmms); xmmsc_io_in_handle (xmms->real); return Qnil; }
static gboolean xmmsc_glib_read_cb (GIOChannel *iochan, GIOCondition cond, gpointer data) { xmmsc_glib_watch_t *watch = data; gboolean ret = FALSE; g_return_val_if_fail (watch, FALSE); if (!(cond & G_IO_IN)) { xmmsc_io_disconnect (watch->conn); } else { ret = xmmsc_io_in_handle (watch->conn); } return ret; }
static gboolean ol_player_xmms2_ensure_connection () { /* ol_log_func (); */ if (connection == NULL && !ol_player_xmms2_init ()) return FALSE; gboolean ret = TRUE; if (connected) xmmsc_io_in_handle (connection); if (connected && xmmsc_io_want_out (connection)) xmmsc_io_out_handle (connection); if (!connected) { ret = ol_player_xmms2_connect (); } if (!ret) ol_debug ("Ensure connection failed!"); return ret; }
static int on_fd_data (void *udata, Ecore_Fd_Handler *handler) { xmmsc_connection_t *c = udata; int ret = 0; if (ecore_main_fd_handler_active_get (handler, ECORE_FD_ERROR)) { xmmsc_io_disconnect (c); return ret; } if (ecore_main_fd_handler_active_get (handler, ECORE_FD_READ)) ret = xmmsc_io_in_handle (c); if (ecore_main_fd_handler_active_get (handler, ECORE_FD_WRITE)) ret = xmmsc_io_out_handle (c); return ret; }
static void xmmsc_io_cf_event_callback (CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info) { CFSocketContext context; context.version = 0; CFSocketGetContext (s, &context); if (type == kCFSocketCloseOnInvalidate) { xmmsc_io_disconnect (context.info); } else if (type == kCFSocketWriteCallBack) { xmmsc_io_out_handle (context.info); } else if (type == kCFSocketReadCallBack) { xmmsc_io_in_handle (context.info); } }
void XmmsQT4::OnRead () { if (!xmmsc_io_in_handle (m_xmmsc)) { return; /* exception? */ } }
static void cli_context_event_loop_select (cli_context_t *ctx) { xmmsc_connection_t *conn = cli_context_xmms_async (ctx); fd_set rfds, wfds; gint modfds; gint xmms2fd; gint maxfds = 0; FD_ZERO(&rfds); FD_ZERO(&wfds); /* Listen to xmms2 if connected */ if (conn) { xmms2fd = xmmsc_io_fd_get (conn); if (xmms2fd == -1) { g_printf (_("Error: failed to retrieve XMMS2 file descriptor!")); return; } FD_SET(xmms2fd, &rfds); if (xmmsc_io_want_out (conn)) { FD_SET(xmms2fd, &wfds); } if (maxfds < xmms2fd) { maxfds = xmms2fd; } } /* Listen to readline in shell mode or status mode */ if ((cli_context_in_mode (ctx, CLI_EXECUTION_MODE_SHELL) && cli_context_in_status (ctx, CLI_ACTION_STATUS_READY)) || cli_context_in_status (ctx, CLI_ACTION_STATUS_REFRESH)) { FD_SET(STDIN_FILENO, &rfds); if (maxfds < STDIN_FILENO) { maxfds = STDIN_FILENO; } } if (cli_context_in_status (ctx, CLI_ACTION_STATUS_REFRESH)) { struct timeval refresh; refresh.tv_sec = cli_context_refresh_interval (ctx); refresh.tv_usec = 0; modfds = select (maxfds + 1, &rfds, &wfds, NULL, &refresh); } else { modfds = select (maxfds + 1, &rfds, &wfds, NULL, NULL); } if (modfds < 0 && errno != EINTR) { g_printf (_("Error: invalid I/O result!")); return; } else if (modfds != 0) { /* Get/send data to xmms2 */ if (conn) { if (FD_ISSET(xmms2fd, &rfds) && !xmmsc_io_in_handle (conn)) { return; } if (FD_ISSET(xmms2fd, &wfds) && !xmmsc_io_out_handle (conn)) { return; } } /* User input found, read it */ if ((cli_context_in_mode (ctx, CLI_EXECUTION_MODE_SHELL) || cli_context_in_status (ctx, CLI_ACTION_STATUS_REFRESH)) && FD_ISSET(STDIN_FILENO, &rfds)) { rl_callback_read_char (); } } /* Status -refresh Ask theefer: use callbacks for update and -refresh only for print? Nesciens: Yes, please! */ if (cli_context_in_status (ctx, CLI_ACTION_STATUS_REFRESH)) { cli_context_refresh_status (ctx); } }
static void loop_select (cli_infos_t *infos) { fd_set rfds, wfds; gint modfds; gint xmms2fd; gint maxfds = 0; FD_ZERO(&rfds); FD_ZERO(&wfds); /* Listen to xmms2 if connected */ if (infos->conn) { xmms2fd = xmmsc_io_fd_get (infos->conn); if (xmms2fd == -1) { g_printf (_("Error: failed to retrieve XMMS2 file descriptor!")); return; } FD_SET(xmms2fd, &rfds); if (xmmsc_io_want_out (infos->conn)) { FD_SET(xmms2fd, &wfds); } if (maxfds < xmms2fd) { maxfds = xmms2fd; } } /* Listen to readline in shell mode or status mode */ if ((infos->mode == CLI_EXECUTION_MODE_SHELL && infos->status == CLI_ACTION_STATUS_READY) || infos->status == CLI_ACTION_STATUS_REFRESH) { FD_SET(STDINFD, &rfds); if (maxfds < STDINFD) { maxfds = STDINFD; } } if (infos->status == CLI_ACTION_STATUS_REFRESH) { struct timeval refresh; refresh.tv_sec = infos->status_entry->refresh; refresh.tv_usec = 0; modfds = select (maxfds + 1, &rfds, &wfds, NULL, &refresh); } else { modfds = select (maxfds + 1, &rfds, &wfds, NULL, NULL); } if (modfds < 0) { g_printf (_("Error: invalid I/O result!")); return; } else if (modfds != 0) { /* Get/send data to xmms2 */ if (infos->conn) { if (FD_ISSET(xmms2fd, &rfds)) { xmmsc_io_in_handle (infos->conn); } if (FD_ISSET(xmms2fd, &wfds)) { xmmsc_io_out_handle (infos->conn); } } /* User input found, read it */ if ((infos->mode == CLI_EXECUTION_MODE_SHELL || infos->status == CLI_ACTION_STATUS_REFRESH) && FD_ISSET(STDINFD, &rfds)) { rl_callback_read_char (); } } /* Status -refresh Ask theefer: use callbacks for update and -refresh only for print? */ if (infos->status == CLI_ACTION_STATUS_REFRESH) { status_update_all (infos, infos->status_entry); g_printf ("\r"); status_print_entry (infos->status_entry); } }
void Listener::handleIn() { xmmsc_io_in_handle( conn_ ); }