diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index d55b43cd..fa6ff098 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -212,6 +212,29 @@ enum IdentityTransfer { noReply, } +/// How a channel write (`CMD_SET_CHANNEL`) ended, as the radio reported it. +/// (#1026) +enum ChannelWrite { + /// The radio answered OK. + ok, + + /// The radio refused because a different channel holds the slot + /// (`ERR_CODE_BAD_STATE`, OffbandMesh/meshcore-firmware#1864). That channel + /// is still there, intact. + occupied, + + /// The radio refused for another reason, e.g. a slot index it does not have. + rejected, + + /// Not connected, or no reply before the timeout. The write may or may not + /// have landed. + noReply, + + /// An edit to a new key cleared the old channel, but the new one was not + /// confirmed, so the slot is now empty. (#1026) + clearedNotAdded, +} + /// Result of [MeshCoreConnector.exportPrivateKey]. [identity] is /// non-null only when [outcome] is [IdentityTransfer.ok]. (#578) class IdentityExportResult { @@ -6882,6 +6905,19 @@ class MeshCoreConnector extends ChangeNotifier { } Future getChannels({int? maxChannels, bool force = false}) async { + // A sync started while a channel write waits for its reply would share the + // reply queue with it. Replies are matched by order, so the sync's + // empty-slot ERR could be taken as the write's answer. Deferred until the + // writes finish, then run once (#1026). The writers' own re-reads call + // [_syncChannels] directly. + if (_channelWritesInFlight > 0) { + _channelSyncDeferredByWrite = true; + return; + } + return _syncChannels(maxChannels: maxChannels, force: force); + } + + Future _syncChannels({int? maxChannels, bool force = false}) async { if (!isConnected) return; if (_isSyncingChannels) { debugPrint('[ChannelSync] Already syncing channels, ignoring request'); @@ -7231,31 +7267,46 @@ class MeshCoreConnector extends ChangeNotifier { } } - Future setChannel(int index, String name, Uint8List psk) async { - if (!isConnected) return; + /// How long a channel write waits for the radio's OK or ERR. (#1026) + @visibleForTesting + Duration channelWriteReplyTimeout = const Duration(seconds: 5); + + int _channelWritesInFlight = 0; + bool _channelSyncDeferredByWrite = false; - // Persisted channel history is keyed by the channel's PSK identity (#194), - // so reassigning this slot to a different channel cannot surface the old - // occupant's messages THERE. Two slot-keyed remnants still can, and both - // are handled when the slot changes occupant (different PSK): - // - legacy slot-index keys (pre-#194) would be adopted onto the new - // occupant by the store's one-time migration; purge them (#193/#1063). - // - the in-memory conversation map is slot-keyed; drop this slot's entry. - // The old occupant's PSK-keyed history is deliberately left intact: if - // that channel is ever re-added (any slot), its history comes back - // (#1063). A rename (same PSK) keeps everything. - final existing = _findChannelByIndex(index); - final sameChannel = existing != null && listEquals(existing.psk, psk); + /// True while the channel list cannot be trusted to show which slots are + /// free: a sync is re-reading it, or a write has not been answered yet. A + /// slot chosen against it could already be taken. (#1021, #1026) + bool get isChannelTableBusy => + _isSyncingChannels || _channelWritesInFlight > 0; - await sendFrame(buildSetChannelFrame(index, name, psk)); + void _beginChannelWrite() => _channelWritesInFlight++; - if (!sameChannel) { - await _channelMessageStore.clearLegacySlotHistory(index); - _channelMessages.remove(index); + /// Asks for a re-read once every channel write has its answer. A writer + /// never starts one itself: another write may still be waiting on the same + /// reply queue. Nested and batched writes therefore re-read once, at the end. + void _syncAfterChannelWrites() => _channelSyncDeferredByWrite = true; + + /// Ends one write; the last one to end runs the sync requested by a writer, + /// or by [getChannels] while writes were waiting for their replies. + void _endChannelWrite() { + _channelWritesInFlight--; + if (_channelWritesInFlight == 0 && _channelSyncDeferredByWrite) { + _channelSyncDeferredByWrite = false; + unawaited(_syncChannels(force: true)); } + } - // Refresh channels after setting - await getChannels(force: true); + /// Runs several channel writes as one, so no sync or other add can start + /// between two of them. Each write inside passes `refresh: false`, and the + /// caller re-reads the list once afterwards. (#1026) + Future batchChannelWrites(Future Function() writes) async { + _beginChannelWrite(); + try { + return await writes(); + } finally { + _endChannelWrite(); + } } /// Writes the client's cached channel list back onto the radio (#1060). @@ -7282,47 +7333,229 @@ class MeshCoreConnector extends ChangeNotifier { tag: 'ChannelSync', ); - var sent = 0; - for (final channel in toRestore) { - if (!isConnected) break; - await sendFrame( - buildSetChannelFrame(channel.index, channel.name, channel.psk), + // Counted as a write in flight for its whole length, so an add made while + // it runs is refused instead of choosing a slot this is about to fill + // (#1021, #1026). + _beginChannelWrite(); + try { + var sent = 0; + for (final channel in toRestore) { + if (!isConnected) break; + await sendFrame( + buildSetChannelFrame(channel.index, channel.name, channel.psk), + ); + sent++; + // Space the writes. On BLE [sendFrame] prefers write-without-response, + // which returns once the frame reaches the OS and not once the radio + // has taken it, so an unpaced loop can overrun the radio and lose + // channels with no error anywhere. The USB branch of [sendFrame] + // already spaces its own frames for exactly this reason; BLE has no + // such pause. + if (sent < toRestore.length) { + await Future.delayed(_channelRestoreFrameGap); + } + } + + // The radio now holds these again, so a fresh sync should confirm them + // and the erased-slot block clears itself on the next pass. + // + // This deliberately does NOT report how many the radio confirmed: + // [getChannels] returns once the first request is away, not once the + // sync has finished, so counting confirmations here would read a list + // the radio has not answered for yet and report 0 every time. The + // authoritative feedback is the erased-slot banner, which is re-derived + // on every sync and therefore stays up if some writes did not land. + _syncAfterChannelWrites(); + return sent; + } finally { + _endChannelWrite(); + } + } + + /// Writes [name] and [psk] into slot [index] and reports what the radio said. + /// + /// [refresh] re-reads the channel list afterwards. A caller writing several + /// channels passes false and refreshes once at the end, because a write sent + /// during a sync cannot tell its reply from the sync's. + Future setChannel( + int index, + String name, + Uint8List psk, { + bool refresh = true, + }) async { + if (!isConnected) return ChannelWrite.noReply; + return _setChannel( + index, + name, + psk, + occupantPsk: _findChannelByIndex(index)?.psk, + refresh: refresh, + ); + } + + /// Writes an edit of [channel]. A rename keeps the key and is a plain write. + /// A new key is clear-then-add: firmware with + /// OffbandMesh/meshcore-firmware#1864 refuses a different channel over an + /// occupied slot, and that is what a new key in place is. + /// + /// A new key is a slot reassignment for history purposes, the same as + /// before the clear-then-add: the old key's PSK-keyed history is kept, so + /// it comes back if that key is ever re-added (#1063). + /// + /// If the clear lands and the add does not, the slot is left empty and this + /// returns [ChannelWrite.clearedNotAdded], so the user is told the channel is + /// gone rather than that the change may not have happened. + Future editChannel( + Channel channel, + String name, + Uint8List psk, + ) async { + if (!isConnected) return ChannelWrite.noReply; + if (listEquals(channel.psk, psk)) { + return _setChannel( + channel.index, + name, + psk, + occupantPsk: channel.psk, + refresh: true, ); - sent++; - // Space the writes. On BLE [sendFrame] prefers write-without-response, - // which returns once the frame reaches the OS and not once the radio has - // taken it, so an unpaced loop can overrun the radio and lose channels - // with no error anywhere. The USB branch of [sendFrame] already spaces - // its own frames for exactly this reason; BLE has no such pause. - if (sent < toRestore.length) { - await Future.delayed(_channelRestoreFrameGap); + } + _beginChannelWrite(); + try { + final cleared = await _writeChannelSlot(channel.index, '', Uint8List(16)); + if (cleared != ChannelWrite.ok) { + _syncAfterChannelWrites(); + return cleared; } + await _retireSlotOccupant(channel.index); + final added = await _setChannel( + channel.index, + name, + psk, + occupantPsk: null, + refresh: true, + ); + return added == ChannelWrite.ok + ? ChannelWrite.ok + : ChannelWrite.clearedNotAdded; + } finally { + _endChannelWrite(); } + } - // The radio now holds these again, so a fresh sync should confirm them and - // the erased-slot block clears itself on the next pass. - // - // This deliberately does NOT report how many the radio confirmed: - // [getChannels] returns once the first request is away, not once the sync - // has finished, so counting confirmations here would read a list the radio - // has not answered for yet and report 0 every time. The authoritative - // feedback is the erased-slot banner, which is re-derived on every sync and - // therefore stays up if some writes did not land. - await getChannels(force: true); - return sent; + Future deleteChannel(int index, {bool refresh = true}) async { + if (!isConnected) return ChannelWrite.noReply; + _beginChannelWrite(); + try { + // A slot is deleted by writing an empty name and a zero PSK. Its history + // goes outright (the true-delete path, #1063), once the radio has said + // OK: a refused delete leaves the channel, and it keeps its history. + final result = await _writeChannelSlot(index, '', Uint8List(16)); + if (result == ChannelWrite.ok) { + await _channelMessageStore.clearChannelMessages(index); + _channelMessages.remove(index); + } + if (refresh) _syncAfterChannelWrites(); + return result; + } finally { + _endChannelWrite(); + } } - Future deleteChannel(int index) async { - if (!isConnected) return; + Future _setChannel( + int index, + String name, + Uint8List psk, { + required Uint8List? occupantPsk, + required bool refresh, + }) async { + _beginChannelWrite(); + try { + // A rename (same PSK) keeps everything; a different PSK retires the + // slot's previous occupant (see [_retireSlotOccupant]). + final sameChannel = occupantPsk != null && listEquals(occupantPsk, psk); + + final result = await _writeChannelSlot(index, name, psk); + + // Only after the radio says OK. A refused write leaves the slot's + // channel in place, and its slot-keyed state has to stay with it. (#1026) + if (result == ChannelWrite.ok && !sameChannel) { + await _retireSlotOccupant(index); + } + + // Re-read on every outcome: after a refusal the list we chose the slot + // from was wrong, and after no reply nobody knows what the slot holds. + if (refresh) _syncAfterChannelWrites(); + return result; + } finally { + _endChannelWrite(); + } + } - // Delete by setting empty name and zero PSK - await sendFrame(buildSetChannelFrame(index, '', Uint8List(16))); - // Clear stored messages for this channel - await _channelMessageStore.clearChannelMessages(index); - // Clear in-memory messages for this channel + /// Sends one `CMD_SET_CHANNEL` and waits for the radio's OK or ERR, using + /// the generic-ack queue the channel-message sends already use. + /// + /// That queue matches replies to commands by order, which holds because the + /// firmware answers commands one at a time in the order they arrive. + Future _writeChannelSlot( + int index, + String name, + Uint8List psk, + ) async { + if (!isConnected) return ChannelWrite.noReply; + final reply = Completer(); + final pending = _PendingCommandAck( + commandCode: cmdSetChannel, + reply: reply, + ); + // Queued before the frame goes out, so a fast reply cannot arrive first. + _pendingGenericAckQueue.add(pending); + try { + await sendFrame(buildSetChannelFrame(index, name, psk)); + } catch (e) { + _pendingGenericAckQueue.remove(pending); + _appDebugLogService?.error( + 'Channel write to slot $index was not sent: $e', + tag: 'ChannelWrite', + ); + return ChannelWrite.noReply; + } + final int? errCode; + try { + errCode = await reply.future.timeout(channelWriteReplyTimeout); + } on TimeoutException { + // Dropped so a late or lost reply cannot be matched to the next command. + _pendingGenericAckQueue.remove(pending); + _appDebugLogService?.warn( + 'Radio did not answer the channel write to slot $index', + tag: 'ChannelWrite', + ); + return ChannelWrite.noReply; + } + if (errCode == null) return ChannelWrite.ok; + _appDebugLogService?.warn( + 'Radio refused the channel write to slot $index (error $errCode)', + tag: 'ChannelWrite', + ); + return errCode == errCodeBadState + ? ChannelWrite.occupied + : ChannelWrite.rejected; + } + + /// Drops the slot-keyed remnants of a slot's previous occupant once the slot + /// has been given to a different channel. + /// + /// Persisted channel history is keyed by the channel's PSK identity (#194), + /// so reassigning this slot to a different channel cannot surface the old + /// occupant's messages THERE. Two slot-keyed remnants still can: + /// - legacy slot-index keys (pre-#194) would be adopted onto the new + /// occupant by the store's one-time migration; purge them (#193/#1063). + /// - the in-memory conversation map is slot-keyed; drop this slot's entry. + /// The old occupant's PSK-keyed history is deliberately left intact: if + /// that channel is ever re-added (any slot), its history comes back (#1063). + Future _retireSlotOccupant(int index) async { + await _channelMessageStore.clearLegacySlotHistory(index); _channelMessages.remove(index); - // Refresh channels after deleting - await getChannels(force: true); } // --- Offband GPS query (CMD_OFFBAND_GPS / RESP_CODE_OFFBAND_GPS = 0xC1) (#135) @@ -8538,6 +8771,7 @@ class MeshCoreConnector extends ChangeNotifier { } final failedAck = _pendingGenericAckQueue.removeAt(0); + failedAck.answer(errCode); if (failedAck.commandCode != cmdSendChannelTxtMsg || failedAck.channelSendQueueId == null) { return; @@ -10518,6 +10752,7 @@ class MeshCoreConnector extends ChangeNotifier { } final pendingAck = _pendingGenericAckQueue.removeAt(0); + pendingAck.answer(null); if (pendingAck.commandCode != cmdSendChannelTxtMsg || pendingAck.channelSendQueueId == null) { return; @@ -12096,7 +12331,20 @@ class _PendingCommandAck { final int commandCode; final String? channelSendQueueId; - _PendingCommandAck({required this.commandCode, this.channelSendQueueId}); + /// Completed with null for OK or with the error code for ERR, for a caller + /// that waits on the reply. (#1026) + final Completer? reply; + + _PendingCommandAck({ + required this.commandCode, + this.channelSendQueueId, + this.reply, + }); + + void answer(int? errCode) { + final waiter = reply; + if (waiter != null && !waiter.isCompleted) waiter.complete(errCode); + } } /// A `0xC5` request waiting for its reply. diff --git a/lib/connector/meshcore_protocol.dart b/lib/connector/meshcore_protocol.dart index f27a9aa9..937dd9a8 100644 --- a/lib/connector/meshcore_protocol.dart +++ b/lib/connector/meshcore_protocol.dart @@ -502,6 +502,11 @@ const int errCodeUnsupportedCmd = 1; /// not hold. (#762) const int errCodeNotFound = 2; +/// `ERR_CODE_BAD_STATE`: e.g. `CMD_SET_CHANNEL` putting a different channel +/// over an occupied slot, which firmware with OffbandMesh/meshcore-firmware#1864 +/// refuses. (#1026) +const int errCodeBadState = 4; + Uint8List buildOffbandBlockAddFrame(Uint8List pubKey) => Uint8List.fromList([cmdOffbandBlock, offbandBlockAdd, ...pubKey]); Uint8List buildOffbandBlockRemoveFrame(Uint8List pubKey) => diff --git a/lib/helpers/channel_slot_decision.dart b/lib/helpers/channel_slot_decision.dart new file mode 100644 index 00000000..ee481a15 --- /dev/null +++ b/lib/helpers/channel_slot_decision.dart @@ -0,0 +1,61 @@ +import '../models/channel.dart'; + +/// Why a channel slot could not be allocated. +enum ChannelSlotRefusal { + /// The channel list is mid-rewrite, so no slot can be trusted to be free. + syncing, + + /// Every slot on the radio is in use. + full, +} + +/// Either a slot that is safe to write, or the reason it was refused. +class ChannelSlotDecision { + const ChannelSlotDecision.slot(int this.slot) : refusal = null; + const ChannelSlotDecision.refused(ChannelSlotRefusal this.refusal) + : slot = null; + + final int? slot; + final ChannelSlotRefusal? refusal; + + bool get isAllowed => slot != null; +} + +/// Decide which channel slot a new channel may occupy (#1021). +/// +/// Pulled out of the channels screen so it can be tested without a widget, and +/// so the QR and config-import paths can share one answer instead of each +/// carrying their own (there were three divergent implementations, and only one +/// of them had the bug). +/// +/// Two refusals, both deliberate: +/// +/// * [isSyncing] true means the connector has emptied its channel list and is +/// refilling it slot by slot. Any index would look free. Choosing one here is +/// what overwrote Public: a slot picked during a sync pointed at an occupied +/// slot by the time it was written. +/// * No free index means the radio is full. The caller must be told, never +/// handed slot 0 as a consolation, which is the old `return 0` bug and is +/// where Public normally lives. +/// +/// Callers pass the connector's `isChannelTableBusy` (a sync, or a write the +/// radio has not answered yet), not `hasLoadedChannels`: the latter stays false +/// after a *failed* sync while the cached list is restored into use, so gating +/// on it would refuse forever on a flaky link. +/// +/// An absent index genuinely means a free slot, because the connector never +/// adds an empty channel to its list. +ChannelSlotDecision decideChannelSlot({ + required List channels, + required int maxChannels, + required bool isSyncing, +}) { + if (isSyncing) { + return const ChannelSlotDecision.refused(ChannelSlotRefusal.syncing); + } + final used = channels.map((c) => c.index).toSet(); + for (var i = 0; i < maxChannels; i++) { + if (!used.contains(i)) return ChannelSlotDecision.slot(i); + } + return const ChannelSlotDecision.refused(ChannelSlotRefusal.full); +} diff --git a/lib/helpers/channel_slot_ui.dart b/lib/helpers/channel_slot_ui.dart new file mode 100644 index 00000000..7df68c6f --- /dev/null +++ b/lib/helpers/channel_slot_ui.dart @@ -0,0 +1,107 @@ +import 'package:flutter/material.dart'; + +import '../connector/meshcore_connector.dart'; +import '../l10n/l10n.dart'; +import 'channel_slot_decision.dart'; +import 'snack_bar_builder.dart'; + +/// A channel slot that is safe to write right now, or null after telling the +/// user why not (#1021). +/// +/// Every surface that adds a channel goes through this one function: the +/// channels screen, the community QR scanner, and anything else that writes a +/// slot. That is deliberate. The bug this fixes existed because the same +/// question ("which slot is free?") was answered three different ways in three +/// files, and only one of them was wrong. One answer cannot drift. +/// +/// Call it at the moment of the write and never earlier. The connector empties +/// its channel list for the duration of a channel sync, and `setChannel` itself +/// starts one, so a slot chosen before a dialog or a confirmation can point at +/// an occupied slot by the time it is written. +/// +/// The owner's ruling is that the unsafe write is blocked but the control stays +/// live: a greyed-out button prevents the damage and tells the user nothing. So +/// a refusal returns null *and* says what is wrong. +int? allocateChannelSlotOrExplain( + BuildContext context, + MeshCoreConnector connector, +) { + final decision = decideChannelSlot( + channels: connector.channels, + maxChannels: connector.maxChannels, + // Not hasLoadedChannels: that stays false after a FAILED sync while the + // cached list is restored, so gating on it would make adding a channel + // impossible on a flaky link. Busy also covers a write the radio has not + // answered yet (#1026): until it does, the list does not show its slot. + isSyncing: connector.isChannelTableBusy, + ); + switch (decision.refusal) { + case ChannelSlotRefusal.syncing: + showChannelBlockedMessage(context, context.l10n.channels_slotBusySyncing); + return null; + case ChannelSlotRefusal.full: + showChannelBlockedMessage( + context, + context.l10n.channels_slotsAllFull(connector.maxChannels), + ); + return null; + case null: + return decision.slot; + } +} + +/// A refusal the user has to be able to read and act on, so it persists until +/// dismissed. +/// +/// `showDismissibleSnackBar` defaults to `persist: false` and a 4 second toast, +/// which SAFELANE 6 rules out for an error. +void showChannelBlockedMessage(BuildContext context, String message) { + showDismissibleSnackBar(context, content: Text(message), persist: true); +} + +/// Explains a channel write the radio did not confirm, and returns true if it +/// did. A caller shows its own success message only when this returns false, +/// so nothing claims success before the radio has said OK (#1026). +/// +/// A success toast shown after this would replace the explanation (a newer +/// toast replaces the visible one), so callers must not show one. +bool explainUnconfirmedChannelWrite(BuildContext context, ChannelWrite result) { + final l10n = context.l10n; + final message = switch (result) { + ChannelWrite.ok => null, + ChannelWrite.occupied => l10n.channels_writeOccupied, + ChannelWrite.rejected => l10n.channels_writeRejected, + ChannelWrite.noReply => l10n.channels_writeNoReply, + ChannelWrite.clearedNotAdded => l10n.channels_writeClearedNotAdded, + }; + if (message == null) return false; + showChannelBlockedMessage(context, message); + return true; +} + +/// Refuses a second Public channel, and says so. Returns true if it refused. +/// +/// Public is identified by its PSK (`Channel.isPublicChannel`), not by slot 0, +/// so it can live in any slot and this is the only duplicate check it needs. +bool refusePublicAlreadyOnRadio( + BuildContext context, + MeshCoreConnector connector, +) { + if (!connector.channels.any((c) => c.isPublicChannel)) return false; + showChannelBlockedMessage(context, context.l10n.channels_publicAlreadyAdded); + return true; +} + +/// For an edit or delete: refuses while the channel list is being re-read or +/// a write is unanswered, and says so. Returns true if it refused. +/// +/// Replies are matched to commands by order, so a write sent during a sync +/// could take one of the sync's replies as its own. +bool refuseWhileChannelTableBusy( + BuildContext context, + MeshCoreConnector connector, +) { + if (!connector.isChannelTableBusy) return false; + showChannelBlockedMessage(context, context.l10n.channels_slotBusySyncing); + return true; +} diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index c9584788..6f47574b 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -1032,6 +1032,32 @@ } }, "channels_publicChannelAdded": "Public channel added", + "channels_slotBusySyncing": "The radio is still updating its channel list. Try again in a moment.", + "channels_slotsAllFull": "All {count} channel slots are in use. Delete a channel first.", + "@channels_slotsAllFull": { + "placeholders": { + "count": { + "type": "int" + } + } + }, + "channels_publicAlreadyAdded": "The Public channel is already on this radio.", + "channels_writeOccupied": "The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.", + "@channels_writeOccupied": { + "description": "The radio refused a channel write because a different channel holds the slot (ERR_CODE_BAD_STATE, firmware #1864). Persistent (#1026)." + }, + "channels_writeRejected": "The radio refused the change, so the channel is as it was.", + "@channels_writeRejected": { + "description": "The radio answered a channel write with an error other than slot-occupied. Persistent (#1026)." + }, + "channels_writeNoReply": "The radio did not confirm the change. Check the channel list before trying again.", + "@channels_writeNoReply": { + "description": "A channel write got no reply before the timeout, or the radio is not connected; it may or may not have landed. Persistent (#1026)." + }, + "channels_writeClearedNotAdded": "The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.", + "@channels_writeClearedNotAdded": { + "description": "A channel key change is clear-then-add; the clear landed and the add did not, so the edited channel is gone from the radio. Persistent (#1026)." + }, "channels_sortBy": "Sort by", "channels_sortManual": "Manual", "channels_sortAZ": "A-Z", @@ -2514,7 +2540,6 @@ "channels_scanQrDesc": "Add a community or channel from a QR code", "channels_scanQrInstructions": "Point at a MeshCore QR code", "channels_invalidQr": "Invalid QR code", - "channels_noFreeSlot": "No free channel slot", "channels_qrAddConfirm": "Add channel \"{name}\"?", "@channels_qrAddConfirm": { "placeholders": { @@ -3405,6 +3430,10 @@ "@importConfig_reasonNoFreeSlot": { "description": "Skip reason: every channel slot is occupied (#576)." }, + "importConfig_reasonChannelsSyncing": "channels were still being read from the radio; import again in a moment", + "@importConfig_reasonChannelsSyncing": { + "description": "Skip reason: the channel list was mid-sync, so no slot could be trusted to be free (#1021)." + }, "importConfig_reasonAbsentFromFile": "not present in this file", "@importConfig_reasonAbsentFromFile": { "description": "Failure reason: the file did not contain the section (#576)." diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index ef8aa1f4..95cec203 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -3232,6 +3232,48 @@ abstract class AppLocalizations { /// **'Public channel added'** String get channels_publicChannelAdded; + /// No description provided for @channels_slotBusySyncing. + /// + /// In en, this message translates to: + /// **'The radio is still updating its channel list. Try again in a moment.'** + String get channels_slotBusySyncing; + + /// No description provided for @channels_slotsAllFull. + /// + /// In en, this message translates to: + /// **'All {count} channel slots are in use. Delete a channel first.'** + String channels_slotsAllFull(int count); + + /// No description provided for @channels_publicAlreadyAdded. + /// + /// In en, this message translates to: + /// **'The Public channel is already on this radio.'** + String get channels_publicAlreadyAdded; + + /// The radio refused a channel write because a different channel holds the slot (ERR_CODE_BAD_STATE, firmware #1864). Persistent (#1026). + /// + /// In en, this message translates to: + /// **'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'** + String get channels_writeOccupied; + + /// The radio answered a channel write with an error other than slot-occupied. Persistent (#1026). + /// + /// In en, this message translates to: + /// **'The radio refused the change, so the channel is as it was.'** + String get channels_writeRejected; + + /// A channel write got no reply before the timeout, or the radio is not connected; it may or may not have landed. Persistent (#1026). + /// + /// In en, this message translates to: + /// **'The radio did not confirm the change. Check the channel list before trying again.'** + String get channels_writeNoReply; + + /// A channel key change is clear-then-add; the clear landed and the add did not, so the edited channel is gone from the radio. Persistent (#1026). + /// + /// In en, this message translates to: + /// **'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'** + String get channels_writeClearedNotAdded; + /// No description provided for @channels_sortBy. /// /// In en, this message translates to: @@ -7496,12 +7538,6 @@ abstract class AppLocalizations { /// **'Invalid QR code'** String get channels_invalidQr; - /// No description provided for @channels_noFreeSlot. - /// - /// In en, this message translates to: - /// **'No free channel slot'** - String get channels_noFreeSlot; - /// No description provided for @channels_qrAddConfirm. /// /// In en, this message translates to: @@ -9496,6 +9532,12 @@ abstract class AppLocalizations { /// **'no free channel slot on the device'** String get importConfig_reasonNoFreeSlot; + /// Skip reason: the channel list was mid-sync, so no slot could be trusted to be free (#1021). + /// + /// In en, this message translates to: + /// **'channels were still being read from the radio; import again in a moment'** + String get importConfig_reasonChannelsSyncing; + /// Failure reason: the file did not contain the section (#576). /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index 90863dd3..9a1b3536 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -1833,6 +1833,35 @@ class AppLocalizationsBg extends AppLocalizations { @override String get channels_publicChannelAdded => 'Публичен канал добавен'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => 'Сортирай по'; @@ -4410,9 +4439,6 @@ class AppLocalizationsBg extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5639,6 +5665,10 @@ class AppLocalizationsBg extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index 4783561f..28b102e3 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -1828,6 +1828,35 @@ class AppLocalizationsDe extends AppLocalizations { @override String get channels_publicChannelAdded => 'Öffentlicher Kanal hinzugefügt'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => 'Sortiere nach'; @@ -4416,9 +4445,6 @@ class AppLocalizationsDe extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5656,6 +5682,10 @@ class AppLocalizationsDe extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 55cc9ca7..be9702e2 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -1806,6 +1806,35 @@ class AppLocalizationsEn extends AppLocalizations { @override String get channels_publicChannelAdded => 'Public channel added'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => 'Sort by'; @@ -4347,9 +4376,6 @@ class AppLocalizationsEn extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5562,6 +5588,10 @@ class AppLocalizationsEn extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index 755a8e4c..153c50dd 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -1829,6 +1829,35 @@ class AppLocalizationsEs extends AppLocalizations { @override String get channels_publicChannelAdded => 'Canal público añadido'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => 'Ordenar por'; @@ -4405,9 +4434,6 @@ class AppLocalizationsEs extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5644,6 +5670,10 @@ class AppLocalizationsEs extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index 554ef261..a91f95be 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -1834,6 +1834,35 @@ class AppLocalizationsFr extends AppLocalizations { @override String get channels_publicChannelAdded => 'Le canal public a été ajouté'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => 'Trier par'; @@ -4427,9 +4456,6 @@ class AppLocalizationsFr extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5672,6 +5698,10 @@ class AppLocalizationsFr extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index 75dce93e..c3923965 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -1834,6 +1834,35 @@ class AppLocalizationsHu extends AppLocalizations { @override String get channels_publicChannelAdded => 'A nyilvános csatorna hozzáadva'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => 'Szűrés'; @@ -4422,9 +4451,6 @@ class AppLocalizationsHu extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5661,6 +5687,10 @@ class AppLocalizationsHu extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index c009c111..256dd7cb 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -1831,6 +1831,35 @@ class AppLocalizationsIt extends AppLocalizations { @override String get channels_publicChannelAdded => 'Canale pubblico aggiunto'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => 'Ordina per'; @@ -4410,9 +4439,6 @@ class AppLocalizationsIt extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5649,6 +5675,10 @@ class AppLocalizationsIt extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index afb53252..64b5e75a 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -1772,6 +1772,35 @@ class AppLocalizationsJa extends AppLocalizations { @override String get channels_publicChannelAdded => 'パブリックチャンネルが追加されました'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => '並び替え'; @@ -4224,9 +4253,6 @@ class AppLocalizationsJa extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5415,6 +5441,10 @@ class AppLocalizationsJa extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index bc4cdf39..52c18a85 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -1767,6 +1767,35 @@ class AppLocalizationsKo extends AppLocalizations { @override String get channels_publicChannelAdded => '공개 채널 추가'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => '정렬 기준 선택'; @@ -4226,9 +4255,6 @@ class AppLocalizationsKo extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5416,6 +5442,10 @@ class AppLocalizationsKo extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index 5b0d9b3b..7ba0f3ab 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -1819,6 +1819,35 @@ class AppLocalizationsNl extends AppLocalizations { @override String get channels_publicChannelAdded => 'Open kanaal toegevoegd'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => 'Sorteren door'; @@ -4391,9 +4420,6 @@ class AppLocalizationsNl extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5624,6 +5650,10 @@ class AppLocalizationsNl extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index c209edc4..adbdba82 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -1840,6 +1840,35 @@ class AppLocalizationsPl extends AppLocalizations { @override String get channels_publicChannelAdded => 'Kanał publiczny dodany'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => 'Sortuj po'; @@ -4423,9 +4452,6 @@ class AppLocalizationsPl extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5661,6 +5687,10 @@ class AppLocalizationsPl extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index f63eb395..aba7e8b2 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -1828,6 +1828,35 @@ class AppLocalizationsPt extends AppLocalizations { @override String get channels_publicChannelAdded => 'Canal público adicionado'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => 'Ordenar por'; @@ -4404,9 +4433,6 @@ class AppLocalizationsPt extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5637,6 +5663,10 @@ class AppLocalizationsPt extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index f6f00478..06fe6abc 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -1829,6 +1829,35 @@ class AppLocalizationsRu extends AppLocalizations { @override String get channels_publicChannelAdded => 'Публичный канал добавлен'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => 'Сортировка'; @@ -4412,9 +4441,6 @@ class AppLocalizationsRu extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5655,6 +5681,10 @@ class AppLocalizationsRu extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 076a7d9f..035a572a 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -1820,6 +1820,35 @@ class AppLocalizationsSk extends AppLocalizations { @override String get channels_publicChannelAdded => 'Veľký kanál pridaný'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => 'Triediť podľa'; @@ -4391,9 +4420,6 @@ class AppLocalizationsSk extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5621,6 +5647,10 @@ class AppLocalizationsSk extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index dd594b0f..a6ba1ce0 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -1817,6 +1817,35 @@ class AppLocalizationsSl extends AppLocalizations { @override String get channels_publicChannelAdded => 'javna skupnost dodana'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => 'Sortiraj po'; @@ -4386,9 +4415,6 @@ class AppLocalizationsSl extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5619,6 +5645,10 @@ class AppLocalizationsSl extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index c803fb43..fad12bcf 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -1809,6 +1809,35 @@ class AppLocalizationsSv extends AppLocalizations { @override String get channels_publicChannelAdded => 'Allmänt kanal tillagd'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => 'Sortera efter'; @@ -4366,9 +4395,6 @@ class AppLocalizationsSv extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5594,6 +5620,10 @@ class AppLocalizationsSv extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index aeade4c7..9c3dfb30 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -1824,6 +1824,35 @@ class AppLocalizationsUk extends AppLocalizations { @override String get channels_publicChannelAdded => 'Публічний канал додано'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => 'Сортувати за'; @@ -4408,9 +4437,6 @@ class AppLocalizationsUk extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5656,6 +5682,10 @@ class AppLocalizationsUk extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index b5f19995..348f8e1d 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -1753,6 +1753,35 @@ class AppLocalizationsZh extends AppLocalizations { @override String get channels_publicChannelAdded => '已添加公共频道'; + @override + String get channels_slotBusySyncing => + 'The radio is still updating its channel list. Try again in a moment.'; + + @override + String channels_slotsAllFull(int count) { + return 'All $count channel slots are in use. Delete a channel first.'; + } + + @override + String get channels_publicAlreadyAdded => + 'The Public channel is already on this radio.'; + + @override + String get channels_writeOccupied => + 'The radio refused: another channel already uses that slot, and it was left unchanged. Try again now that the list has been re-read.'; + + @override + String get channels_writeRejected => + 'The radio refused the change, so the channel is as it was.'; + + @override + String get channels_writeNoReply => + 'The radio did not confirm the change. Check the channel list before trying again.'; + + @override + String get channels_writeClearedNotAdded => + 'The old channel was removed, but the radio did not confirm the new one, so that slot is now empty. Add the channel again.'; + @override String get channels_sortBy => '排序方式'; @@ -4129,9 +4158,6 @@ class AppLocalizationsZh extends AppLocalizations { @override String get channels_invalidQr => 'Invalid QR code'; - @override - String get channels_noFreeSlot => 'No free channel slot'; - @override String channels_qrAddConfirm(String name) { return 'Add channel \"$name\"?'; @@ -5289,6 +5315,10 @@ class AppLocalizationsZh extends AppLocalizations { String get importConfig_reasonNoFreeSlot => 'no free channel slot on the device'; + @override + String get importConfig_reasonChannelsSyncing => + 'channels were still being read from the radio; import again in a moment'; + @override String get importConfig_reasonAbsentFromFile => 'not present in this file'; diff --git a/lib/screens/channels_screen.dart b/lib/screens/channels_screen.dart index 3d0e983c..cb2d8958 100644 --- a/lib/screens/channels_screen.dart +++ b/lib/screens/channels_screen.dart @@ -30,6 +30,7 @@ import '../widgets/channel_notify_mode.dart'; import '../widgets/radio_channel_notify.dart'; import '../widgets/radio_tone.dart'; import '../widgets/battery_optimization_banner.dart'; +import '../helpers/channel_slot_ui.dart'; import '../helpers/snack_bar_builder.dart'; import 'channel_chat_screen.dart'; import 'community_qr_scanner_screen.dart'; @@ -814,10 +815,10 @@ class _ChannelsScreenState extends State void _showAddChannelDialog(BuildContext context) { final connector = context.read(); - final nextIndex = _findNextAvailableIndex( - connector.channels, - connector.maxChannels, - ); + // No slot is chosen here. It used to be, and that was the bug: the channel + // list is emptied for the duration of a sync, so an index picked when this + // dialog opened could point at an occupied slot by the time Add was + // pressed. Each handler now calls _allocateChannelSlot at the write (#1021). final hasPublicChannel = connector.channels.any((c) => c.isPublicChannel); int? selectedOption; final nameController = TextEditingController(); @@ -920,28 +921,44 @@ class _ChannelsScreenState extends State ); return; } + final slot = _allocateChannelSlot( + dialogContext, + connector, + ); + // Refused: leave the dialog open so the user + // can retry once the sync finishes. + if (slot == null) return; final random = Random.secure(); final psk = Uint8List(16); for (int i = 0; i < 16; i++) { psk[i] = random.nextInt(256); } Navigator.pop(dialogContext); - await connector.setChannel( - nextIndex, + final result = await connector.setChannel( + slot, name, psk, ); - await channelMessageStore.clearChannelMessages( - nextIndex, - ); - if (context.mounted) { - showDismissibleSnackBar( - context, - content: Text( - context.l10n.channels_channelAdded(name), - ), - ); + // Only on OK: a refused write leaves another + // channel in this slot, and this would wipe + // that channel's history (#1026). + if (result == ChannelWrite.ok) { + await channelMessageStore + .clearChannelMessages(slot); } + if (!context.mounted) return; + if (explainUnconfirmedChannelWrite( + context, + result, + )) { + return; + } + showDismissibleSnackBar( + context, + content: Text( + context.l10n.channels_channelAdded(name), + ), + ); }, child: Text(dialogContext.l10n.common_create), ), @@ -988,7 +1005,7 @@ class _ChannelsScreenState extends State children: [ Expanded( child: FilledButton( - onPressed: () { + onPressed: () async { final name = nameController.text.trim(); final pskHex = pskController.text.trim(); if (name.isEmpty) { @@ -1016,16 +1033,30 @@ class _ChannelsScreenState extends State ); return; } + final slot = _allocateChannelSlot( + dialogContext, + connector, + ); + if (slot == null) return; Navigator.pop(dialogContext); - connector.setChannel(nextIndex, name, psk); - if (context.mounted) { - showDismissibleSnackBar( - context, - content: Text( - context.l10n.channels_channelAdded(name), - ), - ); + final result = await connector.setChannel( + slot, + name, + psk, + ); + if (!context.mounted) return; + if (explainUnconfirmedChannelWrite( + context, + result, + )) { + return; } + showDismissibleSnackBar( + context, + content: Text( + context.l10n.channels_channelAdded(name), + ), + ); }, child: Text(dialogContext.l10n.common_add), ), @@ -1046,20 +1077,34 @@ class _ChannelsScreenState extends State children: [ Expanded( child: FilledButton( - onPressed: () { + onPressed: () async { + final slot = _allocateChannelSlot( + dialogContext, + connector, + ); + if (slot == null) return; final psk = Channel.parsePskHex( Channel.publicChannelPsk, ); Navigator.pop(dialogContext); - connector.setChannel(nextIndex, 'Public', psk); - if (context.mounted) { - showDismissibleSnackBar( - context, - content: Text( - context.l10n.channels_publicChannelAdded, - ), - ); + final result = await connector.setChannel( + slot, + 'Public', + psk, + ); + if (!context.mounted) return; + if (explainUnconfirmedChannelWrite( + context, + result, + )) { + return; } + showDismissibleSnackBar( + context, + content: Text( + context.l10n.channels_publicChannelAdded, + ), + ); }, child: Text(dialogContext.l10n.common_add), ), @@ -1229,24 +1274,38 @@ class _ChannelsScreenState extends State _loadCommunities(); } + // The screen's context, not the dialog's: the + // hashtag store write above is awaited, so the + // dialog may already be gone by here. + if (!context.mounted) return; + final slot = _allocateChannelSlot( + context, + connector, + ); + if (slot == null) return; if (dialogContext.mounted) { Navigator.pop(dialogContext); } - connector.setChannel( - nextIndex, + final result = await connector.setChannel( + slot, channelName, psk, ); - if (context.mounted) { - showDismissibleSnackBar( - context, - content: Text( - context.l10n.channels_channelAdded( - channelName, - ), - ), - ); + if (!context.mounted) return; + if (explainUnconfirmedChannelWrite( + context, + result, + )) { + return; } + showDismissibleSnackBar( + context, + content: Text( + context.l10n.channels_channelAdded( + channelName, + ), + ), + ); }, child: Text(dialogContext.l10n.common_add), ), @@ -1355,19 +1414,25 @@ class _ChannelsScreenState extends State // Save to store await _communityStore.addCommunity(community); - // Optionally add the community public channel to the device - if (addPublicChannel) { - final psk = community - .deriveCommunityPublicPsk(); - final channelName = - '${community.name} Public'; - connector.setChannel( - nextIndex, - channelName, - psk, + // Optionally add the community public channel to the device. + // The community itself is already saved above, + // so a refused slot skips only the channel + // write and never loses the community. Uses the + // screen's context, not the dialog's: this runs + // after an await and the dialog may be gone. + int? slot; + var channelRefused = false; + if (addPublicChannel && context.mounted) { + slot = _allocateChannelSlot( + context, + connector, ); + channelRefused = slot == null; } + // Closed before the write, which now waits for + // the radio: an open dialog would let a second + // tap create the community twice. if (dialogContext.mounted) { Navigator.pop(dialogContext); } @@ -1375,13 +1440,34 @@ class _ChannelsScreenState extends State // Refresh communities list _loadCommunities(); - if (context.mounted) { - showDismissibleSnackBar( - context, - content: Text( - context.l10n.community_created(name), - ), + if (slot != null) { + final result = await connector.setChannel( + slot, + '${community.name} Public', + community.deriveCommunityPublicPsk(), ); + if (context.mounted) { + channelRefused = + explainUnconfirmedChannelWrite( + context, + result, + ); + } + } + + if (context.mounted) { + // A refusal's message is showing and + // persists; this toast would replace it + // (#1026). The QR below still shows: the + // community was created either way. + if (!channelRefused) { + showDismissibleSnackBar( + context, + content: Text( + context.l10n.community_created(name), + ), + ); + } // Show QR code dialog await QrCodeShareDialog.show( @@ -1661,12 +1747,18 @@ class _ChannelsScreenState extends State return; } + // Checked first: mid-sync the list is empty, so the identity + // check below would close the dialog and blame a changed + // channel. This keeps the dialog, and the user's edits, open + // and gives the real reason (#1021, #1026). + if (refuseWhileChannelTableBusy(dialogContext, connector)) { + return; + } // #1103 review: this dialog captured the channel when it // opened. If a sync replaced the slot's identity meanwhile // (the #1060 class), writing by the captured index would hit // the NEW occupant with the OLD dialog's rules. Refuse the - // write and say why; mid-sync the list is empty, so this - // also fails closed while slots are unconfirmed. + // write and say why. final live = connector.channels.cast().firstWhere( (c) => c?.index == channel.index, orElse: () => null, @@ -1702,7 +1794,16 @@ class _ChannelsScreenState extends State Navigator.pop(dialogContext); try { - await connector.setChannel(channel.index, name, psk); + final result = await connector.editChannel( + channel, + name, + psk, + ); + if (result != ChannelWrite.ok) { + if (!context.mounted) return; + explainUnconfirmedChannelWrite(context, result); + return; + } await connector.setChannelCyr2LatEnabled( channel.index, cyr2latEnabled, @@ -1770,6 +1871,10 @@ class _ChannelsScreenState extends State ), ); if (confirmed != true) return; + // Its writes share the reply queue with any sync or other channel write, + // so like every channel write it waits for a quiet table (#1026). + if (!context.mounted) return; + if (refuseWhileChannelTableBusy(context, connector)) return; final written = await connector.restoreChannelsToRadio(); if (!context.mounted) return; @@ -1804,13 +1909,21 @@ class _ChannelsScreenState extends State ), TextButton( onPressed: () async { + if (refuseWhileChannelTableBusy(dialogContext, connector)) { + return; + } Navigator.pop(dialogContext); try { - await connector.deleteChannel(channel.index); + final result = await connector.deleteChannel(channel.index); - await channelMessageStore.clearChannelMessages(channel.index); + // Only on OK: if the radio kept the channel, it keeps its + // history too (#1026). + if (result == ChannelWrite.ok) { + await channelMessageStore.clearChannelMessages(channel.index); + } if (!context.mounted) return; + if (explainUnconfirmedChannelWrite(context, result)) return; showDismissibleSnackBar( context, @@ -1842,22 +1955,35 @@ class _ChannelsScreenState extends State ); } - void _addPublicChannel(BuildContext context, MeshCoreConnector connector) { + Future _addPublicChannel( + BuildContext context, + MeshCoreConnector connector, + ) async { + // This used to write slot 0 unconditionally, with no occupancy check, so + // it overwrote whatever was there (#1021). Public is identified by its PSK + // (`Channel.isPublicChannel`), not by its index, so it has no claim on + // slot 0 and can live anywhere. + if (refusePublicAlreadyOnRadio(context, connector)) return; + final slot = _allocateChannelSlot(context, connector); + if (slot == null) return; final psk = Channel.parsePskHex(Channel.publicChannelPsk); - connector.setChannel(0, 'Public', psk); + final result = await connector.setChannel(slot, 'Public', psk); + if (!context.mounted) return; + if (explainUnconfirmedChannelWrite(context, result)) return; showDismissibleSnackBar( context, content: Text(context.l10n.channels_publicChannelAdded), ); } - int _findNextAvailableIndex(List channels, int maxChannels) { - final usedIndices = channels.map((c) => c.index).toSet(); - for (int i = 0; i < maxChannels; i++) { - if (!usedIndices.contains(i)) return i; - } - return 0; - } + /// Thin alias for the shared allocator, kept so the five call sites in this + /// file read the same as before. The logic lives in + /// `helpers/channel_slot_ui.dart` so this screen, the QR scanner and config + /// import all answer "which slot is free?" the same way (#1021). + int? _allocateChannelSlot( + BuildContext context, + MeshCoreConnector connector, + ) => allocateChannelSlotOrExplain(context, connector); void _showManageCommunitiesDialog(BuildContext context) { showModalBottomSheet( @@ -2064,23 +2190,44 @@ class _ChannelsScreenState extends State ), TextButton( onPressed: () async { + if (communityChannels.isNotEmpty && + refuseWhileChannelTableBusy(dialogContext, connector)) { + return; + } Navigator.pop(dialogContext); - // Delete all community channels from the device - for (final channel in communityChannels) { - await connector.deleteChannel(channel.index); + // Delete all community channels from the device. Each delete is + // answered before the next goes out, and the list is re-read + // once at the end. A sync between two deletes would share their + // reply queue, so the loop runs as one batch (#1026). + final failure = await connector.batchChannelWrites(() async { + ChannelWrite? first; + for (final channel in communityChannels) { + final result = await connector.deleteChannel( + channel.index, + refresh: false, + ); + if (result != ChannelWrite.ok) first ??= result; + } + return first; + }); + if (communityChannels.isNotEmpty) { + await connector.getChannels(force: true); } // Remove community from store await _communityStore.removeCommunity(community.id); _loadCommunities(); - if (context.mounted) { - showDismissibleSnackBar( - context, - content: Text(context.l10n.community_deleted(community.name)), - ); + if (!context.mounted) return; + if (failure != null && + explainUnconfirmedChannelWrite(context, failure)) { + return; } + showDismissibleSnackBar( + context, + content: Text(context.l10n.community_deleted(community.name)), + ); }, child: Text( dialogContext.l10n.community_delete, diff --git a/lib/screens/community_qr_scanner_screen.dart b/lib/screens/community_qr_scanner_screen.dart index 289edce7..bce2865e 100644 --- a/lib/screens/community_qr_scanner_screen.dart +++ b/lib/screens/community_qr_scanner_screen.dart @@ -9,6 +9,7 @@ import '../models/community.dart'; import '../storage/community_store.dart'; import '../widgets/adaptive_app_bar_title.dart'; import '../widgets/qr_scanner_widget.dart'; +import '../helpers/channel_slot_ui.dart'; import '../helpers/snack_bar_builder.dart'; /// Screen for scanning community QR codes to join communities. @@ -224,24 +225,41 @@ class _CommunityQrScannerScreenState extends State { _communityStore.setPublicKeyHex = connector.selfPublicKeyHex; await _communityStore.addCommunity(community); - // Optionally add the community public channel to the device + // Optionally add the community public channel to the device. The + // community is already saved above, so a refused slot only skips the + // channel; it never loses the community. + // + // This used to skip the channel silently when the radio was full and then + // show a green "joined" toast, which told the user everything had worked + // when the channel had not been added (#1021). A refusal, or a write the + // radio did not confirm (#1026), now explains itself, and only a confirmed + // write shows the green confirmation. + var channelRefused = false; if (addPublicChannel && context.mounted) { final connector = context.read(); - final nextIndex = _findNextAvailableChannelIndex(connector); - - if (nextIndex != null) { + final slot = allocateChannelSlotOrExplain(context, connector); + if (slot == null) { + channelRefused = true; + } else { final psk = community.deriveCommunityPublicPsk(); final channelName = '${community.name} Public'; - connector.setChannel(nextIndex, channelName, psk); + final result = await connector.setChannel(slot, channelName, psk); + if (context.mounted) { + channelRefused = explainUnconfirmedChannelWrite(context, result); + } } } if (context.mounted) { - showDismissibleSnackBar( - context, - content: Text(context.l10n.community_joined(community.name)), - backgroundColor: Colors.green, - ); + // The refusal message is already showing and persists; a green toast + // on top of it would contradict it. + if (!channelRefused) { + showDismissibleSnackBar( + context, + content: Text(context.l10n.community_joined(community.name)), + backgroundColor: Colors.green, + ); + } // Return to previous screen Navigator.pop(context, community); @@ -271,17 +289,11 @@ class _CommunityQrScannerScreenState extends State { } return; } - final nextIndex = _findNextAvailableChannelIndex(connector); - if (nextIndex == null) { - if (context.mounted) { - showDismissibleSnackBar( - context, - content: Text(context.l10n.channels_noFreeSlot), - backgroundColor: Colors.red, - ); - } - return; - } + // No slot is chosen here. It used to be, and that is the same bug the + // channels screen had: the index was picked before the confirmation + // dialog below and written after it, so a channel sync during the + // confirmation (a channel write starts one) could leave it pointing at + // an occupied slot. The slot is now chosen after the user confirms. if (!context.mounted) return; final confirmed = await showDialog( context: context, @@ -301,7 +313,18 @@ class _CommunityQrScannerScreenState extends State { ), ); if (confirmed == true && context.mounted) { - connector.setChannel(nextIndex, channel.name, channel.psk); + final slot = allocateChannelSlotOrExplain(context, connector); + // Refused: the persistent message explains why. Stay on this screen so + // the user can retry, rather than popping away from the explanation. + if (slot == null) return; + final result = await connector.setChannel( + slot, + channel.name, + channel.psk, + ); + if (!context.mounted) return; + // Not confirmed: stay on this screen with the explanation showing. + if (explainUnconfirmedChannelWrite(context, result)) return; showDismissibleSnackBar( context, content: Text(context.l10n.channels_qrAdded(channel.name)), @@ -312,12 +335,4 @@ class _CommunityQrScannerScreenState extends State { Navigator.pop(context); } } - - int? _findNextAvailableChannelIndex(MeshCoreConnector connector) { - final usedIndices = connector.channels.map((c) => c.index).toSet(); - for (int i = 0; i < connector.maxChannels; i++) { - if (!usedIndices.contains(i)) return i; - } - return null; - } } diff --git a/lib/screens/import_config_screen.dart b/lib/screens/import_config_screen.dart index 5f44f8ad..27f86520 100644 --- a/lib/screens/import_config_screen.dart +++ b/lib/screens/import_config_screen.dart @@ -323,6 +323,8 @@ String _reasonText(BuildContext context, StockConfigImportIssue reason) { return l10n.importConfig_reasonAlreadyPresent; case StockConfigImportIssue.noFreeSlot: return l10n.importConfig_reasonNoFreeSlot; + case StockConfigImportIssue.channelsSyncing: + return l10n.importConfig_reasonChannelsSyncing; case StockConfigImportIssue.notWritable: return l10n.importConfig_reasonNotWritable; } diff --git a/lib/services/stock_config_import_service.dart b/lib/services/stock_config_import_service.dart index 9f2db4a2..425d7f12 100644 --- a/lib/services/stock_config_import_service.dart +++ b/lib/services/stock_config_import_service.dart @@ -47,6 +47,10 @@ enum StockConfigImportIssue { /// Every channel slot on the device is occupied. noFreeSlot, + /// The channel list was being re-read from the radio, so no slot could be + /// trusted to be free. Importing again once it finishes will work (#1021). + channelsSyncing, + /// We have no supported way to write this value to the device. notWritable, } @@ -70,8 +74,9 @@ class StockConfigImportResult { /// Sections whose commands were **sent** to the device without error. /// - /// This is not device confirmation. Apart from the identity import, which - /// waits for a real OK or ERR, the firmware's generic OK for these commands + /// This is not device confirmation. Apart from the identity import and the + /// channel writes, which wait for a real OK or ERR, the firmware's generic OK + /// for these commands /// is not currently awaited, so a frame lost or refused after it left our /// side would still land here. Wiring per-command confirmation is tracked /// separately; until then this set means "sent", and the UI says so rather @@ -88,7 +93,9 @@ class StockConfigImportResult { /// send count and not a confirmed count. final int contactsWritten; - /// Channels whose write command was sent. Same caveat as [contactsWritten]. + /// Channels the radio confirmed writing. Unlike [contactsWritten] this is a + /// confirmed count: a channel write waits for the radio's OK, and one it + /// refused or never answered is in [skippedChannels] instead (#1026). final int channelsAdded; bool get isComplete => failed.isEmpty && skippedChannels.isEmpty; @@ -274,16 +281,41 @@ class StockConfigImportService { existing: _connector.channels, incoming: incoming, maxChannels: _connector.maxChannels, + isSyncing: _connector.isChannelTableBusy, ); - for (final assignment in plan.assignments) { - await _connector.setChannel( - assignment.slot, - assignment.channel.name, - assignment.channel.secret, - ); + // Each write is answered before the next goes out, and the list is + // re-read once at the end. A sync between two writes would share their + // reply queue, where a write's reply cannot be told from the sync's, so + // the whole loop runs as one batch (#1026). + final added = await _connector.batchChannelWrites(() async { + var count = 0; + for (final assignment in plan.assignments) { + final result = await _connector.setChannel( + assignment.slot, + assignment.channel.name, + assignment.channel.secret, + refresh: false, + ); + if (result == ChannelWrite.ok) { + count++; + } else { + skipped.add( + SkippedChannel( + assignment.channel.name, + result == ChannelWrite.noReply + ? StockConfigImportIssue.noReply + : StockConfigImportIssue.rejected, + ), + ); + } + } + return count; + }); + if (plan.assignments.isNotEmpty) { + await _connector.getChannels(force: true); } skipped.addAll(plan.skipped); - return plan.assignments.length; + return added; } /// Upserts every contact. The firmware's add-or-update command keys on the @@ -357,11 +389,25 @@ class ChannelImportPlan { /// New channels go into the lowest free slot. Stock's file has no index field, /// so incoming order is the only ordering information there is, and slots /// already occupied are left alone. +/// +/// While [isSyncing] is true nothing is planned. The connector empties its +/// channel list for the duration of a sync, so [existing] would look empty and +/// every incoming channel would be written over slots that are in fact +/// occupied, Public included (#1021). Each channel is reported as skipped +/// instead, so the user sees why and can import again. [isSyncing] is required +/// so a caller cannot forget it and get the unsafe behavior by default. ChannelImportPlan planChannelImport({ required List existing, required List incoming, required int maxChannels, + required bool isSyncing, }) { + if (isSyncing) { + return ChannelImportPlan(const [], [ + for (final channel in incoming) + SkippedChannel(channel.name, StockConfigImportIssue.channelsSyncing), + ]); + } final live = existing.where((c) => !c.isEmpty).toList(); final takenSlots = live.map((c) => c.index).toSet(); final psks = live.map((c) => c.pskHex).toSet(); diff --git a/test/connector/channel_write_history_identity_test.dart b/test/connector/channel_write_history_identity_test.dart new file mode 100644 index 00000000..a1e3dc78 --- /dev/null +++ b/test/connector/channel_write_history_identity_test.dart @@ -0,0 +1,128 @@ +// #1026 on top of #1063: what a confirmed channel write does to PSK-keyed +// history. +// +// History is keyed by the channel's PSK (#194). Giving a slot to a different +// channel is a reassignment: the old channel's history is kept, so it comes +// back if that channel is ever re-added (#1063). Deleting a channel is the one +// path that removes its history outright. Both happen only after the radio's +// OK (#1026). Exercised through the real store, not the in-memory map. + +import 'dart:typed_data'; + +import 'package:drift/native.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/connector/meshcore_connector.dart'; +import 'package:meshcore_open/connector/meshcore_protocol.dart'; +import 'package:meshcore_open/models/channel.dart'; +import 'package:meshcore_open/models/channel_message.dart'; +import 'package:meshcore_open/storage/channel_message_store.dart'; +import 'package:meshcore_open/storage/drift/blob_store.dart'; +import 'package:meshcore_open/storage/drift/offband_database.dart'; +import 'package:meshcore_open/storage/prefs_manager.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +Uint8List psk(int fill) => Uint8List.fromList(List.filled(16, fill)); + +List channelInfo(int index, String name, Uint8List key) => [ + respCodeChannelInfo, + index, + ...name.codeUnits, + ...List.filled(32 - name.length, 0), + ...key, +]; + +ChannelMessage msg(String text) => ChannelMessage( + senderName: 's', + text: text, + timestamp: DateTime.fromMillisecondsSinceEpoch(1000), + isOutgoing: false, + channelIndex: 0, + messageId: text, +); + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + late OffbandDatabase db; + late MeshCoreConnector connector; + + final weather = Channel(index: 0, name: 'Weather', psk: psk(0x22)); + + /// Reads the history stored under [weather]'s PSK, whatever slot it is in. + late ChannelMessageStore weatherHistory; + + Future settle() => Future.delayed(Duration.zero); + void ok() => connector.handleFrameForTest([respCodeOk]); + + setUp(() async { + SharedPreferences.setMockInitialValues({}); + PrefsManager.reset(); + await PrefsManager.initialize(); + db = OffbandDatabase(NativeDatabase.memory()); + BlobStore.overrideForTest(BlobStore(db)); + + connector = MeshCoreConnector(); + connector.sendFrameOverrideForTest = (_) {}; + connector.setConnectedForTest(); + connector.setSelfPublicKeyForTest( + Uint8List.fromList(List.generate(32, (i) => i)), + ); + connector.wireMessageStoreForTest(); + + // The radio holds Weather in slot 0. + await connector.getChannels(maxChannels: 1, force: true); + connector.handleFrameForTest(channelInfo(0, weather.name, weather.psk)); + await settle(); + expect(connector.channels.single.pskHex, weather.pskHex); + + weatherHistory = ChannelMessageStore() + ..setPublicKeyHex = connector.selfPublicKeyHex + ..channelPskResolver = (_) => weather.pskHex; + await weatherHistory.saveChannelMessages(0, [msg('kept')]); + expect(await weatherHistory.loadChannelMessages(0), hasLength(1)); + }); + + tearDown(() async { + BlobStore.clearTestOverride(); + await db.close(); + }); + + test( + 'a slot given to another channel keeps the old one\'s history', + () async { + final write = connector.setChannel(0, 'Other', psk(0x33), refresh: false); + ok(); + + expect(await write, ChannelWrite.ok); + expect(await weatherHistory.loadChannelMessages(0), hasLength(1)); + }, + ); + + test('a new key by edit keeps the old key\'s history too', () async { + final edit = connector.editChannel(weather, 'Weather', psk(0x99)); + await settle(); + ok(); // the clear + for (var i = 0; i < 50; i++) { + await settle(); + } + ok(); // the add + + expect(await edit, ChannelWrite.ok); + expect(await weatherHistory.loadChannelMessages(0), hasLength(1)); + }); + + test('a confirmed delete removes the channel\'s history', () async { + final delete = connector.deleteChannel(0, refresh: false); + ok(); + + expect(await delete, ChannelWrite.ok); + expect(await weatherHistory.loadChannelMessages(0), isEmpty); + }); + + test('a refused delete keeps it', () async { + final delete = connector.deleteChannel(0, refresh: false); + connector.handleFrameForTest([respCodeErr, errCodeNotFound]); + + expect(await delete, ChannelWrite.rejected); + expect(await weatherHistory.loadChannelMessages(0), hasLength(1)); + }); +} diff --git a/test/connector/channel_write_reply_test.dart b/test/connector/channel_write_reply_test.dart new file mode 100644 index 00000000..2ba161af --- /dev/null +++ b/test/connector/channel_write_reply_test.dart @@ -0,0 +1,321 @@ +// #1026 (epic #1021): a channel write waits for the radio's OK or ERR, and a +// slot's message history is cleared only once the radio has said OK. +// +// Firmware with OffbandMesh/meshcore-firmware#1864 refuses a different channel +// over an occupied slot with ERR_CODE_BAD_STATE and keeps that channel intact. +// Clearing its history on the strength of having sent the frame would lose it. + +import 'dart:typed_data'; + +import 'package:drift/native.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/connector/meshcore_connector.dart'; +import 'package:meshcore_open/connector/meshcore_protocol.dart'; +import 'package:meshcore_open/helpers/channel_slot_decision.dart'; +import 'package:meshcore_open/models/channel.dart'; +import 'package:meshcore_open/storage/drift/blob_store.dart'; +import 'package:meshcore_open/storage/drift/offband_database.dart'; +import 'package:meshcore_open/storage/prefs_manager.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +Uint8List psk(int fill) => Uint8List.fromList(List.filled(16, fill)); + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + late OffbandDatabase db; + late MeshCoreConnector connector; + late List sent; + + List setFrames() => + sent.where((f) => f.isNotEmpty && f[0] == cmdSetChannel).toList(); + + void ok() => connector.handleFrameForTest([respCodeOk]); + void err(int code) => connector.handleFrameForTest([respCodeErr, code]); + + /// The second write of a clear-then-add goes out only after the first has + /// been answered and its history cleared, which takes real async time. + Future untilSetFrames(int count) async { + for (var i = 0; i < 2000 && setFrames().length < count; i++) { + await Future.delayed(const Duration(milliseconds: 1)); + } + expect(setFrames(), hasLength(count)); + } + + setUp(() async { + SharedPreferences.setMockInitialValues({}); + PrefsManager.reset(); + await PrefsManager.initialize(); + db = OffbandDatabase(NativeDatabase.memory()); + BlobStore.overrideForTest(BlobStore(db)); + connector = MeshCoreConnector(); + connector.setConnectedForTest(); + sent = []; + connector.sendFrameOverrideForTest = sent.add; + connector.channelMessagesForTest[3] = []; + }); + + tearDown(() async { + await db.close(); + BlobStore.clearTestOverride(); + }); + + group('setChannel', () { + test('OK clears the slot\'s old history and reports ok', () async { + final write = connector.setChannel( + 3, + 'Weather', + psk(0x22), + refresh: false, + ); + ok(); + + expect(await write, ChannelWrite.ok); + expect(connector.channelMessagesForTest.containsKey(3), isFalse); + }); + + test('BAD_STATE is occupied, and the history stays', () async { + final write = connector.setChannel( + 3, + 'Weather', + psk(0x22), + refresh: false, + ); + err(errCodeBadState); + + expect(await write, ChannelWrite.occupied); + expect(connector.channelMessagesForTest.containsKey(3), isTrue); + }); + + test('any other ERR is rejected, and the history stays', () async { + final write = connector.setChannel( + 3, + 'Weather', + psk(0x22), + refresh: false, + ); + err(errCodeNotFound); + + expect(await write, ChannelWrite.rejected); + expect(connector.channelMessagesForTest.containsKey(3), isTrue); + }); + + test('no reply is noReply, and the history stays', () async { + connector.channelWriteReplyTimeout = const Duration(milliseconds: 20); + final write = connector.setChannel( + 3, + 'Weather', + psk(0x22), + refresh: false, + ); + + expect(await write, ChannelWrite.noReply); + expect(connector.channelMessagesForTest.containsKey(3), isTrue); + }); + + test('a timed-out write cannot take the next write\'s reply', () async { + connector.channelWriteReplyTimeout = const Duration(milliseconds: 20); + expect( + await connector.setChannel(3, 'A', psk(0x22), refresh: false), + ChannelWrite.noReply, + ); + + connector.channelWriteReplyTimeout = const Duration(seconds: 5); + final second = connector.setChannel(4, 'B', psk(0x33), refresh: false); + err(errCodeBadState); + + expect(await second, ChannelWrite.occupied); + }); + + test('the table is busy until the radio answers', () async { + final write = connector.setChannel( + 3, + 'Weather', + psk(0x22), + refresh: false, + ); + expect(connector.isChannelTableBusy, isTrue); + + ok(); + await write; + expect(connector.isChannelTableBusy, isFalse); + }); + + test('disconnected sends nothing and reports noReply', () async { + final fresh = MeshCoreConnector(); + fresh.sendFrameOverrideForTest = sent.add; + + expect( + await fresh.setChannel(3, 'Weather', psk(0x22)), + ChannelWrite.noReply, + ); + expect(sent, isEmpty); + }); + }); + + group('deleteChannel', () { + test('OK clears the history', () async { + final delete = connector.deleteChannel(3, refresh: false); + ok(); + + expect(await delete, ChannelWrite.ok); + expect(connector.channelMessagesForTest.containsKey(3), isFalse); + }); + + test('a refusal keeps the history', () async { + final delete = connector.deleteChannel(3, refresh: false); + err(errCodeNotFound); + + expect(await delete, ChannelWrite.rejected); + expect(connector.channelMessagesForTest.containsKey(3), isTrue); + }); + }); + + group('editChannel', () { + final current = Channel(index: 3, name: 'Weather', psk: psk(0x22)); + + test('a rename is one write and keeps the history', () async { + final edit = connector.editChannel(current, 'Wx', psk(0x22)); + ok(); + + expect(await edit, ChannelWrite.ok); + expect(setFrames(), hasLength(1)); + expect(connector.channelMessagesForTest.containsKey(3), isTrue); + }); + + test('a new key is clear-then-add, so #1864 firmware accepts it', () async { + final edit = connector.editChannel(current, 'Weather', psk(0x99)); + await untilSetFrames(1); + // The clear: an empty name. + expect(setFrames()[0][2], 0); + ok(); + + await untilSetFrames(2); + expect(setFrames()[1].sublist(2 + 32, 2 + 32 + 16), psk(0x99)); + ok(); + + expect(await edit, ChannelWrite.ok); + expect(connector.channelMessagesForTest.containsKey(3), isFalse); + }); + + test('a refused clear writes nothing more and keeps the history', () async { + final edit = connector.editChannel(current, 'Weather', psk(0x99)); + await untilSetFrames(1); + err(errCodeNotFound); + + expect(await edit, ChannelWrite.rejected); + expect(setFrames(), hasLength(1)); + expect(connector.channelMessagesForTest.containsKey(3), isTrue); + }); + + test( + 'a clear that lands and an add that fails says the slot is empty', + () async { + final edit = connector.editChannel(current, 'Weather', psk(0x99)); + await untilSetFrames(1); + ok(); // the clear lands + + await untilSetFrames(2); + err(errCodeNotFound); // the add does not + + expect(await edit, ChannelWrite.clearedNotAdded); + }, + ); + }); + + // Gemini review of #1021: a sync started while a write waits for its reply + // shares the reply queue with it, so the sync's empty-slot ERR could be + // taken as the write's answer. The sync waits for the writes instead. + group('a sync requested during a write', () { + List getFrames() => + sent.where((f) => f.isNotEmpty && f[0] == cmdGetChannel).toList(); + + test('is deferred until the reply, then runs', () async { + final write = connector.setChannel(3, 'A', psk(0x22), refresh: false); + await connector.getChannels(force: true); + expect(connector.isSyncingChannels, isFalse); + expect(getFrames(), isEmpty); + + ok(); + expect(await write, ChannelWrite.ok); + await Future.delayed(Duration.zero); + expect(connector.isSyncingChannels, isTrue); + expect(getFrames(), isNotEmpty); + }); + + test('does not start between two writes of a batch', () async { + final batch = connector.batchChannelWrites(() async { + final first = connector.setChannel(3, 'A', psk(0x22), refresh: false); + await connector.getChannels(force: true); + ok(); + await first; + await Future.delayed(Duration.zero); + // Between the two writes: the deferred sync must not have started. + expect(connector.isSyncingChannels, isFalse); + final second = connector.setChannel(4, 'B', psk(0x33), refresh: false); + ok(); + return second; + }); + + expect(await batch, ChannelWrite.ok); + expect(getFrames(), isNotEmpty, reason: 'runs once the batch ends'); + }); + + test('a write\'s own re-read waits for another pending write', () async { + final first = connector.setChannel(3, 'A', psk(0x22)); + final second = connector.deleteChannel(4); + + ok(); // answers the first; the second is still waiting + expect(await first, ChannelWrite.ok); + await Future.delayed(Duration.zero); + expect(connector.isSyncingChannels, isFalse); + expect(getFrames(), isEmpty); + + ok(); + expect(await second, ChannelWrite.ok); + expect(connector.isSyncingChannels, isTrue); + }); + }); + + // #1024: after a FAILED sync the cached list is restored but + // hasLoadedChannels stays false. Gating adds on hasLoadedChannels would lock + // the user out of adding channels on a flaky link, so the table has to read + // as usable here, driven through the real sync rather than asserted. + group('after a failed sync', () { + List channelInfo(int index, String name, int fill) => [ + respCodeChannelInfo, + index, + ...name.codeUnits, + ...List.filled(32 - name.length, 0), + ...psk(fill), + ]; + + Future settle() => Future.delayed(Duration.zero); + + test( + 'the restored list is not busy, and an add gets a free slot', + () async { + await connector.getChannels(maxChannels: 2, force: true); + connector.handleFrameForTest(channelInfo(0, 'Public', 0x11)); + await settle(); + connector.handleFrameForTest(channelInfo(1, 'Weather', 0x22)); + await settle(); + expect(connector.hasLoadedChannels, isTrue); + + connector.sendFrameOverrideForTest = (_) => + throw Exception('link lost'); + await connector.getChannels(maxChannels: 2, force: true); + await settle(); + + expect(connector.hasLoadedChannels, isFalse); + expect(connector.channels.map((c) => c.index), unorderedEquals([0, 1])); + expect(connector.isChannelTableBusy, isFalse); + final decision = decideChannelSlot( + channels: connector.channels, + maxChannels: 3, + isSyncing: connector.isChannelTableBusy, + ); + expect(decision.slot, 2); + }, + ); + }); +} diff --git a/test/helpers/channel_slot_decision_test.dart b/test/helpers/channel_slot_decision_test.dart new file mode 100644 index 00000000..a4a6dc1c --- /dev/null +++ b/test/helpers/channel_slot_decision_test.dart @@ -0,0 +1,181 @@ +// Channel slot allocation (#1021). Adding a channel could overwrite another, +// including Public, losing it from the client and the radio. +// +// Three faults combined: the slot was chosen when the add dialog opened, the +// connector empties its channel list during a sync so any index looked free, +// and the chooser answered "no free slot" with slot 0, which is where Public +// normally lives. These pin the decision so none of them can come back. + +import 'dart:typed_data'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/helpers/channel_slot_decision.dart'; +import 'package:meshcore_open/models/channel.dart'; + +Channel _ch(int index, {String name = 'ch', String? pskHex}) => Channel( + index: index, + name: name, + psk: Channel.parsePskHex(pskHex ?? '00112233445566778899aabbccddeeff'), +); + +void main() { + group('decideChannelSlot', () { + test('takes the lowest free slot', () { + final d = decideChannelSlot( + channels: [_ch(0), _ch(1), _ch(3)], + maxChannels: 8, + isSyncing: false, + ); + expect(d.isAllowed, isTrue); + expect(d.slot, 2); + expect(d.refusal, isNull); + }); + + test('takes slot 0 when the radio is empty', () { + final d = decideChannelSlot( + channels: const [], + maxChannels: 8, + isSyncing: false, + ); + expect(d.slot, 0); + }); + + test('refuses with full, NEVER slot 0, when every slot is used', () { + final d = decideChannelSlot( + channels: [for (var i = 0; i < 8; i++) _ch(i)], + maxChannels: 8, + isSyncing: false, + ); + expect(d.isAllowed, isFalse); + expect(d.refusal, ChannelSlotRefusal.full); + expect( + d.slot, + isNull, + reason: 'the old return 0 fallback is what destroyed Public', + ); + }); + + test('refuses while syncing, even though every slot looks free', () { + // This is the reported bug. Mid-sync the connector has emptied its list, + // so an empty list plus a free-looking slot 0 is exactly the state that + // overwrote Public. + final d = decideChannelSlot( + channels: const [], + maxChannels: 8, + isSyncing: true, + ); + expect(d.isAllowed, isFalse); + expect(d.refusal, ChannelSlotRefusal.syncing); + expect(d.slot, isNull); + }); + + test('syncing is refused even when a slot genuinely is free', () { + final d = decideChannelSlot( + channels: [_ch(0)], + maxChannels: 8, + isSyncing: true, + ); + expect(d.refusal, ChannelSlotRefusal.syncing); + }); + + test('syncing takes precedence over full', () { + final d = decideChannelSlot( + channels: [for (var i = 0; i < 8; i++) _ch(i)], + maxChannels: 8, + isSyncing: true, + ); + expect( + d.refusal, + ChannelSlotRefusal.syncing, + reason: 'a list being rewritten cannot be trusted to say it is full', + ); + }); + + // The regression test for the gate I nearly got wrong. After a FAILED sync + // the connector leaves hasLoadedChannels false but restores the cached + // list into use. Gating on that flag would refuse forever on a flaky link, + // so the decision takes isSyncing only, and a restored list allocates + // normally. + test('allocates normally after a failed sync, from the restored list', () { + final d = decideChannelSlot( + channels: [_ch(0), _ch(1)], + maxChannels: 8, + isSyncing: false, + ); + expect( + d.isAllowed, + isTrue, + reason: 'a failed sync must not disable adding channels', + ); + expect(d.slot, 2); + }); + + test('a single-slot radio can be filled and then refuses', () { + expect( + decideChannelSlot( + channels: const [], + maxChannels: 1, + isSyncing: false, + ).slot, + 0, + ); + expect( + decideChannelSlot( + channels: [_ch(0)], + maxChannels: 1, + isSyncing: false, + ).refusal, + ChannelSlotRefusal.full, + ); + }); + + test('an out-of-range index in the list does not block a free slot', () { + // Defensive: a stale or odd index must not make the radio look full. + final d = decideChannelSlot( + channels: [_ch(99)], + maxChannels: 4, + isSyncing: false, + ); + expect(d.slot, 0); + }); + + test('Public holds no claim on slot 0, since it is identified by PSK', () { + // `Channel.isPublicChannel` compares the PSK, not the index, so Public + // can live anywhere and nothing may assume slot 0 belongs to it. + final public = Channel( + index: 3, + name: 'Public', + psk: Channel.parsePskHex(Channel.publicChannelPsk), + ); + expect(public.isPublicChannel, isTrue); + final d = decideChannelSlot( + channels: [public], + maxChannels: 8, + isSyncing: false, + ); + expect(d.slot, 0, reason: 'slot 0 is free here and may be used'); + }); + + test('a decision is either a slot or a refusal, never both', () { + final allowed = decideChannelSlot( + channels: const [], + maxChannels: 4, + isSyncing: false, + ); + final refused = decideChannelSlot( + channels: const [], + maxChannels: 4, + isSyncing: true, + ); + expect(allowed.slot != null && allowed.refusal == null, isTrue); + expect(refused.slot == null && refused.refusal != null, isTrue); + }); + }); + + group('Uint8List psk sanity', () { + test('the helper builds channels with a real 16 byte psk', () { + expect(_ch(0).psk, isA()); + expect(_ch(0).psk.length, 16); + }); + }); +} diff --git a/test/helpers/channel_slot_ui_test.dart b/test/helpers/channel_slot_ui_test.dart new file mode 100644 index 00000000..a1b566dd --- /dev/null +++ b/test/helpers/channel_slot_ui_test.dart @@ -0,0 +1,188 @@ +// #1024 (epic #1021): every channel refusal message shows on its own failure, +// stays until dismissed, and is absent when the action is allowed. +// +// The messages are the whole point of the owner's ruling: block the unsafe +// write, keep the control live, and say why. A message that never shows, or +// that disappears in four seconds, is the silent failure that ruling rejects. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/connector/meshcore_connector.dart'; +import 'package:meshcore_open/helpers/channel_slot_ui.dart'; +import 'package:meshcore_open/l10n/app_localizations.dart'; +import 'package:meshcore_open/models/channel.dart'; + +class _FakeConn extends MeshCoreConnector { + _FakeConn({this.list = const [], this.max = 40, this.busy = false}); + + final List list; + final int max; + final bool busy; + + @override + List get channels => list; + @override + int get maxChannels => max; + @override + bool get isChannelTableBusy => busy; +} + +Channel _ch(int index, String name, int fill) => Channel( + index: index, + name: name, + psk: Channel.parsePskHex(List.filled(32, fill.toRadixString(16)).join()), +); + +final _l10n = lookupAppLocalizations(const Locale('en')); + +/// Every refusal this file can show, so a success can assert none of them. +final _allMessages = [ + _l10n.channels_slotBusySyncing, + _l10n.channels_slotsAllFull(3), + _l10n.channels_publicAlreadyAdded, + _l10n.channels_writeOccupied, + _l10n.channels_writeRejected, + _l10n.channels_writeNoReply, + _l10n.channels_writeClearedNotAdded, +]; + +Future _host(WidgetTester tester) async { + late BuildContext context; + await tester.pumpWidget( + MaterialApp( + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: Scaffold( + body: Builder( + builder: (c) { + context = c; + return const SizedBox.shrink(); + }, + ), + ), + ), + ); + return context; +} + +/// Shown, and still shown well past the 4 second toast default. +Future _expectPersistent(WidgetTester tester, String message) async { + await tester.pump(); + expect(find.text(message), findsOneWidget); + await tester.pump(const Duration(seconds: 10)); + expect(find.text(message), findsOneWidget); +} + +Future _expectNoRefusal(WidgetTester tester) async { + await tester.pump(); + for (final message in _allMessages) { + expect(find.text(message), findsNothing, reason: message); + } +} + +void main() { + group('allocateChannelSlotOrExplain', () { + testWidgets('busy: refused, with the busy message', (tester) async { + final context = await _host(tester); + final slot = allocateChannelSlotOrExplain(context, _FakeConn(busy: true)); + + expect(slot, isNull); + await _expectPersistent(tester, _l10n.channels_slotBusySyncing); + }); + + testWidgets('full: refused, naming the slot count', (tester) async { + final context = await _host(tester); + final slot = allocateChannelSlotOrExplain( + context, + _FakeConn( + list: [_ch(0, 'A', 1), _ch(1, 'B', 2), _ch(2, 'C', 3)], + max: 3, + ), + ); + + expect(slot, isNull); + await _expectPersistent(tester, _l10n.channels_slotsAllFull(3)); + }); + + testWidgets('a free slot: allowed, and no message', (tester) async { + final context = await _host(tester); + final slot = allocateChannelSlotOrExplain( + context, + _FakeConn(list: [_ch(0, 'A', 1)], max: 3), + ); + + expect(slot, 1); + await _expectNoRefusal(tester); + }); + }); + + group('refusePublicAlreadyOnRadio', () { + testWidgets('Public present, in any slot: refused', (tester) async { + final context = await _host(tester); + final publicPsk = Channel.parsePskHex(Channel.publicChannelPsk); + final refused = refusePublicAlreadyOnRadio( + context, + _FakeConn( + list: [Channel(index: 5, name: 'Public', psk: publicPsk)], + ), + ); + + expect(refused, isTrue); + await _expectPersistent(tester, _l10n.channels_publicAlreadyAdded); + }); + + testWidgets('no Public: allowed, and no message', (tester) async { + final context = await _host(tester); + final refused = refusePublicAlreadyOnRadio( + context, + _FakeConn(list: [_ch(0, 'A', 1)]), + ); + + expect(refused, isFalse); + await _expectNoRefusal(tester); + }); + }); + + group('explainUnconfirmedChannelWrite', () { + final cases = { + ChannelWrite.occupied: _l10n.channels_writeOccupied, + ChannelWrite.rejected: _l10n.channels_writeRejected, + ChannelWrite.noReply: _l10n.channels_writeNoReply, + ChannelWrite.clearedNotAdded: _l10n.channels_writeClearedNotAdded, + }; + for (final entry in cases.entries) { + testWidgets('${entry.key.name}: explained, persistently', (tester) async { + final context = await _host(tester); + + expect(explainUnconfirmedChannelWrite(context, entry.key), isTrue); + await _expectPersistent(tester, entry.value); + }); + } + + testWidgets('ok: nothing to explain, and no message', (tester) async { + final context = await _host(tester); + + expect(explainUnconfirmedChannelWrite(context, ChannelWrite.ok), isFalse); + await _expectNoRefusal(tester); + }); + }); + + group('refuseWhileChannelTableBusy', () { + testWidgets('busy: refused, with the busy message', (tester) async { + final context = await _host(tester); + + expect( + refuseWhileChannelTableBusy(context, _FakeConn(busy: true)), + isTrue, + ); + await _expectPersistent(tester, _l10n.channels_slotBusySyncing); + }); + + testWidgets('idle: allowed, and no message', (tester) async { + final context = await _host(tester); + + expect(refuseWhileChannelTableBusy(context, _FakeConn()), isFalse); + await _expectNoRefusal(tester); + }); + }); +} diff --git a/test/services/stock_config_import_service_test.dart b/test/services/stock_config_import_service_test.dart index a8bcfcc1..fbafbe76 100644 --- a/test/services/stock_config_import_service_test.dart +++ b/test/services/stock_config_import_service_test.dart @@ -28,6 +28,7 @@ void main() { existing: [live(0, 'Public', 0x11)], incoming: [incoming('Weather', 0x22)], maxChannels: 40, + isSyncing: false, ); expect(plan.assignments, hasLength(1)); @@ -41,6 +42,7 @@ void main() { existing: [live(0, 'Public', 0x11)], incoming: [incoming('Renamed', 0x11)], maxChannels: 40, + isSyncing: false, ); expect(plan.assignments, isEmpty); @@ -55,6 +57,7 @@ void main() { existing: [live(0, 'Public', 0x11)], incoming: [incoming('Public', 0x99)], maxChannels: 40, + isSyncing: false, ); expect(plan.assignments, isEmpty); @@ -72,6 +75,7 @@ void main() { ], incoming: [incoming('Emergency', 0x33)], maxChannels: 40, + isSyncing: false, ); expect(plan.assignments.single.slot, 1); @@ -86,6 +90,7 @@ void main() { incoming('Third', 0x44), ], maxChannels: 40, + isSyncing: false, ); expect(plan.assignments.map((a) => a.slot), [1, 2, 3]); @@ -101,6 +106,7 @@ void main() { existing: [live(0, 'A', 0x11), live(1, 'B', 0x22)], incoming: [incoming('C', 0x33), incoming('D', 0x44)], maxChannels: 2, + isSyncing: false, ); expect(plan.assignments, isEmpty); @@ -116,6 +122,7 @@ void main() { existing: const [], incoming: [incoming('Dupe', 0x55), incoming('Dupe', 0x55)], maxChannels: 40, + isSyncing: false, ); expect(plan.assignments, hasLength(1)); @@ -127,11 +134,48 @@ void main() { existing: [live(0, 'Public', 0x11)], incoming: const [], maxChannels: 40, + isSyncing: false, ); expect(plan.assignments, isEmpty); expect(plan.skipped, isEmpty); }); + + // #1021: the connector empties its channel list for the length of a sync, + // so mid-sync `existing` looks empty. Planning then would write every + // incoming channel over slots that are really occupied, starting at 0. + test('mid-sync nothing is written, even into slots that look free', () { + final plan = planChannelImport( + existing: const [], + incoming: [incoming('Weather', 0x22), incoming('Emergency', 0x33)], + maxChannels: 40, + isSyncing: true, + ); + + expect(plan.assignments, isEmpty); + expect(plan.skipped.map((s) => s.name), ['Weather', 'Emergency']); + expect( + plan.skipped.map((s) => s.reason), + everyElement(StockConfigImportIssue.channelsSyncing), + ); + }); + + test('mid-sync every channel is reported as syncing, not as present', () { + // A partial list cannot prove a channel is already there either, so + // "already present" would be a guess. Syncing is the true reason. + final plan = planChannelImport( + existing: [live(0, 'Public', 0x11)], + incoming: [incoming('Public', 0x11)], + maxChannels: 40, + isSyncing: true, + ); + + expect(plan.assignments, isEmpty); + expect( + plan.skipped.single.reason, + StockConfigImportIssue.channelsSyncing, + ); + }); }); group('import result', () { diff --git a/untranslated.json b/untranslated.json index 8a149493..3e152471 100644 --- a/untranslated.json +++ b/untranslated.json @@ -154,6 +154,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -210,7 +217,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -318,6 +324,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -524,6 +531,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -580,7 +594,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -688,6 +701,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -894,6 +908,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -950,7 +971,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -1058,6 +1078,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -1264,6 +1285,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -1320,7 +1348,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -1428,6 +1455,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -1634,6 +1662,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -1690,7 +1725,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -1798,6 +1832,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -2004,6 +2039,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -2060,7 +2102,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -2168,6 +2209,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -2374,6 +2416,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -2430,7 +2479,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -2538,6 +2586,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -2744,6 +2793,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -2800,7 +2856,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -2908,6 +2963,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -3114,6 +3170,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -3170,7 +3233,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -3278,6 +3340,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -3484,6 +3547,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -3540,7 +3610,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -3648,6 +3717,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -3854,6 +3924,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -3910,7 +3987,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -4018,6 +4094,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -4224,6 +4301,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -4280,7 +4364,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -4388,6 +4471,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -4594,6 +4678,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -4650,7 +4741,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -4758,6 +4848,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -4964,6 +5055,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -5020,7 +5118,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -5128,6 +5225,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -5334,6 +5432,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -5390,7 +5495,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -5498,6 +5602,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -5704,6 +5809,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -5760,7 +5872,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -5868,6 +5979,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported", @@ -6074,6 +6186,13 @@ "channels_radioSoundFollows", "channels_radioSoundMutedByRadio", "channels_radioSoundReading", + "channels_slotBusySyncing", + "channels_slotsAllFull", + "channels_publicAlreadyAdded", + "channels_writeOccupied", + "channels_writeRejected", + "channels_writeNoReply", + "channels_writeClearedNotAdded", "composerBudgetBlockedTitle", "composerBudgetLimitedTitle", "composerBudgetBluetoothCause", @@ -6130,7 +6249,6 @@ "channels_scanQrDesc", "channels_scanQrInstructions", "channels_invalidQr", - "channels_noFreeSlot", "channels_qrAddConfirm", "channels_qrAdded", "channels_qrExists", @@ -6238,6 +6356,7 @@ "importConfig_resultFailedHeading", "importConfig_reasonAlreadyPresent", "importConfig_reasonNoFreeSlot", + "importConfig_reasonChannelsSyncing", "importConfig_reasonAbsentFromFile", "importConfig_reasonNoReply", "importConfig_reasonUnsupported",