changeset 964:2cd7b73e2c9a

[gaim-migrate @ 974] damn i'm smooth. chat is working now. :) committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 10 Oct 2000 10:04:59 +0000
parents c1fb7afe4fd7
children 50f2977537d8
files FIXME po/POTFILES.in src/aim.c src/buddy_chat.c src/conversation.c src/gaim.h src/multi.h src/oscar.c src/perl.c src/server.c src/toc.c
diffstat 11 files changed, 188 insertions(+), 161 deletions(-) [+]
line wrap: on
line diff
--- a/FIXME	Tue Oct 10 09:14:26 2000 +0000
+++ b/FIXME	Tue Oct 10 10:04:59 2000 +0000
@@ -23,6 +23,5 @@
 7. Get rid of dologin. Signons should be handled differently. The account editor should have final
    control over this. DONE
 8. I seriously doubt the applet will compile. If it compiles it definitely won't run.
-9. Chat is broken. Don't even try to join a room. It won't work.
 
 And that's just the large things. There are countless trivial issues that need to be addressed.
--- a/po/POTFILES.in	Tue Oct 10 09:14:26 2000 +0000
+++ b/po/POTFILES.in	Tue Oct 10 10:04:59 2000 +0000
@@ -14,4 +14,5 @@
 src/plugins.c
 src/prefs.c
 src/rvous.c
+src/server.c
 src/toc.c
--- a/src/aim.c	Tue Oct 10 09:14:26 2000 +0000
+++ b/src/aim.c	Tue Oct 10 10:04:59 2000 +0000
@@ -61,7 +61,6 @@
 GList *buddy_pounces = NULL;
 GSList *away_messages = NULL;
 GSList *groups = NULL;
-GList *buddy_chats = NULL;
 GList *conversations = NULL;
 GList *chat_rooms = NULL;
 
--- a/src/buddy_chat.c	Tue Oct 10 09:14:26 2000 +0000
+++ b/src/buddy_chat.c	Tue Oct 10 10:04:59 2000 +0000
@@ -38,6 +38,7 @@
 #include "pixmaps/close.xpm"
 
 static GtkWidget *joinchat;
+static struct gaim_connection *joinchatgc;
 static GtkWidget *entry;
 static GtkWidget *invite;
 static GtkWidget *inviteentry;
@@ -60,25 +61,6 @@
 }
 
 
-struct conversation *find_chat(char *name)
-{
-	char cuser[64];
-	struct conversation *c = NULL;
-	GList *cnv = buddy_chats;
-
-	strcpy(cuser, normalize(name));
-
-	while (cnv) {
-		c = (struct conversation *)cnv->data;
-		if (!strcasecmp(cuser, normalize(c->name))) {
-			return c;
-		}
-		cnv = cnv->next;
-	}
-	return NULL;
-}
-
-
 static void do_join_chat()
 {
 	char *group;
@@ -86,12 +68,47 @@
 	group = gtk_entry_get_text(GTK_ENTRY(entry));
 
         if (joinchat) {
-                serv_join_chat(community + 4, group);
+                serv_join_chat(joinchatgc, community + 4, group);
 		gtk_widget_destroy(joinchat);
 	}
 	joinchat=NULL;
 }
 
+static void joinchat_choose(GtkWidget *w, struct gaim_connection *g)
+{
+	joinchatgc = g;
+}
+
+
+static void create_joinchat_menu(GtkWidget *box)
+{
+	GtkWidget *optmenu;
+	GtkWidget *menu;
+	GtkWidget *opt;
+	GSList *c = connections;
+	struct gaim_connection *g;
+
+	optmenu = gtk_option_menu_new();
+	gtk_box_pack_start(GTK_BOX(box), optmenu, FALSE, FALSE, 5);
+	gtk_widget_show(optmenu);
+
+	menu = gtk_menu_new();
+
+	while (c) {
+		g = (struct gaim_connection *)c->data;
+		opt = gtk_menu_item_new_with_label(g->username);
+		gtk_object_set_user_data(GTK_OBJECT(opt), g);
+		gtk_signal_connect(GTK_OBJECT(opt), "activate", GTK_SIGNAL_FUNC(joinchat_choose), g);
+		gtk_menu_append(GTK_MENU(menu), opt);
+		gtk_widget_show(opt);
+		c = c->next;
+	}
+
+	gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
+	gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), 0);
+
+	joinchatgc = connections->data;
+}
 
 
 void join_chat()
