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; } }
/* * 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); } }
void gaim_gtkxfer_dialog_add_xfer(GaimGtkXferDialog *dialog, GaimXfer *xfer) { GaimGtkXferUiData *data; GaimXferType type; GdkPixbuf *pixbuf; char *size_str, *remaining_str; char *lfilename, *utf8; g_return_if_fail(dialog != NULL); g_return_if_fail(xfer != NULL); gaim_xfer_ref(xfer); data = GAIM_GTKXFER(xfer); data->in_list = TRUE; gaim_gtkxfer_dialog_show(dialog); data->start_time = time(NULL); data->end_time = -1; type = gaim_xfer_get_type(xfer); size_str = gaim_str_size_to_units(gaim_xfer_get_size(xfer)); remaining_str = gaim_str_size_to_units(gaim_xfer_get_bytes_remaining(xfer)); pixbuf = gtk_widget_render_icon(dialog->window, (type == GAIM_XFER_RECEIVE ? GAIM_STOCK_DOWNLOAD : GAIM_STOCK_UPLOAD), GTK_ICON_SIZE_MENU, NULL); gtk_list_store_append(dialog->model, &data->iter); lfilename = g_path_get_basename(gaim_xfer_get_local_filename(xfer)); utf8 = g_filename_to_utf8(lfilename, -1, NULL, NULL, NULL); g_free(lfilename); lfilename = utf8; gtk_list_store_set(dialog->model, &data->iter, COLUMN_STATUS, pixbuf, COLUMN_PROGRESS, 0.0, COLUMN_FILENAME, (type == GAIM_XFER_RECEIVE) ? gaim_xfer_get_filename(xfer) : lfilename, COLUMN_SIZE, size_str, COLUMN_REMAINING, _("Waiting for transfer to begin"), COLUMN_DATA, xfer, -1); g_free(lfilename); gtk_tree_view_columns_autosize(GTK_TREE_VIEW(dialog->tree)); g_object_unref(pixbuf); g_free(size_str); g_free(remaining_str); dialog->num_transfers++; ensure_row_selected(dialog); }