From 5762fbb9a7a8bcd77efdd45baa3907d5a9237cef Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Wed, 1 Mar 2023 11:27:21 +0100 Subject: [PATCH] Allow JSON-RPC to get text of QR code as well Desktop does use this as it allows reading QR codes as text from the clipboard as well as copying the QR text to the clipboard instead of showing the QR code. --- deltachat-jsonrpc/src/api/mod.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/deltachat-jsonrpc/src/api/mod.rs b/deltachat-jsonrpc/src/api/mod.rs index 6ff1a371d..a9e214bee 100644 --- a/deltachat-jsonrpc/src/api/mod.rs +++ b/deltachat-jsonrpc/src/api/mod.rs @@ -1376,7 +1376,19 @@ impl CommandApi { res } - /// Returns the QR code for the running [`CommandApi::provide_backup`]. + /// Returns the text of the QR code for the running [`CommandApi::provide_backup`]. + /// + /// This QR code text can be used in [`CommandApi::get_backup`] on a second device to + /// retrieve the backup and setup this second device. + async fn get_backup_qr(&self, account_id: u32) -> Result { + let ctx = self.get_context(account_id).await?; + let qr = ctx + .backup_export_qr() + .ok_or(anyhow!("no backup being exported"))?; + qr::format_backup(&qr) + } + + /// Returns the rendered QR code for the running [`CommandApi::provide_backup`]. /// /// This QR code can be used in [`CommandApi::get_backup`] on a second device to /// retrieve the backup and setup this second device.