diff src/protocols/oscar/oscar.c @ 4359:5fb47ec9bfe4

[gaim-migrate @ 4625] Wow, okay, where to begin with this one ;) I rewrote the whole conversation backend. It is now core/UI split. Here's how it works.. Every conversation is represented by a gaim_conversation structure. This branches out into gaim_im and gaim_chat structures. Every conversation lives in (well, normally, but it doesn't have to) a gaim_window structure. This is a _CORE_ representation of a window. There can be multiple gaim_window structures around. The gaim_window and gaim_conversation structures have UI-specific operation structures associated with them. At the moment, the only UI is GTK+, and this will be for some time. Don't start thinking you can write a QT UI now. It's just not going to happen. Everything that is done on a conversation is done through the core API. This API does core processing and then calls the UI operations for the rendering and anything else. Now, what does this give the user? - Multiple windows. - Multiple tabs per window. - Draggable tabs. - Send As menu is moved to the menubar. - Menubar for chats. - Some very cool stuff in the future, like replacing, say, IRC chat windows with an X-Chat interface, or whatever. - Later on, customizable window/conversation positioning. For developers: - Fully documented API - Core/UI split - Variable checking and mostly sane handling of incorrect variables. - Logical structure to conversations, both core and UI. - Some very cool stuff in the future, like replacing, say, IRC chat windows with an X-Chat interface, or whatever. - Later on, customizable window/conversation positioning. - Oh yeah, and the beginning of a stock icon system. Now, there are things that aren't there yet. You will see tabs even if you have them turned off. This will be fixed in time. Also, the preferences will change to work with the new structure. I'm starting school in 2 days, so it may not be done immediately, but hopefully in the next week. Enjoy! committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 20 Jan 2003 09:10:23 +0000
parents 2b8abf7f9cc1
children 7ba9b56a8796
line wrap: on
line diff
--- a/src/protocols/oscar/oscar.c	Mon Jan 20 07:00:10 2003 +0000
+++ b/src/protocols/oscar/oscar.c	Mon Jan 20 09:10:23 2003 +0000
@@ -156,7 +156,7 @@
 	int inpa;
 	int id;
 	struct gaim_connection *gc; /* i hate this. */
-	struct conversation *cnv; /* bah. */
+	struct gaim_conversation *cnv; /* bah. */
 	int maxlen;
 	int maxvis;
 };
@@ -458,7 +458,7 @@
 static void gaim_directim_disconnect(aim_session_t *sess, aim_conn_t *conn) {
 	struct gaim_connection *gc = sess->aux_data;
 	struct oscar_data *od = (struct oscar_data *)gc->proto_data;
-	struct conversation *cnv;
+	struct gaim_conversation *cnv;
 	struct direct_im *dim;
 	char *sn;
 	char buf[256];
@@ -476,9 +476,10 @@
 	else 
 		g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), sn);
 		
-	if ((cnv = find_conversation(sn)))
-		write_to_conv(cnv, buf, WFLAG_SYSTEM, NULL, time(NULL), -1);
-	update_progress(cnv, 100);
+	if ((cnv = gaim_find_conversation(sn)))
+		gaim_conversation_write(cnv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL));
+
+	gaim_conversation_update_progress(cnv, 100);
 
 	g_free(dim); /* I guess? I don't see it anywhere else... -- mid */
 	g_free(sn);
@@ -1487,7 +1488,7 @@
 	struct direct_im *dim = data;
 	struct gaim_connection *gc = dim->gc;
 	struct oscar_data *od = gc->proto_data;
-	struct conversation *cnv;
+	struct gaim_conversation *cnv;
 	char buf[256];
 	struct sockaddr name;
 	socklen_t name_len = 1;
@@ -1505,14 +1506,14 @@
 	if (dim->conn->fd != source)
 		dim->conn->fd = source;
 	aim_conn_completeconnect(od->sess, dim->conn);
-	if (!(cnv = find_conversation(dim->name))) 
-		cnv = new_conversation(dim->name);
+	if (!(cnv = gaim_find_conversation(dim->name))) 
+		cnv = gaim_conversation_new(GAIM_CONV_IM, dim->name);
 
 	/* This is the best way to see if we're connected or not */
 	if (getpeername(source, &name, &name_len) == 0) {
 		g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name);
 		dim->connected = TRUE;
-		write_to_conv(cnv, buf, WFLAG_SYSTEM, NULL, time(NULL), -1);
+		gaim_conversation_write(cnv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL));
 	}
 	od->direct_ims = g_slist_append(od->direct_ims, dim);
 	
@@ -2956,7 +2957,7 @@
 		return 1;
 
 	for (i = 0; i < count; i++)
