Mercurial > pidgin
changeset 1773:6d1d9e988fd4
[gaim-migrate @ 1783]
Away message queueue thingy.
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Mon, 30 Apr 2001 06:02:06 +0000 |
parents | 896432d66303 |
children | 9d0c91c705b7 |
files | ChangeLog src/away.c src/gaim.h src/prefs.c src/server.c |
diffstat | 5 files changed, 180 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Apr 30 01:58:24 2001 +0000 +++ b/ChangeLog Mon Apr 30 06:02:06 2001 +0000 @@ -19,6 +19,7 @@ * MSN Properly handles URL decoding of 'friendly' names * Redesigned Preferences pages (design by DennisR) * Can select where tabs are for tabbed IM/Chat windows + * Option to queue away messages while away version 0.11.0-pre10 (04/13/2001): * Many, many bug fixes
--- a/src/away.c Mon Apr 30 01:58:24 2001 +0000 +++ b/src/away.c Mon Apr 30 06:02:06 2001 +0000 @@ -40,6 +40,9 @@ GtkWidget *imaway = NULL; GtkWidget *awaymenu = NULL; +GtkWidget *clistqueue = NULL; +GtkWidget *clistqueuesw; + struct away_message *awaymessage = NULL; struct away_message *default_away; int auto_away; @@ -51,24 +54,66 @@ imaway = NULL; } +void purge_away_queue() +{ + struct conversation *cnv; + GSList *templist = message_queue; + + gtk_clist_freeze(GTK_CLIST(clistqueue)); + + gtk_clist_clear(GTK_CLIST(clistqueue)); + + while (templist) + { + struct queued_message *qm = (struct queued_message *)templist->data; + + cnv = find_conversation(qm->name); + + if (!cnv) + cnv = new_conversation(qm->name); + + cnv->gc = qm->gc; + + write_to_conv(cnv, qm->message, WFLAG_RECV, NULL, qm->tm); + + free(qm->message); + + templist = g_slist_remove(templist, qm); + + free(qm); + } + + gtk_clist_thaw(GTK_CLIST(clistqueue)); + + message_queue = NULL; +} + +void toggle_away_queue() +{ + if (!clistqueue || !clistqueuesw) + return; + + if (general_options & OPT_GEN_QUEUE_WHEN_AWAY) + { + gtk_widget_show(clistqueue); + gtk_widget_show(clistqueuesw); + } + else + { + gtk_widget_hide(clistqueue); + gtk_widget_hide(clistqueuesw); + purge_away_queue(); + } + +} + void do_im_back(GtkWidget *w, GtkWidget *x) { if (imaway) { GtkWidget *tmp = imaway; - /*GSList *templist = message_queue; - - while (templist) - { - struct queued_message *qm = (struct queued_message *)templist->data; - free(qm->message); - - message_queue = g_slist_remove(message_queue, qm); + purge_away_queue(); - free(qm); - } - */ - imaway = NULL; gtk_widget_destroy(tmp); if (w != tmp) @@ -120,7 +165,7 @@ vscrollbar = gtk_vscrollbar_new(GTK_TEXT(awaytext)->vadj); gtk_widget_show(vscrollbar); - gtk_widget_set_usize(awaytext, 225, 100); + gtk_widget_set_usize(awaytext, 245, 120); gtk_text_set_word_wrap(GTK_TEXT(awaytext), TRUE); gtk_widget_show(awaytext); gtk_text_freeze(GTK_TEXT(awaytext)); @@ -130,8 +175,19 @@ if (display_options & OPT_DISP_COOL_LOOK) gtk_button_set_relief(GTK_BUTTON(back), GTK_RELIEF_NONE); + clistqueuesw = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(clistqueuesw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + + clistqueue = gtk_clist_new(2); + gtk_clist_set_column_width(GTK_CLIST(clistqueue), 0, 100); + gtk_widget_set_usize(GTK_WIDGET(clistqueue), -1, 50); + gtk_container_add(GTK_CONTAINER(clistqueuesw), clistqueue); + /* Put the buttons in the box */ gtk_box_pack_start(GTK_BOX(vbox), awaytext, TRUE, TRUE, 0); + + gtk_box_pack_start(GTK_BOX(vbox), clistqueuesw, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(vbox), back, FALSE, FALSE, 0); /* Handle closes right */ @@ -139,6 +195,12 @@ gtk_signal_connect(GTK_OBJECT(back), "clicked", GTK_SIGNAL_FUNC(do_im_back), imaway); /* Finish up */ + if (general_options & OPT_GEN_QUEUE_WHEN_AWAY) + { + gtk_widget_show(clistqueuesw); + gtk_widget_show(clistqueue); + } + gtk_widget_show(back); gtk_widget_show(vbox); if (strlen(a->name))
--- a/src/gaim.h Mon Apr 30 01:58:24 2001 +0000 +++ b/src/gaim.h Mon Apr 30 06:02:06 2001 +0000 @@ -426,6 +426,7 @@ extern struct away_message *default_away; extern int auto_away; extern GtkWidget *awaymenu; +extern GtkWidget *clistqueue; /* Globals in prpl.c */ extern GtkWidget *protomenu; @@ -463,6 +464,7 @@ #define OPT_GEN_CTL_ENTER 0x02000000 #define OPT_GEN_F2_TOGGLES 0x04000000 #define OPT_GEN_NO_AUTO_RESP 0x08000000 +#define OPT_GEN_QUEUE_WHEN_AWAY 0x10000000 extern int display_options; #define OPT_DISP_SHOW_TIME 0x00000001 @@ -719,6 +721,8 @@ extern void do_away_menu(); extern void away_list_unclicked(GtkWidget *, struct away_message *); extern void away_list_clicked(GtkWidget *, struct away_message *); +extern void toggle_away_queue(); +extern void purge_away_queue(); /* Functions in aim.c */ extern void show_login();
--- a/src/prefs.c Mon Apr 30 01:58:24 2001 +0000 +++ b/src/prefs.c Mon Apr 30 06:02:06 2001 +0000 @@ -431,6 +431,7 @@ gaim_button(_("Show URLs as links"), &general_options, OPT_GEN_SEND_LINKS, vbox); gaim_button(_("Highlight misspelled words"), &general_options, OPT_GEN_CHECK_SPELLING, vbox); gaim_button(_("Sending messages removes away status"), &general_options, OPT_GEN_BACK_ON_IM, vbox); + gaim_button(_("Queue new messages when away"), &general_options, OPT_GEN_QUEUE_WHEN_AWAY, vbox); vbox = gtk_vbox_new(TRUE, 5); gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 5); @@ -2213,6 +2214,9 @@ if ((int)option == OPT_GEN_CHECK_SPELLING) toggle_spellchk(); + if ((int)option == OPT_GEN_QUEUE_WHEN_AWAY) + toggle_away_queue(); + save_prefs(); }
--- a/src/server.c Mon Apr 30 01:58:24 2001 +0000 +++ b/src/server.c Mon Apr 30 06:02:06 2001 +0000 @@ -309,6 +309,44 @@ serv_touch_idle(g); } +int find_queue_row_by_name(char *name) +{ + GSList *templist; + char *temp; + int i; + + templist = message_queue; + + for (i = 0; i < GTK_CLIST(clistqueue)->rows; i++) + { + gtk_clist_get_text(GTK_CLIST(clistqueue), i, 0, &temp); + + if (!strcmp(name, temp)) + return i; + } + + return -1; +} + +int find_queue_total_by_name(char *name) +{ + GSList *templist; + int i = 0; + + templist = message_queue; + + while (templist) + { + struct queued_message *qm = (struct queued_message *)templist->data; + if (!strcmp(name, qm->name)) + i++; + + templist = templist->next; + } + + return i; +} + void serv_got_im(struct gaim_connection *gc, char *name, char *message, int away, time_t mtime) { struct conversation *cnv; @@ -354,32 +392,65 @@ away = WFLAG_AUTO; if (gc->away) { - if (!(general_options & OPT_GEN_DISCARD_WHEN_AWAY)) { - if (cnv == NULL) { - new_conv = 1; - cnv = new_conversation(name); - cnv->gc = gc; - gtk_option_menu_set_history(GTK_OPTION_MENU(cnv->menu), - g_slist_index(connections, gc)); - update_buttons_by_protocol(cnv); - } - } else { - return; - } - if (cnv != NULL) { + if (general_options & OPT_GEN_QUEUE_WHEN_AWAY) + { struct queued_message *qm; - if (cnv->makesound && (sound_options & OPT_SOUND_RECV)) - play_sound(RECEIVE); - /* + int row; + qm = (struct queued_message *)g_new0(struct queued_message, 1); snprintf(qm->name, sizeof(qm->name), "%s", name); qm->message = strdup(message); qm->gc = gc; qm->tm = mtime; + row = find_queue_row_by_name(qm->name); + + if (row >= 0) + { + char number[32]; + int qtotal; + + qtotal = find_queue_total_by_name(qm->name); + + snprintf(number, 32, _("(%d messages)"), ++qtotal); + + gtk_clist_set_text(GTK_CLIST(clistqueue), row, 1, number); + } + else + { + + gchar *heh[2]; + + heh[0] = strdup(qm->name); + heh[1] = strdup(_("(1 message)")); + gtk_clist_append(GTK_CLIST(clistqueue), heh); + + g_free(heh[0]); + g_free(heh[1]); + } + message_queue = g_slist_append(message_queue, qm); - */ - write_to_conv(cnv, message, away | WFLAG_RECV, NULL, mtime); + } + else + { + if (!(general_options & OPT_GEN_DISCARD_WHEN_AWAY)) { + if (cnv == NULL) { + new_conv = 1; + cnv = new_conversation(name); + cnv->gc = gc; + gtk_option_menu_set_history(GTK_OPTION_MENU(cnv->menu), + g_slist_index(connections, gc)); + update_buttons_by_protocol(cnv); + } + } else { + return; + } + if (cnv != NULL) { + if (cnv->makesound && (sound_options & OPT_SOUND_RECV)) + play_sound(RECEIVE); + + write_to_conv(cnv, message, away | WFLAG_RECV, NULL, mtime); + } } } else { @@ -393,10 +464,12 @@ } if (new_conv && (sound_options & OPT_SOUND_FIRST_RCV)) { play_sound(FIRST_RECEIVE); - } else { + } else + { if (cnv->makesound && (sound_options & OPT_SOUND_RECV)) play_sound(RECEIVE); } + write_to_conv(cnv, message, away | WFLAG_RECV, NULL, mtime); } @@ -411,19 +484,18 @@ time(&t); + /* 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; - /* apply default fonts and colors */ - tmpmsg = stylize(gc->away, MSG_LEN); - - serv_send_im(gc, name, away_subs(tmpmsg, alias), 1); - if (cnv != NULL) write_to_conv(cnv, away_subs(tmpmsg, alias), WFLAG_SEND | WFLAG_AUTO, NULL, mtime); + g_free(tmpmsg); } }