Linux + iPhone Continuity / iMessage / SMS
feat: encrypted messages and contacts, and API for reading
Zack Bartel69d90e3bf48d
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 161cd03..3578e71 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -33,6 +33,7 @@ pkg_check_modules(WAYLAND REQUIRED IMPORTED_TARGET wayland-client)pkg_check_modules(AVAHI REQUIRED IMPORTED_TARGET avahi-client)find_package(OpenSSL REQUIRED)find_package(Intl REQUIRED)+pkg_check_modules(SECRET REQUIRED IMPORTED_TARGET libsecret-1)include(FetchContent)diff --git a/PKGBUILD b/PKGBUILDindex ffd2341..aececf3 100644--- a/PKGBUILD+++ b/PKGBUILD@@ -5,7 +5,7 @@ pkgdesc="Bridge an iPhone to the Linux desktop: clipboard, files, messages, andarch=('x86_64')url="https://github.com/zackb/tether"license=('MIT')-depends=('gtk3' 'gtk-layer-shell' 'libnotify' 'openssl' 'wayland' 'avahi' 'glib2' 'bluez' 'bluez-utils' 'bluez-obex')+depends=('gtk3' 'gtk-layer-shell' 'libnotify' 'openssl' 'wayland' 'avahi' 'glib2' 'libsecret' 'bluez' 'bluez-utils' 'bluez-obex')makedepends=('cmake' 'ninja' 'git')provides=('tether' 'tether-bin')conflicts=('tether' 'tether-bin')diff --git a/docs/BLUETOOTH.md b/docs/BLUETOOTH.mdindex 647b064..0ddf901 100644--- a/docs/BLUETOOTH.md+++ b/docs/BLUETOOTH.md@@ -825,9 +825,62 @@ iPhone was, exactly as on 2026-08-19.The transfer object disappears from D-Bus the moment it finishes, so a vanished objectis a normal terminal state rather than a failure (file may still take a bit to appear afterwards),which is why the pull waits instead of giving up. Contacts are staged in `$XDG_RUNTIME_DIR` rather than `/tmp`, since a-phonebook is personal data, and the cache and journal are both written mode 0600.+phonebook is personal data.-***THIS HAS TO CHANGE BEFORE PUBLIC RELEASE.***+### The store at rest++Mode 0600 was the whole protection until 0.2.24, and it is not enough: it does+nothing about `$HOME` backups, a synced home directory, or another process+running as the same user. Both stores are now sealed.++Each record is `base64(nonce[12] || ciphertext || tag[16])`, AES-256-GCM+through the OpenSSL that is already linked for TLS. The journal seals per line+so appending stays an append; the contact cache is rewritten whole after every+PBAP pull anyway, so it gets one envelope for the file.++The key is 32 bytes from `RAND_bytes`, kept in the desktop secret service+(schema `com.tether.Store`, attribute `application=tether`). Lookup uses+`secret_service_search_sync` **without** `SECRET_SEARCH_UNLOCK`:+`secret_password_lookup_sync` would raise an unlock prompt, which is wrong for a+user unit that can start before the graphical session. On a host with no secret+service on the bus at all the key falls back to `~/.config/tether/store.key`,+mode 0600 — that stops a backup or a synced home, not another process running as+you, and it is never written when a wallet is merely locked.++Three retention modes, `retention` in `bluetooth.json`, also `tether+--bt-retention`:++| Mode | Journal | Contacts | An older tetherd sees |+|---|---|---|---|+| `encrypted` (default) | `messages.ndjson.enc` | `contacts.json.enc` | nothing |+| `plaintext` | `messages.ndjson` | `contacts.json` | files it reads correctly |+| `none` | — | — | nothing |++The path follows the mode, and that is load-bearing rather than cosmetic. A+package upgrade leaves the running daemon on the old binary, and a downgrade can+put an old binary back permanently. An old `tetherd` cannot parse a sealed line,+so it would read an empty history and then compact that emptiness back over the+file. Because the only names it ever opens are `messages.ndjson` and+`contacts.json`, and those only ever hold plaintext, it finds nothing under+`encrypted` and writes to files nothing else reads. Rolling forward finds the+sealed store intact. `compact()` additionally refuses to replace a populated+journal with zero records, which closes the same hole for the next format change.++Changing modes migrates the data: read under the old mode, write under the new,+fsync, rename, then unlink the source — never the other way round, so a crash+mid-migration leaves both copies rather than neither. A store written by a+pre-0.2.24 daemon migrates on the first start after the upgrade.++A locked wallet keeps MAP and PBAP up and messages flowing to the UI, and only+pauses what is retained: the journal does not open, nothing is replayed, and+contact names go unresolved. The key is retried on each message poll, rate+limited to one wallet round trip a minute, so history starts persisting within a+minute of the user unlocking.++> **Losing the keyring entry loses the retained history.** There is no escrow and+> no plaintext copy left behind. The phone can refill part of it over MAP; sent+> messages, which the iPhone's MAP sent folder never returns, are gone. `tether+> --bt-retention plaintext` is the supported way to keep a readable copy.## Creditsdiff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.mdindex a01e3d1..2cb8acd 100644--- a/docs/PROTOCOL.md+++ b/docs/PROTOCOL.md@@ -334,6 +334,20 @@ identifier. Group keys are `group:name:<slug>` or `group:members:<slugs>`.**Response**: `{"command": "bt_messages", "thread": ..., "messages": [...]}` with `handle`,`body`, `timestamp`, `outgoing`, `read`, and `folder` per message.+#### `bt_list_contacts` (Client -> Daemon, answered directly)+**Payload**: `{"command": "bt_list_contacts", "query": "ada", "limit": 100}`+Both fields are optional; an empty or absent `query` matches every contact, and `limit`+defaults to 100.+**Response**: `{"command": "bt_contacts", "query": ..., "contacts": [...]}`. Each contact+carries `name` and `addresses`, namespaced exactly as thread keys are+(`tel:+15035550101`, `email:[email protected]`), so an address can be handed straight back+as the `thread` of a `bt_send_message`. Contacts with no usable address are omitted.++Matching is a case- and accent-insensitive substring over the name and every address,+with numbers matched in normalized form too, so `5551234567` finds a contact stored as+`+1 (555) 123-4567`. This is the only way to read the phonebook: the cache on disk is+encrypted and only `tetherd` holds the key.+#### `bt_mark_read` (Client -> Daemon, broadcast)**Payload**: `{"command": "bt_mark_read", "handle": "...", "read": true}`Writes through to the phone over OBEX, so it answers asynchronously with a@@ -374,6 +388,10 @@ Notifications* toggle is the consent gate. With it off, only `app_id` and `app_npopulated. Messages notifications (`com.apple.MobileSMS`) are retained but never raise adesktop popup, since MAP already delivers those with working read state.+Since 0.2.24 `bt_status` also carries `version`, the daemon's own `TETHER_VERSION`. A+client that finds the field absent, or holding a version other than its own, is talking to+a `tetherd` left running across a package upgrade.+#### `bt_set_ancs_content` (Client -> Daemon, broadcast)**Payload**: `{"command": "bt_set_ancs_content", "enabled": true}`Turns notification content mirroring on or off. Persists to@@ -381,6 +399,17 @@ Turns notification content mirroring on or off. Persists toclient without a restart, and answers with a fresh `bt_status`. `bt_status` carries`ancs_enabled` and `ancs_content_enabled` so a client can render the current state.+#### `bt_set_retention` (Client -> Daemon, broadcast)+**Payload**: `{"command": "bt_set_retention", "retention": "encrypted"}`+One of `encrypted` (the default), `plaintext`, or `none`. Persists to `retention` in+`~/.config/tether/bluetooth.json` and answers with a fresh `bt_status`.++Changing the mode moves what is already stored to the path the new mode uses; `none`+deletes the message journal and the contact cache outright. `bt_status` carries+`retention` alongside `retention_ready`, which is false when the mode is `encrypted` and+the wallet has no key to offer yet — the link stays up in that state, but nothing is+retained or replayed. See `BLUETOOTH.md` for the on-disk format.+#### `bt_notification_action` (Client -> Daemon, broadcast)**Payload**: `{"command": "bt_notification_action", "uid": 42, "action": "positive"}`ANCS offers positive and negative actions only — there is no free-text reply on a mirroreddiff --git a/docs/man/man1/tether.1.in b/docs/man/man1/tether.1.inindex 4f28669..2252984 100644--- a/docs/man/man1/tether.1.in+++ b/docs/man/man1/tether.1.in@@ -94,6 +94,21 @@ Show messages in one conversation.\fB\-\-bt-send\fR \fITHREAD\fR \fITEXT\fRReply in one conversation..TP+\fB\-\-bt-contacts\fR [\fIQUERY\fR]+List iPhone contacts, or search them by name, number or email address. Prints each+contact's name followed by its addresses, one per line, in the same+\fItel:\fR/\fIemail:\fR form \fB\-\-bt-send\fR takes as its conversation.+.TP+\fB\-\-bt-retention\fR \fIencrypted\fR|\fIplaintext\fR|\fInone\fR+How message history and the contact cache are kept on disk. \fIencrypted\fR, the+default, seals them with a key from the desktop keyring, falling back to a 0600+key file on a host with no secret service. \fIplaintext\fR keeps the readable+files earlier versions wrote. \fInone\fR deletes what is already stored and+retains nothing further.+.IP+Losing the keyring entry loses the retained history: there is no escrow and no+plaintext copy is left behind.+.TP\fB\-\-bt-notifications\fRList mirrored iPhone notifications..TPdiff --git a/nix/package.nix b/nix/package.nixindex 97f0aa6..208844a 100644--- a/nix/package.nix+++ b/nix/package.nix@@ -16,6 +16,7 @@avahi,openssl,glib,+ libsecret,gtk3,gtk-layer-shell,libnotify,@@ -89,6 +90,7 @@ stdenv.mkDerivation (finalAttrs: {avahiopensslglib+ libsecretgtk3gtk-layer-shelllibnotifydiff --git a/packaging/flatpak/com.tether.desktop.yml b/packaging/flatpak/com.tether.desktop.ymlindex 608ea07..70fddf1 100644--- a/packaging/flatpak/com.tether.desktop.yml+++ b/packaging/flatpak/com.tether.desktop.yml@@ -15,6 +15,7 @@ finish-args:- --system-talk-name=org.freedesktop.Avahi # Bonjour, so the iPhone finds this PC- --talk-name=org.bluez.obex # MAP messages and PBAP contacts- --talk-name=org.freedesktop.Notifications+ - --talk-name=org.freedesktop.secrets # the key for the encrypted message store- --filesystem=xdg-download # where received files go- --filesystem=xdg-run/tether:create- --allow=bluetoothdiff --git a/packaging/tether.install b/packaging/tether.installindex 852085f..6ab13ac 100644--- a/packaging/tether.install+++ b/packaging/tether.install@@ -14,12 +14,6 @@ To see exactly what is left, and the commands to run:tether --bt-setup-WiFi needs inbound 5134/tcp, and 5353/udp for mDNS discovery. Profiles for ufw-and firewalld are installed but NOT applied, for the same reason:-- sudo ufw allow Tether- sudo firewall-cmd --permanent --add-service=tether && sudo firewall-cmd --reload-MSG}diff --git a/po/cs.po b/po/cs.poindex fd9c330..dc3dab3 100644--- a/po/cs.po+++ b/po/cs.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Czech\n"@@ -99,6 +99,10 @@ msgstr "Zobrazit zprávy jedné konverzace."msgid "Reply in one conversation."msgstr "Odpovědět v jedné konverzaci."+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr "Vypsat kontakty z iPhonu nebo je vyhledat podle jména či čísla."+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr "Spárovat iPhone přes Bluetooth."@@ -135,6 +139,12 @@ msgstr "Zapnout nebo vypnout zrcadlení oznámení."msgid "Mirror notification titles and bodies, not just the app."msgstr "Zrcadlit názvy a text oznámení, nejen aplikaci."+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr "Jak se na disku uchovává historie zpráv a kontakty. encrypted použije klíč z klíčenky prostředí; none smaže uložená data a dál nic neuchovává."+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr "Vybere, který adaptér Bluetooth se použije."@@ -427,6 +437,31 @@ msgstr[0] "({} nepřečtená)"msgstr[1] "({} nepřečtené)"msgstr[2] "({} nepřečtených)"+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr "Běžící tetherd je {}, ale toto je tether {}. Restartujte jej příkazem:\n systemctl --user restart tetherd\n"++#: src/cli/main.cpp+msgid "an older build"+msgstr "starší sestavení"++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr "Nepodařilo se načíst kontakty od démona.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr "Zatím žádné kontakty. Zkontrolujte 'tether --bt-connection'.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr "Žádné kontakty neodpovídají %s\n"+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr "Nepodařilo se načíst zprávy od démona.\n"@@ -557,6 +592,20 @@ msgstr "Zrcadlení oznámení zapnuto."msgid "Notification mirroring disabled."msgstr "Zrcadlení oznámení vypnuto."+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr "Očekáváno encrypted, plaintext nebo none, např. --bt-retention encrypted\n"++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr "Mažou se uložené zprávy a kontakty.\n"++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr "Uchovávání nastaveno na %s.\n"+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr "Očekáván adaptér, např. --bt-adapter hci1, nebo --bt-adapter auto\n"@@ -1341,6 +1390,29 @@ msgstr """poslala. Volba „Zobrazovat oznámení zpráv“ v telefonu musí být přesto ""zapnutá."+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr "Uchovávat historii zpráv:"++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr "Šifrovaně"++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr "Nešifrovaně"++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr "Neuchovávat"++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr "Kde se v tomto počítači ukládají zprávy a kontakty. Šifrovaně je uchová pomocí klíče ve vaší klíčence. Neuchovávat smaže již uložená data a dál nic neuchovává."+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr "Spárovat přes Bluetooth"diff --git a/po/de.po b/po/de.poindex f22a456..d9c5848 100644--- a/po/de.po+++ b/po/de.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: 2026-08-22\n""Last-Translator: Tether project\n""Language-Team: German\n"@@ -99,6 +99,10 @@ msgstr "Nachrichten einer Unterhaltung anzeigen."msgid "Reply in one conversation."msgstr "In einer Unterhaltung antworten."+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr "Kontakte des iPhones auflisten oder nach Name oder Nummer durchsuchen."+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr "Ein iPhone per Bluetooth koppeln."@@ -136,6 +140,12 @@ msgstr "Die Spiegelung von Mitteilungen ein- oder ausschalten."msgid "Mirror notification titles and bodies, not just the app."msgstr "Titel und Text der Mitteilungen spiegeln, nicht nur die App."+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr "Wie Nachrichtenverlauf und Kontakte auf der Festplatte abgelegt werden. encrypted verwendet einen Schlüssel aus dem Schlüsselbund der Arbeitsumgebung; none löscht das Gespeicherte und behält nichts weiter."+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr "Wählt den zu verwendenden Bluetooth-Adapter."@@ -425,6 +435,31 @@ msgid_plural "({} unread)"msgstr[0] "({} ungelesen)"msgstr[1] "({} ungelesen)"+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr "Der laufende tetherd ist {}, dies hier ist aber tether {}. Starten Sie ihn neu mit:\n systemctl --user restart tetherd\n"++#: src/cli/main.cpp+msgid "an older build"+msgstr "ein älterer Build"++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr "Die Kontakte konnten nicht vom Daemon gelesen werden.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr "Noch keine Kontakte. Prüfen Sie 'tether --bt-connection'.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr "Keine Kontakte passen zu %s\n"+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr "Die Nachrichten konnten nicht vom Daemon gelesen werden.\n"@@ -562,6 +597,20 @@ msgstr "Spiegelung von Mitteilungen eingeschaltet."msgid "Notification mirroring disabled."msgstr "Spiegelung von Mitteilungen ausgeschaltet."+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr "Erwartet wurde encrypted, plaintext oder none, z. B. --bt-retention encrypted\n"++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr "Gespeicherte Nachrichten und Kontakte werden gelöscht.\n"++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr "Aufbewahrung auf %s gesetzt.\n"+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr "Adapter erwartet, z. B. --bt-adapter hci1, oder --bt-adapter auto\n"@@ -1368,6 +1417,29 @@ msgstr """sendenden App. Die Einstellung „Nachrichtenmitteilungen anzeigen“ am Telefon ""muss weiterhin aktiv sein."+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr "Nachrichtenverlauf aufbewahren:"++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr "Verschlüsselt"++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr "Unverschlüsselt"++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr "Nicht aufbewahren"++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr "Wo Nachrichten und Kontakte auf diesem Rechner gespeichert werden. Verschlüsselt bewahrt sie mit einem Schlüssel in Ihrem Schlüsselbund auf. Nicht aufbewahren löscht das bereits Gespeicherte und behält nichts weiter."+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr "Über Bluetooth koppeln"diff --git a/po/es.po b/po/es.poindex 8d1e662..1da554c 100644--- a/po/es.po+++ b/po/es.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: 2026-08-22\n""Last-Translator: Tether project\n""Language-Team: Spanish\n"@@ -100,6 +100,10 @@ msgstr "Mostrar los mensajes de una conversación."msgid "Reply in one conversation."msgstr "Responder en una conversación."+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr "Listar los contactos del iPhone, o buscarlos por nombre o número."+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr "Emparejar con un iPhone por Bluetooth."@@ -136,6 +140,12 @@ msgstr "Activar o desactivar la duplicación de notificaciones."msgid "Mirror notification titles and bodies, not just the app."msgstr "Duplicar títulos y contenido de las notificaciones, no solo la app."+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr "Cómo se guardan en disco el historial de mensajes y los contactos. encrypted usa una clave del llavero del escritorio; none elimina lo almacenado y no conserva nada más."+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr "Elige qué adaptador Bluetooth usar."@@ -424,6 +434,31 @@ msgid_plural "({} unread)"msgstr[0] "({} sin leer)"msgstr[1] "({} sin leer)"+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr "El tetherd en ejecución es {}, pero este es tether {}. Reinícielo con:\n systemctl --user restart tetherd\n"++#: src/cli/main.cpp+msgid "an older build"+msgstr "una versión anterior"++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr "No se pudieron leer los contactos del daemon.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr "Aún no hay contactos. Compruebe 'tether --bt-connection'.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr "Ningún contacto coincide con %s\n"+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr "No se pudieron leer los mensajes del daemon.\n"@@ -558,6 +593,20 @@ msgstr "Duplicación de notificaciones activada."msgid "Notification mirroring disabled."msgstr "Duplicación de notificaciones desactivada."+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr "Se esperaba encrypted, plaintext o none, p. ej. --bt-retention encrypted\n"++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr "Eliminando los mensajes y contactos almacenados.\n"++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr "Conservación establecida en %s.\n"+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr ""@@ -1360,6 +1409,29 @@ msgstr """la envió. El propio ajuste «Mostrar notificaciones de mensajes» del teléfono ""debe seguir activado."+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr "Conservar el historial de mensajes:"++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr "Cifrado"++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr "Sin cifrar"++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr "No conservar"++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr "Dónde se almacenan los mensajes y los contactos en este equipo. Cifrado los guarda con una clave en el llavero de su escritorio. No conservar elimina lo ya almacenado y no conserva nada más."+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr "Emparejar por Bluetooth"diff --git a/po/fr.po b/po/fr.poindex 966bae1..d111a34 100644--- a/po/fr.po+++ b/po/fr.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: 2026-08-22\n""Last-Translator: Tether project\n""Language-Team: French\n"@@ -101,6 +101,10 @@ msgstr "Afficher les messages d'une conversation."msgid "Reply in one conversation."msgstr "Répondre dans une conversation."+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr "Lister les contacts de l'iPhone, ou les rechercher par nom ou numéro."+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr "Appairer un iPhone en Bluetooth."@@ -139,6 +143,12 @@ msgid "Mirror notification titles and bodies, not just the app."msgstr """Dupliquer les titres et le contenu des notifications, pas seulement l'app."+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr "Comment l'historique des messages et les contacts sont conservés sur le disque. encrypted utilise une clé du trousseau du bureau ; none supprime ce qui est stocké et ne conserve plus rien."+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr "Choisit l'adaptateur Bluetooth à utiliser."@@ -430,6 +440,31 @@ msgid_plural "({} unread)"msgstr[0] "({} non lu)"msgstr[1] "({} non lus)"+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr "Le tetherd en cours d'exécution est {}, mais ceci est tether {}. Redémarrez-le avec :\n systemctl --user restart tetherd\n"++#: src/cli/main.cpp+msgid "an older build"+msgstr "une version plus ancienne"++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr "Impossible de lire les contacts depuis le démon.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr "Aucun contact pour l'instant. Vérifiez avec 'tether --bt-connection'.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr "Aucun contact ne correspond à %s\n"+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr "Impossible de lire les messages depuis le démon.\n"@@ -563,6 +598,20 @@ msgstr "Duplication des notifications activée."msgid "Notification mirroring disabled."msgstr "Duplication des notifications désactivée."+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr "Attendu encrypted, plaintext ou none, p. ex. --bt-retention encrypted\n"++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr "Suppression des messages et des contacts stockés.\n"++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr "Conservation définie sur %s.\n"+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr "Adaptateur attendu, par ex. --bt-adapter hci1, ou --bt-adapter auto\n"@@ -1367,6 +1416,29 @@ msgstr """seulement l'app émettrice. Le réglage « Afficher les notifications de ""messages » du téléphone doit rester activé."+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr "Conserver l'historique des messages :"++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr "Chiffré"++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr "Non chiffré"++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr "Ne pas conserver"++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr "Où les messages et les contacts sont stockés sur cet ordinateur. Chiffré les conserve avec une clé dans le trousseau de votre bureau. Ne pas conserver supprime ce qui est déjà stocké et ne conserve plus rien."+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr "Appairer en Bluetooth"diff --git a/po/it.po b/po/it.poindex af3cee8..191ba41 100644--- a/po/it.po+++ b/po/it.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Italian\n"@@ -101,6 +101,10 @@ msgstr "Mostra i messaggi di una conversazione."msgid "Reply in one conversation."msgstr "Rispondi in una conversazione."+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr "Elenca i contatti dell'iPhone, o cercali per nome o numero."+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr "Accoppia un iPhone tramite Bluetooth."@@ -137,6 +141,12 @@ msgstr "Attiva o disattiva il mirroring delle notifiche."msgid "Mirror notification titles and bodies, not just the app."msgstr "Rispecchia titoli e testo delle notifiche, non solo l'app."+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr "Come vengono conservati su disco la cronologia dei messaggi e i contatti. encrypted usa una chiave del portachiavi del desktop; none elimina quanto memorizzato e non conserva altro."+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr "Sceglie quale adattatore Bluetooth usare."@@ -424,6 +434,31 @@ msgid_plural "({} unread)"msgstr[0] "({} non letto)"msgstr[1] "({} non letti)"+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr "Il tetherd in esecuzione è {}, ma questo è tether {}. Riavvialo con:\n systemctl --user restart tetherd\n"++#: src/cli/main.cpp+msgid "an older build"+msgstr "una versione più vecchia"++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr "Impossibile leggere i contatti dal daemon.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr "Ancora nessun contatto. Controlla 'tether --bt-connection'.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr "Nessun contatto corrisponde a %s\n"+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr "Impossibile leggere i messaggi dal daemon.\n"@@ -559,6 +594,20 @@ msgstr "Mirroring delle notifiche attivato."msgid "Notification mirroring disabled."msgstr "Mirroring delle notifiche disattivato."+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr "Attesi encrypted, plaintext o none, ad es. --bt-retention encrypted\n"++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr "Eliminazione dei messaggi e dei contatti memorizzati.\n"++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr "Conservazione impostata su %s.\n"+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr ""@@ -1358,6 +1407,29 @@ msgstr """l'ha inviata. L'opzione \"Mostra notifiche messaggi\" del telefono deve ""comunque essere attiva."+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr "Conserva la cronologia dei messaggi:"++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr "Cifrata"++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr "Non cifrata"++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr "Non conservare"++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr "Dove messaggi e contatti vengono memorizzati su questo computer. Cifrata li conserva con una chiave nel portachiavi del desktop. Non conservare elimina quanto già memorizzato e non conserva altro."+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr "Accoppia tramite Bluetooth"diff --git a/po/ja.po b/po/ja.poindex f00763e..f21822f 100644--- a/po/ja.po+++ b/po/ja.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Japanese\n"@@ -99,6 +99,10 @@ msgstr "1 つの会話のメッセージを表示します。"msgid "Reply in one conversation."msgstr "1 つの会話で返信します。"+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr "iPhone の連絡先を一覧表示、または名前や番号で検索します。"+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr "Bluetooth で iPhone とペアリングします。"@@ -135,6 +139,12 @@ msgstr "通知のミラーリングをオンまたはオフにします。"msgid "Mirror notification titles and bodies, not just the app."msgstr "アプリ名だけでなく、通知のタイトルと本文もミラーリングします。"+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr "メッセージ履歴と連絡先をディスクにどう保持するか。encrypted はデスクトップのキーリングにある鍵を使います。none は保存済みのものを削除し、以後何も保持しません。"+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr "使用する Bluetooth アダプタを選択します。"@@ -413,6 +423,31 @@ msgid "({} unread)"msgid_plural "({} unread)"msgstr[0] "({} 件未読)"+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr "実行中の tetherd は {} ですが、こちらは tether {} です。次のコマンドで再起動してください:\n systemctl --user restart tetherd\n"++#: src/cli/main.cpp+msgid "an older build"+msgstr "より古いビルド"++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr "デーモンから連絡先を読み取れませんでした。\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr "まだ連絡先はありません。'tether --bt-connection' を確認してください。\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr "%s に一致する連絡先はありません\n"+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr "デーモンからメッセージを読み取れませんでした。\n"@@ -540,6 +575,20 @@ msgstr "通知のミラーリングを有効にしました。"msgid "Notification mirroring disabled."msgstr "通知のミラーリングを無効にしました。"+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr "encrypted、plaintext、none のいずれかを指定してください。例: --bt-retention encrypted\n"++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr "保存されたメッセージと連絡先を削除しています。\n"++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr "保持設定を %s にしました。\n"+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr ""@@ -1326,6 +1375,29 @@ msgstr """どのアプリが送信したかだけでなく、各通知のタイトルと本文も iPhone に要求しま""す。iPhone 側の「メッセージ通知を表示」もオンになっている必要があります。"+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr "メッセージ履歴の保持:"++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr "暗号化する"++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr "暗号化しない"++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr "保持しない"++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr "このコンピューターでメッセージと連絡先を保存する方法。「暗号化する」はデスクトップのキーリングにある鍵で保存します。「保持しない」は保存済みのものを削除し、以後何も保持しません。"+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr "Bluetooth でペアリング"diff --git a/po/ko.po b/po/ko.poindex abc1a85..01af4e8 100644--- a/po/ko.po+++ b/po/ko.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Korean\n"@@ -98,6 +98,10 @@ msgstr "한 대화의 메시지를 표시합니다."msgid "Reply in one conversation."msgstr "한 대화에서 답장합니다."+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr "iPhone 연락처를 나열하거나 이름 또는 번호로 검색합니다."+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr "Bluetooth로 iPhone과 페어링합니다."@@ -134,6 +138,12 @@ msgstr "알림 미러링을 켜거나 끕니다."msgid "Mirror notification titles and bodies, not just the app."msgstr "앱뿐 아니라 알림의 제목과 본문도 미러링합니다."+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr "메시지 기록과 연락처를 디스크에 보관하는 방식입니다. encrypted는 데스크톱 키링의 키를 사용하고, none은 저장된 내용을 삭제하며 이후 아무것도 보관하지 않습니다."+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr "사용할 Bluetooth 어댑터를 선택합니다."@@ -412,6 +422,31 @@ msgid "({} unread)"msgid_plural "({} unread)"msgstr[0] "(읽지 않음 {}개)"+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr "실행 중인 tetherd는 {}이지만 이것은 tether {}입니다. 다음 명령으로 다시 시작하십시오:\n systemctl --user restart tetherd\n"++#: src/cli/main.cpp+msgid "an older build"+msgstr "이전 빌드"++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr "데몬에서 연락처를 읽지 못했습니다.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr "아직 연락처가 없습니다. 'tether --bt-connection'을 확인하십시오.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr "%s과(와) 일치하는 연락처가 없습니다\n"+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr "데몬에서 메시지를 읽지 못했습니다.\n"@@ -538,6 +573,20 @@ msgstr "알림 미러링을 켰습니다."msgid "Notification mirroring disabled."msgstr "알림 미러링을 껐습니다."+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr "encrypted, plaintext 또는 none이 필요합니다. 예: --bt-retention encrypted\n"++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr "저장된 메시지와 연락처를 삭제하는 중입니다.\n"++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr "보관 방식을 %s(으)로 설정했습니다.\n"+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr "어댑터를 지정하세요. 예: --bt-adapter hci1 또는 --bt-adapter auto\n"@@ -1312,6 +1361,29 @@ msgstr """어떤 앱이 보냈는지뿐 아니라 각 알림의 제목과 본문도 iPhone에 요청합니다. ""iPhone의 '메시지 알림 보기' 설정도 켜져 있어야 합니다."+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr "메시지 기록 보관:"++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr "암호화"++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr "암호화 안 함"++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr "보관 안 함"++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr "이 컴퓨터에 메시지와 연락처를 저장하는 방식입니다. 암호화는 데스크톱 키링의 키로 보관합니다. 보관 안 함은 이미 저장된 내용을 삭제하고 이후 아무것도 보관하지 않습니다."+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr "Bluetooth로 페어링"diff --git a/po/nl.po b/po/nl.poindex 895ecf5..39ce089 100644--- a/po/nl.po+++ b/po/nl.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Dutch\n"@@ -99,6 +99,10 @@ msgstr "De berichten van één gesprek tonen."msgid "Reply in one conversation."msgstr "In één gesprek antwoorden."+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr "Contacten van de iPhone tonen, of erin zoeken op naam of nummer."+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr "Een iPhone via Bluetooth koppelen."@@ -136,6 +140,12 @@ msgstr "Het spiegelen van meldingen in- of uitschakelen."msgid "Mirror notification titles and bodies, not just the app."msgstr "Titels en tekst van meldingen spiegelen, niet alleen de app."+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr "Hoe berichtgeschiedenis en contacten op schijf worden bewaard. encrypted gebruikt een sleutel uit de sleutelbos van het bureaublad; none verwijdert wat is opgeslagen en bewaart verder niets."+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr "Kiest welke Bluetooth-adapter wordt gebruikt."@@ -423,6 +433,31 @@ msgid_plural "({} unread)"msgstr[0] "({} ongelezen)"msgstr[1] "({} ongelezen)"+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr "De draaiende tetherd is {}, maar dit is tether {}. Start hem opnieuw met:\n systemctl --user restart tetherd\n"++#: src/cli/main.cpp+msgid "an older build"+msgstr "een oudere build"++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr "Kon de contacten niet van de daemon lezen.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr "Nog geen contacten. Controleer 'tether --bt-connection'.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr "Geen contacten komen overeen met %s\n"+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr "Kon de berichten niet van de daemon lezen.\n"@@ -554,6 +589,20 @@ msgstr "Spiegelen van meldingen ingeschakeld."msgid "Notification mirroring disabled."msgstr "Spiegelen van meldingen uitgeschakeld."+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr "Verwacht encrypted, plaintext of none, bijv. --bt-retention encrypted\n"++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr "Opgeslagen berichten en contacten worden verwijderd.\n"++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr "Bewaren ingesteld op %s.\n"+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr "Adapter verwacht, bijv. --bt-adapter hci1, of --bt-adapter auto\n"@@ -1352,6 +1401,29 @@ msgstr """app hem stuurde. De optie \"Toon berichtmeldingen\" van de telefoon moet nog ""steeds aanstaan."+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr "Berichtgeschiedenis bewaren:"++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr "Versleuteld"++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr "Onversleuteld"++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr "Niet bewaren"++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr "Waar berichten en contacten op deze computer worden opgeslagen. Versleuteld bewaart ze met een sleutel in uw sleutelbos. Niet bewaren verwijdert wat al is opgeslagen en bewaart verder niets."+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr "Koppelen via Bluetooth"diff --git a/po/pl.po b/po/pl.poindex cfb58af..42f0534 100644--- a/po/pl.po+++ b/po/pl.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Polish\n"@@ -100,6 +100,10 @@ msgstr "Pokaż wiadomości jednej rozmowy."msgid "Reply in one conversation."msgstr "Odpowiedz w jednej rozmowie."+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr "Wypisz kontakty z iPhone'a lub wyszukaj je według nazwy albo numeru."+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr "Sparuj iPhone'a przez Bluetooth."@@ -136,6 +140,12 @@ msgstr "Włącz lub wyłącz kopiowanie powiadomień."msgid "Mirror notification titles and bodies, not just the app."msgstr "Kopiuj tytuły i treść powiadomień, nie tylko aplikację."+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr "Jak historia wiadomości i kontakty są przechowywane na dysku. encrypted używa klucza z pęku kluczy środowiska; none usuwa zapisane dane i niczego dalej nie przechowuje."+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr "Wybiera używany adapter Bluetooth."@@ -428,6 +438,31 @@ msgstr[0] "({} nieprzeczytana)"msgstr[1] "({} nieprzeczytane)"msgstr[2] "({} nieprzeczytanych)"+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr "Działający tetherd to {}, a to jest tether {}. Uruchom go ponownie poleceniem:\n systemctl --user restart tetherd\n"++#: src/cli/main.cpp+msgid "an older build"+msgstr "starsza wersja"++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr "Nie udało się odczytać kontaktów od demona.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr "Nie ma jeszcze kontaktów. Sprawdź 'tether --bt-connection'.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr "Żaden kontakt nie pasuje do %s\n"+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr "Nie udało się odczytać wiadomości od demona.\n"@@ -559,6 +594,20 @@ msgstr "Kopiowanie powiadomień włączone."msgid "Notification mirroring disabled."msgstr "Kopiowanie powiadomień wyłączone."+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr "Oczekiwano encrypted, plaintext lub none, np. --bt-retention encrypted\n"++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr "Usuwanie zapisanych wiadomości i kontaktów.\n"++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr "Przechowywanie ustawione na %s.\n"+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr "Oczekiwano adaptera, np. --bt-adapter hci1, lub --bt-adapter auto\n"@@ -1355,6 +1404,29 @@ msgstr """która aplikacja je wysłała. Opcja „Pokaż powiadomienia o wiadomościach” w ""telefonie i tak musi być włączona."+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr "Przechowuj historię wiadomości:"++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr "Zaszyfrowane"++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr "Niezaszyfrowane"++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr "Nie przechowuj"++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr "Gdzie na tym komputerze przechowywane są wiadomości i kontakty. Zaszyfrowane przechowuje je przy użyciu klucza z pęku kluczy. Nie przechowuj usuwa już zapisane dane i niczego dalej nie przechowuje."+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr "Sparuj przez Bluetooth"diff --git a/po/pt_BR.po b/po/pt_BR.poindex dfcc7b8..98a8119 100644--- a/po/pt_BR.po+++ b/po/pt_BR.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Brazilian Portuguese\n"@@ -100,6 +100,10 @@ msgstr "Mostrar as mensagens de uma conversa."msgid "Reply in one conversation."msgstr "Responder em uma conversa."+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr "Listar os contatos do iPhone, ou procurá-los por nome ou número."+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr "Parear com um iPhone por Bluetooth."@@ -136,6 +140,12 @@ msgstr "Ativar ou desativar o espelhamento de notificações."msgid "Mirror notification titles and bodies, not just the app."msgstr "Espelhar títulos e texto das notificações, não apenas o app."+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr "Como o histórico de mensagens e os contatos são guardados em disco. encrypted usa uma chave do chaveiro da área de trabalho; none apaga o que está armazenado e não guarda mais nada."+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr "Escolhe qual adaptador Bluetooth usar."@@ -423,6 +433,31 @@ msgid_plural "({} unread)"msgstr[0] "({} não lida)"msgstr[1] "({} não lidas)"+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr "O tetherd em execução é {}, mas este é o tether {}. Reinicie-o com:\n systemctl --user restart tetherd\n"++#: src/cli/main.cpp+msgid "an older build"+msgstr "uma versão mais antiga"++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr "Não foi possível ler os contatos no daemon.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr "Ainda não há contatos. Verifique 'tether --bt-connection'.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr "Nenhum contato corresponde a %s\n"+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr "Não foi possível ler as mensagens no daemon.\n"@@ -555,6 +590,20 @@ msgstr "Espelhamento de notificações ativado."msgid "Notification mirroring disabled."msgstr "Espelhamento de notificações desativado."+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr "Esperado encrypted, plaintext ou none, p. ex. --bt-retention encrypted\n"++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr "Apagando as mensagens e os contatos armazenados.\n"++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr "Retenção definida como %s.\n"+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr ""@@ -1352,6 +1401,29 @@ msgstr """enviou. A opção \"Mostrar Notificações de Mensagens\" do próprio telefone ""ainda precisa estar ativada."+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr "Guardar o histórico de mensagens:"++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr "Criptografado"++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr "Sem criptografia"++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr "Não guardar"++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr "Onde as mensagens e os contatos são armazenados neste computador. Criptografado os guarda com uma chave no chaveiro da sua área de trabalho. Não guardar apaga o que já está armazenado e não guarda mais nada."+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr "Parear por Bluetooth"diff --git a/po/ru.po b/po/ru.poindex 8fb743b..1062757 100644--- a/po/ru.po+++ b/po/ru.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Russian\n"@@ -100,6 +100,10 @@ msgstr "Показать сообщения одной переписки."msgid "Reply in one conversation."msgstr "Ответить в одной переписке."+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr "Показать контакты iPhone или найти их по имени либо номеру."+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr "Создать пару с iPhone по Bluetooth."@@ -136,6 +140,12 @@ msgstr "Включить или выключить дублирование увmsgid "Mirror notification titles and bodies, not just the app."msgstr "Дублировать заголовки и текст уведомлений, а не только приложение."+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr "Как история сообщений и контакты хранятся на диске. encrypted использует ключ из связки ключей рабочего стола; none удаляет сохранённое и больше ничего не хранит."+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr "Выбор используемого адаптера Bluetooth."@@ -428,6 +438,31 @@ msgstr[0] "({} непрочитанное)"msgstr[1] "({} непрочитанных)"msgstr[2] "({} непрочитанных)"+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr "Запущен tetherd {}, но это tether {}. Перезапустите его командой:\n systemctl --user restart tetherd\n"++#: src/cli/main.cpp+msgid "an older build"+msgstr "более старая сборка"++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr "Не удалось прочитать контакты у демона.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr "Контактов пока нет. Проверьте 'tether --bt-connection'.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr "Нет контактов, соответствующих %s\n"+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr "Не удалось прочитать сообщения у демона.\n"@@ -561,6 +596,20 @@ msgstr "Дублирование уведомлений включено."msgid "Notification mirroring disabled."msgstr "Дублирование уведомлений выключено."+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr "Ожидалось encrypted, plaintext или none, например --bt-retention encrypted\n"++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr "Удаление сохранённых сообщений и контактов.\n"++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr "Хранение установлено на %s.\n"+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr "Ожидался адаптер, например --bt-adapter hci1, или --bt-adapter auto\n"@@ -1355,6 +1404,29 @@ msgstr """приложение, которое его отправило. Параметр «Показ уведомлений о сообщениях» ""на самом телефоне всё равно должен быть включён."+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr "Хранить историю сообщений:"++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr "Зашифрованно"++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr "Незашифрованно"++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr "Не хранить"++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr "Где на этом компьютере хранятся сообщения и контакты. «Зашифрованно» хранит их с ключом в вашей связке ключей. «Не хранить» удаляет уже сохранённое и больше ничего не хранит."+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr "Создать пару по Bluetooth"diff --git a/po/sv.po b/po/sv.poindex 5186ee6..2d41485 100644--- a/po/sv.po+++ b/po/sv.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Swedish\n"@@ -100,6 +100,10 @@ msgstr "Visa meddelandena i en konversation."msgid "Reply in one conversation."msgstr "Svara i en konversation."+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr "Lista iPhone-kontakter, eller sök i dem på namn eller nummer."+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr "Parkoppla en iPhone via Bluetooth."@@ -136,6 +140,12 @@ msgstr "Slå på eller av spegling av aviseringar."msgid "Mirror notification titles and bodies, not just the app."msgstr "Spegla aviseringarnas rubrik och text, inte bara appen."+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr "Hur meddelandehistorik och kontakter sparas på disk. encrypted använder en nyckel från skrivbordets nyckelring; none raderar det som sparats och sparar inget mer."+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr "Väljer vilken Bluetooth-adapter som ska användas."@@ -421,6 +431,31 @@ msgid_plural "({} unread)"msgstr[0] "({} oläst)"msgstr[1] "({} olästa)"+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr "Den körande tetherd är {}, men detta är tether {}. Starta om den med:\n systemctl --user restart tetherd\n"++#: src/cli/main.cpp+msgid "an older build"+msgstr "ett äldre bygge"++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr "Kunde inte läsa kontakterna från demonen.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr "Inga kontakter ännu. Kontrollera 'tether --bt-connection'.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr "Inga kontakter matchar %s\n"+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr "Kunde inte läsa meddelandena från demonen.\n"@@ -552,6 +587,20 @@ msgstr "Spegling av aviseringar aktiverad."msgid "Notification mirroring disabled."msgstr "Spegling av aviseringar avaktiverad."+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr "Förväntade encrypted, plaintext eller none, t.ex. --bt-retention encrypted\n"++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr "Raderar sparade meddelanden och kontakter.\n"++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr "Lagring inställd på %s.\n"+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr ""@@ -1337,6 +1386,29 @@ msgstr """app som skickade den. Telefonens egen inställning \"Visa ""meddelandeaviseringar\" måste ändå vara på."+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr "Spara meddelandehistorik:"++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr "Krypterat"++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr "Okrypterat"++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr "Spara inte"++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr "Var meddelanden och kontakter lagras på den här datorn. Krypterat sparar dem med en nyckel i din nyckelring. Spara inte raderar det som redan lagrats och sparar inget mer."+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr "Parkoppla via Bluetooth"diff --git a/po/tether.pot b/po/tether.potindex 9d4f9a5..bfab452 100644--- a/po/tether.pot+++ b/po/tether.pot@@ -6,9 +6,9 @@#, fuzzymsgid ""msgstr ""-"Project-Id-Version: tether 0.2.22\n"+"Project-Id-Version: tether 0.2.23\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n""Last-Translator: FULL NAME <EMAIL@ADDRESS>\n""Language-Team: LANGUAGE <[email protected]>\n"@@ -98,6 +98,10 @@ msgstr ""msgid "Reply in one conversation."msgstr ""+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr ""+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr ""@@ -130,6 +134,12 @@ msgstr ""msgid "Mirror notification titles and bodies, not just the app."msgstr ""+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr ""+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr ""@@ -392,6 +402,31 @@ msgid_plural "({} unread)"msgstr[0] ""msgstr[1] ""+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr ""++#: src/cli/main.cpp+msgid "an older build"+msgstr ""++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr ""++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr ""++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr ""+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr ""@@ -515,6 +550,20 @@ msgstr ""msgid "Notification mirroring disabled."msgstr ""+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr ""++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr ""++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr ""+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr ""@@ -1205,6 +1254,29 @@ msgid """has to be on."msgstr ""+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr ""++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr ""++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr ""++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr ""++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr ""+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr ""diff --git a/po/tr.po b/po/tr.poindex 2c78f6b..ce23103 100644--- a/po/tr.po+++ b/po/tr.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Turkish\n"@@ -98,6 +98,10 @@ msgstr "Bir konuşmadaki mesajları göster."msgid "Reply in one conversation."msgstr "Bir konuşmada yanıtla."+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr "iPhone kişilerini listeler veya ada ya da numaraya göre arar."+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr "Bluetooth üzerinden bir iPhone ile eşleş."@@ -135,6 +139,12 @@ msgid "Mirror notification titles and bodies, not just the app."msgstr """Yalnızca uygulamayı değil, bildirimlerin başlığını ve metnini de yansıt."+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr "Mesaj geçmişinin ve kişilerin diskte nasıl tutulacağı. encrypted masaüstü anahtarlığındaki bir anahtarı kullanır; none saklananları siler ve başka bir şey tutmaz."+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr "Hangi Bluetooth bağdaştırıcısının kullanılacağını seçer."@@ -421,6 +431,31 @@ msgid_plural "({} unread)"msgstr[0] "({} okunmamış)"msgstr[1] "({} okunmamış)"+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr "Çalışan tetherd {}, ancak bu tether {}. Şu komutla yeniden başlatın:\n systemctl --user restart tetherd\n"++#: src/cli/main.cpp+msgid "an older build"+msgstr "daha eski bir sürüm"++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr "Kişiler arka plan hizmetinden okunamadı.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr "Henüz kişi yok. 'tether --bt-connection' komutunu denetleyin.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr "%s ile eşleşen kişi yok\n"+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr "Mesajlar arka plan hizmetinden okunamadı.\n"@@ -552,6 +587,20 @@ msgstr "Bildirim yansıtma etkinleştirildi."msgid "Notification mirroring disabled."msgstr "Bildirim yansıtma devre dışı bırakıldı."+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr "encrypted, plaintext veya none bekleniyordu, örn. --bt-retention encrypted\n"++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr "Saklanan mesajlar ve kişiler siliniyor.\n"++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr "Saklama %s olarak ayarlandı.\n"+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr ""@@ -1335,6 +1384,29 @@ msgstr """uygulamanın gönderdiğini değil. Telefonun kendi \"Mesaj Bildirimlerini ""Göster\" seçeneğinin yine de açık olması gerekir."+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr "Mesaj geçmişini sakla:"++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr "Şifreli"++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr "Şifresiz"++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr "Saklama"++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr "Mesajların ve kişilerin bu bilgisayarda nerede saklanacağı. Şifreli, onları masaüstü anahtarlığınızdaki bir anahtarla saklar. Saklama, halihazırda saklananları siler ve başka bir şey tutmaz."+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr "Bluetooth üzerinden eşleş"diff --git a/po/uk.po b/po/uk.poindex 0fc1d97..5192b84 100644--- a/po/uk.po+++ b/po/uk.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Ukrainian\n"@@ -101,6 +101,10 @@ msgstr "Показати повідомлення однієї розмови."msgid "Reply in one conversation."msgstr "Відповісти в одній розмові."+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr "Показати контакти iPhone або знайти їх за іменем чи номером."+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr "Створити пару з iPhone через Bluetooth."@@ -137,6 +141,12 @@ msgstr "Увімкнути або вимкнути дублювання сповmsgid "Mirror notification titles and bodies, not just the app."msgstr "Дублювати заголовки та текст сповіщень, а не лише програму."+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr "Як історія повідомлень і контакти зберігаються на диску. encrypted використовує ключ зі сховища ключів стільниці; none вилучає збережене й більше нічого не зберігає."+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr "Вибирає, який адаптер Bluetooth використовувати."@@ -429,6 +439,31 @@ msgstr[0] "({} непрочитане)"msgstr[1] "({} непрочитані)"msgstr[2] "({} непрочитаних)"+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr "Запущено tetherd {}, але це tether {}. Перезапустіть його командою:\n systemctl --user restart tetherd\n"++#: src/cli/main.cpp+msgid "an older build"+msgstr "старіша збірка"++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr "Не вдалося прочитати контакти у демона.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr "Контактів поки немає. Перевірте 'tether --bt-connection'.\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr "Немає контактів, що відповідають %s\n"+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr "Не вдалося прочитати повідомлення у демона.\n"@@ -560,6 +595,20 @@ msgstr "Дублювання сповіщень увімкнено."msgid "Notification mirroring disabled."msgstr "Дублювання сповіщень вимкнено."+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr "Очікувалося encrypted, plaintext або none, наприклад --bt-retention encrypted\n"++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr "Вилучення збережених повідомлень і контактів.\n"++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr "Зберігання встановлено на %s.\n"+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr ""@@ -1352,6 +1401,29 @@ msgstr """програма його надіслала. Параметр «Показ сповіщень про повідомлення» на ""самому телефоні все одно має бути ввімкнено."+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr "Зберігати історію повідомлень:"++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr "Зашифровано"++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr "Незашифровано"++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr "Не зберігати"++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr "Де на цьому комп'ютері зберігаються повідомлення й контакти. «Зашифровано» зберігає їх із ключем у вашому сховищі ключів. «Не зберігати» вилучає вже збережене й більше нічого не зберігає."+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr "Створити пару через Bluetooth"diff --git a/po/zh_CN.po b/po/zh_CN.poindex 69c4459..76202e3 100644--- a/po/zh_CN.po+++ b/po/zh_CN.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-09-02 11:40-0700\n"+"POT-Creation-Date: 2026-09-02 20:38-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Simplified Chinese\n"@@ -98,6 +98,10 @@ msgstr "显示某个会话中的信息。"msgid "Reply in one conversation."msgstr "在某个会话中回复。"+#: src/cli/main.cpp+msgid "List iPhone contacts, or search them by name or number."+msgstr "列出 iPhone 通讯录,或按姓名或号码搜索。"+#: src/cli/main.cppmsgid "Pair with an iPhone over Bluetooth."msgstr "通过蓝牙与 iPhone 配对。"@@ -132,6 +136,12 @@ msgstr "开启或关闭通知镜像。"msgid "Mirror notification titles and bodies, not just the app."msgstr "镜像通知的标题和正文,而不只是所属 App。"+#: src/cli/main.cpp+msgid ""+"How message history and contacts are kept on disk. Encrypted uses a key from "+"the desktop keyring; none deletes what is stored and keeps nothing further."+msgstr "消息记录和通讯录在磁盘上的保存方式。encrypted 使用桌面密钥环中的密钥;none 会删除已存储的内容且不再保留任何内容。"+#: src/cli/main.cppmsgid "Choose which Bluetooth controller to use."msgstr "选择要使用的蓝牙适配器。"@@ -408,6 +418,31 @@ msgid "({} unread)"msgid_plural "({} unread)"msgstr[0] "({} 条未读)"+#: src/cli/main.cpp+#, c++-format+msgid ""+"The running tetherd is {}, but this is tether {}. Restart it with:\n"+" systemctl --user restart tetherd\n"+msgstr "正在运行的 tetherd 是 {},而此处是 tether {}。请用以下命令重启:\n systemctl --user restart tetherd\n"++#: src/cli/main.cpp+msgid "an older build"+msgstr "较旧的版本"++#: src/cli/main.cpp+msgid "Could not read contacts from the daemon.\n"+msgstr "无法从守护进程读取通讯录。\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts yet. Check 'tether --bt-connection'.\n"+msgstr "暂无通讯录。请检查 'tether --bt-connection'。\n"++#: src/cli/main.cpp+#, c-format+msgid "No contacts match %s\n"+msgstr "没有匹配 %s 的联系人\n"+#: src/cli/main.cppmsgid "Could not read messages from the daemon.\n"msgstr "无法从守护进程读取信息。\n"@@ -533,6 +568,20 @@ msgstr "通知镜像已启用。"msgid "Notification mirroring disabled."msgstr "通知镜像已停用。"+#: src/cli/main.cpp+msgid "Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"+msgstr "应为 encrypted、plaintext 或 none,例如 --bt-retention encrypted\n"++#: src/cli/main.cpp+#, c-format+msgid "Deleting stored messages and contacts.\n"+msgstr "正在删除已存储的消息和通讯录。\n"++#: src/cli/main.cpp+#, c-format+msgid "Retention set to %s.\n"+msgstr "保留方式已设为 %s。\n"+#: src/cli/main.cppmsgid "Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"msgstr "需要指定适配器,例如 --bt-adapter hci1 或 --bt-adapter auto\n"@@ -1284,6 +1333,29 @@ msgstr """向 iPhone 请求每条通知的标题和正文,而不只是发送它的 App。iPhone 自身的“显示""信息通知”开关仍需保持开启。"+#: src/gtk/devices_view.cpp+msgid "Keep message history:"+msgstr "保留消息记录:"++#: src/gtk/devices_view.cpp+msgid "Encrypted"+msgstr "加密"++#: src/gtk/devices_view.cpp+msgid "Unencrypted"+msgstr "不加密"++#: src/gtk/devices_view.cpp+msgid "Do not keep"+msgstr "不保留"++#: src/gtk/devices_view.cpp+msgid ""+"Where messages and contacts are stored on this computer. Encrypted keeps "+"them with a key in your desktop keyring. Do not keep deletes what is already "+"stored and retains nothing further."+msgstr "消息和通讯录在这台计算机上的存储方式。「加密」会用桌面密钥环中的密钥保存。「不保留」会删除已存储的内容且不再保留任何内容。"+#: src/gtk/devices_view.cppmsgid "Pair over Bluetooth"msgstr "通过蓝牙配对"diff --git a/scripts/ci-deps.sh b/scripts/ci-deps.shindex bea39f2..e7b83e4 100755--- a/scripts/ci-deps.sh+++ b/scripts/ci-deps.sh@@ -13,14 +13,14 @@ case ${ID_LIKE:-$ID} in*arch*)pacman -Syu --noconfirm --needed \base-devel cmake ninja git pkgconf \- wayland avahi openssl glib2 \+ wayland avahi openssl glib2 libsecret \gtk3 gtk-layer-shell libnotify \npm zip gettext;;*fedora*)dnf install -y \gcc-c++ cmake ninja-build git pkgconf-pkg-config \- wayland-devel avahi-devel openssl-devel glib2-devel \+ wayland-devel avahi-devel openssl-devel glib2-devel libsecret-devel \gtk3-devel gtk-layer-shell-devel libnotify-devel \npm zip rpm-build gettext;;@@ -29,7 +29,7 @@ case ${ID_LIKE:-$ID} inapt-get updateapt-get install -y --no-install-recommends \g++ cmake ninja-build git pkg-config ca-certificates \- libwayland-dev libavahi-client-dev libssl-dev libglib2.0-dev \+ libwayland-dev libavahi-client-dev libssl-dev libglib2.0-dev libsecret-1-dev \libgtk-3-dev libgtk-layer-shell-dev libnotify-dev \npm zip gettext;;@@ -42,5 +42,5 @@ esaccommand -v msgfmt >/dev/null || { echo "ci-deps: msgfmt missing; translations would be skipped" >&2; exit 1; }pkg-config --print-errors --exists \- "wayland-client avahi-client openssl glib-2.0 gio-2.0 gtk+-3.0 gtk-layer-shell-0 libnotify"+ "wayland-client avahi-client openssl glib-2.0 gio-2.0 libsecret-1 gtk+-3.0 gtk-layer-shell-0 libnotify"echo "==> ready: gtk $(pkg-config --modversion gtk+-3.0), openssl $(pkg-config --modversion openssl)"diff --git a/scripts/tether-reset.sh b/scripts/tether-reset.shindex d78f83d..a0e516b 100755--- a/scripts/tether-reset.sh+++ b/scripts/tether-reset.sh@@ -2,7 +2,8 @@# Delete Tether's pairing state so the next pair starts from nothing.## tether-reset.sh wifi mTLS keys, known hosts, pending pair requests-# tether-reset.sh bt the BlueZ bond, Bluetooth config, contacts, messages+# tether-reset.sh bt the BlueZ bond, Bluetooth config, contacts, messages,+# and the key the encrypted store was written with# tether-reset.sh all both, plus the daemon log## Paths are spelled out rather than derived from XDG_CONFIG_HOME/XDG_DATA_HOME@@ -44,8 +45,11 @@ wifi_paths=(bt_paths=("$config/bluetooth.json""$config/groups.json"+ "$config/store.key""$share/contacts.json"+ "$share/contacts.json.enc""$share/messages.ndjson"+ "$share/messages.ndjson.enc")paths=()@@ -115,6 +119,14 @@ for p in "${paths[@]}"; dofidone+# The store key normally lives in the desktop keyring, not in a file, so the+# loop above misses it on any machine with a working secret service.+if [[ $scope == bt || $scope == all ]] && command -v secret-tool >/dev/null 2>&1; then+ if secret-tool clear application tether >/dev/null 2>&1; then+ printf ' %s✓%s store key in the desktop keyring\n' "$grn" "$rst"+ fi+fi+echoecho "Done. The iPhone side cannot be cleared from here:"if [[ $scope == bt || $scope == all ]]; thendiff --git a/src/cli/main.cpp b/src/cli/main.cppindex 736defe..cad2533 100644--- a/src/cli/main.cpp+++ b/src/cli/main.cpp@@ -17,6 +17,7 @@#include <tether/extension_host.hpp>#include <tether/i18n.hpp>#include <tether/log.hpp>+#include <tether/version.hpp>#include <thread>#include <unistd.h>#include <vector>@@ -190,6 +191,7 @@ static const Opt kOptions[] = {{"--bt-threads", N_("List iPhone message conversations.")},{"--bt-messages <thread>", N_("Show messages in one conversation.")},{"--bt-send <thread> <text>", N_("Reply in one conversation.")},+ {"--bt-contacts [query]", N_("List iPhone contacts, or search them by name or number.")},{"--bt-pair <addr> [--explicit-pair]", N_("Pair with an iPhone over Bluetooth.")},{"--explicit-pair",N_("Ask the iPhone to authenticate directly instead of connecting first. Tether falls back to this on "@@ -201,6 +203,9 @@ static const Opt kOptions[] = {{"--bt-enable <on|off>", N_("Connect to the iPhone over Bluetooth, or stop.")},{"--bt-ancs <on|off>", N_("Turn notification mirroring on or off.")},{"--bt-ancs-content <on|off>", N_("Mirror notification titles and bodies, not just the app.")},+ {"--bt-retention <encrypted|plaintext|none>",+ N_("How message history and contacts are kept on disk. Encrypted uses a key from the desktop keyring; "+ "none deletes what is stored and keeps nothing further.")},{"--bt-adapter <hciN|auto>", N_("Choose which Bluetooth controller to use.")},{"--bt-notifications", N_("List mirrored iPhone notifications.")},{"--bt-diagnostics", N_("Print a redacted Bluetooth report for a bug report.")},@@ -655,6 +660,61 @@ static int print_bt_threads(tether::Client& client) {return 0;}+// A package upgrade replaces the binaries but leaves the old tetherd running.+static void warn_if_daemon_is_older(tether::Client& client) {+ std::string running;+ try {+ auto status = nlohmann::json::parse(client.send_and_wait("{\"command\":\"bt_status\"}\n"));+ running = status.value("version", "");+ } catch (const std::exception&) {+ return;+ }+ if (running == TETHER_VERSION)+ return;++ // No version field at all means a daemon older than the field itself.+ debug::log(ERR,+ _("The running tetherd is {}, but this is tether {}. Restart it with:\n"+ " systemctl --user restart tetherd\n"),+ running.empty() ? _("an older build") : running.c_str(),+ TETHER_VERSION);+}++static int print_bt_contacts(tether::Client& client, const std::string& query) {+ nlohmann::json request;+ request["command"] = "bt_list_contacts";+ request["query"] = query;++ nlohmann::json resp;+ try {+ resp = nlohmann::json::parse(client.send_and_wait(request.dump() + "\n"));+ } catch (const std::exception&) {+ debug::log(ERR, _("Could not read contacts from the daemon.\n"));+ warn_if_daemon_is_older(client);+ return 1;+ }++ const auto& contacts = resp["contacts"];+ if (contacts.empty()) {+ if (query.empty())+ fprintf(stdout, _("No contacts yet. Check 'tether --bt-connection'.\n"));+ else+ fprintf(stdout, _("No contacts match %s\n"), query.c_str());+ return 0;+ }++ // Name then addresses, one address per line+ for (const auto& c : contacts) {+ // A vCard with addresses but no FN would start its block with a blank line+ const std::string name = c.value("name", "");+ if (!name.empty())+ fprintf(stdout, " %s\n", name.c_str());+ for (const auto& address : c["addresses"])+ fprintf(stdout, " %s\n", address.get<std::string>().c_str());+ }+ return 0;+}+static int print_bt_messages(tether::Client& client, const std::string& thread) {nlohmann::json request;request["command"] = "bt_list_messages";@@ -777,6 +837,10 @@ int main(int argc, char* argv[]) {action = "bt_diagnostics";} else if (arg == "--bt-threads") {action = "bt_threads";+ } else if (arg == "--bt-contacts") {+ action = "bt_contacts";+ if (i + 1 < argc && argv[i + 1][0] != '-')+ arg_val = argv[++i];} else if (arg == "--bt-messages") {action = "bt_messages";if (i + 1 < argc && argv[i + 1][0] != '-')@@ -801,6 +865,10 @@ int main(int argc, char* argv[]) {action = "bt_ancs_content";if (i + 1 < argc && argv[i + 1][0] != '-')arg_val = argv[++i];+ } else if (arg == "--bt-retention") {+ action = "bt_retention";+ if (i + 1 < argc && argv[i + 1][0] != '-')+ arg_val = argv[++i];} else if (arg == "--bt-adapter") {action = "bt_adapter";if (i + 1 < argc && argv[i + 1][0] != '-')@@ -961,6 +1029,8 @@ int main(int argc, char* argv[]) {return print_bt_diagnostics(client);} else if (action == "bt_threads") {return print_bt_threads(client);+ } else if (action == "bt_contacts") {+ return print_bt_contacts(client, arg_val);} else if (action == "bt_notifications") {return print_bt_notifications(client);} else if (action == "bt_messages") {@@ -1023,6 +1093,22 @@ int main(int argc, char* argv[]) {"%s\n",content ? (on ? _("Notification contents enabled.") : _("Notification contents disabled.")): (on ? _("Notification mirroring enabled.") : _("Notification mirroring disabled.")));+ } else if (action == "bt_retention") {+ if (arg_val != "encrypted" && arg_val != "plaintext" && arg_val != "none") {+ debug::log(ERR, _("Expected encrypted, plaintext or none, e.g. --bt-retention encrypted\n"));+ return 1;+ }+ if (arg_val == "none")+ fprintf(stdout, _("Deleting stored messages and contacts.\n"));++ nlohmann::json request;+ request["command"] = "bt_set_retention";+ request["retention"] = arg_val;+ if (!client.send(request.dump() + "\n")) {+ debug::log(ERR, _("Could not reach the daemon.\n"));+ return 1;+ }+ fprintf(stdout, _("Retention set to %s.\n"), arg_val.c_str());} else if (action == "bt_adapter") {if (arg_val.empty()) {debug::log(ERR, _("Expected a controller, e.g. --bt-adapter hci1, or --bt-adapter auto\n"));diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txtindex 5faca00..9e57205 100644--- a/src/core/CMakeLists.txt+++ b/src/core/CMakeLists.txt@@ -7,6 +7,7 @@ add_library(tether STATICsrc/otp.cppsrc/file_transfer.cppsrc/crypto.cpp+ src/secret_store.cppsrc/client.cppsrc/extension_host.cppsrc/discovery.cpp@@ -61,5 +62,6 @@ target_link_libraries(tether PUBLICOpenSSL::CryptoPkgConfig::AVAHIPkgConfig::GLIB+ PkgConfig::SECRETIntl::Intl)diff --git a/src/core/include/tether/bluetooth/config.hpp b/src/core/include/tether/bluetooth/config.hppindex 70899a1..2cd0ce9 100644--- a/src/core/include/tether/bluetooth/config.hpp+++ b/src/core/include/tether/bluetooth/config.hpp@@ -1,5 +1,7 @@#pragma once+#include "tether/secret_store.hpp"+#include <string>namespace tether::bluetooth {@@ -33,6 +35,8 @@ namespace tether::bluetooth {// Controller to use, "hci1" or its address. Empty picks the first// powered one, which is wrong on any machine with a second controller.std::string adapter;+ // How the message journal and contact cache are kept on disk. Encrypted by default.+ Retention retention = Retention::Encrypted;bool operator==(const Config&) const = default;};diff --git a/src/core/include/tether/bluetooth/connection.hpp b/src/core/include/tether/bluetooth/connection.hppindex c564f73..675d129 100644--- a/src/core/include/tether/bluetooth/connection.hpp+++ b/src/core/include/tether/bluetooth/connection.hpp@@ -96,6 +96,9 @@ namespace tether::bluetooth {// Why a group thread can or cannot be replied to, for the UI to show.ReplyEligibility group_reply_status(const std::string& thread_key, std::string& reason);+ // Closes the message journal and drops the in-memory history.+ void discard_retained_messages();+void set_group_replies_enabled(bool enabled);void reload_group_rosters();diff --git a/src/core/include/tether/bluetooth/contacts.hpp b/src/core/include/tether/bluetooth/contacts.hppindex aa50018..8d409ad 100644--- a/src/core/include/tether/bluetooth/contacts.hpp+++ b/src/core/include/tether/bluetooth/contacts.hpp@@ -1,6 +1,7 @@#pragma once#include "tether/bluetooth/vcard.hpp"+#include "tether/secret_store.hpp"#include <map>#include <nlohmann/json.hpp>@@ -21,6 +22,9 @@ namespace tether::bluetooth {// Every address a display name maps to. Returns all matches.std::vector<std::string> addresses_for_name(const std::string& name) const;+ // Contacts whose name or any of their addresses contains `needle`, case- and accent-insensitively.+ std::vector<VCard> search(const std::string& needle, size_t limit) const;+size_t size() const { return contacts_.size(); }size_t indexed() const { return by_key_.size(); }const std::vector<VCard>& contacts() const { return contacts_; }@@ -32,9 +36,13 @@ namespace tether::bluetooth {std::map<std::string, std::string> by_tel_suffix_;};- // Cached at ~/.local/share/tether/contacts.json so names survive a restart- // and are available before PBAP reconnects.+ std::string contacts_path(Retention mode);std::string contacts_path();++ // Rewrites the cache from one mode's file into the other's and removes the+ // source. No-op unless the source exists and the destination does not.+ bool migrate_contacts(Retention from, Retention to);+bool save_contacts(const ContactStore& store);ContactStore load_contacts();diff --git a/src/core/include/tether/bluetooth/journal.hpp b/src/core/include/tether/bluetooth/journal.hppindex 80c9c6d..317fd40 100644--- a/src/core/include/tether/bluetooth/journal.hpp+++ b/src/core/include/tether/bluetooth/journal.hpp@@ -1,6 +1,7 @@#pragma once#include "tether/bluetooth/messages.hpp"+#include "tether/secret_store.hpp"#include <cstdint>#include <fstream>@@ -12,12 +13,26 @@ namespace tether::bluetooth {inline constexpr size_t JOURNAL_MAX_MESSAGES = 10000;inline constexpr int64_t JOURNAL_MAX_AGE_SECONDS = 90LL * 24 * 3600;+ // Encrypted retention keeps messages.ndjson.enc; plaintext keeps the+ // readable messages.ndjson an older tetherd would also write. Nothing ever+ // writes a sealed record to the plaintext name, which is what makes running+ // an older daemon against this store harmless.+ std::string journal_path(Retention mode);std::string journal_path();- // Append-only newline-delimited JSON at ~/.local/share/tether/messages.ndjson.+ // Rewrites the journal from one mode's file into the other's and removes the+ // source. No-op unless the source exists and the destination does not, so it+ // is safe to call on every open. False on any refusal, including a source+ // that could not be read.+ bool migrate_journal(Retention from, Retention to);++ // Append-only newline-delimited JSON, one record per line, mode 0600. Each+ // record is sealed under the active retention mode.class MessageJournal {public:- // Creates the directory and opens the file for appending, mode 0600+ // Creates the directory and opens the file for appending, mode 0600.+ // False when retention is off, or when it is encrypted and the wallet+ // has no key to offer yet: the caller then runs live-only and retries.bool open();bool is_open() const { return out_.is_open(); }void close();@@ -27,7 +42,9 @@ namespace tether::bluetooth {// Malformed lines are skipped rather than aborting the loadstd::vector<Message> load(int64_t now) const;- // Rewrites the file to exactly `messages`, atomically.+ // Rewrites the file to exactly `messages`, atomically. Refuses to empty+ // a populated journal, so a read that silently produced nothing cannot+ // destroy the history it failed to parse.bool compact(const std::vector<Message>& messages);private:diff --git a/src/core/include/tether/net.hpp b/src/core/include/tether/net.hppindex e360a1a..7ff49ee 100644--- a/src/core/include/tether/net.hpp+++ b/src/core/include/tether/net.hpp@@ -40,6 +40,10 @@ namespace tether {nlohmann::json build_bt_status();nlohmann::json build_bt_devices();+ // How many contacts a bt_list_contacts answers with when the caller does not say.+ inline constexpr size_t BT_CONTACTS_DEFAULT_LIMIT = 100;+ nlohmann::json build_bt_contacts(const std::string& query, size_t limit = BT_CONTACTS_DEFAULT_LIMIT);+// Whether mDNS is usable (avahi-daemon is running). False until the// Avahi client reports otherwise. Setting it pushes an "mdns_status" event// to local subscribers.diff --git a/src/core/include/tether/secret_store.hpp b/src/core/include/tether/secret_store.hppnew file mode 100644index 0000000..da17416--- /dev/null+++ b/src/core/include/tether/secret_store.hpp@@ -0,0 +1,46 @@+#pragma once++#include <string>++namespace tether {++ // How the Bluetooth message journal and contact cache are kept on disk.+ enum class Retention {+ Encrypted, // AES-256-GCM, key in the desktop secret service+ Plaintext, // readable JSON+ None, // nothing retained+ };++ const char* to_string(Retention retention);+ Retention retention_from_string(const std::string& value);++ namespace secret {++ // Set once at startup from the Bluetooth config, and again whenever the+ // user changes the mode. Defaults to Encrypted.+ void set_retention(Retention retention);+ Retention retention();++ // False when the wallet is locked or unreachable. Cached.+ bool have_key();++ inline constexpr int KEY_RETRY_SECONDS = 60;++ // base64(nonce || ciphertext || tag) for Encrypted, `plain` unchanged+ // under Plaintext. Empty when there is no key to seal with (do not write).+ std::string seal(const std::string& plain);++ // Inverse of seal, including the Plaintext pass-through. False when the+ // record is truncated, tampered with, or sealed under another key.+ bool unseal(const std::string& record, std::string& out);++ // Same, against a named mode rather than the active one.+ std::string seal(const std::string& plain, Retention mode);+ bool unseal(const std::string& record, std::string& out, Retention mode);++ // Forget the cached key and retention. Tests only.+ void reset_for_test();++ } // namespace secret++} // namespace tetherdiff --git a/src/core/src/bluetooth/config.cpp b/src/core/src/bluetooth/config.cppindex e1c11a7..5c7059c 100644--- a/src/core/src/bluetooth/config.cpp+++ b/src/core/src/bluetooth/config.cpp@@ -51,6 +51,7 @@ namespace tether::bluetooth {j["group_messages_enabled"] = config.group_messages_enabled;j["enabled"] = config.enabled;j["adapter"] = config.adapter;+ j["retention"] = to_string(config.retention);return j.dump(2);}@@ -68,6 +69,7 @@ namespace tether::bluetooth {config.group_messages_enabled = j.value("group_messages_enabled", false);config.enabled = j.value("enabled", true);config.adapter = j.value("adapter", "");+ config.retention = retention_from_string(j.value("retention", "encrypted"));} catch (const std::exception&) {// A corrupt file must not stop the daemon; defaults are safe.}diff --git a/src/core/src/bluetooth/connection.cpp b/src/core/src/bluetooth/connection.cppindex 8a18be9..d2b0817 100644--- a/src/core/src/bluetooth/connection.cpp+++ b/src/core/src/bluetooth/connection.cpp@@ -9,6 +9,7 @@#include "tether/bluetooth/pairing.hpp"#include "tether/bluetooth/pbap_session.hpp"#include "tether/log.hpp"+#include "tether/secret_store.hpp"#include <tether/i18n.hpp>#include <algorithm>@@ -161,6 +162,13 @@ namespace tether::bluetooth {info, thread_key, contact_store(), rosters, g_group_replies_enabled, recipients, reason);}+ void discard_retained_messages() {+ std::lock_guard<std::mutex> lock(g_messages_mutex);+ g_journal.close();+ g_messages = MessageStore();+ contact_store() = ContactStore();+ }+void set_group_replies_enabled(bool enabled) {std::lock_guard<std::mutex> lock(g_group_mutex);g_group_replies_enabled = enabled;@@ -696,12 +704,22 @@ namespace tether::bluetooth {}// Pulls the inbox and folds it into the store, announcing anything new.- //- // ponytail: polling only. MAP's notification service would push new mail- // instead, but obexd surfaces it as ObjectManager signals on the session bus,- // which is a second watcher to build and maintain. Dedupe by handle makes- // polling correct either way; add MNS if the poll latency proves annoying.void ConnectionState::sync_messages(int64_t now) {+ // The journal stays shut when the wallet was locked at startup+ {+ std::lock_guard<std::mutex> lock(g_messages_mutex);+ if (!g_journal.is_open() && secret::retention() != Retention::None && secret::have_key()) {+ if (g_journal.open()) {+ contact_store() = load_contacts();+ auto history = g_journal.load(now);+ for (const auto& message : history)+ g_messages.add(message);+ g_journal.compact(history);+ debug::log(INFO, "bluetooth: wallet unlocked; replayed {} message(s)", history.size());+ }+ }+ }+if (!profiles->status().map_open) {if (!open_map_path.empty()) {std::lock_guard<std::mutex> lock(g_map_mutex);diff --git a/src/core/src/bluetooth/contacts.cpp b/src/core/src/bluetooth/contacts.cppindex 0d0204a..908125f 100644--- a/src/core/src/bluetooth/contacts.cpp+++ b/src/core/src/bluetooth/contacts.cpp@@ -1,12 +1,15 @@#include "tether/bluetooth/contacts.hpp"#include "tether/bluetooth/bmessage.hpp"#include "tether/log.hpp"+#include "tether/secret_store.hpp"#include <algorithm>#include <cctype>#include <cstdlib>+#include <fcntl.h>#include <filesystem>#include <fstream>+#include <glib.h>#include <pwd.h>#include <unistd.h>@@ -99,13 +102,47 @@ namespace tether::bluetooth {return out;}- std::string contacts_path() {+ static std::string fold(const std::string& text) {+ gchar* normalized = g_utf8_normalize(text.c_str(), -1, G_NORMALIZE_ALL);+ gchar* folded = g_utf8_casefold(normalized ? normalized : text.c_str(), -1);+ std::string out = folded ? folded : "";+ g_free(normalized);+ g_free(folded);+ return out;+ }++ std::vector<VCard> ContactStore::search(const std::string& needle, size_t limit) const {+ const std::string wanted = fold(needle);+ std::vector<VCard> out;+ for (const auto& card : contacts_) {+ if (out.size() >= limit)+ break;+ if (wanted.empty()) {+ out.push_back(card);+ continue;+ }+ std::string haystack = fold(card.name);+ for (const auto& tel : card.tels)+ haystack += " " + fold(tel) + " " + normalize_phone(tel);+ for (const auto& email : card.emails)+ haystack += " " + fold(email);+ if (haystack.find(wanted) != std::string::npos)+ out.push_back(card);+ }+ std::sort(out.begin(), out.end(), [](const VCard& a, const VCard& b) { return fold(a.name) < fold(b.name); });+ return out;+ }++ std::string contacts_path(Retention mode) {std::string home = home_dir();- if (home.empty())+ if (home.empty() || mode == Retention::None)return {};- return (std::filesystem::path(home) / ".local" / "share" / "tether" / "contacts.json").string();+ const std::filesystem::path dir = std::filesystem::path(home) / ".local" / "share" / "tether";+ return (dir / (mode == Retention::Encrypted ? "contacts.json.enc" : "contacts.json")).string();}+ std::string contacts_path() { return contacts_path(secret::retention()); }+std::string serialize_contacts(const ContactStore& store) {nlohmann::json j;j["contacts"] = nlohmann::json::array();@@ -116,14 +153,18 @@ namespace tether::bluetooth {c["emails"] = card.emails;j["contacts"].push_back(std::move(c));}- return j.dump(2);++ return secret::seal(j.dump(2));}ContactStore deserialize_contacts(const std::string& text) {ContactStore store;std::vector<VCard> cards;+ std::string plain;+ if (!secret::unseal(text, plain))+ return store;try {- auto j = nlohmann::json::parse(text);+ auto j = nlohmann::json::parse(plain);for (const auto& c : j.value("contacts", nlohmann::json::array())) {VCard card;card.name = c.value("name", "");@@ -142,7 +183,14 @@ namespace tether::bluetooth {}ContactStore load_contacts() {- std::string path = contacts_path();+ const Retention mode = secret::retention();+ if (mode == Retention::None || !secret::have_key())+ return {};++ // No-op unless a cache written under the other mode is still there.+ migrate_contacts(mode == Retention::Encrypted ? Retention::Plaintext : Retention::Encrypted, mode);++ std::string path = contacts_path(mode);if (path.empty())return {};std::ifstream in(path);@@ -153,7 +201,16 @@ namespace tether::bluetooth {}bool save_contacts(const ContactStore& store) {- std::string path = contacts_path();+ const Retention mode = secret::retention();+ if (mode == Retention::None)+ return false;++ const std::string body = serialize_contacts(store);++ if (body.empty())+ return false;++ std::string path = contacts_path(mode);if (path.empty())return false;@@ -168,7 +225,7 @@ namespace tether::bluetooth {debug::log(ERR, "bluetooth: cannot write {}", tmp);return false;}- out << serialize_contacts(store);+ out << body;if (!out) {debug::log(ERR, "bluetooth: failed writing {}", tmp);return false;@@ -189,6 +246,61 @@ namespace tether::bluetooth {return true;}+ bool migrate_contacts(Retention from, Retention to) {+ const std::string source = contacts_path(from);+ const std::string destination = contacts_path(to);+ if (source.empty() || destination.empty() || source == destination)+ return false;+ if (!std::filesystem::exists(source) || std::filesystem::exists(destination))+ return false;++ std::ifstream in(source);+ if (!in.is_open())+ return false;+ std::string text((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());+ in.close();++ std::string plain;+ if (!secret::unseal(text, plain, from)) {+ debug::log(WARN, "bluetooth: cannot read {} to migrate it; leaving it in place", source);+ return false;+ }+ const std::string sealed = secret::seal(plain, to);+ if (sealed.empty())+ return false;++ std::error_code ec;+ std::filesystem::create_directories(std::filesystem::path(destination).parent_path(), ec);++ const std::string tmp = destination + ".tmp";+ {+ std::ofstream out(tmp, std::ios::trunc);+ if (!out.is_open())+ return false;+ out << sealed;+ if (!out)+ return false;+ }+ std::filesystem::permissions(tmp,+ std::filesystem::perms::owner_read | std::filesystem::perms::owner_write,+ std::filesystem::perm_options::replace,+ ec);++ if (const int fd = ::open(tmp.c_str(), O_RDONLY); fd >= 0) {+ ::fsync(fd);+ ::close(fd);+ }+ std::filesystem::rename(tmp, destination, ec);+ if (ec) {+ debug::log(ERR, "bluetooth: cannot replace {}: {}", destination, ec.message());+ std::filesystem::remove(tmp, ec);+ return false;+ }+ std::filesystem::remove(source, ec);+ debug::log(INFO, "bluetooth: migrated the contact cache to {} retention", to_string(to));+ return true;+ }+ContactStore& contact_store() {static ContactStore store;return store;diff --git a/src/core/src/bluetooth/diagnostics.cpp b/src/core/src/bluetooth/diagnostics.cppindex afa0fca..916df77 100644--- a/src/core/src/bluetooth/diagnostics.cpp+++ b/src/core/src/bluetooth/diagnostics.cpp@@ -1,4 +1,5 @@#include "tether/bluetooth/diagnostics.hpp"+#include <tether/secret_store.hpp>#include "tether/bluetooth/config.hpp"#include "tether/bluetooth/monitor.hpp"@@ -235,6 +236,8 @@ namespace tether::bluetooth {report["group_messages_enabled"] = config.group_messages_enabled;report["enabled"] = config.enabled;report["ancs_soliciting"] = ancs_solicitation_active();+ report["retention"] = to_string(config.retention);+ report["retention_ready"] = secret::have_key();report["status"] = redactor.value(status);report["connection"] = redactor.value(connection);report["timeline"] = redactor.value(diagnostic_timeline());diff --git a/src/core/src/bluetooth/journal.cpp b/src/core/src/bluetooth/journal.cppindex fbf0232..c9ebc9f 100644--- a/src/core/src/bluetooth/journal.cpp+++ b/src/core/src/bluetooth/journal.cpp@@ -1,8 +1,10 @@#include "tether/bluetooth/journal.hpp"#include "tether/log.hpp"+#include "tether/secret_store.hpp"#include <algorithm>#include <cstdlib>+#include <fcntl.h>#include <filesystem>#include <map>#include <nlohmann/json.hpp>@@ -29,22 +31,41 @@ namespace tether::bluetooth {ec);}+ // Flushes a file to disk before anything is renamed over or unlinked.+ void sync_path(const std::string& path) {+ const int fd = ::open(path.c_str(), O_RDONLY);+ if (fd < 0)+ return;+ ::fsync(fd);+ ::close(fd);+ }++ Retention other_mode(Retention mode) {+ return mode == Retention::Encrypted ? Retention::Plaintext : Retention::Encrypted;+ }+} // namespace- std::string journal_path() {+ std::string journal_path(Retention mode) {std::string home = home_dir();- if (home.empty())+ if (home.empty() || mode == Retention::None)return {};- return (std::filesystem::path(home) / ".local" / "share" / "tether" / "messages.ndjson").string();+ const std::filesystem::path dir = std::filesystem::path(home) / ".local" / "share" / "tether";+ return (dir / (mode == Retention::Encrypted ? "messages.ndjson.enc" : "messages.ndjson")).string();}+ std::string journal_path() { return journal_path(secret::retention()); }+std::string serialize_message_line(const Message& message) {- return to_json(message).dump(-1, ' ', false, nlohmann::json::error_handler_t::replace);+ return secret::seal(to_json(message).dump(-1, ' ', false, nlohmann::json::error_handler_t::replace));}bool deserialize_message_line(const std::string& line, Message& out) {+ std::string text;+ if (!secret::unseal(line, text))+ return false;try {- auto j = nlohmann::json::parse(line);+ auto j = nlohmann::json::parse(text);if (!j.is_object())return false;Message message;@@ -97,14 +118,92 @@ namespace tether::bluetooth {return messages;}+ bool migrate_journal(Retention from, Retention to) {+ const std::string source = journal_path(from);+ const std::string destination = journal_path(to);+ if (source.empty() || destination.empty() || source == destination)+ return false;+ if (!std::filesystem::exists(source) || std::filesystem::exists(destination))+ return false;++ std::ifstream in(source);+ if (!in.is_open())+ return false;++ std::vector<std::string> records;+ std::string line;+ size_t unreadable = 0;+ while (std::getline(in, line)) {+ if (line.empty())+ continue;+ std::string text;+ if (secret::unseal(line, text, from))+ records.push_back(std::move(text));+ else+ ++unreadable;+ }+ in.close();++ if (records.empty() && unreadable) {+ debug::log(WARN, "bluetooth: cannot read {} to migrate it; leaving it in place", source);+ return false;+ }++ std::error_code ec;+ std::filesystem::create_directories(std::filesystem::path(destination).parent_path(), ec);++ const std::string tmp = destination + ".tmp";+ {+ std::ofstream out(tmp, std::ios::trunc);+ if (!out.is_open()) {+ debug::log(ERR, "bluetooth: cannot write {}", tmp);+ return false;+ }+ for (const auto& record : records) {+ const std::string sealed = secret::seal(record, to);+ if (sealed.empty())+ return false;+ out << sealed << "\n";+ }+ if (!out) {+ debug::log(ERR, "bluetooth: failed writing {}", tmp);+ return false;+ }+ }+ restrict_permissions(tmp);++ // The source is deleted immediately after, so the replacement has to be on disk first.+ sync_path(tmp);+ std::filesystem::rename(tmp, destination, ec);+ if (ec) {+ debug::log(ERR, "bluetooth: cannot replace {}: {}", destination, ec.message());+ std::filesystem::remove(tmp, ec);+ return false;+ }+ sync_path(std::filesystem::path(destination).parent_path().string());++ std::filesystem::remove(source, ec);+ debug::log(INFO, "bluetooth: migrated {} message(s) to {} retention", records.size(), to_string(to));+ return true;+ }+bool MessageJournal::open() {- path_ = journal_path();+ const Retention mode = secret::retention();+ if (mode == Retention::None)+ return false;+ // Encrypted set but a locked or unreachable wallet: stay live-only+ if (!secret::have_key())+ return false;++ path_ = journal_path(mode);if (path_.empty())return false;std::error_code ec;std::filesystem::create_directories(std::filesystem::path(path_).parent_path(), ec);+ migrate_journal(other_mode(mode), mode);+out_.open(path_, std::ios::app);if (!out_.is_open()) {debug::log(ERR, "bluetooth: cannot open journal {}", path_);@@ -122,7 +221,12 @@ namespace tether::bluetooth {void MessageJournal::append(const Message& message) {if (!out_.is_open())return;- out_ << serialize_message_line(message) << "\n";++ const std::string line = serialize_message_line(message);+ if (line.empty())+ return;++ out_ << line << "\n";out_.flush();}@@ -159,6 +263,12 @@ namespace tether::bluetooth {return false;std::error_code ec;++ if (messages.empty() && std::filesystem::file_size(path, ec) > 0 && !ec) {+ debug::log(WARN, "bluetooth: refusing to empty a populated journal");+ return false;+ }+std::filesystem::create_directories(std::filesystem::path(path).parent_path(), ec);const std::string tmp = path + ".tmp";@@ -168,8 +278,14 @@ namespace tether::bluetooth {debug::log(ERR, "bluetooth: cannot write {}", tmp);return false;}- for (const auto& message : messages)- out << serialize_message_line(message) << "\n";+ for (const auto& message : messages) {+ const std::string line = serialize_message_line(message);+ if (line.empty()) {+ debug::log(ERR, "bluetooth: cannot seal the journal; leaving {} as it was", path);+ return false;+ }+ out << line << "\n";+ }if (!out) {debug::log(ERR, "bluetooth: failed writing {}", tmp);return false;diff --git a/src/core/src/net.cpp b/src/core/src/net.cppindex ee68fc7..01cc42c 100644--- a/src/core/src/net.cpp+++ b/src/core/src/net.cpp@@ -41,7 +41,10 @@#include <optional>#include <set>#include <sstream>+#include <tether/bluetooth/journal.hpp>#include <tether/log.hpp>+#include <tether/secret_store.hpp>+#include <tether/version.hpp>#include <thread>#include <vector>@@ -301,6 +304,9 @@ namespace tether {status["adapter"] = config.adapter;status["ancs_content_enabled"] = config.ancs_content_enabled;status["enabled"] = config.enabled;+ status["retention"] = to_string(config.retention);+ status["retention_ready"] = secret::have_key();+ status["version"] = TETHER_VERSION;if (!bluetooth::g_bluez) {status["capability"] = nullptr;status["adapters"] = nlohmann::json::array();@@ -612,6 +618,35 @@ namespace tether {return result;}+ nlohmann::json build_bt_contacts(const std::string& query, size_t limit) {+ nlohmann::json result;+ result["command"] = "bt_contacts";+ result["query"] = query;+ nlohmann::json contacts = nlohmann::json::array();+ {+ std::lock_guard<std::mutex> lock(bluetooth::message_store_mutex());+ for (const auto& card : bluetooth::contact_store().search(query, limit)) {+ nlohmann::json entry;+ entry["name"] = card.name;+ // Namespaced the same way threads are, so an address here can be+ // handed straight back as the thread of a bt_send_message.+ nlohmann::json addresses = nlohmann::json::array();+ for (const auto& tel : card.tels)+ if (std::string normalized = bluetooth::normalize_phone(tel); !normalized.empty())+ addresses.push_back("tel:" + normalized);+ for (const auto& email : card.emails)+ if (std::string normalized = bluetooth::normalize_email(email); !normalized.empty())+ addresses.push_back("email:" + normalized);+ if (addresses.empty())+ continue;+ entry["addresses"] = std::move(addresses);+ contacts.push_back(std::move(entry));+ }+ }+ result["contacts"] = contacts;+ return result;+ }+nlohmann::json build_bt_devices() {nlohmann::json result;result["command"] = "bt_devices";@@ -940,6 +975,13 @@ namespace tether {std::string payload = build_bt_threads().dump() + "\n";write_plain_packet(client_fd, payload);continue;+ } else if (j.contains("command") && j["command"] == "bt_list_contacts") {+ std::string payload =+ build_bt_contacts(j.value("query", ""), j.value("limit", BT_CONTACTS_DEFAULT_LIMIT))+ .dump(-1, ' ', false, nlohmann::json::error_handler_t::replace) ++ "\n";+ write_plain_packet(client_fd, payload);+ continue;} else if (j.contains("command") && j["command"] == "bt_list_messages" && j.contains("thread")) {std::string payload = build_bt_messages(j["thread"]).dump() + "\n";write_plain_packet(client_fd, payload);@@ -1070,6 +1112,27 @@ namespace tether {bluetooth::set_group_replies_enabled(config.group_messages_enabled &&config.ancs_content_enabled && config.ancs_enabled);broadcast_local_event(build_bt_status().dump());+ } else if (j.contains("command") && j["command"] == "bt_set_retention" && j.contains("retention")) {+ auto config = bluetooth::load_config();+ const Retention previous = config.retention;+ config.retention = retention_from_string(j.value("retention", "encrypted"));+ if (config.retention != previous) {+ bluetooth::save_config(config);+ secret::set_retention(config.retention);+ // Move what is already stored+ if (config.retention == Retention::None) {+ bluetooth::discard_retained_messages();+ std::error_code ec;+ for (auto mode : {Retention::Encrypted, Retention::Plaintext}) {+ std::filesystem::remove(bluetooth::journal_path(mode), ec);+ std::filesystem::remove(bluetooth::contacts_path(mode), ec);+ }+ } else {+ bluetooth::migrate_journal(previous, config.retention);+ bluetooth::migrate_contacts(previous, config.retention);+ }+ }+ broadcast_local_event(build_bt_status().dump());} else if (j.contains("command") && j["command"] == "bt_list_notifications") {nlohmann::json payload;payload["command"] = "bt_notifications";diff --git a/src/core/src/secret_store.cpp b/src/core/src/secret_store.cppnew file mode 100644index 0000000..86ba33a--- /dev/null+++ b/src/core/src/secret_store.cpp@@ -0,0 +1,395 @@+#include "tether/secret_store.hpp"+#include "tether/base64.hpp"+#include "tether/log.hpp"++#include <chrono>+#include <cstdlib>+#include <filesystem>+#include <fstream>+#include <libsecret/secret.h>+#include <mutex>+#include <openssl/evp.h>+#include <openssl/rand.h>+#include <pwd.h>+#include <unistd.h>++namespace tether {++ const char* to_string(Retention retention) {+ switch (retention) {+ case Retention::Plaintext:+ return "plaintext";+ case Retention::None:+ return "none";+ case Retention::Encrypted:+ break;+ }+ return "encrypted";+ }++ Retention retention_from_string(const std::string& value) {+ if (value == "plaintext")+ return Retention::Plaintext;+ if (value == "none")+ return Retention::None;+ return Retention::Encrypted;+ }++ namespace secret {++ namespace {++ constexpr size_t KEY_BYTES = 32;+ constexpr size_t NONCE_BYTES = 12;+ constexpr size_t TAG_BYTES = 16;++ const SecretSchema* store_schema() {+ static const SecretSchema schema = {+ "com.tether.Store",+ SECRET_SCHEMA_NONE,+ {+ {"application", SECRET_SCHEMA_ATTRIBUTE_STRING},+ {nullptr, SECRET_SCHEMA_ATTRIBUTE_STRING},+ },+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ };+ return &schema;+ }++ std::string home_dir() {+ if (const char* home = getenv("HOME"); home && *home)+ return home;+ if (const passwd* pw = getpwuid(getuid()); pw && pw->pw_dir)+ return pw->pw_dir;+ return {};+ }++ std::string keyfile_path() {+ std::string home = home_dir();+ if (home.empty())+ return {};+ return (std::filesystem::path(home) / ".config" / "tether" / "store.key").string();+ }++ int64_t now_seconds() {+ return std::chrono::duration_cast<std::chrono::seconds>(+ std::chrono::steady_clock::now().time_since_epoch())+ .count();+ }++ std::mutex g_mutex;+ Retention g_retention = Retention::Encrypted;+ std::vector<unsigned char> g_key;+ int64_t g_last_failure = 0;+ bool g_failed_once = false;++ // Reads the key out of the desktop secret service without unlocking it.+ bool key_from_service(std::vector<unsigned char>& out, bool& service_present) {+ service_present = false;++ GError* err = nullptr;+ SecretService* service = secret_service_get_sync(SECRET_SERVICE_OPEN_SESSION, nullptr, &err);+ if (!service) {+ if (err) {+ debug::log(DEBUG, "secret: no secret service on the bus: {}", err->message);+ g_error_free(err);+ }+ return false;+ }+ service_present = true;++ GHashTable* attributes = g_hash_table_new(g_str_hash, g_str_equal);+ g_hash_table_insert(attributes, const_cast<char*>("application"), const_cast<char*>("tether"));+ GList* items = secret_service_search_sync(+ service, store_schema(), attributes, SECRET_SEARCH_LOAD_SECRETS, nullptr, &err);+ g_hash_table_unref(attributes);+ g_object_unref(service);++ if (err) {+ debug::log(WARN, "secret: search failed: {}", err->message);+ g_error_free(err);+ return false;+ }++ bool found = false;+ for (GList* node = items; node && !found; node = node->next) {+ auto* item = static_cast<SecretItem*>(node->data);+ // null on a locked collection+ SecretValue* value = secret_item_get_secret(item);+ if (!value)+ continue;+ gsize length = 0;+ const gchar* text = secret_value_get(value, &length);+ if (text) {+ auto decoded = base64_decode(std::string(text, length));+ if (decoded.size() == KEY_BYTES) {+ out = std::move(decoded);+ found = true;+ }+ }+ secret_value_unref(value);+ }+ g_list_free_full(items, g_object_unref);+ return found;+ }++ bool key_to_service(const std::vector<unsigned char>& key) {+ GError* err = nullptr;+ const std::string encoded = base64_encode(key);+ const gboolean ok = secret_password_store_sync(store_schema(),+ SECRET_COLLECTION_DEFAULT,+ "Tether message store key",+ encoded.c_str(),+ nullptr,+ &err,+ "application",+ "tether",+ nullptr);+ if (err) {+ debug::log(WARN, "secret: cannot store the key in the wallet: {}", err->message);+ g_error_free(err);+ }+ return ok == TRUE;+ }++ bool key_from_file(std::vector<unsigned char>& out) {+ const std::string path = keyfile_path();+ if (path.empty())+ return false;+ std::ifstream in(path, std::ios::binary);+ if (!in.is_open())+ return false;+ std::string text((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());+ while (!text.empty() && (text.back() == '\n' || text.back() == '\r'))+ text.pop_back();+ auto decoded = base64_decode(text);+ if (decoded.size() != KEY_BYTES)+ return false;+ out = std::move(decoded);+ return true;+ }++ bool key_to_file(const std::vector<unsigned char>& key) {+ const std::string path = keyfile_path();+ if (path.empty())+ return false;++ std::error_code ec;+ std::filesystem::create_directories(std::filesystem::path(path).parent_path(), ec);++ const std::string tmp = path + ".tmp";+ {+ std::ofstream out(tmp, std::ios::trunc);+ if (!out.is_open()) {+ debug::log(ERR, "secret: cannot write {}", tmp);+ return false;+ }+ out << base64_encode(key) << "\n";+ if (!out)+ return false;+ }+ std::filesystem::permissions(tmp,+ std::filesystem::perms::owner_read | std::filesystem::perms::owner_write,+ std::filesystem::perm_options::replace,+ ec);+ std::filesystem::rename(tmp, path, ec);+ if (ec) {+ debug::log(ERR, "secret: cannot replace {}: {}", path, ec.message());+ std::filesystem::remove(tmp, ec);+ return false;+ }+ return true;+ }++ // Caller holds g_mutex.+ bool load_key_locked() {+ if (!g_key.empty())+ return true;+ if (g_failed_once && now_seconds() - g_last_failure < KEY_RETRY_SECONDS)+ return false;++ bool service_present = false;+ std::vector<unsigned char> key;+ if (key_from_service(key, service_present)) {+ g_key = std::move(key);+ g_failed_once = false;+ return true;+ }++ if (!service_present && key_from_file(key)) {+ g_key = std::move(key);+ g_failed_once = false;+ return true;+ }++ if (service_present) {+ // wallet is locked, or this is first run+ std::vector<unsigned char> fresh(KEY_BYTES);+ if (RAND_bytes(fresh.data(), static_cast<int>(fresh.size())) != 1)+ return false;+ if (key_to_service(fresh)) {+ g_key = std::move(fresh);+ g_failed_once = false;+ debug::log(INFO, "secret: generated a new store key in the wallet");+ return true;+ }+ debug::log(WARN, "secret: wallet is locked; retained history is paused until it unlocks");+ g_failed_once = true;+ g_last_failure = now_seconds();+ return false;+ }++ std::vector<unsigned char> fresh(KEY_BYTES);+ if (RAND_bytes(fresh.data(), static_cast<int>(fresh.size())) != 1)+ return false;+ if (!key_to_file(fresh)) {+ g_failed_once = true;+ g_last_failure = now_seconds();+ return false;+ }+ g_key = std::move(fresh);+ g_failed_once = false;+ debug::log(INFO, "secret: no secret service; store key kept in a 0600 file");+ return true;+ }++ bool encrypt(const std::string& plain,+ const std::vector<unsigned char>& key,+ std::vector<unsigned char>& out) {+ out.resize(NONCE_BYTES + plain.size() + TAG_BYTES);+ if (RAND_bytes(out.data(), NONCE_BYTES) != 1)+ return false;++ EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();+ if (!ctx)+ return false;++ bool ok = EVP_EncryptInit_ex(ctx, EVP_aes_256_gcm(), nullptr, key.data(), out.data()) == 1;+ int length = 0;+ if (ok)+ ok = EVP_EncryptUpdate(ctx,+ out.data() + NONCE_BYTES,+ &length,+ reinterpret_cast<const unsigned char*>(plain.data()),+ static_cast<int>(plain.size())) == 1;+ int total = length;+ if (ok)+ ok = EVP_EncryptFinal_ex(ctx, out.data() + NONCE_BYTES + total, &length) == 1;+ total += length;+ if (ok)+ ok = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, TAG_BYTES, out.data() + NONCE_BYTES + total) ==+ 1;+ EVP_CIPHER_CTX_free(ctx);++ if (!ok)+ return false;+ out.resize(NONCE_BYTES + static_cast<size_t>(total) + TAG_BYTES);+ return true;+ }++ bool decrypt(const std::vector<unsigned char>& sealed,+ const std::vector<unsigned char>& key,+ std::string& out) {+ if (sealed.size() < NONCE_BYTES + TAG_BYTES)+ return false;+ const size_t body = sealed.size() - NONCE_BYTES - TAG_BYTES;++ EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();+ if (!ctx)+ return false;++ std::string plain(body, '\0');+ bool ok = EVP_DecryptInit_ex(ctx, EVP_aes_256_gcm(), nullptr, key.data(), sealed.data()) == 1;+ int length = 0;+ if (ok && body)+ ok = EVP_DecryptUpdate(ctx,+ reinterpret_cast<unsigned char*>(plain.data()),+ &length,+ sealed.data() + NONCE_BYTES,+ static_cast<int>(body)) == 1;+ int total = length;+ if (ok)+ ok = EVP_CIPHER_CTX_ctrl(ctx,+ EVP_CTRL_GCM_SET_TAG,+ TAG_BYTES,+ const_cast<unsigned char*>(sealed.data() + NONCE_BYTES + body)) == 1;+ // Fails when the tag does not match, which is the whole point.+ if (ok)+ ok = EVP_DecryptFinal_ex(ctx, reinterpret_cast<unsigned char*>(plain.data()) + total, &length) == 1;+ total += length;+ EVP_CIPHER_CTX_free(ctx);++ if (!ok)+ return false;+ plain.resize(static_cast<size_t>(total));+ out = std::move(plain);+ return true;+ }++ } // namespace++ void set_retention(Retention retention) {+ std::lock_guard<std::mutex> lock(g_mutex);+ g_retention = retention;+ }++ Retention retention() {+ std::lock_guard<std::mutex> lock(g_mutex);+ return g_retention;+ }++ bool have_key() {+ std::lock_guard<std::mutex> lock(g_mutex);+ if (g_retention != Retention::Encrypted)+ return true;+ return load_key_locked();+ }++ std::string seal(const std::string& plain, Retention mode) {+ std::lock_guard<std::mutex> lock(g_mutex);+ if (mode == Retention::Plaintext)+ return plain;+ if (mode == Retention::None || !load_key_locked())+ return {};++ std::vector<unsigned char> sealed;+ if (!encrypt(plain, g_key, sealed)) {+ debug::log(ERR, "secret: failed to seal a record");+ return {};+ }+ return base64_encode(sealed);+ }++ bool unseal(const std::string& record, std::string& out, Retention mode) {+ std::lock_guard<std::mutex> lock(g_mutex);+ if (mode == Retention::Plaintext) {+ out = record;+ return true;+ }+ if (mode == Retention::None || !load_key_locked())+ return false;+ return decrypt(base64_decode(record), g_key, out);+ }++ std::string seal(const std::string& plain) { return seal(plain, retention()); }++ bool unseal(const std::string& record, std::string& out) { return unseal(record, out, retention()); }++ void reset_for_test() {+ std::lock_guard<std::mutex> lock(g_mutex);+ g_retention = Retention::Encrypted;+ g_key.clear();+ g_failed_once = false;+ g_last_failure = 0;+ }++ } // namespace secret++} // namespace tetherdiff --git a/src/daemon/main.cpp b/src/daemon/main.cppindex 2834d19..bba45c8 100644--- a/src/daemon/main.cpp+++ b/src/daemon/main.cpp@@ -18,6 +18,7 @@#include <tether/log.hpp>#include <tether/net.hpp>#include <tether/otp.hpp>+#include <tether/secret_store.hpp>#include <tether/wayland.hpp>#include <unistd.h>@@ -238,6 +239,10 @@ int main(int argc, char** argv) {auto bt_config = tether::bluetooth::load_config();tether::bluetooth::g_bt_connections = &connections;+ // Before anything opens the journal or the contact cache: the mode picks+ // which file each of those lives in.+ tether::secret::set_retention(bt_config.retention);+tether::bluetooth::set_group_replies_enabled(bt_config.group_messages_enabled &&bt_config.ancs_content_enabled && bt_config.ancs_enabled);tether::bluetooth::reload_group_rosters();diff --git a/src/gtk/devices_view.cpp b/src/gtk/devices_view.cppindex bb158b8..94833b1 100644--- a/src/gtk/devices_view.cpp+++ b/src/gtk/devices_view.cpp@@ -72,6 +72,7 @@ namespace tether::ui {GtkWidget* chk_bt_enabled = nullptr;GtkWidget* chk_bt_ancs = nullptr;GtkWidget* chk_bt_content = nullptr;+ GtkWidget* cmb_bt_retention = nullptr;GtkWidget* btn_bt_unpair = nullptr;GtkWidget* lbl_welcome_wifi = nullptr;@@ -162,6 +163,7 @@ namespace tether::ui {void on_bt_enabled_toggled(GtkWidget* widget, gpointer);void on_bt_ancs_toggled(GtkWidget* widget, gpointer);void on_bt_content_toggled(GtkWidget* widget, gpointer);+ void on_bt_retention_changed(GtkWidget* widget, gpointer);void update_action_bt_scan_controls() {if (g_devices.btn_action_bt_pair)@@ -309,6 +311,14 @@ namespace tether::ui {g_devices.bt_status.value("ancs_content_enabled", true));g_signal_handlers_unblock_by_func(g_devices.chk_bt_content, reinterpret_cast<gpointer>(on_bt_content_toggled), nullptr);++ gtk_widget_set_visible(gtk_widget_get_parent(g_devices.cmb_bt_retention), available && supervised);+ g_signal_handlers_block_by_func(+ g_devices.cmb_bt_retention, reinterpret_cast<gpointer>(on_bt_retention_changed), nullptr);+ gtk_combo_box_set_active_id(GTK_COMBO_BOX(g_devices.cmb_bt_retention),+ g_devices.bt_status.value("retention", "encrypted").c_str());+ g_signal_handlers_unblock_by_func(+ g_devices.cmb_bt_retention, reinterpret_cast<gpointer>(on_bt_retention_changed), nullptr);}void update_right_pane() {@@ -461,6 +471,12 @@ namespace tether::ui {{"enabled", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) == TRUE}});}+ void on_bt_retention_changed(GtkWidget* widget, gpointer) {+ const gchar* id = gtk_combo_box_get_active_id(GTK_COMBO_BOX(widget));+ if (id)+ daemon_send({{"command", "bt_set_retention"}, {"retention", id}});+ }+void on_bt_setup_copy_click(GtkWidget*, gpointer) {gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), g_devices.bt_setup_commands.c_str(), -1);set_status_main(_("Setup commands copied to the clipboard."));@@ -1329,6 +1345,20 @@ namespace tether::ui {g_signal_connect(g_devices.chk_bt_content, "toggled", G_CALLBACK(on_bt_content_toggled), nullptr);gtk_box_pack_start(GTK_BOX(bt_box), g_devices.chk_bt_content, FALSE, FALSE, 0);+ GtkWidget* retention_row = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);+ gtk_box_pack_start(GTK_BOX(retention_row), gtk_label_new(_("Keep message history:")), FALSE, FALSE, 0);+ g_devices.cmb_bt_retention = gtk_combo_box_text_new();+ gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(g_devices.cmb_bt_retention), "encrypted", _("Encrypted"));+ gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(g_devices.cmb_bt_retention), "plaintext", _("Unencrypted"));+ gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(g_devices.cmb_bt_retention), "none", _("Do not keep"));+ gtk_widget_set_tooltip_text(g_devices.cmb_bt_retention,+ _("Where messages and contacts are stored on this computer. Encrypted keeps "+ "them with a key in your desktop keyring. Do not keep deletes what is "+ "already stored and retains nothing further."));+ g_signal_connect(g_devices.cmb_bt_retention, "changed", G_CALLBACK(on_bt_retention_changed), nullptr);+ gtk_box_pack_start(GTK_BOX(retention_row), g_devices.cmb_bt_retention, FALSE, FALSE, 0);+ gtk_box_pack_start(GTK_BOX(bt_box), retention_row, FALSE, FALSE, 0);+g_devices.lbl_bt_reason = gtk_label_new(nullptr);gtk_label_set_xalign(GTK_LABEL(g_devices.lbl_bt_reason), 0.0);gtk_label_set_line_wrap(GTK_LABEL(g_devices.lbl_bt_reason), TRUE);diff --git a/src/gtk/messages_view.cpp b/src/gtk/messages_view.cppindex 5084a0d..ebe0d89 100644--- a/src/gtk/messages_view.cpp+++ b/src/gtk/messages_view.cpp@@ -111,6 +111,8 @@ namespace tether::ui {enum ComposeColumn { COMPOSE_COL_DISPLAY, COMPOSE_COL_ADDRESS, COMPOSE_COL_SEARCH, COMPOSE_COL_COUNT };+ constexpr int CONTACT_COMPLETION_LIMIT = 5000;+void update_composer_sensitivity();void update_placeholder();void apply_row_selection(GtkWidget* row);@@ -799,38 +801,44 @@ namespace tether::ui {return out;}- // Read from disk rather than held: the daemon rewrites this cache after- // every PBAP sync, and the app outlives several of them.- // ponytail: a bt_list_contacts command would give the live store instead- // of the last saved snapshot; add it if the cache proves too stale.- void rebuild_contact_completion() {+ void request_contact_completion() {+ nlohmann::json j;+ j["command"] = "bt_list_contacts";+ j["limit"] = CONTACT_COMPLETION_LIMIT;+ daemon_send(j);+ }++ void show_contact_completion(const nlohmann::json& event) {gtk_list_store_clear(g_messages.compose_model);g_messages.compose_names.clear();+ if (!event.contains("contacts") || !event["contacts"].is_array())+ return;- const bluetooth::ContactStore contacts = bluetooth::load_contacts();std::set<std::string> seen;- for (const auto& card : contacts.contacts()) {- std::vector<std::string> addresses = card.tels;- addresses.insert(addresses.end(), card.emails.begin(), card.emails.end());- for (const auto& address : addresses) {+ for (const auto& card : event["contacts"]) {+ const std::string name = card.value("name", "");+ if (!card.contains("addresses") || !card["addresses"].is_array())+ continue;+ for (const auto& entry : card["addresses"]) {+ if (!entry.is_string())+ continue;// The same validation a typed address gets, so the popup can// never offer something the send path would then refuse.bluetooth::Recipient recipient;std::string err;- if (!bluetooth::recipient_from_input(address, recipient, err))+ if (!bluetooth::recipient_from_input(entry.get<std::string>(), recipient, err))continue;const std::string key = bluetooth::thread_key_for(recipient);if (key.empty() || !seen.insert(key).second)continue;- if (!card.name.empty())- g_messages.compose_names.emplace(key, card.name);+ if (!name.empty())+ g_messages.compose_names.emplace(key, name);- const std::string display =- card.name.empty() ? recipient.address : card.name + " · " + recipient.address;+ const std::string display = name.empty() ? recipient.address : name + " · " + recipient.address;// The normalized form is in the haystack too, so "5551234567"// finds a contact whose number is stored as "+1 (555) 123-4567".const std::string search =- fold(card.name + " " + recipient.address + " " + key.substr(key.find(':') + 1));+ fold(name + " " + recipient.address + " " + key.substr(key.find(':') + 1));GtkTreeIter iter;gtk_list_store_append(g_messages.compose_model, &iter);@@ -943,7 +951,7 @@ namespace tether::ui {g_messages.composing = true;g_messages.compose_requested_key.clear();- rebuild_contact_completion();+ request_contact_completion();clear_list_box(g_messages.conversation);g_messages.rendered.clear();@@ -1056,6 +1064,10 @@ namespace tether::ui {show_messages(event);return true;}+ if (command == "bt_contacts") {+ show_contact_completion(event);+ return true;+ }if (command == "bt_connection_changed") {update_connection(event);return false;diff --git a/test/CMakeLists.txt b/test/CMakeLists.txtindex e6ebd94..6e50122 100644--- a/test/CMakeLists.txt+++ b/test/CMakeLists.txt@@ -14,6 +14,8 @@ add_executable(tether_testtest_vcard.cpptest_journal.cpptest_crypto.cpp+ test_secret_store.cpp+ secret_test_env.cpptest_discovery.cpptest_event_loop.cpptest_display_width.cppdiff --git a/test/scoped_env.hpp b/test/scoped_env.hppnew file mode 100644index 0000000..6a46d89--- /dev/null+++ b/test/scoped_env.hpp@@ -0,0 +1,39 @@+#pragma once++#include <cstdlib>+#include <filesystem>+#include <string>++namespace tether::testing {++ // Store paths are derived from $HOME, so the only way to point them at a+ // scratch file is to move HOME for the duration of a test.+ class ScopedEnv {+ public:+ ScopedEnv(const char* name, const std::string& value) : name_(name) {+ if (const char* previous = getenv(name)) {+ previous_ = previous;+ had_previous_ = true;+ }+ setenv(name, value.c_str(), 1);+ }++ ScopedEnv(const char* name, const std::filesystem::path& value) : ScopedEnv(name, value.string()) {}++ ~ScopedEnv() {+ if (had_previous_)+ setenv(name_, previous_.c_str(), 1);+ else+ unsetenv(name_);+ }++ ScopedEnv(const ScopedEnv&) = delete;+ ScopedEnv& operator=(const ScopedEnv&) = delete;++ private:+ const char* name_;+ std::string previous_;+ bool had_previous_ = false;+ };++} // namespace tether::testingdiff --git a/test/secret_test_env.cpp b/test/secret_test_env.cppnew file mode 100644index 0000000..31e8aa2--- /dev/null+++ b/test/secret_test_env.cpp@@ -0,0 +1,23 @@+#include <cstdlib>+#include <filesystem>+#include <string>+#include <unistd.h>++namespace {++ // Runs before main, so nothing in this binary can reach the developer's real+ // wallet or home directory. Store paths and the store key both follow $HOME,+ // and a test that forgets to scope it would otherwise write a throwaway key+ // into the user's own keyring or ~/.config/tether. Tests that scope HOME+ // themselves still override this.+ const bool sandboxed = [] {+ setenv("DBUS_SESSION_BUS_ADDRESS", "unix:path=/nonexistent/tether-test", 1);++ const auto home = std::filesystem::temp_directory_path() / ("tether-test-home-" + std::to_string(::getpid()));+ std::error_code ec;+ std::filesystem::create_directories(home, ec);+ setenv("HOME", home.c_str(), 1);+ return true;+ }();++} // namespacediff --git a/test/test_bt_diagnostics.cpp b/test/test_bt_diagnostics.cppindex ee14ce6..50e8352 100644--- a/test/test_bt_diagnostics.cpp+++ b/test/test_bt_diagnostics.cpp@@ -1,6 +1,8 @@#include "tether/bluetooth/diagnostics.hpp"+#include "scoped_env.hpp"#include <cstdlib>+#include <gtest/gtest.h>using namespace tether::bluetooth;@@ -69,8 +71,10 @@ TEST(BtDiagnostics, LeavesTimestampsAndErrorCodesAlone) {}TEST(BtDiagnostics, RedactsHomeAndRuntimeDirectories) {- setenv("HOME", "/home/someone", 1);- setenv("XDG_RUNTIME_DIR", "/run/user/1000", 1);+ // Scoped, not set: HOME also picks the store key and the Bluetooth store+ // paths, so leaking it here breaks whichever test happens to run next.+ tether::testing::ScopedEnv home("HOME", std::string("/home/someone"));+ tether::testing::ScopedEnv runtime("XDG_RUNTIME_DIR", std::string("/run/user/1000"));Redactor r;EXPECT_EQ(r.text("staged /run/user/1000/tether/out.bmsg"), "staged <runtime>/tether/out.bmsg");EXPECT_EQ(r.text("wrote /home/someone/.config/tether/bluetooth.json"),@@ -78,9 +82,13 @@ TEST(BtDiagnostics, RedactsHomeAndRuntimeDirectories) {}TEST(BtDiagnostics, RedactsRuntimeDirectoryWithoutTheEnvironmentVariable) {+ const char* previous = getenv("XDG_RUNTIME_DIR");+ const std::string saved = previous ? previous : "";unsetenv("XDG_RUNTIME_DIR");Redactor r;EXPECT_EQ(r.text("/run/user/4242/tether/tetherd.sock"), "<runtime>/tether/tetherd.sock");+ if (!saved.empty())+ setenv("XDG_RUNTIME_DIR", saved.c_str(), 1);}TEST(BtDiagnostics, DropsContentKeysRatherThanRedactingThem) {diff --git a/test/test_journal.cpp b/test/test_journal.cppindex 8c4586a..56baa6f 100644--- a/test/test_journal.cpp+++ b/test/test_journal.cpp@@ -1,10 +1,15 @@+#include "scoped_env.hpp"+#include <gtest/gtest.h>#include <tether/bluetooth/journal.hpp>+#include <tether/secret_store.hpp>#include <cstdlib>#include <filesystem>+#include <fstream>#include <string>+using namespace tether;using namespace tether::bluetooth;namespace {@@ -25,7 +30,50 @@ namespace {} // namespace+namespace {++ using tether::testing::ScopedEnv;++ // journal_path() is derived from $HOME, so the only way to point the journal+ // at a scratch file is to move HOME for the duration of the test. The store+ // key follows HOME, so scoping it also keeps the key out of the real wallet.+ class ScopedHome {+ public:+ explicit ScopedHome(const std::filesystem::path& dir, Retention mode = Retention::Encrypted)+ : home_("HOME", dir) {+ secret::reset_for_test();+ secret::set_retention(mode);+ }++ ~ScopedHome() { secret::reset_for_test(); }++ private:+ ScopedEnv home_;+ };++ std::vector<std::string> lines_of(const std::filesystem::path& path) {+ std::vector<std::string> out;+ std::ifstream in(path);+ std::string line;+ while (std::getline(in, line))+ if (!line.empty())+ out.push_back(line);+ return out;+ }++ std::filesystem::path scratch(const std::string& name) {+ const auto dir = std::filesystem::temp_directory_path() / ("tether-journal-" + name);+ std::filesystem::remove_all(dir);+ std::filesystem::create_directories(dir);+ return dir;+ }++} // namespace+TEST(Journal, RoundTripsAMessage) {+ const auto home = scratch("round-trip");+ ScopedHome scoped(home);+Message original = make("/msg/1", NOW, "hello \xF0\x9F\x92\xA9");original.read = true;original.outgoing = true;@@ -36,6 +84,9 @@ TEST(Journal, RoundTripsAMessage) {}TEST(Journal, SerializesToASingleLine) {+ const auto home = scratch("single-line");+ ScopedHome scoped(home);+const std::string line = serialize_message_line(make("/msg/1", NOW, "two\nlines"));EXPECT_EQ(line.find('\n'), std::string::npos) << "an embedded newline would split one record into two";}@@ -43,6 +94,9 @@ TEST(Journal, SerializesToASingleLine) {// One bad write must not cost the whole history, so unreadable lines are// skipped rather than aborting the load.TEST(Journal, RejectsMalformedLines) {+ const auto home = scratch("malformed");+ ScopedHome scoped(home);+Message out;EXPECT_FALSE(deserialize_message_line("", out));EXPECT_FALSE(deserialize_message_line("{not json", out));@@ -101,30 +155,6 @@ TEST(Journal, RetentionCollapsesRepeatedHandles) {EXPECT_TRUE(kept[0].read) << "the newest copy carries the current read state";}-namespace {-- // journal_path() is derived from $HOME, so the only way to point the journal- // at a scratch file is to move HOME for the duration of the test.- class ScopedHome {- public:- explicit ScopedHome(const std::filesystem::path& dir) {- if (const char* previous = getenv("HOME"))- previous_ = previous;- setenv("HOME", dir.c_str(), 1);- }- ~ScopedHome() {- if (previous_.empty())- unsetenv("HOME");- else- setenv("HOME", previous_.c_str(), 1);- }-- private:- std::string previous_;- };--} // namespace-// The unread badge has to survive a daemon restart, so a mark-read is only// really applied once it has been written back. The journal is append-only, and// retention keeps the last line for a handle: re-appending is the whole fix.@@ -162,3 +192,155 @@ TEST(Journal, ReadStateSurvivesARestart) {std::filesystem::remove_all(home);}++TEST(Journal, EncryptedRetentionLeavesNothingReadable) {+ const auto home = scratch("encrypted");+ ScopedHome scoped(home);++ MessageJournal journal;+ ASSERT_TRUE(journal.open());+ journal.append(make("/msg/1", NOW, "meet me at the usual place"));++ const auto store = home / ".local" / "share" / "tether";+ EXPECT_FALSE(std::filesystem::exists(store / "messages.ndjson"))+ << "the plaintext name must stay empty, or an older tetherd would compact the store away";++ const auto sealed = store / "messages.ndjson.enc";+ ASSERT_TRUE(std::filesystem::exists(sealed));++ std::ifstream in(sealed);+ const std::string text((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());+ EXPECT_EQ(text.find("usual place"), std::string::npos) << "the message body is on disk in the clear";+ EXPECT_EQ(text.find("+15551234567"), std::string::npos) << "the phone number is on disk in the clear";+ EXPECT_EQ(text.find('{'), std::string::npos);++ std::filesystem::remove_all(home);+}++TEST(Journal, MigratesAPlaintextStoreOnFirstOpen) {+ const auto home = scratch("migrate");+ const auto store = home / ".local" / "share" / "tether";++ // A journal exactly as a pre-0.2.24 daemon left it.+ {+ ScopedHome scoped(home, Retention::Plaintext);+ MessageJournal journal;+ ASSERT_TRUE(journal.open());+ journal.append(make("/msg/1", NOW, "one"));+ journal.append(make("/msg/2", NOW + 1, "two"));+ }+ ASSERT_TRUE(std::filesystem::exists(store / "messages.ndjson"));++ {+ ScopedHome scoped(home);+ MessageJournal journal;+ ASSERT_TRUE(journal.open());++ EXPECT_FALSE(std::filesystem::exists(store / "messages.ndjson")) << "the plaintext copy outlived the migration";+ ASSERT_TRUE(std::filesystem::exists(store / "messages.ndjson.enc"));+ EXPECT_EQ(lines_of(store / "messages.ndjson.enc").size(), 2u);++ auto loaded = journal.load(NOW + 1);+ ASSERT_EQ(loaded.size(), 2u) << "migration lost messages";+ EXPECT_EQ(loaded[0].body, "one");+ EXPECT_EQ(loaded[1].body, "two");+ }++ std::filesystem::remove_all(home);+}++TEST(Journal, MigratesBackToPlaintextOnOptOut) {+ const auto home = scratch("migrate-back");+ const auto store = home / ".local" / "share" / "tether";++ {+ ScopedHome scoped(home);+ MessageJournal journal;+ ASSERT_TRUE(journal.open());+ journal.append(make("/msg/1", NOW, "one"));+ }++ // Flipping to plaintext has to move the data, not strand it behind a name+ // nothing reads any more.+ {+ ScopedHome scoped(home, Retention::Plaintext);+ MessageJournal journal;+ ASSERT_TRUE(journal.open());++ EXPECT_FALSE(std::filesystem::exists(store / "messages.ndjson.enc"));+ auto loaded = journal.load(NOW);+ ASSERT_EQ(loaded.size(), 1u);+ EXPECT_EQ(loaded[0].body, "one");+ }++ std::filesystem::remove_all(home);+}++// The regression that matters most. A locked wallet used to mean an empty read,+// and the compact that follows a read would then write that emptiness back over+// every message the user had.+TEST(Journal, ALockedWalletCannotDestroyHistory) {+ const auto home = scratch("locked");+ const auto sealed = home / ".local" / "share" / "tether" / "messages.ndjson.enc";++ {+ ScopedHome scoped(home);+ MessageJournal journal;+ ASSERT_TRUE(journal.open());+ journal.append(make("/msg/1", NOW, "one"));+ journal.append(make("/msg/2", NOW + 1, "two"));+ }+ const auto before = lines_of(sealed);+ ASSERT_EQ(before.size(), 2u);++ {+ // A different HOME is a different key, which is what a wallet that will+ // not open looks like from here.+ const auto elsewhere = scratch("locked-other");+ ScopedEnv home_env("HOME", elsewhere);+ secret::reset_for_test();++ MessageJournal journal;+ journal.open();+ std::filesystem::remove_all(elsewhere);+ }++ {+ ScopedHome scoped(home);+ MessageJournal journal;+ ASSERT_TRUE(journal.open());+ auto loaded = journal.load(NOW + 1);+ EXPECT_EQ(loaded.size(), 2u) << "history did not survive a pass with the wrong key";+ }+ EXPECT_EQ(lines_of(sealed), before) << "the journal was rewritten by a daemon that could not read it";++ std::filesystem::remove_all(home);+}++TEST(Journal, CompactRefusesToEmptyAPopulatedJournal) {+ const auto home = scratch("compact-guard");+ ScopedHome scoped(home);++ MessageJournal journal;+ ASSERT_TRUE(journal.open());+ journal.append(make("/msg/1", NOW, "one"));++ EXPECT_FALSE(journal.compact({})) << "compacting to nothing must be refused, not obeyed";+ EXPECT_EQ(journal.load(NOW).size(), 1u);++ std::filesystem::remove_all(home);+}++TEST(Journal, RetentionNoneWritesNothing) {+ const auto home = scratch("none");+ ScopedHome scoped(home, Retention::None);++ MessageJournal journal;+ EXPECT_FALSE(journal.open());+ journal.append(make("/msg/1", NOW, "one"));++ EXPECT_FALSE(std::filesystem::exists(home / ".local" / "share" / "tether" / "messages.ndjson"));+ EXPECT_FALSE(std::filesystem::exists(home / ".local" / "share" / "tether" / "messages.ndjson.enc"));++ std::filesystem::remove_all(home);+}diff --git a/test/test_secret_store.cpp b/test/test_secret_store.cppnew file mode 100644index 0000000..89f2d71--- /dev/null+++ b/test/test_secret_store.cpp@@ -0,0 +1,173 @@+#include "scoped_env.hpp"++#include <gtest/gtest.h>+#include <tether/secret_store.hpp>++#include <filesystem>+#include <fstream>++using namespace tether;+using tether::testing::ScopedEnv;++namespace {++ // A scratch HOME, so every key in this file is a throwaway keyfile. The bus+ // is already pointed at nothing for the whole binary (secret_test_env.cpp).+ class ScopedKeyStore {+ public:+ ScopedKeyStore()+ : dir_(std::filesystem::temp_directory_path() /+ ("tether-secret-" + std::to_string(::getpid()) + "-" + std::to_string(counter())))+ , home_("HOME", dir_) {+ std::filesystem::create_directories(dir_);+ secret::reset_for_test();+ }++ ~ScopedKeyStore() {+ secret::reset_for_test();+ std::error_code ec;+ std::filesystem::remove_all(dir_, ec);+ }++ const std::filesystem::path& dir() const { return dir_; }++ private:+ static int counter() {+ static int n = 0;+ return ++n;+ }++ std::filesystem::path dir_;+ ScopedEnv home_;+ };++ constexpr const char* SAMPLE = R"({"handle":"/msg/1","body":"hello ø"})";++} // namespace++TEST(SecretStore, SealUnsealRoundTrip) {+ ScopedKeyStore store;+ ASSERT_TRUE(secret::have_key());++ const std::string sealed = secret::seal(SAMPLE);+ ASSERT_FALSE(sealed.empty());+ EXPECT_NE(sealed[0], '{') << "a sealed record must not look like the plaintext JSON it replaced";++ std::string out;+ ASSERT_TRUE(secret::unseal(sealed, out));+ EXPECT_EQ(out, SAMPLE);+}++TEST(SecretStore, SealIsNonDeterministic) {+ ScopedKeyStore store;+ ASSERT_TRUE(secret::have_key());+ // A fresh nonce per record, so identical messages do not produce identical+ // lines and leak that a body repeated.+ EXPECT_NE(secret::seal(SAMPLE), secret::seal(SAMPLE));+}++TEST(SecretStore, SealedRecordHasNoNewline) {+ ScopedKeyStore store;+ // The journal is newline-framed, so a record containing one would corrupt+ // every line after it.+ const std::string sealed = secret::seal("first\nsecond\nthird");+ ASSERT_FALSE(sealed.empty());+ EXPECT_EQ(sealed.find('\n'), std::string::npos);++ std::string out;+ ASSERT_TRUE(secret::unseal(sealed, out));+ EXPECT_EQ(out, "first\nsecond\nthird");+}++TEST(SecretStore, TamperedRecordFailsToUnseal) {+ ScopedKeyStore store;+ std::string sealed = secret::seal(SAMPLE);+ ASSERT_GT(sealed.size(), 20u);++ // Flip a character in the middle of the ciphertext. GCM's tag has to catch+ // it rather than handing back mangled plaintext.+ sealed[sealed.size() / 2] = sealed[sealed.size() / 2] == 'A' ? 'B' : 'A';++ std::string out;+ EXPECT_FALSE(secret::unseal(sealed, out));+}++TEST(SecretStore, TruncatedRecordFailsToUnseal) {+ ScopedKeyStore store;+ const std::string sealed = secret::seal(SAMPLE);+ std::string out;+ EXPECT_FALSE(secret::unseal(sealed.substr(0, sealed.size() / 2), out));+ EXPECT_FALSE(secret::unseal("", out));+ EXPECT_FALSE(secret::unseal("not base64 at all!!", out));+}++TEST(SecretStore, ADifferentKeyCannotUnseal) {+ std::string sealed;+ {+ ScopedKeyStore store;+ sealed = secret::seal(SAMPLE);+ ASSERT_FALSE(sealed.empty());+ }+ // A second store means a second generated key. Losing the key loses the+ // history, which is the documented trade.+ ScopedKeyStore other;+ std::string out;+ EXPECT_FALSE(secret::unseal(sealed, out));+}++TEST(SecretStore, KeySurvivesWithinTheSameHome) {+ ScopedKeyStore store;+ const std::string sealed = secret::seal(SAMPLE);++ // Drop the cached key: the keyfile has to be enough to read it back, or a+ // daemon restart would lose everything it just wrote.+ secret::reset_for_test();++ std::string out;+ ASSERT_TRUE(secret::unseal(sealed, out));+ EXPECT_EQ(out, SAMPLE);+}++TEST(SecretStore, KeyfileIsOwnerOnly) {+ ScopedKeyStore store;+ ASSERT_TRUE(secret::have_key());++ const std::filesystem::path key = store.dir() / ".config" / "tether" / "store.key";+ ASSERT_TRUE(std::filesystem::exists(key));+ const auto mode = std::filesystem::status(key).permissions();+ EXPECT_EQ(mode & std::filesystem::perms::group_all, std::filesystem::perms::none);+ EXPECT_EQ(mode & std::filesystem::perms::others_all, std::filesystem::perms::none);+}++TEST(SecretStore, PlaintextModeIsTheIdentity) {+ ScopedKeyStore store;+ secret::set_retention(Retention::Plaintext);++ EXPECT_EQ(secret::seal(SAMPLE), SAMPLE);+ std::string out;+ ASSERT_TRUE(secret::unseal(SAMPLE, out));+ EXPECT_EQ(out, SAMPLE);+ EXPECT_TRUE(secret::have_key()) << "plaintext needs no key, so nothing should ever wait on one";+}++TEST(SecretStore, NoneModeSealsNothing) {+ ScopedKeyStore store;+ secret::set_retention(Retention::None);++ EXPECT_TRUE(secret::seal(SAMPLE).empty());+ std::string out;+ EXPECT_FALSE(secret::unseal("anything", out));+}++TEST(SecretStore, RetentionNamesRoundTrip) {+ EXPECT_STREQ(to_string(Retention::Encrypted), "encrypted");+ EXPECT_STREQ(to_string(Retention::Plaintext), "plaintext");+ EXPECT_STREQ(to_string(Retention::None), "none");++ EXPECT_EQ(retention_from_string("plaintext"), Retention::Plaintext);+ EXPECT_EQ(retention_from_string("none"), Retention::None);+ EXPECT_EQ(retention_from_string("encrypted"), Retention::Encrypted);+ // An unreadable or absent value must not silently downgrade the store.+ EXPECT_EQ(retention_from_string(""), Retention::Encrypted);+ EXPECT_EQ(retention_from_string("nonsense"), Retention::Encrypted);+}diff --git a/test/test_vcard.cpp b/test/test_vcard.cppindex d1e0059..ad6997a 100644--- a/test/test_vcard.cpp+++ b/test/test_vcard.cpp@@ -1,18 +1,67 @@+#include "scoped_env.hpp"+#include <gtest/gtest.h>#include <tether/bluetooth/contacts.hpp>#include <tether/bluetooth/messages.hpp>#include <tether/bluetooth/vcard.hpp>+#include <tether/secret_store.hpp>++#include <filesystem>+#include <fstream>+using namespace tether;using namespace tether::bluetooth;+namespace {++ ContactStore three_contacts() {+ ContactStore store;+ store.set(parse_vcards("BEGIN:VCARD\nFN:Ada Lovelace\nTEL:+1 (555) 123-4567\nEND:VCARD\n"+ "BEGIN:VCARD\nFN:Grace Hopper\nEMAIL:[email protected]\nEND:VCARD\n"+ "BEGIN:VCARD\nFN:Alan Turing\nTEL:+15559876543\nEMAIL:[email protected]\nEND:VCARD\n"));+ return store;+ }++ std::vector<std::string> names_of(const std::vector<VCard>& cards) {+ std::vector<std::string> out;+ for (const auto& card : cards)+ out.push_back(card.name);+ return out;+ }++ // A scratch HOME, so the store key and both cache paths are throwaway.+ class ScopedStore {+ public:+ explicit ScopedStore(const std::string& name, Retention mode = Retention::Encrypted)+ : dir_(std::filesystem::temp_directory_path() / ("tether-contacts-" + name)), home_("HOME", dir_) {+ std::filesystem::remove_all(dir_);+ std::filesystem::create_directories(dir_);+ secret::reset_for_test();+ secret::set_retention(mode);+ }++ ~ScopedStore() {+ secret::reset_for_test();+ std::error_code ec;+ std::filesystem::remove_all(dir_, ec);+ }++ std::filesystem::path store() const { return dir_ / ".local" / "share" / "tether"; }++ private:+ std::filesystem::path dir_;+ tether::testing::ScopedEnv home_;+ };++} // namespace+TEST(VCard, ParsesNameTelAndEmail) {- auto cards = parse_vcards(- "BEGIN:VCARD\r\n"- "VERSION:3.0\r\n"- "FN:Ada Lovelace\r\n"- "TEL;TYPE=CELL:+15551234567\r\n"- "EMAIL;TYPE=INTERNET:[email protected]\r\n"- "END:VCARD\r\n");+ auto cards = parse_vcards("BEGIN:VCARD\r\n"+ "VERSION:3.0\r\n"+ "FN:Ada Lovelace\r\n"+ "TEL;TYPE=CELL:+15551234567\r\n"+ "EMAIL;TYPE=INTERNET:[email protected]\r\n"+ "END:VCARD\r\n");ASSERT_EQ(cards.size(), 1u);EXPECT_EQ(cards[0].name, "Ada Lovelace");@@ -25,14 +74,13 @@ TEST(VCard, ParsesNameTelAndEmail) {// A contact reachable at several numbers is the normal case, not an edge case:// keeping only the first would silently lose the address a thread is keyed on.TEST(VCard, KeepsEveryTelAndEmail) {- auto cards = parse_vcards(- "BEGIN:VCARD\n"- "FN:Grace Hopper\n"- "TEL;TYPE=CELL:+15550000001\n"- "TEL;TYPE=HOME:+15550000002\n"- "EMAIL:[email protected]\n"- "EMAIL:[email protected]\n"- "END:VCARD\n");+ auto cards = parse_vcards("BEGIN:VCARD\n"+ "FN:Grace Hopper\n"+ "TEL;TYPE=CELL:+15550000001\n"+ "TEL;TYPE=HOME:+15550000002\n"+ "EMAIL:[email protected]\n"+ "EMAIL:[email protected]\n"+ "END:VCARD\n");ASSERT_EQ(cards.size(), 1u);EXPECT_EQ(cards[0].tels.size(), 2u);@@ -40,9 +88,8 @@ TEST(VCard, KeepsEveryTelAndEmail) {}TEST(VCard, ParsesMultipleCards) {- auto cards = parse_vcards(- "BEGIN:VCARD\nFN:One\nTEL:+1555000001\nEND:VCARD\n"- "BEGIN:VCARD\nFN:Two\nTEL:+1555000002\nEND:VCARD\n");+ auto cards = parse_vcards("BEGIN:VCARD\nFN:One\nTEL:+1555000001\nEND:VCARD\n"+ "BEGIN:VCARD\nFN:Two\nTEL:+1555000002\nEND:VCARD\n");ASSERT_EQ(cards.size(), 2u);EXPECT_EQ(cards[0].name, "One");@@ -52,13 +99,12 @@ TEST(VCard, ParsesMultipleCards) {// RFC 2425 folding splits long values across lines; without unfolding, a long// name or address is silently truncated at the fold.TEST(VCard, UnfoldsContinuationLines) {- auto cards = parse_vcards(- "BEGIN:VCARD\r\n"- "FN:A Very Long Contact\r\n"- " Name Indeed\r\n"- "TEL:+1555\r\n"- " 0000001\r\n"- "END:VCARD\r\n");+ auto cards = parse_vcards("BEGIN:VCARD\r\n"+ "FN:A Very Long Contact\r\n"+ " Name Indeed\r\n"+ "TEL:+1555\r\n"+ " 0000001\r\n"+ "END:VCARD\r\n");ASSERT_EQ(cards.size(), 1u);EXPECT_EQ(cards[0].name, "A Very Long Contact Name Indeed");@@ -96,9 +142,8 @@ TEST(VCard, IgnoresMalformedInput) {// A card cut off mid-transfer should still yield what it had rather than// swallowing the card that follows it.TEST(VCard, RecoversFromUnterminatedCard) {- auto cards = parse_vcards(- "BEGIN:VCARD\nFN:First\nTEL:+1555000001\n"- "BEGIN:VCARD\nFN:Second\nTEL:+1555000002\nEND:VCARD\n");+ auto cards = parse_vcards("BEGIN:VCARD\nFN:First\nTEL:+1555000001\n"+ "BEGIN:VCARD\nFN:Second\nTEL:+1555000002\nEND:VCARD\n");ASSERT_EQ(cards.size(), 2u);EXPECT_EQ(cards[0].name, "First");@@ -193,3 +238,96 @@ TEST(MessageStore, RefreshesObjectPathOnRelist) {ASSERT_NE(store.find("42"), nullptr);EXPECT_EQ(store.find("42")->object_path, "/org/bluez/obex/client/session11/message42");}++TEST(ContactSearch, MatchesOnPartOfAName) {+ EXPECT_EQ(names_of(three_contacts().search("lace", 10)), (std::vector<std::string>{"Ada Lovelace"}));+ EXPECT_EQ(names_of(three_contacts().search("hopper", 10)), (std::vector<std::string>{"Grace Hopper"}));+}++TEST(ContactSearch, IsCaseInsensitive) {+ EXPECT_EQ(names_of(three_contacts().search("ADA", 10)), (std::vector<std::string>{"Ada Lovelace"}));+}++TEST(ContactSearch, MatchesANumberTypedWithoutItsFormatting) {+ // The contact is stored as "+1 (555) 123-4567"; nobody types it that way.+ EXPECT_EQ(names_of(three_contacts().search("5551234567", 10)), (std::vector<std::string>{"Ada Lovelace"}));+}++TEST(ContactSearch, MatchesAnEmailAddress) {+ EXPECT_EQ(names_of(three_contacts().search("grace@", 10)), (std::vector<std::string>{"Grace Hopper"}));+}++TEST(ContactSearch, AnEmptyQueryReturnsEverythingSortedByName) {+ EXPECT_EQ(names_of(three_contacts().search("", 10)),+ (std::vector<std::string>{"Ada Lovelace", "Alan Turing", "Grace Hopper"}));+}++TEST(ContactSearch, HonoursTheLimit) { EXPECT_EQ(three_contacts().search("", 2).size(), 2u); }++TEST(ContactSearch, NoMatchIsEmptyRatherThanEverything) { EXPECT_TRUE(three_contacts().search("nobody", 10).empty()); }++TEST(ContactStore, EncryptedCacheLeavesNothingReadable) {+ ScopedStore scoped("encrypted");+ ASSERT_TRUE(save_contacts(three_contacts()));++ EXPECT_FALSE(std::filesystem::exists(scoped.store() / "contacts.json"))+ << "the plaintext name must stay empty, or an older tetherd would read the phonebook";+ const auto sealed = scoped.store() / "contacts.json.enc";+ ASSERT_TRUE(std::filesystem::exists(sealed));++ std::ifstream in(sealed);+ const std::string text((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());+ EXPECT_EQ(text.find("Lovelace"), std::string::npos) << "a contact name is on disk in the clear";+ EXPECT_EQ(text.find("5551234567"), std::string::npos) << "a phone number is on disk in the clear";++ EXPECT_EQ(load_contacts().name_for("tel:+15551234567"), "Ada Lovelace");+}++TEST(ContactStore, MigratesAPlaintextCacheOnLoad) {+ ScopedStore scoped("migrate");+ {+ secret::set_retention(Retention::Plaintext);+ ASSERT_TRUE(save_contacts(three_contacts()));+ ASSERT_TRUE(std::filesystem::exists(scoped.store() / "contacts.json"));+ }++ secret::set_retention(Retention::Encrypted);+ EXPECT_EQ(load_contacts().name_for("tel:+15551234567"), "Ada Lovelace") << "migration lost the phonebook";+ EXPECT_FALSE(std::filesystem::exists(scoped.store() / "contacts.json"))+ << "the plaintext copy outlived the migration";+ EXPECT_TRUE(std::filesystem::exists(scoped.store() / "contacts.json.enc"));+}++TEST(ContactStore, RetentionNoneWritesNothing) {+ ScopedStore scoped("none", Retention::None);+ EXPECT_FALSE(save_contacts(three_contacts()));+ EXPECT_FALSE(std::filesystem::exists(scoped.store() / "contacts.json"));+ EXPECT_FALSE(std::filesystem::exists(scoped.store() / "contacts.json.enc"));+ EXPECT_EQ(load_contacts().size(), 0u);+}++// Overwriting a good cache with an empty one would cost every display name+// until the next PBAP pull, which can be a reconnect away.+TEST(ContactStore, AnUnreadableKeyDoesNotClobberTheCache) {+ ScopedStore scoped("clobber");+ ASSERT_TRUE(save_contacts(three_contacts()));+ const auto sealed = scoped.store() / "contacts.json.enc";+ std::ifstream in(sealed);+ const std::string before((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());+ in.close();++ {+ // A different HOME is a different key: what a locked wallet looks like.+ const auto elsewhere = std::filesystem::temp_directory_path() / "tether-contacts-clobber-other";+ std::filesystem::create_directories(elsewhere);+ tether::testing::ScopedEnv home("HOME", elsewhere);+ secret::reset_for_test();+ load_contacts();+ std::filesystem::remove_all(elsewhere);+ }++ secret::reset_for_test();+ std::ifstream after_in(sealed);+ const std::string after((std::istreambuf_iterator<char>(after_in)), std::istreambuf_iterator<char>());+ EXPECT_EQ(after, before) << "the cache was rewritten by a daemon that could not read it";+}