add set_config_from_qr to jsonrpc

This commit is contained in:
Simon Laux
2022-07-03 20:45:27 +02:00
parent 8776767a44
commit d6b6d96e21
3 changed files with 27 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ use deltachat::{
context::get_info,
message::{Message, MsgId, Viewtype},
provider::get_provider_info,
qr,
};
use std::collections::BTreeMap;
use std::sync::Arc;
@@ -185,6 +186,18 @@ impl CommandApi {
Ok(())
}
/// Set configuration values from a QR code. (technically from the URI that is stored in the qrcode)
/// Before this function is called, dc_check_qr() should confirm the type of the
/// QR code is DC_QR_ACCOUNT or DC_QR_WEBRTC_INSTANCE.
///
/// Internally, the function will call dc_set_config() with the appropriate keys,
/// e.g. `addr` and `mail_pw` for DC_QR_ACCOUNT
/// or `webrtc_instance` for DC_QR_WEBRTC_INSTANCE.
async fn set_config_from_qr(&self, account_id: u32, qr_content: String) -> Result<()> {
let ctx = self.get_context(account_id).await?;
qr::set_config_from_qr(&ctx, &qr_content).await
}
async fn get_config(&self, account_id: u32, key: String) -> Result<Option<String>> {
let ctx = self.get_context(account_id).await?;
get_config(&ctx, &key).await