Skip to content

Linux + iPhone Continuity / iMessage / SMS

fix: restore BlueZ startup probe and no-device advice after PR #67

Zack Bartel7bfd43e4e48a
diff --git a/po/cs.po b/po/cs.po
index 52d51e3..c2a0fc7 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -1110,9 +1110,8 @@ msgid "Nearby (Tap to Pair)"
msgstr "V okolí (klepnutím spárujete)"
#: src/gtk/devices_view.cpp
-#, fuzzy
msgid "Partially connected"
-msgstr "nepřipojeno"
+msgstr "Částečně připojeno"
#: src/gtk/devices_view.cpp
msgid "Paired"
@@ -1330,9 +1329,8 @@ msgid "Today"
msgstr "Dnes"
#: src/gtk/messages_view.cpp
-#, fuzzy
msgid "Bluetooth connection needed to sync messages."
-msgstr "Démon uzavřel spojení dříve, než byla zpráva odeslána.\n"
+msgstr "Pro synchronizaci zpráv je potřeba připojení Bluetooth."
#: src/gtk/messages_view.cpp
msgid "Select a conversation"
diff --git a/po/de.po b/po/de.po
index ebb9e89..c217ed3 100644
--- a/po/de.po
+++ b/po/de.po
@@ -1136,9 +1136,8 @@ msgid "Nearby (Tap to Pair)"
msgstr "In der Nähe (zum Koppeln tippen)"
#: src/gtk/devices_view.cpp
-#, fuzzy
msgid "Partially connected"
-msgstr "nicht verbunden"
+msgstr "Teilweise verbunden"
#: src/gtk/devices_view.cpp
msgid "Paired"
@@ -1356,11 +1355,10 @@ msgid "Today"
msgstr "Heute"
#: src/gtk/messages_view.cpp
-#, fuzzy
msgid "Bluetooth connection needed to sync messages."
msgstr ""
-"Der Daemon hat die Verbindung geschlossen, bevor die Nachricht gesendet "
-"wurde.\n"
+"Zum Synchronisieren von Nachrichten ist eine Bluetooth-Verbindung "
+"erforderlich."
#: src/gtk/messages_view.cpp
msgid "Select a conversation"
diff --git a/po/es.po b/po/es.po
index 7bf24ba..200efae 100644
--- a/po/es.po
+++ b/po/es.po
@@ -1127,9 +1127,8 @@ msgid "Nearby (Tap to Pair)"
msgstr "Cerca (toque para emparejar)"
#: src/gtk/devices_view.cpp
-#, fuzzy
msgid "Partially connected"
-msgstr "no conectado"
+msgstr "Parcialmente conectado"
#: src/gtk/devices_view.cpp
msgid "Paired"
@@ -1347,9 +1346,8 @@ msgid "Today"
msgstr "Hoy"
#: src/gtk/messages_view.cpp
-#, fuzzy
msgid "Bluetooth connection needed to sync messages."
-msgstr "El daemon cerró la conexión antes de enviar el mensaje.\n"
+msgstr "Se necesita una conexión Bluetooth para sincronizar los mensajes."
#: src/gtk/messages_view.cpp
msgid "Select a conversation"
diff --git a/po/fr.po b/po/fr.po
index 5c33ddb..ab00d17 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -1135,9 +1135,8 @@ msgid "Nearby (Tap to Pair)"
msgstr "À proximité (toucher pour appairer)"
#: src/gtk/devices_view.cpp
-#, fuzzy
msgid "Partially connected"
-msgstr "non connecté"
+msgstr "Partiellement connecté"
#: src/gtk/devices_view.cpp
msgid "Paired"
@@ -1355,9 +1354,8 @@ msgid "Today"
msgstr "Aujourd'hui"
#: src/gtk/messages_view.cpp
-#, fuzzy
msgid "Bluetooth connection needed to sync messages."
-msgstr "Le démon a fermé la connexion avant l'envoi du message.\n"
+msgstr "Une connexion Bluetooth est nécessaire pour synchroniser les messages."
#: src/gtk/messages_view.cpp
msgid "Select a conversation"
diff --git a/po/it.po b/po/it.po
index fa7dda5..1b2731d 100644
--- a/po/it.po
+++ b/po/it.po
@@ -1124,9 +1124,8 @@ msgid "Nearby (Tap to Pair)"
msgstr "Nelle vicinanze (tocca per accoppiare)"
#: src/gtk/devices_view.cpp
-#, fuzzy
msgid "Partially connected"
-msgstr "non connesso"
+msgstr "Parzialmente connesso"
#: src/gtk/devices_view.cpp
msgid "Paired"
@@ -1343,10 +1342,8 @@ msgid "Today"
msgstr "Oggi"
#: src/gtk/messages_view.cpp
-#, fuzzy
msgid "Bluetooth connection needed to sync messages."
-msgstr ""
-"Il daemon ha chiuso la connessione prima che il messaggio fosse inviato.\n"
+msgstr "È necessaria una connessione Bluetooth per sincronizzare i messaggi."
#: src/gtk/messages_view.cpp
msgid "Select a conversation"
diff --git a/po/ja.po b/po/ja.po
index 3cb6893..0edd15b 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -1096,9 +1096,8 @@ msgid "Nearby (Tap to Pair)"
msgstr "近くにあります (タップしてペアリング)"
#: src/gtk/devices_view.cpp
-#, fuzzy
msgid "Partially connected"
-msgstr "未接続"
+msgstr "部分的に接続"
#: src/gtk/devices_view.cpp
msgid "Paired"
@@ -1312,9 +1311,8 @@ msgid "Today"
msgstr "今日"
#: src/gtk/messages_view.cpp
-#, fuzzy
msgid "Bluetooth connection needed to sync messages."
-msgstr "メッセージが送信される前にデーモンが接続を閉じました。\n"
+msgstr "メッセージの同期にはBluetooth接続が必要です。"
#: src/gtk/messages_view.cpp
msgid "Select a conversation"
diff --git a/po/ko.po b/po/ko.po
index a764d60..1aa125b 100644
--- a/po/ko.po
+++ b/po/ko.po
@@ -1086,9 +1086,8 @@ msgid "Nearby (Tap to Pair)"
msgstr "근처 (탭하여 페어링)"
#: src/gtk/devices_view.cpp
-#, fuzzy
msgid "Partially connected"
-msgstr "연결 안 됨"
+msgstr "부분적으로 연결됨"
#: src/gtk/devices_view.cpp
msgid "Paired"
@@ -1300,9 +1299,8 @@ msgid "Today"
msgstr "오늘"
#: src/gtk/messages_view.cpp
-#, fuzzy
msgid "Bluetooth connection needed to sync messages."
-msgstr "메시지가 전송되기 전에 데몬이 연결을 닫았습니다.\n"
+msgstr "메시지를 동기화하려면 Bluetooth 연결이 필요합니다."
#: src/gtk/messages_view.cpp
msgid "Select a conversation"
diff --git a/po/nl.po b/po/nl.po
index 330a463..8188e87 100644
--- a/po/nl.po
+++ b/po/nl.po
@@ -1120,9 +1120,8 @@ msgid "Nearby (Tap to Pair)"
msgstr "In de buurt (tik om te koppelen)"
#: src/gtk/devices_view.cpp
-#, fuzzy
msgid "Partially connected"
-msgstr "niet verbonden"
+msgstr "Gedeeltelijk verbonden"
#: src/gtk/devices_view.cpp
msgid "Paired"
@@ -1339,9 +1338,8 @@ msgid "Today"
msgstr "Vandaag"
#: src/gtk/messages_view.cpp
-#, fuzzy
msgid "Bluetooth connection needed to sync messages."
-msgstr "De daemon sloot de verbinding voordat het bericht verstuurd was.\n"
+msgstr "Er is een Bluetooth-verbinding nodig om berichten te synchroniseren."
#: src/gtk/messages_view.cpp
msgid "Select a conversation"
diff --git a/po/pl.po b/po/pl.po
index 3210445..47b063d 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -1122,9 +1122,8 @@ msgid "Nearby (Tap to Pair)"
msgstr "W pobliżu (dotknij, aby sparować)"
#: src/gtk/devices_view.cpp
-#, fuzzy
msgid "Partially connected"
-msgstr "nie połączono"
+msgstr "Częściowo połączono"
#: src/gtk/devices_view.cpp
msgid "Paired"
@@ -1343,9 +1342,8 @@ msgid "Today"
msgstr "Dzisiaj"
#: src/gtk/messages_view.cpp
-#, fuzzy
msgid "Bluetooth connection needed to sync messages."
-msgstr "Demon zamknął połączenie, zanim wiadomość została wysłana.\n"
+msgstr "Do synchronizacji wiadomości wymagane jest połączenie Bluetooth."
#: src/gtk/messages_view.cpp
msgid "Select a conversation"
diff --git a/po/pt_BR.po b/po/pt_BR.po
index 647555d..ac23dd7 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -1119,9 +1119,8 @@ msgid "Nearby (Tap to Pair)"
msgstr "Por perto (toque para parear)"
#: src/gtk/devices_view.cpp
-#, fuzzy
msgid "Partially connected"
-msgstr "não conectado"
+msgstr "Parcialmente conectado"
#: src/gtk/devices_view.cpp
msgid "Paired"
@@ -1338,9 +1337,8 @@ msgid "Today"
msgstr "Hoje"
#: src/gtk/messages_view.cpp
-#, fuzzy
msgid "Bluetooth connection needed to sync messages."
-msgstr "O daemon fechou a conexão antes de a mensagem ser enviada.\n"
+msgstr "É necessária uma conexão Bluetooth para sincronizar as mensagens."
#: src/gtk/messages_view.cpp
msgid "Select a conversation"
diff --git a/po/ru.po b/po/ru.po
index 36bf155..777dd26 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -1122,9 +1122,8 @@ msgid "Nearby (Tap to Pair)"
msgstr "Поблизости (нажмите, чтобы создать пару)"
#: src/gtk/devices_view.cpp
-#, fuzzy
msgid "Partially connected"
-msgstr "не подключено"
+msgstr "Подключено частично"
#: src/gtk/devices_view.cpp
msgid "Paired"
@@ -1343,9 +1342,8 @@ msgid "Today"
msgstr "Сегодня"
#: src/gtk/messages_view.cpp
-#, fuzzy
msgid "Bluetooth connection needed to sync messages."
-msgstr "Демон закрыл соединение до того, как сообщение было отправлено.\n"
+msgstr "Для синхронизации сообщений требуется подключение Bluetooth."
#: src/gtk/messages_view.cpp
msgid "Select a conversation"
diff --git a/po/sv.po b/po/sv.po
index f6c7535..e717c05 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -1105,9 +1105,8 @@ msgid "Nearby (Tap to Pair)"
msgstr "I närheten (tryck för att parkoppla)"
#: src/gtk/devices_view.cpp
-#, fuzzy
msgid "Partially connected"
-msgstr "inte ansluten"
+msgstr "Delvis ansluten"
#: src/gtk/devices_view.cpp
msgid "Paired"
@@ -1325,9 +1324,8 @@ msgid "Today"
msgstr "Idag"
#: src/gtk/messages_view.cpp
-#, fuzzy
msgid "Bluetooth connection needed to sync messages."
-msgstr "Demonen stängde anslutningen innan meddelandet skickades.\n"
+msgstr "En Bluetooth-anslutning krävs för att synkronisera meddelanden."
#: src/gtk/messages_view.cpp
msgid "Select a conversation"
diff --git a/po/tr.po b/po/tr.po
index 7fd75b1..73ff63a 100644
--- a/po/tr.po
+++ b/po/tr.po
@@ -1103,9 +1103,8 @@ msgid "Nearby (Tap to Pair)"
msgstr "Yakında (eşleşmek için dokunun)"
#: src/gtk/devices_view.cpp
-#, fuzzy
msgid "Partially connected"
-msgstr "bağlı değil"
+msgstr "Kısmen bağlı"
#: src/gtk/devices_view.cpp
msgid "Paired"
@@ -1322,9 +1321,8 @@ msgid "Today"
msgstr "Bugün"
#: src/gtk/messages_view.cpp
-#, fuzzy
msgid "Bluetooth connection needed to sync messages."
-msgstr "Arka plan hizmeti, mesaj gönderilmeden bağlantıyı kapattı.\n"
+msgstr "Mesajları eşitlemek için Bluetooth bağlantısı gerekli."
#: src/gtk/messages_view.cpp
msgid "Select a conversation"
diff --git a/po/uk.po b/po/uk.po
index f235ed5..c7a4365 100644
--- a/po/uk.po
+++ b/po/uk.po
@@ -1118,9 +1118,8 @@ msgid "Nearby (Tap to Pair)"
msgstr "Поблизу (торкніться, щоб створити пару)"
#: src/gtk/devices_view.cpp
-#, fuzzy
msgid "Partially connected"
-msgstr "не під'єднано"
+msgstr "Під'єднано частково"
#: src/gtk/devices_view.cpp
msgid "Paired"
@@ -1339,9 +1338,8 @@ msgid "Today"
msgstr "Сьогодні"
#: src/gtk/messages_view.cpp
-#, fuzzy
msgid "Bluetooth connection needed to sync messages."
-msgstr "Демон закрив з'єднання до того, як повідомлення було надіслано.\n"
+msgstr "Для синхронізації повідомлень потрібне з’єднання Bluetooth."
#: src/gtk/messages_view.cpp
msgid "Select a conversation"
diff --git a/po/zh_CN.po b/po/zh_CN.po
index 128fe88..617e319 100644
--- a/po/zh_CN.po
+++ b/po/zh_CN.po
@@ -1062,9 +1062,8 @@ msgid "Nearby (Tap to Pair)"
msgstr "附近(轻点以配对)"
#: src/gtk/devices_view.cpp
-#, fuzzy
msgid "Partially connected"
-msgstr "未连接"
+msgstr "部分连接"
#: src/gtk/devices_view.cpp
msgid "Paired"
@@ -1274,9 +1273,8 @@ msgid "Today"
msgstr "今天"
#: src/gtk/messages_view.cpp
-#, fuzzy
msgid "Bluetooth connection needed to sync messages."
-msgstr "信息发送前守护进程已关闭连接。\n"
+msgstr "需要蓝牙连接才能同步消息。"
#: src/gtk/messages_view.cpp
msgid "Select a conversation"
diff --git a/src/core/include/tether/bluetooth/monitor.hpp b/src/core/include/tether/bluetooth/monitor.hpp
index 45b95b0..3c5d95c 100644
--- a/src/core/include/tether/bluetooth/monitor.hpp
+++ b/src/core/include/tether/bluetooth/monitor.hpp
@@ -51,8 +51,7 @@ namespace tether::bluetooth {
// BlueZ exposes Secure Connections only through the management interface.
// Runs btmgmt without a shell and returns no value if it fails or exceeds the
// deadline. Public so the process boundary and timeout can be tested directly.
- std::optional<bool> probe_secure_connections(
- const std::string& adapter_id,
- std::chrono::milliseconds timeout = std::chrono::seconds(1));
+ std::optional<bool> probe_secure_connections(const std::string& adapter_id,
+ std::chrono::milliseconds timeout = std::chrono::seconds(1));
} // namespace tether::bluetooth
diff --git a/src/core/include/tether/bluetooth/objects.hpp b/src/core/include/tether/bluetooth/objects.hpp
index dac5feb..01fa085 100644
--- a/src/core/include/tether/bluetooth/objects.hpp
+++ b/src/core/include/tether/bluetooth/objects.hpp
@@ -136,8 +136,7 @@ namespace tether::bluetooth {
// setting read by BluezMonitor. Keeping the external btmgmt probe out of
// this function makes capability resolution deterministic and prevents a
// stalled controller query from blocking unrelated callers.
- Capability resolve_capability(const BluezObjects& objects,
- std::optional<bool> secure_connections = std::nullopt);
+ Capability resolve_capability(const BluezObjects& objects, std::optional<bool> secure_connections = std::nullopt);
nlohmann::json to_json(const Adapter& adapter);
nlohmann::json to_json(const Device& device);
diff --git a/src/core/include/tether/net.hpp b/src/core/include/tether/net.hpp
index 6096d19..e62c789 100644
--- a/src/core/include/tether/net.hpp
+++ b/src/core/include/tether/net.hpp
@@ -105,6 +105,9 @@ namespace tether {
int client_fd;
std::string fingerprint;
std::string device_name;
+ // The device was accepted elsewhere and the dialog killed, so its
+ // non-zero exit is not a refusal.
+ bool superseded = false;
};
// keyed by the pipe read-fd we monitor in epoll
std::map<int, PendingPairDialog> pending_dialogs_;
diff --git a/src/core/src/bluetooth/monitor.cpp b/src/core/src/bluetooth/monitor.cpp
index 2ac440d..d2c7c9d 100644
--- a/src/core/src/bluetooth/monitor.cpp
+++ b/src/core/src/bluetooth/monitor.cpp
@@ -4,9 +4,9 @@
#include <algorithm>
#include <array>
#include <atomic>
+#include <cerrno>
#include <chrono>
#include <condition_variable>
-#include <cerrno>
#include <csignal>
#include <fcntl.h>
#include <filesystem>
@@ -15,8 +15,8 @@
#include <mutex>
#include <optional>
#include <poll.h>
-#include <sys/wait.h>
#include <sys/eventfd.h>
+#include <sys/wait.h>
#include <thread>
#include <unistd.h>
@@ -141,8 +141,7 @@ namespace tether::bluetooth {
return value;
}
- std::optional<bool> probe_secure_connections(const std::string& adapter_id,
- std::chrono::milliseconds timeout) {
+ std::optional<bool> probe_secure_connections(const std::string& adapter_id, std::chrono::milliseconds timeout) {
if (adapter_id.empty())
return std::nullopt;
@@ -159,17 +158,8 @@ namespace tether::bluetooth {
GError* error = nullptr;
const auto flags = static_cast<GSpawnFlags>(G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD |
G_SPAWN_STDERR_TO_DEV_NULL | G_SPAWN_CLOEXEC_PIPES);
- if (!g_spawn_async_with_pipes(nullptr,
- argv.data(),
- nullptr,
- flags,
- nullptr,
- nullptr,
- &child,
- nullptr,
- &output_fd,
- nullptr,
- &error)) {
+ if (!g_spawn_async_with_pipes(
+ nullptr, argv.data(), nullptr, flags, nullptr, nullptr, &child, nullptr, &output_fd, nullptr, &error)) {
debug::log(WARN,
"bluetooth: cannot start btmgmt for {}: {}",
adapter_id,
@@ -214,8 +204,8 @@ namespace tether::bluetooth {
if (waited < 0 && errno != EINTR)
break;
- const auto remaining = std::chrono::duration_cast<std::chrono::milliseconds>(
- deadline - std::chrono::steady_clock::now());
+ const auto remaining =
+ std::chrono::duration_cast<std::chrono::milliseconds>(deadline - std::chrono::steady_clock::now());
pollfd watched{output_fd, POLLIN | POLLHUP, 0};
poll(&watched, 1, static_cast<int>(std::clamp<int64_t>(remaining.count(), 1, 50)));
}
@@ -239,8 +229,8 @@ namespace tether::bluetooth {
}
}
- const auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
- std::chrono::steady_clock::now() - started);
+ const auto elapsed =
+ std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - started);
debug::log(WARN, "bluetooth: btmgmt info for {} timed out after {}ms", adapter_id, elapsed.count());
close(output_fd);
g_spawn_close_pid(child);
@@ -375,6 +365,31 @@ namespace tether::bluetooth {
return false;
}
+ // fail fast when bluetoothd is not present
+ GVariant* probe = g_dbus_connection_call_sync(impl_->conn,
+ BLUEZ_NAME,
+ "/",
+ OBJECT_MANAGER,
+ "GetManagedObjects",
+ nullptr,
+ G_VARIANT_TYPE("(a{oa{sa{sv}}})"),
+ G_DBUS_CALL_FLAGS_NONE,
+ 5000,
+ nullptr,
+ &error);
+ if (!probe) {
+ debug::log(WARN, "bluetooth: BlueZ unavailable: {}", error ? error->message : "unknown");
+ g_clear_error(&error);
+ g_clear_object(&impl_->conn);
+ return false;
+ }
+ impl_->objects = parse_managed_objects(probe);
+ impl_->objects.experimental_api = bluetoothd_has_experimental();
+ // Secure Connections stays unknown until the watcher thread's first
+ // refresh: probing it here would fork btmgmt on the startup path.
+ impl_->cap = resolve_capability(impl_->objects);
+ g_variant_unref(probe);
+
impl_->efd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
if (impl_->efd < 0) {
debug::log(ERR, "bluetooth: eventfd() failed");
diff --git a/src/core/src/net.cpp b/src/core/src/net.cpp
index 67b3a1d..8929c15 100644
--- a/src/core/src/net.cpp
+++ b/src/core/src/net.cpp
@@ -2,6 +2,7 @@
#include <tether/i18n.hpp>
#include <arpa/inet.h>
+#include <csignal>
#include <errno.h>
#include <fcntl.h>
#include <sys/file.h>
@@ -1104,6 +1105,7 @@ namespace tether {
event["command"] = "pair_accepted";
event["fingerprint"] = print;
event["device_name"] = target_host;
+ event["connected"] = false;
broadcast_local_event(event.dump());
}
}
@@ -1565,10 +1567,10 @@ namespace tether {
promoted = true;
nlohmann::json connected_event{{"command", "client_connected"},
- {"fingerprint", fingerprint},
- {"device_name", device_name},
- {"address", remote.address},
- {"paired", true}};
+ {"fingerprint", fingerprint},
+ {"device_name", device_name},
+ {"address", remote.address},
+ {"paired", true}};
broadcast_local_event(connected_event.dump());
nlohmann::json response{{"command", "pair_accepted"}};
@@ -1586,10 +1588,12 @@ namespace tether {
// An external acceptance supersedes any dialog for the same request.
// Its exit callback observes the promoted session and ignores the stale
// non-zero result rather than sending pair_rejected to the phone.
- for (const auto& [read_fd, dialog] : pending_dialogs_) {
+ for (auto& [read_fd, dialog] : pending_dialogs_) {
(void)read_fd;
- if (dialog.fingerprint == fingerprint)
- kill(dialog.pid, SIGTERM);
+ if (dialog.fingerprint != fingerprint)
+ continue;
+ dialog.superseded = true;
+ kill(dialog.pid, SIGTERM);
}
debug::log(INFO,
@@ -1709,7 +1713,7 @@ namespace tether {
if (exit_code == 0) {
accept_device(info.fingerprint, info.device_name);
- } else if (client_paired_.contains(info.client_fd) && client_paired_[info.client_fd]) {
+ } else if (info.superseded) {
debug::log(INFO, "Pairing dialog dismissed after {} was accepted elsewhere", info.device_name);
} else {
diff --git a/src/gtk/devices_view.cpp b/src/gtk/devices_view.cpp
index f1089d0..e40dde9 100644
--- a/src/gtk/devices_view.cpp
+++ b/src/gtk/devices_view.cpp
@@ -696,9 +696,9 @@ namespace tether::ui {
const std::string name = device.value("name", "").empty() ? address : device.value("name", "");
const bool paired = device.value("paired", false);
const bool connected = device.value("connected", false);
- const bool route_ready = is_supervised_bt_device(address) &&
- (g_devices.bt_connection.value("map_open", false) ||
- g_devices.bt_connection.value("ancs_ready", false));
+ const bool route_ready =
+ is_supervised_bt_device(address) && (g_devices.bt_connection.value("map_open", false) ||
+ g_devices.bt_connection.value("ancs_ready", false));
GtkWidget* row = gtk_list_box_row_new();
g_object_set_data_full(G_OBJECT(row), "bt_address", g_strdup(address.c_str()), g_free);
@@ -717,10 +717,10 @@ namespace tether::ui {
gtk_label_set_xalign(GTK_LABEL(title), 0.0);
gtk_box_pack_start(GTK_BOX(labels), title, FALSE, FALSE, 0);
- const char* subtitle_text = route_ready ? _("Connected")
- : connected ? _("Partially connected")
- : paired ? _("Paired")
- : _("Nearby (Tap to Pair)");
+ const char* subtitle_text = route_ready ? _("Connected")
+ : connected ? _("Partially connected")
+ : paired ? _("Paired")
+ : _("Nearby (Tap to Pair)");
GtkWidget* subtitle = gtk_label_new(subtitle_text);
gtk_label_set_xalign(GTK_LABEL(subtitle), 0.0);
gtk_style_context_add_class(gtk_widget_get_style_context(subtitle), "muted");
@@ -997,11 +997,10 @@ namespace tether::ui {
}
if (g_devices.select_bt_after_scan) {
- const auto iphone = std::find_if(g_devices.bt_devices.begin(),
- g_devices.bt_devices.end(),
- [](const nlohmann::json& device) {
- return device.value("iphone", false);
- });
+ const auto iphone =
+ std::find_if(g_devices.bt_devices.begin(),
+ g_devices.bt_devices.end(),
+ [](const nlohmann::json& device) { return device.value("iphone", false); });
if (iphone != g_devices.bt_devices.end()) {
g_devices.selected_bt_address = iphone->value("address", "");
g_devices.selected_bt_name = iphone->value("name", "iPhone");
@@ -1031,11 +1030,12 @@ namespace tether::ui {
set_text(g_devices.lbl_bt_progress, message);
// A failed scan already carries the reason; only a scan that really
// ran and found nothing wants the "check the phone" advice.
- if (event.value("success", false) && g_devices.select_bt_after_scan) {
+ if (event.value("success", false) && (g_devices.bt_devices.empty() || g_devices.select_bt_after_scan)) {
const char* advice = _("No iPhone found. Unlock the phone and open Settings > Bluetooth so it "
"advertises, then scan again.");
set_text(g_devices.lbl_welcome_bt, advice);
- set_status_action(advice);
+ if (g_devices.select_bt_after_scan)
+ set_status_action(advice);
g_devices.select_bt_after_scan = false;
update_action_bt_scan_controls();
} else if (!event.value("success", false)) {
diff --git a/src/gtk/messages_view.cpp b/src/gtk/messages_view.cpp
index 3017c22..5084a0d 100644
--- a/src/gtk/messages_view.cpp
+++ b/src/gtk/messages_view.cpp
@@ -1161,8 +1161,7 @@ namespace tether::ui {
GtkWidget* placeholder = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
gtk_widget_set_valign(placeholder, GTK_ALIGN_CENTER);
gtk_widget_set_halign(placeholder, GTK_ALIGN_CENTER);
- g_messages.placeholder_icon =
- gtk_image_new_from_icon_name("mail-unread-symbolic", GTK_ICON_SIZE_DIALOG);
+ g_messages.placeholder_icon = gtk_image_new_from_icon_name("mail-unread-symbolic", GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start(GTK_BOX(placeholder), g_messages.placeholder_icon, FALSE, FALSE, 0);
g_messages.placeholder_label = gtk_label_new(_("Select a conversation"));
gtk_style_context_add_class(gtk_widget_get_style_context(g_messages.placeholder_label), "muted");
diff --git a/test/test_bluetooth_monitor.cpp b/test/test_bluetooth_monitor.cpp
index 93e9ee2..4188651 100644
--- a/test/test_bluetooth_monitor.cpp
+++ b/test/test_bluetooth_monitor.cpp
@@ -3,9 +3,9 @@
#include <chrono>
#include <cstdlib>
+#include <fcntl.h>
#include <filesystem>
#include <fstream>
-#include <fcntl.h>
#include <string>
#include <sys/types.h>
#include <unistd.h>
@@ -20,8 +20,7 @@ namespace {
explicit FakeBtmgmt(const std::string& body) {
const char* path = std::getenv("PATH");
old_path_ = path ? path : "";
- dir_ = std::filesystem::path("/var/tmp") /
- ("tether-monitor-test-" + std::to_string(getpid()));
+ dir_ = std::filesystem::path("/var/tmp") / ("tether-monitor-test-" + std::to_string(getpid()));
std::filesystem::remove_all(dir_);
std::filesystem::create_directories(dir_);
@@ -30,8 +29,7 @@ namespace {
script << "#!/bin/sh\n" << body;
script.close();
std::filesystem::permissions(executable,
- std::filesystem::perms::owner_read |
- std::filesystem::perms::owner_write |
+ std::filesystem::perms::owner_read | std::filesystem::perms::owner_write |
std::filesystem::perms::owner_exec,
std::filesystem::perm_options::replace);
setenv("PATH", dir_.c_str(), 1);