diff --git a/Cargo.lock b/Cargo.lock index 310c94567..ced1ce0ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -176,6 +176,18 @@ version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" +[[package]] +name = "bytemuck" +version = "1.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3995eaeebcdf32f91f980d360f78732ddc061097ab4e39991ae7a6ace9194677" + +[[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + [[package]] name = "bytes" version = "1.10.1" @@ -866,6 +878,17 @@ dependencies = [ "icu_properties", ] +[[package]] +name = "image" +version = "0.25.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db35664ce6b9810857a38a906215e75a9c879f0696556a39f59c62829710251a" +dependencies = [ + "bytemuck", + "byteorder-lite", + "num-traits", +] + [[package]] name = "indexmap" version = "2.10.0" @@ -1282,6 +1305,15 @@ dependencies = [ "prost", ] +[[package]] +name = "qrcode" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d68782463e408eb1e668cf6152704bd856c78c5b6417adaee3203d8f4c1fc9ec" +dependencies = [ + "image", +] + [[package]] name = "quote" version = "1.0.40" @@ -2117,6 +2149,7 @@ dependencies = [ "libsqlite3-sys", "log", "prost", + "qrcode", "rand", "rand_core 0.9.3", "rustls", diff --git a/Cargo.toml b/Cargo.toml index c70ef4957..9dbd87fe3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ async-trait = "0.1.88" base64 = { version = "0.22.1", default-features = false, features = ["alloc"] } bincode = { version = "2.0.1", features = ["serde"] } bytes = { version = "1.5", default-features = false } +qrcode = { version = "0.14.1", features = ["image"] } # Time handling chrono = { version = "0.4" } diff --git a/src/main.rs b/src/main.rs index e7299d604..8c2cc4151 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,7 @@ use chrono::Local; use log::{debug, error, info}; +use qrcode::QrCode; +use qrcode::render::unicode::Dense1x2; use std::io::Cursor; use tokio::task; use wacore::download::{Downloadable, MediaType}; @@ -43,7 +45,21 @@ fn main() { "New pairing code received (valid for {} seconds):", timeout.as_secs() ); - info!("\n{}\n", code); + info!("Scan the QR code below with your WhatsApp:"); + info!("----------------------------------------"); + + match QrCode::new(code.clone()) { + Ok(code) => { + let string = code.render::().build(); + + info!("{}", string); + } + Err(e) => { + error!("Failed to generate QR code: {}", e); + info!("QR Code data: {}", code); + } + } + info!("----------------------------------------"); }