-		add_chat_buddy(c->cnv, info[i].sn, NULL);
+		gaim_chat_add_user(GAIM_CHAT(c->cnv), info[i].sn, NULL);
 
 	return 1;
 }
@@ -2979,7 +2980,7 @@
 		return 1;
 
 	for (i = 0; i < count; i++)
-		remove_chat_buddy(c->cnv, info[i].sn, NULL);
+		gaim_chat_remove_user(GAIM_CHAT(c->cnv), info[i].sn, NULL);
 
 	return 1;
 }
@@ -4507,14 +4508,14 @@
 static void oscar_chat_leave(struct gaim_connection *g, int id) {
 	struct oscar_data *odata = g ? (struct oscar_data *)g->proto_data : NULL;
 	GSList *bcs = g->buddy_chats;
-	struct conversation *b = NULL;
+	struct gaim_conversation *b = NULL;
 	struct chat_connection *c = NULL;
 	int count = 0;
 
 	while (bcs) {
 		count++;
-		b = (struct conversation *)bcs->data;
-		if (id == b->id)
+		b = (struct gaim_conversation *)bcs->data;
+		if (id == gaim_chat_get_id(GAIM_CHAT(b)))
 			break;
 		bcs = bcs->next;
 		b = NULL;
@@ -4525,7 +4526,7 @@
 
 	debug_printf("Attempting to leave room %s (currently in %d rooms)\n", b->name, count);
 	
-	c = find_oscar_chat(g, b->id);
+	c = find_oscar_chat(g, gaim_chat_get_id(GAIM_CHAT(b)));
 	if (c != NULL) {
 		if (odata)
 			odata->oscar_chats = g_slist_remove(odata->oscar_chats, c);
@@ -4538,20 +4539,20 @@
 		g_free(c);
 	}
 	/* we do this because with Oscar it doesn't tell us we left */
-	serv_got_chat_left(g, b->id);
+	serv_got_chat_left(g, gaim_chat_get_id(GAIM_CHAT(b)));
 }
 
 static int oscar_chat_send(struct gaim_connection *g, int id, char *message) {
 	struct oscar_data *odata = (struct oscar_data *)g->proto_data;
 	GSList *bcs = g->buddy_chats;
-	struct conversation *b = NULL;
+	struct gaim_conversation *b = NULL;
 	struct chat_connection *c = NULL;
 	char *buf, *buf2;
 	int i, j;
 
 	while (bcs) {
-		b = (struct conversation *)bcs->data;
-		if (id == b->id)
+		b = (struct gaim_conversation *)bcs->data;
+		if (id == gaim_chat_get_id(GAIM_CHAT(b)))
 			break;
 		bcs = bcs->next;
 		b = NULL;
@@ -4730,7 +4731,7 @@
 	struct gaim_connection *gc = sess->aux_data;
 	struct oscar_data *od = (struct oscar_data *)gc->proto_data;
 	aim_conn_t *newconn, *listenerconn;
-	struct conversation *cnv;
+	struct gaim_conversation *cnv;
 	struct direct_im *dim;
 	char buf[256];
 	char *sn;
@@ -4748,8 +4749,8 @@
 	debug_printf("DirectIM: initiate success to %s\n", sn);
 	dim = find_direct_im(od, sn);
 
-	if (!(cnv = find_conversation(sn)))
-		cnv = new_conversation(sn);
+	if (!(cnv = gaim_find_conversation(sn)))
+		cnv = gaim_conversation_new(GAIM_CONV_IM, sn);
 	gaim_input_remove(dim->watcher);
 	dim->conn = newconn;
 	dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ,
@@ -4757,7 +4758,7 @@
 	dim->connected = TRUE;
 	g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn);
 	g_free(sn);
-	write_to_conv(cnv, buf, WFLAG_SYSTEM, NULL, time(NULL), -1);
+	gaim_conversation_write(cnv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL));
 
 	aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING,
 				gaim_directim_incoming, 0);
@@ -4774,7 +4775,7 @@
 	double percent;
 	struct gaim_connection *gc = sess->aux_data;
 	struct oscar_data *od = (struct oscar_data *)gc->proto_data;
-	struct conversation *c;
+	struct gaim_conversation *c;
 	struct direct_im *dim;
 
 	va_start(ap, fr);
@@ -4791,8 +4792,8 @@
 	while (gtk_events_pending())
 		gtk_main_iteration();
 	
-	if ((c = find_conversation(sn)))
-		update_progress(c, percent);
+	if ((c = gaim_find_conversation(sn)))
+		gaim_conversation_update_progress(c, percent);
 	dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ,
 				      oscar_callback, dim->conn);