changeset 2591:b771cbe7e161

[gaim-migrate @ 2604] spam! glorious spam. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 23 Oct 2001 21:39:44 +0000
parents 2dd86a1af92b
children f194dd8250d4
files TODO src/aim.c src/protocols/msn/msn.c
diffstat 3 files changed, 36 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/TODO	Tue Oct 23 20:56:25 2001 +0000
+++ b/TODO	Tue Oct 23 21:39:44 2001 +0000
@@ -46,10 +46,6 @@
 	New User Registration
 
 MSN:
-	Need to make it so txqueue is a GSList* of char* instead of char*, so
-		that you can "send" more than one message before you're
-		actually connected. This is actually a bug that it doesn't do
-		this already.
 	Permit/Deny
 	Need some way of indicating "invite" in IM window
 	File Transfer
--- a/src/aim.c	Tue Oct 23 20:56:25 2001 +0000
+++ b/src/aim.c	Tue Oct 23 21:39:44 2001 +0000
@@ -406,6 +406,7 @@
 	default:
 		debug_printf("caught signal %d\n", sig);
 		gtkspell_stop();
+		signoff_all(NULL, NULL);
 #ifdef GAIM_PLUGINS
 		remove_all_plugins();
 #endif
--- a/src/protocols/msn/msn.c	Tue Oct 23 20:56:25 2001 +0000
+++ b/src/protocols/msn/msn.c	Tue Oct 23 21:39:44 2001 +0000
@@ -53,7 +53,7 @@
 	int trId;
 	int total;
 	char *user;
-	char *txqueue;
+	GSList *txqueue;
 };
 
 struct msn_buddy {
@@ -296,7 +296,7 @@
 	while (m) {
 		struct msn_switchboard *ms = m->data;
 		m = m->next;
-		if ((ms->total == 1) && !g_strcasecmp(ms->user, id))
+		if ((ms->total <= 1) && !g_strcasecmp(ms->user, id))
 			return ms;
 	}
 
@@ -346,8 +346,10 @@
 	g_free(ms->auth);
 	if (ms->user)
 		g_free(ms->user);
-	if (ms->txqueue)
-		g_free(ms->txqueue);
+	while (ms->txqueue) {
+		g_free(ms->txqueue->data);
+		ms->txqueue = g_slist_remove(ms->txqueue, ms->txqueue->data);
+	}
 	if (ms->chat)
 		serv_got_chat_left(gc, ms->chat->id);
 
@@ -422,16 +424,18 @@
 		if (ms->chat)
 			add_chat_buddy(ms->chat, user);
 		ms->total++;
-		if (ms->txqueue) {
-			char *utf8 = str_to_utf8(ms->txqueue);
+		while (ms->txqueue) {
+			char *utf8 = str_to_utf8(ms->txqueue->data);
 			g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s%s", ++ms->trId,
 					strlen(MIME_HEADER) + strlen(utf8),
 					MIME_HEADER, utf8);
 			g_free(utf8);
-			g_free(ms->txqueue);
-			ms->txqueue = NULL;
-			if (msn_write(ms->fd, buf, strlen(buf)) < 0)
+			g_free(ms->txqueue->data);
+			ms->txqueue = g_slist_remove(ms->txqueue, ms->txqueue->data);
+			if (msn_write(ms->fd, buf, strlen(buf)) < 0) {
 				msn_kill_switch(ms);
+				return;
+			}
 			debug_printf("\n");
 		}
 	} else if (!g_strncasecmp(buf, "MSG", 3)) {
@@ -1194,7 +1198,15 @@
 	char buf[MSN_BUF_LEN];
 
 	if (ms) {
-		char *utf8 = str_to_utf8(message);
+		char *utf8;
+
+		if (ms->txqueue) {
+			debug_printf("appending to queue\n");
+			ms->txqueue = g_slist_append(ms->txqueue, g_strdup(message));
+			return 1;
+		}
+
+		utf8 = str_to_utf8(message);
 		g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s%s", ++ms->trId,
 				strlen(MIME_HEADER) + strlen(utf8),
 				MIME_HEADER, utf8);
@@ -1213,7 +1225,7 @@
 		ms = g_new0(struct msn_switchboard, 1);
 		md->switches = g_slist_append(md->switches, ms);
 		ms->user = g_strdup(who);
-		ms->txqueue = g_strdup(message);
+		ms->txqueue = g_slist_append(ms->txqueue, g_strdup(message));
 		ms->gc = gc;
 		ms->fd = -1;
 	} else
@@ -1233,8 +1245,10 @@
 	g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s%s", ++ms->trId,
 			strlen(MIME_HEADER) + strlen(message),
 			MIME_HEADER, message);
-	if (msn_write(ms->fd, buf, strlen(buf)) < 0)
+	if (msn_write(ms->fd, buf, strlen(buf)) < 0) {
 		msn_kill_switch(ms);
+		return 0;
+	}
 	debug_printf("\n");
 	serv_got_chat_in(gc, id, gc->username, 0, message, time(NULL));
 	return 0;
@@ -1457,6 +1471,14 @@
 	return m;
 }
 
+static void msn_convo_closed(struct gaim_connection *gc, char *who)
+{
+	struct msn_switchboard *ms = msn_find_switch(gc, who);
+
+	if (ms)
+		msn_kill_switch(ms);
+}
+
 static struct prpl *my_protocol = NULL;
 
 void msn_init(struct prpl *ret)
@@ -1480,6 +1502,7 @@
 	ret->normalize = msn_normalize;
 	ret->do_action = msn_do_action;
 	ret->actions = msn_actions;
+	ret->convo_closed = msn_convo_closed;
 
 	my_protocol = ret;
 }