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:
@@ -24,6 +24,8 @@ public final class Bookmark {
|
||||
public String channelPassword = "";
|
||||
/** Connect to this server automatically when the client starts. */
|
||||
public boolean connectOnStartup = false;
|
||||
/** TeamSpeak's "Enable myTeamSpeak features" ({@code Bookmark_Data.send_mytsid_on_server}). */
|
||||
public boolean myTeamSpeakFeatures = true;
|
||||
/** The server's icon as last seen there, 0 for none or not yet known. */
|
||||
public long iconId = 0;
|
||||
|
||||
@@ -46,6 +48,7 @@ public final class Bookmark {
|
||||
b.channel = channel;
|
||||
b.channelPassword = channelPassword;
|
||||
b.connectOnStartup = connectOnStartup;
|
||||
b.myTeamSpeakFeatures = myTeamSpeakFeatures;
|
||||
b.iconId = iconId;
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ public final class Bookmarks {
|
||||
bm.channel = p.getProperty(prefix + "channel", "");
|
||||
bm.channelPassword = p.getProperty(prefix + "channelPassword", "");
|
||||
bm.connectOnStartup = Boolean.parseBoolean(p.getProperty(prefix + "connectOnStartup", "false"));
|
||||
bm.myTeamSpeakFeatures = Boolean.parseBoolean(p.getProperty(prefix + "myTeamSpeakFeatures", "true"));
|
||||
bm.iconId = parseLong(p.getProperty(prefix + "iconId"));
|
||||
if (bm.address != null && !bm.address.isBlank()) b.entries.add(bm);
|
||||
}
|
||||
@@ -110,6 +111,7 @@ public final class Bookmarks {
|
||||
p.setProperty(prefix + "channel", nullToEmpty(bm.channel));
|
||||
p.setProperty(prefix + "channelPassword", nullToEmpty(bm.channelPassword));
|
||||
p.setProperty(prefix + "connectOnStartup", Boolean.toString(bm.connectOnStartup));
|
||||
p.setProperty(prefix + "myTeamSpeakFeatures", Boolean.toString(bm.myTeamSpeakFeatures));
|
||||
p.setProperty(prefix + "iconId", Long.toString(bm.iconId));
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -8,19 +8,27 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* One entry of the contact list, keyed by the client's unique id.
|
||||
* One entry of the contact list, keyed by the client's unique id — or, for a contact
|
||||
* brought over from TeamSpeak 6, by a myTeamSpeak ID, which is the person rather
|
||||
* than one of their identities.
|
||||
*
|
||||
* <p>The fields are exactly the ones the TeamSpeak 3 client keeps for a contact,
|
||||
* and {@link #toRecord()} / {@link #parseRecord} use its own {@code Key=Value}
|
||||
* serialisation (the {@code value} column of its {@code Contacts} table), so
|
||||
* records can be exchanged with it as they are.
|
||||
* records can be exchanged with it as they are. The myTeamSpeak ID is an extra
|
||||
* {@code MyTsId} line, written only when set.
|
||||
*/
|
||||
public final class Contact {
|
||||
|
||||
/** TeamSpeak writes {@code LastSeen} as an ISO local date-time without zone. */
|
||||
private static final DateTimeFormatter LAST_SEEN = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
|
||||
/** Base64 never holds a colon, so these keys cannot pass for a unique id. */
|
||||
private static final String MYTS_KEY_PREFIX = "myts:";
|
||||
|
||||
/** Empty for a contact known only by its {@link #myTeamSpeakId}. */
|
||||
public final String uniqueId;
|
||||
/** The {@code client_myteamspeak_id} the contact's clients carry, or empty. */
|
||||
public final String myTeamSpeakId;
|
||||
/** Custom name; TeamSpeak seeds it with the nickname the client had when added. */
|
||||
public String nickname = "";
|
||||
public String phoneticNickname = "";
|
||||
@@ -42,7 +50,27 @@ public final class Contact {
|
||||
public String lastSeenServerAddress = "";
|
||||
|
||||
public Contact(String uniqueId) {
|
||||
this(uniqueId, "");
|
||||
}
|
||||
|
||||
public Contact(String uniqueId, String myTeamSpeakId) {
|
||||
this.uniqueId = uniqueId == null ? "" : uniqueId;
|
||||
this.myTeamSpeakId = myTeamSpeakId == null ? "" : myTeamSpeakId;
|
||||
}
|
||||
|
||||
/** What the contact list files the entry under: the unique id, else the myTeamSpeak ID. */
|
||||
public String key() {
|
||||
return uniqueId.isEmpty() ? MYTS_KEY_PREFIX + myTeamSpeakId : uniqueId;
|
||||
}
|
||||
|
||||
/** The id shown for the contact: its unique id, else its myTeamSpeak ID. */
|
||||
public String shownId() {
|
||||
return uniqueId.isEmpty() ? myTeamSpeakId : uniqueId;
|
||||
}
|
||||
|
||||
/** What the contact list calls the contact: its custom name, else its id. */
|
||||
public String label() {
|
||||
return nickname.isBlank() ? shownId() : nickname;
|
||||
}
|
||||
|
||||
/** The name the contact is shown under, given the nickname it currently carries. */
|
||||
@@ -56,12 +84,12 @@ public final class Contact {
|
||||
}
|
||||
|
||||
public Contact copy() {
|
||||
Contact c = new Contact(uniqueId);
|
||||
Contact c = new Contact(uniqueId, myTeamSpeakId);
|
||||
c.copyFrom(this);
|
||||
return c;
|
||||
}
|
||||
|
||||
/** Takes over every field but the unique id. */
|
||||
/** Takes over every field but the ids. */
|
||||
public void copyFrom(Contact other) {
|
||||
nickname = other.nickname;
|
||||
phoneticNickname = other.phoneticNickname;
|
||||
@@ -115,10 +143,11 @@ public final class Contact {
|
||||
line(sb, "LastSeen", lastSeen == null ? "" : LAST_SEEN.format(lastSeen));
|
||||
line(sb, "LastSeenServerName", lastSeenServerName);
|
||||
line(sb, "LastSeenServerAddress", lastSeenServerAddress);
|
||||
if (!myTeamSpeakId.isEmpty()) line(sb, "MyTsId", myTeamSpeakId);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Parses a TeamSpeak contact record, or returns {@code null} when it carries no unique id. */
|
||||
/** Parses a TeamSpeak contact record, or returns {@code null} when it carries no id at all. */
|
||||
public static Contact parseRecord(String record) {
|
||||
if (record == null) return null;
|
||||
Map<String, String> fields = new LinkedHashMap<>();
|
||||
@@ -127,9 +156,10 @@ public final class Contact {
|
||||
if (eq > 0) fields.put(line.substring(0, eq).trim(), line.substring(eq + 1));
|
||||
}
|
||||
String uid = fields.getOrDefault("IDS", "").trim();
|
||||
if (uid.isEmpty()) return null;
|
||||
String myTsId = fields.getOrDefault("MyTsId", "").trim();
|
||||
if (uid.isEmpty() && myTsId.isEmpty()) return null;
|
||||
|
||||
Contact c = new Contact(uid);
|
||||
Contact c = new Contact(uid, myTsId);
|
||||
c.nickname = fields.getOrDefault("Nickname", "");
|
||||
c.type = ContactType.fromCode(parseInt(fields.get("Friend"), ContactType.NEUTRAL.code()));
|
||||
c.automute = parseFlag(fields.get("Automute"));
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -31,6 +32,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* between the two verbatim. On first run the list is seeded from an installed
|
||||
* TeamSpeak client's database, when one is found.
|
||||
*
|
||||
* <p>A contact known by its myTeamSpeak ID alone stands for every client carrying
|
||||
* that ID, once the connection {@linkplain #link links} the client to it; lookups by
|
||||
* unique id then find it like any other.
|
||||
*
|
||||
* <p>Safe to use from any thread: lookups are lock-free on a snapshot, and
|
||||
* mutations are serialised and announced to listeners on the calling thread.
|
||||
*/
|
||||
@@ -49,7 +54,9 @@ public final class ContactStore {
|
||||
}
|
||||
|
||||
private final File file;
|
||||
private final Map<String, Contact> byUid = new LinkedHashMap<>();
|
||||
private final Map<String, Contact> byKey = new LinkedHashMap<>();
|
||||
/** Unique id → myTeamSpeak ID of the clients seen so far, which only lives as long as the client. */
|
||||
private final Map<String, String> myTsIds = new ConcurrentHashMap<>();
|
||||
/** Immutable snapshot for readers, replaced under the lock after every change. */
|
||||
private volatile List<Contact> snapshot = List.of();
|
||||
private final List<Listener> listeners = new CopyOnWriteArrayList<>();
|
||||
@@ -96,9 +103,9 @@ public final class ContactStore {
|
||||
if (c != null) parsed.add(c);
|
||||
}
|
||||
synchronized (this) {
|
||||
byUid.clear();
|
||||
for (Contact c : parsed) byUid.put(c.uniqueId, c);
|
||||
snapshot = List.copyOf(byUid.values());
|
||||
byKey.clear();
|
||||
for (Contact c : parsed) byKey.put(c.key(), c);
|
||||
snapshot = List.copyOf(byKey.values());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,14 +139,33 @@ public final class ContactStore {
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* The contact a client is filed under: by its unique id, else by the myTeamSpeak ID it was
|
||||
* {@linkplain #link linked} with. A {@link Contact#key()} finds its contact too.
|
||||
*/
|
||||
public Contact find(String uniqueId) {
|
||||
if (uniqueId == null || uniqueId.isEmpty()) return null;
|
||||
for (Contact c : snapshot) {
|
||||
if (c.uniqueId.equals(uniqueId)) return c;
|
||||
if (c.uniqueId.equals(uniqueId) || c.key().equals(uniqueId)) return c;
|
||||
}
|
||||
return findByMyTeamSpeakId(myTsIds.get(uniqueId));
|
||||
}
|
||||
|
||||
public Contact findByMyTeamSpeakId(String myTeamSpeakId) {
|
||||
if (myTeamSpeakId == null || myTeamSpeakId.isEmpty()) return null;
|
||||
for (Contact c : snapshot) {
|
||||
if (c.myTeamSpeakId.equals(myTeamSpeakId)) return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Notes which myTeamSpeak ID a client carries (empty for none), so {@link #find} can match it. */
|
||||
public void link(String uniqueId, String myTeamSpeakId) {
|
||||
if (uniqueId == null || uniqueId.isEmpty()) return;
|
||||
if (myTeamSpeakId == null || myTeamSpeakId.isEmpty()) myTsIds.remove(uniqueId);
|
||||
else myTsIds.put(uniqueId, myTeamSpeakId);
|
||||
}
|
||||
|
||||
/** The type a client is filed under, {@code null} when it is not a contact. */
|
||||
public ContactType typeOf(String uniqueId) {
|
||||
Contact c = find(uniqueId);
|
||||
@@ -163,35 +189,38 @@ public final class ContactStore {
|
||||
public Contact add(String uniqueId, String nickname, ContactType type, ContactDefaults defaults) {
|
||||
Contact contact;
|
||||
synchronized (this) {
|
||||
contact = byUid.get(uniqueId);
|
||||
contact = find(uniqueId);
|
||||
if (contact == null) {
|
||||
contact = new Contact(uniqueId);
|
||||
contact.nickname = nickname == null ? "" : nickname;
|
||||
contact.applyDefaults(defaults.of(type));
|
||||
byUid.put(uniqueId, contact);
|
||||
byKey.put(contact.key(), contact);
|
||||
}
|
||||
contact.type = type;
|
||||
snapshot = List.copyOf(byUid.values());
|
||||
snapshot = List.copyOf(byKey.values());
|
||||
}
|
||||
changed();
|
||||
return contact;
|
||||
}
|
||||
|
||||
/** Stores an edited contact, replacing any entry with the same unique id. */
|
||||
/** Stores an edited contact, replacing any entry with the same {@link Contact#key()}. */
|
||||
public void put(Contact contact) {
|
||||
synchronized (this) {
|
||||
Contact existing = byUid.get(contact.uniqueId);
|
||||
Contact existing = byKey.get(contact.key());
|
||||
if (existing != null && existing != contact) existing.copyFrom(contact);
|
||||
else byUid.put(contact.uniqueId, contact);
|
||||
snapshot = List.copyOf(byUid.values());
|
||||
else byKey.put(contact.key(), contact);
|
||||
snapshot = List.copyOf(byKey.values());
|
||||
}
|
||||
changed();
|
||||
}
|
||||
|
||||
/** Removes the contact {@link #find} gives for the id. */
|
||||
public void remove(String uniqueId) {
|
||||
synchronized (this) {
|
||||
if (byUid.remove(uniqueId) == null) return;
|
||||
snapshot = List.copyOf(byUid.values());
|
||||
Contact contact = find(uniqueId);
|
||||
if (contact == null) return;
|
||||
byKey.remove(contact.key());
|
||||
snapshot = List.copyOf(byKey.values());
|
||||
}
|
||||
changed();
|
||||
}
|
||||
@@ -199,9 +228,9 @@ public final class ContactStore {
|
||||
/** Takes over a whole list, e.g. one read from the TeamSpeak client. */
|
||||
public void replaceAll(Collection<Contact> contacts) {
|
||||
synchronized (this) {
|
||||
byUid.clear();
|
||||
for (Contact c : contacts) byUid.put(c.uniqueId, c);
|
||||
snapshot = List.copyOf(byUid.values());
|
||||
byKey.clear();
|
||||
for (Contact c : contacts) byKey.put(c.key(), c);
|
||||
snapshot = List.copyOf(byKey.values());
|
||||
}
|
||||
changed();
|
||||
}
|
||||
@@ -216,9 +245,9 @@ public final class ContactStore {
|
||||
int added = 0;
|
||||
synchronized (this) {
|
||||
for (Contact c : contacts) {
|
||||
if (byUid.put(c.uniqueId, c) == null) added++;
|
||||
if (byKey.put(c.key(), c) == null) added++;
|
||||
}
|
||||
snapshot = List.copyOf(byUid.values());
|
||||
snapshot = List.copyOf(byKey.values());
|
||||
}
|
||||
changed();
|
||||
return added;
|
||||
|
||||
@@ -12,27 +12,8 @@ import java.time.Instant;
|
||||
*/
|
||||
public record AccountInfo(String username, String userId, String uuid, Instant created) {
|
||||
|
||||
private static final String BASE32 = "abcdefghijklmnopqrstuvwxyz234567";
|
||||
|
||||
static AccountInfo of(String username, String uuid, byte[] userId, long createdSeconds) {
|
||||
return new AccountInfo(username, userId == null ? "" : base32(userId), uuid,
|
||||
return new AccountInfo(username, userId == null ? "" : MyTsId.base32(userId), uuid,
|
||||
createdSeconds > 0 ? Instant.ofEpochSecond(createdSeconds) : null);
|
||||
}
|
||||
|
||||
/** RFC 4648 base32, lowercase and unpadded. */
|
||||
static String base32(byte[] data) {
|
||||
StringBuilder out = new StringBuilder((data.length * 8 + 4) / 5);
|
||||
int buffer = 0, bits = 0;
|
||||
for (byte b : data) {
|
||||
buffer = (buffer << 8) | (b & 0xff);
|
||||
bits += 8;
|
||||
while (bits >= 5) {
|
||||
out.append(BASE32.charAt((buffer >> (bits - 5)) & 31));
|
||||
bits -= 5;
|
||||
}
|
||||
buffer &= (1 << bits) - 1;
|
||||
}
|
||||
if (bits > 0) out.append(BASE32.charAt((buffer << (5 - bits)) & 31));
|
||||
return out.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Reads the bookmarks and identities a myTeamSpeak account synchronises, the way
|
||||
* Reads the bookmarks, identities and contacts a myTeamSpeak account synchronises, the way
|
||||
* the official client pulls them on a fresh install: sign in, ask for every item
|
||||
* of the wanted classes against an empty local state, decrypt them, and sign out.
|
||||
* Nothing is ever written to the account. Staying signed in is {@link MyTeamSpeakLogin}'s.
|
||||
@@ -41,11 +41,16 @@ public final class MyTeamSpeak {
|
||||
public long bookmarks() {
|
||||
return items.stream().filter(SyncItem.Bookmark.class::isInstance).count();
|
||||
}
|
||||
|
||||
public long contacts() {
|
||||
return items.stream().filter(SyncItem.Contact.class::isInstance).count();
|
||||
}
|
||||
}
|
||||
|
||||
private static final String NO_VERSION = "00000000-0000-0000-0000-000000000000";
|
||||
private static final int SYNC_VERSION_1_1 = 1;
|
||||
private static final int[] ITEM_CLASSES = {0 /* BOOKMARK */, 1 /* IDENTITY */, 6 /* ITEM_FOLDER */};
|
||||
private static final int CONTACTS = 8;
|
||||
private static final int[] ITEM_CLASSES = {0 /* BOOKMARK */, 1 /* IDENTITY */, 6 /* ITEM_FOLDER */, CONTACTS};
|
||||
|
||||
private static final int LOGIN_OK = 200;
|
||||
private static final int LOGIN_OFFLINE = 201;
|
||||
@@ -159,7 +164,7 @@ public final class MyTeamSpeak {
|
||||
ProtobufReader reply = new ProtobufReader(
|
||||
transport.call("synchronization", "requestServerItems", request.toByteArray()));
|
||||
|
||||
List<byte[]> frames = new ArrayList<>();
|
||||
List<Frame> frames = new ArrayList<>();
|
||||
int status = 0;
|
||||
while (reply.next()) {
|
||||
switch (reply.fieldNumber()) {
|
||||
@@ -173,13 +178,8 @@ public final class MyTeamSpeak {
|
||||
}
|
||||
|
||||
List<SyncItem> items = new ArrayList<>();
|
||||
for (byte[] frame : frames) {
|
||||
SyncItem item;
|
||||
try {
|
||||
item = SyncItemDecoder.decode(MyTsCrypto.decryptItem(frame, itemKey));
|
||||
} catch (GeneralSecurityException e) {
|
||||
throw new MyTsException("Could not decrypt the account's items", e);
|
||||
}
|
||||
for (Frame frame : frames) {
|
||||
SyncItem item = decode(frame, itemKey);
|
||||
if (item != null) items.add(item);
|
||||
}
|
||||
return SyncOrder.sorted(items);
|
||||
@@ -191,7 +191,7 @@ public final class MyTeamSpeak {
|
||||
* and not all of them are encrypted (add-on flags come in the clear), so only the
|
||||
* wanted classes are kept.
|
||||
*/
|
||||
private static void collectFrames(ProtobufReader itemClass, List<byte[]> frames) throws IOException {
|
||||
private static void collectFrames(ProtobufReader itemClass, List<Frame> frames) throws IOException {
|
||||
int classId = 0;
|
||||
List<byte[]> blobs = new ArrayList<>();
|
||||
while (itemClass.next()) {
|
||||
@@ -205,7 +205,30 @@ public final class MyTeamSpeak {
|
||||
}
|
||||
}
|
||||
for (int wanted : ITEM_CLASSES) {
|
||||
if (wanted == classId) frames.addAll(blobs);
|
||||
if (wanted != classId) continue;
|
||||
for (byte[] blob : blobs) frames.add(new Frame(classId, blob));
|
||||
}
|
||||
}
|
||||
|
||||
private record Frame(int itemClass, byte[] blob) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Contacts are TeamSpeak 6's and were never seen in an account, so one that does not
|
||||
* decrypt is taken for plaintext, like add-on flags, or else left out — not allowed to
|
||||
* fail the bookmarks and identities.
|
||||
*/
|
||||
private static SyncItem decode(Frame frame, byte[] itemKey) throws IOException, MyTsException {
|
||||
try {
|
||||
return SyncItemDecoder.decode(MyTsCrypto.decryptItem(frame.blob(), itemKey));
|
||||
} catch (GeneralSecurityException e) {
|
||||
if (frame.itemClass() != CONTACTS) throw new MyTsException("Could not decrypt the account's items", e);
|
||||
}
|
||||
try {
|
||||
SyncItem item = SyncItemDecoder.decode(frame.blob());
|
||||
return item instanceof SyncItem.Contact ? item : null;
|
||||
} catch (IOException | RuntimeException notPlaintext) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package eu.lixko.ts3j.client.myts;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* The two spellings of a myTeamSpeak ID. Servers carry it as {@code client_myteamspeak_id},
|
||||
* standard base64; TeamSpeak chat puts the same bytes, lowercase base32, in the localpart of
|
||||
* the account's Matrix user ID ({@code @<base32>:<homeserver>}).
|
||||
*/
|
||||
public final class MyTsId {
|
||||
|
||||
private static final String BASE32 = "abcdefghijklmnopqrstuvwxyz234567";
|
||||
|
||||
private MyTsId() {
|
||||
}
|
||||
|
||||
/** The myTeamSpeak ID behind a TeamSpeak chat user ID, or empty when it is not one. */
|
||||
public static String fromChatId(String chatId) {
|
||||
if (chatId == null || !chatId.startsWith("@")) return "";
|
||||
int colon = chatId.indexOf(':');
|
||||
if (colon < 2) return "";
|
||||
byte[] id = base32Decode(chatId.substring(1, colon));
|
||||
return id == null ? "" : Base64.getEncoder().encodeToString(id);
|
||||
}
|
||||
|
||||
/** RFC 4648 base32, lowercase and unpadded. */
|
||||
static String base32(byte[] data) {
|
||||
StringBuilder out = new StringBuilder((data.length * 8 + 4) / 5);
|
||||
int buffer = 0, bits = 0;
|
||||
for (byte b : data) {
|
||||
buffer = (buffer << 8) | (b & 0xff);
|
||||
bits += 8;
|
||||
while (bits >= 5) {
|
||||
out.append(BASE32.charAt((buffer >> (bits - 5)) & 31));
|
||||
bits -= 5;
|
||||
}
|
||||
buffer &= (1 << bits) - 1;
|
||||
}
|
||||
if (bits > 0) out.append(BASE32.charAt((buffer << (5 - bits)) & 31));
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
/** The inverse of {@link #base32}, either case; {@code null} for anything else. */
|
||||
static byte[] base32Decode(String text) {
|
||||
byte[] out = new byte[text.length() * 5 / 8];
|
||||
int buffer = 0, bits = 0, n = 0;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
int value = BASE32.indexOf(Character.toLowerCase(text.charAt(i)));
|
||||
if (value < 0) return null;
|
||||
buffer = (buffer << 5) | value;
|
||||
bits += 5;
|
||||
if (bits >= 8) {
|
||||
out[n++] = (byte) (buffer >> (bits - 8));
|
||||
bits -= 8;
|
||||
buffer &= (1 << bits) - 1;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ public final class ClientEntry {
|
||||
/** How text-to-speech should say the nickname ({@code client_nickname_phonetic}). */
|
||||
public volatile String phoneticNickname = "";
|
||||
public volatile String uniqueId = "";
|
||||
/** {@code client_myteamspeak_id}: the client's myTeamSpeak account, empty when it shares none. */
|
||||
public volatile String myTeamSpeakId = "";
|
||||
public volatile int databaseId;
|
||||
public volatile int type; // 0 = normal voice client, 1 = server-query
|
||||
public volatile int talkPower;
|
||||
|
||||
@@ -47,6 +47,7 @@ final class ConnectionEventHandler implements TS3Listener {
|
||||
c.away = e.isClientAway();
|
||||
c.awayMessage = TeamspeakConnection.orEmpty(e.get("client_away_message"));
|
||||
c.uniqueId = TeamspeakConnection.orEmpty(e.getUniqueClientIdentifier());
|
||||
c.myTeamSpeakId = TeamspeakConnection.orEmpty(e.get("client_myteamspeak_id"));
|
||||
c.avatarFlag = TeamspeakConnection.orEmpty(e.get("client_flag_avatar"));
|
||||
c.country = TeamspeakConnection.orEmpty(e.get("client_country"));
|
||||
c.databaseId = e.getClientDatabaseId();
|
||||
@@ -351,6 +352,10 @@ final class ConnectionEventHandler implements TS3Listener {
|
||||
c.channelCommander = e.getBoolean("client_is_channel_commander");
|
||||
if (reported(e, "client_flag_avatar")) c.avatarFlag = TeamspeakConnection.orEmpty(e.get("client_flag_avatar"));
|
||||
if (reported(e, "client_country")) c.country = TeamspeakConnection.orEmpty(e.get("client_country"));
|
||||
if (reported(e, "client_myteamspeak_id")) {
|
||||
c.myTeamSpeakId = TeamspeakConnection.orEmpty(e.get("client_myteamspeak_id"));
|
||||
if (!c.self && !c.isQuery()) conn.applyContact(c);
|
||||
}
|
||||
if (has(e, "client_unread_messages")) {
|
||||
int before = c.unreadMessages;
|
||||
c.unreadMessages = safeInt(e, "client_unread_messages");
|
||||
|
||||
@@ -1312,9 +1312,11 @@ public final class TeamspeakConnection implements TS3Listener {
|
||||
|
||||
/**
|
||||
* Applies a client's contact entry to its playback — the automatic mute and the
|
||||
* volume modifier — and records the sighting. Called when the client appears.
|
||||
* volume modifier — and records the sighting. Called when the client appears, which
|
||||
* is also when its myTeamSpeak ID can first match a contact.
|
||||
*/
|
||||
void applyContact(ClientEntry client) {
|
||||
contacts.link(client.uniqueId, client.myTeamSpeakId);
|
||||
Contact contact = applyContactPlayback(client);
|
||||
if (contact != null) contacts.markSeen(client.uniqueId, model.getServerName(), serverHost + ":" + serverPort);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package eu.lixko.ts3j.client.teamspeak;
|
||||
|
||||
import eu.lixko.ts3j.client.myts.MyTsId;
|
||||
|
||||
/**
|
||||
* One entry of the TeamSpeak 3 client's synchronised item store — the data that
|
||||
* a myTeamSpeak account syncs between installations. Since client 3.1 the
|
||||
* bookmarks and identities of every installation live there, signed in or not.
|
||||
* Whisper lists, hotkey profiles and the other item classes are not modelled.
|
||||
* TeamSpeak 6 adds contacts. Whisper lists, hotkey profiles and the other item
|
||||
* classes are not modelled.
|
||||
*/
|
||||
public sealed interface SyncItem {
|
||||
|
||||
@@ -33,10 +36,28 @@ public sealed interface SyncItem {
|
||||
* in some myTeamSpeak items); empty for the default
|
||||
* @param defaultChannel channel path to join, "/"-separated; empty for the server default
|
||||
* @param defaultChannelId the same channel by id, {@code 0} when unknown
|
||||
* @param myTeamSpeakFeatures "Enable myTeamSpeak features" ({@code send_mytsid_on_server})
|
||||
*/
|
||||
record Bookmark(String uuid, String parentUuid, String previousUuid, String name, String address, int port,
|
||||
String nickname, String phoneticNickname, String identityUuid,
|
||||
String serverPassword, String defaultChannel, String defaultChannelPassword,
|
||||
long defaultChannelId, boolean autoconnect) implements SyncItem {
|
||||
long defaultChannelId, boolean autoconnect, boolean myTeamSpeakFeatures) implements SyncItem {
|
||||
}
|
||||
|
||||
/**
|
||||
* What TeamSpeak 6 keeps about a chat: a custom name and how it is filed. One exists only
|
||||
* once something about the chat was customised, so it is not a whole contact list.
|
||||
*
|
||||
* @param myTsId the partner's myTeamSpeak ID as servers carry it; TeamSpeak 6 leaves it empty
|
||||
* @param chatMemberId the partner's TeamSpeak chat (Matrix) user ID, for a direct chat
|
||||
*/
|
||||
record Contact(String uuid, String parentUuid, String previousUuid, String customName, String category,
|
||||
boolean favourite, boolean directChat, String myTsId, String chatMemberId) implements SyncItem {
|
||||
|
||||
/** The partner's myTeamSpeak ID, read out of the chat ID when the item names none; empty for a group chat. */
|
||||
public String myTeamSpeakId() {
|
||||
if (!myTsId.isBlank()) return myTsId;
|
||||
return directChat ? MyTsId.fromChatId(chatMemberId) : "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public final class SyncItemDecoder {
|
||||
case 4 -> deleted = r.readVarint() == ITEM_DELETED;
|
||||
case 7 -> parent = r.readString();
|
||||
case 8 -> previous = r.readString();
|
||||
case 16, 17, 22 -> {
|
||||
case 16, 17, 22, 25 -> {
|
||||
contentField = r.fieldNumber();
|
||||
content = r.readMessage();
|
||||
}
|
||||
@@ -50,6 +50,7 @@ public final class SyncItemDecoder {
|
||||
return switch (contentField) {
|
||||
case 16 -> bookmark(uuid, parent, previous, content);
|
||||
case 17 -> identity(uuid, parent, previous, content);
|
||||
case 25 -> contact(uuid, parent, previous, content);
|
||||
default -> folder(uuid, parent, previous, content);
|
||||
};
|
||||
}
|
||||
@@ -59,7 +60,7 @@ public final class SyncItemDecoder {
|
||||
String serverPassword = "", channel = "", channelPassword = "";
|
||||
int port = 9987;
|
||||
long channelId = 0;
|
||||
boolean autoconnect = false;
|
||||
boolean autoconnect = false, myTeamSpeakFeatures = false;
|
||||
while (r.next()) {
|
||||
switch (r.fieldNumber()) {
|
||||
case 1 -> name = r.readString();
|
||||
@@ -73,11 +74,12 @@ public final class SyncItemDecoder {
|
||||
case 9 -> channelPassword = r.readString();
|
||||
case 10 -> channelId = r.readVarint();
|
||||
case 14 -> autoconnect = r.readBool();
|
||||
case 22 -> myTeamSpeakFeatures = r.readBool();
|
||||
default -> r.skip();
|
||||
}
|
||||
}
|
||||
return new SyncItem.Bookmark(uuid, parent, previous, name, address, port, nickname, phonetic, identity,
|
||||
serverPassword, channel, channelPassword, channelId, autoconnect);
|
||||
serverPassword, channel, channelPassword, channelId, autoconnect, myTeamSpeakFeatures);
|
||||
}
|
||||
|
||||
private static SyncItem.Identity identity(String uuid, String parent, String previous, ProtobufReader r) throws IOException {
|
||||
@@ -96,6 +98,23 @@ public final class SyncItemDecoder {
|
||||
return new SyncItem.Identity(uuid, parent, previous, identity, name, nickname, phonetic, isDefault);
|
||||
}
|
||||
|
||||
private static SyncItem.Contact contact(String uuid, String parent, String previous, ProtobufReader r) throws IOException {
|
||||
String name = "", category = "", myTsId = "", memberId = "";
|
||||
boolean favourite = false, direct = false;
|
||||
while (r.next()) {
|
||||
switch (r.fieldNumber()) {
|
||||
case 2 -> name = r.readString();
|
||||
case 3 -> category = r.readString();
|
||||
case 5 -> favourite = r.readBool();
|
||||
case 6 -> direct = r.readBool();
|
||||
case 7 -> myTsId = r.readString();
|
||||
case 8 -> memberId = r.readString();
|
||||
default -> r.skip();
|
||||
}
|
||||
}
|
||||
return new SyncItem.Contact(uuid, parent, previous, name, category, favourite, direct, myTsId, memberId);
|
||||
}
|
||||
|
||||
private static SyncItem.Folder folder(String uuid, String parent, String previous, ProtobufReader r) throws IOException {
|
||||
String name = "";
|
||||
while (r.next()) {
|
||||
|
||||
+62
-9
@@ -5,6 +5,9 @@ import eu.lixko.ts3j.client.config.Bookmarks;
|
||||
import eu.lixko.ts3j.client.config.IdentityEntry;
|
||||
import eu.lixko.ts3j.client.config.IdentityStore;
|
||||
import eu.lixko.ts3j.client.config.Settings;
|
||||
import eu.lixko.ts3j.client.contacts.Contact;
|
||||
import eu.lixko.ts3j.client.contacts.ContactStore;
|
||||
import eu.lixko.ts3j.client.contacts.ContactType;
|
||||
import com.github.manevolent.ts3j.identity.LocalIdentity;
|
||||
|
||||
import java.io.File;
|
||||
@@ -21,15 +24,18 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* Carries the TeamSpeak 3 client's synchronised bookmarks and identities —
|
||||
* from its local store or a myTeamSpeak account — over into this client's stores. Importing is additive and idempotent: an identity
|
||||
* already present (same unique ID) or a bookmark already present (same label,
|
||||
* address and port) is left alone, and bookmarks are wired to the identities
|
||||
* they referenced in TeamSpeak.
|
||||
* from its local store or a myTeamSpeak account — over into this client's stores,
|
||||
* and TeamSpeak 6's contacts along with them when given a contact list. Importing
|
||||
* is additive and idempotent: an identity already present (same unique ID), a
|
||||
* bookmark already present (same label, address and port) or a contact already
|
||||
* present (same myTeamSpeak ID) is left alone, and bookmarks are wired to the
|
||||
* identities they referenced in TeamSpeak.
|
||||
*/
|
||||
public final class TeamSpeakImporter {
|
||||
|
||||
/** What an import did; {@code known} counts the items that were already there. */
|
||||
public record Result(int identitiesAdded, int identitiesKnown, int bookmarksAdded, int bookmarksKnown) {
|
||||
public record Result(int identitiesAdded, int identitiesKnown, int bookmarksAdded, int bookmarksKnown,
|
||||
int contactsAdded, int contactsKnown) {
|
||||
public int identities() {
|
||||
return identitiesAdded + identitiesKnown;
|
||||
}
|
||||
@@ -42,11 +48,26 @@ public final class TeamSpeakImporter {
|
||||
private final IdentityStore identities;
|
||||
private final Bookmarks bookmarks;
|
||||
private final Settings settings;
|
||||
/** Where contacts go; {@code null} leaves them out. */
|
||||
private final ContactStore contacts;
|
||||
|
||||
public TeamSpeakImporter(IdentityStore identities, Bookmarks bookmarks, Settings settings) {
|
||||
this(identities, bookmarks, settings, null);
|
||||
}
|
||||
|
||||
public TeamSpeakImporter(IdentityStore identities, Bookmarks bookmarks, Settings settings, ContactStore contacts) {
|
||||
this.identities = identities;
|
||||
this.bookmarks = bookmarks;
|
||||
this.settings = settings;
|
||||
this.contacts = contacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a contact can be brought over: only a direct chat says whose it is, and only a
|
||||
* myTeamSpeak ID can be matched against clients on a server.
|
||||
*/
|
||||
public static boolean isImportable(SyncItem.Contact contact) {
|
||||
return !contact.myTeamSpeakId().isEmpty();
|
||||
}
|
||||
|
||||
/** Imports the identities only. */
|
||||
@@ -64,7 +85,7 @@ public final class TeamSpeakImporter {
|
||||
return importAll(TeamSpeakSettingsDb.readSyncItems(db));
|
||||
}
|
||||
|
||||
/** Imports every identity and bookmark among items read elsewhere, such as from a myTeamSpeak account. */
|
||||
/** Imports every identity, bookmark and contact among items read elsewhere, such as from a myTeamSpeak account. */
|
||||
public Result importAll(List<SyncItem> items) throws IOException {
|
||||
return importItems(items, true, false);
|
||||
}
|
||||
@@ -84,9 +105,15 @@ public final class TeamSpeakImporter {
|
||||
return importItems(new ArrayList<>(selection), true, false);
|
||||
}
|
||||
|
||||
/** Whether the item is here already: an identity with the same key, or a bookmark with the same label and address. */
|
||||
/**
|
||||
* Whether the item is here already: an identity with the same key, a bookmark with the same
|
||||
* label and address, or a contact with the same myTeamSpeak ID.
|
||||
*/
|
||||
public boolean isPresent(SyncItem item) {
|
||||
if (item instanceof SyncItem.Bookmark bookmark) return find(bookmark) != null;
|
||||
if (item instanceof SyncItem.Contact contact) {
|
||||
return contacts != null && contacts.findByMyTeamSpeakId(contact.myTeamSpeakId()) != null;
|
||||
}
|
||||
if (!(item instanceof SyncItem.Identity identity)) return false;
|
||||
try {
|
||||
return identities.byUniqueId(IdentityStore.parseIdentityString(identity.identity()).getUid().toBase64()) != null;
|
||||
@@ -157,7 +184,7 @@ public final class TeamSpeakImporter {
|
||||
}
|
||||
}
|
||||
if (settingsChanged) settings.save();
|
||||
if (!withBookmarks) return new Result(identitiesAdded, identitiesKnown, 0, 0);
|
||||
if (!withBookmarks) return new Result(identitiesAdded, identitiesKnown, 0, 0, 0, 0);
|
||||
|
||||
for (SyncItem.Bookmark bookmark : syncBookmarks) {
|
||||
if (find(bookmark) != null) {
|
||||
@@ -172,7 +199,32 @@ public final class TeamSpeakImporter {
|
||||
bookmarksAdded++;
|
||||
}
|
||||
if (bookmarksAdded > 0) bookmarks.save();
|
||||
return new Result(identitiesAdded, identitiesKnown, bookmarksAdded, bookmarksKnown);
|
||||
|
||||
int contactsAdded = 0, contactsKnown = 0;
|
||||
if (contacts != null) {
|
||||
Map<String, Contact> added = new LinkedHashMap<>();
|
||||
for (SyncItem item : items) {
|
||||
if (!(item instanceof SyncItem.Contact sync) || !isImportable(sync)) continue;
|
||||
if (isPresent(sync) || added.containsKey(sync.myTeamSpeakId())) {
|
||||
contactsKnown++;
|
||||
} else {
|
||||
added.put(sync.myTeamSpeakId(), toContact(sync));
|
||||
contactsAdded++;
|
||||
}
|
||||
}
|
||||
if (!added.isEmpty()) contacts.merge(added.values());
|
||||
}
|
||||
return new Result(identitiesAdded, identitiesKnown, bookmarksAdded, bookmarksKnown,
|
||||
contactsAdded, contactsKnown);
|
||||
}
|
||||
|
||||
/** Someone chatted with in TeamSpeak 6 is a friend, as a contact there is. */
|
||||
private Contact toContact(SyncItem.Contact sync) {
|
||||
Contact contact = new Contact("", sync.myTeamSpeakId());
|
||||
contact.nickname = sync.customName();
|
||||
contact.type = ContactType.FRIEND;
|
||||
contact.applyDefaults(settings.contactDefaults.of(ContactType.FRIEND));
|
||||
return contact;
|
||||
}
|
||||
|
||||
private Bookmark toBookmark(SyncItem.Bookmark sync, IdentityEntry identity) {
|
||||
@@ -183,6 +235,7 @@ public final class TeamSpeakImporter {
|
||||
if (b.channel.isBlank() && sync.defaultChannelId() != 0) b.channel = "/" + sync.defaultChannelId();
|
||||
b.channelPassword = sync.defaultChannelPassword();
|
||||
b.connectOnStartup = sync.autoconnect();
|
||||
b.myTeamSpeakFeatures = sync.myTeamSpeakFeatures();
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,4 +118,41 @@ class ContactStoreTest {
|
||||
store.remove("a=");
|
||||
assertEquals(1, store.all().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aMyTeamSpeakContactStandsForTheClientsLinkedToIt() throws Exception {
|
||||
File file = new File(dir, "myts.txt");
|
||||
ContactStore store = new ContactStore(file);
|
||||
Contact friend = new Contact("", "AQID");
|
||||
friend.nickname = "Friend";
|
||||
friend.type = ContactType.FRIEND;
|
||||
store.merge(List.of(friend));
|
||||
assertNull(store.find("one="));
|
||||
|
||||
store.link("one=", "AQID");
|
||||
store.link("two=", "AQID");
|
||||
assertEquals(friend, store.find("one="));
|
||||
assertEquals(friend, store.find("two="));
|
||||
assertEquals(friend, store.find(friend.key()));
|
||||
assertEquals("Friend (Nick)", store.displayName("two=", "Nick"));
|
||||
|
||||
// Adding a linked client re-types the shared contact rather than filing a second one.
|
||||
store.add("one=", "One", ContactType.BLOCKED, new ContactDefaults());
|
||||
assertEquals(1, store.all().size());
|
||||
assertEquals(ContactType.BLOCKED, friend.type);
|
||||
// A contact of the client's own comes first.
|
||||
store.merge(List.of(new Contact("two=")));
|
||||
assertEquals("two=", store.find("two=").uniqueId);
|
||||
store.remove("two=");
|
||||
store.link("two=", "");
|
||||
assertNull(store.find("two="));
|
||||
|
||||
ContactStore reloaded = new ContactStore(file);
|
||||
reloaded.readFile();
|
||||
assertEquals("AQID", reloaded.all().get(0).myTeamSpeakId);
|
||||
assertEquals("", reloaded.all().get(0).uniqueId);
|
||||
|
||||
store.remove("one=");
|
||||
assertTrue(store.all().isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,4 +80,24 @@ class ContactTest {
|
||||
c.volumeModifier = -6;
|
||||
assertEquals(0.501, c.volumeGain(), 0.001);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aMyTeamSpeakIdTravelsAsAnExtraLine() {
|
||||
Contact plain = Contact.parseRecord(new Contact("abc=").toRecord());
|
||||
assertFalse(plain.toRecord().contains("MyTsId"));
|
||||
|
||||
Contact c = new Contact("", "AQID");
|
||||
c.nickname = "Friend";
|
||||
String record = c.toRecord();
|
||||
assertTrue(record.startsWith("IDS=\n"), record);
|
||||
assertTrue(record.endsWith("MyTsId=AQID\n"), record);
|
||||
Contact back = Contact.parseRecord(record);
|
||||
assertEquals("", back.uniqueId);
|
||||
assertEquals("AQID", back.myTeamSpeakId);
|
||||
assertEquals("Friend", back.nickname);
|
||||
assertEquals("myts:AQID", back.key());
|
||||
assertEquals("AQID", back.shownId());
|
||||
assertEquals("AQID", back.copy().myTeamSpeakId);
|
||||
assertNull(Contact.parseRecord("Nickname=Nobody\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,28 +2,11 @@ package eu.lixko.ts3j.client.myts;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
class AccountInfoTest {
|
||||
|
||||
private static String base32(String text) {
|
||||
return AccountInfo.base32(text.getBytes(StandardCharsets.US_ASCII));
|
||||
}
|
||||
|
||||
@Test
|
||||
void encodesRfc4648VectorsLowercaseAndUnpadded() {
|
||||
assertEquals("", base32(""));
|
||||
assertEquals("my", base32("f"));
|
||||
assertEquals("mzxq", base32("fo"));
|
||||
assertEquals("mzxw6", base32("foo"));
|
||||
assertEquals("mzxw6yq", base32("foob"));
|
||||
assertEquals("mzxw6ytb", base32("fooba"));
|
||||
assertEquals("mzxw6ytboi", base32("foobar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void toleratesAReplyWithoutIdentityData() {
|
||||
AccountInfo info = AccountInfo.of("tester", "u", null, 0);
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package eu.lixko.ts3j.client.myts;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
class MyTsIdTest {
|
||||
|
||||
private static String base32(String text) {
|
||||
return MyTsId.base32(text.getBytes(StandardCharsets.US_ASCII));
|
||||
}
|
||||
|
||||
@Test
|
||||
void encodesRfc4648VectorsLowercaseAndUnpadded() {
|
||||
assertEquals("", base32(""));
|
||||
assertEquals("my", base32("f"));
|
||||
assertEquals("mzxq", base32("fo"));
|
||||
assertEquals("mzxw6", base32("foo"));
|
||||
assertEquals("mzxw6yq", base32("foob"));
|
||||
assertEquals("mzxw6ytb", base32("fooba"));
|
||||
assertEquals("mzxw6ytboi", base32("foobar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void decodesWhatItEncodes() {
|
||||
for (String text : new String[] {"", "f", "fo", "foo", "foob", "fooba", "foobar"}) {
|
||||
assertArrayEquals(text.getBytes(StandardCharsets.US_ASCII), MyTsId.base32Decode(base32(text)));
|
||||
}
|
||||
assertArrayEquals("foobar".getBytes(StandardCharsets.US_ASCII), MyTsId.base32Decode("MZXW6YTBOI"));
|
||||
assertNull(MyTsId.base32Decode("mzxw6ytb0i"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void readsTheIdOutOfAChatUserId() {
|
||||
byte[] id = {1, 2, 3, (byte) 0xfe, (byte) 0xff, 0x40, 0x7f};
|
||||
String expected = Base64.getEncoder().encodeToString(id);
|
||||
assertEquals(expected, MyTsId.fromChatId("@" + MyTsId.base32(id) + ":chat.teamspeak.com"));
|
||||
assertEquals("", MyTsId.fromChatId("@someone"));
|
||||
assertEquals("", MyTsId.fromChatId("someone:chat.teamspeak.com"));
|
||||
assertEquals("", MyTsId.fromChatId("@not-base32:chat.teamspeak.com"));
|
||||
assertEquals("", MyTsId.fromChatId(null));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package eu.lixko.ts3j.client.teamspeak;
|
||||
|
||||
import eu.lixko.ts3j.client.config.IdentityStore;
|
||||
import eu.lixko.ts3j.client.proto.ProtobufWriter;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
@@ -8,6 +9,7 @@ import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@@ -79,4 +81,29 @@ class SyncItemsTest {
|
||||
assertEquals(42, byId.defaultChannelId());
|
||||
assertEquals("", byId.identityUuid());
|
||||
}
|
||||
|
||||
/** TeamSpeak 6's contact item, Item_Data field 25, as its client writes one: no myTeamSpeak ID, only the chat partner. */
|
||||
static byte[] contactItem(String uuid, String customName, boolean direct, String memberId) {
|
||||
ProtobufWriter contact = new ProtobufWriter().string(1, "!room:chat.teamspeak.com").string(2, customName)
|
||||
.string(3, "Work").varint(5, 1).varint(6, direct ? 1 : 0).string(8, memberId);
|
||||
return new ProtobufWriter().string(2, uuid).varint(4, 3).varint(6, 8)
|
||||
.string(7, "ffffffff-ffff-ffff-ffff-ffffffffffff").message(25, contact).toByteArray();
|
||||
}
|
||||
|
||||
@Test
|
||||
void decodesATeamSpeak6Contact() throws Exception {
|
||||
// "aebagbaf" is base32 for bytes 01 02 03 04 05.
|
||||
SyncItem item = SyncItemDecoder.decode(contactItem("c1", "Buddy", true, "@aebagbaf:chat.teamspeak.com"));
|
||||
SyncItem.Contact contact = assertInstanceOf(SyncItem.Contact.class, item);
|
||||
assertEquals("c1", contact.uuid());
|
||||
assertEquals("", contact.parentUuid());
|
||||
assertEquals("Buddy", contact.customName());
|
||||
assertEquals("Work", contact.category());
|
||||
assertTrue(contact.favourite());
|
||||
assertEquals("AQIDBAU=", contact.myTeamSpeakId());
|
||||
|
||||
SyncItem.Contact group = (SyncItem.Contact) SyncItemDecoder.decode(
|
||||
contactItem("c2", "Group", false, "@aebagbaf:chat.teamspeak.com"));
|
||||
assertEquals("", group.myTeamSpeakId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class SyncOrderTest {
|
||||
|
||||
private static SyncItem.Bookmark bookmark(String uuid, String parent, String previous) {
|
||||
return new SyncItem.Bookmark(uuid, parent, previous, uuid, uuid + ".example", 9987, "", "", "", "", "", "",
|
||||
0, false);
|
||||
0, false, true);
|
||||
}
|
||||
|
||||
private static SyncItem.Folder folder(String uuid, String parent, String previous) {
|
||||
|
||||
+34
-1
@@ -6,6 +6,9 @@ import eu.lixko.ts3j.client.config.Bookmarks;
|
||||
import eu.lixko.ts3j.client.config.IdentityEntry;
|
||||
import eu.lixko.ts3j.client.config.IdentityStore;
|
||||
import eu.lixko.ts3j.client.config.Settings;
|
||||
import eu.lixko.ts3j.client.contacts.Contact;
|
||||
import eu.lixko.ts3j.client.contacts.ContactStore;
|
||||
import eu.lixko.ts3j.client.contacts.ContactType;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -85,13 +88,14 @@ class TeamSpeakImporterTest {
|
||||
SyncItem.Identity identity = TeamSpeakSettingsDb.readSyncItems(SyncItemsTest.fixture()).stream()
|
||||
.filter(SyncItem.Identity.class::isInstance).map(SyncItem.Identity.class::cast).findFirst().orElseThrow();
|
||||
SyncItem.Bookmark bookmark = new SyncItem.Bookmark("b", "", "", "Server", "example.com", 9987, "", "",
|
||||
identity.name(), "", "", "", 0, false);
|
||||
identity.name(), "", "", "", 0, false, true);
|
||||
|
||||
new TeamSpeakImporter(identities, bookmarks, settings).importAll(List.of(bookmark, identity));
|
||||
assertEquals(identities.all().get(0).getId(), bookmarks.all().get(0).identityId);
|
||||
assertEquals("", bookmarks.all().get(0).nickname);
|
||||
assertEquals(identity.nickname(), identities.all().get(0).getNickname());
|
||||
assertEquals(identity.phoneticNickname(), identities.all().get(0).getPhoneticNickname());
|
||||
assertTrue(bookmarks.all().get(0).myTeamSpeakFeatures);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -127,4 +131,33 @@ class TeamSpeakImporterTest {
|
||||
assertEquals(before + first.identitiesAdded(), identities.all().size());
|
||||
assertNotNull(identities.byId(settings.defaultIdentityId));
|
||||
}
|
||||
|
||||
@Test
|
||||
void importsTeamSpeak6ContactsAsFriendsByMyTeamSpeakId() throws Exception {
|
||||
Settings settings = new Settings();
|
||||
settings.contactDefaults.of(ContactType.FRIEND).ignorePokes = true;
|
||||
ContactStore contacts = ContactStore.load();
|
||||
TeamSpeakImporter importer = new TeamSpeakImporter(IdentityStore.load(settings), new Bookmarks(), settings,
|
||||
contacts);
|
||||
List<SyncItem> items = List.of(
|
||||
SyncItemDecoder.decode(SyncItemsTest.contactItem("c1", "Buddy", true, "@aebagbaf:chat.teamspeak.com")),
|
||||
SyncItemDecoder.decode(SyncItemsTest.contactItem("c2", "Group", false, "")));
|
||||
assertFalse(importer.isPresent(items.get(0)));
|
||||
assertFalse(TeamSpeakImporter.isImportable((SyncItem.Contact) items.get(1)));
|
||||
|
||||
TeamSpeakImporter.Result first = importer.importAll(items);
|
||||
assertEquals(1, first.contactsAdded());
|
||||
Contact buddy = contacts.findByMyTeamSpeakId("AQIDBAU=");
|
||||
assertNotNull(buddy);
|
||||
assertEquals("", buddy.uniqueId);
|
||||
assertEquals("Buddy", buddy.nickname);
|
||||
assertEquals(ContactType.FRIEND, buddy.type);
|
||||
assertTrue(buddy.ignorePokes);
|
||||
assertTrue(importer.isPresent(items.get(0)));
|
||||
|
||||
TeamSpeakImporter.Result second = importer.importSelected(items, List.of(items.get(0)));
|
||||
assertEquals(0, second.contactsAdded());
|
||||
assertEquals(1, second.contactsKnown());
|
||||
assertEquals(1, contacts.all().size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,17 @@ body is protobuf, not JSON).
|
||||
[CRYPTO_RE_SALT.md](CRYPTO_RE_SALT.md#5-synchronization-and-upload-state-machine) for the recovered
|
||||
state machine and confidence boundaries.
|
||||
|
||||
### TeamSpeak 6 item classes
|
||||
The TS6 binary's `Sync_Serializing.proto` is newer than the TS3 one in `myteamspeak.recovered.proto`:
|
||||
`Item_Class` 7 is `GROUP_CHATS` (TS3: `ROOM_CATEGORY`) and **8 is `CONTACTS`**; `Item_Data` gains oneof
|
||||
`group_chats(24)` and `contact(25)`. `Contact{chat_room_id(1), custom_name(2), custom_category(3),
|
||||
notification_preference(4), is_favourite(5), is_direct_chat(6), mytsid(7), chat_member_id(8)}`.
|
||||
TS6 writes one per chat once a custom name, category or notification setting is set — it is room
|
||||
settings, not the contact list (that is the Matrix rooms) — and never fills `mytsid`; a direct chat's
|
||||
`chat_member_id` is the partner's Matrix ID `@<base32 myTS ID bytes>:<homeserver>`. The same bytes as
|
||||
standard base64 are the `client_myteamspeak_id` servers report (33 bytes, leading `0x01`), which is how
|
||||
TS6 ties a server client to a chat contact.
|
||||
|
||||
## Crypto status
|
||||
|
||||
myTeamSpeak sync is **end-to-end encrypted**, using TeamSpeak's own `teamcrypto` library
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# Announcing the myTeamSpeak ID to a server
|
||||
|
||||
What the client has to send so that a server shows our `client_myteamspeak_id`, the way the
|
||||
official client does when a bookmark has "Enable myTeamSpeak features" on. Observed with TS3 3.6.2
|
||||
signed in to the throwaway account against the test server, 2026-10-10.
|
||||
|
||||
## The switch
|
||||
|
||||
Connect dialog and bookmarks: **"Enable myTeamSpeak features"**, on by default. It is
|
||||
`Bookmark_Data.send_mytsid_on_server (22)` in the sync schema. When it is on and the client is
|
||||
signed in, `clientinit` carries the extra parameters below. `client_myteamspeak_id` itself is
|
||||
sent empty; the server fills it in from them and announces it to everyone
|
||||
(`notifycliententerview client_myteamspeak_id=<base64>`).
|
||||
|
||||
The official client also has a post-connect `updatemytsid` command, which takes the same data,
|
||||
for signing in or out while connected. It was not hit during a normal connect.
|
||||
|
||||
## Extra `clientinit` parameters
|
||||
|
||||
| Parameter | Value | Source |
|
||||
|-----------------|-----------------------------------------------------------------|----------------------------|
|
||||
| `myTeamspeakId` | base64 of the 33-byte myTeamSpeak ID (`01 20 …`) | known: login `myts_id_data.my_teamspeak_id (4)` |
|
||||
| `acTime` | account creation time as a u64, byte-swapped, in decimal | known: login `myts_id_data.account_creation_time (3)` |
|
||||
| `userPubKey` | base64, 32 bytes (Ed25519 public key) | known: login `myts_id_data.user_public_key (1)` |
|
||||
| `pubSign` | base64, 64 bytes | known: first 64 bytes of login `myts_id_data.public_signature (5)` |
|
||||
| `pubSignCert` | base64, 112 bytes (certificate naming "TeamSpeak Systems GmbH") | known: remaining 112 bytes of `public_signature (5)` |
|
||||
| `authSign` | base64, 64 bytes | **unknown, still to find** |
|
||||
|
||||
`acTime` example: creation time `1790376353` = `0x6AB6F9A1`; as big-endian u64
|
||||
`a1f9b66a00000000` = `11671560475690139648`.
|
||||
|
||||
## Still to find: `authSign`
|
||||
|
||||
- It is made fresh for each connection. It is not part of the login reply, and replaying an old
|
||||
one is not expected to work.
|
||||
- Without valid data the server refuses the ID: `clientupdate client_myteamspeak_id=<anything>`
|
||||
gives "invalid parameter".
|
||||
- To find: what `authSign` covers and how the client produces it, using only what our existing
|
||||
sign-in (`MyTeamSpeakLogin`) already holds.
|
||||
|
||||
## Verification once it is known
|
||||
|
||||
1. Connect our client with the switch on, signed in to the throwaway account.
|
||||
2. From a second client (the ts3j probe bot), check that `notifycliententerview` carries
|
||||
`client_myteamspeak_id=ASCwXERY29umCjNyMewplck8cVzzMx/Xsh8vab8V7grN`, the throwaway's ID.
|
||||
3. Check that with the switch off the field stays empty.
|
||||
@@ -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