Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
add setConfigFromQr
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-Laux committed Nov 10, 2021
1 parent 9297787 commit e89da5c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased][unreleased]

## Added
- added missing `context.setConfigFromQr(qrcodeContent:string)`

## [1.60.1] - 2021-08-10

Expand Down
6 changes: 6 additions & 0 deletions lib/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,12 @@ export class Context {
}
}

setConfigFromQr(qrcodeContent: string): boolean {
return Boolean(
binding.dcn_set_config_from_qr(this.dcn_context, qrcodeContent)
)
}

estimateDeletionCount(fromServer: boolean, seconds: number): number {
debug(`estimateDeletionCount fromServer: ${fromServer} seconds: ${seconds}`)
return binding.dcn_estimate_deletion_cnt(
Expand Down
15 changes: 15 additions & 0 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,20 @@ NAPI_METHOD(dcn_set_config_null) {
NAPI_RETURN_INT32(status);
}

NAPI_METHOD(dcn_set_config_from_qr) {
NAPI_ARGV(2);
NAPI_DCN_CONTEXT();
NAPI_ARGV_UTF8_MALLOC(qr, 1);

//TRACE("calling..");
int status = dc_set_config_from_qr(dcn_context->dc_context, qr);
//TRACE("result %d", status);

free(qr);

NAPI_RETURN_INT32(status);
}

NAPI_METHOD(dcn_estimate_deletion_cnt) {
NAPI_ARGV(3);
NAPI_DCN_CONTEXT();
Expand Down Expand Up @@ -3165,6 +3179,7 @@ NAPI_INIT() {
NAPI_EXPORT_FUNCTION(dcn_set_chat_mute_duration);
NAPI_EXPORT_FUNCTION(dcn_set_config);
NAPI_EXPORT_FUNCTION(dcn_set_config_null);
NAPI_EXPORT_FUNCTION(dcn_set_config_from_qr);
NAPI_EXPORT_FUNCTION(dcn_estimate_deletion_cnt);
NAPI_EXPORT_FUNCTION(dcn_set_draft);
NAPI_EXPORT_FUNCTION(dcn_set_stock_translation);
Expand Down

0 comments on commit e89da5c

Please sign in to comment.