Пример #1
0
Файл: si.c Проект: VoxOx/VoxOx
static void
jabber_si_xfer_bytestreams_send_init(GaimXfer *xfer)
{
	JabberSIXfer *jsx;

	gaim_xfer_ref(xfer);

	jsx = xfer->data;
	jsx->listen_data = gaim_network_listen_range(0, 0, SOCK_STREAM,
				jabber_si_xfer_bytestreams_listen_cb, xfer);
	if (jsx->listen_data == NULL) {
		gaim_xfer_unref(xfer);
		/* XXX: couldn't open a port, we're fscked */
		gaim_xfer_cancel_local(xfer);
		return;
	}

}
Пример #2
0
/*
 * This function is called after the user has selected a file to send.
 */
static void irc_dccsend_send_init(GaimXfer *xfer) {
	GaimConnection *gc = gaim_account_get_connection(gaim_xfer_get_account(xfer));
	struct irc_xfer_send_data *xd = xfer->data;

	xfer->filename = g_path_get_basename(xfer->local_filename);

	gaim_xfer_ref(xfer);

	/* Create a listening socket */
	xd->listen_data = gaim_network_listen_range(0, 0, SOCK_STREAM,
			irc_dccsend_network_listen_cb, xfer);
	if (xd->listen_data == NULL) {
		gaim_xfer_unref(xfer);
		gaim_notify_error(gc, NULL, _("File Transfer Failed"),
		                  _("Gaim could not open a listening port."));
		gaim_xfer_cancel_local(xfer);
	}

}
Пример #3
0
/*
 * This function is called after the user has selected a file to send.
 */
static void gaym_dccsend_send_init(GaimXfer *xfer) {
	struct gaym_xfer_send_data *xd = xfer->data;
	GaimConnection *gc = gaim_account_get_connection(gaim_xfer_get_account(xfer));
	struct gaym_conn *gaym = gc->proto_data;
	int sock;
	const char *arg[2];
	char *tmp;
	struct in_addr addr;
	unsigned short int port;

	xfer->filename = g_path_get_basename(xfer->local_filename);

	/* Create a listening socket */
	sock = gaim_network_listen_range(0, 0);

	if (sock < 0) {
		gaim_notify_error(gc, NULL, _("File Transfer Aborted"),
		                  _("Gaim could not open a listening port."));
		gaim_xfer_cancel_local(xfer);
		return;
	}

	xd->fd = sock;

	port = gaim_network_get_port_from_fd(sock);
	gaim_debug_misc("gaym", "port is %hu\n", port);
	/* Monitor the listening socket */
	xfer->watcher = gaim_input_add(sock, GAIM_INPUT_READ,
	                               gaym_dccsend_send_connected, xfer);

	/* Send the intended recipient the DCC request */
	arg[0] = xfer->who;
	inet_aton(gaim_network_get_my_ip(gaym->fd), &addr);
	arg[1] = tmp = g_strdup_printf("\001DCC SEND \"%s\" %u %hu %zu\001",
	                         xfer->filename, ntohl(addr.s_addr),
	                         port, xfer->size);

	gaym_cmd_privmsg(xfer->account->gc->proto_data, "msg", NULL, arg);
	g_free(tmp);
}