Mercurial > pidgin.yaz
changeset 1774:9d0c91c705b7
[gaim-migrate @ 1784]
Fixed a problem with away messages when you're queing received messages.
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Mon, 30 Apr 2001 07:00:15 +0000 |
parents | 6d1d9e988fd4 |
children | 9ca22174da76 |
files | src/aim.c src/away.c src/gaim.h src/server.c |
diffstat | 4 files changed, 80 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/aim.c Mon Apr 30 06:02:06 2001 +0000 +++ b/src/aim.c Mon Apr 30 07:00:15 2001 +0000 @@ -69,6 +69,7 @@ GList *conversations = NULL; GList *chat_rooms = NULL; GSList *message_queue = NULL; +GSList *away_time_queue = NULL; GtkWidget *mainwindow = NULL;
--- a/src/away.c Mon Apr 30 06:02:06 2001 +0000 +++ b/src/away.c Mon Apr 30 07:00:15 2001 +0000 @@ -51,6 +51,9 @@ { if (imaway) gtk_widget_destroy(imaway); + + clistqueue = NULL; + clistqueuesw = NULL; imaway = NULL; } @@ -60,7 +63,6 @@ GSList *templist = message_queue; gtk_clist_freeze(GTK_CLIST(clistqueue)); - gtk_clist_clear(GTK_CLIST(clistqueue)); while (templist) @@ -80,12 +82,23 @@ templist = g_slist_remove(templist, qm); - free(qm); + g_free(qm); + } + + templist = away_time_queue; + + while (templist) + { + struct queued_away_response *qar = (struct queued_away_response *)templist->data; + + templist = g_slist_remove(templist, qar); + g_free(qar); } gtk_clist_thaw(GTK_CLIST(clistqueue)); message_queue = NULL; + away_time_queue = NULL; } void toggle_away_queue()
--- a/src/gaim.h Mon Apr 30 06:02:06 2001 +0000 +++ b/src/gaim.h Mon Apr 30 07:00:15 2001 +0000 @@ -273,6 +273,12 @@ char *message; time_t tm; struct gaim_connection *gc; + time_t sent_away; +}; + +struct queued_away_response { + char name[80]; + time_t sent_away; }; struct away_message { @@ -543,6 +549,7 @@ extern int web_browser; extern GList *aim_users; extern GSList *message_queue; +extern GSList *away_time_queue; extern char sound_cmd[2048]; extern char web_command[2048]; extern struct save_pos blist_pos;
--- a/src/server.c Mon Apr 30 06:02:06 2001 +0000 +++ b/src/server.c Mon Apr 30 07:00:15 2001 +0000 @@ -347,6 +347,26 @@ return i; } +struct queued_away_response *find_queued_away_response_by_name(char *name) +{ + GSList *templist; + struct queued_away_response *qar; + + templist = away_time_queue; + + while (templist) + { + qar = (struct queued_away_response *)templist->data; + + if (!strcmp(name, qar->name)) + return qar; + + templist = templist->next; + } + + return NULL; +} + void serv_got_im(struct gaim_connection *gc, char *name, char *message, int away, time_t mtime) { struct conversation *cnv; @@ -395,10 +415,11 @@ if (general_options & OPT_GEN_QUEUE_WHEN_AWAY) { struct queued_message *qm; + struct queued_away_response *qar; int row; qm = (struct queued_message *)g_new0(struct queued_message, 1); - snprintf(qm->name, sizeof(qm->name), "%s", name); + g_snprintf(qm->name, sizeof(qm->name), "%s", name); qm->message = strdup(message); qm->gc = gc; qm->tm = mtime; @@ -412,7 +433,7 @@ qtotal = find_queue_total_by_name(qm->name); - snprintf(number, 32, _("(%d messages)"), ++qtotal); + g_snprintf(number, 32, _("(%d messages)"), ++qtotal); gtk_clist_set_text(GTK_CLIST(clistqueue), row, 1, number); } @@ -420,11 +441,14 @@ { gchar *heh[2]; + int tmp = 0; - heh[0] = strdup(qm->name); - heh[1] = strdup(_("(1 message)")); + heh[0] = g_strdup(qm->name); + heh[1] = g_strdup(_("(1 message)")); gtk_clist_append(GTK_CLIST(clistqueue), heh); + row = find_queue_row_by_name(qm->name); + g_free(heh[0]); g_free(heh[1]); } @@ -481,17 +505,42 @@ char *tmpmsg; struct buddy *b = find_buddy(gc, name); char *alias = b ? b->show : name; + int sawy; + int row; + struct queued_away_response *qar = NULL; time(&t); + if (cnv) + sawy = cnv->sent_away; + else + { + qar = find_queued_away_response_by_name(name); + + if (!qar) + { + qar = (struct queued_away_response *)g_new0(struct queued_away_response, 1); + + g_snprintf(qar->name, sizeof(qar->name), "%s", name); + qar->sent_away = 0; + + away_time_queue = g_slist_append(away_time_queue, qar); + } + + sawy = qar->sent_away; + } + + if ((t - sawy) < 120) + return; + /* apply default fonts and colors */ tmpmsg = stylize(gc->away, MSG_LEN); serv_send_im(gc, name, away_subs(tmpmsg, alias), 1); - if ((cnv == NULL) || (t - cnv->sent_away) < 120) - return; - - cnv->sent_away = t; + if (cnv) + cnv->sent_away = t; + else if (qar) + qar->sent_away = t; if (cnv != NULL) write_to_conv(cnv, away_subs(tmpmsg, alias), WFLAG_SEND | WFLAG_AUTO, NULL, mtime);