changeset 2447:6bdeb91abe4e

[gaim-migrate @ 2460] i hope this works committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 08 Oct 2001 01:12:02 +0000
parents f9cad82d321b
children dab1bf4a8392
files src/conversation.c src/core.c src/core.h
diffstat 3 files changed, 107 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/conversation.c	Sat Oct 06 06:21:01 2001 +0000
+++ b/src/conversation.c	Mon Oct 08 01:12:02 2001 +0000
@@ -1334,27 +1334,11 @@
 	char buf2[BUF_LONG];
 	char mdate[64];
 
-	if (!c->is_chat && !g_list_find(conversations, c))
-		return;
-
 	if (c->is_chat && (!c->gc || !g_slist_find(c->gc->buddy_chats, c)))
 		return;
 
-	strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime));
-
-	gtk_font_options = gtk_font_options ^ GTK_IMHTML_NO_COMMENTS;
-
-	if (convo_options & OPT_CONVO_IGNORE_COLOUR)
-		gtk_font_options = gtk_font_options ^ GTK_IMHTML_NO_COLOURS;
-
-	if (convo_options & OPT_CONVO_IGNORE_FONTS)
-		gtk_font_options = gtk_font_options ^ GTK_IMHTML_NO_FONTS;
-
-	if (convo_options & OPT_CONVO_IGNORE_SIZES)
-		gtk_font_options = gtk_font_options ^ GTK_IMHTML_NO_SIZES;
-
-	if (!(logging_options & OPT_LOG_STRIP_HTML))
-		gtk_font_options = gtk_font_options ^ GTK_IMHTML_RETURN_LOG;
+	if (!c->is_chat && !g_list_find(conversations, c))
+		return;
 
 	if (!c->is_chat || !(c->gc->prpl->options & OPT_PROTO_UNIQUE_CHATNAME)) {
 		if (!who) {
@@ -1380,6 +1364,36 @@
 		}
 	}
 
+	/* XXX CUI: this is really bad and should be moved somewhere else later. */
+	if (c->gc) {
+		int index = g_slist_index(connections, c->gc);
+		int sname = strlen(who);
+		int swhat = strlen(what);
+		UI_build_broadcast(CUI_TYPE_MESSAGE, CUI_MESSAGE_RECV,
+				sizeof(index), &index,
+				sizeof(sname), &sname,
+				sname, who,
+				sizeof(flags), &flags,
+				sizeof(swhat), &swhat,
+				swhat, what,
+				sizeof(mtime), &mtime, -1);
+	}
+
+	strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime));
+
+	gtk_font_options = gtk_font_options ^ GTK_IMHTML_NO_COMMENTS;
+
+	if (convo_options & OPT_CONVO_IGNORE_COLOUR)
+		gtk_font_options = gtk_font_options ^ GTK_IMHTML_NO_COLOURS;
+
+	if (convo_options & OPT_CONVO_IGNORE_FONTS)
+		gtk_font_options = gtk_font_options ^ GTK_IMHTML_NO_FONTS;
+
+	if (convo_options & OPT_CONVO_IGNORE_SIZES)
+		gtk_font_options = gtk_font_options ^ GTK_IMHTML_NO_SIZES;
+
+	if (!(logging_options & OPT_LOG_STRIP_HTML))
+		gtk_font_options = gtk_font_options ^ GTK_IMHTML_RETURN_LOG;
 
 	if (flags & WFLAG_SYSTEM) {
 		if (convo_options & OPT_CONVO_SHOW_TIME)
--- a/src/core.c	Sat Oct 06 06:21:01 2001 +0000
+++ b/src/core.c	Mon Oct 08 01:12:02 2001 +0000
@@ -34,12 +34,50 @@
 #include <errno.h>
 #include <signal.h>
 #include <getopt.h>
+#include <stdarg.h>
 
 #include "gaim.h"
 
 static gint UI_fd = -1;
 GSList *uis = NULL;
 
+static guchar *UI_build(int *len, guchar type, guchar subtype, va_list args1)
+{
+	va_list args2;
+	guchar *buffer;
+	int pos;
+	int size;
+	void *data;
+
+	G_VA_COPY(args2, args1);
+
+	buffer = g_malloc(sizeof(guchar) * 2 + 4);
+	*len = sizeof(guchar) * 2 + 4;
+	pos = 0;
+
+	memcpy(buffer + pos, &type, sizeof(type)); pos += sizeof(type);
+	memcpy(buffer + pos, &subtype, sizeof(subtype)); pos += sizeof(subtype);
+
+	/* we come back and do size last */
+	pos += 4;
+
+	size = va_arg(args2, int);
+	while (size != -1) {
+		*len += size;
+		buffer = g_realloc(buffer, *len);
+
+		data = va_arg(args2, void *);
+		memcpy(buffer + pos, data, size);
+		pos += size;
+
+		size = va_arg(args2, int);
+	}
+
+	va_end(args2);
+
+	return buffer;
+}
+
 gint UI_write(struct UI *ui, guchar *data, gint len)
 {
 	guchar *send = g_new0(guchar, len + 6);
@@ -53,6 +91,21 @@
 	return sent;
 }
 
+void UI_build_write(struct UI *ui, guchar type, guchar subtype, ...)
+{
+	va_list ap;
+	gchar *data;
+	int len;
+
+	va_start(ap, subtype);
+	data = UI_build(&len, type, subtype, ap);
+	va_end(ap);
+
+	UI_write(ui, data, len);
+
+	g_free(data);
+}
+
 void UI_broadcast(guchar *data, gint len)
 {
 	GSList *u = uis;
@@ -63,6 +116,24 @@
 	}
 }
 
+void UI_build_broadcast(guchar type, guchar subtype, ...)
+{
+	va_list ap;
+	gchar *data;
+	int len;
+
+	if (!uis)
+		return;
+
+	va_start(ap, subtype);
+	data = UI_build(&len, type, subtype, ap);
+	va_end(ap);
+
+	UI_broadcast(data, len);
+
+	g_free(data);
+}
+
 static void meta_handler(struct UI *ui, guchar subtype, guchar *data)
 {
 	switch (subtype) {
@@ -290,9 +361,11 @@
 		case CUI_TYPE_BUDDY:
 			buddy_handler(ui, subtype, in);
 			break;
+			*/
 		case CUI_TYPE_MESSAGE:
 			message_handler(ui, subtype, in);
 			break;
+			/*
 		case CUI_TYPE_CHAT:
 			chat_handler(ui, subtype, in);
 			break;
--- a/src/core.h	Sat Oct 06 06:21:01 2001 +0000
+++ b/src/core.h	Mon Oct 08 01:12:02 2001 +0000
@@ -156,7 +156,9 @@
 
 /* Functions in core.c */
 extern gint UI_write(struct UI *, guchar *, int);
+extern void UI_build_write(struct UI *, guchar, guchar, ...);
 extern void UI_broadcast(guchar *data, int);
+extern void UI_build_broadcast(guchar, guchar, ...);
 /* Don't ever use these; when gaim-core is done these will be
  * merged into the core's main() and won't be called directly */
 extern int core_main();