Beispiel #1
0
static void
items_changed_cb (GMenuModel *model, int position, int added, int removed, RBButtonBar *bar)
{
	clear_handlers (bar);
	clear_button_bar (bar);
	build_button_bar (bar);
}
Beispiel #2
0
void
done_bittorrent_listening_socket(struct connection *conn)
{
	struct bittorrent_connection *connection, *bittorrent = conn->info;

	/* The bittorrent connection might not even have been added if the
	 * request for the metainfo file failed so carefully look it up. */
	foreach (connection, bittorrent_connections)
		if (connection == bittorrent) {
			del_from_list(bittorrent);
			break;
		}

	/* If there are no more connections left remove all pending peer
	 * connections. */
	if (list_empty(bittorrent_connections)) {
		struct bittorrent_peer_connection *peer, *next;

		foreachsafe (peer, next, bittorrent_peer_connections)
			done_bittorrent_peer_connection(peer);
	}

	/* Close the listening socket. */
	if (bittorrent_socket != -1) {
		/* Unregister the socket from the select() loop mechanism. */
		clear_handlers(bittorrent_socket);

		close(bittorrent_socket);
		bittorrent_socket = -1;
	}
}
Beispiel #3
0
static void
free_itrm(struct itrm *itrm)
{
	if (!itrm) return;

	if (!itrm->remote) {
		if (itrm->orig_title && *itrm->orig_title) {
			set_window_title(itrm->orig_title, itrm->title_codepage);

		} else if (itrm->touched_title) {
			/* Set the window title to the value of $TERM if X11
			 * wasn't compiled in. Should hopefully make at least
			 * half the users happy. (debian bug #312955) */
			unsigned char title[MAX_TERM_LEN];

			get_terminal_name(title);
			if (*title)
				set_window_title(title,
						 get_cp_index("US-ASCII"));
		}


		unhandle_terminal_resize(itrm->in.ctl);
#ifdef CONFIG_MOUSE
		disable_mouse();
#endif
		send_done_sequence(itrm->out.std, itrm->altscreen);
		tcsetattr(itrm->in.ctl, TCSANOW, &itrm->t);
	}

	mem_free_set(&itrm->orig_title, NULL);

	/* elinks -remote may not have a valid stdin if not run from a tty (bug 938) */
	if (!itrm->remote || itrm->in.std >= 0) clear_handlers(itrm->in.std);
	clear_handlers(itrm->in.sock);
	clear_handlers(itrm->out.std);
	clear_handlers(itrm->out.sock);

	kill_timer(&itrm->timer);

	if (itrm == ditrm) ditrm = NULL;
	mem_free_if(itrm->out.queue.data);
	mem_free_if(itrm->in.queue.data);
	mem_free(itrm);
}
Beispiel #4
0
static void
impl_dispose (GObject *object)
{
	RBButtonBar *bar = RB_BUTTON_BAR (object);

	clear_handlers (bar);
	g_clear_object (&bar->priv->model);
	G_OBJECT_CLASS (rb_button_bar_parent_class)->dispose (object);
}
Beispiel #5
0
void
close_socket(struct socket *socket)
{
	if (socket->fd == -1) return;
#ifdef CONFIG_SSL
	if (socket->ssl) ssl_close(socket);
#endif
	close(socket->fd);
	clear_handlers(socket->fd);
	socket->fd = -1;
}
Beispiel #6
0
void
unhandle_mouse(void *h)
{
	struct gpm_mouse_spec *gms = h;

	if (!gms) return;

	clear_handlers(gms->h);
	mem_free(gms);
	done_mouse();
}
Beispiel #7
0
void
suspend_mouse(void *h)
{
	struct gpm_mouse_spec *gms = h;

	if (!gms) return;

	gms->h = init_mouse(gms->cons, 1);
	if (gms->h < 0) return;

	clear_handlers(gms->h);
}
Beispiel #8
0
static void
gpm_mouse_in(struct gpm_mouse_spec *gms)
{
	Gpm_Event gev;
	struct term_event ev;
	struct term_event_mouse mouse;

	if (Gpm_GetEvent(&gev) <= 0) {
		clear_handlers(gms->h);
		return;
	}

	mouse.x = int_max(gev.x - 1, 0);
	mouse.y = int_max(gev.y - 1, 0);

	if (gev.buttons & GPM_B_LEFT)
		mouse.button = B_LEFT;
	else if (gev.buttons & GPM_B_MIDDLE)
		mouse.button = B_MIDDLE;
	else if (gev.buttons & GPM_B_RIGHT)
		mouse.button = B_RIGHT;
	else
		return;

	if (gev.type & GPM_DOWN)
		mouse.button |= B_DOWN;
	else if (gev.type & GPM_UP)
		mouse.button |= B_UP;
	else if (gev.type & GPM_DRAG)
		mouse.button |= B_DRAG;
	else
		return;

	set_mouse_term_event(&ev, mouse.x, mouse.y, mouse.button);
	gms->fn(gms->data, (char *) &ev, sizeof(ev));
}
Beispiel #9
0
static void
flag_error(xmlparseobject *self)
{
    clear_handlers(self);
}
Beispiel #10
0
static void
read_select(struct socket *socket)
{
	struct read_buffer *rb = socket->read_buffer;
	ssize_t rd;

	assertm(rb != NULL, "read socket has no buffer");
	if_assert_failed {
		socket->ops->done(socket, connection_state(S_INTERNAL));
		return;
	}

	/* We are making some progress, therefore reset the timeout; we do this
	 * for read_select() to avoid that the periodic calls to user handlers
	 * has to do it. */
	socket->ops->set_timeout(socket, connection_state(0));

	if (!socket->duplex)
		clear_handlers(socket->fd);

	if (!rb->freespace) {
		int size = RD_SIZE(rb, rb->length);

		rb = mem_realloc(rb, size);
		if (!rb) {
			socket->ops->done(socket, connection_state(S_OUT_OF_MEM));
			return;
		}
		rb->freespace = size - sizeof(*rb) - rb->length;
		assert(rb->freespace > 0);
		socket->read_buffer = rb;
	}

#ifdef CONFIG_SSL
	if (socket->ssl) {
		rd = ssl_read(socket, rb->data + rb->length, rb->freespace);
	} else
#endif
	{
		rd = generic_read(socket, rb->data + rb->length, rb->freespace);
	}

	switch (rd) {
#ifdef CONFIG_SSL
	case SOCKET_SSL_WANT_READ:
		read_from_socket(socket, rb, connection_state(S_TRANS), rb->done);
		break;
#endif
	case SOCKET_CANT_READ:
		if (socket->state != SOCKET_RETRY_ONCLOSE) {
			socket->state = SOCKET_CLOSED;
			rb->done(socket, rb);
			break;
		}

		socket->ops->retry(socket, connection_state(S_CANT_READ));
		break;

	case SOCKET_SYSCALL_ERROR:
		socket->ops->retry(socket, connection_state_for_errno(errno));
		break;

	case SOCKET_INTERNAL_ERROR:
		/* The global errno variable is used for passing
		 * internal connection_state error value. */
		socket->ops->done(socket, connection_state(errno));
		break;

	default:
		debug_transfer_log(rb->data + rb->length, rd);

		rb->length += rd;
		rb->freespace -= rd;
		assert(rb->freespace >= 0);

		rb->done(socket, rb);
	}
}
Beispiel #11
0
static void
write_select(struct socket *socket)
{
	struct write_buffer *wb = socket->write_buffer;
	int wr;

	assertm(wb != NULL, "write socket has no buffer");
	if_assert_failed {
		socket->ops->done(socket, connection_state(S_INTERNAL));
		return;
	}

	/* We are making some progress, therefore reset the timeout; ie.  when
	 * uploading large files the time needed for all the data to be sent can
	 * easily exceed the timeout. */
	socket->ops->set_timeout(socket, connection_state(0));

#if 0
	printf("ws: %d\n",wb->length-wb->pos);
	for (wr = wb->pos; wr < wb->length; wr++) printf("%c", wb->data[wr]);
	printf("-\n");
#endif

#ifdef CONFIG_SSL
	if (socket->ssl) {
		wr = ssl_write(socket, wb->data + wb->pos, wb->length - wb->pos);
	} else
#endif
	{
		assert(wb->length - wb->pos > 0);
		wr = generic_write(socket, wb->data + wb->pos, wb->length - wb->pos);
	}

	switch (wr) {
	case SOCKET_CANT_WRITE:
		socket->ops->retry(socket, connection_state(S_CANT_WRITE));
		break;

	case SOCKET_SYSCALL_ERROR:
		socket->ops->retry(socket, connection_state_for_errno(errno));
		break;

	case SOCKET_INTERNAL_ERROR:
		/* The global errno variable is used for passing
		 * internal connection_state error value. */
		socket->ops->done(socket, connection_state(errno));
		break;

	default:
		if (wr < 0) break;

		/*printf("wr: %d\n", wr);*/
		wb->pos += wr;

		if (wb->pos == wb->length) {
			socket_write_T done = wb->done;

			if (!socket->duplex) {
				clear_handlers(socket->fd);

			} else {
				select_handler_T read_handler;
				select_handler_T error_handler;

				read_handler  = get_handler(socket->fd, SELECT_HANDLER_READ);
				error_handler = read_handler
					      ? (select_handler_T) exception
					      : NULL;

				set_handlers(socket->fd, read_handler, NULL,
					     error_handler, socket);
			}

			mem_free_set(&socket->write_buffer, NULL);
			done(socket);
		}
	}
}