mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-19 00:13:01 +08:00
simple ab store and add batch operation toast
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
f5cf291f55
commit
2f5ae54c08
@ -309,6 +309,7 @@ class _PeerTabPageState extends State<PeerTabPage>
|
||||
break;
|
||||
}
|
||||
gFFI.peerTabModel.closeSelection();
|
||||
showToast(translate('Successful'));
|
||||
}
|
||||
|
||||
deletePeerConfirmDialog(onSubmit);
|
||||
@ -334,6 +335,7 @@ class _PeerTabPageState extends State<PeerTabPage>
|
||||
}
|
||||
await bind.mainStoreFav(favs: favs);
|
||||
gFFI.peerTabModel.closeSelection();
|
||||
showToast(translate('Successful'));
|
||||
},
|
||||
child: Tooltip(
|
||||
message: translate('Add to Favorites'),
|
||||
@ -354,6 +356,7 @@ class _PeerTabPageState extends State<PeerTabPage>
|
||||
gFFI.abModel.addPeers(peers);
|
||||
gFFI.abModel.pushAb();
|
||||
gFFI.peerTabModel.closeSelection();
|
||||
showToast(translate('Successful'));
|
||||
},
|
||||
child: Tooltip(
|
||||
message: translate('Add to Address Book'),
|
||||
@ -377,6 +380,7 @@ class _PeerTabPageState extends State<PeerTabPage>
|
||||
peers.map((p) => p.id).toList(), selectedTags);
|
||||
gFFI.abModel.pushAb();
|
||||
gFFI.peerTabModel.closeSelection();
|
||||
showToast(translate('Successful'));
|
||||
});
|
||||
},
|
||||
child: Tooltip(
|
||||
|
@ -61,7 +61,7 @@ class AbModel {
|
||||
authHeaders['Accept-Encoding'] = "gzip";
|
||||
final resp = await http.get(Uri.parse(api), headers: authHeaders);
|
||||
if (resp.body.isNotEmpty && resp.body.toLowerCase() != "null") {
|
||||
Map<String, dynamic> json = jsonDecode(resp.body);
|
||||
Map<String, dynamic> json = jsonDecode(utf8.decode(resp.bodyBytes));
|
||||
if (json.containsKey('error')) {
|
||||
abError.value = json['error'];
|
||||
} else if (json.containsKey('data')) {
|
||||
|
@ -23,7 +23,7 @@ use crate::{
|
||||
log,
|
||||
password_security::{
|
||||
decrypt_str_or_original, decrypt_vec_or_original, encrypt_str_or_original,
|
||||
encrypt_vec_or_original,
|
||||
encrypt_vec_or_original, symmetric_crypt,
|
||||
},
|
||||
};
|
||||
|
||||
@ -1504,13 +1504,14 @@ impl Ab {
|
||||
pub fn store(json: String) {
|
||||
if let Ok(mut file) = std::fs::File::create(Self::path()) {
|
||||
let data = compress(json.as_bytes());
|
||||
let max_len = 32 * 1024 * 1024;
|
||||
let max_len = 64 * 1024 * 1024;
|
||||
if data.len() > max_len {
|
||||
// not store original
|
||||
// maxlen of function decompress
|
||||
return;
|
||||
}
|
||||
let data = encrypt_vec_or_original(&data, PASSWORD_ENC_VERSION, max_len);
|
||||
file.write_all(&data).ok();
|
||||
if let Ok(data) = symmetric_crypt(&data, true) {
|
||||
file.write_all(&data).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1518,8 +1519,7 @@ impl Ab {
|
||||
if let Ok(mut file) = std::fs::File::open(Self::path()) {
|
||||
let mut data = vec![];
|
||||
if file.read_to_end(&mut data).is_ok() {
|
||||
let (data, succ, _) = decrypt_vec_or_original(&data, PASSWORD_ENC_VERSION);
|
||||
if succ {
|
||||
if let Ok(data) = symmetric_crypt(&data, false) {
|
||||
let data = decompress(&data);
|
||||
if let Ok(ab) = serde_json::from_str::<Ab>(&String::from_utf8_lossy(&data)) {
|
||||
return ab;
|
||||
@ -1527,6 +1527,7 @@ impl Ab {
|
||||
}
|
||||
}
|
||||
};
|
||||
Self::remove();
|
||||
Ab::default()
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ fn decrypt(v: &[u8]) -> Result<Vec<u8>, ()> {
|
||||
}
|
||||
}
|
||||
|
||||
fn symmetric_crypt(data: &[u8], encrypt: bool) -> Result<Vec<u8>, ()> {
|
||||
pub fn symmetric_crypt(data: &[u8], encrypt: bool) -> Result<Vec<u8>, ()> {
|
||||
use sodiumoxide::crypto::secretbox;
|
||||
use std::convert::TryInto;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user