comparison src/gtkft.c @ 8585:e4087b5c0627

[gaim-migrate @ 9335] Patch from Pekka Riikonen to allow a prpl to accept a file transfer without choosing the save filename, and then to later complete this selection. This also provides some API extension to allow a prpl to handle its own connection setups and a posteriori add the connection to gaim's file transfer list. committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Mon, 05 Apr 2004 20:15:29 +0000
parents 5956297c6bcc
children 8db7732df1fd
comparison
equal deleted inserted replaced
8584:058efd3cb86f 8585:e4087b5c0627
1172 gaim_gtkxfer_ask_recv(GaimXfer *xfer) 1172 gaim_gtkxfer_ask_recv(GaimXfer *xfer)
1173 { 1173 {
1174 char *buf, *size_buf; 1174 char *buf, *size_buf;
1175 size_t size; 1175 size_t size;
1176 1176
1177 size = gaim_xfer_get_size(xfer); 1177 /* If we have already accepted the request, ask the destination file
1178 1178 name directly */
1179 size_buf = gaim_str_size_to_units(size); 1179 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_ACCEPTED) {
1180 1180 size = gaim_xfer_get_size(xfer);
1181 buf = g_strdup_printf(_("%s wants to send you %s (%s)"), 1181 size_buf = gaim_str_size_to_units(size);
1182 xfer->who, gaim_xfer_get_filename(xfer), size_buf); 1182
1183 1183 buf = g_strdup_printf(_("%s wants to send you %s (%s)"),
1184 g_free(size_buf); 1184 xfer->who, gaim_xfer_get_filename(xfer),
1185 1185 size_buf);
1186 gaim_request_accept_cancel(NULL, NULL, buf, NULL, 0, xfer, 1186 g_free(size_buf);
1187 G_CALLBACK(choose_file), 1187
1188 G_CALLBACK(cancel_recv_cb)); 1188 gaim_request_accept_cancel(NULL, NULL, buf, NULL, 0, xfer,
1189 1189 G_CALLBACK(choose_file),
1190 G_CALLBACK(cancel_recv_cb));
1191 g_free(buf);
1192 } else
1193 choose_file(xfer);
1194 }
1195
1196 static int
1197 ask_accept_ok(GaimXfer *xfer)
1198 {
1199 gaim_xfer_request_accepted(xfer, NULL);
1200 return 0;
1201 }
1202
1203 static int
1204 ask_accept_cancel(GaimXfer *xfer)
1205 {
1206 gaim_xfer_request_denied(xfer);
1207 gaim_xfer_unref(xfer);
1208 return 0;
1209 }
1210
1211 static void
1212 gaim_gtkxfer_ask_accept(GaimXfer *xfer)
1213 {
1214 char *buf, *buf2 = NULL;
1215
1216 buf = g_strdup_printf(_("Accept file transfer request from %s?"),
1217 xfer->who);
1218 if (gaim_xfer_get_remote_ip(xfer) &&
1219 gaim_xfer_get_remote_port(xfer))
1220 buf2 = g_strdup_printf(_("A file is available for download from:\n"
1221 "Remote host: %s\nRemote port: %d"),
1222 gaim_xfer_get_remote_ip(xfer),
1223 gaim_xfer_get_remote_port(xfer));
1224 gaim_request_accept_cancel(NULL, NULL, buf, buf2, 0, xfer,
1225 G_CALLBACK(ask_accept_ok),
1226 G_CALLBACK(ask_accept_cancel));
1190 g_free(buf); 1227 g_free(buf);
1228 g_free(buf2);
1191 } 1229 }
1192 1230
1193 static void 1231 static void
1194 gaim_gtkxfer_request_file(GaimXfer *xfer) 1232 gaim_gtkxfer_request_file(GaimXfer *xfer)
1195 { 1233 {
1196 gaim_xfer_ref(xfer); 1234 gaim_xfer_ref(xfer);
1197 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) 1235 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) {
1198 gaim_gtkxfer_ask_recv(xfer); 1236 if (gaim_xfer_get_filename(xfer) ||
1199 else 1237 gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_ACCEPTED)
1238 gaim_gtkxfer_ask_recv(xfer);
1239 else
1240 gaim_gtkxfer_ask_accept(xfer);
1241 } else
1200 choose_file(xfer); 1242 choose_file(xfer);
1201 } 1243 }
1202 1244
1203 static void 1245 static void
1204 gaim_gtkxfer_ask_cancel(GaimXfer *xfer) 1246 gaim_gtkxfer_ask_cancel(GaimXfer *xfer)