Mercurial > pidgin.yaz
changeset 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 | 20cbadb004a0 |
children | 9699787f1c55 |
files | src/ft.c src/ft.h src/gtkft.c src/protocols/irc/dcc_send.c src/protocols/msn/msn.c src/protocols/oscar/oscar.c src/protocols/yahoo/yahoo_filexfer.c |
diffstat | 7 files changed, 74 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ft.c Sun Mar 06 00:10:54 2005 +0000 +++ b/src/ft.c Sun Mar 06 00:23:54 2005 +0000 @@ -142,6 +142,7 @@ { gchar *msg = NULL; GaimXferType xfer_type = gaim_xfer_get_type(xfer); + GaimAccount *account = gaim_xfer_get_account(xfer); switch(xfer_type) { case GAIM_XFER_SEND: @@ -159,7 +160,7 @@ } gaim_xfer_conversation_write(xfer, msg, TRUE); - gaim_xfer_error(xfer_type, xfer->who, msg); + gaim_xfer_error(xfer_type, account, xfer->who, msg); g_free(msg); } @@ -253,20 +254,23 @@ /* If we have already accepted the request, ask the destination file name directly */ if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_ACCEPTED) { + GaimBuddy *buddy = gaim_find_buddy(xfer->account, xfer->who); + if (gaim_xfer_get_filename(xfer) != NULL) { size = gaim_xfer_get_size(xfer); size_buf = gaim_str_size_to_units(size); escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1); buf = g_strdup_printf(_("%s wants to send you %s (%s)"), - xfer->who, escaped, - size_buf); + buddy ? gaim_buddy_get_alias(buddy) : xfer->who, + escaped, size_buf); g_free(size_buf); g_free(escaped); } else { - buf = g_strdup_printf(_("%s wants to send you a file"), xfer->who); + buf = g_strdup_printf(_("%s wants to send you a file"), + buddy ? gaim_buddy_get_alias(buddy) : xfer->who); } if (xfer->message != NULL) @@ -304,9 +308,10 @@ gaim_xfer_ask_accept(GaimXfer *xfer) { char *buf, *buf2 = NULL; + GaimBuddy *buddy = gaim_find_buddy(xfer->account, xfer->who); buf = g_strdup_printf(_("Accept file transfer request from %s?"), - xfer->who); + buddy ? gaim_buddy_get_alias(buddy) : xfer->who); if (gaim_xfer_get_remote_ip(xfer) && gaim_xfer_get_remote_port(xfer)) buf2 = g_strdup_printf(_("A file is available for download from:\n" @@ -344,11 +349,15 @@ { GaimXferType type; struct stat st; + char *msg; + GaimAccount *account; + GaimBuddy *buddy; if (xfer == NULL) return; type = gaim_xfer_get_type(xfer); + account = gaim_xfer_get_account(xfer); if (!filename && type == GAIM_XFER_RECEIVE) { xfer->status = GAIM_XFER_STATUS_ACCEPTED; @@ -356,14 +365,14 @@ return; } + buddy = gaim_find_buddy(account, xfer->who); + if (type == GAIM_XFER_SEND) { - char *msg; - /* Check the filename. */ if (g_strrstr(filename, "..")) { msg = g_strdup_printf(_("%s is not a valid filename.\n"), filename); - gaim_xfer_error(type, xfer->who, msg); + gaim_xfer_error(type, account, xfer->who, msg); g_free(msg); gaim_xfer_unref(xfer); @@ -381,13 +390,18 @@ gaim_xfer_set_size(xfer, st.st_size); msg = g_strdup_printf(_("Offering to send %s to %s"), - filename, xfer->who); + filename, buddy ? gaim_buddy_get_alias(buddy) : xfer->who); gaim_xfer_conversation_write(xfer, msg, FALSE); g_free(msg); } else { xfer->status = GAIM_XFER_STATUS_ACCEPTED; gaim_xfer_set_local_filename(xfer, filename); + + msg = g_strdup_printf(_("Starting transfer of %s from %s"), + xfer->filename, buddy ? gaim_buddy_get_alias(buddy) : xfer->who); + gaim_xfer_conversation_write(xfer, msg, FALSE); + g_free(msg); } gaim_xfer_add(xfer); @@ -533,9 +547,19 @@ g_return_if_fail(xfer != NULL); - if (completed == TRUE) + if (completed == TRUE) { + char *msg = NULL; gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_DONE); + if (gaim_xfer_get_filename(xfer) != NULL) + msg = g_strdup_printf(_("Transfer of file %s complete"), + gaim_xfer_get_filename(xfer)); + else + msg = g_strdup_printf(_("File transfer complete")); + gaim_xfer_conversation_write(xfer, msg, FALSE); + g_free(msg); + } + ui_ops = gaim_xfer_get_ui_ops(xfer); if (ui_ops != NULL && ui_ops->update_progress != NULL) @@ -863,8 +887,6 @@ void gaim_xfer_end(GaimXfer *xfer) { - char *msg = NULL; - g_return_if_fail(xfer != NULL); /* See if we are actually trying to cancel this. */ @@ -873,14 +895,6 @@ return; } - if (gaim_xfer_get_filename(xfer) != NULL) - msg = g_strdup_printf(_("Transfer of file %s complete"), - gaim_xfer_get_filename(xfer)); - else - msg = g_strdup_printf(_("File transfer complete")); - gaim_xfer_conversation_write(xfer, msg, FALSE); - g_free(msg); - if (xfer->ops.end != NULL) xfer->ops.end(xfer); @@ -976,25 +990,31 @@ { GaimXferUiOps *ui_ops; gchar *msg, *escaped; + GaimAccount *account; + GaimBuddy *buddy; g_return_if_fail(xfer != NULL); gaim_request_close_with_handle(xfer); gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_REMOTE); + account = gaim_xfer_get_account(xfer); + buddy = gaim_find_buddy(account, xfer->who); + if (gaim_xfer_get_filename(xfer) != NULL) { escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1); msg = g_strdup_printf(_("%s canceled the transfer of %s"), - xfer->who, escaped); + buddy ? gaim_buddy_get_alias(buddy) : xfer->who, escaped); g_free(escaped); } else { - msg = g_strdup_printf(_("%s canceled the file transfer"), xfer->who); + msg = g_strdup_printf(_("%s canceled the file transfer"), + buddy ? gaim_buddy_get_alias(buddy) : xfer->who); } gaim_xfer_conversation_write(xfer, msg, TRUE); - gaim_xfer_error(gaim_xfer_get_type(xfer), xfer->who, msg); + gaim_xfer_error(gaim_xfer_get_type(xfer), account, xfer->who, msg); g_free(msg); if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) @@ -1032,17 +1052,24 @@ } void -gaim_xfer_error(GaimXferType type, const char *who, const char *msg) +gaim_xfer_error(GaimXferType type, GaimAccount *account, const char *who, const char *msg) { char *title; g_return_if_fail(msg != NULL); g_return_if_fail(type != GAIM_XFER_UNKNOWN); + if (account) { + GaimBuddy *buddy; + buddy = gaim_find_buddy(account, who); + if (buddy) + who = gaim_buddy_get_alias(buddy); + } + if (type == GAIM_XFER_SEND) - title = g_strdup_printf(_("File transfer to %s aborted.\n"), who); + title = g_strdup_printf(_("File transfer to %s failed.\n"), who); else - title = g_strdup_printf(_("File transfer from %s aborted.\n"), who); + title = g_strdup_printf(_("File transfer from %s failed.\n"), who); gaim_notify_error(NULL, NULL, title, msg);
--- a/src/ft.h Sun Mar 06 00:10:54 2005 +0000 +++ b/src/ft.h Sun Mar 06 00:23:54 2005 +0000 @@ -522,14 +522,15 @@ * Displays a file transfer-related error message. * * This is a wrapper around gaim_notify_error(), which automatically - * specifies a title ("File transfer to <i>user</i> aborted" or - * "File Transfer from <i>user</i> aborted"). + * specifies a title ("File transfer to <i>user</i> failed" or + * "File Transfer from <i>user</i> failed"). * - * @param type The type of file transfer. - * @param who The user on the other end of the transfer. - * @param msg The message to display. + * @param type The type of file transfer. + * @param account The account sending or receiving the file. + * @param who The user on the other end of the transfer. + * @param msg The message to display. */ -void gaim_xfer_error(GaimXferType type, const char *who, const char *msg); +void gaim_xfer_error(GaimXferType type, GaimAccount *account, const char *who, const char *msg); /** * Updates file transfer progress.
--- a/src/gtkft.c Sun Mar 06 00:10:54 2005 +0000 +++ b/src/gtkft.c Sun Mar 06 00:23:54 2005 +0000 @@ -913,7 +913,7 @@ GAIM_STOCK_FILE_CANCELED, GTK_ICON_SIZE_MENU, NULL); - if (gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_LOCAL) + if (gaim_xfer_is_canceled(xfer)) status = _("Canceled"); else status = _("Failed");
--- a/src/protocols/irc/dcc_send.c Sun Mar 06 00:10:54 2005 +0000 +++ b/src/protocols/irc/dcc_send.c Sun Mar 06 00:23:54 2005 +0000 @@ -269,7 +269,7 @@ sock = gaim_network_listen_range(0, 0); if (sock < 0) { - gaim_notify_error(gc, NULL, _("File Transfer Aborted"), + gaim_notify_error(gc, NULL, _("File Transfer Failed"), _("Gaim could not open a listening port.")); gaim_xfer_cancel_local(xfer); return;
--- a/src/protocols/msn/msn.c Sun Mar 06 00:10:54 2005 +0000 +++ b/src/protocols/msn/msn.c Sun Mar 06 00:23:54 2005 +0000 @@ -367,7 +367,7 @@ msg = g_strdup_printf(_("Error reading %s: \n%s.\n"), filename, strerror(errno)); - gaim_xfer_error(gaim_xfer_get_type(xfer), who, msg); + gaim_xfer_error(gaim_xfer_get_type(xfer), account, xfer->who, msg); gaim_xfer_cancel_local(xfer); g_free(msg);
--- a/src/protocols/oscar/oscar.c Sun Mar 06 00:10:54 2005 +0000 +++ b/src/protocols/oscar/oscar.c Sun Mar 06 00:23:54 2005 +0000 @@ -2022,12 +2022,12 @@ oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); if (xfer->fd == -1) { - gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, + gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, _("Unable to establish file descriptor.")); gaim_xfer_cancel_local(xfer); } } else { - gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, + gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, _("Unable to create new connection.")); gaim_xfer_cancel_local(xfer); /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ @@ -2106,7 +2106,7 @@ aim_im_sendch2_sendfile_ask(od->sess, oft_info); aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); } else { - gaim_xfer_error(GAIM_XFER_SEND, xfer->who, + gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, _("Unable to establish listener socket.")); gaim_xfer_cancel_local(xfer); }
--- a/src/protocols/yahoo/yahoo_filexfer.c Sun Mar 06 00:10:54 2005 +0000 +++ b/src/protocols/yahoo/yahoo_filexfer.c Sun Mar 06 00:23:54 2005 +0000 @@ -66,7 +66,8 @@ if (!(xd = xfer->data)) return; if (source < 0) { - gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, _("Unable to connect.")); + gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), + xfer->who, _("Unable to connect.")); gaim_xfer_cancel_remote(xfer); return; } @@ -109,7 +110,8 @@ if (source < 0) { - gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, _("Unable to connect.")); + gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), + xfer->who, _("Unable to connect.")); gaim_xfer_cancel_remote(xfer); return; } @@ -165,7 +167,7 @@ if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) { if (0 && gaim_xfer_get_size(xfer) >= 1048577) { - gaim_notify_error(gc, NULL, _("File Transfer Aborted"), + gaim_notify_error(gc, NULL, _("File Transfer Failed"), _("Gaim cannot send files over Yahoo! that are bigger than " "One Megabyte (1,048,576 bytes).")); gaim_xfer_cancel_local(xfer); @@ -175,7 +177,7 @@ gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), yahoo_sendfile_connected, xfer) == -1) { - gaim_notify_error(gc, NULL, _("File Transfer Aborted"), + gaim_notify_error(gc, NULL, _("File Transfer Failed"), _("Unable to establish file descriptor.")); gaim_xfer_cancel_remote(xfer); } @@ -184,7 +186,7 @@ gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), yahoo_sendfile_connected, xfer) == -1) { - gaim_notify_error(gc, NULL, _("File Transfer Aborted"), + gaim_notify_error(gc, NULL, _("File Transfer Failed"), _("Unable to establish file descriptor.")); gaim_xfer_cancel_remote(xfer); } @@ -194,7 +196,7 @@ xfer->fd = gaim_proxy_connect(account, xfer_data->host, xfer_data->port, yahoo_receivefile_connected, xfer); if (xfer->fd == -1) { - gaim_notify_error(gc, NULL, _("File Transfer Aborted"), + gaim_notify_error(gc, NULL, _("File Transfer Failed"), _("Unable to establish file descriptor.")); gaim_xfer_cancel_remote(xfer); }