mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
feat(deltachat-repl): built-in QR code printer
Print QR codes with Rust code instead of depending on external `qrencode`.
This commit is contained in:
39
Cargo.lock
generated
39
Cargo.lock
generated
@@ -1109,6 +1109,28 @@ version = "0.8.19"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
|
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossterm"
|
||||||
|
version = "0.28.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.6.0",
|
||||||
|
"crossterm_winapi",
|
||||||
|
"parking_lot",
|
||||||
|
"rustix",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossterm_winapi"
|
||||||
|
version = "0.9.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crunchy"
|
name = "crunchy"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
@@ -1403,6 +1425,7 @@ dependencies = [
|
|||||||
"dirs",
|
"dirs",
|
||||||
"log",
|
"log",
|
||||||
"nu-ansi-term",
|
"nu-ansi-term",
|
||||||
|
"qr2term",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
"rustyline",
|
"rustyline",
|
||||||
"tokio",
|
"tokio",
|
||||||
@@ -4457,6 +4480,22 @@ dependencies = [
|
|||||||
"unarray",
|
"unarray",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "qr2term"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6867c60b38e9747a079a19614dbb5981a53f21b9a56c265f3bfdf6011a50a957"
|
||||||
|
dependencies = [
|
||||||
|
"crossterm",
|
||||||
|
"qrcode",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "qrcode"
|
||||||
|
version = "0.14.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d68782463e408eb1e668cf6152704bd856c78c5b6417adaee3203d8f4c1fc9ec"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "qrcodegen"
|
name = "qrcodegen"
|
||||||
version = "1.8.0"
|
version = "1.8.0"
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ deltachat = { workspace = true, features = ["internals"]}
|
|||||||
dirs = "5"
|
dirs = "5"
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
nu-ansi-term = { workspace = true }
|
nu-ansi-term = { workspace = true }
|
||||||
|
qr2term = "0.3.3"
|
||||||
rusqlite = { workspace = true }
|
rusqlite = { workspace = true }
|
||||||
rustyline = "14"
|
rustyline = "14"
|
||||||
tokio = { workspace = true, features = ["fs", "rt-multi-thread", "macros"] }
|
tokio = { workspace = true, features = ["fs", "rt-multi-thread", "macros"] }
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
#![allow(clippy::format_push_string)]
|
#![allow(clippy::format_push_string)]
|
||||||
extern crate dirs;
|
extern crate dirs;
|
||||||
|
|
||||||
use std::io::Write;
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Command;
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
@@ -491,12 +489,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
|
|||||||
let provider = BackupProvider::prepare(&context).await?;
|
let provider = BackupProvider::prepare(&context).await?;
|
||||||
let qr = format_backup(&provider.qr())?;
|
let qr = format_backup(&provider.qr())?;
|
||||||
println!("QR code: {}", qr);
|
println!("QR code: {}", qr);
|
||||||
let output = Command::new("qrencode")
|
qr2term::print_qr(qr.as_str())?;
|
||||||
.args(["-t", "ansiutf8", qr.as_str(), "-o", "-"])
|
|
||||||
.output()
|
|
||||||
.expect("failed to execute process");
|
|
||||||
std::io::stdout().write_all(&output.stdout).unwrap();
|
|
||||||
std::io::stderr().write_all(&output.stderr).unwrap();
|
|
||||||
provider.await?;
|
provider.await?;
|
||||||
}
|
}
|
||||||
"receive-backup" => {
|
"receive-backup" => {
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
extern crate deltachat;
|
extern crate deltachat;
|
||||||
|
|
||||||
use std::borrow::Cow::{self, Borrowed, Owned};
|
use std::borrow::Cow::{self, Borrowed, Owned};
|
||||||
use std::io::{self, Write};
|
|
||||||
use std::process::Command;
|
|
||||||
|
|
||||||
use anyhow::{bail, Error};
|
use anyhow::{bail, Error};
|
||||||
use deltachat::chat::ChatId;
|
use deltachat::chat::ChatId;
|
||||||
@@ -450,12 +448,7 @@ async fn handle_cmd(
|
|||||||
qr.replace_range(12..22, "0000000000")
|
qr.replace_range(12..22, "0000000000")
|
||||||
}
|
}
|
||||||
println!("{qr}");
|
println!("{qr}");
|
||||||
let output = Command::new("qrencode")
|
qr2term::print_qr(qr.as_str())?;
|
||||||
.args(["-t", "ansiutf8", qr.as_str(), "-o", "-"])
|
|
||||||
.output()
|
|
||||||
.expect("failed to execute process");
|
|
||||||
io::stdout().write_all(&output.stdout).unwrap();
|
|
||||||
io::stderr().write_all(&output.stderr).unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"getqrsvg" => {
|
"getqrsvg" => {
|
||||||
|
|||||||
Reference in New Issue
Block a user