changeset 2374:9e9385cddcc6

[gaim-migrate @ 2387] i need to go to class. but just because i need to do something doesn't mean i will, especially when what i need to do is related to school. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 27 Sep 2001 20:32:59 +0000
parents 84a5ea08545a
children 09fe1b00d31f
files src/buddy_chat.c src/conversation.c src/gaim.h
diffstat 3 files changed, 62 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/buddy_chat.c	Thu Sep 27 19:27:52 2001 +0000
+++ b/src/buddy_chat.c	Thu Sep 27 20:32:59 2001 +0000
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <sys/time.h>
 #include <unistd.h>
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <gtk/gtk.h>
@@ -469,6 +470,46 @@
 		return FALSE;
 }
 
+static gboolean find_nick(struct gaim_connection *gc, char *message)
+{
+	char *msg = g_strdup(message), *who, *p;
+	int n;
+	g_strdown(msg);
+
+	who = g_strdup(gc->username);
+	n = strlen(who);
+	g_strdown(who);
+
+	if ((p = strstr(msg, who)) != NULL) {
+		if ((p == msg) || (!isalnum(*(p - 1)) && !isalnum(*(p + n)))) {
+			g_free(who);
+			g_free(msg);
+			return TRUE;
+		}
+	}
+	g_free(who);
+
+	if (g_strcasecmp(gc->username, gc->displayname)) {
+		g_free(msg);
+		return FALSE;
+	}
+
+	who = g_strdup(gc->displayname);
+	n = strlen(who);
+	g_strdown(who);
+
+	if ((p = strstr(msg, who)) != NULL) {
+		if ((p == msg) || (!isalnum(*(p - 1)) && !isalnum(*(p + n)))) {
+			g_free(who);
+			g_free(msg);
+			return TRUE;
+		}
+	}
+	g_free(who);
+	g_free(msg);
+	return FALSE;
+}
+
 void chat_write(struct conversation *b, char *who, int flag, char *message, time_t mtime)
 {
 	GList *ignore = b->ignored;
@@ -488,11 +529,11 @@
 
 	if (!(flag & WFLAG_WHISPER)) {
 		str = g_strdup(normalize (who));
-		if (!g_strcasecmp(str, normalize (b->gc->username))) {
+		if (!g_strcasecmp(str, normalize(b->gc->username))) {
 			if (b->makesound && (sound_options & OPT_SOUND_CHAT_YOU_SAY))
 				play_sound(CHAT_YOU_SAY);
 			flag |= WFLAG_SEND;
-		} else if (!g_strcasecmp(str, normalize (b->gc->displayname))) {
+		} else if (!g_strcasecmp(str, normalize(b->gc->displayname))) {
 			if (b->makesound && (sound_options & OPT_SOUND_CHAT_YOU_SAY))
 				play_sound(CHAT_YOU_SAY);
 			flag |= WFLAG_SEND;
@@ -504,6 +545,9 @@
 		g_free(str);
 	}
 
+	if ((flag & WFLAG_RECV) && find_nick(b->gc, message))
+		flag |= WFLAG_NICK;
+
 	write_to_conv(b, message, flag, who, mtime);
 }
 
--- a/src/conversation.c	Thu Sep 27 19:27:52 2001 +0000
+++ b/src/conversation.c	Thu Sep 27 20:32:59 2001 +0000
@@ -1429,11 +1429,11 @@
 			if (meify(what)) {
 				str = g_malloc(1024);
 				g_snprintf(str, 1024, "***%s", who);
-				strcpy(colour, "#6C2585\0");
+				strcpy(colour, "#6C2585");
 			} else {
 				str = g_malloc(1024);
 				g_snprintf(str, 1024, "*%s*:", who);
-				strcpy(colour, "#00ff00\0");
+				strcpy(colour, "#00ff00");
 			}
 		} else {
 			if (meify(what)) {
@@ -1442,14 +1442,19 @@
 					g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, who);
 				else
 					g_snprintf(str, 1024, "***%s", who);
-				strcpy(colour, "#062585\0");
+				if (flags & WFLAG_NICK)
+					strcpy(colour, "#ef7f00");
+				else
+					strcpy(colour, "#062585");
 			} else {
 				str = g_malloc(1024);
 				if (flags & WFLAG_AUTO)
 					g_snprintf(str, 1024, "%s %s", who, AUTO_RESPONSE);
 				else
 					g_snprintf(str, 1024, "%s:", who);
-				if (flags & WFLAG_RECV)
+				if (flags & WFLAG_NICK)
+					strcpy(colour, "#ef7f00");
+				else if (flags & WFLAG_RECV)
 					strcpy(colour, "#ff0000");
 				else if (flags & WFLAG_SEND)
 					strcpy(colour, "#0000ff");
--- a/src/gaim.h	Thu Sep 27 19:27:52 2001 +0000
+++ b/src/gaim.h	Thu Sep 27 20:32:59 2001 +0000
@@ -63,12 +63,13 @@
 #define UC_NORMAL	8
 #define UC_UNAVAILABLE  16
 
-#define WFLAG_SEND 1
-#define WFLAG_RECV 2
-#define WFLAG_AUTO 4
-#define WFLAG_WHISPER 8
-#define WFLAG_FILERECV 16
-#define WFLAG_SYSTEM 32
+#define WFLAG_SEND	0x01
+#define WFLAG_RECV	0x02
+#define WFLAG_AUTO	0x04
+#define WFLAG_WHISPER	0x08
+#define WFLAG_FILERECV	0x10
+#define WFLAG_SYSTEM	0x20
+#define WFLAG_NICK	0x40
 
 #define AUTO_RESPONSE "&lt;AUTO-REPLY&gt; : "