diff --git a/deltachat-jsonrpc/src/api/mod.rs b/deltachat-jsonrpc/src/api/mod.rs index 7ad7c2aab..da0cdd149 100644 --- a/deltachat-jsonrpc/src/api/mod.rs +++ b/deltachat-jsonrpc/src/api/mod.rs @@ -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> { let ctx = self.get_context(account_id).await?; get_config(&ctx, &key).await diff --git a/deltachat-jsonrpc/typescript/generated/client.ts b/deltachat-jsonrpc/typescript/generated/client.ts index 6b0ff7994..03d314eda 100644 --- a/deltachat-jsonrpc/typescript/generated/client.ts +++ b/deltachat-jsonrpc/typescript/generated/client.ts @@ -109,6 +109,19 @@ export class RawClient { return (this._transport.request('batch_set_config', [accountId, config] as RPC.Params)) as Promise; } + /** + * 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. + */ + public setConfigFromQr(accountId: T.U32, qrContent: string): Promise { + return (this._transport.request('set_config_from_qr', [accountId, qrContent] as RPC.Params)) as Promise; + } + public getConfig(accountId: T.U32, key: string): Promise<(string|null)> { return (this._transport.request('get_config', [accountId, key] as RPC.Params)) as Promise<(string|null)>; diff --git a/deltachat-jsonrpc/typescript/generated/types.ts b/deltachat-jsonrpc/typescript/generated/types.ts index df7f16bbc..bb14ba803 100644 --- a/deltachat-jsonrpc/typescript/generated/types.ts +++ b/deltachat-jsonrpc/typescript/generated/types.ts @@ -12,4 +12,4 @@ export type FullChat={"id":U32;"name":string;"is_protected":boolean;"profile_ima export type I32=number; export type U64=number; export type Message={"id":U32;"chat_id":U32;"from_id":U32;"quoted_text":(string|null);"quoted_message_id":(U32|null);"text":(string|null);"has_location":boolean;"has_html":boolean;"view_type":U32;"state":U32;"timestamp":I64;"sort_timestamp":I64;"received_timestamp":I64;"has_deviating_timestamp":boolean;"subject":string;"show_padlock":boolean;"is_setupmessage":boolean;"is_info":boolean;"is_forwarded":boolean;"duration":I32;"dimensions_height":I32;"dimensions_width":I32;"videochat_type":(U32|null);"videochat_url":(string|null);"override_sender_name":(string|null);"sender":Contact;"setup_code_begin":(string|null);"file":(string|null);"file_mime":(string|null);"file_bytes":U64;"file_name":(string|null);}; -export type __AllTyps=[string,boolean,Record,U32,U32,null,(U32)[],U32,null,(U32|null),(Account)[],U32,Account,U32,string,(ProviderInfo|null),U32,boolean,U32,Record,U32,string,(string|null),null,U32,Record,null,U32,string,(string|null),U32,(string)[],Record,U32,null,U32,null,U32,string,U32,U32,string,null,U32,(U32|null),(string|null),(U32|null),(ChatListEntry)[],U32,(ChatListEntry)[],Record,U32,U32,FullChat,U32,U32,null,U32,U32,null,U32,U32,U32,(U32)[],U32,U32,Message,U32,(U32)[],Record,U32,U32,Contact,U32,string,(string|null),U32,U32,U32,U32,U32,U32,null,U32,U32,null,U32,(Contact)[],U32,U32,(string|null),(U32)[],U32,U32,(string|null),(Contact)[],U32,(U32)[],Record,U32,string,U32,U32]; +export type __AllTyps=[string,boolean,Record,U32,U32,null,(U32)[],U32,null,(U32|null),(Account)[],U32,Account,U32,string,(ProviderInfo|null),U32,boolean,U32,Record,U32,string,(string|null),null,U32,Record,null,U32,string,null,U32,string,(string|null),U32,(string)[],Record,U32,null,U32,null,U32,string,U32,U32,string,null,U32,(U32|null),(string|null),(U32|null),(ChatListEntry)[],U32,(ChatListEntry)[],Record,U32,U32,FullChat,U32,U32,null,U32,U32,null,U32,U32,U32,(U32)[],U32,U32,Message,U32,(U32)[],Record,U32,U32,Contact,U32,string,(string|null),U32,U32,U32,U32,U32,U32,null,U32,U32,null,U32,(Contact)[],U32,U32,(string|null),(U32)[],U32,U32,(string|null),(Contact)[],U32,(U32)[],Record,U32,string,U32,U32];