Mercurial > pidgin.yaz
changeset 9627:8a540b8a5f70
[gaim-migrate @ 10471]
A bug fix for away message tooltips and some more removing-gaim_notify_errors.
Here's the thought: for errors associated with a buddy, check to see if
there's already a window open for him, if so, print the error to the window
and present the window to the user. If not, you can go ahead and gaim_notify_error.
So, things like checking profiles in the buddy list might potentially print errors
to conversations. I think this is good, but we'll try it out a bit.
If it's really good, we won't even gaim_notify_error and instead create a new convo
window just for the error.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sun, 01 Aug 2004 00:31:45 +0000 |
parents | afd069368860 |
children | b85d6212d707 |
files | src/conversation.c src/conversation.h src/gtkconv.c src/protocols/oscar/oscar.c |
diffstat | 4 files changed, 75 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/src/conversation.c Sat Jul 31 23:30:01 2004 +0000 +++ b/src/conversation.c Sun Aug 01 00:31:45 2004 +0000 @@ -1666,6 +1666,29 @@ gaim_conversation_write(c, who, message, flags, mtime); } +gboolean gaim_conv_present_error(const char *who, GaimAccount *account, const char *what) +{ + GaimConversation *conv; + GaimConvWindow *window; + + g_return_val_if_fail(who != NULL, FALSE); + g_return_val_if_fail(account !=NULL, FALSE); + g_return_val_if_fail(what != NULL, FALSE); + + conv = gaim_find_conversation_with_account(who, account); + if (conv != NULL) + gaim_conversation_write(conv, NULL, what, GAIM_MESSAGE_ERROR, time(NULL)); + else + return FALSE; + window = gaim_conversation_get_window(conv); + if (!gaim_conv_window_has_focus(window)) /* don't change the active conversation if the user is using this window */ + gaim_conv_window_switch_conversation(window, gaim_conversation_get_index(conv)); + + gaim_conv_window_raise(window); + + return TRUE; +} + void gaim_conv_im_send(GaimConvIm *im, const char *message) {
--- a/src/conversation.h Sat Jul 31 23:30:01 2004 +0000 +++ b/src/conversation.h Sun Aug 01 00:31:45 2004 +0000 @@ -1001,6 +1001,21 @@ time_t mtime); /** + * Presents an IM-error to the user + * + * This is a helper function to find a conversation, write an error to it, and + * raise the window. If a conversation with this user doesn't already exist, + * the function will return FALSE and the calling function can attempt to present + * the error another way (gaim_notify_error, most likely) + * + * @param who The user this error is about + * @param account The account this error is on + * @param what The error + * @return TRUE if the error was presented, else FALSE + */ +gboolean gaim_conv_present_error(const char *who, GaimAccount *account, const char *what); + +/** * Sends a message to this IM conversation. * * @param im The IM.
--- a/src/gtkconv.c Sat Jul 31 23:30:01 2004 +0000 +++ b/src/gtkconv.c Sun Aug 01 00:31:45 2004 +0000 @@ -5073,13 +5073,13 @@ } else if (flags & GAIM_MESSAGE_ERROR) { if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")) - g_snprintf(buf, BUF_LONG, "<FONT SIZE=\"2\">(%s)</FONT> <B>%s</B>", + g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"#ff0000\"><FONT SIZE=\"2\">(%s)</FONT> <B>%s</B></FONT>", mdate, message); else g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"#ff0000\"><B>%s</B></FONT>", message); g_snprintf(buf2, sizeof(buf2), - "<FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT>", + "<FONT COLOR=\"#ff0000\"><FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT></FONT>", sml_attrib, mdate, message); gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0);
--- a/src/protocols/oscar/oscar.c Sat Jul 31 23:30:01 2004 +0000 +++ b/src/protocols/oscar/oscar.c Sun Aug 01 00:31:45 2004 +0000 @@ -1414,6 +1414,7 @@ gaim_connection_error(gc, _("Disconnected.")); } else if (conn->type == AIM_CONN_TYPE_CHAT) { struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); + GaimConversation *conv = gaim_find_chat(gc, c->id); char *buf; gaim_debug_info("oscar", "disconnected from chat room %s\n", c->name); @@ -1424,7 +1425,10 @@ c->fd = -1; aim_conn_kill(od->sess, &conn); buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); - gaim_notify_error(gc, NULL, buf, NULL); + if (conv) + gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); + else + gaim_notify_error(gc, NULL, buf, NULL); g_free(buf); } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { if (od->cnpa > 0) @@ -3678,7 +3682,6 @@ static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { GaimConnection *gc = sess->aux_data; GaimAccount *account = gaim_connection_get_account(gc); - GaimConversation *conv; char *buf; va_list ap; fu16_t chan, nummissed, reason; @@ -3748,10 +3751,7 @@ break; } - conv = gaim_find_conversation_with_account(userinfo->sn, account); - if (conv != NULL) - gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); - else + if (!gaim_conv_present_error(userinfo->sn, account, buf)) gaim_notify_error(sess->aux_data, NULL, buf, NULL); g_free(buf); @@ -3872,8 +3872,8 @@ } static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { + GaimConnection *gc = sess->aux_data; #if 0 - GaimConnection *gc = sess->aux_data; OscarData *od = gc->proto_data; GaimXfer *xfer; #endif @@ -3899,11 +3899,13 @@ #endif /* Data is assumed to be the destination sn */ - buf = g_strdup_printf(_("Your message to %s did not get sent:"), data); - gaim_notify_error(sess->aux_data, NULL, buf, - (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); - g_free(buf); - + if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), + (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Your message did not get sent."))) { + buf = g_strdup_printf(_("Your message to %s did not get sent:"), data); + gaim_notify_error(sess->aux_data, NULL, buf, + (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); + g_free(buf); + } return 1; } @@ -3945,7 +3947,7 @@ * happens when you request info of someone who is offline. */ static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { - gchar *buf; + gchar *buf, *cbuf; va_list ap; fu16_t reason; char *destn; @@ -3957,12 +3959,15 @@ if (destn == NULL) return 1; - - buf = g_strdup_printf(_("User information for %s unavailable:"), destn); - - gaim_notify_error(sess->aux_data, NULL, buf, - (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); - g_free(buf); + + cbuf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); + if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), cbuf)) { + buf = g_strdup_printf(_("User information for %s unavailable:"), destn); + gaim_notify_error(sess->aux_data, NULL, buf, + (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); + g_free(buf); + } + g_free(cbuf); return 1; } @@ -5522,7 +5527,8 @@ if (!aim_snvalid(buddy->name)) { gchar *buf; buf = g_strdup_printf(_("Could not add the buddy %s because the screen name is invalid. Screen names must either start with a letter and contain only letters, numbers and spaces, or contain only numbers."), buddy->name); - gaim_notify_error(gc, NULL, _("Unable To Add"), buf); + if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) + gaim_notify_error(gc, NULL, _("Unable To Add"), buf); g_free(buf); /* Remove from local list */ @@ -5970,7 +5976,8 @@ case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ gchar *buf; buf = g_strdup_printf(_("Could not add the buddy %s because you have too many buddies in your buddy list. Please remove one and try again."), (retval->name ? retval->name : _("(no name)"))); - gaim_notify_error(gc, NULL, _("Unable To Add"), buf); + if (!gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) + gaim_notify_error(gc, NULL, _("Unable To Add"), buf); g_free(buf); } @@ -5983,7 +5990,8 @@ gchar *buf; gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); buf = g_strdup_printf(_("Could not add the buddy %s for an unknown reason. The most common reason for this is that you have the maximum number of allowed buddies in your buddy list."), (retval->name ? retval->name : _("(no name)"))); - gaim_notify_error(gc, NULL, _("Unable To Add"), buf); + if (!gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) + gaim_notify_error(gc, NULL, _("Unable To Add"), buf); g_free(buf); } break; } @@ -6448,15 +6456,17 @@ g_free(charset); if (away_utf8 != NULL) { gchar *tmp1, *tmp2; - tmp1 = gaim_strcasereplace(away_utf8, "<BR>", "\n"); + /* tmp1 = gaim_strcasereplace(away_utf8, "<BR>", "\n"); This replacement is handled in strip_html. + * g_free(away_utf8); + */ + tmp2 = gaim_markup_strip_html(away_utf8); g_free(away_utf8); - tmp2 = gaim_markup_strip_html(tmp1); - g_free(tmp1); tmp1 = gaim_escape_html(tmp2); g_free(tmp2); tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); g_free(tmp1); g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); + g_free(tmp2); } }