@@ -112,24 +129,48 @@
                                       "Gaim");
 		gtk_window_set_policy(GTK_WINDOW(joinchat), FALSE, FALSE, TRUE);
 		gtk_widget_realize(joinchat);
-		bbox = gtk_hbox_new(TRUE, 10);
-		topbox = gtk_hbox_new(FALSE, 5);
-		vbox = gtk_vbox_new(FALSE, 5);
-		entry = gtk_entry_new();
-		hbox = gtk_hbox_new(TRUE, 10);
+		gtk_signal_connect(GTK_OBJECT(joinchat), "delete_event",
+			   GTK_SIGNAL_FUNC(destroy_join_chat), joinchat);
+		gtk_window_set_title(GTK_WINDOW(joinchat), _("Join Chat"));
+		gtk_container_set_border_width(GTK_CONTAINER(joinchat), 5);
+		aol_icon(joinchat->window);
 
 		frame = gtk_frame_new(_("Buddy Chat"));
+                gtk_container_add(GTK_CONTAINER(joinchat), frame);
+		gtk_widget_show(frame);
 
-		join = picture_button(joinchat, _("Join"), join_xpm);
-		cancel = picture_button(joinchat, _("Cancel"), cancel_xpm);
+		vbox = gtk_vbox_new(FALSE, 5);
+		gtk_container_add(GTK_CONTAINER(frame), vbox);
+		gtk_widget_show(vbox);
 
-		gtk_box_pack_start(GTK_BOX(bbox), join, FALSE, FALSE, 5);
-		gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5);
+		topbox = gtk_hbox_new(FALSE, 5);
+		gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5);
+		gtk_widget_show(topbox);
 
 		label = gtk_label_new(_("Join what group:"));
+		gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5);
 		gtk_widget_show(label);
-		gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5);
+
+		entry = gtk_entry_new();
 		gtk_box_pack_start(GTK_BOX(topbox), entry, FALSE, FALSE, 5);
+		gtk_signal_connect(GTK_OBJECT(entry), "activate",
+			   GTK_SIGNAL_FUNC(do_join_chat), joinchat);
+		gtk_window_set_focus(GTK_WINDOW(joinchat), entry);
+		gtk_widget_show(entry);
+
+		hbox = gtk_hbox_new(TRUE, 10);
+		gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+		gtk_widget_show(hbox);
+
+		label = gtk_label_new(_("Join Chat As:"));
+		gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+		gtk_widget_show(label);
+
+		create_joinchat_menu(hbox);
+
+		hbox = gtk_hbox_new(TRUE, 10);
+		gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+		gtk_widget_show(hbox);
 
 		opt = gtk_radio_button_new_with_label(NULL,
 							_("AIM Private Chats"));
@@ -144,38 +185,19 @@
 		gtk_box_pack_start(GTK_BOX(hbox), opt, FALSE, FALSE, 0);
 		gtk_widget_show(opt);
 
-		/* And the boxes in the box */
-		gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5);
-		gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+		bbox = gtk_hbox_new(TRUE, 10);
 		gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 5);
-		
-		/* Handle closes right */
-		gtk_signal_connect(GTK_OBJECT(joinchat), "delete_event",
-			   GTK_SIGNAL_FUNC(destroy_join_chat), joinchat);
+		gtk_widget_show(bbox);
 
-		gtk_signal_connect(GTK_OBJECT(cancel), "clicked",
-			   GTK_SIGNAL_FUNC(destroy_join_chat), joinchat);
+		join = picture_button(joinchat, _("Join"), join_xpm);
+		gtk_box_pack_start(GTK_BOX(bbox), join, FALSE, FALSE, 5);
 		gtk_signal_connect(GTK_OBJECT(join), "clicked",
 			   GTK_SIGNAL_FUNC(do_join_chat), joinchat);
