myTeamSpeak: import TeamSpeak 6 contacts; bookmark myTeamSpeak switch
TeamSpeak 6 syncs chat contacts as item class 8 (Item_Data field 25). They are imported as friends keyed by myTeamSpeak ID, taken from the item or from the partner's chat ID (@<base32 id>:<homeserver>), the same bytes servers report as base64 client_myteamspeak_id. The contact list matches them to clients through the ID each client carries. Bookmarks gain TeamSpeak's "Enable myTeamSpeak features" switch (send_mytsid_on_server), stored and imported but not yet sent; what is still missing is noted in docs/myteamspeak/myteamspeak_server_signin.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -59,6 +59,7 @@ public final class BookmarksDialog extends JDialog {
|
||||
private final JTextField channel = new JTextField();
|
||||
private final JPasswordField channelPassword = new JPasswordField();
|
||||
private final JCheckBox connectOnStartup = new JCheckBox("Connect on startup");
|
||||
private final JCheckBox myTeamSpeakFeatures = new JCheckBox("Enable myTeamSpeak features");
|
||||
private final IdentityChooser identity;
|
||||
|
||||
private final JPanel details;
|
||||
@@ -144,6 +145,7 @@ public final class BookmarksDialog extends JDialog {
|
||||
addRow(panel, row++, "Channel password:", channelPassword);
|
||||
addRow(panel, row++, "Identity:", identity);
|
||||
addRow(panel, row++, "", connectOnStartup);
|
||||
addRow(panel, row++, "", myTeamSpeakFeatures);
|
||||
|
||||
GridBagConstraints filler = new GridBagConstraints();
|
||||
filler.gridx = 0;
|
||||
@@ -210,6 +212,7 @@ public final class BookmarksDialog extends JDialog {
|
||||
channel.setText(b == null ? "" : nullToEmpty(b.channel));
|
||||
channelPassword.setText(b == null ? "" : nullToEmpty(b.channelPassword));
|
||||
connectOnStartup.setSelected(b != null && b.connectOnStartup);
|
||||
myTeamSpeakFeatures.setSelected(b == null || b.myTeamSpeakFeatures);
|
||||
identity.setSelectedIdentityId(b == null ? "" : nullToEmpty(b.identityId));
|
||||
}
|
||||
|
||||
@@ -229,6 +232,7 @@ public final class BookmarksDialog extends JDialog {
|
||||
editing.channelPassword = new String(channelPassword.getPassword());
|
||||
editing.identityId = identity.getSelectedIdentityId();
|
||||
editing.connectOnStartup = connectOnStartup.isSelected();
|
||||
editing.myTeamSpeakFeatures = myTeamSpeakFeatures.isSelected();
|
||||
list.repaint();
|
||||
}
|
||||
|
||||
|
||||
@@ -208,13 +208,13 @@ final class ContactsDialog extends JDialog {
|
||||
tree.setTransferHandler(new DropHandler());
|
||||
}
|
||||
|
||||
/** Re-lists the contacts, keeping the selection on the same unique id. */
|
||||
/** Re-lists the contacts, keeping the selection on the same contact. */
|
||||
private void reload() {
|
||||
String selectedUid = selectedContact() == null ? null : selectedContact().uniqueId;
|
||||
String selectedUid = selectedContact() == null ? null : selectedContact().key();
|
||||
for (DefaultMutableTreeNode group : List.of(friends, blocked, neutral)) group.removeAllChildren();
|
||||
List<Contact> sorted = new ArrayList<>(contacts.all());
|
||||
sorted.sort(Comparator.comparing((Contact c) -> c.nickname, String.CASE_INSENSITIVE_ORDER)
|
||||
.thenComparing(c -> c.uniqueId));
|
||||
sorted.sort(Comparator.comparing(Contact::label, String.CASE_INSENSITIVE_ORDER)
|
||||
.thenComparing(Contact::key));
|
||||
for (Contact c : sorted) groupOf(c.type).add(new DefaultMutableTreeNode(c));
|
||||
treeModel.reload();
|
||||
for (int i = 0; i < tree.getRowCount(); i++) tree.expandRow(i);
|
||||
@@ -233,12 +233,14 @@ final class ContactsDialog extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
/** Selects the contact with a unique id, if it is on the list. */
|
||||
/** Selects the contact a client's unique id (or a contact key) is filed under, if it is on the list. */
|
||||
void select(String uniqueId) {
|
||||
Contact wanted = contacts.find(uniqueId);
|
||||
if (wanted == null) return;
|
||||
java.util.Enumeration<?> nodes = root.depthFirstEnumeration();
|
||||
while (nodes.hasMoreElements()) {
|
||||
DefaultMutableTreeNode n = (DefaultMutableTreeNode) nodes.nextElement();
|
||||
if (n.getUserObject() instanceof Contact && ((Contact) n.getUserObject()).uniqueId.equals(uniqueId)) {
|
||||
if (n.getUserObject() instanceof Contact && ((Contact) n.getUserObject()).key().equals(wanted.key())) {
|
||||
TreePath path = new TreePath(n.getPath());
|
||||
tree.setSelectionPath(path);
|
||||
tree.scrollPathToVisible(path);
|
||||
@@ -276,9 +278,10 @@ final class ContactsDialog extends JDialog {
|
||||
applyDefaults.addActionListener(a -> edit(c -> c.applyDefaults(settings.contactDefaults.of(c.type))));
|
||||
menu.add(applyDefaults);
|
||||
menu.addSeparator();
|
||||
JMenuItem copyUid = new JMenuItem("Copy Unique ID to Clipboard", Icons.of("COPY"));
|
||||
JMenuItem copyUid = new JMenuItem(contact.uniqueId.isEmpty()
|
||||
? "Copy myTeamSpeak ID to Clipboard" : "Copy Unique ID to Clipboard", Icons.of("COPY"));
|
||||
copyUid.addActionListener(a -> Toolkit.getDefaultToolkit().getSystemClipboard()
|
||||
.setContents(new StringSelection(contact.uniqueId), null));
|
||||
.setContents(new StringSelection(contact.shownId()), null));
|
||||
menu.add(copyUid);
|
||||
menu.show(tree, e.getX(), e.getY());
|
||||
}
|
||||
@@ -287,9 +290,9 @@ final class ContactsDialog extends JDialog {
|
||||
Contact contact = selectedContact();
|
||||
if (contact == null) return;
|
||||
int answer = JOptionPane.showConfirmDialog(this,
|
||||
"Do you really want to delete contact " + contact.nickname + "?", "Remove Contact",
|
||||
"Do you really want to delete contact " + contact.label() + "?", "Remove Contact",
|
||||
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||
if (answer == JOptionPane.YES_OPTION) contacts.remove(contact.uniqueId);
|
||||
if (answer == JOptionPane.YES_OPTION) contacts.remove(contact.key());
|
||||
}
|
||||
|
||||
private void importFromTeamSpeak() {
|
||||
@@ -545,7 +548,7 @@ final class ContactsDialog extends JDialog {
|
||||
Object obj = ((DefaultMutableTreeNode) value).getUserObject();
|
||||
if (obj instanceof Contact) {
|
||||
Contact c = (Contact) obj;
|
||||
setText("<html>" + esc(c.nickname) + " <span style='color:" + hex(sel ? getForeground() : Theme.chatSystem())
|
||||
setText("<html>" + esc(c.label()) + " <span style='color:" + hex(sel ? getForeground() : Theme.chatSystem())
|
||||
+ "'> " + (c.lastSeen == null ? "Never" : SEEN_DAY.format(c.lastSeen)) + "</span></html>");
|
||||
setFont(Theme.uiFont());
|
||||
setBorder(margin);
|
||||
|
||||
@@ -1023,7 +1023,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
||||
sessions.microphoneOwner() == null ? null : sessions.microphoneOwner().connection().getMicrophone(),
|
||||
selected == null ? null : selected.connection().getPlayback(),
|
||||
sounds, hotkeys,
|
||||
new MyTeamSpeakPanel(myTeamSpeak, new TeamSpeakImporter(identities, bookmarks, settings),
|
||||
new MyTeamSpeakPanel(myTeamSpeak, new TeamSpeakImporter(identities, bookmarks, settings, contacts),
|
||||
menuBar::rebuildBookmarks, this::myTeamSpeakChanged),
|
||||
() -> {
|
||||
applyOutputSettingsToAllTabs();
|
||||
|
||||
@@ -61,6 +61,7 @@ final class MyTeamSpeakPanel extends JPanel {
|
||||
private final JPanel details = new JPanel(new GridBagLayout());
|
||||
private final ItemTable identities = new ItemTable("Nickname");
|
||||
private final ItemTable bookmarks = new ItemTable("Address");
|
||||
private final ItemTable contacts = new ItemTable("myTeamSpeak ID");
|
||||
private final FormPanel sections = new FormPanel(false);
|
||||
private final JButton refresh = new JButton("Refresh");
|
||||
private final JButton importButton = new JButton("Import selected");
|
||||
@@ -91,8 +92,8 @@ final class MyTeamSpeakPanel extends JPanel {
|
||||
GridBagConstraints c = FormPanel.gbc();
|
||||
c.gridwidth = 2;
|
||||
c.gridy = 0;
|
||||
form.add(new JLabel("<html>Sign in to your myTeamSpeak account to bring over the bookmarks and "
|
||||
+ "identities it synchronises. The client stays signed in; your password itself is not kept.</html>"), c);
|
||||
form.add(new JLabel("<html>Sign in to your myTeamSpeak account to bring over the bookmarks, "
|
||||
+ "identities and contacts it synchronises. The client stays signed in; your password itself is not kept.</html>"), c);
|
||||
c.gridwidth = 1;
|
||||
FormPanel.addRow(form, c, 1, new JLabel("Email:"), email);
|
||||
FormPanel.addRow(form, c, 2, new JLabel("Password:"), password);
|
||||
@@ -245,11 +246,12 @@ final class MyTeamSpeakPanel extends JPanel {
|
||||
List<Row> rows = new ArrayList<>();
|
||||
for (SyncItem item : accountItems) {
|
||||
if (item instanceof SyncItem.Folder) continue;
|
||||
if (item instanceof SyncItem.Contact contact && !TeamSpeakImporter.isImportable(contact)) continue;
|
||||
boolean present = importer.isPresent(item);
|
||||
rows.add(new Row(item, present, !present));
|
||||
}
|
||||
setRows(rows);
|
||||
status(dataStatus, rows.isEmpty() ? "The account holds no bookmarks or identities." : " ", false);
|
||||
status(dataStatus, rows.isEmpty() ? "The account holds no bookmarks, identities or contacts." : " ", false);
|
||||
updateImportButton();
|
||||
}
|
||||
|
||||
@@ -258,8 +260,9 @@ final class MyTeamSpeakPanel extends JPanel {
|
||||
if (chosen.isEmpty()) return;
|
||||
try {
|
||||
TeamSpeakImporter.Result r = importer.importSelected(accountItems, chosen);
|
||||
status(dataStatus, "Imported " + count(r.identitiesAdded(), "identity", "identities") + " and "
|
||||
+ count(r.bookmarksAdded(), "bookmark", "bookmarks") + ".", false);
|
||||
status(dataStatus, "Imported " + count(r.identitiesAdded(), "identity", "identities") + ", "
|
||||
+ count(r.bookmarksAdded(), "bookmark", "bookmarks") + " and "
|
||||
+ count(r.contactsAdded(), "contact", "contacts") + ".", false);
|
||||
if (onImported != null) onImported.run();
|
||||
} catch (IOException e) {
|
||||
status(dataStatus, "Could not import: " + e.getMessage(), true);
|
||||
@@ -304,18 +307,20 @@ final class MyTeamSpeakPanel extends JPanel {
|
||||
}
|
||||
|
||||
private Stream<Row> allRows() {
|
||||
return Stream.concat(identities.rows.stream(), bookmarks.rows.stream());
|
||||
return Stream.of(identities, bookmarks, contacts).flatMap(table -> table.rows.stream());
|
||||
}
|
||||
|
||||
/** Splits the rows into the Identities and Bookmarks sections, leaving out an empty one. */
|
||||
/** Splits the rows into the Identities, Bookmarks and Contacts sections, leaving out an empty one. */
|
||||
private void setRows(List<Row> rows) {
|
||||
identities.set(rows.stream().filter(r -> r.item() instanceof SyncItem.Identity).toList());
|
||||
bookmarks.set(rows.stream().filter(r -> r.item() instanceof SyncItem.Bookmark).toList());
|
||||
contacts.set(rows.stream().filter(r -> r.item() instanceof SyncItem.Contact).toList());
|
||||
sections.removeAll();
|
||||
GridBagConstraints c = FormPanel.gbc();
|
||||
int row = 0;
|
||||
if (!identities.rows.isEmpty()) row = addSection(c, row, "Identities", identities);
|
||||
if (!bookmarks.rows.isEmpty()) row = addSection(c, row, "Bookmarks", bookmarks);
|
||||
if (!contacts.rows.isEmpty()) row = addSection(c, row, "Contacts", contacts);
|
||||
FormPanel.addFiller(sections, c, row);
|
||||
sections.revalidate();
|
||||
sections.repaint();
|
||||
@@ -414,11 +419,13 @@ final class MyTeamSpeakPanel extends JPanel {
|
||||
case 1 -> switch (r.item()) {
|
||||
case SyncItem.Bookmark b -> b.name();
|
||||
case SyncItem.Identity i -> i.name();
|
||||
case SyncItem.Contact contact -> contact.customName();
|
||||
default -> "";
|
||||
};
|
||||
case 2 -> switch (r.item()) {
|
||||
case SyncItem.Bookmark b -> Bookmark.hostPort(b.address(), b.port());
|
||||
case SyncItem.Identity i -> i.nickname();
|
||||
case SyncItem.Contact contact -> contact.myTeamSpeakId();
|
||||
default -> "";
|
||||
};
|
||||
default -> r.present() ? "Yes" : "";
|
||||
|
||||
Reference in New Issue
Block a user