Add the Tools > Ban List window

Reimplements the official client's ban list: a searchable table of the
server's bans with Add / Remove / Edit, an own-ban filter and highlight,
choosable columns, and the Add/Edit dialog whose IP and name patterns
can be read as IPv4/IPv6 wildcards, fixed strings or regular expressions
(translated to the regexes banadd takes exactly as the official client
does). Editing is add-then-delete, since the protocol has no banedit.

The ban list is read from the notifybanlist burst that answers banlist,
like channelpermlist. The menu item is only shown where the server grants
b_client_ban_list.

Also fixes ServerModel numbering permissions from 0 instead of 1, which
had every selfPermissionValue() lookup reading the neighbouring
permission — including the group-assignment menus.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-17 23:00:18 +00:00
co-authored by Claude Opus 5
parent 636090d075
commit 22e0304f25
20 changed files with 1705 additions and 44 deletions
@@ -7,9 +7,12 @@ import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.KeyStroke;
import javax.swing.MenuSelectionManager;
import javax.swing.SwingUtilities;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@@ -45,6 +48,11 @@ final class MainMenuBar extends JMenuBar {
void onShowIdentities();
/** Whether the current server lets us read its ban list; asked as the Tools menu opens. */
boolean canViewBanList();
void onShowBanList();
void onShowSettings();
void onShowAbout();
@@ -64,6 +72,7 @@ final class MainMenuBar extends JMenuBar {
private JCheckBoxMenuItem awayItem;
private JMenuItem awayStatusItem;
private JCheckBoxMenuItem commanderItem;
private JMenuItem banListItem;
MainMenuBar(Bookmarks bookmarks, Listener listener) {
this.bookmarks = bookmarks;
@@ -114,11 +123,34 @@ final class MainMenuBar extends JMenuBar {
JMenu tools = new JMenu("Tools");
JMenuItem identitiesItem = new JMenuItem("Identities…", Icons.of("IDENTITY_MANAGER"));
identitiesItem.addActionListener(e -> listener.onShowIdentities());
banListItem = new JMenuItem("Ban List", Icons.of("BAN_LIST"));
banListItem.addActionListener(e -> listener.onShowBanList());
JMenuItem options = new JMenuItem("Options…", Icons.of("SETTINGS"));
options.addActionListener(e -> listener.onShowSettings());
JPopupMenu.Separator banListSeparator = new JPopupMenu.Separator();
tools.add(identitiesItem);
tools.addSeparator();
tools.add(banListItem);
tools.add(banListSeparator);
tools.add(options);
// Permissions arrive after the connection does, so the item is judged as the menu opens
// rather than on a fixed refresh.
tools.addMenuListener(new MenuListener() {
@Override
public void menuSelected(MenuEvent e) {
boolean shown = banListItem.isEnabled() && listener.canViewBanList();
banListItem.setVisible(shown);
banListSeparator.setVisible(shown);
}
@Override
public void menuDeselected(MenuEvent e) {
}
@Override
public void menuCanceled(MenuEvent e) {
}
});
JMenu help = new JMenu("Help");
JMenuItem about = new JMenuItem("About", Icons.of("ABOUT"));
@@ -137,6 +169,7 @@ final class MainMenuBar extends JMenuBar {
awayItem.setEnabled(connected);
awayStatusItem.setEnabled(connected);
commanderItem.setEnabled(connected);
banListItem.setEnabled(connected);
awayItem.setSelected(away);
commanderItem.setSelected(commander);
}