-		gtk_signal_connect(GTK_OBJECT(entry), "activate",
-			   GTK_SIGNAL_FUNC(do_join_chat), joinchat);
-		/* Finish up */
-		gtk_widget_show(join);
-		gtk_widget_show(cancel);
-		gtk_widget_show(entry);
-		gtk_widget_show(topbox);
-		gtk_widget_show(hbox);
-		gtk_widget_show(bbox);
-		gtk_widget_show(vbox);
-		gtk_widget_show(frame);
-		gtk_container_add(GTK_CONTAINER(frame), vbox);
-		gtk_window_set_title(GTK_WINDOW(joinchat), _("Join Chat"));
-		gtk_window_set_focus(GTK_WINDOW(joinchat), entry);
-                gtk_container_add(GTK_CONTAINER(joinchat), frame);
-		gtk_container_set_border_width(GTK_CONTAINER(joinchat), 5);
-                gtk_widget_realize(joinchat);
-		aol_icon(joinchat->window);
 
+		cancel = picture_button(joinchat, _("Cancel"), cancel_xpm);
+		gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5);
+		gtk_signal_connect(GTK_OBJECT(cancel), "clicked",
+			   GTK_SIGNAL_FUNC(destroy_join_chat), joinchat);
 	}
 	gtk_widget_show(joinchat);
 }
@@ -195,7 +217,7 @@
 	mess = gtk_entry_get_text(GTK_ENTRY(invitemess));
 
         if (invite) {
-                serv_chat_invite(b->id, mess, buddy);
+                serv_chat_invite(b->gc, b->id, mess, buddy);
 		gtk_widget_destroy(invite);
 	}
 	invite=NULL;
@@ -359,7 +381,7 @@
 	gtk_editable_delete_text(GTK_EDITABLE(b->entry), 0, -1);
 
         escape_text(buf); /* it's ok to leave this here because oscar can't whisper */
-        serv_chat_whisper(b->id, who, buf);
+        serv_chat_whisper(b->gc, b->id, who, buf);
                           
 	g_snprintf(buf2, sizeof(buf2), "%s->%s", b->gc->username, who);
 
@@ -705,7 +727,8 @@
 void handle_click_chat(GtkWidget *widget, GdkEventButton *event, struct chat_room *cr)
 {
         if (event->type == GDK_2BUTTON_PRESS && event->button == 1) {
-                serv_join_chat(cr->exchange, cr->name);
+		/* FIXME */
+                serv_join_chat(connections->data, cr->exchange, cr->name);
         }
 }
 
