[ekg2-commit] r4250 - trunk/plugins/irc: trunk/plugins/irc/input.c trunk/plugins/irc/input.h trunk/plugins/irc/misc.c

SVN commit svn w toxygen.net
Sob, 9 Sie 2008, 01:18:42 CEST


Author: gim
Date: 2008-08-09 01:18:42 +0200 (Sat, 09 Aug 2008)
New Revision: 4250

Modified:
   trunk/plugins/irc/input.c
   trunk/plugins/irc/input.h
   trunk/plugins/irc/misc.c
Log:
fix highlighting (http://bugs.ekg2.org/ticket/2)
found by M.G. & Greyer



Modified: trunk/plugins/irc/input.c
===================================================================
--- trunk/plugins/irc/input.c	2008-08-08 23:00:10 UTC (rev 4249)
+++ trunk/plugins/irc/input.c	2008-08-08 23:18:42 UTC (rev 4250)
@@ -77,6 +77,36 @@
 	return ret;
 }
 
+char *irc_ircoldcolstr_juststrip(session_t *sess, char *inp)
+{
+	int		col;
+	char		*ret, *str, *back;
+
+	if (!inp || !(*inp))
+		return xstrdup("");
+
+	ret = str = xstrdup(inp);
+	back = str;
+
+
+	for (;*str;)
+	{
+		if (*str == 3) /* ^c */
+		{
+			col = irc_getircoldcol(str+1);
+			str+=(col>>24)&0xff;
+		} else if (*str == 2) /* ^b */ {} 
+		else if (*str == 15) /* ^o */ {}
+		else if (*str == 18 || *str == 22) /* ^r */ {}
+		else if (*str == 31) /* ^_ */ {}
+		else 
+			*back++ = *str;
+		str++;
+	}
+	*back = '\0';
+	return ret;
+}
+
 char *irc_ircoldcolstr_to_ekgcolstr_nf(session_t *sess, char *str, int strip)
 {
 	int		col, oldstrip = strip;

Modified: trunk/plugins/irc/input.h
===================================================================
--- trunk/plugins/irc/input.h	2008-08-08 23:00:10 UTC (rev 4249)
+++ trunk/plugins/irc/input.h	2008-08-08 23:18:42 UTC (rev 4250)
@@ -21,6 +21,7 @@
 #include <ekg/sessions.h>
 #include "irc.h"
 
+char *irc_ircoldcolstr_juststrip(session_t *sess, char *inp);
 char *irc_ircoldcolstr_to_ekgcolstr(session_t *s, char *str, int strip);
 char *irc_ircoldcolstr_to_ekgcolstr_nf(session_t *sess, char *str, int strip);
 char *ctcp_parser(session_t *sess, int ispriv, char *sender, char *recp, char *s);

Modified: trunk/plugins/irc/misc.c
===================================================================
--- trunk/plugins/irc/misc.c	2008-08-08 23:00:10 UTC (rev 4249)
+++ trunk/plugins/irc/misc.c	2008-08-08 23:18:42 UTC (rev 4250)
@@ -1136,22 +1136,10 @@
 		// class = (mw&1)?EKG_MSGCLASS_CHAT:EKG_MSGCLASS_MESSAGE;
 		IRC_TO_LOWER(param[2]);
 		dest = irc_uid(param[2]);
-		if ((pubtous = xstrcasestr(ctcpstripped, j->nick))) {
-			tous = pubtous[xstrlen(j->nick)];
-			if (!isalnum(tous) && !isalpha_pl(tous))
-				if (pubtous == ctcpstripped || (!isalnum(*(pubtous-1)) && !isalpha_pl(*(pubtous-1))))
-				{
-					ekgbeep = EKG_TRY_BEEP;
-					xosd_to_us = 1;
-				}
-		}
+
 		w = window_find_s(s, dest);
+		format = NULL;
 
-		format = saprintf("irc_%s_f_chan%s%s", prv?"msg":"not",
-					(!w)?"":"_n", ekgbeep?"h":"");
-		if (!xosd_to_us)
-			class |= EKG_MSGCLASS_NOT2US;
-
 		/* ok new irc-find-person checked */
 		if ((person = irc_find_person(j->people, param[0]+1)))
 		{
@@ -1167,6 +1155,7 @@
 	}
 
 	if (ctcpstripped) {
+		char *clear_string;
 		int isour = 0;
   		if (xosd_is_priv) /* @ wrong place */
 			query_emit_id(NULL, MESSAGE_DECRYPT, &(s->uid), &dest, &ctcpstripped, &secure , NULL);
@@ -1175,16 +1164,51 @@
 
 		/* TODO 'secure' var checking, but still don't know how to react to it (GiM)
 		 */
-		coloured = irc_ircoldcolstr_to_ekgcolstr(s, ctcpstripped,1);
-		debug("<%c%s/%s> %s\n", perchn?*(perchn->sign):' ', param[0]+1, param[2], OMITCOLON(param[3]));
+		coloured = irc_ircoldcolstr_to_ekgcolstr(s, ctcpstripped, 1);
+		clear_string = irc_ircoldcolstr_juststrip(s, ctcpstripped);
+		debug("<%c%s/%s> %s [%s]\n", perchn?*(perchn->sign):' ', param[0]+1, param[2], OMITCOLON(param[3]), clear_string);
+
 		prefix[1] = '\0';
 		prefix[0] = perchn?*(perchn->sign):' ';
 		if (!session_int_get(s, "SHOW_NICKMODE_EMPTY") && *prefix==' ')
 			*prefix='\0';
+		/* privmsg on channel */
+                if (NULL == format)
+		{
+			if ((pubtous = xstrcasestr(clear_string, j->nick))) {
+				/* pubtus - points to beginning of a nickname
+				 * tous   - points after end    of a nickname
+				 */
+				tous = pubtous[xstrlen(j->nick)];
+				if (!isalnum(tous) && !isalpha_pl(tous))
+				{
+					if (pubtous == clear_string || (!isalnum(*(pubtous-1)) && !isalpha_pl(*(pubtous-1))))
+					{
+						ekgbeep = EKG_TRY_BEEP;
+						xosd_to_us = 1;
+					}
+				}
+			}
+			/* rest */
+
+			/* privmsg <--> notice
+			 * w -> window not yet created (other format)
+			 * ekgbeep -> higlight format or normal
+			 */
+			format = saprintf("irc_%s_f_chan%s%s", prv?"msg":"not",
+					(!w)?"":"_n", ekgbeep?"h":"");
+
+			if (!xosd_to_us)
+				class |= EKG_MSGCLASS_NOT2US;
+                }
+		xfree (clear_string);
+
 		head = format_string(format_find(format), session_name(s),
 				prefix, param[0]+1, me, param[2], coloured, "Y ");
+
 		xfree(coloured);
-		coloured = irc_ircoldcolstr_to_ekgcolstr(s, ctcpstripped,0);
+		coloured = irc_ircoldcolstr_to_ekgcolstr(s, ctcpstripped, 0);
+
 	/*
 234707 <@dredzik> GiM, string nadawca, string wiadomość, bool
 234707 wiadomość_do_ciebie, bool kanał_czy_priv, string



Więcej informacji o liście dyskusyjnej ekg2-commit