summary refs log tree commit diff stats
path: root/src/common
diff options
context:
space:
mode:
authorRichardHitt <rbh00@netcom.com>2013-03-05 00:13:51 -0800
committerRichard Hitt <rbh00@f17.rbh00.pacbell.net>2013-03-20 15:10:30 -0700
commitf5631b2e2292adb90f0447a5a7eb0f7dece02d1c (patch)
treebf05a6f2d705fc40e2176c8fdd4c2c27c00cdb97 /src/common
parentc5404b8e25afdc30b5bcafdd2a21b169443e00cc (diff)
Redesign the Ban List window. Closes Issues #303, #342, #427
 This is a combination of 18 commits.
 The first commit's message is:
Here is the initial banlist branch of RichardHitt/hexchat.
Changed files are only src/fe-gtk/{banlist.c,fe-gtk.h}.
This version works and contains my first efforts at selective
sensitization of radio buttons and control buttons.

From this point I intend to undertake a stepwise redesign.

Step 1 will be to make the existing banlist code work for
multiple simultaneous banlist windows (for different channels,
obviously).  It will be a hackathon with the only goal of getting
it working.

Step 2 will be the objectization and alpha-stage tidying-up of
all the terrible looking stuff I will have done in Step 1.

 This is the 2nd commit message:

Here's the post-Step-1 commit.  It works for multiple banlist windows.

Note particularly what I've done to banlist.h.
Note that for many functions in banlist.c the argument is now
a banlist_info *, rather than a session *.
Note in banlist.c the initialization of array modes[] which
contains driving information for the checkboxes.

Of course those checkboxes aren't yet implemented.  Maybe in Step 2
I will change to checkboxes from radio buttons; but definitely I will
change to letting modes[] drive processing.

 This is the 3rd commit message:

Converted to checkboxes.  Much additional work.
Note that the infrastructure for Auto-invite is not yet
present in the hexchat tree.  I'm nearly done with banlist,
I think!

 This is the 4th commit message:

Fleshed out 'invite'.  Tagged masks uniformly, e.g. (b) (e) (I).
General cleanup, nearly at the point of beta quality.

 This is the 5th commit message:

Added fourth mode type: quiet.  Did lots and lots of cleanup.  Beta-ready?

 This is the 6th commit message:

Get the banlist timestamps properly sortable.

 This is the 7th commit message:

Redesign the supports_foo() routines.  Now they're responsible for setting
the flags in ->capable, ->readable, ->writeable.

 This is the 8th commit message:

Deleted a couple of RBH comments.

 This is the 9th commit message:

Now the ESC key will close the banlist window.

 This is the 10th commit message:

Fix the fe-text occurrence of fe_add_ban_list().

 This is the 11th commit message:

Fixed also fe_ban_list_end() and removed fe_is_banwindow().

 This is the 12th commit message:

Use old-style initialization for array of structures modes[]

 This is the 13th commit message:

Oops, incomplete regression of modes[] initialization.  This fixes.

 This is the 14th commit message:

Fixed strptime buy implementing a special version here.
Fixed column width concerns by setting resizable and autosize.

 This is the 15th commit message:

Get rid of testing line.

 This is the 16th commit message:

Changed to gtkutil_destroy_on_esc ()

 This is the 17th commit message:

Remove no-longer-used functnion

 This is the 18th commit message:

Minor cleanups to banlist.c, banlist.h

 Please enter the commit message for your changes. Lines starting
 with '#' will be ignored, and an empty message aborts the commit.

 Author:    RichardHitt <rbh00@netcom.com>
 Committer: Richard Hitt <rbh00@f17.rbh00.pacbell.net>

 Not currently on any branch.
 Changes to be committed:
   (use "git reset HEAD <file>..." to unstage)

	modified:   src/common/fe.h
	modified:   src/common/hexchat.h
	modified:   src/common/inbound.c
	modified:   src/common/modes.c
	modified:   src/common/proto-irc.c
	modified:   src/common/server.c
	modified:   src/fe-gtk/banlist.c
	modified:   src/fe-gtk/banlist.h
	modified:   src/fe-gtk/fe-gtk.c
	modified:   src/fe-gtk/fe-gtk.h
	modified:   src/fe-gtk/maingui.c
	modified:   src/fe-text/fe-text.c
Diffstat (limited to 'src/common')
-rw-r--r--src/common/fe.h5
-rw-r--r--src/common/hexchat.h1
-rw-r--r--src/common/inbound.c11
-rw-r--r--src/common/modes.c4
-rw-r--r--src/common/proto-irc.c33
-rw-r--r--src/common/server.c1
6 files changed, 41 insertions, 14 deletions
diff --git a/src/common/fe.h b/src/common/fe.h
index 4903ef0e..337c4b47 100644
--- a/src/common/fe.h
+++ b/src/common/fe.h
@@ -59,9 +59,8 @@ int fe_is_chanwindow (struct server *serv);
 void fe_add_chan_list (struct server *serv, char *chan, char *users,
 							  char *topic);
 void fe_chan_list_end (struct server *serv);
-int fe_is_banwindow (struct session *sess);
-void fe_add_ban_list (struct session *sess, char *mask, char *who, char *when, int is_exemption);
-void fe_ban_list_end (struct session *sess, int is_exemption);
+gboolean fe_add_ban_list (struct session *sess, char *mask, char *who, char *when, int rplcode);
+gboolean fe_ban_list_end (struct session *sess, int rplcode);
 void fe_notify_update (char *name);
 void fe_notify_ask (char *name, char *networks);
 void fe_text_clear (struct session *sess, int lines);
