comparison src/ft.c @ 10654:f2e86683cafc

[gaim-migrate @ 12182] sf patch #1152664, from Richard Laager This patches does three things: First, it uses aliases in file transfer messages whenever possible. Second, it fixes the case where file transfer completion messages are not showing for MSN. Third, it makes the wording more consistent: Canceled is used to describe cases when the file transfer was actively canceled by either party. Failed is used otherwise. Aborted is no longer used at all. Previously, aborted was used in some places while failed was used under the same circumstances in other places. Also, in the file transfer box, canceled was used in one place for remotely or locally canceled files while in another place in the same box canceled was only used for locally canceled files (failed was used for remotely canceled files). committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 06 Mar 2005 00:23:54 +0000
parents 0f7452b1f777
children d83f745c997b
comparison
equal deleted inserted replaced
10653:20cbadb004a0 10654:f2e86683cafc
140 140
141 static void gaim_xfer_show_file_error(GaimXfer *xfer, const char *filename) 141 static void gaim_xfer_show_file_error(GaimXfer *xfer, const char *filename)
142 { 142 {
143 gchar *msg = NULL; 143 gchar *msg = NULL;
144 GaimXferType xfer_type = gaim_xfer_get_type(xfer); 144 GaimXferType xfer_type = gaim_xfer_get_type(xfer);
145 GaimAccount *account = gaim_xfer_get_account(xfer);
145 146
146 switch(xfer_type) { 147 switch(xfer_type) {
147 case GAIM_XFER_SEND: 148 case GAIM_XFER_SEND:
148 msg = g_strdup_printf(_("Error reading %s: \n%s.\n"), 149 msg = g_strdup_printf(_("Error reading %s: \n%s.\n"),
149 filename, strerror(errno)); 150 filename, strerror(errno));
157 filename, strerror(errno)); 158 filename, strerror(errno));
158 break; 159 break;
159 } 160 }
160 161
161 gaim_xfer_conversation_write(xfer, msg, TRUE); 162 gaim_xfer_conversation_write(xfer, msg, TRUE);
162 gaim_xfer_error(xfer_type, xfer->who, msg); 163 gaim_xfer_error(xfer_type, account, xfer->who, msg);
163 g_free(msg); 164 g_free(msg);
164 } 165 }
165 166
166 static void 167 static void
167 gaim_xfer_choose_file_ok_cb(void *user_data, const char *filename) 168 gaim_xfer_choose_file_ok_cb(void *user_data, const char *filename)
251 size_t size; 252 size_t size;
252 253
253 /* If we have already accepted the request, ask the destination file 254 /* If we have already accepted the request, ask the destination file
254 name directly */ 255 name directly */
255 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_ACCEPTED) { 256 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_ACCEPTED) {
257 GaimBuddy *buddy = gaim_find_buddy(xfer->account, xfer->who);
258
256 if (gaim_xfer_get_filename(xfer) != NULL) 259 if (gaim_xfer_get_filename(xfer) != NULL)
257 { 260 {
258 size = gaim_xfer_get_size(xfer); 261 size = gaim_xfer_get_size(xfer);
259 size_buf = gaim_str_size_to_units(size); 262 size_buf = gaim_str_size_to_units(size);
260 escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1); 263 escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1);
261 buf = g_strdup_printf(_("%s wants to send you %s (%s)"), 264 buf = g_strdup_printf(_("%s wants to send you %s (%s)"),
262 xfer->who, escaped, 265 buddy ? gaim_buddy_get_alias(buddy) : xfer->who,
263 size_buf); 266 escaped, size_buf);
264 g_free(size_buf); 267 g_free(size_buf);
265 g_free(escaped); 268 g_free(escaped);
266 } 269 }
267 else 270 else
268 { 271 {
269 buf = g_strdup_printf(_("%s wants to send you a file"), xfer->who); 272 buf = g_strdup_printf(_("%s wants to send you a file"),
273 buddy ? gaim_buddy_get_alias(buddy) : xfer->who);
270 } 274 }
271 275
272 if (xfer->message != NULL) 276 if (xfer->message != NULL)
273 serv_got_im(gaim_account_get_connection(xfer->account), 277 serv_got_im(gaim_account_get_connection(xfer->account),
274 xfer->who, xfer->message, 0, time(NULL)); 278 xfer->who, xfer->message, 0, time(NULL));
302 306
303 static void 307 static void
304 gaim_xfer_ask_accept(GaimXfer *xfer) 308 gaim_xfer_ask_accept(GaimXfer *xfer)
305 { 309 {
306 char *buf, *buf2 = NULL; 310 char *buf, *buf2 = NULL;
311 GaimBuddy *buddy = gaim_find_buddy(xfer->account, xfer->who);
307 312
308 buf = g_strdup_printf(_("Accept file transfer request from %s?"), 313 buf = g_strdup_printf(_("Accept file transfer request from %s?"),
309 xfer->who); 314 buddy ? gaim_buddy_get_alias(buddy) : xfer->who);
310 if (gaim_xfer_get_remote_ip(xfer) && 315 if (gaim_xfer_get_remote_ip(xfer) &&
311 gaim_xfer_get_remote_port(xfer)) 316 gaim_xfer_get_remote_port(xfer))
312 buf2 = g_strdup_printf(_("A file is available for download from:\n" 317 buf2 = g_strdup_printf(_("A file is available for download from:\n"
313 "Remote host: %s\nRemote port: %d"), 318 "Remote host: %s\nRemote port: %d"),
314 gaim_xfer_get_remote_ip(xfer), 319 gaim_xfer_get_remote_ip(xfer),
342 void 347 void
343 gaim_xfer_request_accepted(GaimXfer *xfer, const char *filename) 348 gaim_xfer_request_accepted(GaimXfer *xfer, const char *filename)
344 { 349 {
345 GaimXferType type; 350 GaimXferType type;
346 struct stat st; 351 struct stat st;
352 char *msg;
353 GaimAccount *account;
354 GaimBuddy *buddy;
347 355
348 if (xfer == NULL) 356 if (xfer == NULL)
349 return; 357 return;
350 358
351 type = gaim_xfer_get_type(xfer); 359 type = gaim_xfer_get_type(xfer);
360 account = gaim_xfer_get_account(xfer);
352 361
353 if (!filename && type == GAIM_XFER_RECEIVE) { 362 if (!filename && type == GAIM_XFER_RECEIVE) {
354 xfer->status = GAIM_XFER_STATUS_ACCEPTED; 363 xfer->status = GAIM_XFER_STATUS_ACCEPTED;
355 xfer->ops.init(xfer); 364 xfer->ops.init(xfer);
356 return; 365 return;
357 } 366 }
358 367
368 buddy = gaim_find_buddy(account, xfer->who);
369
359 if (type == GAIM_XFER_SEND) { 370 if (type == GAIM_XFER_SEND) {
360 char *msg;
361
362 /* Check the filename. */ 371 /* Check the filename. */
363 if (g_strrstr(filename, "..")) { 372 if (g_strrstr(filename, "..")) {
364 373
365 msg = g_strdup_printf(_("%s is not a valid filename.\n"), filename); 374 msg = g_strdup_printf(_("%s is not a valid filename.\n"), filename);
366 gaim_xfer_error(type, xfer->who, msg); 375 gaim_xfer_error(type, account, xfer->who, msg);
367 g_free(msg); 376 g_free(msg);
368 377
369 gaim_xfer_unref(xfer); 378 gaim_xfer_unref(xfer);
370 return; 379 return;
371 } 380 }
379 gaim_xfer_set_local_filename(xfer, filename); 388 gaim_xfer_set_local_filename(xfer, filename);
380 gaim_xfer_set_filename(xfer, g_basename(filename)); 389 gaim_xfer_set_filename(xfer, g_basename(filename));
381 gaim_xfer_set_size(xfer, st.st_size); 390 gaim_xfer_set_size(xfer, st.st_size);
382 391
383 msg = g_strdup_printf(_("Offering to send %s to %s"), 392 msg = g_strdup_printf(_("Offering to send %s to %s"),
384 filename, xfer->who); 393 filename, buddy ? gaim_buddy_get_alias(buddy) : xfer->who);
385 gaim_xfer_conversation_write(xfer, msg, FALSE); 394 gaim_xfer_conversation_write(xfer, msg, FALSE);
386 g_free(msg); 395 g_free(msg);
387 } 396 }
388 else { 397 else {
389 xfer->status = GAIM_XFER_STATUS_ACCEPTED; 398 xfer->status = GAIM_XFER_STATUS_ACCEPTED;
390 gaim_xfer_set_local_filename(xfer, filename); 399 gaim_xfer_set_local_filename(xfer, filename);
400
401 msg = g_strdup_printf(_("Starting transfer of %s from %s"),
402 xfer->filename, buddy ? gaim_buddy_get_alias(buddy) : xfer->who);
403 gaim_xfer_conversation_write(xfer, msg, FALSE);
404 g_free(msg);
391 } 405 }
392 406
393 gaim_xfer_add(xfer); 407 gaim_xfer_add(xfer);
394 xfer->ops.init(xfer); 408 xfer->ops.init(xfer);
395 409
531 { 545 {
532 GaimXferUiOps *ui_ops; 546 GaimXferUiOps *ui_ops;
533 547
534 g_return_if_fail(xfer != NULL); 548 g_return_if_fail(xfer != NULL);
535 549
536 if (completed == TRUE) 550 if (completed == TRUE) {
551 char *msg = NULL;
537 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_DONE); 552 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_DONE);
553
554 if (gaim_xfer_get_filename(xfer) != NULL)
555 msg = g_strdup_printf(_("Transfer of file %s complete"),
556 gaim_xfer_get_filename(xfer));
557 else
558 msg = g_strdup_printf(_("File transfer complete"));
559 gaim_xfer_conversation_write(xfer, msg, FALSE);
560 g_free(msg);
561 }
538 562
539 ui_ops = gaim_xfer_get_ui_ops(xfer); 563 ui_ops = gaim_xfer_get_ui_ops(xfer);
540 564
541 if (ui_ops != NULL && ui_ops->update_progress != NULL) 565 if (ui_ops != NULL && ui_ops->update_progress != NULL)
542 ui_ops->update_progress(xfer, gaim_xfer_get_progress(xfer)); 566 ui_ops->update_progress(xfer, gaim_xfer_get_progress(xfer));
861 } 885 }
862 886
863 void 887 void
864 gaim_xfer_end(GaimXfer *xfer) 888 gaim_xfer_end(GaimXfer *xfer)
865 { 889 {
866 char *msg = NULL;
867
868 g_return_if_fail(xfer != NULL); 890 g_return_if_fail(xfer != NULL);
869 891
870 /* See if we are actually trying to cancel this. */ 892 /* See if we are actually trying to cancel this. */
871 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_DONE) { 893 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_DONE) {
872 gaim_xfer_cancel_local(xfer); 894 gaim_xfer_cancel_local(xfer);
873 return; 895 return;
874 } 896 }
875
876 if (gaim_xfer_get_filename(xfer) != NULL)
877 msg = g_strdup_printf(_("Transfer of file %s complete"),
878 gaim_xfer_get_filename(xfer));
879 else
880 msg = g_strdup_printf(_("File transfer complete"));
881 gaim_xfer_conversation_write(xfer, msg, FALSE);
882 g_free(msg);
883 897
884 if (xfer->ops.end != NULL) 898 if (xfer->ops.end != NULL)
885 xfer->ops.end(xfer); 899 xfer->ops.end(xfer);
886 900
887 if (xfer->watcher != 0) { 901 if (xfer->watcher != 0) {
974 void 988 void
975 gaim_xfer_cancel_remote(GaimXfer *xfer) 989 gaim_xfer_cancel_remote(GaimXfer *xfer)
976 { 990 {
977 GaimXferUiOps *ui_ops; 991 GaimXferUiOps *ui_ops;
978 gchar *msg, *escaped; 992 gchar *msg, *escaped;
993 GaimAccount *account;
994 GaimBuddy *buddy;
979 995
980 g_return_if_fail(xfer != NULL); 996 g_return_if_fail(xfer != NULL);
981 997
982 gaim_request_close_with_handle(xfer); 998 gaim_request_close_with_handle(xfer);
983 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_REMOTE); 999 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_REMOTE);
1000
1001 account = gaim_xfer_get_account(xfer);
1002 buddy = gaim_find_buddy(account, xfer->who);
984 1003
985 if (gaim_xfer_get_filename(xfer) != NULL) 1004 if (gaim_xfer_get_filename(xfer) != NULL)
986 { 1005 {
987 escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1); 1006 escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1);
988 msg = g_strdup_printf(_("%s canceled the transfer of %s"), 1007 msg = g_strdup_printf(_("%s canceled the transfer of %s"),
989 xfer->who, escaped); 1008 buddy ? gaim_buddy_get_alias(buddy) : xfer->who, escaped);
990 g_free(escaped); 1009 g_free(escaped);
991 } 1010 }
992 else 1011 else
993 { 1012 {
994 msg = g_strdup_printf(_("%s canceled the file transfer"), xfer->who); 1013 msg = g_strdup_printf(_("%s canceled the file transfer"),
1014 buddy ? gaim_buddy_get_alias(buddy) : xfer->who);
995 } 1015 }
996 gaim_xfer_conversation_write(xfer, msg, TRUE); 1016 gaim_xfer_conversation_write(xfer, msg, TRUE);
997 gaim_xfer_error(gaim_xfer_get_type(xfer), xfer->who, msg); 1017 gaim_xfer_error(gaim_xfer_get_type(xfer), account, xfer->who, msg);
998 g_free(msg); 1018 g_free(msg);
999 1019
1000 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) 1020 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND)
1001 { 1021 {
1002 if (xfer->ops.cancel_send != NULL) 1022 if (xfer->ops.cancel_send != NULL)
1030 1050
1031 gaim_xfer_unref(xfer); 1051 gaim_xfer_unref(xfer);
1032 } 1052 }
1033 1053
1034 void 1054 void
1035 gaim_xfer_error(GaimXferType type, const char *who, const char *msg) 1055 gaim_xfer_error(GaimXferType type, GaimAccount *account, const char *who, const char *msg)
1036 { 1056 {
1037 char *title; 1057 char *title;
1038 1058
1039 g_return_if_fail(msg != NULL); 1059 g_return_if_fail(msg != NULL);
1040 g_return_if_fail(type != GAIM_XFER_UNKNOWN); 1060 g_return_if_fail(type != GAIM_XFER_UNKNOWN);
1041 1061
1062 if (account) {
1063 GaimBuddy *buddy;
1064 buddy = gaim_find_buddy(account, who);
1065 if (buddy)
1066 who = gaim_buddy_get_alias(buddy);
1067 }
1068
1042 if (type == GAIM_XFER_SEND) 1069 if (type == GAIM_XFER_SEND)
1043 title = g_strdup_printf(_("File transfer to %s aborted.\n"), who); 1070 title = g_strdup_printf(_("File transfer to %s failed.\n"), who);
1044 else 1071 else
1045 title = g_strdup_printf(_("File transfer from %s aborted.\n"), who); 1072 title = g_strdup_printf(_("File transfer from %s failed.\n"), who);
1046 1073
1047 gaim_notify_error(NULL, NULL, title, msg); 1074 gaim_notify_error(NULL, NULL, title, msg);
1048 1075
1049 g_free(title); 1076 g_free(title);
1050 } 1077 }