add ab full check

This commit is contained in:
rustdesk 2023-07-26 20:43:18 +08:00
parent 4fe85cdd4a
commit 791645fa59
38 changed files with 124 additions and 1 deletions

View File

@ -241,6 +241,9 @@ class _AddressBookState extends State<AddressBook> {
}
void abAddId() async {
if (gFFI.abModel.isFull(true)) {
return;
}
var isInProgress = false;
IDTextEditingController idController = IDTextEditingController(text: '');
TextEditingController aliasController = TextEditingController(text: '');

View File

@ -644,6 +644,9 @@ abstract class BasePeerCard extends StatelessWidget {
),
proc: () {
() async {
if (gFFI.abModel.isFull(true)) {
return;
}
if (!gFFI.abModel.idContainBy(peer.id)) {
gFFI.abModel.addPeer(peer);
await gFFI.abModel.pushAb();

View File

@ -29,6 +29,7 @@ class AbModel {
final selectedTags = List<String>.empty(growable: true).obs;
var initialized = false;
var licensedDevices = 0;
WeakReference<FFI> parent;
@ -52,6 +53,10 @@ class AbModel {
if (json.containsKey('error')) {
abError.value = json['error'];
} else if (json.containsKey('data')) {
try {
gFFI.abModel.licensedDevices = json['licensed_devices'];
// ignore: empty_catches
} catch (e) {}
final data = jsonDecode(json['data']);
if (data != null) {
tags.clear();
@ -94,6 +99,15 @@ class AbModel {
peers.add(peer);
}
bool isFull(bool warn) {
final res = licensedDevices > 0 && peers.length >= licensedDevices;
if (res && warn) {
BotToast.showText(
contentColor: Colors.red, text: translate("exceed_max_devices"));
}
return res;
}
void addPeer(Peer peer) {
peers.removeWhere((e) => e.id == peer.id);
peers.add(peer);

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -71,6 +71,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("resolution_custom_tip", "Custom resolution"),
("accept_and_elevate_btn_tooltip", "Accept the connection and elevate UAC permissions."),
("clipboard_wait_response_timeout_tip", "Timed out waiting for copy response."),
("logout_tip", "Are you sure you want to log out?")
("logout_tip", "Are you sure you want to log out?"),
("exceed_max_devices", "You have reached the maximum number of managed devices."),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", "Servizio"),
("Start", "Avvia"),
("Stop", "Ferma"),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", "Сервис"),
("Start", "Запустить"),
("Stop", "Остановить"),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}

View File

@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Service", ""),
("Start", ""),
("Stop", ""),
("exceed_max_devices", ""),
("Sync with recent sessions", ""),
("Sort tags", ""),
].iter().cloned().collect();
}