Add identity management

Manage several TeamSpeak identities like the official client instead of
using one auto-generated identity file.

- IdentityStore/IdentityEntry keep each identity as a TeamSpeak-format INI
  in ~/.ts3jclient/identities, so files interchange with the TS3 client;
  supports create, import, export, rename, remove and a cancellable
  security-level search. A legacy identity.ini is migrated in on first load.
- Settings hold the default identity; bookmarks may pin their own, falling
  back to the default when unset.
- TeamspeakConnection now connects with the identity it is handed.
- Swing: Tools -> Identities manager, plus an identity drop-down in the
  connect and bookmark forms.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-13 07:42:08 +00:00
parent f912cab07b
commit 17ad6cde1c
12 changed files with 880 additions and 38 deletions

View File

@@ -1,5 +1,6 @@
package com.ts3client.ui;
import com.ts3client.config.IdentityStore;
import com.ts3client.config.Settings;
import javax.swing.BorderFactory;
@@ -23,10 +24,11 @@ public final class ConnectDialog extends JDialog {
private final JTextField portField;
private final JTextField nickField;
private final JPasswordField passwordField;
private final IdentityChooser identityChooser;
private boolean confirmed;
public ConnectDialog(Frame owner, Settings settings) {
public ConnectDialog(Frame owner, Settings settings, IdentityStore identities) {
super(owner, "Connect to Server", true);
String addr = settings.lastAddress;
@@ -44,6 +46,7 @@ public final class ConnectDialog extends JDialog {
portField = new JTextField(Integer.toString(port), 6);
nickField = new JTextField(settings.nickname, 18);
passwordField = new JPasswordField(settings.serverPassword, 18);
identityChooser = new IdentityChooser(identities, false, settings.defaultIdentityId);
JPanel form = new JPanel(new GridBagLayout());
form.setBorder(BorderFactory.createEmptyBorder(12, 12, 8, 12));
@@ -57,6 +60,7 @@ public final class ConnectDialog extends JDialog {
add(form, c, row++, "Port:", portField);
add(form, c, row++, "Nickname:", nickField);
add(form, c, row++, "Password (optional):", passwordField);
add(form, c, row++, "Identity:", identityChooser);
JPanel buttons = new JPanel(new BorderLayout());
JPanel right = new JPanel();
@@ -116,4 +120,9 @@ public final class ConnectDialog extends JDialog {
public String getPassword() {
return new String(passwordField.getPassword());
}
/** Chosen identity id, or an empty string to fall back to the default identity. */
public String getIdentityId() {
return identityChooser.getSelectedIdentityId();
}
}