diff --git a/src/common/hexchat.h b/src/common/hexchat.h
index fcc77251..8e459306 100644
--- a/src/common/hexchat.h
+++ b/src/common/hexchat.h
@@ -575,6 +575,7 @@ typedef struct server
 	unsigned int have_idmsg:1;		/* freenode's IDENTIFY-MSG */
 	unsigned int have_sasl:1;		/* SASL capability */
 	unsigned int have_except:1;	/* ban exemptions +e */
+	unsigned int have_invite:1;	/* invite exemptions +I */
 	unsigned int using_cp1255:1;	/* encoding is CP1255/WINDOWS-1255? */
 	unsigned int using_irc:1;		/* encoding is "IRC" (CP1252/UTF-8 hybrid)? */
 	unsigned int use_who:1;			/* whether to use WHO command to get dcc_ip */
diff --git a/src/common/inbound.c b/src/common/inbound.c
index 898dcf4b..f9083eaf 100644
--- a/src/common/inbound.c
+++ b/src/common/inbound.c
@@ -1272,12 +1272,14 @@ inbound_user_info (session *sess, char *chan, char *user, char *host,
 }
 
 int
-inbound_banlist (session *sess, time_t stamp, char *chan, char *mask, char *banner, int is_exemption)
+inbound_banlist (session *sess, time_t stamp, char *chan, char *mask, char *banner, int rplcode)
 {
 	char *time_str = ctime (&stamp);
 	server *serv = sess->server;
+	char *nl;
 
-	time_str[19] = 0;	/* get rid of the \n */
+	if ((nl = strchr (time_str, '\n')))
+		*nl = 0;
 	if (stamp == 0)
 		time_str = "";
 
@@ -1288,18 +1290,17 @@ inbound_banlist (session *sess, time_t stamp, char *chan, char *mask, char *bann
 		goto nowindow;
 	}
 
-   if (!fe_is_banwindow (sess))
+	if (!fe_add_ban_list (sess, mask, banner, time_str, rplcode))
 	{
 nowindow:
 		/* let proto-irc.c do the 'goto def' for exemptions */
-		if (is_exemption)
+		if (rplcode == 348)	/* RPL_EXCEPTLIST */
 			return FALSE;
 
 		EMIT_SIGNAL (XP_TE_BANLIST, sess, chan, mask, banner, time_str, 0);
 		return TRUE;
 	}
 
-	fe_add_ban_list (sess, mask, banner, time_str, is_exemption);
 	return TRUE;
 }
 
diff --git a/src/common/modes.c b/src/common/modes.c
index 6caa46b9..7326b6fe 100644
--- a/src/common/modes.c
+++ b/src/common/modes.c
@@ -824,6 +824,10 @@ inbound_005 (server * serv, char *word[])
 #ifndef WIN32
 			serv->have_except = TRUE;
 #endif
+		} else if (strcmp (word[w], "INVEX") == 0)
+		{
+			/* supports mode letter +I, default channel invite */
+			serv->have_invite = TRUE;
 		} else if (strncmp (word[w], "ELIST=", 6) == 0)
 		{
 			/* supports LIST >< min/max user counts? */
diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c
index 18015607..13147016 100644
--- a/src/common/proto-irc.c
+++ b/src/common/proto-irc.c
@@ -778,8 +778,18 @@ process_numeric (session * sess, int n,
 		}
 		break;
 
+	case 346:	/* +I-list entry */
+		if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 346))
+			goto def;
+		break;
+
+	case 347:	/* end of invite list */
+		if (!fe_ban_list_end (sess, 347))
+			goto def;
+		break;
+
 	case 348:	/* +e-list entry */
-		if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], TRUE))
+		if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 348))
 			goto def;
 		break;
 
@@ -790,9 +800,8 @@ process_numeric (session * sess, int n,
 			sess = serv->front_session;
 			goto def;
 		}
-		if (!fe_is_banwindow (sess))
+		if (!fe_ban_list_end (sess, 349))
 			goto def;
-		fe_ban_list_end (sess, TRUE);
 		break;
 
 	case 353:						  /* NAMES */
@@ -806,7 +815,8 @@ process_numeric (session * sess, int n,
 		break;
 
 	case 367: /* banlist entry */
-		inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], FALSE);
+		if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 367))
+			goto def;
 		break;
 
 	case 368:
@@ -816,9 +826,8 @@ process_numeric (session * sess, int n,
 			sess = serv->front_session;
 			goto def;
 		}
-		if (!fe_is_banwindow (sess))
+		if (!fe_ban_list_end (sess, 368))
 			goto def;
-		fe_ban_list_end (sess, FALSE);
 		break;
 
 	case 369:	/* WHOWAS end */
@@ -881,6 +890,18 @@ process_numeric (session * sess, int n,
 		notify_set_online (serv, word[4]);
 		break;
 
+	case 728:	/* +q-list entry */
+		/* NOTE:  FREENODE returns these results inconsistent with e.g. +b */
+		/* Who else has imlemented MODE_QUIET, I wonder? */
+		if (!inbound_banlist (sess, atol (word[8]), word[4], word[6], word[7], 728))
+			goto def;
+		break;
+
+	case 729:	/* end of quiet list */
+		if (!fe_ban_list_end (sess, 729))
+			goto def;
+		break;
+
 	case 903:	/* successful SASL auth */
 	case 904:	/* aborted SASL auth */
 	case 905:	/* failed SASL auth */
diff --git a/src/common/server.c b/src/common/server.c
index 42cae85f..8ad1d6ca 100644
--- a/src/common/server.c
+++ b/src/common/server.c
@@ -1890,6 +1890,7 @@ server_set_defaults (server *serv)
 	serv->have_idmsg = FALSE;
 	serv->have_sasl = FALSE;
 	serv->have_except = FALSE;
+	serv->have_invite = FALSE;
 }
 
 char *