changeset 4621:69f028a6f357

[gaim-migrate @ 4912] Added half-op support, used on some IRC networks. Also fixed the bug where trying to IM a person in a chat with a @, %, or + prefix was keeping that prefix for the username in the IM window. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 27 Feb 2003 09:42:18 +0000
parents fb520992d5a1
children 56dde5f7d3a8
files ChangeLog src/conversation.c src/gtkconv.c src/protocols/irc/irc.c
diffstat 4 files changed, 52 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Feb 26 06:21:50 2003 +0000
+++ b/ChangeLog	Thu Feb 27 09:42:18 2003 +0000
@@ -69,6 +69,7 @@
 	  Mark Doliner)
 	* DCC File Receive support for IRC.
 	* Optional password on IRC accounts. (Thanks, Christian Hammond)
+	* Added half-op support.
 
 	Jabber:
 	* Jabber invisibility and permanently cancel sending on-
--- a/src/conversation.c	Wed Feb 26 06:21:50 2003 +0000
+++ b/src/conversation.c	Thu Feb 27 09:42:18 2003 +0000
@@ -64,18 +64,23 @@
 	if (*a == '@') {
 		if (*b != '@') return -1;
 
-		return (strcasecmp(a + 1, b + 1));
+		return strcasecmp(a + 1, b + 1);
+
+	} else if (*a == '%') {
+		if (*b != '%') return -1;
+
+		return strcasecmp(a + 1, b + 1);
 
 	} else if (*a == '+') {
 		if (*b == '@') return  1;
 		if (*b != '+') return -1;
-		
-		return (strcasecmp(a + 1, b + 1));
-
-	} else if (*a == '@' || *b == '+')
+
+		return strcasecmp(a + 1, b + 1);
+
+	} else if (*b == '@' || *b == '%' || *b == '+')
 		return 1;
 
-	return (strcasecmp(a, b));
+	return strcasecmp(a, b);
 }
 
 static gboolean
@@ -1768,7 +1773,7 @@
 		const char *ign = (const char *)ignored->data;
 
 		if (!g_strcasecmp(user, ign) ||
-			(*ign == '+' && !g_strcasecmp(user, ign + 1)))
+			((*ign == '+' || *ign == '%') && !g_strcasecmp(user, ign + 1)))
 			return ign;
 
 		if (*ign == '@') {
--- a/src/gtkconv.c	Wed Feb 26 06:21:50 2003 +0000
+++ b/src/gtkconv.c	Thu Feb 27 09:42:18 2003 +0000
@@ -551,6 +551,7 @@
 		return;
 
 	if (*name == '@') name++;
+	if (*name == '%') name++;
 	if (*name == '+') name++;
 
 	account = gaim_conversation_get_account(conv);
@@ -713,6 +714,10 @@
 	gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path);
 	gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &who, -1);
 
+	if (*who == '@') who++;
+	if (*who == '%') who++;
+	if (*who == '+') who++;
+
 	if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) {
 		struct gaim_conversation *c;
 
@@ -2239,7 +2244,7 @@
 		char *nick = nicks->data;
 		/* this checks to see if the current nick could be a completion */
 		if (g_strncasecmp(nick, entered, strlen(entered))) {
-			if (nick[0] != '+' && nick[0] != '@')
+			if (*nick != '+' && *nick != '@' && *nick != '%')
 				continue;
 
 			if (g_strncasecmp(nick + 1, entered, strlen(entered))) {
@@ -2270,6 +2275,7 @@
 				nick = nicks->data;
 
 				if (*nick == '@') nick++;
+				if (*nick == '%') nick++;
 				if (*nick == '+') nick++;
 			}
 
--- a/src/protocols/irc/irc.c	Wed Feb 26 06:21:50 2003 +0000
+++ b/src/protocols/irc/irc.c	Thu Feb 27 09:42:18 2003 +0000
@@ -759,7 +759,7 @@
 	struct gaim_conversation *c = irc_find_chat(gc, room);
 	GList *r;
 
-	if (mode != 'o' && mode != 'v')
+	if (mode != 'o' && mode != 'v' && mode != 'h')
 		return;
 
 	if (!c)
@@ -767,33 +767,52 @@
 
 	r = gaim_chat_get_users(GAIM_CHAT(c));
 	while (r) {
-		gboolean op = FALSE, voice = FALSE;
+		gboolean op = FALSE, halfop = FALSE, voice = FALSE;
 		char *who = r->data;
+
 		if (*who == '@') {
 			op = TRUE;
 			who++;
 		}
+
+		if (*who == '%') {
+			halfop = TRUE;
+			who++;
+		}
+
 		if (*who == '+') {
 			voice = TRUE;
 			who++;
 		}
+
 		if (!strcmp(who, nick)) {
 			char *tmp, buf[IRC_BUF_LEN];
+
 			if (mode == 'o') {
 				if (sign == '-')
 					op = FALSE;
 				else
 					op = TRUE;
 			}
+
+			if (mode == 'h') {
+				if (sign == '-')
+					halfop = FALSE;
+				else
+					halfop = TRUE;
+			}
+
 			if (mode == 'v') {
 				if (sign == '-')
 					voice = FALSE;
 				else
 					voice = TRUE;
 			}
+
 			tmp = g_strdup(r->data);
-			g_snprintf(buf, sizeof(buf), "%s%s%s", op ? "@" : "",
-				   voice ? "+" : "", nick);
+			g_snprintf(buf, sizeof(buf), "%s%s%s",
+					   (op ? "@" : (halfop ? "%" : "")),
+					   voice ? "+" : "", nick);
 			gaim_chat_rename_user(GAIM_CHAT(c), tmp, buf);
 			g_free(tmp);
 			return;
@@ -1114,6 +1133,8 @@
 			char *who = r->data;
 			if (*who == '@')
 				who++;
+			if (*who == '%')
+				who++;
 			if (*who == '+')
 				who++;
 			if (!g_strcasecmp(who, nick)) {
@@ -1154,6 +1175,8 @@
 			int n = 0;
 			if (*who == '@')
 				buf[n++] = *who++;
+			if (*who == '%')
+				buf[n++] = *who++;
 			if (*who == '+')
 				buf[n++] = *who++;
 			g_snprintf(buf + n, sizeof(buf) - n, "%s", new);
@@ -1633,6 +1656,8 @@
 		char *who = r->data;
 		if (*who == '@')
 			who++;
+		if (*who == '%')
+			who++;
 		if (*who == '+')
 			who++;
 		if (!g_strcasecmp(who, nick)) {
@@ -2291,7 +2316,7 @@
 static int 
 irc_send_im(struct gaim_connection *gc, char *who, char *what, int len, int flags)
 {
-	if (*who == '@' || *who == '+')
+	if (*who == '@' || *who == '%' || *who == '+')
 		return send_msg(gc, who + 1, what);
 	return send_msg(gc, who, what);
 }
@@ -2710,6 +2735,8 @@
 
 	if (*who == '@')
 		who++;
+	if (*who == '%')
+		who++;
 	if (*who == '+')
 		who++;