Mercurial > pidgin
changeset 1898:73d73939f698
[gaim-migrate @ 1908]
this is part one of three.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 28 May 2001 03:36:04 +0000 |
parents | 97b1667e1255 |
children | a2624692260b |
files | ChangeLog plugins/icq/gaim_icq.c src/away.c src/buddy.c src/buddy_chat.c src/conversation.c src/gaim.h src/prpl.h src/server.c |
diffstat | 9 files changed, 117 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri May 25 23:07:22 2001 +0000 +++ b/ChangeLog Mon May 28 03:36:04 2001 +0000 @@ -17,6 +17,8 @@ * Fixed a small issue with HTML not being stripped from log files properly (Thanks, faceprint and David Stoddard) * Can turn on/off Yahoo! Mail announcements + * Can force messages through the server for ICQ (use this if + you have problems sending) version 0.11.0-pre11 (04/30/2001): * Zephyr updates and additions, thanks Neil Sanchala (nsanch)
--- a/plugins/icq/gaim_icq.c Fri May 25 23:07:22 2001 +0000 +++ b/plugins/icq/gaim_icq.c Mon May 28 03:36:04 2001 +0000 @@ -19,6 +19,7 @@ struct icq_data { ICQLINK *link; int cur_status; + GSList *thru_serv; }; static guint ack_timer = 0; @@ -298,15 +299,22 @@ icq_Logout(id->link); icq_Disconnect(id->link); icq_ICQLINKDelete(id->link); + g_slist_free(id->thru_serv); g_free(id); } -static struct prpl *my_protocol = NULL; - static void icq_send_msg(struct gaim_connection *gc, char *who, char *msg, int away) { - struct icq_data *id = (struct icq_data *)gc->proto_data; - if (!away && (strlen(msg) > 0)) - icq_SendMessage(id->link, atol(who), msg, ICQ_SEND_BESTWAY); + if (!away && (strlen(msg) > 0)) { + struct icq_data *id = (struct icq_data *)gc->proto_data; + GSList *l = id->thru_serv; + long w = atol(who); + while (l) { + if (w == (long)l->data) + break; + l = l->next; + } + icq_SendMessage(id->link, w, msg, l ? ICQ_SEND_THRUSERVER : ICQ_SEND_BESTWAY); + } } static void icq_keepalive(struct gaim_connection *gc) { @@ -471,6 +479,44 @@ return m; } +static void toggle_thru_serv(GtkToggleButton *button, struct conversation *c) +{ + struct gaim_connection *gc = gtk_object_get_user_data(GTK_OBJECT(button)); + struct icq_data *id = gc->proto_data; + GSList *l = id->thru_serv; + long who = atol(c->name); + + while (l) { + if (who == (long)l->data) + break; + l = l->next; + } + if (l) + id->thru_serv = g_slist_remove(id->thru_serv, (void *)who); + else + id->thru_serv = g_slist_append(id->thru_serv, (void *)who); +} + +static void icq_insert_convo(struct gaim_connection *gc, struct conversation *c) +{ + GtkWidget *button; + + button = gtk_check_button_new_with_label("Send message through server"); + gtk_box_pack_start(GTK_BOX(c->lbox), button, FALSE, FALSE, 5); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(toggle_thru_serv), c); + gtk_object_set_user_data(GTK_OBJECT(button), gc); + gtk_widget_show(button); +} + +static void icq_remove_convo(struct gaim_connection *gc, struct conversation *c) +{ + while (GTK_BOX(c->lbox)->children) + gtk_container_remove(GTK_CONTAINER(c->lbox), + ((GtkBoxChild *)GTK_BOX(c->lbox)->children->data)->widget); +} + +static struct prpl *my_protocol = NULL; + static void icq_init(struct prpl *ret) { ret->protocol = PROTO_ICQ; ret->name = icq_name; @@ -478,6 +524,8 @@ ret->away_states = icq_away_states; ret->buddy_menu = icq_buddy_menu; ret->user_opts = icq_user_opts; + ret->insert_convo = icq_insert_convo; + ret->remove_convo = icq_remove_convo; ret->login = icq_login; ret->close = icq_close; ret->send_im = icq_send_msg;
--- a/src/away.c Fri May 25 23:07:22 2001 +0000 +++ b/src/away.c Mon May 28 03:36:04 2001 +0000 @@ -71,12 +71,8 @@ cnv = find_conversation(qm->name); if (!cnv) cnv = new_conversation(qm->name); - if (g_slist_index(connections, qm->gc) >= 0) { - cnv->gc = qm->gc; - gtk_option_menu_set_history(GTK_OPTION_MENU(cnv->menu), - g_slist_index(connections, qm->gc)); - update_buttons_by_protocol(cnv); - } + if (g_slist_index(connections, qm->gc) >= 0) + set_convo_gc(cnv, qm->gc); write_to_conv(cnv, qm->message, qm->flags, NULL, qm->tm);
--- a/src/buddy.c Fri May 25 23:07:22 2001 +0000 +++ b/src/buddy.c Mon May 28 03:36:04 2001 +0000 @@ -561,11 +561,7 @@ } else { c = new_conversation(b->name); - c->gc = b->gc; - - gtk_option_menu_set_history(GTK_OPTION_MENU(c->menu), g_slist_index(connections, b->gc)); - - update_buttons_by_protocol(c); + set_convo_gc(c, b->gc); } } @@ -580,12 +576,7 @@ } else { c = new_conversation(b->name); - c->gc = b->connlist->data; - - gtk_option_menu_set_history(GTK_OPTION_MENU(c->menu), - g_slist_index(connections, b->connlist->data)); - - update_buttons_by_protocol(c); + set_convo_gc(c, b->connlist->data); } } @@ -635,11 +626,7 @@ } else { c = new_conversation(b->name); - c->gc = b->connlist->data; - gtk_option_menu_set_history(GTK_OPTION_MENU(c->menu), - g_slist_index(connections, b->connlist->data)); - - update_buttons_by_protocol(c); + set_convo_gc(c, b->connlist->data); } if (display_options & OPT_DISP_ONE_WINDOW) raise_convo_tab(c); @@ -1722,20 +1709,14 @@ if (c == NULL) c = new_conversation(name); - c->gc = u->gc; - gtk_option_menu_set_history(GTK_OPTION_MENU(c->menu), - g_slist_index(connections, u->gc)); - update_buttons_by_protocol(c); + set_convo_gc(c, u->gc); } if (b->options & OPT_POUNCE_SEND_IM) { c = find_conversation(name); if (c == NULL) c = new_conversation(name); - c->gc = u->gc; - gtk_option_menu_set_history(GTK_OPTION_MENU(c->menu), - g_slist_index(connections, u->gc)); - update_buttons_by_protocol(c); + set_convo_gc(c, u->gc); write_to_conv(c, b->message, WFLAG_SEND, NULL, time((time_t)NULL)); serv_send_im(u->gc, name, b->message, 0);
--- a/src/buddy_chat.c Fri May 25 23:07:22 2001 +0000 +++ b/src/buddy_chat.c Mon May 28 03:36:04 2001 +0000 @@ -474,9 +474,7 @@ gdk_window_show(c->window->window); else { c = new_conversation(gtk_object_get_user_data(obj)); - c->gc = b->gc; - gtk_option_menu_set_history(GTK_OPTION_MENU(c->menu), g_slist_index(connections, b->gc)); - update_buttons_by_protocol(c); + set_convo_gc(c, b->gc); } }
--- a/src/conversation.c Fri May 25 23:07:22 2001 +0000 +++ b/src/conversation.c Mon May 28 03:36:04 2001 +0000 @@ -150,6 +150,8 @@ c->history = g_string_new(""); conversations = g_list_append(conversations, c); show_conv(c); + if (c->gc && c->gc->prpl && c->gc->prpl->insert_convo) + (*c->gc->prpl->insert_convo)(c->gc, c); plugin_event(event_new_conversation, name, 0, 0, 0); return c; } @@ -420,6 +422,8 @@ c->window = NULL; } } else { + if (c->gc && c->gc->prpl && c->gc->prpl->remove_convo) + (*c->gc->prpl->remove_convo)(c->gc, c); if (display_options & OPT_DISP_ONE_CHAT_WINDOW) { if (g_list_length(chats) > 1) { gtk_notebook_remove_page(GTK_NOTEBOOK(chat_notebook), @@ -1755,12 +1759,22 @@ return toolbar; } -static void convo_sel_send(GtkObject * m, struct gaim_connection *c) +static void convo_sel_send(GtkObject *m, struct gaim_connection *c) { struct conversation *cnv = gtk_object_get_user_data(m); + + if (cnv->gc == c) + return; + + if (cnv->gc && cnv->gc->prpl && cnv->gc->prpl->remove_convo) + (*cnv->gc->prpl->remove_convo)(cnv->gc, cnv); + cnv->gc = c; update_buttons_by_protocol(cnv); + + if (cnv->gc && cnv->gc->prpl && cnv->gc->prpl->insert_convo) + (*cnv->gc->prpl->insert_convo)(cnv->gc, cnv); } void update_convo_add_button(struct conversation *c) @@ -1846,17 +1860,34 @@ while (c) { C = (struct conversation *)c->data; + c = c->next; + create_convo_menu(C); - if (connections) - C->gc = (struct gaim_connection *)connections->data; - else - C->gc = NULL; + if (g_slist_index(connections, C->gc) < 0) + continue; + + set_convo_gc(C, connections ? connections->data : NULL); + } +} + +void set_convo_gc(struct conversation *c, struct gaim_connection *gc) +{ + if (c->gc == gc) + return; - update_buttons_by_protocol(C); + if (c->gc && c->gc->prpl && c->gc->prpl->remove_convo) + (*c->gc->prpl->remove_convo)(c->gc, c); + + c->gc = gc; - c = c->next; - } + if (gc) + gtk_option_menu_set_history(GTK_OPTION_MENU(c->menu), g_slist_index(connections, gc)); + + update_buttons_by_protocol(c); + + if (c->gc && c->gc->prpl && c->gc->prpl->insert_convo) + (*c->gc->prpl->insert_convo)(c->gc, c); } void update_buttons_by_protocol(struct conversation *c) @@ -2075,6 +2106,10 @@ create_convo_menu(c); + c->lbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox2), c->lbox, FALSE, FALSE, 0); + gtk_widget_show(c->lbox); + entry = gtk_text_new(NULL, NULL); c->entry = entry; if (!(display_options & OPT_DISP_ONE_WINDOW)) @@ -2097,7 +2132,7 @@ gtk_box_pack_start(GTK_BOX(vbox2), entry, TRUE, TRUE, 0); gtk_widget_show(entry); - bbox = gtk_hbox_new(FALSE, 5); + c->bbox = bbox = gtk_hbox_new(FALSE, 5); gtk_box_pack_start(GTK_BOX(vbox2), bbox, FALSE, FALSE, 0); gtk_widget_show(bbox);
--- a/src/gaim.h Fri May 25 23:07:22 2001 +0000 +++ b/src/gaim.h Mon May 28 03:36:04 2001 +0000 @@ -355,6 +355,8 @@ GtkWidget *send; /* stuff used just for IM */ + GtkWidget *lbox; + GtkWidget *bbox; GtkWidget *sw; GtkWidget *info; GtkWidget *warn; @@ -704,6 +706,7 @@ extern void set_font_face(char *, struct conversation *); extern void redo_convo_menus(); extern void toggle_spellchk(); +extern void set_convo_gc(struct conversation *, struct gaim_connection *); extern void update_buttons_by_protocol(struct conversation *); extern void toggle_smileys(); extern void toggle_timestamps();
--- a/src/prpl.h Fri May 25 23:07:22 2001 +0000 +++ b/src/prpl.h Mon May 28 03:36:04 2001 +0000 @@ -79,7 +79,9 @@ void (* user_opts)(GtkWidget *, struct aim_user *); void (* draw_new_user)(GtkWidget *); void (* do_new_user)(); - void (* draw_join_chat) (struct gaim_connection *, GtkWidget *); + void (* draw_join_chat)(struct gaim_connection *, GtkWidget *); + void (* insert_convo)(struct gaim_connection *, struct conversation *); + void (* remove_convo)(struct gaim_connection *, struct conversation *); /* all the server-related functions */ void (* login) (struct aim_user *);
--- a/src/server.c Fri May 25 23:07:22 2001 +0000 +++ b/src/server.c Mon May 28 03:36:04 2001 +0000 @@ -405,11 +405,8 @@ /* we should update the conversation window buttons and menu, if it exists. */ cnv = find_conversation(name); - if (cnv) { - cnv->gc = gc; - gtk_option_menu_set_history(GTK_OPTION_MENU(cnv->menu), g_slist_index(connections, gc)); - update_buttons_by_protocol(cnv); - } + if (cnv) + set_convo_gc(cnv, gc); /* if you can't figure this out, stop reading right now. * "we're not worthy! we're not worthy!" */ @@ -484,10 +481,7 @@ 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); + set_convo_gc(cnv, gc); } if (new_conv && (sound_options & OPT_SOUND_FIRST_RCV)) play_sound(FIRST_RECEIVE); @@ -540,10 +534,7 @@ 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); + set_convo_gc(cnv, gc); } if (new_conv && (sound_options & OPT_SOUND_FIRST_RCV)) play_sound(FIRST_RECEIVE);