@@ -779,22 +802,30 @@
 
 void update_chat_button_pix()
 {
-	GList *bcs = buddy_chats;
-	struct conversation *c;
-	int opt = 1;
+	GSList *C = connections;
+	struct gaim_connection *g;
+
+	while (C) {
+		GSList *bcs;
+		struct conversation *c;
+		int opt = 1;
+		g = (struct gaim_connection *)C->data;
+		bcs = g->buddy_chats;
 
-	while (bcs) {
-		c = (struct conversation *)bcs->data;
-		c->send = change_text(c->window, _("Send"), c->send, tmp_send_xpm, opt);
-		c->whisper = change_text(c->window, _("Whisper"), c->whisper, tb_forward_xpm, opt);
-		c->invite = change_text(c->window, _("Invite"), c->invite, join_xpm, opt);
-		c->close = change_text(c->window, _("Close"), c->close, cancel_xpm, opt);
-		gtk_object_set_user_data(GTK_OBJECT(c->close), c);
-		gtk_signal_connect(GTK_OBJECT(c->close), "clicked", GTK_SIGNAL_FUNC(close_callback),c);
-		gtk_signal_connect(GTK_OBJECT(c->send), "clicked", GTK_SIGNAL_FUNC(send_callback),c);
-		gtk_signal_connect(GTK_OBJECT(c->invite), "clicked", GTK_SIGNAL_FUNC(invite_callback),c);
-		gtk_signal_connect(GTK_OBJECT(c->whisper), "clicked", GTK_SIGNAL_FUNC(whisper_callback),c);
-		bcs = bcs->next;
+		while (bcs) {
+			c = (struct conversation *)bcs->data;
+			c->send = change_text(c->window, _("Send"), c->send, tmp_send_xpm, opt);
+			c->whisper = change_text(c->window, _("Whisper"), c->whisper, tb_forward_xpm, opt);
+			c->invite = change_text(c->window, _("Invite"), c->invite, join_xpm, opt);
+			c->close = change_text(c->window, _("Close"), c->close, cancel_xpm, opt);
+			gtk_object_set_user_data(GTK_OBJECT(c->close), c);
+			gtk_signal_connect(GTK_OBJECT(c->close), "clicked", GTK_SIGNAL_FUNC(close_callback),c);
+			gtk_signal_connect(GTK_OBJECT(c->send), "clicked", GTK_SIGNAL_FUNC(send_callback),c);
+			gtk_signal_connect(GTK_OBJECT(c->invite), "clicked", GTK_SIGNAL_FUNC(invite_callback),c);
+			gtk_signal_connect(GTK_OBJECT(c->whisper), "clicked", GTK_SIGNAL_FUNC(whisper_callback),c);
+			bcs = bcs->next;
+		}
+		C = C->next;
 	}
 }
 
--- a/src/conversation.c	Tue Oct 10 09:14:26 2000 +0000
+++ b/src/conversation.c	Tue Oct 10 10:04:59 2000 +0000
@@ -249,6 +249,9 @@
 
 void update_log_convs()
 {
+	GSList *C = connections;
+	struct gaim_connection *g;
+	GSList *bcs;
 	GList *cnv = conversations;
 	struct conversation *c;
 
@@ -261,14 +264,18 @@
 		cnv = cnv->next;
 	}
 
-	cnv = buddy_chats;
-	while(cnv) {
-		c = (struct conversation *)cnv->data;
+	while (C) {
+		g = (struct gaim_connection *)C->data;
+		bcs = g->buddy_chats;
+		while(bcs) {
+			c = (struct conversation *)bcs->data;
 
-		if (c->log_button)
-			gtk_widget_set_sensitive(c->log_button, ((general_options & OPT_GEN_LOG_ALL)) ? FALSE : TRUE);
+			if (c->log_button)
+				gtk_widget_set_sensitive(c->log_button, ((general_options & OPT_GEN_LOG_ALL)) ? FALSE : TRUE);
 
-		cnv = cnv->next;
+			bcs = bcs->next;
+		}
+		C = C->next;
 	}
 }
 
@@ -381,7 +388,7 @@
 	c->log_dialog = NULL;
 
 	if (c->is_chat) {
-		serv_chat_leave(c->id);
+		serv_chat_leave(c->gc, c->id);
 	} else {
 		if (c->is_direct) {
 			if (c->gc->protocol == PROTO_OSCAR) {
@@ -694,7 +701,7 @@
 		if (c->makesound && (sound_options & OPT_SOUND_SEND))
 			play_sound(SEND);
 	} else {
-		serv_chat_send(c->id, buf);
+		serv_chat_send(c->gc, c->id, buf);
 
 		/* no sound because we do that when we receive our message */
 	}
--- a/src/gaim.h	Tue Oct 10 09:14:26 2000 +0000
+++ b/src/gaim.h	Tue Oct 10 10:04:59 2000 +0000
@@ -470,7 +470,6 @@
 extern GList *buddy_pounces;
 extern GSList *away_messages;
 extern GSList *groups;
-extern GList *buddy_chats;
 extern GList *conversations;
 extern GList *chat_rooms;
 extern GtkWidget *mainwindow;
@@ -580,7 +579,6 @@
 
 /* Functions in buddy_chat.c */
 extern void join_chat();
-extern struct conversation *find_chat(char *name);
 extern void chat_write(struct conversation *, char *, int, char *);
 extern void add_chat_buddy(struct conversation *, char *);
 extern void remove_chat_buddy(struct conversation *, char *);
@@ -648,12 +646,12 @@
 extern void serv_warn(char *, int);
 extern void serv_set_dir(char *, char *, char *, char *, char *, char *, char *, int);
 extern void serv_dir_search(char *, char *, char *, char *, char *, char *, char *, char *);
-extern void serv_accept_chat(int);
-extern void serv_join_chat(int, char *);
-extern void serv_chat_invite(int, char *, char *);
-extern void serv_chat_leave(int);
-extern void serv_chat_whisper(int, char *, char *);
-extern void serv_chat_send(int, char *);
+extern void serv_accept_chat(struct gaim_connection *, int);
+extern void serv_join_chat(struct gaim_connection *, int, char *);
+extern void serv_chat_invite(struct gaim_connection *, int, char *, char *);
+extern void serv_chat_leave(struct gaim_connection *, int);
+extern void serv_chat_whisper(struct gaim_connection *, int, char *, char *);
+extern void serv_chat_send(struct gaim_connection *, int, char *);
 extern void serv_do_imimage(GtkWidget *, char *);
 extern void serv_got_imimage(struct gaim_connection *, char *, char *, char *, struct aim_conn_t *, int);
 
@@ -661,10 +659,10 @@
 extern void serv_got_update(char *, int, int, time_t, time_t, int, u_short);
 extern void serv_got_im(struct gaim_connection *, char *, char *, int);
 extern void serv_got_eviled(char *, int);
-extern void serv_got_chat_invite(char *, int, char *, char *);
-extern void serv_got_joined_chat(int, char *);
-extern void serv_got_chat_left(int);
-extern void serv_got_chat_in(int, char *, int, char *);
+extern void serv_got_chat_invite(struct gaim_connection *, char *, int, char *, char *);
+extern void serv_got_joined_chat(struct gaim_connection *, int, char *);
+extern void serv_got_chat_left(struct gaim_connection *, int);
+extern void serv_got_chat_in(struct gaim_connection *, int, char *, int, char *);
 extern void serv_rvous_accept(char *, char *, char *);
 extern void serv_rvous_cancel(char *, char *, char *);
 
--- a/src/multi.h	Tue Oct 10 09:14:26 2000 +0000
+++ b/src/multi.h	Tue Oct 10 10:04:59 2000 +0000
@@ -48,6 +48,7 @@
 	char *create_name;
 
 	GSList *oscar_chats;
+	GSList *buddy_chats;
 
 	/* that's all we need for oscar. now then, on to TOC.... */
 	int toc_fd;
--- a/src/oscar.c	Tue Oct 10 09:14:26 2000 +0000
+++ b/src/oscar.c	Tue Oct 10 10:04:59 2000 +0000
@@ -448,6 +448,7 @@
 int gaim_server_ready(struct aim_session_t *sess,
 		      struct command_rx_struct *command, ...) {
 	static int id = 1;
+	struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess);
 	switch (command->conn->type) {
 	case AIM_CONN_TYPE_BOS:
 		aim_setversions(sess, command->conn);
@@ -471,7 +472,7 @@
 		aim_bos_reqrate(sess, command->conn);
 		aim_bos_ackrateresp(sess, command->conn);
 		aim_chat_clientready(sess, command->conn);
-		serv_got_joined_chat(id++, aim_chat_getname(command->conn));
+		serv_got_joined_chat(gc, id++, aim_chat_getname(command->conn));
 		break;
 	case AIM_CONN_TYPE_RENDEZVOUS:
 		aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_directim_incoming, 0);
@@ -736,7 +737,8 @@
 			lang     = va_arg(ap, char *);
 			va_end(ap);
 
-			serv_got_chat_invite(roominfo->name,
+			serv_got_chat_invite(gc,
+					     roominfo->name,
 					     roominfo->exchange,
 					     userinfo->sn,
 					     msg);
@@ -1000,8 +1002,9 @@
 	va_list ap;
 	int count, i = 0;
 	struct aim_userinfo_s *info;
+	struct gaim_connection *g = find_gaim_conn_by_aim_sess(sess);
 
-	GList *bcs = buddy_chats;
+	GSList *bcs = g->buddy_chats;
 	struct conversation *b = NULL;
 
 	va_start(ap, command);
@@ -1030,8 +1033,9 @@
 	va_list ap;
 	int count, i = 0;
 	struct aim_userinfo_s *info;
+	struct gaim_connection *g = find_gaim_conn_by_aim_sess(sess);
 
-	GList *bcs = buddy_chats;
+	GSList *bcs = g->buddy_chats;
 	struct conversation *b = NULL;
 
 	va_start(ap, command);
@@ -1066,8 +1070,9 @@
 	va_list ap;
 	struct aim_userinfo_s *info;
 	char *msg;
+	struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess);
 
-	GList *bcs = buddy_chats;
+	GSList *bcs = gc->buddy_chats;
 	struct conversation *b = NULL;
 
 	va_start(ap, command);
@@ -1084,7 +1089,7 @@
 	if (!b)
 		return 0;
 
-	serv_got_chat_in(b->id, info->sn, 0, msg);
+	serv_got_chat_in(gc, b->id, info->sn, 0, msg);
 
 	return 1;
 }
--- a/src/perl.c	Tue Oct 10 09:14:26 2000 +0000
+++ b/src/perl.c	Tue Oct 10 10:04:59 2000 +0000
@@ -476,6 +476,7 @@
 
 XS (XS_AIM_print_to_chat)
 {
+	/* FIXME: need to make this multi-connection based
 	char *nick, *what;
 	struct conversation *c = NULL;
 	GList *bcs = buddy_chats;
@@ -495,6 +496,7 @@
 	if (!c)
 		XSRETURN(0);
 	serv_chat_send(c->id, what);
+	*/
 }
 
 int perl_event(char *event, char *args)
--- a/src/server.c	Tue Oct 10 09:14:26 2000 +0000
+++ b/src/server.c	Tue Oct 10 10:04:59 2000 +0000
@@ -35,6 +35,9 @@
 #include "multi.h"
 #include "gaim.h"
 
+#include "pixmaps/ok.xpm"
+#include "pixmaps/cancel.xpm"
+
 int correction_time = 0;
 
 struct gaim_connection *serv_login(char *username, char *password)
@@ -511,25 +514,21 @@
 }
 
 
-void serv_accept_chat(int i)
+void serv_accept_chat(struct gaim_connection *g, int i)
 {
-	/* FIXME */
-	struct gaim_connection *g = connections->data;
 	if (g->protocol == PROTO_TOC) {
 	        char *buf = g_malloc(256);
 	        g_snprintf(buf, 255, "toc_chat_accept %d",  i);
 	        sflap_send(g, buf, -1, TYPE_DATA);
 	        g_free(buf);
 	} else if (g->protocol == PROTO_OSCAR) {
-	/* this should never get called because libfaim doesn't use the id
-	 * (i'm not even sure Oscar does). go through serv_join_chat instead */
+		/* this should never get called because libfaim doesn't use the id
+		 * (i'm not even sure Oscar does). go through serv_join_chat instead */
 	}
 }
 
-void serv_join_chat(int exchange, char *name)
+void serv_join_chat(struct gaim_connection *g, int exchange, char *name)
 {
-	/* FIXME */
-	struct gaim_connection *g = connections->data;
 	if (g->protocol == PROTO_TOC) {
 	        char buf[BUF_LONG];
 	        g_snprintf(buf, sizeof(buf)/2, "toc_chat_join %d \"%s\"", exchange, name);
@@ -551,16 +550,14 @@
 	}
 }
 
-void serv_chat_invite(int id, char *message, char *name)
+void serv_chat_invite(struct gaim_connection *g, int id, char *message, char *name)
 {
-	/* FIXME */
-	struct gaim_connection *g = connections->data;
 	if (g->protocol == PROTO_TOC) {
 	        char buf[BUF_LONG];
 	        g_snprintf(buf, sizeof(buf)/2, "toc_chat_invite %d \"%s\" %s", id, message, normalize(name));
 	        sflap_send(g, buf, -1, TYPE_DATA);
 	} else if (g->protocol == PROTO_OSCAR) {
-		GList *bcs = buddy_chats;
+		GSList *bcs = g->buddy_chats;
 		struct conversation *b = NULL;
 
 		while (bcs) {
@@ -578,17 +575,15 @@
 	}
 }
 
-void serv_chat_leave(int id)
+void serv_chat_leave(struct gaim_connection *g, int id)
 {
-	/* FIXME */
-	struct gaim_connection *g = connections->data;
 	if (g->protocol == PROTO_TOC) {
 	        char *buf = g_malloc(256);
 	        g_snprintf(buf, 255, "toc_chat_leave %d",  id);
 	        sflap_send(g, buf, -1, TYPE_DATA);
 	        g_free(buf);
 	} else if (g->protocol == PROTO_OSCAR) {
-		GList *bcs = buddy_chats;
+		GSList *bcs = g->buddy_chats;
 		struct conversation *b = NULL;
 		struct chat_connection *c = NULL;
 		int count = 0;
@@ -619,14 +614,12 @@
 			g_free(c);
 		}
 		/* we do this because with Oscar it doesn't tell us we left */
-		serv_got_chat_left(b->id);
+		serv_got_chat_left(g, b->id);
 	}
 }
 
-void serv_chat_whisper(int id, char *who, char *message)
+void serv_chat_whisper(struct gaim_connection *g, int id, char *who, char *message)
 {
-	/* FIXME */
-	struct gaim_connection *g = connections->data;
 	if (g->protocol == PROTO_TOC) {
 	        char buf2[MSG_LEN];
 	        g_snprintf(buf2, sizeof(buf2), "toc_chat_whisper %d %s \"%s\"", id, who, message);
@@ -637,10 +630,8 @@
 	}
 }
 
-void serv_chat_send(int id, char *message)
+void serv_chat_send(struct gaim_connection *g, int id, char *message)
 {
-	/* FIXME */
-	struct gaim_connection *g = connections->data;
 	if (g->protocol == PROTO_TOC) {
 	        char buf[MSG_LEN];
 		escape_text(message);
@@ -648,7 +639,7 @@
 	        sflap_send(g, buf, -1, TYPE_DATA);
 	} else if (g->protocol == PROTO_OSCAR) {
 		struct aim_conn_t *cn;
-		GList *bcs = buddy_chats;
+		GSList *bcs = g->buddy_chats;
 		struct conversation *b = NULL;
 
 		while (bcs) {
@@ -901,16 +892,16 @@
 
 static void chat_invite_callback(GtkWidget *w, GtkWidget *w2)
 {
-	/* FIXME */
-	struct gaim_connection *g = connections->data;
+	struct gaim_connection *g = (struct gaim_connection *)
+					gtk_object_get_user_data(GTK_OBJECT(GTK_DIALOG(w2)->vbox));
 	if (g->protocol == PROTO_TOC) {
 	        int i = (int)gtk_object_get_user_data(GTK_OBJECT(w2));
-	        serv_accept_chat(i);
+	        serv_accept_chat(g, i);
 		gtk_widget_destroy(w2);
 	} else if (g->protocol == PROTO_OSCAR) {
 		char *i = (char *)gtk_object_get_user_data(GTK_OBJECT(w2));
 		int id = (int)gtk_object_get_user_data(GTK_OBJECT(w));
-		serv_join_chat(id, i);
+		serv_join_chat(g, id, i);
 		g_free(i);
 		gtk_widget_destroy(w2);
 	}
@@ -918,7 +909,7 @@
 
 
 
-void serv_got_chat_invite(char *name, int id, char *who, char *message)
+void serv_got_chat_invite(struct gaim_connection *g, char *name, int id, char *who, char *message)
 {
         GtkWidget *d;
         GtkWidget *label;
@@ -926,16 +917,14 @@
         GtkWidget *nobtn;
 
         char buf2[BUF_LONG];
-	/* FIXME */
-	struct gaim_connection *g = connections->data;
 
 
 	plugin_event(event_chat_invited, who, name, message);
 
 	if (message)
-		g_snprintf(buf2, sizeof(buf2), "User '%s' invites you to buddy chat room: '%s'\n%s", who, name, message);
+		g_snprintf(buf2, sizeof(buf2), "User '%s' invites %s to buddy chat room: '%s'\n%s", who, g->username, name, message);
 	else
-		g_snprintf(buf2, sizeof(buf2), "User '%s' invites you to buddy chat room: '%s'\n", who, name);
+		g_snprintf(buf2, sizeof(buf2), "User '%s' invites %s to buddy chat room: '%s'\n", who, g->username, name);
 
         d = gtk_dialog_new();
         gtk_widget_realize(d);
@@ -944,9 +933,8 @@
 
         label = gtk_label_new(buf2);
         gtk_widget_show(label);
-        yesbtn = gtk_button_new_with_label("Yes");
-        gtk_widget_show(yesbtn);
-        nobtn = gtk_button_new_with_label("No");
+        yesbtn = picture_button(d, _("Yes"), ok_xpm);
+        nobtn = picture_button(d, _("No"), cancel_xpm);
         gtk_widget_show(nobtn);
         gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox),
                            label, FALSE, FALSE, 5);
@@ -955,16 +943,11 @@
         gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area),
                            nobtn, FALSE, FALSE, 5);
 
-	if (display_options & OPT_DISP_COOL_LOOK)
-		gtk_button_set_relief(GTK_BUTTON(yesbtn), GTK_RELIEF_NONE);
-	if (display_options & OPT_DISP_COOL_LOOK)
-		gtk_button_set_relief(GTK_BUTTON(nobtn), GTK_RELIEF_NONE);
-
-        /*		gtk_widget_set_usize(d, 200, 110); */
-
-	if (g->protocol == PROTO_TOC)
+	gtk_object_set_user_data(GTK_OBJECT(GTK_DIALOG(d)->vbox), g);
+	if (g->protocol == PROTO_TOC) {
 	        gtk_object_set_user_data(GTK_OBJECT(d), (void *)id);
-	else if (g->protocol == PROTO_OSCAR) {
+		gtk_object_set_user_data(GTK_OBJECT(GTK_DIALOG(d)->vbox), g);
+	} else if (g->protocol == PROTO_OSCAR) {
 		gtk_object_set_user_data(GTK_OBJECT(d), (void *)g_strdup(name));
 		gtk_object_set_user_data(GTK_OBJECT(yesbtn), (void *)id);
 	} else {
@@ -980,19 +963,20 @@
         gtk_widget_show(d);
 }
 
-void serv_got_joined_chat(int id, char *name)
+void serv_got_joined_chat(struct gaim_connection *gc, int id, char *name)
 {
         struct conversation *b;
 
 	plugin_event(event_chat_join, name, 0, 0);
 
         b = (struct conversation *)g_new0(struct conversation, 1);
-        buddy_chats = g_list_append(buddy_chats, b);
+        gc->buddy_chats = g_slist_append(gc->buddy_chats, b);
 
 	b->is_chat = TRUE;
         b->ignored = NULL;
         b->in_room = NULL;
         b->id = id;
+	b->gc = gc;
         g_snprintf(b->name, 80, "%s", name);
 
 	if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(b->name)) {
@@ -1015,9 +999,9 @@
         show_new_buddy_chat(b);
 }
 
-void serv_got_chat_left(int id)
+void serv_got_chat_left(struct gaim_connection *g, int id)
 {
-        GList *bcs = buddy_chats;
+        GSList *bcs = g->buddy_chats;
         struct conversation *b = NULL;
 
 
@@ -1038,15 +1022,15 @@
 	sprintf(debug_buff, "Leaving room %s.\n", b->name);
 	debug_print(debug_buff);
 
-        buddy_chats = g_list_remove(buddy_chats, b);
+        g->buddy_chats = g_slist_remove(g->buddy_chats, b);
 
         g_free(b);
 }
 
-void serv_got_chat_in(int id, char *who, int whisper, char *message)
+void serv_got_chat_in(struct gaim_connection *g, int id, char *who, int whisper, char *message)
 {
         int w;
-        GList *bcs = buddy_chats;
+        GSList *bcs = g->buddy_chats;
         struct conversation *b = NULL;
 
         while(bcs) {
--- a/src/toc.c	Tue Oct 10 09:14:26 2000 +0000
+++ b/src/toc.c	Tue Oct 10 10:04:59 2000 +0000
@@ -39,7 +39,7 @@
 #include "gaim.h"
 #include "gnome_applet_mgr.h"
 
-#define REVISION "gaim:$Revision: 970 $"
+#define REVISION "gaim:$Revision: 974 $"
 
 
 static unsigned int peer_ver=0;
@@ -497,7 +497,7 @@
 
 		sscanf(strtok(NULL, ":"), "%d", &id);
                 name = strtok(NULL, ":");
-                serv_got_joined_chat(id, name);
+                serv_got_joined_chat(gc, id, name);
 
 	} else if (!strcasecmp(c, "DIR_STATUS")) {
 	} else if (!strcasecmp(c, "ADMIN_PASSWD_STATUS")) {
@@ -506,7 +506,7 @@
 		int id;
 		char *in;
 		char *buddy;
-                GList *bcs = buddy_chats;
+                GSList *bcs = gc->buddy_chats;
 		struct conversation *b = NULL;
 		
 		sscanf(strtok(NULL, ":"), "%d", &id);
@@ -543,7 +543,7 @@
 
                 sscanf(strtok(NULL, ":"), "%d", &id);
 
-                serv_got_chat_left(id);
+                serv_got_chat_left(gc, id);
 
 
 	} else if (!strcasecmp(c, "CHAT_IN")) {
@@ -565,7 +565,7 @@
 		else
 			w = 0;
 
-		serv_got_chat_in(id, who, w, m);
+		serv_got_chat_in(gc, id, who, w, m);
 
 
 	} else if (!strcasecmp(c, "CHAT_INVITE")) {
@@ -580,7 +580,7 @@
 		who = strtok(NULL, ":");
                 message = strtok(NULL, ":");
 
-                serv_got_chat_invite(name, id, who, message);
+                serv_got_chat_invite(gc, name, id, who, message);
 
 
         } else if (!strcasecmp(c, "RVOUS_PROPOSE")) {