From 4f71c77ae4439c398f627e951e109d3a22039e76 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 15 Feb 2025 02:06:27 +0000 Subject: [PATCH] build: remove deprecated node module --- .github/workflows/ci.yml | 13 - .github/workflows/node-docs.yml | 44 - .github/workflows/node-package.yml | 240 -- .github/workflows/node-tests.yml | 71 - README.md | 4 +- node/.prettierrc.yml | 6 - node/CONTRIBUTORS.md | 21 - node/LICENSE | 674 ----- node/README.md | 260 -- node/binding.gyp | 78 - node/binding.js | 1 - node/constants.js | 311 -- node/events.js | 50 - node/examples/send_message.js | 40 - node/images/tests.png | Bin 26489 -> 0 bytes node/lib/binding.ts | 9 - node/lib/chat.ts | 111 - node/lib/chatlist.ts | 42 - node/lib/constants.ts | 361 --- node/lib/contact.ts | 98 - node/lib/context.ts | 897 ------ node/lib/deltachat.ts | 234 -- node/lib/index.ts | 20 - node/lib/locations.ts | 82 - node/lib/lot.ts | 52 - node/lib/message.ts | 366 --- node/lib/types.ts | 25 - node/lib/util.ts | 6 - node/patches/m1_build_use_x86_64.patch | 13 - node/scripts/common.js | 26 - node/scripts/generate-constants.js | 65 - node/scripts/install.js | 22 - node/scripts/postLinksToDetails.js | 47 - node/scripts/postinstall.js | 57 - node/scripts/rebuild-core.js | 17 - node/src/module.c | 3600 ------------------------ node/src/napi-macros-extensions.h | 144 - node/test/fixtures/avatar.png | Bin 7901 -> 0 bytes node/test/fixtures/image.jpeg | Bin 13096 -> 0 bytes node/test/fixtures/logo.png | Bin 27597 -> 0 bytes node/test/test.mjs | 943 ------- node/tsconfig.json | 22 - node/windows.md | 37 - package.json | 59 - 44 files changed, 1 insertion(+), 9167 deletions(-) delete mode 100644 .github/workflows/node-docs.yml delete mode 100644 .github/workflows/node-package.yml delete mode 100644 .github/workflows/node-tests.yml delete mode 100644 node/.prettierrc.yml delete mode 100644 node/CONTRIBUTORS.md delete mode 100644 node/LICENSE delete mode 100644 node/README.md delete mode 100644 node/binding.gyp delete mode 100644 node/binding.js delete mode 100644 node/constants.js delete mode 100644 node/events.js delete mode 100644 node/examples/send_message.js delete mode 100644 node/images/tests.png delete mode 100644 node/lib/binding.ts delete mode 100644 node/lib/chat.ts delete mode 100644 node/lib/chatlist.ts delete mode 100644 node/lib/constants.ts delete mode 100644 node/lib/contact.ts delete mode 100644 node/lib/context.ts delete mode 100644 node/lib/deltachat.ts delete mode 100644 node/lib/index.ts delete mode 100644 node/lib/locations.ts delete mode 100644 node/lib/lot.ts delete mode 100644 node/lib/message.ts delete mode 100644 node/lib/types.ts delete mode 100644 node/lib/util.ts delete mode 100644 node/patches/m1_build_use_x86_64.patch delete mode 100644 node/scripts/common.js delete mode 100755 node/scripts/generate-constants.js delete mode 100644 node/scripts/install.js delete mode 100644 node/scripts/postLinksToDetails.js delete mode 100644 node/scripts/postinstall.js delete mode 100644 node/scripts/rebuild-core.js delete mode 100644 node/src/module.c delete mode 100644 node/src/napi-macros-extensions.h delete mode 100644 node/test/fixtures/avatar.png delete mode 100644 node/test/fixtures/image.jpeg delete mode 100644 node/test/fixtures/logo.png delete mode 100644 node/test/test.mjs delete mode 100644 node/tsconfig.json delete mode 100644 node/windows.md delete mode 100644 package.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab7042d44..57820c300 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,19 +45,6 @@ jobs: - name: Check with only default features run: cargo check --all-targets - npm_constants: - name: Check if node constants are up to date - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - show-progress: false - persist-credentials: false - - name: Rebuild constants - run: npm run build:core:constants - - name: Check that constants are not changed - run: git diff --exit-code - cargo_deny: name: cargo deny runs-on: ubuntu-latest diff --git a/.github/workflows/node-docs.yml b/.github/workflows/node-docs.yml deleted file mode 100644 index 9522f3095..000000000 --- a/.github/workflows/node-docs.yml +++ /dev/null @@ -1,44 +0,0 @@ -# GitHub Actions workflow to build -# Node.js bindings documentation -# and upload it to the web server. -# Built documentation is available at - -name: Generate & upload node.js documentation - -on: - push: - branches: - - main - -permissions: {} - -jobs: - generate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - show-progress: false - persist-credentials: false - - - name: Use Node.js 18.x - uses: actions/setup-node@v4 - with: - node-version: 18.x - - - name: npm install and generate documentation - working-directory: node - run: | - npm i --ignore-scripts - npx typedoc - mv docs js - - - name: Upload - uses: horochx/deploy-via-scp@1.1.0 - with: - user: ${{ secrets.USERNAME }} - key: ${{ secrets.KEY }} - host: "delta.chat" - port: 22 - local: "node/js" - remote: "/var/www/html/" diff --git a/.github/workflows/node-package.yml b/.github/workflows/node-package.yml deleted file mode 100644 index 95f14607b..000000000 --- a/.github/workflows/node-package.yml +++ /dev/null @@ -1,240 +0,0 @@ -name: "node.js build" -on: - pull_request: - push: - tags: - - "*" - - "!py-*" - -permissions: {} - -jobs: - prebuild: - name: Prebuild - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [macos-latest, windows-latest] - steps: - - uses: actions/checkout@v4 - with: - show-progress: false - persist-credentials: false - - uses: actions/setup-node@v4 - with: - node-version: "18" - - name: System info - run: | - rustc -vV - rustup -vV - cargo -vV - npm --version - node --version - - - name: Cache node modules - uses: actions/cache@v4 - with: - path: | - ${{ env.APPDATA }}/npm-cache - ~/.npm - key: ${{ matrix.os }}-node-${{ hashFiles('**/package.json') }} - - - name: Cache cargo index - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry/ - ~/.cargo/git - target - key: ${{ matrix.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}-2 - - - name: Install dependencies & build - if: steps.cache.outputs.cache-hit != 'true' - working-directory: node - run: npm install --verbose - - - name: Build Prebuild - working-directory: node - run: | - npm run prebuildify - tar -zcvf "${{ matrix.os }}.tar.gz" -C prebuilds . - - - name: Upload Prebuild - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.os }} - path: node/${{ matrix.os }}.tar.gz - - prebuild-linux: - name: Prebuild Linux - runs-on: ubuntu-latest - - # Build Linux prebuilds inside a container with old glibc for backwards compatibility. - # Debian 10 contained glibc 2.28: https://packages.debian.org/buster/libc6 - container: debian:10 - steps: - # Working directory is owned by 1001:1001 by default. - # Change it to our user. - - name: Change working directory owner - run: chown root:root . - - - uses: actions/checkout@v4 - with: - show-progress: false - persist-credentials: false - - uses: actions/setup-node@v4 - with: - node-version: "18" - - run: apt-get update - - # Python is needed for node-gyp - - name: Install curl, python and compilers - run: apt-get install -y curl build-essential python3 - - name: Install Rust - run: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - name: System info - run: | - rustc -vV - rustup -vV - cargo -vV - npm --version - node --version - - - name: Cache node modules - uses: actions/cache@v4 - with: - path: | - ${{ env.APPDATA }}/npm-cache - ~/.npm - key: ${{ matrix.os }}-node-${{ hashFiles('**/package.json') }} - - - name: Cache cargo index - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry/ - ~/.cargo/git - target - key: ${{ matrix.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}-2 - - - name: Install dependencies & build - if: steps.cache.outputs.cache-hit != 'true' - working-directory: node - run: npm install --verbose - - - name: Build Prebuild - working-directory: node - run: | - npm run prebuildify - tar -zcvf "linux.tar.gz" -C prebuilds . - - - name: Upload Prebuild - uses: actions/upload-artifact@v4 - with: - name: linux - path: node/linux.tar.gz - - pack-module: - needs: [prebuild, prebuild-linux] - name: Package deltachat-node and upload to download.delta.chat - runs-on: ubuntu-latest - steps: - - name: Install tree - run: sudo apt install tree - - uses: actions/checkout@v4 - with: - show-progress: false - persist-credentials: false - - uses: actions/setup-node@v4 - with: - node-version: "18" - - name: Get tag - id: tag - uses: dawidd6/action-get-tag@v1 - continue-on-error: true - - name: Get Pull Request ID - id: prepare - run: | - tag=${{ steps.tag.outputs.tag }} - if [ -z "$tag" ]; then - node -e "console.log('DELTACHAT_NODE_TAR_GZ=deltachat-node-' + '${{ github.ref }}'.split('/')[2] + '.tar.gz')" >> $GITHUB_ENV - else - echo "DELTACHAT_NODE_TAR_GZ=deltachat-node-${{ steps.tag.outputs.tag }}.tar.gz" >> $GITHUB_ENV - echo "No preview will be uploaded this time, but the $tag release" - fi - - name: System info - run: | - rustc -vV - rustup -vV - cargo -vV - npm --version - node --version - echo $DELTACHAT_NODE_TAR_GZ - - name: Download Linux prebuild - uses: actions/download-artifact@v4 - with: - name: linux - - name: Download macOS prebuild - uses: actions/download-artifact@v4 - with: - name: macos-latest - - name: Download Windows prebuild - uses: actions/download-artifact@v4 - with: - name: windows-latest - - shell: bash - run: | - mkdir node/prebuilds - tar -xvzf linux.tar.gz -C node/prebuilds - tar -xvzf macos-latest.tar.gz -C node/prebuilds - tar -xvzf windows-latest.tar.gz -C node/prebuilds - tree node/prebuilds - rm -f linux.tar.gz macos-latest.tar.gz windows-latest.tar.gz - - name: Install dependencies without running scripts - run: | - npm install --ignore-scripts - - name: Build constants - run: | - npm run build:core:constants - - name: Build TypeScript part - run: | - npm run build:bindings:ts - - name: Package - shell: bash - run: | - mv node/README.md README.md - npm pack . - ls -lah - mv $(find deltachat-node-*) $DELTACHAT_NODE_TAR_GZ - - name: Upload prebuild - uses: actions/upload-artifact@v4 - with: - name: deltachat-node.tgz - path: ${{ env.DELTACHAT_NODE_TAR_GZ }} - # Upload to download.delta.chat/node/preview/ - - name: Upload deltachat-node preview to download.delta.chat/node/preview/ - if: ${{ ! steps.tag.outputs.tag }} - id: upload-preview - shell: bash - run: | - echo -e "${{ secrets.SSH_KEY }}" >__TEMP_INPUT_KEY_FILE - chmod 600 __TEMP_INPUT_KEY_FILE - scp -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE -P "22" -r $DELTACHAT_NODE_TAR_GZ "${{ secrets.USERNAME }}"@"download.delta.chat":"/var/www/html/download/node/preview/" - continue-on-error: true - - name: Post links to details - if: steps.upload-preview.outcome == 'success' - run: node ./node/scripts/postLinksToDetails.js - env: - URL: preview/${{ env.DELTACHAT_NODE_TAR_GZ }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Upload to download.delta.chat/node/ - - name: Upload deltachat-node build to download.delta.chat/node/ - if: ${{ steps.tag.outputs.tag }} - id: upload - shell: bash - run: | - echo -e "${{ secrets.SSH_KEY }}" >__TEMP_INPUT_KEY_FILE - chmod 600 __TEMP_INPUT_KEY_FILE - scp -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE -P "22" -r $DELTACHAT_NODE_TAR_GZ "${{ secrets.USERNAME }}"@"download.delta.chat":"/var/www/html/download/node/" diff --git a/.github/workflows/node-tests.yml b/.github/workflows/node-tests.yml deleted file mode 100644 index 73b7fe7b9..000000000 --- a/.github/workflows/node-tests.yml +++ /dev/null @@ -1,71 +0,0 @@ -# GitHub Actions workflow -# to test Node.js bindings. - -name: "node.js tests" - -# Cancel previously started workflow runs -# when the branch is updated. -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -on: - pull_request: - push: - branches: - - main - -permissions: {} - -jobs: - tests: - name: Tests - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - steps: - - uses: actions/checkout@v4 - with: - show-progress: false - persist-credentials: false - - uses: actions/setup-node@v4 - with: - node-version: "18" - - name: System info - run: | - rustc -vV - rustup -vV - cargo -vV - npm --version - node --version - - - name: Cache node modules - uses: actions/cache@v4 - with: - path: | - ${{ env.APPDATA }}/npm-cache - ~/.npm - key: ${{ matrix.os }}-node-${{ hashFiles('**/package.json') }} - - - name: Cache cargo index - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry/ - ~/.cargo/git - target - key: ${{ matrix.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}-2 - - - name: Install dependencies & build - if: steps.cache.outputs.cache-hit != 'true' - working-directory: node - run: npm install --verbose - - - name: Test - timeout-minutes: 10 - working-directory: node - run: npm run test - env: - CHATMAIL_DOMAIN: ${{ vars.CHATMAIL_DOMAIN }} - NODE_OPTIONS: "--force-node-api-uncaught-exceptions-policy=true" diff --git a/README.md b/README.md index 1e8d6f437..ec2589990 100644 --- a/README.md +++ b/README.md @@ -176,9 +176,7 @@ To add the updates from the Language bindings are available for: - **C** \[[πŸ“‚ source](./deltachat-ffi) | [πŸ“š docs](https://c.delta.chat)\] -- **Node.js** - - over JSON-RPC: \[[πŸ“‚ source](./deltachat-rpc-client) | [πŸ“¦ npm](https://www.npmjs.com/package/@deltachat/jsonrpc-client) | [πŸ“š docs](https://js.jsonrpc.delta.chat/)\] - - over CFFI[^1]: \[[πŸ“‚ source](./node) | [πŸ“¦ npm](https://www.npmjs.com/package/deltachat-node) | [πŸ“š docs](https://js.delta.chat/)\] +- **JS**: \[[πŸ“‚ source](./deltachat-rpc-client) | [πŸ“¦ npm](https://www.npmjs.com/package/@deltachat/jsonrpc-client) | [πŸ“š docs](https://js.jsonrpc.delta.chat/)\] - **Python** \[[πŸ“‚ source](./python) | [πŸ“¦ pypi](https://pypi.org/project/deltachat) | [πŸ“š docs](https://py.delta.chat)\] - **Go** - over jsonrpc: \[[πŸ“‚ source](https://github.com/deltachat/deltachat-rpc-client-go/)\] diff --git a/node/.prettierrc.yml b/node/.prettierrc.yml deleted file mode 100644 index 5ca635d59..000000000 --- a/node/.prettierrc.yml +++ /dev/null @@ -1,6 +0,0 @@ -# .prettierrc -trailingComma: es5 -tabWidth: 2 -semi: false -singleQuote: true -jsxSingleQuote: true diff --git a/node/CONTRIBUTORS.md b/node/CONTRIBUTORS.md deleted file mode 100644 index 1c81d4add..000000000 --- a/node/CONTRIBUTORS.md +++ /dev/null @@ -1,21 +0,0 @@ -# Contributors - -| Name | GitHub | -| :-------------------- | :----------------------------------------------- | -| **Lars-Magnus Skog** | | -| **jikstra** | | -| **Simon Laux** | [**@Simon-Laux**](https://github.com/Simon-Laux) | -| **Jikstra** | [**@Jikstra**](https://github.com/Jikstra) | -| **Nico de Haen** | | -| **B. Petersen** | | -| **Karissa McKelvey** | [**@karissa**](https://github.com/karissa) | -| **developer** | | -| **Alexander Krotov** | | -| **Floris Bruynooghe** | | -| **lefherz** | | -| **Pablo** | [**@pabzm**](https://github.com/pabzm) | -| **pabzm** | | -| **holger krekel** | | -| **Robert SchΓΌtz** | | -| **bb** | | -| **Charles Paul** | | diff --git a/node/LICENSE b/node/LICENSE deleted file mode 100644 index 94a9ed024..000000000 --- a/node/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/node/README.md b/node/README.md deleted file mode 100644 index 93a0beb76..000000000 --- a/node/README.md +++ /dev/null @@ -1,260 +0,0 @@ -# deltachat-node - -> node.js bindings for [`deltachat-core-rust`](..) - -[![npm](https://img.shields.io/npm/v/deltachat-node.svg)](https://www.npmjs.com/package/deltachat-node) -![Node version](https://img.shields.io/node/v/deltachat-node.svg) -[![JavaScript Style Guide](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) - -`deltachat-node` primarily aims to offer two things: - -- A high level JavaScript api with syntactic sugar -- A low level c binding api around [`deltachat-core-rust`](..) - -This code used to live at [`deltachat-node`](https://github.com/deltachat/deltachat-node) - -## Table of Contents - -
Click to expand - -- [Install](#install) -- [Dependencies](#dependencies) -- [Build from source](#build-from-source) -- [Usage](#usage) -- [Developing](#developing) -- [License](#license) - -
- -## Install - -By default the installation will try to use the bundled prebuilds in the -npm package. If this fails it falls back to compile `../deltachat-core-rust` from -this repository, using `scripts/rebuild-core.js`. - -To install from npm use: - -``` -npm install deltachat-node -``` - -## Dependencies - -- Nodejs >= `v18.0.0` -- rustup (optional if you can't use the prebuilds) - -> On Windows, you may need to also install **Perl** to be able to compile deltachat-core. - -## Build from source - -If you want to build from source, make sure that you have `rustup` installed. -You can either use `npm install deltachat-node --build-from-source` to force -building from source or clone this repository and follow this steps: - -1. `git clone https://github.com/deltachat/deltachat-core-rust.git` -2. `cd deltachat-core-rust` -3. `npm i` -4. `npm run build` - -> Our `package.json` file is located in the root directory of this repository, -> not inside this folder. (We need this in order to include the rust source -> code in the npm package.) - -### Use a git branch in deltachat-desktop - -You can directly install a core branch, but make sure: -- that you have typescript in your project dependencies, as it is likely required -- you know that there are **no prebuilds** and so core is built during installation which is why it takes so long - -``` -npm install https://github.com/deltachat/deltachat-core-rust.git#branch -``` - -If you want prebuilds for a branch that has a core pr, you might find an npm tar.gz package for that branch at . -The github ci also posts a link to it in the checks for each pr. - -### Use build-from-source in deltachat-desktop - -If you want to use the manually built node bindings in the desktop client (for -example), you can follow these instructions: - -First clone the -[deltachat-desktop](https://github.com/deltachat/deltachat-desktop) repository, -e.g. with `git clone https://github.com/deltachat/deltachat-desktop`. - -Then you need to make sure that this directory is referenced correctly in -deltachat-desktop's package.json. You need to change -`deltachat-desktop/package.json` like this: - -``` -diff --git i/package.json w/package.json -index 45893894..5154512c 100644 ---- i/package.json -+++ w/package.json -@@ -83,7 +83,7 @@ - "application-config": "^1.0.1", - "classnames": "^2.3.1", - "debounce": "^1.2.0", -- "deltachat-node": "1.79.3", -+ "deltachat-node": "file:../deltachat-core-rust/", - "emoji-js-clean": "^4.0.0", - "emoji-mart": "^3.0.1", - "emoji-regex": "^9.2.2", -``` - -Then, in the `deltachat-desktop` repository, run: - -1. `npm i` -2. `npm run build` -3. And `npm run start` to start the newly built client. - -### Workaround to build for x86_64 on Apple's M1 - -deltachat doesn't support universal (fat) binaries (that contain builds for both cpu architectures) yet, until it does you can use the following workaround to get x86_64 builds: - -``` -$ fnm install 19 --arch x64 -$ fnm use 19 -$ node -p process.arch -# result should be x64 -$ rustup target add x86_64-apple-darwin -$ git apply patches/m1_build_use_x86_64.patch -$ CARGO_BUILD_TARGET=x86_64-apple-darwin npm run build -$ npm run test -``` - -(when using [fnm](https://github.com/Schniz/fnm) instead of nvm, you can select the architecture) -If your node and electron are already build for arm64 you can also try building for arm: - -``` -$ fnm install 18 --arch arm64 -$ fnm use 18 -$ node -p process.arch -# result should be arm64 -$ npm_config_arch=arm64 npm run build -$ npm run test -``` - -## Usage - -```js -const { Context } = require('deltachat-node') - -const opts = { - addr: '[email]', - mail_pw: '[password]', -} - -const contact = '[email]' - -async function main() { - const dc = Context.open('./') - dc.on('ALL', console.log.bind(null, 'core |')) - - try { - await dc.configure(opts) - } catch (err) { - console.error('Failed to configure because of: ', err) - dc.unref() - return - } - - dc.startIO() - console.log('fully configured') - - const contactId = dc.createContact('Test', contact) - const chatId = dc.createChatByContactId(contactId) - dc.sendMessage(chatId, 'Hi!') - - console.log('sent message') - - dc.once('DC_EVENT_SMTP_MESSAGE_SENT', async () => { - console.log('Message sent, shutting down...') - dc.stopIO() - console.log('stopped io') - dc.unref() - }) -} - -main() -``` -this example can also be found in the examples folder [examples/send_message.js](./examples/send_message.js) - -### Generating Docs - -We are currently migrating to automatically generated documentation. -You can find the old documentation at [old_docs](./old_docs). - -to generate the documentation, run: - -``` -npx typedoc -``` - -The resulting documentation can be found in the `docs/` folder. -An online version can be found under [js.delta.chat](https://js.delta.chat). - -## Developing - -### Tests and Coverage - -Running `npm test` ends with showing a code coverage report, which is produced by [`nyc`](https://github.com/istanbuljs/nyc#readme). - -![test output](images/tests.png) - -The coverage report from `nyc` in the console is rather limited. To get a more detailed coverage report you can run `npm run coverage-html-report`. This will produce a html report from the `nyc` data and display it in a browser on your local machine. - -To run the integration tests you need to set the `CHATMAIL_DOMAIN` environment variables. E.g.: - -``` -$ export CHATMAIL_DOMAIN=chat.example.org -$ npm run test -``` - -### Scripts - -We have the following scripts for building, testing and coverage: - -- `npm run coverage` Creates a coverage report and passes it to `coveralls`. Only done by `Travis`. -- `npm run coverage-html-report` Generates a html report from the coverage data and opens it in a browser on the local machine. -- `npm run generate-constants` Generates `constants.js` and `events.js` based on the `deltachat-core-rust/deltachat-ffi/deltachat.h` header file. -- `npm install` After dependencies are installed, runs `node-gyp-build` to see if the native code needs to be rebuilt. -- `npm run build` Rebuilds all code. -- `npm run build:core` Rebuilds code in `deltachat-core-rust`. -- `npm run build:bindings` Rebuilds the bindings and links with `deltachat-core-rust`. -- `ΗΉpm run clean` Removes all built code -- `npm run prebuildify` Builds prebuilt binary to `prebuilds/$PLATFORM-$ARCH`. Copies `deltachat.dll` from `deltachat-core-rust` for windows. -- `npm run download-prebuilds` Downloads all prebuilt binaries from github before `npm publish`. -- `npm test` Runs `standard` and then the tests in `test/index.js`. -- `npm run test-integration` Runs the integration tests. -- `npm run hallmark` Runs `hallmark` on all markdown files. - -### Releases - -The following steps are needed to make a release: - -1. Wait until `pack-module` github action is completed -2. Run `npm publish https://download.delta.chat/node/deltachat-node-1.x.x.tar.gz` to publish it to npm. You probably need write rights to npm. - -## License - -Licensed under `GPL-3.0-or-later`, see [LICENSE](./LICENSE) file for details. - -> Copyright Β© 2018 `DeltaChat` contributors. -> -> This program is free software: you can redistribute it and/or modify -> it under the terms of the GNU General Public License as published by -> the Free Software Foundation, either version 3 of the License, or -> (at your option) any later version. -> -> This program is distributed in the hope that it will be useful, -> but WITHOUT ANY WARRANTY; without even the implied warranty of -> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -> GNU General Public License for more details. -> -> You should have received a copy of the GNU General Public License -> along with this program. If not, see . - -[appveyor-shield]: https://ci.appveyor.com/api/projects/status/t0narp672wpbl6pd?svg=true - -[appveyor]: https://ci.appveyor.com/project/ralphtheninja/deltachat-node-d4bf8 diff --git a/node/binding.gyp b/node/binding.gyp deleted file mode 100644 index b0d92eae9..000000000 --- a/node/binding.gyp +++ /dev/null @@ -1,78 +0,0 @@ -{ - # documentation about the format of this file can be found under https://gyp.gsrc.io/docs/InputFormatReference.md - # Variables can be specified when calling node-gyp as so: - # node-gyp configure -- -Dvarname=value - "variables": { - # Whether to use a system-wide installation of deltachat-core - # using pkg-config. Set to either "true" or "false". - "USE_SYSTEM_LIBDELTACHAT%": " { - console.log('Message sent, shutting down...') - dc.stopIO() - console.log('stopped io') - dc.unref() - }) -} - -main() diff --git a/node/images/tests.png b/node/images/tests.png deleted file mode 100644 index 829295b38dcc66061e5c924e90a6a75fde432d1b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 26489 zcmce;1yEewwlzvZ2niZOa0`$C!QCaeyF0<%U6bJMH12L4+$Fd>G|)IS?$EgWo$ov6 z{P&)F-e2!kz4xd^QEO9Od+oXA8gtAs=k8DiIdN1Zd?YwHI8;dq5hXad7n`tO&Nr`N zSInc*W?+9_ISEOsyn+3AzcCJh&GDQ?HJp|0Or71nIhw$k+1lBd&^Z}7nwZ!+ncF#^ zz<2P&!F`026cJQ$Pd{9CbN?`V*LikgEot}Z)ti9#mga&O zjoEm*hnea4$l)OYUA}1XVl4#%X}~)n&Y<6u@b84)kRCfTh(MhU!o*-o??i%6#^Fir6B9=(W3_O1drU6yt5{##TirX+d&rDHeSOiJW^*

O&>Q={4h^?wmGwCZ<&fxSnXowQu8`^3!TAqMZ?cHA2j5sq z)Xh{J)^Iv%6i7Ol?(sMuoxk=g)Fk3dHe_ML8=zs^o(AfQ6CdBbdX^h=*maK(Y{O&A zM>vk+WWo>%aU6rItR>;gf+!=tn{fPuY}O&75dVZ?VOxDx33um>Ihx8g*wZgkZ|0R$reM!t@@oQYlCE^(B_dpJteUG#wec z20(kU7+-hDdLL@faQv*AEDNw(kudare-MXrCRj97-$6N{S;=*Y+SN`ZvMeTiOUnE6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!^~F4D;KJ|LgiAZv6vI`vD2%?NLy%SR#PoM>=RfOth1p9~H& zB)_Nkwqy;HUeR{2d{vMoPHZ2H(>t>s+cFtst@d=z+p2?i#7`qjn9UriIpB+wkPkz~ zmng=oxf5nWs zC>kZ3PSM-(cE!)=V~lbE_u(GI4$>-ev=b%kMwxDZOEO(ik;;@13S|Jgna_&qHt?rp zR2miD$8^`qc^%Yv&u=2nu0%m!V%BGxw1j6%wOyTD+qd3sm zR`*y@cJjF^Q>l)IaZ?smk}vURJ^Ynx7SA`=yjrfWc%t?ycJq-(_;*yWhLlJ)ROCSG zx!&U^GlaI3>Uo__`9#f+NY6c;H$+loa=hnxgb! zFP1;ufRK3IZdo}?c;qXAj~&g=IcDa_PyG?%WDyGf80)z)XyQIHZU*aOrP;`_4d{Oq zed+AE*Ft!x@yD&Ebl6UR&)}$B^eF^5Y6~V_8^m?K?$fx8-2&C;2iWQTL)j_+rR;}S z)6owG_7k#a2#NZ~*zPczw?Vrs{%e{b{C_9wru*BFUiF6`KBl0dH+(?!Xr9nS=zkoe zWW4*10gse}M%T*ggsr-^AFv;tS4oI#ZwuuY%KzvlX@}cfcm@^O=+6l*!cWux;{STL q`)h*Qzt)oh@IPI4(BIWgy~(ZjfpH07EyTBTkfh(rOO%S~`~DB3`Q1JM diff --git a/node/lib/binding.ts b/node/lib/binding.ts deleted file mode 100644 index 275bf12ff..000000000 --- a/node/lib/binding.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { join } from 'path' - -/** - * bindings are not typed yet. - * if the available function names are required they can be found inside of `../src/module.c` - */ -export const bindings: any = require('node-gyp-build')(join(__dirname, '../')) - -export default bindings diff --git a/node/lib/chat.ts b/node/lib/chat.ts deleted file mode 100644 index 49a6b8f52..000000000 --- a/node/lib/chat.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* eslint-disable camelcase */ - -import binding from './binding' -import rawDebug from 'debug' -const debug = rawDebug('deltachat:node:chat') -import { C } from './constants' -import { integerToHexColor } from './util' -import { ChatJSON } from './types' - -interface NativeChat {} -/** - * Wrapper around dc_chat_t* - */ - -export class Chat { - constructor(public dc_chat: NativeChat) { - debug('Chat constructor') - if (dc_chat === null) { - throw new Error('native chat can not be null') - } - } - - getVisibility(): - | C.DC_CHAT_VISIBILITY_NORMAL - | C.DC_CHAT_VISIBILITY_ARCHIVED - | C.DC_CHAT_VISIBILITY_PINNED { - return binding.dcn_chat_get_visibility(this.dc_chat) - } - - get color(): string { - return integerToHexColor(binding.dcn_chat_get_color(this.dc_chat)) - } - - getId(): number { - return binding.dcn_chat_get_id(this.dc_chat) - } - - getName(): string { - return binding.dcn_chat_get_name(this.dc_chat) - } - - getMailinglistAddr(): string { - return binding.dcn_chat_get_mailinglist_addr(this.dc_chat) - } - - getProfileImage(): string { - return binding.dcn_chat_get_profile_image(this.dc_chat) - } - - getType(): number { - return binding.dcn_chat_get_type(this.dc_chat) - } - - isSelfTalk(): boolean { - return Boolean(binding.dcn_chat_is_self_talk(this.dc_chat)) - } - - isContactRequest(): boolean { - return Boolean(binding.dcn_chat_is_contact_request(this.dc_chat)) - } - - isUnpromoted(): boolean { - return Boolean(binding.dcn_chat_is_unpromoted(this.dc_chat)) - } - - isProtected(): boolean { - return Boolean(binding.dcn_chat_is_protected(this.dc_chat)) - } - - get canSend(): boolean { - return Boolean(binding.dcn_chat_can_send(this.dc_chat)) - } - - isDeviceTalk(): boolean { - return Boolean(binding.dcn_chat_is_device_talk(this.dc_chat)) - } - - isSingle(): boolean { - return this.getType() === C.DC_CHAT_TYPE_SINGLE - } - - isGroup(): boolean { - return this.getType() === C.DC_CHAT_TYPE_GROUP - } - - isMuted(): boolean { - return Boolean(binding.dcn_chat_is_muted(this.dc_chat)) - } - - toJson(): ChatJSON { - debug('toJson') - const visibility = this.getVisibility() - return { - archived: visibility === C.DC_CHAT_VISIBILITY_ARCHIVED, - pinned: visibility === C.DC_CHAT_VISIBILITY_PINNED, - color: this.color, - id: this.getId(), - name: this.getName(), - mailinglistAddr: this.getMailinglistAddr(), - profileImage: this.getProfileImage(), - type: this.getType(), - isSelfTalk: this.isSelfTalk(), - isUnpromoted: this.isUnpromoted(), - isProtected: this.isProtected(), - canSend: this.canSend, - isDeviceTalk: this.isDeviceTalk(), - isContactRequest: this.isContactRequest(), - muted: this.isMuted(), - } - } -} diff --git a/node/lib/chatlist.ts b/node/lib/chatlist.ts deleted file mode 100644 index 73233e006..000000000 --- a/node/lib/chatlist.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* eslint-disable camelcase */ - -import binding from './binding' -import { Lot } from './lot' -import { Chat } from './chat' -const debug = require('debug')('deltachat:node:chatlist') - -interface NativeChatList {} -/** - * Wrapper around dc_chatlist_t* - */ -export class ChatList { - constructor(private dc_chatlist: NativeChatList) { - debug('ChatList constructor') - if (dc_chatlist === null) { - throw new Error('native chat list can not be null') - } - } - - getChatId(index: number): number { - debug(`getChatId ${index}`) - return binding.dcn_chatlist_get_chat_id(this.dc_chatlist, index) - } - - getCount(): number { - debug('getCount') - return binding.dcn_chatlist_get_cnt(this.dc_chatlist) - } - - getMessageId(index: number): number { - debug(`getMessageId ${index}`) - return binding.dcn_chatlist_get_msg_id(this.dc_chatlist, index) - } - - getSummary(index: number, chat?: Chat): Lot { - debug(`getSummary ${index}`) - const dc_chat = (chat && chat.dc_chat) || null - return new Lot( - binding.dcn_chatlist_get_summary(this.dc_chatlist, index, dc_chat) - ) - } -} diff --git a/node/lib/constants.ts b/node/lib/constants.ts deleted file mode 100644 index 6c5801616..000000000 --- a/node/lib/constants.ts +++ /dev/null @@ -1,361 +0,0 @@ -// Generated! - -export enum C { - DC_CERTCK_ACCEPT_INVALID = 2, - DC_CERTCK_ACCEPT_INVALID_CERTIFICATES = 3, - DC_CERTCK_AUTO = 0, - DC_CERTCK_STRICT = 1, - DC_CHAT_ID_ALLDONE_HINT = 7, - DC_CHAT_ID_ARCHIVED_LINK = 6, - DC_CHAT_ID_LAST_SPECIAL = 9, - DC_CHAT_ID_TRASH = 3, - DC_CHAT_TYPE_BROADCAST = 160, - DC_CHAT_TYPE_GROUP = 120, - DC_CHAT_TYPE_MAILINGLIST = 140, - DC_CHAT_TYPE_SINGLE = 100, - DC_CHAT_TYPE_UNDEFINED = 0, - DC_CHAT_VISIBILITY_ARCHIVED = 1, - DC_CHAT_VISIBILITY_NORMAL = 0, - DC_CHAT_VISIBILITY_PINNED = 2, - DC_CONNECTIVITY_CONNECTED = 4000, - DC_CONNECTIVITY_CONNECTING = 2000, - DC_CONNECTIVITY_NOT_CONNECTED = 1000, - DC_CONNECTIVITY_WORKING = 3000, - DC_CONTACT_ID_DEVICE = 5, - DC_CONTACT_ID_INFO = 2, - DC_CONTACT_ID_LAST_SPECIAL = 9, - DC_CONTACT_ID_SELF = 1, - DC_DOWNLOAD_AVAILABLE = 10, - DC_DOWNLOAD_DONE = 0, - DC_DOWNLOAD_FAILURE = 20, - DC_DOWNLOAD_IN_PROGRESS = 1000, - DC_DOWNLOAD_UNDECIPHERABLE = 30, - DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE = 2200, - DC_EVENT_ACCOUNTS_CHANGED = 2302, - DC_EVENT_ACCOUNTS_ITEM_CHANGED = 2303, - DC_EVENT_CHANNEL_OVERFLOW = 2400, - DC_EVENT_CHATLIST_CHANGED = 2300, - DC_EVENT_CHATLIST_ITEM_CHANGED = 2301, - DC_EVENT_CHAT_EPHEMERAL_TIMER_MODIFIED = 2021, - DC_EVENT_CHAT_MODIFIED = 2020, - DC_EVENT_CONFIGURE_PROGRESS = 2041, - DC_EVENT_CONFIG_SYNCED = 2111, - DC_EVENT_CONNECTIVITY_CHANGED = 2100, - DC_EVENT_CONTACTS_CHANGED = 2030, - DC_EVENT_DELETED_BLOB_FILE = 151, - DC_EVENT_ERROR = 400, - DC_EVENT_ERROR_SELF_NOT_IN_GROUP = 410, - DC_EVENT_IMAP_CONNECTED = 102, - DC_EVENT_IMAP_INBOX_IDLE = 106, - DC_EVENT_IMAP_MESSAGE_DELETED = 104, - DC_EVENT_IMAP_MESSAGE_MOVED = 105, - DC_EVENT_IMEX_FILE_WRITTEN = 2052, - DC_EVENT_IMEX_PROGRESS = 2051, - DC_EVENT_INCOMING_MSG = 2005, - DC_EVENT_INCOMING_MSG_BUNCH = 2006, - DC_EVENT_INCOMING_REACTION = 2002, - DC_EVENT_INCOMING_WEBXDC_NOTIFY = 2003, - DC_EVENT_INFO = 100, - DC_EVENT_LOCATION_CHANGED = 2035, - DC_EVENT_MSGS_CHANGED = 2000, - DC_EVENT_MSGS_NOTICED = 2008, - DC_EVENT_MSG_DELETED = 2016, - DC_EVENT_MSG_DELIVERED = 2010, - DC_EVENT_MSG_FAILED = 2012, - DC_EVENT_MSG_READ = 2015, - DC_EVENT_NEW_BLOB_FILE = 150, - DC_EVENT_REACTIONS_CHANGED = 2001, - DC_EVENT_SECUREJOIN_INVITER_PROGRESS = 2060, - DC_EVENT_SECUREJOIN_JOINER_PROGRESS = 2061, - DC_EVENT_SELFAVATAR_CHANGED = 2110, - DC_EVENT_SMTP_CONNECTED = 101, - DC_EVENT_SMTP_MESSAGE_SENT = 103, - DC_EVENT_WARNING = 300, - DC_EVENT_WEBXDC_INSTANCE_DELETED = 2121, - DC_EVENT_WEBXDC_REALTIME_ADVERTISEMENT = 2151, - DC_EVENT_WEBXDC_REALTIME_DATA = 2150, - DC_EVENT_WEBXDC_STATUS_UPDATE = 2120, - DC_GCL_ADD_ALLDONE_HINT = 4, - DC_GCL_ADD_SELF = 2, - DC_GCL_ARCHIVED_ONLY = 1, - DC_GCL_FOR_FORWARDING = 8, - DC_GCL_NO_SPECIALS = 2, - DC_GCL_VERIFIED_ONLY = 1, - DC_GCM_ADDDAYMARKER = 1, - DC_GCM_INFO_ONLY = 2, - DC_IMEX_EXPORT_BACKUP = 11, - DC_IMEX_EXPORT_SELF_KEYS = 1, - DC_IMEX_IMPORT_BACKUP = 12, - DC_IMEX_IMPORT_SELF_KEYS = 2, - DC_INFO_AUTOCRYPT_SETUP_MESSAGE = 6, - DC_INFO_EPHEMERAL_TIMER_CHANGED = 10, - DC_INFO_GROUP_IMAGE_CHANGED = 3, - DC_INFO_GROUP_NAME_CHANGED = 2, - DC_INFO_INVALID_UNENCRYPTED_MAIL = 13, - DC_INFO_LOCATIONSTREAMING_ENABLED = 8, - DC_INFO_LOCATION_ONLY = 9, - DC_INFO_MEMBER_ADDED_TO_GROUP = 4, - DC_INFO_MEMBER_REMOVED_FROM_GROUP = 5, - DC_INFO_PROTECTION_DISABLED = 12, - DC_INFO_PROTECTION_ENABLED = 11, - DC_INFO_SECURE_JOIN_MESSAGE = 7, - DC_INFO_UNKNOWN = 0, - DC_INFO_WEBXDC_INFO_MESSAGE = 32, - DC_KEY_GEN_DEFAULT = 0, - DC_KEY_GEN_ED25519 = 2, - DC_KEY_GEN_RSA2048 = 1, - DC_KEY_GEN_RSA4096 = 3, - DC_LP_AUTH_NORMAL = 4, - DC_LP_AUTH_OAUTH2 = 2, - DC_MEDIA_QUALITY_BALANCED = 0, - DC_MEDIA_QUALITY_WORSE = 1, - DC_MSG_AUDIO = 40, - DC_MSG_FILE = 60, - DC_MSG_GIF = 21, - DC_MSG_ID_DAYMARKER = 9, - DC_MSG_ID_LAST_SPECIAL = 9, - DC_MSG_ID_MARKER1 = 1, - DC_MSG_IMAGE = 20, - DC_MSG_STICKER = 23, - DC_MSG_TEXT = 10, - DC_MSG_VCARD = 90, - DC_MSG_VIDEO = 50, - DC_MSG_VIDEOCHAT_INVITATION = 70, - DC_MSG_VOICE = 41, - DC_MSG_WEBXDC = 80, - DC_PROVIDER_STATUS_BROKEN = 3, - DC_PROVIDER_STATUS_OK = 1, - DC_PROVIDER_STATUS_PREPARATION = 2, - DC_PUSH_CONNECTED = 2, - DC_PUSH_HEARTBEAT = 1, - DC_PUSH_NOT_CONNECTED = 0, - DC_QR_ACCOUNT = 250, - DC_QR_ADDR = 320, - DC_QR_ASK_VERIFYCONTACT = 200, - DC_QR_ASK_VERIFYGROUP = 202, - DC_QR_BACKUP = 251, - DC_QR_BACKUP2 = 252, - DC_QR_ERROR = 400, - DC_QR_FPR_MISMATCH = 220, - DC_QR_FPR_OK = 210, - DC_QR_FPR_WITHOUT_ADDR = 230, - DC_QR_LOGIN = 520, - DC_QR_PROXY = 271, - DC_QR_REVIVE_VERIFYCONTACT = 510, - DC_QR_REVIVE_VERIFYGROUP = 512, - DC_QR_TEXT = 330, - DC_QR_URL = 332, - DC_QR_WEBRTC_INSTANCE = 260, - DC_QR_WITHDRAW_VERIFYCONTACT = 500, - DC_QR_WITHDRAW_VERIFYGROUP = 502, - DC_SHOW_EMAILS_ACCEPTED_CONTACTS = 1, - DC_SHOW_EMAILS_ALL = 2, - DC_SHOW_EMAILS_OFF = 0, - DC_SOCKET_AUTO = 0, - DC_SOCKET_PLAIN = 3, - DC_SOCKET_SSL = 1, - DC_SOCKET_STARTTLS = 2, - DC_STATE_IN_FRESH = 10, - DC_STATE_IN_NOTICED = 13, - DC_STATE_IN_SEEN = 16, - DC_STATE_OUT_DELIVERED = 26, - DC_STATE_OUT_DRAFT = 19, - DC_STATE_OUT_FAILED = 24, - DC_STATE_OUT_MDN_RCVD = 28, - DC_STATE_OUT_PENDING = 20, - DC_STATE_OUT_PREPARING = 18, - DC_STATE_UNDEFINED = 0, - DC_STR_AC_SETUP_MSG_BODY = 43, - DC_STR_AC_SETUP_MSG_SUBJECT = 42, - DC_STR_ADD_MEMBER_BY_OTHER = 129, - DC_STR_ADD_MEMBER_BY_YOU = 128, - DC_STR_AEAP_ADDR_CHANGED = 122, - DC_STR_AEAP_EXPLANATION_AND_LINK = 123, - DC_STR_ARCHIVEDCHATS = 40, - DC_STR_AUDIO = 11, - DC_STR_BACKUP_TRANSFER_MSG_BODY = 163, - DC_STR_BACKUP_TRANSFER_QR = 162, - DC_STR_BAD_TIME_MSG_BODY = 85, - DC_STR_BROADCAST_LIST = 115, - DC_STR_CANNOT_LOGIN = 60, - DC_STR_CANTDECRYPT_MSG_BODY = 29, - DC_STR_CHAT_PROTECTION_DISABLED = 171, - DC_STR_CHAT_PROTECTION_ENABLED = 170, - DC_STR_CONFIGURATION_FAILED = 84, - DC_STR_CONNECTED = 107, - DC_STR_CONNTECTING = 108, - DC_STR_CONTACT = 200, - DC_STR_CONTACT_NOT_VERIFIED = 36, - DC_STR_CONTACT_SETUP_CHANGED = 37, - DC_STR_CONTACT_VERIFIED = 35, - DC_STR_DEVICE_MESSAGES = 68, - DC_STR_DEVICE_MESSAGES_HINT = 70, - DC_STR_DOWNLOAD_AVAILABILITY = 100, - DC_STR_DRAFT = 3, - DC_STR_E2E_AVAILABLE = 25, - DC_STR_E2E_PREFERRED = 34, - DC_STR_ENCRYPTEDMSG = 24, - DC_STR_ENCR_NONE = 28, - DC_STR_ENCR_TRANSP = 27, - DC_STR_EPHEMERAL_DAY = 79, - DC_STR_EPHEMERAL_DAYS = 95, - DC_STR_EPHEMERAL_DISABLED = 75, - DC_STR_EPHEMERAL_FOUR_WEEKS = 81, - DC_STR_EPHEMERAL_HOUR = 78, - DC_STR_EPHEMERAL_HOURS = 94, - DC_STR_EPHEMERAL_MINUTE = 77, - DC_STR_EPHEMERAL_MINUTES = 93, - DC_STR_EPHEMERAL_SECONDS = 76, - DC_STR_EPHEMERAL_TIMER_1_DAY_BY_OTHER = 147, - DC_STR_EPHEMERAL_TIMER_1_DAY_BY_YOU = 146, - DC_STR_EPHEMERAL_TIMER_1_HOUR_BY_OTHER = 145, - DC_STR_EPHEMERAL_TIMER_1_HOUR_BY_YOU = 144, - DC_STR_EPHEMERAL_TIMER_1_MINUTE_BY_OTHER = 143, - DC_STR_EPHEMERAL_TIMER_1_MINUTE_BY_YOU = 142, - DC_STR_EPHEMERAL_TIMER_1_WEEK_BY_OTHER = 149, - DC_STR_EPHEMERAL_TIMER_1_WEEK_BY_YOU = 148, - DC_STR_EPHEMERAL_TIMER_DAYS_BY_OTHER = 155, - DC_STR_EPHEMERAL_TIMER_DAYS_BY_YOU = 154, - DC_STR_EPHEMERAL_TIMER_DISABLED_BY_OTHER = 139, - DC_STR_EPHEMERAL_TIMER_DISABLED_BY_YOU = 138, - DC_STR_EPHEMERAL_TIMER_HOURS_BY_OTHER = 153, - DC_STR_EPHEMERAL_TIMER_HOURS_BY_YOU = 152, - DC_STR_EPHEMERAL_TIMER_MINUTES_BY_OTHER = 151, - DC_STR_EPHEMERAL_TIMER_MINUTES_BY_YOU = 150, - DC_STR_EPHEMERAL_TIMER_SECONDS_BY_OTHER = 141, - DC_STR_EPHEMERAL_TIMER_SECONDS_BY_YOU = 140, - DC_STR_EPHEMERAL_TIMER_WEEKS_BY_OTHER = 157, - DC_STR_EPHEMERAL_TIMER_WEEKS_BY_YOU = 156, - DC_STR_EPHEMERAL_WEEK = 80, - DC_STR_EPHEMERAL_WEEKS = 96, - DC_STR_ERROR = 112, - DC_STR_ERROR_NO_NETWORK = 87, - DC_STR_FAILED_SENDING_TO = 74, - DC_STR_FILE = 12, - DC_STR_FINGERPRINTS = 30, - DC_STR_FORWARDED = 97, - DC_STR_GIF = 23, - DC_STR_GROUP_IMAGE_CHANGED_BY_OTHER = 127, - DC_STR_GROUP_IMAGE_CHANGED_BY_YOU = 126, - DC_STR_GROUP_IMAGE_DELETED_BY_OTHER = 135, - DC_STR_GROUP_IMAGE_DELETED_BY_YOU = 134, - DC_STR_GROUP_LEFT_BY_OTHER = 133, - DC_STR_GROUP_LEFT_BY_YOU = 132, - DC_STR_GROUP_NAME_CHANGED_BY_OTHER = 125, - DC_STR_GROUP_NAME_CHANGED_BY_YOU = 124, - DC_STR_IMAGE = 9, - DC_STR_INCOMING_MESSAGES = 103, - DC_STR_INVALID_UNENCRYPTED_MAIL = 174, - DC_STR_LAST_MSG_SENT_SUCCESSFULLY = 111, - DC_STR_LOCATION = 66, - DC_STR_LOCATION_ENABLED_BY_OTHER = 137, - DC_STR_LOCATION_ENABLED_BY_YOU = 136, - DC_STR_MESSAGES = 114, - DC_STR_MESSAGE_ADD_MEMBER = 173, - DC_STR_MSGACTIONBYME = 63, - DC_STR_MSGACTIONBYUSER = 62, - DC_STR_MSGADDMEMBER = 17, - DC_STR_MSGDELMEMBER = 18, - DC_STR_MSGGROUPLEFT = 19, - DC_STR_MSGGRPIMGCHANGED = 16, - DC_STR_MSGGRPIMGDELETED = 33, - DC_STR_MSGGRPNAME = 15, - DC_STR_MSGLOCATIONDISABLED = 65, - DC_STR_MSGLOCATIONENABLED = 64, - DC_STR_NEW_GROUP_SEND_FIRST_MESSAGE = 172, - DC_STR_NOMESSAGES = 1, - DC_STR_NOT_CONNECTED = 121, - DC_STR_NOT_SUPPORTED_BY_PROVIDER = 113, - DC_STR_ONE_MOMENT = 106, - DC_STR_OUTGOING_MESSAGES = 104, - DC_STR_PARTIAL_DOWNLOAD_MSG_BODY = 99, - DC_STR_PART_OF_TOTAL_USED = 116, - DC_STR_QUOTA_EXCEEDING_MSG_BODY = 98, - DC_STR_REACTED_BY = 177, - DC_STR_READRCPT = 31, - DC_STR_READRCPT_MAILBODY = 32, - DC_STR_REMOVE_MEMBER_BY_OTHER = 131, - DC_STR_REMOVE_MEMBER_BY_YOU = 130, - DC_STR_REPLY_NOUN = 90, - DC_STR_SAVED_MESSAGES = 69, - DC_STR_SECUREJOIN_WAIT = 190, - DC_STR_SECUREJOIN_WAIT_TIMEOUT = 191, - DC_STR_SECURE_JOIN_GROUP_QR_DESC = 120, - DC_STR_SECURE_JOIN_REPLIES = 118, - DC_STR_SECURE_JOIN_STARTED = 117, - DC_STR_SELF = 2, - DC_STR_SELF_DELETED_MSG_BODY = 91, - DC_STR_SENDING = 110, - DC_STR_SERVER_TURNED_OFF = 92, - DC_STR_SETUP_CONTACT_QR_DESC = 119, - DC_STR_STICKER = 67, - DC_STR_STORAGE_ON_DOMAIN = 105, - DC_STR_SUBJECT_FOR_NEW_CONTACT = 73, - DC_STR_SYNC_MSG_BODY = 102, - DC_STR_SYNC_MSG_SUBJECT = 101, - DC_STR_UNKNOWN_SENDER_FOR_CHAT = 72, - DC_STR_UPDATE_REMINDER_MSG_BODY = 86, - DC_STR_UPDATING = 109, - DC_STR_VIDEO = 10, - DC_STR_VIDEOCHAT_INVITATION = 82, - DC_STR_VIDEOCHAT_INVITE_MSG_BODY = 83, - DC_STR_VOICEMESSAGE = 7, - DC_STR_WELCOME_MESSAGE = 71, - DC_STR_YOU_REACTED = 176, - DC_TEXT1_DRAFT = 1, - DC_TEXT1_SELF = 3, - DC_TEXT1_USERNAME = 2, - DC_VIDEOCHATTYPE_BASICWEBRTC = 1, - DC_VIDEOCHATTYPE_JITSI = 2, - DC_VIDEOCHATTYPE_UNKNOWN = 0, -} - -// Generated! - -export const EventId2EventName: { [key: number]: string } = { - 100: 'DC_EVENT_INFO', - 101: 'DC_EVENT_SMTP_CONNECTED', - 102: 'DC_EVENT_IMAP_CONNECTED', - 103: 'DC_EVENT_SMTP_MESSAGE_SENT', - 104: 'DC_EVENT_IMAP_MESSAGE_DELETED', - 105: 'DC_EVENT_IMAP_MESSAGE_MOVED', - 106: 'DC_EVENT_IMAP_INBOX_IDLE', - 150: 'DC_EVENT_NEW_BLOB_FILE', - 151: 'DC_EVENT_DELETED_BLOB_FILE', - 300: 'DC_EVENT_WARNING', - 400: 'DC_EVENT_ERROR', - 410: 'DC_EVENT_ERROR_SELF_NOT_IN_GROUP', - 2000: 'DC_EVENT_MSGS_CHANGED', - 2001: 'DC_EVENT_REACTIONS_CHANGED', - 2002: 'DC_EVENT_INCOMING_REACTION', - 2003: 'DC_EVENT_INCOMING_WEBXDC_NOTIFY', - 2005: 'DC_EVENT_INCOMING_MSG', - 2006: 'DC_EVENT_INCOMING_MSG_BUNCH', - 2008: 'DC_EVENT_MSGS_NOTICED', - 2010: 'DC_EVENT_MSG_DELIVERED', - 2012: 'DC_EVENT_MSG_FAILED', - 2015: 'DC_EVENT_MSG_READ', - 2016: 'DC_EVENT_MSG_DELETED', - 2020: 'DC_EVENT_CHAT_MODIFIED', - 2021: 'DC_EVENT_CHAT_EPHEMERAL_TIMER_MODIFIED', - 2030: 'DC_EVENT_CONTACTS_CHANGED', - 2035: 'DC_EVENT_LOCATION_CHANGED', - 2041: 'DC_EVENT_CONFIGURE_PROGRESS', - 2051: 'DC_EVENT_IMEX_PROGRESS', - 2052: 'DC_EVENT_IMEX_FILE_WRITTEN', - 2060: 'DC_EVENT_SECUREJOIN_INVITER_PROGRESS', - 2061: 'DC_EVENT_SECUREJOIN_JOINER_PROGRESS', - 2100: 'DC_EVENT_CONNECTIVITY_CHANGED', - 2110: 'DC_EVENT_SELFAVATAR_CHANGED', - 2111: 'DC_EVENT_CONFIG_SYNCED', - 2120: 'DC_EVENT_WEBXDC_STATUS_UPDATE', - 2121: 'DC_EVENT_WEBXDC_INSTANCE_DELETED', - 2150: 'DC_EVENT_WEBXDC_REALTIME_DATA', - 2151: 'DC_EVENT_WEBXDC_REALTIME_ADVERTISEMENT', - 2200: 'DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE', - 2300: 'DC_EVENT_CHATLIST_CHANGED', - 2301: 'DC_EVENT_CHATLIST_ITEM_CHANGED', - 2302: 'DC_EVENT_ACCOUNTS_CHANGED', - 2303: 'DC_EVENT_ACCOUNTS_ITEM_CHANGED', - 2400: 'DC_EVENT_CHANNEL_OVERFLOW', -} diff --git a/node/lib/contact.ts b/node/lib/contact.ts deleted file mode 100644 index 41e3e270c..000000000 --- a/node/lib/contact.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { integerToHexColor } from './util' - -/* eslint-disable camelcase */ - -import binding from './binding' -const debug = require('debug')('deltachat:node:contact') - -interface NativeContact {} -/** - * Wrapper around dc_contact_t* - */ -export class Contact { - constructor(public dc_contact: NativeContact) { - debug('Contact constructor') - if (dc_contact === null) { - throw new Error('native contact can not be null') - } - } - - toJson() { - debug('toJson') - return { - address: this.getAddress(), - color: this.color, - authName: this.authName, - status: this.status, - displayName: this.getDisplayName(), - id: this.getId(), - lastSeen: this.lastSeen, - name: this.getName(), - profileImage: this.getProfileImage(), - nameAndAddr: this.getNameAndAddress(), - isBlocked: this.isBlocked(), - isVerified: this.isVerified(), - } - } - - getAddress(): string { - return binding.dcn_contact_get_addr(this.dc_contact) - } - - /** Get original contact name. - * This is the name of the contact as defined by the contact themself. - * If the contact themself does not define such a name, - * an empty string is returned. */ - get authName(): string { - return binding.dcn_contact_get_auth_name(this.dc_contact) - } - - get color(): string { - return integerToHexColor(binding.dcn_contact_get_color(this.dc_contact)) - } - - /** - * contact's status - * - * Status is the last signature received in a message from this contact. - */ - get status(): string { - return binding.dcn_contact_get_status(this.dc_contact) - } - - getDisplayName(): string { - return binding.dcn_contact_get_display_name(this.dc_contact) - } - - getId(): number { - return binding.dcn_contact_get_id(this.dc_contact) - } - - get lastSeen(): number { - return binding.dcn_contact_get_last_seen(this.dc_contact) - } - - wasSeenRecently() { - return Boolean(binding.dcn_contact_was_seen_recently(this.dc_contact)) - } - - getName(): string { - return binding.dcn_contact_get_name(this.dc_contact) - } - - getNameAndAddress(): string { - return binding.dcn_contact_get_name_n_addr(this.dc_contact) - } - - getProfileImage(): string { - return binding.dcn_contact_get_profile_image(this.dc_contact) - } - - isBlocked() { - return Boolean(binding.dcn_contact_is_blocked(this.dc_contact)) - } - - isVerified() { - return Boolean(binding.dcn_contact_is_verified(this.dc_contact)) - } -} diff --git a/node/lib/context.ts b/node/lib/context.ts deleted file mode 100644 index 67055d8e5..000000000 --- a/node/lib/context.ts +++ /dev/null @@ -1,897 +0,0 @@ -/* eslint-disable camelcase */ - -import binding from './binding' -import { C, EventId2EventName } from './constants' -import { Chat } from './chat' -import { ChatList } from './chatlist' -import { Contact } from './contact' -import { Message } from './message' -import { Lot } from './lot' -import { Locations } from './locations' -import rawDebug from 'debug' -import { AccountManager } from './deltachat' -import { join } from 'path' -import { EventEmitter } from 'stream' -const debug = rawDebug('deltachat:node:index') - -const noop = function () {} -interface NativeContext {} - -/** - * Wrapper around dcn_context_t* - * - * only acts as event emitter when created in standalone mode (without account manager) - * with `Context.open` - */ -export class Context extends EventEmitter { - constructor( - readonly manager: AccountManager | null, - private inner_dcn_context: NativeContext, - readonly account_id: number | null - ) { - super() - debug('DeltaChat constructor') - if (inner_dcn_context === null) { - throw new Error('inner_dcn_context can not be null') - } - } - - /** Opens a standalone context (without an account manager) - * automatically starts the event handler */ - static open(cwd: string): Context { - const dbFile = join(cwd, 'db.sqlite') - const context = new Context(null, binding.dcn_context_new(dbFile), null) - debug('Opened context') - function handleCoreEvent( - eventId: number, - data1: number, - data2: number | string - ) { - const eventString = EventId2EventName[eventId] - debug(eventString, data1, data2) - if (!context.emit) { - console.log('Received an event but EventEmitter is already destroyed.') - console.log(eventString, data1, data2) - return - } - context.emit(eventString, data1, data2) - context.emit('ALL', eventString, data1, data2) - } - binding.dcn_start_event_handler( - context.dcn_context, - handleCoreEvent.bind(this) - ) - debug('Started event handler') - return context - } - - get dcn_context() { - return this.inner_dcn_context - } - - get is_open() { - return Boolean(binding.dcn_context_is_open()) - } - - open(passphrase?: string) { - return Boolean( - binding.dcn_context_open(this.dcn_context, passphrase ? passphrase : '') - ) - } - - unref() { - binding.dcn_context_unref(this.dcn_context) - ;(this.inner_dcn_context as any) = null - } - - acceptChat(chatId: number) { - binding.dcn_accept_chat(this.dcn_context, chatId) - } - - blockChat(chatId: number) { - binding.dcn_block_chat(this.dcn_context, chatId) - } - - addAddressBook(addressBook: string) { - debug(`addAddressBook ${addressBook}`) - return binding.dcn_add_address_book(this.dcn_context, addressBook) - } - - addContactToChat(chatId: number, contactId: number) { - debug(`addContactToChat ${chatId} ${contactId}`) - return Boolean( - binding.dcn_add_contact_to_chat( - this.dcn_context, - Number(chatId), - Number(contactId) - ) - ) - } - - addDeviceMessage(label: string, msg: Message | string) { - debug(`addDeviceMessage ${label} ${msg}`) - if (!msg) { - throw new Error('invalid msg parameter') - } - if (typeof label !== 'string') { - throw new Error('invalid label parameter, must be a string') - } - if (typeof msg === 'string') { - const msgObj = this.messageNew() - msgObj.setText(msg) - msg = msgObj - } - if (!msg.dc_msg) { - throw new Error('invalid msg object') - } - return binding.dcn_add_device_msg(this.dcn_context, label, msg.dc_msg) - } - - setChatVisibility( - chatId: number, - visibility: - | C.DC_CHAT_VISIBILITY_NORMAL - | C.DC_CHAT_VISIBILITY_ARCHIVED - | C.DC_CHAT_VISIBILITY_PINNED - ) { - debug(`setChatVisibility ${chatId} ${visibility}`) - binding.dcn_set_chat_visibility( - this.dcn_context, - Number(chatId), - visibility - ) - } - - blockContact(contactId: number, block: boolean) { - debug(`blockContact ${contactId} ${block}`) - binding.dcn_block_contact( - this.dcn_context, - Number(contactId), - block ? 1 : 0 - ) - } - - checkQrCode(qrCode: string) { - debug(`checkQrCode ${qrCode}`) - const dc_lot = binding.dcn_check_qr(this.dcn_context, qrCode) - let result = dc_lot ? new Lot(dc_lot) : null - if (result) { - return { id: result.getId(), ...result.toJson() } - } - return result - } - - configure(opts: any): Promise { - return new Promise((resolve, reject) => { - debug('configure') - - const onSuccess = () => { - removeListeners() - resolve() - } - const onFail = (error: string) => { - removeListeners() - reject(new Error(error)) - } - - let onConfigure: (...args: any[]) => void - if (this.account_id === null) { - onConfigure = (data1: number, data2: string) => { - if (data1 === 0) return onFail(data2) - else if (data1 === 1000) return onSuccess() - } - } else { - onConfigure = (accountId: number, data1: number, data2: string) => { - if (this.account_id !== accountId) { - return - } - if (data1 === 0) return onFail(data2) - else if (data1 === 1000) return onSuccess() - } - } - - const removeListeners = () => { - ;(this.manager || this).removeListener( - 'DC_EVENT_CONFIGURE_PROGRESS', - onConfigure - ) - } - - const registerListeners = () => { - ;(this.manager || this).on('DC_EVENT_CONFIGURE_PROGRESS', onConfigure) - } - - registerListeners() - - if (!opts) opts = {} - Object.keys(opts).forEach((key) => { - const value = opts[key] - this.setConfig(key, value) - }) - - binding.dcn_configure(this.dcn_context) - }) - } - - continueKeyTransfer(messageId: number, setupCode: string) { - debug(`continueKeyTransfer ${messageId}`) - return new Promise((resolve, reject) => { - binding.dcn_continue_key_transfer( - this.dcn_context, - Number(messageId), - setupCode, - (result: number) => resolve(result === 1) - ) - }) - } - /** @returns chatId */ - createBroadcastList(): number { - debug(`createBroadcastList`) - return binding.dcn_create_broadcast_list(this.dcn_context) - } - - /** @returns chatId */ - createChatByContactId(contactId: number): number { - debug(`createChatByContactId ${contactId}`) - return binding.dcn_create_chat_by_contact_id( - this.dcn_context, - Number(contactId) - ) - } - - /** @returns contactId */ - createContact(name: string, addr: string): number { - debug(`createContact ${name} ${addr}`) - return binding.dcn_create_contact(this.dcn_context, name, addr) - } - - /** - * - * @param chatName The name of the chat that should be created - * @param is_protected Whether the chat should be protected at creation time - * @returns chatId - */ - createGroupChat(chatName: string, is_protected: boolean = false): number { - debug(`createGroupChat ${chatName} [protected:${is_protected}]`) - return binding.dcn_create_group_chat( - this.dcn_context, - is_protected ? 1 : 0, - chatName - ) - } - - deleteChat(chatId: number) { - debug(`deleteChat ${chatId}`) - binding.dcn_delete_chat(this.dcn_context, Number(chatId)) - } - - deleteContact(contactId: number) { - debug(`deleteContact ${contactId}`) - return Boolean( - binding.dcn_delete_contact(this.dcn_context, Number(contactId)) - ) - } - - deleteMessages(messageIds: number[]) { - if (!Array.isArray(messageIds)) { - messageIds = [messageIds] - } - messageIds = messageIds.map((id) => Number(id)) - debug('deleteMessages', messageIds) - binding.dcn_delete_msgs(this.dcn_context, messageIds) - } - - forwardMessages(messageIds: number[], chatId: number) { - if (!Array.isArray(messageIds)) { - messageIds = [messageIds] - } - messageIds = messageIds.map((id) => Number(id)) - debug('forwardMessages', messageIds) - binding.dcn_forward_msgs(this.dcn_context, messageIds, chatId) - } - - getBlobdir(): string { - debug('getBlobdir') - return binding.dcn_get_blobdir(this.dcn_context) - } - - getBlockedCount(): number { - debug('getBlockedCount') - return binding.dcn_get_blocked_cnt(this.dcn_context) - } - - getBlockedContacts(): number[] { - debug('getBlockedContacts') - return binding.dcn_get_blocked_contacts(this.dcn_context) - } - - getChat(chatId: number) { - debug(`getChat ${chatId}`) - const dc_chat = binding.dcn_get_chat(this.dcn_context, Number(chatId)) - return dc_chat ? new Chat(dc_chat) : null - } - - getChatContacts(chatId: number): number[] { - debug(`getChatContacts ${chatId}`) - return binding.dcn_get_chat_contacts(this.dcn_context, Number(chatId)) - } - - getChatIdByContactId(contactId: number): number { - debug(`getChatIdByContactId ${contactId}`) - return binding.dcn_get_chat_id_by_contact_id( - this.dcn_context, - Number(contactId) - ) - } - - getChatMedia( - chatId: number, - msgType1: number, - msgType2: number, - msgType3: number - ): number[] { - debug(`getChatMedia ${chatId}`) - return binding.dcn_get_chat_media( - this.dcn_context, - Number(chatId), - msgType1, - msgType2 || 0, - msgType3 || 0 - ) - } - - getMimeHeaders(messageId: number): string { - debug(`getMimeHeaders ${messageId}`) - return binding.dcn_get_mime_headers(this.dcn_context, Number(messageId)) - } - - getChatlistItemSummary(chatId: number, messageId: number) { - debug(`getChatlistItemSummary ${chatId} ${messageId}`) - return new Lot( - binding.dcn_chatlist_get_summary2(this.dcn_context, chatId, messageId) - ) - } - - getChatMessages(chatId: number, flags: number, marker1before: number) { - debug(`getChatMessages ${chatId} ${flags} ${marker1before}`) - return binding.dcn_get_chat_msgs( - this.dcn_context, - Number(chatId), - flags, - marker1before - ) - } - - /** - * Get encryption info for a chat. - * Get a multi-line encryption info, containing encryption preferences of all members. - * Can be used to find out why messages sent to group are not encrypted. - * - * @param chatId ID of the chat to get the encryption info for. - * @return Multi-line text, must be released using dc_str_unref() after usage. - */ - getChatEncrytionInfo(chatId: number): string { - return binding.dcn_get_chat_encrinfo(this.dcn_context, chatId) - } - - getChats(listFlags: number, queryStr: string, queryContactId: number) { - debug('getChats') - const result = [] - const list = this.getChatList(listFlags, queryStr, queryContactId) - const count = list.getCount() - for (let i = 0; i < count; i++) { - result.push(list.getChatId(i)) - } - return result - } - - getChatList(listFlags: number, queryStr: string, queryContactId: number) { - listFlags = listFlags || 0 - queryStr = queryStr || '' - queryContactId = queryContactId || 0 - debug(`getChatList ${listFlags} ${queryStr} ${queryContactId}`) - return new ChatList( - binding.dcn_get_chatlist( - this.dcn_context, - listFlags, - queryStr, - Number(queryContactId) - ) - ) - } - - getConfig(key: string): string { - debug(`getConfig ${key}`) - return binding.dcn_get_config(this.dcn_context, key) - } - - getContact(contactId: number) { - debug(`getContact ${contactId}`) - const dc_contact = binding.dcn_get_contact( - this.dcn_context, - Number(contactId) - ) - return dc_contact ? new Contact(dc_contact) : null - } - - getContactEncryptionInfo(contactId: number) { - debug(`getContactEncryptionInfo ${contactId}`) - return binding.dcn_get_contact_encrinfo(this.dcn_context, Number(contactId)) - } - - getContacts(listFlags: number, query: string) { - listFlags = listFlags || 0 - query = query || '' - debug(`getContacts ${listFlags} ${query}`) - return binding.dcn_get_contacts(this.dcn_context, listFlags, query) - } - - wasDeviceMessageEverAdded(label: string) { - debug(`wasDeviceMessageEverAdded ${label}`) - const added = binding.dcn_was_device_msg_ever_added(this.dcn_context, label) - return added === 1 - } - - getDraft(chatId: number) { - debug(`getDraft ${chatId}`) - const dc_msg = binding.dcn_get_draft(this.dcn_context, Number(chatId)) - return dc_msg ? new Message(dc_msg) : null - } - - getFreshMessageCount(chatId: number): number { - debug(`getFreshMessageCount ${chatId}`) - return binding.dcn_get_fresh_msg_cnt(this.dcn_context, Number(chatId)) - } - - getFreshMessages() { - debug('getFreshMessages') - return binding.dcn_get_fresh_msgs(this.dcn_context) - } - - getInfo() { - debug('getInfo') - const info = binding.dcn_get_info(this.dcn_context) - return AccountManager.parseGetInfo(info) - } - - getMessage(messageId: number) { - debug(`getMessage ${messageId}`) - const dc_msg = binding.dcn_get_msg(this.dcn_context, Number(messageId)) - return dc_msg ? new Message(dc_msg) : null - } - - getMessageCount(chatId: number): number { - debug(`getMessageCount ${chatId}`) - return binding.dcn_get_msg_cnt(this.dcn_context, Number(chatId)) - } - - getMessageInfo(messageId: number): string { - debug(`getMessageInfo ${messageId}`) - return binding.dcn_get_msg_info(this.dcn_context, Number(messageId)) - } - - getMessageHTML(messageId: number): string { - debug(`getMessageHTML ${messageId}`) - return binding.dcn_get_msg_html(this.dcn_context, Number(messageId)) - } - - getSecurejoinQrCode(chatId: number): string { - debug(`getSecurejoinQrCode ${chatId}`) - return binding.dcn_get_securejoin_qr(this.dcn_context, Number(chatId)) - } - - getSecurejoinQrCodeSVG(chatId: number): string { - debug(`getSecurejoinQrCodeSVG ${chatId}`) - return binding.dcn_get_securejoin_qr_svg(this.dcn_context, chatId) - } - - startIO(): void { - debug(`startIO`) - binding.dcn_start_io(this.dcn_context) - } - - stopIO(): void { - debug(`stopIO`) - binding.dcn_stop_io(this.dcn_context) - } - - stopOngoingProcess(): void { - debug(`stopOngoingProcess`) - binding.dcn_stop_ongoing_process(this.dcn_context) - } - - /** - * - * @deprecated please use `AccountManager.getSystemInfo()` instead - */ - static getSystemInfo() { - return AccountManager.getSystemInfo() - } - - getConnectivity(): number { - return binding.dcn_get_connectivity(this.dcn_context) - } - - getConnectivityHTML(): String { - return binding.dcn_get_connectivity_html(this.dcn_context) - } - - importExport(what: number, param1: string, param2 = '') { - debug(`importExport ${what} ${param1} ${param2}`) - binding.dcn_imex(this.dcn_context, what, param1, param2) - } - - importExportHasBackup(dir: string) { - debug(`importExportHasBackup ${dir}`) - return binding.dcn_imex_has_backup(this.dcn_context, dir) - } - - initiateKeyTransfer(): Promise { - return new Promise((resolve, reject) => { - debug('initiateKeyTransfer2') - binding.dcn_initiate_key_transfer(this.dcn_context, resolve) - }) - } - - isConfigured() { - debug('isConfigured') - return Boolean(binding.dcn_is_configured(this.dcn_context)) - } - - isContactInChat(chatId: number, contactId: number) { - debug(`isContactInChat ${chatId} ${contactId}`) - return Boolean( - binding.dcn_is_contact_in_chat( - this.dcn_context, - Number(chatId), - Number(contactId) - ) - ) - } - - /** - * - * @returns resulting chat id or 0 on error - */ - joinSecurejoin(qrCode: string): number { - debug(`joinSecurejoin ${qrCode}`) - return binding.dcn_join_securejoin(this.dcn_context, qrCode) - } - - lookupContactIdByAddr(addr: string): number { - debug(`lookupContactIdByAddr ${addr}`) - return binding.dcn_lookup_contact_id_by_addr(this.dcn_context, addr) - } - - markNoticedChat(chatId: number) { - debug(`markNoticedChat ${chatId}`) - binding.dcn_marknoticed_chat(this.dcn_context, Number(chatId)) - } - - markSeenMessages(messageIds: number[]) { - if (!Array.isArray(messageIds)) { - messageIds = [messageIds] - } - messageIds = messageIds.map((id) => Number(id)) - debug('markSeenMessages', messageIds) - binding.dcn_markseen_msgs(this.dcn_context, messageIds) - } - - maybeNetwork() { - debug('maybeNetwork') - binding.dcn_maybe_network(this.dcn_context) - } - - messageNew(viewType = C.DC_MSG_TEXT) { - debug(`messageNew ${viewType}`) - return new Message(binding.dcn_msg_new(this.dcn_context, viewType)) - } - - removeContactFromChat(chatId: number, contactId: number) { - debug(`removeContactFromChat ${chatId} ${contactId}`) - return Boolean( - binding.dcn_remove_contact_from_chat( - this.dcn_context, - Number(chatId), - Number(contactId) - ) - ) - } - - /** - * - * @param chatId ID of the chat to search messages in. Set this to 0 for a global search. - * @param query The query to search for. - */ - searchMessages(chatId: number, query: string): number[] { - debug(`searchMessages ${chatId} ${query}`) - return binding.dcn_search_msgs(this.dcn_context, Number(chatId), query) - } - - sendMessage(chatId: number, msg: string | Message) { - debug(`sendMessage ${chatId}`) - if (!msg) { - throw new Error('invalid msg parameter') - } - if (typeof msg === 'string') { - const msgObj = this.messageNew() - msgObj.setText(msg) - msg = msgObj - } - if (!msg.dc_msg) { - throw new Error('invalid msg object') - } - return binding.dcn_send_msg(this.dcn_context, Number(chatId), msg.dc_msg) - } - - downloadFullMessage(messageId: number) { - binding.dcn_download_full_msg(this.dcn_context, messageId) - } - - /** - * - * @returns {Promise} Promise that resolves into the resulting message id - */ - sendVideochatInvitation(chatId: number): Promise { - debug(`sendVideochatInvitation ${chatId}`) - return new Promise((resolve, reject) => { - binding.dcn_send_videochat_invitation( - this.dcn_context, - chatId, - (result: number) => { - if (result !== 0) { - resolve(result) - } else { - reject( - 'Videochatinvitation failed to send, see error events for detailed info' - ) - } - } - ) - }) - } - - setChatName(chatId: number, name: string) { - debug(`setChatName ${chatId} ${name}`) - return Boolean( - binding.dcn_set_chat_name(this.dcn_context, Number(chatId), name) - ) - } - - getChatEphemeralTimer(chatId: number): number { - debug(`getChatEphemeralTimer ${chatId}`) - return binding.dcn_get_chat_ephemeral_timer( - this.dcn_context, - Number(chatId) - ) - } - - setChatEphemeralTimer(chatId: number, timer: number) { - debug(`setChatEphemeralTimer ${chatId} ${timer}`) - return Boolean( - binding.dcn_set_chat_ephemeral_timer( - this.dcn_context, - Number(chatId), - Number(timer) - ) - ) - } - - setChatProfileImage(chatId: number, image: string) { - debug(`setChatProfileImage ${chatId} ${image}`) - return Boolean( - binding.dcn_set_chat_profile_image( - this.dcn_context, - Number(chatId), - image || '' - ) - ) - } - - setConfig(key: string, value: string | boolean | number): number { - debug(`setConfig (string) ${key} ${value}`) - if (value === null) { - return binding.dcn_set_config_null(this.dcn_context, key) - } else { - if (typeof value === 'boolean') { - value = value === true ? '1' : '0' - } else if (typeof value === 'number') { - value = String(value) - } - return binding.dcn_set_config(this.dcn_context, key, value) - } - } - - 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( - this.dcn_context, - fromServer === true ? 1 : 0, - seconds - ) - } - - setStockTranslation(stockId: number, stockMsg: string) { - debug(`setStockTranslation ${stockId} ${stockMsg}`) - return Boolean( - binding.dcn_set_stock_translation( - this.dcn_context, - Number(stockId), - stockMsg - ) - ) - } - - setDraft(chatId: number, msg: Message | null) { - debug(`setDraft ${chatId}`) - binding.dcn_set_draft( - this.dcn_context, - Number(chatId), - msg ? msg.dc_msg : null - ) - } - - setLocation(latitude: number, longitude: number, accuracy: number) { - debug(`setLocation ${latitude}`) - binding.dcn_set_location( - this.dcn_context, - Number(latitude), - Number(longitude), - Number(accuracy) - ) - } - - /* - * @param chatId Chat-id to get location information for. - * 0 to get locations independently of the chat. - * @param contactId Contact id to get location information for. - * If also a chat-id is given, this should be a member of the given chat. - * 0 to get locations independently of the contact. - * @param timestampFrom Start of timespan to return. - * Must be given in number of seconds since 00:00 hours, Jan 1, 1970 UTC. - * 0 for "start from the beginning". - * @param timestampTo End of timespan to return. - * Must be given in number of seconds since 00:00 hours, Jan 1, 1970 UTC. - * 0 for "all up to now". - * @return Array of locations, NULL is never returned. - * The array is sorted descending; - * the first entry in the array is the location with the newest timestamp. - * - * Examples: - * // get locations from the last hour for a global map - * getLocations(0, 0, time(NULL)-60*60, 0); - * - * // get locations from a contact for a global map - * getLocations(0, contact_id, 0, 0); - * - * // get all locations known for a given chat - * getLocations(chat_id, 0, 0, 0); - * - * // get locations from a single contact for a given chat - * getLocations(chat_id, contact_id, 0, 0); - */ - - getLocations( - chatId: number, - contactId: number, - timestampFrom = 0, - timestampTo = 0 - ) { - const locations = new Locations( - binding.dcn_get_locations( - this.dcn_context, - Number(chatId), - Number(contactId), - timestampFrom, - timestampTo - ) - ) - return locations.toJson() - } - - /** - * - * @param duration The duration (0 for no mute, -1 for forever mute, everything else is is the relative mute duration from now in seconds) - */ - setChatMuteDuration(chatId: number, duration: number) { - return Boolean( - binding.dcn_set_chat_mute_duration(this.dcn_context, chatId, duration) - ) - } - - /** get information about the provider */ - getProviderFromEmail(email: string) { - debug('DeltaChat.getProviderFromEmail') - const provider = binding.dcn_provider_new_from_email( - this.dcn_context, - email - ) - if (!provider) { - return undefined - } - return { - before_login_hint: binding.dcn_provider_get_before_login_hint(provider), - overview_page: binding.dcn_provider_get_overview_page(provider), - status: binding.dcn_provider_get_status(provider), - } - } - - sendWebxdcStatusUpdate( - msgId: number, - json: WebxdcSendingStatusUpdate, - descr: string - ) { - return Boolean( - binding.dcn_send_webxdc_status_update( - this.dcn_context, - msgId, - JSON.stringify(json), - descr - ) - ) - } - - getWebxdcStatusUpdates( - msgId: number, - serial = 0 - ): WebxdcReceivedStatusUpdate[] { - return JSON.parse( - binding.dcn_get_webxdc_status_updates(this.dcn_context, msgId, serial) - ) - } - - /** the string contains the binary data, it is an "u8 string", maybe we will use a more efficient type in the future. */ - getWebxdcBlob(message: Message, filename: string): Buffer | null { - return binding.dcn_msg_get_webxdc_blob(message.dc_msg, filename) - } -} - -export type WebxdcInfo = { - name: string - icon: string - summary: string - /** - * if set by the webxdc, name of the document in edit - */ - document?: string -} - -type WebxdcSendingStatusUpdate = { - /** the payload, deserialized json: - * any javascript primitive, array or object. */ - payload: T - /** optional, short, informational message that will be added to the chat, - * eg. "Alice voted" or "Bob scored 123 in MyGame"; - * usually only one line of text is shown, - * use this option sparingly to not spam the chat. */ - info?: string - /** optional, short text, shown beside app icon; - * it is recommended to use some aggregated value, - * eg. "8 votes", "Highscore: 123" */ - summary?: string - /** - * optional, name of the document in edit, - * must not be used eg. in games where the Webxdc does not create documents - */ - document?: string -} - -type WebxdcReceivedStatusUpdate = { - /** the payload, deserialized json */ - payload: T - /** the serial number of this update. Serials are larger `0` and newer serials have higher numbers. */ - serial: number - /** the maximum serial currently known. - * If `max_serial` equals `serial` this update is the last update (until new network messages arrive). */ - max_serial: number - /** optional, short, informational message. */ - info?: string - /** optional, short text, shown beside app icon. If there are no updates, an empty JSON-array is returned. */ - summary?: string -} diff --git a/node/lib/deltachat.ts b/node/lib/deltachat.ts deleted file mode 100644 index 6080aacda..000000000 --- a/node/lib/deltachat.ts +++ /dev/null @@ -1,234 +0,0 @@ -/* eslint-disable camelcase */ - -import binding from './binding' -import { EventId2EventName } from './constants' -import { EventEmitter } from 'events' -import { existsSync } from 'fs' -import rawDebug from 'debug' -import { tmpdir } from 'os' -import { join } from 'path' -import { Context } from './context' -const debug = rawDebug('deltachat:node:index') - -const noop = function () {} -interface NativeAccount {} - -/** - * Wrapper around dcn_account_t* - */ -export class AccountManager extends EventEmitter { - dcn_accounts: NativeAccount - accountDir: string - jsonRpcStarted = false - - constructor(cwd: string, writable = true) { - super() - debug('DeltaChat constructor') - - this.accountDir = cwd - this.dcn_accounts = binding.dcn_accounts_new( - this.accountDir, - writable ? 1 : 0 - ) - } - - getAllAccountIds() { - return binding.dcn_accounts_get_all(this.dcn_accounts) - } - - selectAccount(account_id: number) { - return binding.dcn_accounts_select_account(this.dcn_accounts, account_id) - } - - selectedAccount(): number { - return binding.dcn_accounts_get_selected_account(this.dcn_accounts) - } - - addAccount(): number { - return binding.dcn_accounts_add_account(this.dcn_accounts) - } - - addClosedAccount(): number { - return binding.dcn_accounts_add_closed_account(this.dcn_accounts) - } - - removeAccount(account_id: number) { - return binding.dcn_accounts_remove_account(this.dcn_accounts, account_id) - } - - accountContext(account_id: number) { - const native_context = binding.dcn_accounts_get_account( - this.dcn_accounts, - account_id - ) - if (native_context === null) { - throw new Error( - `could not get context with id ${account_id}, does it even exist? please check your ids` - ) - } - return new Context(this, native_context, account_id) - } - - migrateAccount(dbfile: string): number { - return binding.dcn_accounts_migrate_account(this.dcn_accounts, dbfile) - } - - close() { - this.stopIO() - debug('unrefing context') - binding.dcn_accounts_unref(this.dcn_accounts) - debug('Unref end') - } - - emit( - event: string | symbol, - account_id: number, - data1: any, - data2: any - ): boolean { - super.emit('ALL', event, account_id, data1, data2) - return super.emit(event, account_id, data1, data2) - } - - handleCoreEvent( - eventId: number, - accountId: number, - data1: number, - data2: number | string - ) { - const eventString = EventId2EventName[eventId] - debug('event', eventString, accountId, data1, data2) - debug(eventString, data1, data2) - if (!this.emit) { - console.log('Received an event but EventEmitter is already destroyed.') - console.log(eventString, data1, data2) - return - } - this.emit(eventString, accountId, data1, data2) - } - - startEvents() { - if (this.dcn_accounts === null) { - throw new Error('dcn_account is null') - } - binding.dcn_accounts_start_event_handler( - this.dcn_accounts, - this.handleCoreEvent.bind(this) - ) - debug('Started event handler') - } - - startJsonRpcHandler(callback: ((response: string) => void) | null) { - if (this.dcn_accounts === null) { - throw new Error('dcn_account is null') - } - if (!callback) { - throw new Error('no callback set') - } - if (this.jsonRpcStarted) { - throw new Error('jsonrpc was started already') - } - - binding.dcn_accounts_start_jsonrpc(this.dcn_accounts, callback.bind(this)) - debug('Started JSON-RPC handler') - this.jsonRpcStarted = true - } - - jsonRpcRequest(message: string) { - if (!this.jsonRpcStarted) { - throw new Error( - 'jsonrpc is not active, start it with startJsonRpcHandler first' - ) - } - binding.dcn_json_rpc_request(this.dcn_accounts, message) - } - - startIO() { - binding.dcn_accounts_start_io(this.dcn_accounts) - } - - stopIO() { - binding.dcn_accounts_stop_io(this.dcn_accounts) - } - - static maybeValidAddr(addr: string) { - debug('DeltaChat.maybeValidAddr') - if (addr === null) return false - return Boolean(binding.dcn_maybe_valid_addr(addr)) - } - - static parseGetInfo(info: string) { - debug('static _getInfo') - const result: { [key: string]: string } = {} - - const regex = /^(\w+)=(.*)$/i - info - .split('\n') - .filter(Boolean) - .forEach((line) => { - const match = regex.exec(line) - if (match) { - result[match[1]] = match[2] - } - }) - - return result - } - - static newTemporary() { - let directory = null - while (true) { - const randomString = Math.random().toString(36).substring(2, 5) - directory = join(tmpdir(), 'deltachat-' + randomString) - if (!existsSync(directory)) break - } - const dc = new AccountManager(directory) - const accountId = dc.addAccount() - const context = dc.accountContext(accountId) - return { dc, context, accountId, directory } - } - - static getSystemInfo() { - debug('DeltaChat.getSystemInfo') - const { dc, context } = AccountManager.newTemporary() - const info = AccountManager.parseGetInfo( - binding.dcn_get_info(context.dcn_context) - ) - const { - deltachat_core_version, - sqlite_version, - sqlite_thread_safe, - libetpan_version, - openssl_version, - compile_date, - arch, - } = info - const result = { - deltachat_core_version, - sqlite_version, - sqlite_thread_safe, - libetpan_version, - openssl_version, - compile_date, - arch, - } - context.unref() - dc.close() - return result - } - - /** get information about the provider - * - * This function creates a temporary context to be standalone, - * if possible use `Context.getProviderFromEmail` instead. (otherwise potential proxy settings are not used) - * @deprecated - */ - static getProviderFromEmail(email: string) { - debug('DeltaChat.getProviderFromEmail') - const { dc, context } = AccountManager.newTemporary() - const provider = context.getProviderFromEmail(email) - context.unref() - dc.close() - return provider - } -} diff --git a/node/lib/index.ts b/node/lib/index.ts deleted file mode 100644 index 6b179dbeb..000000000 --- a/node/lib/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { AccountManager } from './deltachat' - -export default AccountManager - -export { Context } from './context' -export { Chat } from './chat' -export { ChatList } from './chatlist' -export { C } from './constants' -export { Contact } from './contact' -export { AccountManager as DeltaChat } -export { Locations } from './locations' -export { Lot } from './lot' -export { - Message, - MessageState, - MessageViewType, - MessageDownloadState, -} from './message' - -export * from './types' diff --git a/node/lib/locations.ts b/node/lib/locations.ts deleted file mode 100644 index 6e197a133..000000000 --- a/node/lib/locations.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* eslint-disable camelcase */ - -const binding = require('../binding') -const debug = require('debug')('deltachat:node:locations') - -interface NativeLocations {} -/** - * Wrapper around dc_location_t* - */ -export class Locations { - constructor(public dc_locations: NativeLocations) { - debug('Locations constructor') - if (dc_locations === null) { - throw new Error('dc_locations can not be null') - } - } - - locationToJson(index: number) { - debug('locationToJson') - return { - accuracy: this.getAccuracy(index), - latitude: this.getLatitude(index), - longitude: this.getLongitude(index), - timestamp: this.getTimestamp(index), - contactId: this.getContactId(index), - msgId: this.getMsgId(index), - chatId: this.getChatId(index), - isIndependent: this.isIndependent(index), - marker: this.getMarker(index), - } - } - - toJson(): ReturnType[] { - debug('toJson') - const locations = [] - const count = this.getCount() - for (let index = 0; index < count; index++) { - locations.push(this.locationToJson(index)) - } - return locations - } - - getCount(): number { - return binding.dcn_array_get_cnt(this.dc_locations) - } - - getAccuracy(index: number): number { - return binding.dcn_array_get_accuracy(this.dc_locations, index) - } - - getLatitude(index: number): number { - return binding.dcn_array_get_latitude(this.dc_locations, index) - } - - getLongitude(index: number): number { - return binding.dcn_array_get_longitude(this.dc_locations, index) - } - - getTimestamp(index: number): number { - return binding.dcn_array_get_timestamp(this.dc_locations, index) - } - - getMsgId(index: number): number { - return binding.dcn_array_get_msg_id(this.dc_locations, index) - } - - getContactId(index: number): number { - return binding.dcn_array_get_contact_id(this.dc_locations, index) - } - - getChatId(index: number): number { - return binding.dcn_array_get_chat_id(this.dc_locations, index) - } - - isIndependent(index: number): boolean { - return binding.dcn_array_is_independent(this.dc_locations, index) - } - - getMarker(index: number): string { - return binding.dcn_array_get_marker(this.dc_locations, index) - } -} diff --git a/node/lib/lot.ts b/node/lib/lot.ts deleted file mode 100644 index 4da0bccab..000000000 --- a/node/lib/lot.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* eslint-disable camelcase */ - -const binding = require('../binding') -const debug = require('debug')('deltachat:node:lot') - -interface NativeLot {} -/** - * Wrapper around dc_lot_t* - */ -export class Lot { - constructor(public dc_lot: NativeLot) { - debug('Lot constructor') - if (dc_lot === null) { - throw new Error('dc_lot can not be null') - } - } - - toJson() { - debug('toJson') - return { - state: this.getState(), - text1: this.getText1(), - text1Meaning: this.getText1Meaning(), - text2: this.getText2(), - timestamp: this.getTimestamp(), - } - } - - getId(): number { - return binding.dcn_lot_get_id(this.dc_lot) - } - - getState(): number { - return binding.dcn_lot_get_state(this.dc_lot) - } - - getText1(): string { - return binding.dcn_lot_get_text1(this.dc_lot) - } - - getText1Meaning(): string { - return binding.dcn_lot_get_text1_meaning(this.dc_lot) - } - - getText2(): string { - return binding.dcn_lot_get_text2(this.dc_lot) - } - - getTimestamp(): number { - return binding.dcn_lot_get_timestamp(this.dc_lot) - } -} diff --git a/node/lib/message.ts b/node/lib/message.ts deleted file mode 100644 index c4036ad6b..000000000 --- a/node/lib/message.ts +++ /dev/null @@ -1,366 +0,0 @@ -/* eslint-disable camelcase */ - -import binding from './binding' -import { C } from './constants' -import { Lot } from './lot' -import { Chat } from './chat' -import { WebxdcInfo } from './context' -const debug = require('debug')('deltachat:node:message') - -export enum MessageDownloadState { - Available = C.DC_DOWNLOAD_AVAILABLE, - Done = C.DC_DOWNLOAD_DONE, - Failure = C.DC_DOWNLOAD_FAILURE, - InProgress = C.DC_DOWNLOAD_IN_PROGRESS, -} - -/** - * Helper class for message states so you can do e.g. - * - * if (msg.getState().isPending()) { .. } - * - */ -export class MessageState { - constructor(public state: number) { - debug(`MessageState constructor ${state}`) - } - - isUndefined() { - return this.state === C.DC_STATE_UNDEFINED - } - - isFresh() { - return this.state === C.DC_STATE_IN_FRESH - } - - isNoticed() { - return this.state === C.DC_STATE_IN_NOTICED - } - - isSeen() { - return this.state === C.DC_STATE_IN_SEEN - } - - isPending() { - return this.state === C.DC_STATE_OUT_PENDING - } - - isFailed() { - return this.state === C.DC_STATE_OUT_FAILED - } - - isDelivered() { - return this.state === C.DC_STATE_OUT_DELIVERED - } - - isReceived() { - return this.state === C.DC_STATE_OUT_MDN_RCVD - } -} - -/** - * Helper class for message types so you can do e.g. - * - * if (msg.getViewType().isVideo()) { .. } - * - */ -export class MessageViewType { - constructor(public viewType: number) { - debug(`MessageViewType constructor ${viewType}`) - } - - isText() { - return this.viewType === C.DC_MSG_TEXT - } - - isImage() { - return this.viewType === C.DC_MSG_IMAGE || this.viewType === C.DC_MSG_GIF - } - - isGif() { - return this.viewType === C.DC_MSG_GIF - } - - isAudio() { - return this.viewType === C.DC_MSG_AUDIO || this.viewType === C.DC_MSG_VOICE - } - - isVoice() { - return this.viewType === C.DC_MSG_VOICE - } - - isVideo() { - return this.viewType === C.DC_MSG_VIDEO - } - - isFile() { - return this.viewType === C.DC_MSG_FILE - } - - isVideochatInvitation() { - return this.viewType === C.DC_MSG_VIDEOCHAT_INVITATION - } -} - -interface NativeMessage {} -/** - * Wrapper around dc_msg_t* - */ -export class Message { - constructor(public dc_msg: NativeMessage) { - debug('Message constructor') - if (dc_msg === null) { - throw new Error('dc_msg can not be null') - } - } - - toJson() { - debug('toJson') - const quotedMessage = this.getQuotedMessage() - const viewType = binding.dcn_msg_get_viewtype(this.dc_msg) - return { - chatId: this.getChatId(), - webxdcInfo: viewType == C.DC_MSG_WEBXDC ? this.webxdcInfo : null, - downloadState: this.downloadState, - duration: this.getDuration(), - file: this.getFile(), - fromId: this.getFromId(), - id: this.getId(), - quotedText: this.getQuotedText(), - quotedMessageId: quotedMessage ? quotedMessage.getId() : null, - receivedTimestamp: this.getReceivedTimestamp(), - sortTimestamp: this.getSortTimestamp(), - text: this.getText(), - timestamp: this.getTimestamp(), - hasLocation: this.hasLocation(), - hasHTML: this.hasHTML, - viewType, - state: binding.dcn_msg_get_state(this.dc_msg), - hasDeviatingTimestamp: this.hasDeviatingTimestamp(), - showPadlock: this.getShowpadlock(), - summary: this.getSummary().toJson(), - subject: this.subject, - isSetupmessage: this.isSetupmessage(), - isInfo: this.isInfo(), - isForwarded: this.isForwarded(), - dimensions: { - height: this.getHeight(), - width: this.getWidth(), - }, - videochatType: this.getVideochatType(), - videochatUrl: this.getVideochatUrl(), - overrideSenderName: this.overrideSenderName, - parentId: this.parent?.getId(), - } - } - - getChatId(): number { - return binding.dcn_msg_get_chat_id(this.dc_msg) - } - - get webxdcInfo(): WebxdcInfo | null { - let info = binding.dcn_msg_get_webxdc_info(this.dc_msg) - return info - ? JSON.parse(binding.dcn_msg_get_webxdc_info(this.dc_msg)) - : null - } - - get downloadState(): MessageDownloadState { - return binding.dcn_msg_get_download_state(this.dc_msg) - } - - get parent(): Message | null { - let msg = binding.dcn_msg_get_parent(this.dc_msg) - return msg ? new Message(msg) : null - } - - getDuration(): number { - return binding.dcn_msg_get_duration(this.dc_msg) - } - - getFile(): string { - return binding.dcn_msg_get_file(this.dc_msg) - } - - getFilebytes(): number { - return binding.dcn_msg_get_filebytes(this.dc_msg) - } - - getFilemime(): string { - return binding.dcn_msg_get_filemime(this.dc_msg) - } - - getFilename(): string { - return binding.dcn_msg_get_filename(this.dc_msg) - } - - getFromId(): number { - return binding.dcn_msg_get_from_id(this.dc_msg) - } - - getHeight(): number { - return binding.dcn_msg_get_height(this.dc_msg) - } - - getId(): number { - return binding.dcn_msg_get_id(this.dc_msg) - } - - getQuotedText(): string { - return binding.dcn_msg_get_quoted_text(this.dc_msg) - } - - getQuotedMessage(): Message | null { - const dc_msg = binding.dcn_msg_get_quoted_msg(this.dc_msg) - return dc_msg ? new Message(dc_msg) : null - } - - getReceivedTimestamp(): number { - return binding.dcn_msg_get_received_timestamp(this.dc_msg) - } - - getSetupcodebegin() { - return binding.dcn_msg_get_setupcodebegin(this.dc_msg) - } - - getShowpadlock() { - return Boolean(binding.dcn_msg_get_showpadlock(this.dc_msg)) - } - - getSortTimestamp(): number { - return binding.dcn_msg_get_sort_timestamp(this.dc_msg) - } - - getState() { - return new MessageState(binding.dcn_msg_get_state(this.dc_msg)) - } - - getSummary(chat?: Chat) { - const dc_chat = (chat && chat.dc_chat) || null - return new Lot(binding.dcn_msg_get_summary(this.dc_msg, dc_chat)) - } - - get subject(): string { - return binding.dcn_msg_get_subject(this.dc_msg) - } - - getSummarytext(approxCharacters: number): string { - approxCharacters = approxCharacters || 0 - return binding.dcn_msg_get_summarytext(this.dc_msg, approxCharacters) - } - - getText(): string { - return binding.dcn_msg_get_text(this.dc_msg) - } - - getTimestamp(): number { - return binding.dcn_msg_get_timestamp(this.dc_msg) - } - - getViewType() { - return new MessageViewType(binding.dcn_msg_get_viewtype(this.dc_msg)) - } - - getVideochatType(): number { - return binding.dcn_msg_get_videochat_type(this.dc_msg) - } - - getVideochatUrl(): string { - return binding.dcn_msg_get_videochat_url(this.dc_msg) - } - - getWidth(): number { - return binding.dcn_msg_get_width(this.dc_msg) - } - - get overrideSenderName(): string { - return binding.dcn_msg_get_override_sender_name(this.dc_msg) - } - - hasDeviatingTimestamp() { - return binding.dcn_msg_has_deviating_timestamp(this.dc_msg) - } - - hasLocation() { - return Boolean(binding.dcn_msg_has_location(this.dc_msg)) - } - - get hasHTML() { - return Boolean(binding.dcn_msg_has_html(this.dc_msg)) - } - - isDeadDrop() { - // TODO: Fix - //return this.getChatId() === C.DC_CHAT_ID_DEADDROP - return false - } - - isForwarded() { - return Boolean(binding.dcn_msg_is_forwarded(this.dc_msg)) - } - - isInfo() { - return Boolean(binding.dcn_msg_is_info(this.dc_msg)) - } - - isSent() { - return Boolean(binding.dcn_msg_is_sent(this.dc_msg)) - } - - isSetupmessage() { - return Boolean(binding.dcn_msg_is_setupmessage(this.dc_msg)) - } - - latefilingMediasize(width: number, height: number, duration: number) { - binding.dcn_msg_latefiling_mediasize(this.dc_msg, width, height, duration) - } - - setDimension(width: number, height: number) { - binding.dcn_msg_set_dimension(this.dc_msg, width, height) - return this - } - - setDuration(duration: number) { - binding.dcn_msg_set_duration(this.dc_msg, duration) - return this - } - - setFile(file: string, mime?: string) { - if (typeof file !== 'string') throw new Error('Missing filename') - binding.dcn_msg_set_file(this.dc_msg, file, mime || '') - return this - } - - setLocation(longitude: number, latitude: number) { - binding.dcn_msg_set_location(this.dc_msg, longitude, latitude) - return this - } - - setQuote(quotedMessage: Message | null) { - binding.dcn_msg_set_quote(this.dc_msg, quotedMessage?.dc_msg) - return this - } - - setText(text: string) { - binding.dcn_msg_set_text(this.dc_msg, text) - return this - } - - setHTML(html: string) { - binding.dcn_msg_set_html(this.dc_msg, html) - return this - } - - setOverrideSenderName(senderName: string) { - binding.dcn_msg_set_override_sender_name(this.dc_msg, senderName) - return this - } - - /** Force the message to be sent in plain text. - * - * This API is for bots, there is no need to expose it in the UI. - */ - forcePlaintext() { - binding.dcn_msg_force_plaintext(this.dc_msg) - } -} diff --git a/node/lib/types.ts b/node/lib/types.ts deleted file mode 100644 index 6bb54d9f8..000000000 --- a/node/lib/types.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { C } from './constants' - -export type ChatTypes = - | C.DC_CHAT_TYPE_GROUP - | C.DC_CHAT_TYPE_MAILINGLIST - | C.DC_CHAT_TYPE_SINGLE - | C.DC_CHAT_TYPE_UNDEFINED - -export interface ChatJSON { - archived: boolean - pinned: boolean - color: string - id: number - name: string - mailinglistAddr: string - profileImage: string - type: number - isSelfTalk: boolean - isUnpromoted: boolean - isProtected: boolean - canSend: boolean - isDeviceTalk: boolean - isContactRequest: boolean - muted: boolean -} diff --git a/node/lib/util.ts b/node/lib/util.ts deleted file mode 100644 index 7a8c4ba6b..000000000 --- a/node/lib/util.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * @param integerColor expects a 24bit rgb integer (left to right: 8bits red, 8bits green, 8bits blue) - */ -export function integerToHexColor(integerColor: number) { - return '#' + (integerColor + 16777216).toString(16).substring(1) -} diff --git a/node/patches/m1_build_use_x86_64.patch b/node/patches/m1_build_use_x86_64.patch deleted file mode 100644 index cf52ea296..000000000 --- a/node/patches/m1_build_use_x86_64.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git i/node/binding.gyp w/node/binding.gyp -index b0d92eae..c5e504fa 100644 ---- i/node/binding.gyp -+++ w/node/binding.gyp -@@ -43,7 +43,7 @@ - "include_dirs": ["../deltachat-ffi"], - "ldflags": ["-Wl,-Bsymbolic"], # Prevent sqlite3 from electron from overriding sqlcipher - "libraries": [ -- "../../target/release/libdeltachat.a", -+ "../../target/x86_64-apple-darwin/release/libdeltachat.a", - "-ldl", - ], - "conditions": [], diff --git a/node/scripts/common.js b/node/scripts/common.js deleted file mode 100644 index af085cb59..000000000 --- a/node/scripts/common.js +++ /dev/null @@ -1,26 +0,0 @@ -const spawnSync = require('child_process').spawnSync - -const verbose = isVerbose() - -function spawn (cmd, args, opts) { - log(`>> spawn: ${cmd} ${args.join(' ')}`) - const result = spawnSync(cmd, args, opts) - if (result.status === null) { - console.error(`Could not find ${cmd}`) - process.exit(1) - } else if (result.status !== 0) { - console.error(`${cmd} failed with code ${result.status}`) - process.exit(1) - } -} - -function log (...args) { - if (verbose) console.log(...args) -} - -function isVerbose () { - const loglevel = process.env.npm_config_loglevel - return loglevel === 'verbose' || process.env.CI === 'true' -} - -module.exports = { spawn, log, isVerbose, verbose } diff --git a/node/scripts/generate-constants.js b/node/scripts/generate-constants.js deleted file mode 100755 index 7e821dc0a..000000000 --- a/node/scripts/generate-constants.js +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env node -const fs = require('fs') -const path = require('path') - -const data = [] -const header = path.resolve(__dirname, '../../deltachat-ffi/deltachat.h') - -console.log('Generating constants...') - -const header_data = fs.readFileSync(header, 'UTF-8') -const regex = /^#define\s+(\w+)\s+(\w+)/gm -while (null != (match = regex.exec(header_data))) { - const key = match[1] - const value = parseInt(match[2]) - if (!isNaN(value)) { - data.push({ key, value }) - } -} - -delete header_data - -const constants = data - .filter( - ({ key }) => key.toUpperCase()[0] === key[0] // check if define name is uppercase - ) - .sort((lhs, rhs) => { - if (lhs.key < rhs.key) return -1 - else if (lhs.key > rhs.key) return 1 - return 0 - }) - .map((row) => { - return ` ${row.key}: ${row.value}` - }) - .join(',\n') - -const events = data - .sort((lhs, rhs) => { - if (lhs.value < rhs.value) return -1 - else if (lhs.value > rhs.value) return 1 - return 0 - }) - .filter((i) => { - return i.key.startsWith('DC_EVENT_') - }) - .map((i) => { - return ` ${i.value}: '${i.key}'` - }) - .join(',\n') - -// backwards compat -fs.writeFileSync( - path.resolve(__dirname, '../constants.js'), - `// Generated!\n\nmodule.exports = {\n${constants}\n}\n` -) -// backwards compat -fs.writeFileSync( - path.resolve(__dirname, '../events.js'), - `/* eslint-disable quotes */\n// Generated!\n\nmodule.exports = {\n${events}\n}\n` -) - -fs.writeFileSync( - path.resolve(__dirname, '../lib/constants.ts'), - `// Generated!\n\nexport enum C {\n${constants.replace(/:/g, ' =')},\n}\n -// Generated!\n\nexport const EventId2EventName: { [key: number]: string } = {\n${events},\n}\n` -) diff --git a/node/scripts/install.js b/node/scripts/install.js deleted file mode 100644 index 3f320be4a..000000000 --- a/node/scripts/install.js +++ /dev/null @@ -1,22 +0,0 @@ -const {execSync} = require('child_process') -const {existsSync} = require('fs') -const {join} = require('path') - -const run = (cmd) => { - console.log('[i] running `' + cmd + '`') - execSync(cmd, {stdio: 'inherit'}) -} - -// Build bindings -if (process.env.USE_SYSTEM_LIBDELTACHAT === 'true') { - console.log('[i] USE_SYSTEM_LIBDELTACHAT is true, rebuilding c bindings and using pkg-config to retrieve lib paths and cflags of libdeltachat') - run('npm run build:bindings:c:c') -} else { - console.log('[i] Building rust core & c bindings, if possible use prebuilds') - run('npm run install:prebuilds') -} - -if (!existsSync(join(__dirname, '..', 'dist'))) { - console.log('[i] Didn\'t find already built typescript bindings. Trying to transpile them. If this fail, make sure typescript is installed ;)') - run('npm run build:bindings:ts') -} diff --git a/node/scripts/postLinksToDetails.js b/node/scripts/postLinksToDetails.js deleted file mode 100644 index 83b70037e..000000000 --- a/node/scripts/postLinksToDetails.js +++ /dev/null @@ -1,47 +0,0 @@ -const { readFileSync } = require('fs') - -const sha = JSON.parse( - readFileSync(process.env['GITHUB_EVENT_PATH'], 'utf8') -).pull_request.head.sha - -const base_url = - 'https://download.delta.chat/node/' - -const GITHUB_API_URL = - 'https://api.github.com/repos/deltachat/deltachat-core-rust/statuses/' + sha - -const file_url = process.env['URL'] -const GITHUB_TOKEN = process.env['GITHUB_TOKEN'] -const context = process.env['MSG_CONTEXT'] - -const STATUS_DATA = { - state: 'success', - description: '⏩ Click on "Details" to download β†’', - context: context || 'Download the node-bindings.tar.gz', - target_url: base_url + file_url, -} - -const http = require('https') - -const options = { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'User-Agent': 'github-action ci for deltachat deskop', - authorization: 'Bearer ' + GITHUB_TOKEN, - }, -} - -const req = http.request(GITHUB_API_URL, options, function(res) { - var chunks = [] - res.on('data', function(chunk) { - chunks.push(chunk) - }) - res.on('end', function() { - var body = Buffer.concat(chunks) - console.log(body.toString()) - }) -}) - -req.write(JSON.stringify(STATUS_DATA)) -req.end() diff --git a/node/scripts/postinstall.js b/node/scripts/postinstall.js deleted file mode 100644 index 15eb241ad..000000000 --- a/node/scripts/postinstall.js +++ /dev/null @@ -1,57 +0,0 @@ -const fs = require('fs') -const path = require('path') - -if (process.platform !== 'win32') { - console.log('postinstall: not windows, so skipping!') - process.exit(0) -} - -const from = path.resolve( - __dirname, - '..', - '..', - 'target', - 'release', - 'deltachat.dll' -) - -const getDestination = () => { - const argv = process.argv - if (argv.length === 3 && argv[2] === '--prebuild') { - return path.resolve( - __dirname, - '..', - 'prebuilds', - 'win32-x64', - 'deltachat.dll' - ) - } else { - return path.resolve( - __dirname, - '..', - 'build', - 'Release', - 'deltachat.dll' - ) - } -} - -const dest = getDestination() - -copy(from, dest, (err) => { - if (err) throw err - console.log(`postinstall: copied ${from} to ${dest}`) -}) - -function copy (from, to, cb) { - fs.stat(from, (err, st) => { - if (err) return cb(err) - fs.readFile(from, (err, buf) => { - if (err) return cb(err) - fs.writeFile(to, buf, (err) => { - if (err) return cb(err) - fs.chmod(to, st.mode, cb) - }) - }) - }) -} diff --git a/node/scripts/rebuild-core.js b/node/scripts/rebuild-core.js deleted file mode 100644 index 80dedcce5..000000000 --- a/node/scripts/rebuild-core.js +++ /dev/null @@ -1,17 +0,0 @@ -const path = require('path') -const { spawn } = require('./common') -const opts = { - cwd: path.resolve(__dirname, '../..'), - stdio: 'inherit' -} - -const buildArgs = [ - 'build', - '--release', - '--features', - 'vendored', - '-p', - 'deltachat_ffi' -] - -spawn('cargo', buildArgs, opts) diff --git a/node/src/module.c b/node/src/module.c deleted file mode 100644 index 02dda50c1..000000000 --- a/node/src/module.c +++ /dev/null @@ -1,3600 +0,0 @@ -#define NAPI_VERSION 4 - -#include -#include -#include -#include -#include -#include -#include "napi-macros-extensions.h" - -//#define DEBUG - -#ifdef DEBUG -#define TRACE(fmt, ...) fprintf(stderr, "> module.c:%d %s() " fmt "\n", __LINE__, __func__, ##__VA_ARGS__) -#else -#define TRACE(fmt, ...) -#endif - -/** - * Custom context - */ -typedef struct dcn_context_t { - dc_context_t* dc_context; - napi_threadsafe_function threadsafe_event_handler; - uv_thread_t event_handler_thread; - int gc; -} dcn_context_t; - -/** - * Custom accounts - */ -typedef struct dcn_accounts_t { - dc_accounts_t* dc_accounts; - napi_threadsafe_function threadsafe_event_handler; - uv_thread_t event_handler_thread; - napi_threadsafe_function threadsafe_jsonrpc_handler; - uv_thread_t jsonrpc_thread; - dc_jsonrpc_instance_t* jsonrpc_instance; - int gc; -} dcn_accounts_t; - - - - -/** - * Finalize functions. These are called once the corresponding - * external is garbage collected on the JavaScript side. - */ - -static void finalize_chat(napi_env env, void* data, void* hint) { - if (data) { - dc_chat_t* chat = (dc_chat_t*)data; - //TRACE("cleaning up chat %d", dc_chat_get_id(chat)); - dc_chat_unref(chat); - } -} - -static void finalize_chatlist(napi_env env, void* data, void* hint) { - if (data) { - //TRACE("cleaning up chatlist object"); - dc_chatlist_unref((dc_chatlist_t*)data); - } -} - -static void finalize_contact(napi_env env, void* data, void* hint) { - if (data) { - dc_contact_t* contact = (dc_contact_t*)data; - //TRACE("cleaning up contact %d", dc_contact_get_id(contact)); - dc_contact_unref(contact); - } -} - -static void finalize_lot(napi_env env, void* data, void* hint) { - if (data) { - //TRACE("cleaning up lot"); - dc_lot_unref((dc_lot_t*)data); - } -} - -static void finalize_array(napi_env env, void* data, void* hint) { - if (data) { - //TRACE("cleaning up array"); - dc_array_unref((dc_array_t*)data); - } -} - -static void finalize_msg(napi_env env, void* data, void* hint) { - if (data) { - dc_msg_t* msg = (dc_msg_t*)data; - //TRACE("cleaning up message %d", dc_msg_get_id(msg)); - dc_msg_unref(msg); - } -} - -static void finalize_provider(napi_env env, void* data, void* hint) { - if (data) { - dc_provider_t* provider = (dc_provider_t*)data; - //TRACE("cleaning up provider"); - dc_provider_unref(provider); - } -} - -/** - * Helpers. - */ - -static uint32_t* js_array_to_uint32(napi_env env, napi_value js_array, uint32_t* length) { - *length = 0; - NAPI_STATUS_THROWS(napi_get_array_length(env, js_array, length)); - - uint32_t* array = calloc(*length, sizeof(uint32_t)); - - for (uint32_t i = 0; i < *length; i++) { - napi_value napi_element; - NAPI_STATUS_THROWS(napi_get_element(env, js_array, i, &napi_element)); - NAPI_STATUS_THROWS(napi_get_value_uint32(env, napi_element, &array[i])); - } - - return array; -} - -static napi_value dc_array_to_js_array(napi_env env, dc_array_t* array) { - napi_value js_array; - - const int length = dc_array_get_cnt(array); - NAPI_STATUS_THROWS(napi_create_array_with_length(env, length, &js_array)); - - if (length > 0) { - for (int i = 0; i < length; i++) { - const uint32_t id = dc_array_get_id(array, i); - napi_value napi_id; - NAPI_STATUS_THROWS(napi_create_uint32(env, id, &napi_id)); - NAPI_STATUS_THROWS(napi_set_element(env, js_array, i, napi_id)); - } - } - - return js_array; -} - -/** - * Main context. - */ - -NAPI_METHOD(dcn_context_new) { - NAPI_ARGV(1); - - NAPI_ARGV_UTF8_MALLOC(db_file, 0); - - TRACE("creating new dc_context"); - - dcn_context_t* dcn_context = calloc(1, sizeof(dcn_context_t)); - dcn_context->dc_context = dc_context_new(NULL, db_file, NULL); - - - napi_value result; - NAPI_STATUS_THROWS(napi_create_external(env, dcn_context, - NULL, NULL, &result)); - return result; -} - -NAPI_METHOD(dcn_context_new_closed) { - NAPI_ARGV(1); - - NAPI_ARGV_UTF8_MALLOC(db_file, 0); - - TRACE("creating new closed dc_context"); - - dcn_context_t* dcn_context = calloc(1, sizeof(dcn_context_t)); - dcn_context->dc_context = dc_context_new_closed(db_file); - - - napi_value result; - NAPI_STATUS_THROWS(napi_create_external(env, dcn_context, - NULL, NULL, &result)); - return result; -} - -NAPI_METHOD(dcn_context_open) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UTF8_MALLOC(passphrase, 1); - - int result = dc_context_open(dcn_context->dc_context, passphrase); - free(passphrase); - - NAPI_RETURN_UINT32(result); -} - -NAPI_METHOD(dcn_context_is_open) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - int result = dc_context_is_open(dcn_context->dc_context); - - NAPI_RETURN_UINT32(result); -} - -/** - * Event struct for calling back to JavaScript - */ -typedef struct dcn_event_t { - int event; - uintptr_t data1_int; - uintptr_t data2_int; - char* data1_str; - char* data2_str; -} dcn_event_t; - - -static void event_handler_thread_func(void* arg) -{ - dcn_context_t* dcn_context = (dcn_context_t*)arg; - dc_context_t* dc_context = dcn_context->dc_context; - - - TRACE("event_handler_thread_func starting"); - - - dc_event_emitter_t* emitter = dc_get_event_emitter(dc_context); - dc_event_t* event; - while (true) { - if (emitter == NULL) { - TRACE("event emitter is null, bailing"); - break; - } - - event = dc_get_next_event(emitter); - if (event == NULL) { - TRACE("event is null, bailing"); - break; - } - - if (!dcn_context->threadsafe_event_handler) { - TRACE("threadsafe_event_handler not set, bailing"); - break; - } - - // Don't process events if we're being garbage collected! - if (dcn_context->gc == 1) { - TRACE("dc_context has been destroyed, bailing"); - break; - } - - - napi_status status = napi_call_threadsafe_function(dcn_context->threadsafe_event_handler, event, napi_tsfn_blocking); - - if (status == napi_closing) { - TRACE("JS function got released, bailing"); - break; - } - } - - dc_event_emitter_unref(emitter); - - TRACE("event_handler_thread_func ended"); - - napi_release_threadsafe_function(dcn_context->threadsafe_event_handler, napi_tsfn_release); -} - -static void call_js_event_handler(napi_env env, napi_value js_callback, void* _context, void* data) -{ - dc_event_t* dc_event = (dc_event_t*)data; - - napi_value global; - napi_status status = napi_get_global(env, &global); - - if (status != napi_ok) { - napi_throw_error(env, NULL, "Unable to get global"); - } - -#define CALL_JS_CALLBACK_ARGC 3 - - const int argc = CALL_JS_CALLBACK_ARGC; - napi_value argv[CALL_JS_CALLBACK_ARGC]; - - const int event_id = dc_event_get_id(dc_event); - - status = napi_create_int32(env, event_id, &argv[0]); - if (status != napi_ok) { - napi_throw_error(env, NULL, "Unable to create argv[0] for event_handler arguments"); - } - - status = napi_create_int32(env, dc_event_get_data1_int(dc_event), &argv[1]); - if (status != napi_ok) { - napi_throw_error(env, NULL, "Unable to create argv[1] for event_handler arguments"); - } - - if DC_EVENT_DATA2_IS_STRING(event_id) { - char* data2_string = dc_event_get_data2_str(dc_event); - // Quick fix for https://github.com/deltachat/deltachat-core-rust/issues/1949 - if (data2_string != 0) { - status = napi_create_string_utf8(env, data2_string, NAPI_AUTO_LENGTH, &argv[2]); - } else { - status = napi_create_string_utf8(env, "", NAPI_AUTO_LENGTH, &argv[2]); - } - if (status != napi_ok) { - napi_throw_error(env, NULL, "Unable to create argv[2] for event_handler arguments"); - } - free(data2_string); - } else { - status = napi_create_int32(env, dc_event_get_data2_int(dc_event), &argv[2]); - if (status != napi_ok) { - napi_throw_error(env, NULL, "Unable to create argv[2] for event_handler arguments"); - } - } - - dc_event_unref(dc_event); - dc_event = NULL; - - TRACE("calling back into js"); - - napi_value result; - status = napi_call_function( - env, - global, - js_callback, - argc, - argv, - &result); - - if (status != napi_ok) { - TRACE("Unable to call event_handler callback2"); - const napi_extended_error_info* error_result; - NAPI_STATUS_THROWS(napi_get_last_error_info(env, &error_result)); - } -} - - -NAPI_METHOD(dcn_start_event_handler) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - napi_value callback = argv[1]; - - TRACE("calling.."); - napi_value async_resource_name; - NAPI_STATUS_THROWS(napi_create_string_utf8(env, "dc_event_callback", NAPI_AUTO_LENGTH, &async_resource_name)); - - TRACE("creating threadsafe function.."); - - NAPI_STATUS_THROWS(napi_create_threadsafe_function( - env, - callback, - 0, - async_resource_name, - 1000, // max_queue_size - 1, - NULL, - NULL, - dcn_context, - call_js_event_handler, - &dcn_context->threadsafe_event_handler)); - TRACE("done"); - - dcn_context->gc = 0; - TRACE("creating uv thread.."); - uv_thread_create(&dcn_context->event_handler_thread, event_handler_thread_func, dcn_context); - - NAPI_RETURN_UNDEFINED(); -} - - -NAPI_METHOD(dcn_context_unref) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - TRACE("Unrefing dc_context"); - dcn_context->gc = 1; - if (dcn_context->event_handler_thread != 0) { - dc_stop_io(dcn_context->dc_context); - uv_thread_join(&dcn_context->event_handler_thread); - dcn_context->event_handler_thread = 0; - } - dc_context_unref(dcn_context->dc_context); - dcn_context->dc_context = NULL; - - NAPI_RETURN_UNDEFINED(); - -} - -/** - * Static functions - */ - -NAPI_METHOD(dcn_maybe_valid_addr) { - NAPI_ARGV(1); - NAPI_ARGV_UTF8_MALLOC(addr, 0); - - //TRACE("calling.."); - int result = dc_may_be_valid_addr(addr); - //TRACE("result %d", result); - - free(addr); - - NAPI_RETURN_INT32(result); -} - -/** - * dcn_context_t - */ - -NAPI_METHOD(dcn_add_address_book) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UTF8_MALLOC(address_book, 1); - - //TRACE("calling.."); - int result = dc_add_address_book(dcn_context->dc_context, address_book); - //TRACE("result %d", result); - - free(address_book); - - NAPI_RETURN_INT32(result); -} - -NAPI_METHOD(dcn_add_contact_to_chat) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - NAPI_ARGV_UINT32(contact_id, 2); - - //TRACE("calling.."); - int result = dc_add_contact_to_chat(dcn_context->dc_context, - chat_id, contact_id); - //TRACE("result %d", result); - - NAPI_RETURN_INT32(result); -} - -NAPI_METHOD(dcn_add_device_msg) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - - NAPI_ARGV_UTF8_MALLOC(label, 1); - - //TRACE("calling.."); - dc_msg_t* dc_msg = NULL; - napi_get_value_external(env, argv[2], (void**)&dc_msg); - - uint32_t msg_id = dc_add_device_msg(dcn_context->dc_context, label, dc_msg); - - free(label); - //TRACE("done"); - - NAPI_RETURN_UINT32(msg_id); -} - -NAPI_METHOD(dcn_block_contact) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(contact_id, 1); - NAPI_ARGV_INT32(new_blocking, 2); - - //TRACE("calling.."); - dc_block_contact(dcn_context->dc_context, contact_id, new_blocking); - //TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_check_qr) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UTF8_MALLOC(qr, 1); - - //TRACE("calling.."); - dc_lot_t* lot = dc_check_qr(dcn_context->dc_context, qr); - - free(qr); - - napi_value result; - if (lot == NULL) { - NAPI_STATUS_THROWS(napi_get_null(env, &result)); - } else { - NAPI_STATUS_THROWS(napi_create_external(env, lot, - finalize_lot, - NULL, &result)); - } - //TRACE("done"); - - return result; -} - - -NAPI_METHOD(dcn_configure) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - TRACE("calling.."); - dc_configure(dcn_context->dc_context); - TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_accept_chat) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - - dc_accept_chat(dcn_context->dc_context, chat_id); - - NAPI_RETURN_UNDEFINED() -} - -NAPI_METHOD(dcn_block_chat) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - - dc_block_chat(dcn_context->dc_context, chat_id); - - NAPI_RETURN_UNDEFINED() -} - -NAPI_ASYNC_CARRIER_BEGIN(dcn_continue_key_transfer) - int msg_id; - char* setup_code; - int result; -NAPI_ASYNC_CARRIER_END(dcn_continue_key_transfer) - - -NAPI_ASYNC_EXECUTE(dcn_continue_key_transfer) { - NAPI_ASYNC_GET_CARRIER(dcn_continue_key_transfer) - carrier->result = dc_continue_key_transfer(carrier->dcn_context->dc_context, - carrier->msg_id, carrier->setup_code); -} - -NAPI_ASYNC_COMPLETE(dcn_continue_key_transfer) { - NAPI_ASYNC_GET_CARRIER(dcn_continue_key_transfer) - if (status != napi_ok) { - napi_throw_type_error(env, NULL, "Execute callback failed."); - return; - } - -#define DCN_CONTINUE_KEY_TRANSFER_CALLBACK_ARGC 1 - - const int argc = DCN_CONTINUE_KEY_TRANSFER_CALLBACK_ARGC; - napi_value argv[DCN_CONTINUE_KEY_TRANSFER_CALLBACK_ARGC]; - NAPI_STATUS_THROWS(napi_create_int32(env, carrier->result, &argv[0])); - - NAPI_ASYNC_CALL_AND_DELETE_CB() - dc_str_unref(carrier->setup_code); - free(carrier); -} - -NAPI_METHOD(dcn_continue_key_transfer) { - NAPI_ARGV(4); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(msg_id, 1); - NAPI_ARGV_UTF8_MALLOC(setup_code, 2); - NAPI_ASYNC_NEW_CARRIER(dcn_continue_key_transfer); - carrier->msg_id = msg_id; - carrier->setup_code = setup_code; - - NAPI_ASYNC_QUEUE_WORK(dcn_continue_key_transfer, argv[3]); - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_join_securejoin) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UTF8_MALLOC(qr_code, 1); - - uint32_t chat_id = dc_join_securejoin(dcn_context->dc_context, qr_code); - - NAPI_RETURN_UINT32(chat_id); -} - -NAPI_METHOD(dcn_create_chat_by_contact_id) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_INT32(contact_id, 1); - - //TRACE("calling.."); - uint32_t chat_id = dc_create_chat_by_contact_id(dcn_context->dc_context, contact_id); - //TRACE("result %d", chat_id); - - NAPI_RETURN_UINT32(chat_id); -} - -NAPI_METHOD(dcn_create_broadcast_list) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - //TRACE("calling.."); - uint32_t chat_id = dc_create_broadcast_list(dcn_context->dc_context); - //TRACE("result %d", chat_id); - - NAPI_RETURN_UINT32(chat_id); -} - -NAPI_METHOD(dcn_create_contact) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UTF8_MALLOC(name, 1); - NAPI_ARGV_UTF8_MALLOC(addr, 2); - - //TRACE("calling.."); - uint32_t contact_id = dc_create_contact(dcn_context->dc_context, name, addr); - //TRACE("result %d", contact_id); - - free(name); - free(addr); - - NAPI_RETURN_UINT32(contact_id); -} - -NAPI_METHOD(dcn_create_group_chat) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_INT32(protect, 1); - NAPI_ARGV_UTF8_MALLOC(chat_name, 2); - - //TRACE("calling.."); - uint32_t chat_id = dc_create_group_chat(dcn_context->dc_context, protect, chat_name); - //TRACE("result %d", chat_id); - - free(chat_name); - - NAPI_RETURN_UINT32(chat_id); -} - -NAPI_METHOD(dcn_delete_chat) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - - //TRACE("calling.."); - dc_delete_chat(dcn_context->dc_context, chat_id); - //TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_delete_contact) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(contact_id, 1); - - //TRACE("calling.."); - int result = dc_delete_contact(dcn_context->dc_context, contact_id); - //TRACE("result %d", result); - - NAPI_RETURN_INT32(result); -} - -NAPI_METHOD(dcn_delete_msgs) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - napi_value js_array = argv[1]; - - //TRACE("calling.."); - uint32_t length; - uint32_t* msg_ids = js_array_to_uint32(env, js_array, &length); - dc_delete_msgs(dcn_context->dc_context, msg_ids, length); - free(msg_ids); - //TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_forward_msgs) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - napi_value js_array = argv[1]; - NAPI_ARGV_UINT32(chat_id, 2); - - //TRACE("calling.."); - uint32_t length; - uint32_t* msg_ids = js_array_to_uint32(env, js_array, &length); - dc_forward_msgs(dcn_context->dc_context, msg_ids, length, chat_id); - free(msg_ids); - //TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_get_blobdir) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - //TRACE("calling.."); - char* blobdir = dc_get_blobdir(dcn_context->dc_context); - //TRACE("result %s", blobdir); - - NAPI_RETURN_AND_UNREF_STRING(blobdir); -} - -NAPI_METHOD(dcn_get_blocked_cnt) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - //TRACE("calling.."); - int blocked_cnt = dc_get_blocked_cnt(dcn_context->dc_context); - //TRACE("result %d", blocked_cnt); - - NAPI_RETURN_INT32(blocked_cnt); -} - -NAPI_METHOD(dcn_get_blocked_contacts) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - //TRACE("calling.."); - dc_array_t* contacts = dc_get_blocked_contacts(dcn_context->dc_context); - napi_value js_array = dc_array_to_js_array(env, contacts); - dc_array_unref(contacts); - //TRACE("done"); - - return js_array; -} - -NAPI_METHOD(dcn_get_chat) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - - //TRACE("calling.."); - napi_value result; - dc_chat_t* chat = dc_get_chat(dcn_context->dc_context, chat_id); - - if (chat == NULL) { - NAPI_STATUS_THROWS(napi_get_null(env, &result)); - } else { - NAPI_STATUS_THROWS(napi_create_external(env, chat, finalize_chat, - NULL, &result)); - } - //TRACE("done"); - - return result; -} - -NAPI_METHOD(dcn_get_chat_contacts) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - - //TRACE("calling.."); - dc_array_t* contacts = dc_get_chat_contacts(dcn_context->dc_context, chat_id); - napi_value js_array = dc_array_to_js_array(env, contacts); - dc_array_unref(contacts); - //TRACE("done"); - - return js_array; -} - -NAPI_METHOD(dcn_get_chat_encrinfo) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - char *value = dc_get_chat_encrinfo(dcn_context->dc_context, chat_id); - NAPI_RETURN_AND_UNREF_STRING(value); -} - -NAPI_METHOD(dcn_get_chat_id_by_contact_id) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(contact_id, 1); - - //TRACE("calling.."); - uint32_t chat_id = dc_get_chat_id_by_contact_id(dcn_context->dc_context, - contact_id); - //TRACE("result %d", chat_id); - - NAPI_RETURN_UINT32(chat_id); -} - -NAPI_METHOD(dcn_get_chat_media) { - NAPI_ARGV(5); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - NAPI_ARGV_INT32(msg_type1, 2); - NAPI_ARGV_INT32(msg_type2, 3); - NAPI_ARGV_INT32(msg_type3, 4); - - //TRACE("calling.."); - dc_array_t* msg_ids = dc_get_chat_media(dcn_context->dc_context, - chat_id, - msg_type1, - msg_type2, - msg_type3); - napi_value js_array = dc_array_to_js_array(env, msg_ids); - dc_array_unref(msg_ids); - //TRACE("done"); - - return js_array; -} - -NAPI_METHOD(dcn_get_mime_headers) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(msg_id, 1); - - //TRACE("calling.."); - char* headers = dc_get_mime_headers(dcn_context->dc_context, msg_id); - //TRACE("result %s", headers); - - NAPI_RETURN_AND_UNREF_STRING(headers); -} - -NAPI_METHOD(dcn_get_chat_msgs) { - NAPI_ARGV(4); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - NAPI_ARGV_UINT32(flags, 2); - NAPI_ARGV_UINT32(marker1before, 3); - - //TRACE("calling.."); - dc_array_t* msg_ids = dc_get_chat_msgs(dcn_context->dc_context, - chat_id, - flags, - marker1before); - napi_value js_array = dc_array_to_js_array(env, msg_ids); - dc_array_unref(msg_ids); - //TRACE("done"); - - return js_array; -} - -NAPI_METHOD(dcn_get_chatlist) { - NAPI_ARGV(4); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_INT32(listflags, 1); - NAPI_ARGV_UTF8_MALLOC(query, 2); - NAPI_ARGV_UINT32(query_contact_id, 3); - - //TRACE("calling.."); - dc_chatlist_t* chatlist = dc_get_chatlist(dcn_context->dc_context, - listflags, - query && query[0] ? query : NULL, - query_contact_id); - - free(query); - - napi_value result; - NAPI_STATUS_THROWS(napi_create_external(env, - chatlist, - finalize_chatlist, - NULL, - &result)); - //TRACE("done"); - - return result; -} - -NAPI_METHOD(dcn_get_config) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UTF8_MALLOC(key, 1); - - //TRACE("calling.."); - char *value = dc_get_config(dcn_context->dc_context, key); - //TRACE("result %s", value); - - free(key); - - NAPI_RETURN_AND_UNREF_STRING(value); -} - -NAPI_METHOD(dcn_get_contact) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(contact_id, 1); - - //TRACE("calling.."); - napi_value result; - dc_contact_t* contact = dc_get_contact(dcn_context->dc_context, contact_id); - - if (contact == NULL) { - NAPI_STATUS_THROWS(napi_get_null(env, &result)); - } else { - NAPI_STATUS_THROWS(napi_create_external(env, contact, - finalize_contact, - NULL, &result)); - } - //TRACE("done"); - - return result; -} - -NAPI_METHOD(dcn_get_contact_encrinfo) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(contact_id, 1); - - //TRACE("calling.."); - char* encr_info = dc_get_contact_encrinfo(dcn_context->dc_context, - contact_id); - //TRACE("result %s", encr_info); - - NAPI_RETURN_AND_UNREF_STRING(encr_info); -} - -NAPI_METHOD(dcn_get_contacts) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(listflags, 1); - NAPI_ARGV_UTF8_MALLOC(query, 2); - - //TRACE("calling.."); - dc_array_t* contacts = dc_get_contacts(dcn_context->dc_context, listflags, - query && query[0] ? query : NULL); - napi_value js_array = dc_array_to_js_array(env, contacts); - free(query); - dc_array_unref(contacts); - //TRACE("done"); - - return js_array; -} - -NAPI_METHOD(dcn_get_connectivity) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - int connectivity = dc_get_connectivity(dcn_context->dc_context); - NAPI_RETURN_INT32(connectivity); -} - -NAPI_METHOD(dcn_get_connectivity_html) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - char* connectivity = dc_get_connectivity_html(dcn_context->dc_context); - NAPI_RETURN_AND_UNREF_STRING(connectivity); -} - -NAPI_METHOD(dcn_was_device_msg_ever_added) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - - NAPI_ARGV_UTF8_MALLOC(label, 1); - - //TRACE("calling.."); - - uint32_t added = dc_was_device_msg_ever_added(dcn_context->dc_context, label); - - free(label); - //TRACE("done"); - - NAPI_RETURN_UINT32(added); -} - -NAPI_METHOD(dcn_get_draft) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - - //TRACE("calling.."); - napi_value result; - dc_msg_t* draft = dc_get_draft(dcn_context->dc_context, chat_id); - - if (draft == NULL) { - NAPI_STATUS_THROWS(napi_get_null(env, &result)); - } else { - NAPI_STATUS_THROWS(napi_create_external(env, draft, finalize_msg, - NULL, &result)); - } - //TRACE("done"); - - return result; -} - -NAPI_METHOD(dcn_get_fresh_msg_cnt) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - - //TRACE("calling.."); - int msg_cnt = dc_get_fresh_msg_cnt(dcn_context->dc_context, chat_id); - //TRACE("result %d", msg_cnt); - - NAPI_RETURN_INT32(msg_cnt); -} - -NAPI_METHOD(dcn_get_fresh_msgs) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - //TRACE("calling.."); - dc_array_t* msg_ids = dc_get_fresh_msgs(dcn_context->dc_context); - napi_value js_array = dc_array_to_js_array(env, msg_ids); - dc_array_unref(msg_ids); - //TRACE("done"); - - return js_array; -} - -NAPI_METHOD(dcn_get_info) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - //TRACE("calling.."); - char *str = dc_get_info(dcn_context->dc_context); - //TRACE("result %s", str); - - NAPI_RETURN_AND_UNREF_STRING(str); -} - -NAPI_METHOD(dcn_get_msg) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(msg_id, 1); - - //TRACE("calling.."); - napi_value result; - dc_msg_t* msg = dc_get_msg(dcn_context->dc_context, msg_id); - - if (msg == NULL) { - NAPI_STATUS_THROWS(napi_get_null(env, &result)); - } else { - NAPI_STATUS_THROWS(napi_create_external(env, msg, finalize_msg, - NULL, &result)); - } - //TRACE("done"); - - return result; -} - -NAPI_METHOD(dcn_get_msg_cnt) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - - //TRACE("calling.."); - int msg_cnt = dc_get_msg_cnt(dcn_context->dc_context, chat_id); - //TRACE("result %d", msg_cnt); - - NAPI_RETURN_INT32(msg_cnt); -} - -NAPI_METHOD(dcn_get_msg_info) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(msg_id, 1); - - //TRACE("calling.."); - char* msg_info = dc_get_msg_info(dcn_context->dc_context, msg_id); - //TRACE("result %s", msg_info); - - NAPI_RETURN_AND_UNREF_STRING(msg_info); -} - - -NAPI_METHOD(dcn_get_msg_html) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(msg_id, 1); - - //TRACE("calling.."); - char* msg_html = dc_get_msg_html(dcn_context->dc_context, msg_id); - //TRACE("result %s", msg_html); - - NAPI_RETURN_AND_UNREF_STRING(msg_html); -} - -NAPI_METHOD(dcn_set_chat_visibility) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - NAPI_ARGV_INT32(visibility, 2); - //TRACE("calling.."); - dc_set_chat_visibility(dcn_context->dc_context, - chat_id, - visibility); - //TRACE("result %d", next_id); - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_get_securejoin_qr) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(group_chat_id, 1); - - //TRACE("calling.."); - char* code = dc_get_securejoin_qr(dcn_context->dc_context, - group_chat_id); - //TRACE("result %s", code); - - NAPI_RETURN_AND_UNREF_STRING(code); -} - -NAPI_METHOD(dcn_get_securejoin_qr_svg) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(group_chat_id, 1); - - //TRACE("calling.."); - char* svg = dc_get_securejoin_qr_svg(dcn_context->dc_context, group_chat_id); - //TRACE("result %s", code); - - NAPI_RETURN_AND_UNREF_STRING(svg); -} - -NAPI_METHOD(dcn_imex) { - NAPI_ARGV(4); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_INT32(what, 1); - NAPI_ARGV_UTF8_MALLOC(param1, 2); - NAPI_ARGV_UTF8_MALLOC(param2, 3); - - TRACE("calling.."); - dc_imex(dcn_context->dc_context, - what, - param1, - param2 && param2[0] ? param2 : NULL); - - free(param1); - free(param2); - TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_imex_has_backup) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UTF8_MALLOC(dir_name, 1); - - //TRACE("calling.."); - char* file = dc_imex_has_backup(dcn_context->dc_context, dir_name); - //TRACE("result %s", file); - - free(dir_name); - - NAPI_RETURN_AND_UNREF_STRING(file); -} - -NAPI_ASYNC_CARRIER_BEGIN(dcn_initiate_key_transfer) - char* result; -NAPI_ASYNC_CARRIER_END(dcn_initiate_key_transfer) - -NAPI_ASYNC_EXECUTE(dcn_initiate_key_transfer) { - NAPI_ASYNC_GET_CARRIER(dcn_initiate_key_transfer); - carrier->result = dc_initiate_key_transfer(carrier->dcn_context->dc_context); -} - -NAPI_ASYNC_COMPLETE(dcn_initiate_key_transfer) { - NAPI_ASYNC_GET_CARRIER(dcn_initiate_key_transfer); - if (status != napi_ok) { - napi_throw_type_error(env, NULL, "Execute callback failed."); - return; - } - -#define DCN_INITIATE_KEY_TRANSFER_CALLBACK_ARGC 1 - - const int argc = DCN_INITIATE_KEY_TRANSFER_CALLBACK_ARGC; - napi_value argv[DCN_INITIATE_KEY_TRANSFER_CALLBACK_ARGC]; - - if (carrier->result) { - NAPI_STATUS_THROWS(napi_create_string_utf8(env, carrier->result, NAPI_AUTO_LENGTH, &argv[0])); - } else { - NAPI_STATUS_THROWS(napi_get_null(env, &argv[0])); - } - - NAPI_ASYNC_CALL_AND_DELETE_CB(); - dc_str_unref(carrier->result); - free(carrier); -} - -NAPI_METHOD(dcn_initiate_key_transfer) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - - NAPI_ASYNC_NEW_CARRIER(dcn_initiate_key_transfer); - - NAPI_ASYNC_QUEUE_WORK(dcn_initiate_key_transfer, argv[1]); - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_is_configured) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - //TRACE("calling.."); - int result = dc_is_configured(dcn_context->dc_context); - //TRACE("result %d", result); - - NAPI_RETURN_INT32(result); -} - -NAPI_METHOD(dcn_is_contact_in_chat) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - NAPI_ARGV_UINT32(contact_id, 2); - - //TRACE("calling.."); - int result = dc_is_contact_in_chat(dcn_context->dc_context, - chat_id, contact_id); - //TRACE("result %d", result); - - NAPI_RETURN_INT32(result); -} - -NAPI_METHOD(dcn_lookup_contact_id_by_addr) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UTF8_MALLOC(addr, 1); - - //TRACE("calling.."); - uint32_t res = dc_lookup_contact_id_by_addr(dcn_context->dc_context, addr); - //TRACE("result %d", res); - - free(addr); - - NAPI_RETURN_UINT32(res); -} - -NAPI_METHOD(dcn_marknoticed_chat) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - - //TRACE("calling.."); - dc_marknoticed_chat(dcn_context->dc_context, chat_id); - //TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_download_full_msg) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(msg_id, 1); - - //TRACE("calling.."); - dc_download_full_msg(dcn_context->dc_context, msg_id); - //TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_markseen_msgs) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - napi_value js_array = argv[1]; - - //TRACE("calling.."); - uint32_t length; - uint32_t* msg_ids = js_array_to_uint32(env, js_array, &length); - dc_markseen_msgs(dcn_context->dc_context, msg_ids, length); - free(msg_ids); - //TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_maybe_network) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - //TRACE("calling.."); - dc_maybe_network(dcn_context->dc_context); - //TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_msg_new) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_INT32(viewtype, 1); - - //TRACE("calling.."); - napi_value result; - dc_msg_t* msg = dc_msg_new(dcn_context->dc_context, viewtype); - - NAPI_STATUS_THROWS(napi_create_external(env, msg, finalize_msg, - NULL, &result)); - //TRACE("done"); - - return result; -} - - -NAPI_METHOD(dcn_remove_contact_from_chat) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - NAPI_ARGV_UINT32(contact_id, 2); - - //TRACE("calling.."); - int result = dc_remove_contact_from_chat(dcn_context->dc_context, - chat_id, contact_id); - //TRACE("result %d", result); - - NAPI_RETURN_INT32(result); -} - -NAPI_METHOD(dcn_search_msgs) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - NAPI_ARGV_UTF8_MALLOC(query, 2); - - //TRACE("calling.."); - dc_array_t* msg_ids = dc_search_msgs(dcn_context->dc_context, - chat_id, query); - napi_value js_array = dc_array_to_js_array(env, msg_ids); - dc_array_unref(msg_ids); - free(query); - //TRACE("done"); - - return js_array; -} - -NAPI_METHOD(dcn_send_msg) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - - //TRACE("calling.."); - dc_msg_t* dc_msg = NULL; - napi_get_value_external(env, argv[2], (void**)&dc_msg); - - uint32_t msg_id = dc_send_msg(dcn_context->dc_context, chat_id, dc_msg); - //TRACE("done"); - - NAPI_RETURN_UINT32(msg_id); -} - -NAPI_ASYNC_CARRIER_BEGIN(dcn_send_videochat_invitation) - int chat_id; - int result; -NAPI_ASYNC_CARRIER_END(dcn_send_videochat_invitation) - -NAPI_ASYNC_EXECUTE(dcn_send_videochat_invitation) { - NAPI_ASYNC_GET_CARRIER(dcn_send_videochat_invitation) - carrier->result = dc_send_videochat_invitation( - carrier->dcn_context->dc_context, - carrier->chat_id - ); -} - -NAPI_ASYNC_COMPLETE(dcn_send_videochat_invitation) { - NAPI_ASYNC_GET_CARRIER(dcn_send_videochat_invitation) - if (status != napi_ok) { - napi_throw_type_error(env, NULL, "Execute callback failed."); - return; - } - -#define DCN_SEND_VIDEO_CHAT_CALLBACK_ARGC 1 - - const int argc = DCN_SEND_VIDEO_CHAT_CALLBACK_ARGC; - napi_value argv[DCN_SEND_VIDEO_CHAT_CALLBACK_ARGC]; - NAPI_STATUS_THROWS(napi_create_int32(env, carrier->result, &argv[0])); - - NAPI_ASYNC_CALL_AND_DELETE_CB() - free(carrier); -} - -NAPI_METHOD(dcn_send_videochat_invitation) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - NAPI_ASYNC_NEW_CARRIER(dcn_send_videochat_invitation); - carrier->chat_id = chat_id; - - NAPI_ASYNC_QUEUE_WORK(dcn_send_videochat_invitation, argv[2]); - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_set_chat_name) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - NAPI_ARGV_UTF8_MALLOC(name, 2); - - //TRACE("calling.."); - int result = dc_set_chat_name(dcn_context->dc_context, - chat_id, - name); - //TRACE("result %d", result); - - free(name); - - NAPI_RETURN_INT32(result); -} - -NAPI_METHOD(dcn_get_chat_ephemeral_timer) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - - uint32_t result = dc_get_chat_ephemeral_timer(dcn_context->dc_context, - chat_id); - NAPI_RETURN_UINT32(result); -} - -NAPI_METHOD(dcn_set_chat_ephemeral_timer) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - NAPI_ARGV_UINT32(timer, 2); - - int result = dc_set_chat_ephemeral_timer(dcn_context->dc_context, - chat_id, - timer); - NAPI_RETURN_INT32(result); -} - -NAPI_METHOD(dcn_set_chat_profile_image) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - NAPI_ARGV_UTF8_MALLOC(image, 2); - - //TRACE("calling.."); - int result = dc_set_chat_profile_image(dcn_context->dc_context, - chat_id, - image && image[0] ? image : NULL); - //TRACE("result %d", result); - - free(image); - - NAPI_RETURN_INT32(result); -} - -NAPI_METHOD(dcn_set_chat_mute_duration) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - NAPI_ARGV_INT32(duration, 2); - - //TRACE("calling.."); - int result = dc_set_chat_mute_duration(dcn_context->dc_context, - chat_id, - duration); - //TRACE("result %d", result); - - NAPI_RETURN_INT32(result); -} - -NAPI_METHOD(dcn_set_config) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UTF8_MALLOC(key, 1); - NAPI_ARGV_UTF8_MALLOC(value, 2); - - //TRACE("calling.."); - int status = dc_set_config(dcn_context->dc_context, key, value); - //TRACE("result %d", status); - - free(key); - free(value); - - NAPI_RETURN_INT32(status); -} - -NAPI_METHOD(dcn_set_config_null) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UTF8_MALLOC(key, 1); - - //TRACE("calling.."); - int status = dc_set_config(dcn_context->dc_context, key, NULL); - //TRACE("result %d", status); - - free(key); - - 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(); - NAPI_ARGV_INT32(from_server, 1); - NAPI_ARGV_INT32(seconds, 2); - - int result = dc_estimate_deletion_cnt (dcn_context->dc_context, from_server, seconds); - - NAPI_RETURN_INT32(result); -} - - -NAPI_METHOD(dcn_set_draft) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(chat_id, 1); - - //TRACE("calling.."); - dc_msg_t* dc_msg = NULL; - napi_get_value_external(env, argv[2], (void**)&dc_msg); - - dc_set_draft(dcn_context->dc_context, chat_id, dc_msg); - //TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_set_stock_translation) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(stock_id, 1); - NAPI_ARGV_UTF8_MALLOC(stock_msg, 2); - - int result = dc_set_stock_translation(dcn_context->dc_context, stock_id, stock_msg); - free(stock_msg); - NAPI_RETURN_INT32(result); -} - - -NAPI_METHOD(dcn_start_io) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - TRACE("calling.."); - TRACE("done"); - - dc_start_io(dcn_context->dc_context); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_stop_io) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - dc_stop_io(dcn_context->dc_context); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_stop_ongoing_process) { - NAPI_ARGV(1); - NAPI_DCN_CONTEXT(); - - //TRACE("calling.."); - dc_stop_ongoing_process(dcn_context->dc_context); - //TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - -/** - * dc_chat_t - */ - -NAPI_METHOD(dcn_chat_get_color) { - NAPI_ARGV(1); - NAPI_DC_CHAT(); - - //TRACE("calling.."); - uint32_t color = dc_chat_get_color(dc_chat); - //TRACE("result %d", color); - - NAPI_RETURN_UINT32(color); -} - -NAPI_METHOD(dcn_chat_get_visibility) { - NAPI_ARGV(1); - NAPI_DC_CHAT(); - - //TRACE("calling.."); - uint32_t visibility = dc_chat_get_visibility(dc_chat); - //TRACE("result %d", color); - - NAPI_RETURN_UINT32(visibility); -} - -NAPI_METHOD(dcn_chat_get_id) { - NAPI_ARGV(1); - NAPI_DC_CHAT(); - - //TRACE("calling.."); - uint32_t chat_id = dc_chat_get_id(dc_chat); - //TRACE("result %d", chat_id); - - NAPI_RETURN_UINT32(chat_id); -} - -NAPI_METHOD(dcn_chat_get_name) { - NAPI_ARGV(1); - NAPI_DC_CHAT(); - - //TRACE("calling.."); - char* name = dc_chat_get_name(dc_chat); - //TRACE("result %s", name); - - NAPI_RETURN_AND_UNREF_STRING(name); -} - -NAPI_METHOD(dcn_chat_get_mailinglist_addr) { - NAPI_ARGV(1); - NAPI_DC_CHAT(); - - //TRACE("calling.."); - char* addr = dc_chat_get_mailinglist_addr(dc_chat); - //TRACE("result %s", name); - - NAPI_RETURN_AND_UNREF_STRING(addr); -} - - -NAPI_METHOD(dcn_chat_get_profile_image) { - NAPI_ARGV(1); - NAPI_DC_CHAT(); - - //TRACE("calling.."); - char* profile_image = dc_chat_get_profile_image(dc_chat); - //TRACE("result %s", profile_image); - - NAPI_RETURN_AND_UNREF_STRING(profile_image); -} - -NAPI_METHOD(dcn_chat_get_type) { - NAPI_ARGV(1); - NAPI_DC_CHAT(); - - //TRACE("calling.."); - int type = dc_chat_get_type(dc_chat); - //TRACE("result %d", type); - - NAPI_RETURN_INT32(type); -} - -NAPI_METHOD(dcn_chat_is_self_talk) { - NAPI_ARGV(1); - NAPI_DC_CHAT(); - - //TRACE("calling.."); - int is_self_talk = dc_chat_is_self_talk(dc_chat); - //TRACE("result %d", is_self_talk); - - NAPI_RETURN_INT32(is_self_talk); -} - -NAPI_METHOD(dcn_chat_is_unpromoted) { - NAPI_ARGV(1); - NAPI_DC_CHAT(); - - //TRACE("calling.."); - int is_unpromoted = dc_chat_is_unpromoted(dc_chat); - //TRACE("result %d", is_unpromoted); - - NAPI_RETURN_INT32(is_unpromoted); -} - -NAPI_METHOD(dcn_chat_can_send) { - NAPI_ARGV(1); - NAPI_DC_CHAT(); - - //TRACE("calling.."); - int can_send = dc_chat_can_send(dc_chat); - //TRACE("result %d", can_send); - - NAPI_RETURN_INT32(can_send); -} - -NAPI_METHOD(dcn_chat_is_protected) { - NAPI_ARGV(1); - NAPI_DC_CHAT(); - - //TRACE("calling.."); - int is_protected = dc_chat_is_protected(dc_chat); - //TRACE("result %d", is_protected); - - NAPI_RETURN_INT32(is_protected); -} - -NAPI_METHOD(dcn_chat_is_device_talk) { - NAPI_ARGV(1); - NAPI_DC_CHAT(); - - //TRACE("calling.."); - int is_device_talk = dc_chat_is_device_talk(dc_chat); - //TRACE("result %d", is_device_talk); - - NAPI_RETURN_INT32(is_device_talk); -} - -NAPI_METHOD(dcn_chat_is_muted) { - NAPI_ARGV(1); - NAPI_DC_CHAT(); - - //TRACE("calling.."); - int is_muted = dc_chat_is_muted(dc_chat); - //TRACE("result %d", is_muted); - - NAPI_RETURN_INT32(is_muted); -} - -NAPI_METHOD(dcn_chat_is_contact_request) { - NAPI_ARGV(1); - NAPI_DC_CHAT(); - - //TRACE("calling.."); - int is_contact_request = dc_chat_is_contact_request(dc_chat); - //TRACE("result %d", is_muted); - - NAPI_RETURN_INT32(is_contact_request); -} - - - -/** - * dc_chatlist_t - */ - -NAPI_METHOD(dcn_chatlist_get_chat_id) { - NAPI_ARGV(2); - NAPI_DC_CHATLIST(); - NAPI_ARGV_INT32(index, 1); - - //TRACE("calling.."); - uint32_t chat_id = dc_chatlist_get_chat_id(dc_chatlist, index); - //TRACE("result %d", chat_id); - - NAPI_RETURN_UINT32(chat_id); -} - -NAPI_METHOD(dcn_chatlist_get_cnt) { - NAPI_ARGV(1); - NAPI_DC_CHATLIST(); - - //TRACE("calling.."); - int count = dc_chatlist_get_cnt(dc_chatlist); - //TRACE("result %d", count); - - NAPI_RETURN_INT32(count); -} - -NAPI_METHOD(dcn_chatlist_get_msg_id) { - NAPI_ARGV(2); - NAPI_DC_CHATLIST(); - NAPI_ARGV_INT32(index, 1); - - //TRACE("calling.."); - uint32_t message_id = dc_chatlist_get_msg_id(dc_chatlist, index); - //TRACE("result %d", message_id); - - NAPI_RETURN_UINT32(message_id); -} - -NAPI_METHOD(dcn_chatlist_get_summary) { - NAPI_ARGV(3); - NAPI_DC_CHATLIST(); - NAPI_ARGV_INT32(index, 1); - - //TRACE("calling.."); - dc_chat_t* dc_chat = NULL; - napi_get_value_external(env, argv[2], (void**)&dc_chat); - - dc_lot_t* summary = dc_chatlist_get_summary(dc_chatlist, index, dc_chat); - - napi_value result; - if (summary == NULL) { - NAPI_STATUS_THROWS(napi_get_null(env, &result)); - } else { - NAPI_STATUS_THROWS(napi_create_external(env, summary, - finalize_lot, - NULL, &result)); - } - //TRACE("done"); - - return result; -} - -NAPI_METHOD(dcn_chatlist_get_summary2) { - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_INT32(chat_id, 1); - NAPI_ARGV_INT32(message_id, 2); - - //TRACE("calling.."); - dc_lot_t* summary = dc_chatlist_get_summary2(dcn_context->dc_context, chat_id, message_id); - - napi_value result; - if (summary == NULL) { - NAPI_STATUS_THROWS(napi_get_null(env, &result)); - } else { - NAPI_STATUS_THROWS(napi_create_external(env, summary, - finalize_lot, - NULL, &result)); - } - //TRACE("done"); - - return result; -} - -/** - * dc_contact_t - */ - -NAPI_METHOD(dcn_contact_get_addr) { - NAPI_ARGV(1); - NAPI_DC_CONTACT(); - - //TRACE("calling.."); - char* addr = dc_contact_get_addr(dc_contact); - //TRACE("result %s", addr); - - NAPI_RETURN_AND_UNREF_STRING(addr); -} - -NAPI_METHOD(dcn_contact_get_auth_name) { - NAPI_ARGV(1); - NAPI_DC_CONTACT(); - - char* auth_name = dc_contact_get_auth_name(dc_contact); - - NAPI_RETURN_AND_UNREF_STRING(auth_name); -} - -NAPI_METHOD(dcn_contact_get_color) { - NAPI_ARGV(1); - NAPI_DC_CONTACT(); - - //TRACE("calling.."); - uint32_t color = dc_contact_get_color(dc_contact); - //TRACE("result %d", color); - - NAPI_RETURN_UINT32(color); -} - -NAPI_METHOD(dcn_contact_get_display_name) { - NAPI_ARGV(1); - NAPI_DC_CONTACT(); - - //TRACE("calling.."); - char* display_name = dc_contact_get_display_name(dc_contact); - //TRACE("result %s", display_name); - - NAPI_RETURN_AND_UNREF_STRING(display_name); -} - -NAPI_METHOD(dcn_contact_get_id) { - NAPI_ARGV(1); - NAPI_DC_CONTACT(); - - //TRACE("calling.."); - uint32_t contact_id = dc_contact_get_id(dc_contact); - //TRACE("result %d", contact_id); - - NAPI_RETURN_UINT32(contact_id); -} - -NAPI_METHOD(dcn_contact_get_name) { - NAPI_ARGV(1); - NAPI_DC_CONTACT(); - - //TRACE("calling.."); - char* name = dc_contact_get_name(dc_contact); - //TRACE("result %s", name); - - NAPI_RETURN_AND_UNREF_STRING(name); -} - -NAPI_METHOD(dcn_contact_get_name_n_addr) { - NAPI_ARGV(1); - NAPI_DC_CONTACT(); - - //TRACE("calling.."); - char* name_n_addr = dc_contact_get_name_n_addr(dc_contact); - //TRACE("result %s", name_n_addr); - - NAPI_RETURN_AND_UNREF_STRING(name_n_addr); -} - -NAPI_METHOD(dcn_contact_get_profile_image) { - NAPI_ARGV(1); - NAPI_DC_CONTACT(); - - //TRACE("calling.."); - char* profile_image = dc_contact_get_profile_image(dc_contact); - //TRACE("result %s", profile_image); - - NAPI_RETURN_AND_UNREF_STRING(profile_image); -} - -NAPI_METHOD(dcn_contact_get_status) { - NAPI_ARGV(1); - NAPI_DC_CONTACT(); - char* status = dc_contact_get_status(dc_contact); - NAPI_RETURN_AND_UNREF_STRING(status); -} - -NAPI_METHOD(dcn_contact_get_last_seen) { - NAPI_ARGV(1); - NAPI_DC_CONTACT(); - int64_t timestamp = dc_contact_get_last_seen(dc_contact); - NAPI_RETURN_INT64(timestamp); -} - -NAPI_METHOD(dcn_contact_was_seen_recently) { - NAPI_ARGV(1); - NAPI_DC_CONTACT(); - int seen_recently = dc_contact_was_seen_recently(dc_contact); - NAPI_RETURN_UINT32(seen_recently); -} - -NAPI_METHOD(dcn_contact_is_blocked) { - NAPI_ARGV(1); - NAPI_DC_CONTACT(); - - //TRACE("calling.."); - int is_blocked = dc_contact_is_blocked(dc_contact); - //TRACE("result %d", is_blocked); - - NAPI_RETURN_UINT32(is_blocked); -} - -NAPI_METHOD(dcn_contact_is_verified) { - NAPI_ARGV(1); - NAPI_DC_CONTACT(); - - //TRACE("calling.."); - int is_verified = dc_contact_is_verified(dc_contact); - //TRACE("result %d", is_verified); - - NAPI_RETURN_UINT32(is_verified); -} - -/** - * dc_lot_t - */ - -NAPI_METHOD(dcn_lot_get_id) { - NAPI_ARGV(1); - NAPI_DC_LOT(); - - //TRACE("calling.."); - uint32_t id = dc_lot_get_id(dc_lot); - //TRACE("result %d", id); - - NAPI_RETURN_UINT32(id); -} - -NAPI_METHOD(dcn_lot_get_state) { - NAPI_ARGV(1); - NAPI_DC_LOT(); - - //TRACE("calling.."); - int state = dc_lot_get_state(dc_lot); - //TRACE("result %d", state); - - NAPI_RETURN_INT32(state); -} - -NAPI_METHOD(dcn_lot_get_text1) { - NAPI_ARGV(1); - NAPI_DC_LOT(); - - //TRACE("calling.."); - char* text1 = dc_lot_get_text1(dc_lot); - //TRACE("result %s", text1); - - NAPI_RETURN_AND_UNREF_STRING(text1); -} - -NAPI_METHOD(dcn_lot_get_text1_meaning) { - NAPI_ARGV(1); - NAPI_DC_LOT(); - - //TRACE("calling.."); - int text1_meaning = dc_lot_get_text1_meaning(dc_lot); - //TRACE("result %d", text1_meaning); - - NAPI_RETURN_INT32(text1_meaning); -} - -NAPI_METHOD(dcn_lot_get_text2) { - NAPI_ARGV(1); - NAPI_DC_LOT(); - - //TRACE("calling.."); - char* text2 = dc_lot_get_text2(dc_lot); - //TRACE("result %s", text2); - - NAPI_RETURN_AND_UNREF_STRING(text2); -} - -NAPI_METHOD(dcn_lot_get_timestamp) { - NAPI_ARGV(1); - NAPI_DC_LOT(); - - //TRACE("calling.."); - int timestamp = dc_lot_get_timestamp(dc_lot); - //TRACE("result %d", timestamp); - - NAPI_RETURN_INT32(timestamp); -} - -/** - * dc_msg_t - */ - -NAPI_METHOD(dcn_msg_get_parent) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - napi_value result; - dc_msg_t* msg = dc_msg_get_parent(dc_msg); - - if (msg == NULL) { - NAPI_STATUS_THROWS(napi_get_null(env, &result)); - } else { - NAPI_STATUS_THROWS(napi_create_external(env, msg, finalize_msg, - NULL, &result)); - } - - return result; -} - -NAPI_METHOD(dcn_msg_get_download_state) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - uint32_t download_state = dc_msg_get_download_state(dc_msg); - //TRACE("result %d", download_state); - - NAPI_RETURN_UINT32(download_state); -} - -NAPI_METHOD(dcn_msg_get_chat_id) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - uint32_t chat_id = dc_msg_get_chat_id(dc_msg); - //TRACE("result %d", chat_id); - - NAPI_RETURN_UINT32(chat_id); -} - -NAPI_METHOD(dcn_msg_get_duration) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int duration = dc_msg_get_duration(dc_msg); - //TRACE("result %d", duration); - - NAPI_RETURN_INT32(duration); -} - -NAPI_METHOD(dcn_msg_get_file) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - char* file = dc_msg_get_file(dc_msg); - //TRACE("result %s", file); - - NAPI_RETURN_AND_UNREF_STRING(file); -} - -NAPI_METHOD(dcn_msg_get_filebytes) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - uint32_t filebytes = dc_msg_get_filebytes(dc_msg); - //TRACE("result %d", filebytes); - - NAPI_RETURN_INT32(filebytes); -} - -NAPI_METHOD(dcn_msg_get_filemime) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - char* filemime = dc_msg_get_filemime(dc_msg); - //TRACE("result %s", filemime); - - NAPI_RETURN_AND_UNREF_STRING(filemime); -} - -NAPI_METHOD(dcn_msg_get_filename) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - char* filename = dc_msg_get_filename(dc_msg); - //TRACE("result %s", filename); - - NAPI_RETURN_AND_UNREF_STRING(filename); -} - -NAPI_METHOD(dcn_msg_get_from_id) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - uint32_t contact_id = dc_msg_get_from_id(dc_msg); - //TRACE("result %d", contact_id); - - NAPI_RETURN_UINT32(contact_id); -} - -NAPI_METHOD(dcn_msg_get_height) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int height = dc_msg_get_height(dc_msg); - //TRACE("result %d", height); - - NAPI_RETURN_INT32(height); -} - -NAPI_METHOD(dcn_msg_get_id) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - uint32_t msg_id = dc_msg_get_id(dc_msg); - //TRACE("result %d", msg_id); - - NAPI_RETURN_UINT32(msg_id); -} - -NAPI_METHOD(dcn_msg_get_override_sender_name) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - char* override_sender_name = dc_msg_get_override_sender_name(dc_msg); - //TRACE("result %s", override_sender_name); - - NAPI_RETURN_AND_UNREF_STRING(override_sender_name); -} - -NAPI_METHOD(dcn_msg_get_quoted_text) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - char* text = dc_msg_get_quoted_text(dc_msg); - //TRACE("result %s", text); - - NAPI_RETURN_AND_UNREF_STRING(text); -} - -NAPI_METHOD(dcn_msg_get_quoted_msg) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - napi_value result; - dc_msg_t* msg = dc_msg_get_quoted_msg(dc_msg); - - if (msg == NULL) { - NAPI_STATUS_THROWS(napi_get_null(env, &result)); - } else { - NAPI_STATUS_THROWS(napi_create_external(env, msg, finalize_msg, - NULL, &result)); - } - - return result; -} - -NAPI_METHOD(dcn_msg_get_received_timestamp) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int timestamp = dc_msg_get_received_timestamp(dc_msg); - //TRACE("result %d", timestamp); - - NAPI_RETURN_INT32(timestamp); -} - - -NAPI_METHOD(dcn_msg_get_setupcodebegin) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - char* setupcodebegin = dc_msg_get_setupcodebegin(dc_msg); - //TRACE("result %s", setupcodebegin); - - NAPI_RETURN_AND_UNREF_STRING(setupcodebegin); -} - -NAPI_METHOD(dcn_msg_get_showpadlock) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int showpadlock = dc_msg_get_showpadlock(dc_msg); - //TRACE("result %d", showpadlock); - - NAPI_RETURN_INT32(showpadlock); -} - -NAPI_METHOD(dcn_msg_get_sort_timestamp) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int timestamp = dc_msg_get_sort_timestamp(dc_msg); - //TRACE("result %d", timestamp); - - NAPI_RETURN_INT32(timestamp); -} - -NAPI_METHOD(dcn_msg_get_state) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int state = dc_msg_get_state(dc_msg); - //TRACE("result %d", state); - - NAPI_RETURN_INT32(state); -} - -NAPI_METHOD(dcn_msg_get_summary) { - NAPI_ARGV(2); - NAPI_DC_MSG(); - - //TRACE("calling.."); - dc_chat_t* dc_chat = NULL; - napi_get_value_external(env, argv[1], (void**)&dc_chat); - - dc_lot_t* summary = dc_msg_get_summary(dc_msg, dc_chat); - - napi_value result; - NAPI_STATUS_THROWS(napi_create_external(env, summary, - finalize_lot, - NULL, &result)); - //TRACE("done"); - - return result; -} - -NAPI_METHOD(dcn_msg_get_summarytext) { - NAPI_ARGV(2); - NAPI_DC_MSG(); - NAPI_ARGV_INT32(approx_characters, 1); - - //TRACE("calling.."); - char* summarytext = dc_msg_get_summarytext(dc_msg, approx_characters); - //TRACE("result %s", summarytext); - - NAPI_RETURN_AND_UNREF_STRING(summarytext); -} - -NAPI_METHOD(dcn_msg_get_subject) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - char* subject = dc_msg_get_subject(dc_msg); - //TRACE("result %s", subject); - - NAPI_RETURN_AND_UNREF_STRING(subject); -} - -NAPI_METHOD(dcn_msg_get_text) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - char* text = dc_msg_get_text(dc_msg); - //TRACE("result %s", text); - - NAPI_RETURN_AND_UNREF_STRING(text); -} - -NAPI_METHOD(dcn_msg_get_timestamp) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int timestamp = dc_msg_get_timestamp(dc_msg); - //TRACE("result %d", timestamp); - - NAPI_RETURN_INT32(timestamp); -} - -NAPI_METHOD(dcn_msg_get_viewtype) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int type = dc_msg_get_viewtype(dc_msg); - //TRACE("result %d", type); - - NAPI_RETURN_INT32(type); -} - -NAPI_METHOD(dcn_msg_get_videochat_type) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - int type = dc_msg_get_videochat_type(dc_msg); - NAPI_RETURN_INT32(type); -} - -NAPI_METHOD(dcn_msg_get_videochat_url) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - char* url = dc_msg_get_videochat_url(dc_msg); - NAPI_RETURN_AND_UNREF_STRING(url); -} - -NAPI_METHOD(dcn_msg_get_width) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int width = dc_msg_get_width(dc_msg); - //TRACE("result %d", width); - - NAPI_RETURN_INT32(width); -} - -NAPI_METHOD(dcn_msg_get_webxdc_info){ - NAPI_ARGV(1); - NAPI_DC_MSG(); - - char* result_json = dc_msg_get_webxdc_info(dc_msg); - - NAPI_RETURN_AND_UNREF_STRING(result_json); -} - -NAPI_METHOD(dcn_msg_has_deviating_timestamp) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int has_deviating_timestamp = dc_msg_has_deviating_timestamp(dc_msg); - //TRACE("result %d", has_deviating_timestamp); - - NAPI_RETURN_INT32(has_deviating_timestamp); -} - -NAPI_METHOD(dcn_msg_has_location) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int has_location = dc_msg_has_location(dc_msg); - //TRACE("result %d", has_location); - - NAPI_RETURN_INT32(has_location); -} - -NAPI_METHOD(dcn_msg_has_html) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int has_html = dc_msg_has_html(dc_msg); - //TRACE("result %d", has_html); - - NAPI_RETURN_INT32(has_html); -} - -NAPI_METHOD(dcn_msg_is_forwarded) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int is_forwarded = dc_msg_is_forwarded(dc_msg); - //TRACE("result %d", is_forwarded); - - NAPI_RETURN_INT32(is_forwarded); -} - -NAPI_METHOD(dcn_msg_is_info) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int is_info = dc_msg_is_info(dc_msg); - //TRACE("result %d", is_info); - - NAPI_RETURN_INT32(is_info); -} - -NAPI_METHOD(dcn_msg_is_sent) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int is_sent = dc_msg_is_sent(dc_msg); - //TRACE("result %d", is_sent); - - NAPI_RETURN_INT32(is_sent); -} - -NAPI_METHOD(dcn_msg_is_setupmessage) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - - //TRACE("calling.."); - int is_setupmessage = dc_msg_is_setupmessage(dc_msg); - //TRACE("result %d", is_setupmessage); - - NAPI_RETURN_INT32(is_setupmessage); -} - -NAPI_METHOD(dcn_msg_latefiling_mediasize) { - NAPI_ARGV(4); - NAPI_DC_MSG(); - NAPI_ARGV_INT32(width, 1); - NAPI_ARGV_INT32(height, 2); - NAPI_ARGV_INT32(duration, 3); - - //TRACE("calling.."); - dc_msg_latefiling_mediasize(dc_msg, width, height, duration); - //TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - - -NAPI_METHOD(dcn_msg_force_plaintext) { - NAPI_ARGV(1); - NAPI_DC_MSG(); - dc_msg_force_plaintext(dc_msg); - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_msg_set_dimension) { - NAPI_ARGV(3); - NAPI_DC_MSG(); - NAPI_ARGV_INT32(width, 1); - NAPI_ARGV_INT32(height, 2); - - //TRACE("calling.."); - dc_msg_set_dimension(dc_msg, width, height); - //TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_msg_set_duration) { - NAPI_ARGV(2); - NAPI_DC_MSG(); - NAPI_ARGV_INT32(duration, 1); - - //TRACE("calling.."); - dc_msg_set_duration(dc_msg, duration); - //TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_msg_set_override_sender_name) { - NAPI_ARGV(2); - NAPI_DC_MSG(); - NAPI_ARGV_UTF8_MALLOC(override_sender_name, 1); - - //TRACE("calling.."); - dc_msg_set_override_sender_name(dc_msg, override_sender_name); - //TRACE("done"); - - free(override_sender_name); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_msg_set_file) { - NAPI_ARGV(3); - NAPI_DC_MSG(); - NAPI_ARGV_UTF8_MALLOC(file, 1); - NAPI_ARGV_UTF8_MALLOC(filemime, 2); - - //TRACE("calling.."); - dc_msg_set_file(dc_msg, file, filemime && filemime[0] ? filemime : NULL); - //TRACE("done"); - - free(file); - free(filemime); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_msg_set_html) { - NAPI_ARGV(2); - NAPI_DC_MSG(); - NAPI_ARGV_UTF8_MALLOC(html, 1); - - //TRACE("calling.."); - dc_msg_set_html(dc_msg, html); - //TRACE("done"); - - free(html); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_msg_set_quote) { - NAPI_ARGV(2); - NAPI_ARGV_DC_MSG(dc_msg, 0) - - dc_msg_t* dc_msg_quote = NULL; - napi_get_value_external(env, argv[1], (void**)&dc_msg_quote); - - dc_msg_set_quote(dc_msg, dc_msg_quote); - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_msg_set_text) { - NAPI_ARGV(2); - NAPI_DC_MSG(); - NAPI_ARGV_UTF8_MALLOC(text, 1); - - //TRACE("calling.."); - dc_msg_set_text(dc_msg, text); - //TRACE("done"); - - free(text); - - NAPI_RETURN_UNDEFINED(); -} - -/** - * locations - */ - -NAPI_METHOD(dcn_msg_set_location) { - NAPI_ARGV(3); - NAPI_DC_MSG(); - NAPI_ARGV_DOUBLE(latitude, 1); - NAPI_ARGV_DOUBLE(longitude, 2); - - //TRACE("calling.."); - dc_msg_set_location(dc_msg, latitude, longitude); - //TRACE("done"); - - NAPI_RETURN_UNDEFINED(); -} - -/** - * locations - */ - -NAPI_METHOD(dcn_set_location) { - NAPI_ARGV(4); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_DOUBLE(latitude, 1); - NAPI_ARGV_DOUBLE(longitude, 2); - NAPI_ARGV_DOUBLE(accuracy, 3); - - //TRACE("calling.."); - int result = dc_set_location(dcn_context->dc_context, latitude, longitude, accuracy); - //TRACE("result %d", result); - - NAPI_RETURN_INT32(result); -} - -NAPI_METHOD(dcn_get_locations) { - NAPI_ARGV(5); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_INT32(chat_id, 1); - NAPI_ARGV_INT32(contact_id, 2); - NAPI_ARGV_INT32(timestamp_from, 3); - NAPI_ARGV_INT32(timestamp_to, 4); - - //TRACE("calling.."); - dc_array_t* locations = dc_get_locations(dcn_context->dc_context, - chat_id, - contact_id, - timestamp_from, - timestamp_to); - - napi_value napi_locations; - NAPI_STATUS_THROWS(napi_create_external(env, locations, - finalize_array, - NULL, &napi_locations)); - //TRACE("done"); - - return napi_locations; -} - -NAPI_METHOD(dcn_array_get_cnt) { - NAPI_ARGV(1); - NAPI_DC_ARRAY(); - - //TRACE("calling.."); - uint32_t size = dc_array_get_cnt(dc_array); - - napi_value napi_size; - NAPI_STATUS_THROWS(napi_create_uint32(env, size, &napi_size)); - //TRACE("done"); - - return napi_size; -} - -NAPI_METHOD(dcn_array_get_id) { - NAPI_ARGV(2); - NAPI_DC_ARRAY(); - - //TRACE("calling.."); - uint32_t index; - NAPI_STATUS_THROWS(napi_get_value_uint32(env, argv[1], &index)); - - uint32_t id = dc_array_get_id(dc_array, index); - - napi_value napi_id; - NAPI_STATUS_THROWS(napi_create_uint32(env, id, &napi_id)); - //TRACE("done"); - - return napi_id; -} - -NAPI_METHOD(dcn_array_get_accuracy) { - NAPI_ARGV(2); - NAPI_DC_ARRAY(); - - //TRACE("calling.."); - uint32_t index; - NAPI_STATUS_THROWS(napi_get_value_uint32(env, argv[1], &index)); - - double accuracy = dc_array_get_accuracy(dc_array, index); - - napi_value napi_accuracy; - NAPI_STATUS_THROWS(napi_create_double(env, accuracy, &napi_accuracy)); - //TRACE("done"); - - return napi_accuracy; -} - -NAPI_METHOD(dcn_array_get_longitude) { - NAPI_ARGV(2); - NAPI_DC_ARRAY(); - - //TRACE("calling.."); - uint32_t index; - NAPI_STATUS_THROWS(napi_get_value_uint32(env, argv[1], &index)); - - double longitude = dc_array_get_longitude(dc_array, index); - - napi_value napi_longitude; - NAPI_STATUS_THROWS(napi_create_double(env, longitude, &napi_longitude)); - //TRACE("done"); - - return napi_longitude; -} - -NAPI_METHOD(dcn_array_get_latitude) { - NAPI_ARGV(2); - NAPI_DC_ARRAY(); - - //TRACE("calling.."); - uint32_t index; - NAPI_STATUS_THROWS(napi_get_value_uint32(env, argv[1], &index)); - - double latitude = dc_array_get_latitude(dc_array, index); - - napi_value napi_latitude; - NAPI_STATUS_THROWS(napi_create_double(env, latitude, &napi_latitude)); - //TRACE("done"); - - return napi_latitude; -} - -NAPI_METHOD(dcn_array_get_timestamp) { - NAPI_ARGV(2); - NAPI_DC_ARRAY(); - - //TRACE("calling.."); - uint32_t index; - NAPI_STATUS_THROWS(napi_get_value_uint32(env, argv[1], &index)); - - int timestamp = dc_array_get_timestamp(dc_array, index); - - napi_value napi_timestamp; - NAPI_STATUS_THROWS(napi_create_int64(env, timestamp, &napi_timestamp)); - //TRACE("done"); - - return napi_timestamp; -} - -NAPI_METHOD(dcn_array_get_msg_id) { - NAPI_ARGV(2); - NAPI_DC_ARRAY(); - - //TRACE("calling.."); - uint32_t index; - NAPI_STATUS_THROWS(napi_get_value_uint32(env, argv[1], &index)); - - uint32_t msg_id = dc_array_get_msg_id(dc_array, index); - - napi_value napi_msg_id; - NAPI_STATUS_THROWS(napi_create_uint32(env, msg_id, &napi_msg_id)); - //TRACE("done"); - - return napi_msg_id; -} - -NAPI_METHOD(dcn_array_is_independent) { - NAPI_ARGV(2); - NAPI_DC_ARRAY(); - - //TRACE("calling.."); - uint32_t index; - NAPI_STATUS_THROWS(napi_get_value_uint32(env, argv[1], &index)); - - int result = dc_array_is_independent(dc_array, index); - //TRACE("result %d", result); - - NAPI_RETURN_INT32(result); -} - -NAPI_METHOD(dcn_array_get_marker) { - NAPI_ARGV(2); - NAPI_DC_ARRAY(); - - //TRACE("calling.."); - uint32_t index; - NAPI_STATUS_THROWS(napi_get_value_uint32(env, argv[1], &index)); - - char* marker = dc_array_get_marker(dc_array, index); - //TRACE("result %s", marker); - - NAPI_RETURN_AND_UNREF_STRING(marker); -} - -NAPI_METHOD(dcn_array_get_contact_id) { - NAPI_ARGV(2); - NAPI_DC_ARRAY(); - - //TRACE("calling.."); - uint32_t index; - NAPI_STATUS_THROWS(napi_get_value_uint32(env, argv[1], &index)); - - uint32_t contact_id = dc_array_get_contact_id(dc_array, index); - - napi_value napi_contact_id; - NAPI_STATUS_THROWS(napi_create_uint32(env, contact_id, &napi_contact_id)); - //TRACE("done"); - - return napi_contact_id; -} - -NAPI_METHOD(dcn_array_get_chat_id) { - NAPI_ARGV(2); - NAPI_DC_ARRAY(); - - //TRACE("calling.."); - uint32_t index; - NAPI_STATUS_THROWS(napi_get_value_uint32(env, argv[1], &index)); - - uint32_t chat_id = dc_array_get_chat_id(dc_array, index); - - napi_value napi_chat_id; - NAPI_STATUS_THROWS(napi_create_uint32(env, chat_id, &napi_chat_id)); - //TRACE("done"); - - return napi_chat_id; -} - -NAPI_METHOD(dcn_provider_new_from_email) { - NAPI_ARGV(2); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UTF8_MALLOC(email, 1) - - //TRACE("calling.."); - napi_value result; - dc_provider_t* provider = dc_provider_new_from_email(dcn_context->dc_context, email); - - if (provider == NULL) { - NAPI_STATUS_THROWS(napi_get_null(env, &result)); - } else { - NAPI_STATUS_THROWS(napi_create_external(env, provider, finalize_provider, - NULL, &result)); - } - //TRACE("done"); - - return result; -} - -NAPI_METHOD(dcn_provider_get_overview_page) { - NAPI_ARGV(1); - NAPI_DC_PROVIDER(); - - //TRACE("calling.."); - char* overview_page = dc_provider_get_overview_page(dc_provider); - //TRACE("result %s", overview_page); - - NAPI_RETURN_AND_UNREF_STRING(overview_page); -} - -NAPI_METHOD(dcn_provider_get_before_login_hint) { - NAPI_ARGV(1); - NAPI_DC_PROVIDER(); - - //TRACE("calling.."); - char* before_login_hint = dc_provider_get_before_login_hint(dc_provider); - //TRACE("result %s", before_login_hint); - - NAPI_RETURN_AND_UNREF_STRING(before_login_hint); -} - -NAPI_METHOD(dcn_provider_get_status) { - NAPI_ARGV(1); - NAPI_DC_PROVIDER(); - - //TRACE("calling.."); - int status = dc_provider_get_status(dc_provider); - //TRACE("result %s", status); - - NAPI_RETURN_INT32(status) -} - -// webxdc - -NAPI_METHOD(dcn_send_webxdc_status_update){ - NAPI_ARGV(4); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(msg_id, 1); - NAPI_ARGV_UTF8_MALLOC(json, 2); - NAPI_ARGV_UTF8_MALLOC(descr, 3); - - int result = dc_send_webxdc_status_update(dcn_context->dc_context, msg_id, json, descr); - free(json); - free(descr); - - NAPI_RETURN_UINT32(result); -} - -NAPI_METHOD(dcn_get_webxdc_status_updates){ - NAPI_ARGV(3); - NAPI_DCN_CONTEXT(); - NAPI_ARGV_UINT32(msg_id, 1); - NAPI_ARGV_UINT32(serial, 2); - - char* result_json = dc_get_webxdc_status_updates(dcn_context->dc_context, msg_id, serial); - - NAPI_RETURN_AND_UNREF_STRING(result_json); -} - -NAPI_METHOD(dcn_msg_get_webxdc_blob){ - NAPI_ARGV(2); - NAPI_DC_MSG(); - NAPI_ARGV_UTF8_MALLOC(filename, 1); - - size_t size; - char* data = dc_msg_get_webxdc_blob(dc_msg, filename, &size); - free(filename); - - napi_value jsbuffer; - if (data == NULL) { - NAPI_STATUS_THROWS(napi_get_null(env, &jsbuffer)); - } else { - // https://nodejs.org/api/n-api.html#napi_create_buffer_copy - NAPI_STATUS_THROWS(napi_create_buffer_copy(env, - size, - data, - NULL, - &jsbuffer)) - dc_str_unref(data); - } - - return jsbuffer; -} - - -// dc_accounts_* - -NAPI_METHOD(dcn_accounts_new) { - NAPI_ARGV(2); - NAPI_ARGV_UTF8_MALLOC(dir, 0); - NAPI_ARGV_INT32(writable, 1); - TRACE("calling.."); - - dcn_accounts_t* dcn_accounts = calloc(1, sizeof(dcn_accounts_t)); - if (dcn_accounts == NULL) { - napi_throw_error(env, NULL, "dcn_accounts is null"); \ - } - - - dcn_accounts->dc_accounts = dc_accounts_new(dir, writable); - - napi_value result; - NAPI_STATUS_THROWS(napi_create_external(env, dcn_accounts, - NULL, NULL, &result)); - return result; -} - - -NAPI_METHOD(dcn_accounts_unref) { - NAPI_ARGV(1); - NAPI_DCN_ACCOUNTS(); - - - TRACE("Unrefing dc_accounts"); - dcn_accounts->gc = 1; - if (dcn_accounts->event_handler_thread != 0) { - dc_accounts_stop_io(dcn_accounts->dc_accounts); - uv_thread_join(&dcn_accounts->event_handler_thread); - dcn_accounts->event_handler_thread = 0; - } - if (dcn_accounts->jsonrpc_instance) { - dc_jsonrpc_request(dcn_accounts->jsonrpc_instance, "{}"); - uv_thread_join(&dcn_accounts->jsonrpc_thread); - dc_jsonrpc_unref(dcn_accounts->jsonrpc_instance); - dcn_accounts->jsonrpc_instance = NULL; - } - dc_accounts_unref(dcn_accounts->dc_accounts); - dcn_accounts->dc_accounts = NULL; - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_accounts_add_account) { - NAPI_ARGV(1); - NAPI_DCN_ACCOUNTS(); - - int account_id = dc_accounts_add_account(dcn_accounts->dc_accounts); - - NAPI_RETURN_UINT32(account_id); -} - -NAPI_METHOD(dcn_accounts_add_closed_account) { - NAPI_ARGV(1); - NAPI_DCN_ACCOUNTS(); - - int account_id = dc_accounts_add_closed_account(dcn_accounts->dc_accounts); - - NAPI_RETURN_UINT32(account_id); -} - - -NAPI_METHOD(dcn_accounts_migrate_account) { - NAPI_ARGV(2); - NAPI_DCN_ACCOUNTS(); - NAPI_ARGV_UTF8_MALLOC(dbfile, 1); - - uint32_t account_id = dc_accounts_migrate_account(dcn_accounts->dc_accounts, dbfile); - - NAPI_RETURN_UINT32(account_id); -} - -NAPI_METHOD(dcn_accounts_remove_account) { - NAPI_ARGV(2); - NAPI_DCN_ACCOUNTS(); - NAPI_ARGV_UINT32(account_id, 1); - - int result = dc_accounts_remove_account(dcn_accounts->dc_accounts, account_id); - - NAPI_RETURN_INT32(result); -} - -NAPI_METHOD(dcn_accounts_get_all) { - NAPI_ARGV(1); - NAPI_DCN_ACCOUNTS(); - - dc_array_t* accounts = dc_accounts_get_all(dcn_accounts->dc_accounts); - napi_value js_array = dc_array_to_js_array(env, accounts); - dc_array_unref(accounts); - - return js_array; -} - -NAPI_METHOD(dcn_accounts_get_account) { - NAPI_ARGV(2); - NAPI_DCN_ACCOUNTS(); - NAPI_ARGV_UINT32(account_id, 1); - - dc_context_t* account_context = dc_accounts_get_account(dcn_accounts->dc_accounts, account_id); - - - napi_value result; - if (account_context == NULL) { - NAPI_STATUS_THROWS(napi_get_null(env, &result)); - } else { - dcn_context_t* dcn_context = calloc(1, sizeof(dcn_context_t)); - dcn_context->dc_context = account_context; - - NAPI_STATUS_THROWS(napi_create_external(env, dcn_context, - NULL, NULL, &result)); - } - - return result; -} - -NAPI_METHOD(dcn_accounts_get_selected_account) { - NAPI_ARGV(1); - NAPI_DCN_ACCOUNTS(); - - dc_context_t* account_context = dc_accounts_get_selected_account(dcn_accounts->dc_accounts); - - - napi_value result; - if (account_context == NULL) { - NAPI_STATUS_THROWS(napi_get_null(env, &result)); - } else { - dcn_context_t* dcn_context = calloc(1, sizeof(dcn_context_t)); - dcn_context->dc_context = account_context; - - NAPI_STATUS_THROWS(napi_create_external(env, dcn_context, - NULL, NULL, &result)); - } - - return result; -} - -NAPI_METHOD(dcn_accounts_select_account) { - NAPI_ARGV(2); - NAPI_DCN_ACCOUNTS(); - NAPI_ARGV_UINT32(account_id, 1); - - int result = dc_accounts_select_account(dcn_accounts->dc_accounts, account_id); - NAPI_RETURN_UINT32(result); -} - -NAPI_METHOD(dcn_accounts_start_io) { - NAPI_ARGV(1); - NAPI_DCN_ACCOUNTS(); - TRACE("calling..."); - dc_accounts_start_io(dcn_accounts->dc_accounts); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_accounts_stop_io) { - NAPI_ARGV(1); - NAPI_DCN_ACCOUNTS(); - - dc_accounts_stop_io(dcn_accounts->dc_accounts); - - NAPI_RETURN_UNDEFINED(); -} - - -NAPI_METHOD(dcn_accounts_maybe_network) { - NAPI_ARGV(1); - NAPI_DCN_ACCOUNTS(); - - dc_accounts_maybe_network(dcn_accounts->dc_accounts); - - NAPI_RETURN_UNDEFINED(); -} - - -NAPI_METHOD(dcn_accounts_maybe_network_lost) { - NAPI_ARGV(1); - NAPI_DCN_ACCOUNTS(); - - dc_accounts_maybe_network_lost(dcn_accounts->dc_accounts); - - NAPI_RETURN_UNDEFINED(); -} - -static void accounts_event_handler_thread_func(void* arg) -{ - dcn_accounts_t* dcn_accounts = (dcn_accounts_t*)arg; - - TRACE("event_handler_thread_func starting"); - - dc_event_emitter_t * dc_event_emitter = dc_accounts_get_event_emitter(dcn_accounts->dc_accounts); - dc_event_t* event; - while (true) { - if (dc_event_emitter == NULL) { - TRACE("event emitter is null, bailing"); - break; - } - event = dc_get_next_event(dc_event_emitter); - if (event == NULL) { - TRACE("no more events"); - break; - } - - if (!dcn_accounts->threadsafe_event_handler) { - TRACE("threadsafe_event_handler not set, bailing"); - break; - } - - // Don't process events if we're being garbage collected! - if (dcn_accounts->gc == 1) { - TRACE("dc_accounts has been destroyed, bailing"); - break; - } - - - napi_status status = napi_call_threadsafe_function(dcn_accounts->threadsafe_event_handler, event, napi_tsfn_blocking); - - if (status == napi_closing) { - TRACE("JS function got released, bailing"); - break; - } - } - - dc_event_emitter_unref(dc_event_emitter); - - TRACE("event_handler_thread_func ended"); - - napi_release_threadsafe_function(dcn_accounts->threadsafe_event_handler, napi_tsfn_release); -} - -static void call_accounts_js_event_handler(napi_env env, napi_value js_callback, void* _context, void* data) -{ - dc_event_t* dc_event = (dc_event_t*)data; - - napi_value global; - napi_status status = napi_get_global(env, &global); - - if (status != napi_ok) { - napi_throw_error(env, NULL, "Unable to get global"); - } - - -#define CALL_JS_CALLBACK_ACCOUNTS_ARGC 4 - - const int argc = CALL_JS_CALLBACK_ACCOUNTS_ARGC; - napi_value argv[CALL_JS_CALLBACK_ACCOUNTS_ARGC]; - - const int event_id = dc_event_get_id(dc_event); - - status = napi_create_uint32(env, event_id, &argv[0]); - if (status != napi_ok) { - napi_throw_error(env, NULL, "Unable to create argv[0] for event_handler arguments"); - } - - const int account_id = dc_event_get_account_id(dc_event); - status = napi_create_uint32(env, account_id, &argv[1]); - if (status != napi_ok) { - napi_throw_error(env, NULL, "Unable to create argv[1] for event_handler arguments"); - } - - - status = napi_create_int32(env, dc_event_get_data1_int(dc_event), &argv[2]); - if (status != napi_ok) { - napi_throw_error(env, NULL, "Unable to create argv[2] for event_handler arguments"); - } - - if DC_EVENT_DATA2_IS_STRING(event_id) { - char* data2_string = dc_event_get_data2_str(dc_event); - // Quick fix for https://github.com/deltachat/deltachat-core-rust/issues/1949 - if (data2_string != 0) { - status = napi_create_string_utf8(env, data2_string, NAPI_AUTO_LENGTH, &argv[3]); - } else { - status = napi_create_string_utf8(env, "", NAPI_AUTO_LENGTH, &argv[3]); - } - if (status != napi_ok) { - napi_throw_error(env, NULL, "Unable to create argv[3] for event_handler arguments"); - } - dc_str_unref(data2_string); - } else { - status = napi_create_int32(env, dc_event_get_data2_int(dc_event), &argv[3]); - if (status != napi_ok) { - napi_throw_error(env, NULL, "Unable to create argv[3] for event_handler arguments"); - } - } - - dc_event_unref(dc_event); - dc_event = NULL; - - TRACE("calling back into js"); - - napi_value result; - status = napi_call_function( - env, - global, - js_callback, - argc, - argv, - &result); - - if (status != napi_ok) { - TRACE("Unable to call event_handler callback2"); - const napi_extended_error_info* error_result; - NAPI_STATUS_THROWS(napi_get_last_error_info(env, &error_result)); - } -} - -NAPI_METHOD(dcn_accounts_start_event_handler) { - NAPI_ARGV(2); - NAPI_DCN_ACCOUNTS(); - napi_value callback = argv[1]; - - TRACE("calling.."); - napi_value async_resource_name; - NAPI_STATUS_THROWS(napi_create_string_utf8(env, "dc_accounts_event_callback", NAPI_AUTO_LENGTH, &async_resource_name)); - - TRACE("creating threadsafe function.."); - - NAPI_STATUS_THROWS(napi_create_threadsafe_function( - env, - callback, - 0, - async_resource_name, - 1000, // max_queue_size - 1, - NULL, - NULL, - dcn_accounts, - call_accounts_js_event_handler, - &dcn_accounts->threadsafe_event_handler)); - TRACE("done"); - - dcn_accounts->gc = 0; - TRACE("creating uv thread.."); - uv_thread_create(&dcn_accounts->event_handler_thread, accounts_event_handler_thread_func, dcn_accounts); - - NAPI_RETURN_UNDEFINED(); -} - -// JSON RPC - -static void accounts_jsonrpc_thread_func(void* arg) -{ - dcn_accounts_t* dcn_accounts = (dcn_accounts_t*)arg; - TRACE("accounts_jsonrpc_thread_func starting"); - char* response; - while (true) { - response = dc_jsonrpc_next_response(dcn_accounts->jsonrpc_instance); - if (response == NULL) { - // done or broken - break; - } - - if (!dcn_accounts->threadsafe_jsonrpc_handler) { - TRACE("threadsafe_jsonrpc_handler not set, bailing"); - break; - } - // Don't process events if we're being garbage collected! - if (dcn_accounts->gc == 1) { - TRACE("dc_accounts has been destroyed, bailing"); - break; - } - - napi_status status = napi_call_threadsafe_function(dcn_accounts->threadsafe_jsonrpc_handler, response, napi_tsfn_blocking); - - if (status == napi_closing) { - TRACE("JS function got released, bailing"); - break; - } - } - TRACE("accounts_jsonrpc_thread_func ended"); - napi_release_threadsafe_function(dcn_accounts->threadsafe_jsonrpc_handler, napi_tsfn_release); -} - -static void call_accounts_js_jsonrpc_handler(napi_env env, napi_value js_callback, void* _context, void* data) -{ - char* response = (char*)data; - napi_value global; - napi_status status = napi_get_global(env, &global); - if (status != napi_ok) { - napi_throw_error(env, NULL, "Unable to get global"); - } - - napi_value argv[1]; - if (response != 0) { - status = napi_create_string_utf8(env, response, NAPI_AUTO_LENGTH, &argv[0]); - } else { - status = napi_create_string_utf8(env, "", NAPI_AUTO_LENGTH, &argv[0]); - } - if (status != napi_ok) { - napi_throw_error(env, NULL, "Unable to create argv for js jsonrpc_handler arguments"); - } - dc_str_unref(response); - - TRACE("calling back into js"); - napi_value result; - status = napi_call_function( - env, - global, - js_callback, - 1, - argv, - &result); - if (status != napi_ok) { - TRACE("Unable to call jsonrpc_handler callback2"); - const napi_extended_error_info* error_result; - NAPI_STATUS_THROWS(napi_get_last_error_info(env, &error_result)); - } -} - -NAPI_METHOD(dcn_accounts_start_jsonrpc) { - NAPI_ARGV(2); - NAPI_DCN_ACCOUNTS(); - napi_value callback = argv[1]; - - TRACE("calling.."); - napi_value async_resource_name; - NAPI_STATUS_THROWS(napi_create_string_utf8(env, "dc_accounts_jsonrpc_callback", NAPI_AUTO_LENGTH, &async_resource_name)); - - TRACE("creating threadsafe function.."); - - NAPI_STATUS_THROWS(napi_create_threadsafe_function( - env, - callback, - 0, - async_resource_name, - 1000, // max_queue_size - 1, - NULL, - NULL, - NULL, - call_accounts_js_jsonrpc_handler, - &dcn_accounts->threadsafe_jsonrpc_handler)); - TRACE("done"); - - dcn_accounts->gc = 0; - dcn_accounts->jsonrpc_instance = dc_jsonrpc_init(dcn_accounts->dc_accounts); - - TRACE("creating uv thread.."); - uv_thread_create(&dcn_accounts->jsonrpc_thread, accounts_jsonrpc_thread_func, dcn_accounts); - - NAPI_RETURN_UNDEFINED(); -} - -NAPI_METHOD(dcn_json_rpc_request) { - NAPI_ARGV(2); - NAPI_DCN_ACCOUNTS(); - if (!dcn_accounts->jsonrpc_instance) { - const char* msg = "dcn_accounts->jsonrpc_instance is null, have you called dcn_accounts_start_jsonrpc()?"; - NAPI_STATUS_THROWS(napi_throw_type_error(env, NULL, msg)); - } - NAPI_ARGV_UTF8_MALLOC(request, 1); - dc_jsonrpc_request(dcn_accounts->jsonrpc_instance, request); - free(request); - NAPI_RETURN_UNDEFINED(); -} - - -NAPI_INIT() { - /** - * Accounts - */ - - NAPI_EXPORT_FUNCTION(dcn_accounts_new); - NAPI_EXPORT_FUNCTION(dcn_accounts_unref); - NAPI_EXPORT_FUNCTION(dcn_accounts_add_account); - NAPI_EXPORT_FUNCTION(dcn_accounts_add_closed_account); - NAPI_EXPORT_FUNCTION(dcn_accounts_migrate_account); - NAPI_EXPORT_FUNCTION(dcn_accounts_remove_account); - NAPI_EXPORT_FUNCTION(dcn_accounts_get_all); - NAPI_EXPORT_FUNCTION(dcn_accounts_get_account); - NAPI_EXPORT_FUNCTION(dcn_accounts_get_selected_account); - NAPI_EXPORT_FUNCTION(dcn_accounts_select_account); - NAPI_EXPORT_FUNCTION(dcn_accounts_start_io); - NAPI_EXPORT_FUNCTION(dcn_accounts_stop_io); - NAPI_EXPORT_FUNCTION(dcn_accounts_maybe_network); - NAPI_EXPORT_FUNCTION(dcn_accounts_maybe_network_lost); - - NAPI_EXPORT_FUNCTION(dcn_accounts_start_event_handler); - - - /** - * Main context - */ - - NAPI_EXPORT_FUNCTION(dcn_context_new); - NAPI_EXPORT_FUNCTION(dcn_context_new_closed); - NAPI_EXPORT_FUNCTION(dcn_context_open); - NAPI_EXPORT_FUNCTION(dcn_context_is_open); - NAPI_EXPORT_FUNCTION(dcn_context_unref); - NAPI_EXPORT_FUNCTION(dcn_start_event_handler); - - /** - * Static functions - */ - - NAPI_EXPORT_FUNCTION(dcn_maybe_valid_addr); - - /** - * dcn_context_t - */ - - NAPI_EXPORT_FUNCTION(dcn_add_address_book); - NAPI_EXPORT_FUNCTION(dcn_add_contact_to_chat); - NAPI_EXPORT_FUNCTION(dcn_add_device_msg); - NAPI_EXPORT_FUNCTION(dcn_block_contact); - NAPI_EXPORT_FUNCTION(dcn_check_qr); - NAPI_EXPORT_FUNCTION(dcn_configure); - NAPI_EXPORT_FUNCTION(dcn_continue_key_transfer); - NAPI_EXPORT_FUNCTION(dcn_create_chat_by_contact_id); - NAPI_EXPORT_FUNCTION(dcn_create_broadcast_list); - NAPI_EXPORT_FUNCTION(dcn_create_contact); - NAPI_EXPORT_FUNCTION(dcn_create_group_chat); - NAPI_EXPORT_FUNCTION(dcn_delete_chat); - NAPI_EXPORT_FUNCTION(dcn_delete_contact); - NAPI_EXPORT_FUNCTION(dcn_delete_msgs); - NAPI_EXPORT_FUNCTION(dcn_forward_msgs); - NAPI_EXPORT_FUNCTION(dcn_get_blobdir); - NAPI_EXPORT_FUNCTION(dcn_get_blocked_cnt); - NAPI_EXPORT_FUNCTION(dcn_get_blocked_contacts); - NAPI_EXPORT_FUNCTION(dcn_get_chat); - NAPI_EXPORT_FUNCTION(dcn_get_chat_contacts); - NAPI_EXPORT_FUNCTION(dcn_get_chat_encrinfo); - NAPI_EXPORT_FUNCTION(dcn_get_chat_id_by_contact_id); - NAPI_EXPORT_FUNCTION(dcn_get_chat_media); - NAPI_EXPORT_FUNCTION(dcn_get_mime_headers); - NAPI_EXPORT_FUNCTION(dcn_get_chat_msgs); - NAPI_EXPORT_FUNCTION(dcn_get_chatlist); - NAPI_EXPORT_FUNCTION(dcn_get_config); - NAPI_EXPORT_FUNCTION(dcn_get_contact); - NAPI_EXPORT_FUNCTION(dcn_get_contact_encrinfo); - NAPI_EXPORT_FUNCTION(dcn_get_contacts); - NAPI_EXPORT_FUNCTION(dcn_get_connectivity); - NAPI_EXPORT_FUNCTION(dcn_get_connectivity_html); - NAPI_EXPORT_FUNCTION(dcn_was_device_msg_ever_added); - NAPI_EXPORT_FUNCTION(dcn_get_draft); - NAPI_EXPORT_FUNCTION(dcn_get_fresh_msg_cnt); - NAPI_EXPORT_FUNCTION(dcn_get_fresh_msgs); - NAPI_EXPORT_FUNCTION(dcn_get_info); - NAPI_EXPORT_FUNCTION(dcn_get_msg); - NAPI_EXPORT_FUNCTION(dcn_get_msg_cnt); - NAPI_EXPORT_FUNCTION(dcn_get_msg_info); - NAPI_EXPORT_FUNCTION(dcn_get_msg_html); - NAPI_EXPORT_FUNCTION(dcn_set_chat_visibility); - NAPI_EXPORT_FUNCTION(dcn_get_securejoin_qr); - NAPI_EXPORT_FUNCTION(dcn_get_securejoin_qr_svg); - NAPI_EXPORT_FUNCTION(dcn_imex); - NAPI_EXPORT_FUNCTION(dcn_imex_has_backup); - NAPI_EXPORT_FUNCTION(dcn_initiate_key_transfer); - NAPI_EXPORT_FUNCTION(dcn_is_configured); - NAPI_EXPORT_FUNCTION(dcn_is_contact_in_chat); - - - - NAPI_EXPORT_FUNCTION(dcn_accept_chat); - NAPI_EXPORT_FUNCTION(dcn_block_chat); - NAPI_EXPORT_FUNCTION(dcn_join_securejoin); - NAPI_EXPORT_FUNCTION(dcn_lookup_contact_id_by_addr); - NAPI_EXPORT_FUNCTION(dcn_marknoticed_chat); - NAPI_EXPORT_FUNCTION(dcn_download_full_msg); - NAPI_EXPORT_FUNCTION(dcn_markseen_msgs); - NAPI_EXPORT_FUNCTION(dcn_maybe_network); - NAPI_EXPORT_FUNCTION(dcn_msg_new); - NAPI_EXPORT_FUNCTION(dcn_remove_contact_from_chat); - NAPI_EXPORT_FUNCTION(dcn_search_msgs); - NAPI_EXPORT_FUNCTION(dcn_send_msg); - NAPI_EXPORT_FUNCTION(dcn_send_videochat_invitation); - NAPI_EXPORT_FUNCTION(dcn_set_chat_name); - NAPI_EXPORT_FUNCTION(dcn_get_chat_ephemeral_timer); - NAPI_EXPORT_FUNCTION(dcn_set_chat_ephemeral_timer); - NAPI_EXPORT_FUNCTION(dcn_set_chat_profile_image); - 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); - NAPI_EXPORT_FUNCTION(dcn_start_io); - NAPI_EXPORT_FUNCTION(dcn_stop_io); - NAPI_EXPORT_FUNCTION(dcn_stop_ongoing_process); - - /** - * dc_chat_t - */ - - NAPI_EXPORT_FUNCTION(dcn_chat_get_color); - NAPI_EXPORT_FUNCTION(dcn_chat_get_visibility); - NAPI_EXPORT_FUNCTION(dcn_chat_get_id); - NAPI_EXPORT_FUNCTION(dcn_chat_get_name); - NAPI_EXPORT_FUNCTION(dcn_chat_get_mailinglist_addr); - NAPI_EXPORT_FUNCTION(dcn_chat_get_profile_image); - NAPI_EXPORT_FUNCTION(dcn_chat_get_type); - NAPI_EXPORT_FUNCTION(dcn_chat_is_self_talk); - NAPI_EXPORT_FUNCTION(dcn_chat_is_unpromoted); - NAPI_EXPORT_FUNCTION(dcn_chat_can_send); - NAPI_EXPORT_FUNCTION(dcn_chat_is_protected); - NAPI_EXPORT_FUNCTION(dcn_chat_is_device_talk); - NAPI_EXPORT_FUNCTION(dcn_chat_is_muted); - NAPI_EXPORT_FUNCTION(dcn_chat_is_contact_request); - - /** - * dc_chatlist_t - */ - - NAPI_EXPORT_FUNCTION(dcn_chatlist_get_chat_id); - NAPI_EXPORT_FUNCTION(dcn_chatlist_get_cnt); - NAPI_EXPORT_FUNCTION(dcn_chatlist_get_msg_id); - NAPI_EXPORT_FUNCTION(dcn_chatlist_get_summary); - NAPI_EXPORT_FUNCTION(dcn_chatlist_get_summary2); - - /** - * dc_contact_t - */ - - NAPI_EXPORT_FUNCTION(dcn_contact_get_addr); - NAPI_EXPORT_FUNCTION(dcn_contact_get_auth_name); - NAPI_EXPORT_FUNCTION(dcn_contact_get_color); - NAPI_EXPORT_FUNCTION(dcn_contact_get_display_name); - NAPI_EXPORT_FUNCTION(dcn_contact_get_id); - NAPI_EXPORT_FUNCTION(dcn_contact_get_name); - NAPI_EXPORT_FUNCTION(dcn_contact_get_name_n_addr); - NAPI_EXPORT_FUNCTION(dcn_contact_get_profile_image); - NAPI_EXPORT_FUNCTION(dcn_contact_get_status); - NAPI_EXPORT_FUNCTION(dcn_contact_get_last_seen); - NAPI_EXPORT_FUNCTION(dcn_contact_is_blocked); - NAPI_EXPORT_FUNCTION(dcn_contact_is_verified); - - /** - * dc_lot_t - */ - - NAPI_EXPORT_FUNCTION(dcn_lot_get_id); - NAPI_EXPORT_FUNCTION(dcn_lot_get_state); - NAPI_EXPORT_FUNCTION(dcn_lot_get_text1); - NAPI_EXPORT_FUNCTION(dcn_lot_get_text1_meaning); - NAPI_EXPORT_FUNCTION(dcn_lot_get_text2); - NAPI_EXPORT_FUNCTION(dcn_lot_get_timestamp); - - /** - * dc_msg_t - */ - - NAPI_EXPORT_FUNCTION(dcn_msg_get_parent); - NAPI_EXPORT_FUNCTION(dcn_msg_get_download_state); - NAPI_EXPORT_FUNCTION(dcn_msg_get_chat_id); - NAPI_EXPORT_FUNCTION(dcn_msg_get_duration); - NAPI_EXPORT_FUNCTION(dcn_msg_get_file); - NAPI_EXPORT_FUNCTION(dcn_msg_get_filebytes); - NAPI_EXPORT_FUNCTION(dcn_msg_get_filemime); - NAPI_EXPORT_FUNCTION(dcn_msg_get_filename); - NAPI_EXPORT_FUNCTION(dcn_msg_get_from_id); - NAPI_EXPORT_FUNCTION(dcn_msg_get_height); - NAPI_EXPORT_FUNCTION(dcn_msg_get_id); - NAPI_EXPORT_FUNCTION(dcn_msg_get_override_sender_name); - NAPI_EXPORT_FUNCTION(dcn_msg_get_quoted_text); - NAPI_EXPORT_FUNCTION(dcn_msg_get_quoted_msg); - NAPI_EXPORT_FUNCTION(dcn_msg_get_received_timestamp); - NAPI_EXPORT_FUNCTION(dcn_msg_get_setupcodebegin); - NAPI_EXPORT_FUNCTION(dcn_msg_get_showpadlock); - NAPI_EXPORT_FUNCTION(dcn_msg_get_sort_timestamp); - NAPI_EXPORT_FUNCTION(dcn_msg_get_state); - NAPI_EXPORT_FUNCTION(dcn_msg_get_summary); - NAPI_EXPORT_FUNCTION(dcn_msg_get_summarytext); - NAPI_EXPORT_FUNCTION(dcn_msg_get_subject); - NAPI_EXPORT_FUNCTION(dcn_msg_get_text); - NAPI_EXPORT_FUNCTION(dcn_msg_get_timestamp); - NAPI_EXPORT_FUNCTION(dcn_msg_get_viewtype); - NAPI_EXPORT_FUNCTION(dcn_msg_get_videochat_type); - NAPI_EXPORT_FUNCTION(dcn_msg_get_videochat_url); - NAPI_EXPORT_FUNCTION(dcn_msg_get_width); - NAPI_EXPORT_FUNCTION(dcn_msg_get_webxdc_info); - NAPI_EXPORT_FUNCTION(dcn_msg_has_deviating_timestamp); - NAPI_EXPORT_FUNCTION(dcn_msg_has_location); - NAPI_EXPORT_FUNCTION(dcn_msg_has_html); - NAPI_EXPORT_FUNCTION(dcn_msg_is_forwarded); - NAPI_EXPORT_FUNCTION(dcn_msg_is_info); - NAPI_EXPORT_FUNCTION(dcn_msg_is_sent); - NAPI_EXPORT_FUNCTION(dcn_msg_is_setupmessage); - NAPI_EXPORT_FUNCTION(dcn_msg_latefiling_mediasize); - NAPI_EXPORT_FUNCTION(dcn_msg_force_plaintext); - NAPI_EXPORT_FUNCTION(dcn_msg_set_dimension); - NAPI_EXPORT_FUNCTION(dcn_msg_set_duration); - NAPI_EXPORT_FUNCTION(dcn_msg_set_override_sender_name); - NAPI_EXPORT_FUNCTION(dcn_msg_set_file); - NAPI_EXPORT_FUNCTION(dcn_msg_set_html); - NAPI_EXPORT_FUNCTION(dcn_msg_set_quote); - NAPI_EXPORT_FUNCTION(dcn_msg_set_text); - NAPI_EXPORT_FUNCTION(dcn_msg_set_location); - - /** - * dc_location - */ - NAPI_EXPORT_FUNCTION(dcn_set_location); - NAPI_EXPORT_FUNCTION(dcn_get_locations); - - /** - * dc_provider - */ - NAPI_EXPORT_FUNCTION(dcn_provider_new_from_email); - NAPI_EXPORT_FUNCTION(dcn_provider_get_overview_page); - NAPI_EXPORT_FUNCTION(dcn_provider_get_before_login_hint); - NAPI_EXPORT_FUNCTION(dcn_provider_get_status); - - /** - * dc_array - */ - NAPI_EXPORT_FUNCTION(dcn_array_get_cnt); - NAPI_EXPORT_FUNCTION(dcn_array_get_id); - NAPI_EXPORT_FUNCTION(dcn_array_get_accuracy); - NAPI_EXPORT_FUNCTION(dcn_array_get_latitude); - NAPI_EXPORT_FUNCTION(dcn_array_get_longitude); - NAPI_EXPORT_FUNCTION(dcn_array_get_timestamp); - NAPI_EXPORT_FUNCTION(dcn_array_get_msg_id); - NAPI_EXPORT_FUNCTION(dcn_array_is_independent); - NAPI_EXPORT_FUNCTION(dcn_array_get_contact_id); - NAPI_EXPORT_FUNCTION(dcn_array_get_chat_id); - NAPI_EXPORT_FUNCTION(dcn_array_get_marker); - - /** webxdc **/ - - NAPI_EXPORT_FUNCTION(dcn_send_webxdc_status_update); - NAPI_EXPORT_FUNCTION(dcn_get_webxdc_status_updates); - NAPI_EXPORT_FUNCTION(dcn_msg_get_webxdc_blob); - - - /** jsonrpc **/ - NAPI_EXPORT_FUNCTION(dcn_accounts_start_jsonrpc); - NAPI_EXPORT_FUNCTION(dcn_json_rpc_request); -} diff --git a/node/src/napi-macros-extensions.h b/node/src/napi-macros-extensions.h deleted file mode 100644 index 968bc02ca..000000000 --- a/node/src/napi-macros-extensions.h +++ /dev/null @@ -1,144 +0,0 @@ -#include - -#undef NAPI_STATUS_THROWS - -#define NAPI_STATUS_THROWS(call) \ - if ((call) != napi_ok) { \ - napi_throw_error(env, NULL, #call " failed!"); \ - } - -#define NAPI_DCN_CONTEXT() \ - dcn_context_t* dcn_context; \ - NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], (void**)&dcn_context)); \ - if (!dcn_context) { \ - const char* msg = "Provided dnc_context is null"; \ - NAPI_STATUS_THROWS(napi_throw_type_error(env, NULL, msg)); \ - } \ - if (!dcn_context->dc_context) { \ - const char* msg = "Provided dc_context is null, did you close the context or not open it?"; \ - NAPI_STATUS_THROWS(napi_throw_type_error(env, NULL, msg)); \ - } - -#define NAPI_DCN_ACCOUNTS() \ - dcn_accounts_t* dcn_accounts; \ - NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], (void**)&dcn_accounts)); \ - if (!dcn_accounts) { \ - const char* msg = "Provided dcn_acounts is null"; \ - NAPI_STATUS_THROWS(napi_throw_type_error(env, NULL, msg)); \ - } \ - if (!dcn_accounts->dc_accounts) { \ - const char* msg = "Provided dc_accounts is null, did you unref the accounts object?"; \ - NAPI_STATUS_THROWS(napi_throw_type_error(env, NULL, msg)); \ - } - - -#define NAPI_DC_CHAT() \ - dc_chat_t* dc_chat; \ - NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], (void**)&dc_chat)); - -#define NAPI_DC_CHATLIST() \ - dc_chatlist_t* dc_chatlist; \ - NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], (void**)&dc_chatlist)); - -#define NAPI_DC_CONTACT() \ - dc_contact_t* dc_contact; \ - NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], (void**)&dc_contact)); - -#define NAPI_DC_LOT() \ - dc_lot_t* dc_lot; \ - NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], (void**)&dc_lot)); - -#define NAPI_DC_MSG() \ - dc_msg_t* dc_msg; \ - NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], (void**)&dc_msg)); - -#define NAPI_ARGV_DC_MSG(name, position) \ - dc_msg_t* name; \ - NAPI_STATUS_THROWS(napi_get_value_external(env, argv[position], (void**)&name)); - -#define NAPI_DC_PROVIDER() \ - dc_provider_t* dc_provider; \ - NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], (void**)&dc_provider)); - -#define NAPI_DC_ARRAY() \ - dc_array_t* dc_array; \ - NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], (void**)&dc_array)); - -#define NAPI_RETURN_UNDEFINED() \ - return 0; - -#define NAPI_RETURN_UINT64(name) \ - napi_value return_int64; \ - NAPI_STATUS_THROWS(napi_create_bigint_int64(env, name, &return_int64)); \ - return return_int64; - -#define NAPI_RETURN_INT64(name) \ - napi_value return_int64; \ - NAPI_STATUS_THROWS(napi_create_int64(env, name, &return_int64)); \ - return return_int64; - - -#define NAPI_RETURN_AND_UNREF_STRING(name) \ - napi_value return_value; \ - if (name == NULL) { \ - NAPI_STATUS_THROWS(napi_get_null(env, &return_value)); \ - return return_value; \ - } \ - NAPI_STATUS_THROWS(napi_create_string_utf8(env, name, NAPI_AUTO_LENGTH, &return_value)); \ - dc_str_unref(name); \ - return return_value; - -#define NAPI_ASYNC_CARRIER_BEGIN(name) \ - typedef struct name##_carrier_t { \ - napi_ref callback_ref; \ - napi_async_work async_work; \ - dcn_context_t* dcn_context; - -#define NAPI_ASYNC_CARRIER_END(name) \ - } name##_carrier_t; - -#define NAPI_ASYNC_EXECUTE(name) \ - static void name##_execute(napi_env env, void* data) - -#define NAPI_ASYNC_GET_CARRIER(name) \ - name##_carrier_t* carrier = (name##_carrier_t*)data; - -#define NAPI_ASYNC_COMPLETE(name) \ - static void name##_complete(napi_env env, napi_status status, void* data) - -#define NAPI_ASYNC_CALL_AND_DELETE_CB() \ - napi_value global; \ - NAPI_STATUS_THROWS(napi_get_global(env, &global)); \ - napi_value callback; \ - NAPI_STATUS_THROWS(napi_get_reference_value(env, carrier->callback_ref, &callback)); \ - NAPI_STATUS_THROWS(napi_call_function(env, global, callback, argc, argv, NULL)); \ - NAPI_STATUS_THROWS(napi_delete_reference(env, carrier->callback_ref)); \ - NAPI_STATUS_THROWS(napi_delete_async_work(env, carrier->async_work)); - -#define NAPI_ASYNC_NEW_CARRIER(name) \ - name##_carrier_t* carrier = calloc(1, sizeof(name##_carrier_t)); \ - carrier->dcn_context = dcn_context; - -#define NAPI_ASYNC_QUEUE_WORK(name, cb) \ - napi_value callback = cb; \ - napi_value async_resource_name; \ - NAPI_STATUS_THROWS(napi_create_reference(env, callback, 1, &carrier->callback_ref)); \ - NAPI_STATUS_THROWS(napi_create_string_utf8(env, #name "_callback", \ - NAPI_AUTO_LENGTH, \ - &async_resource_name)); \ - NAPI_STATUS_THROWS(napi_create_async_work(env, callback, async_resource_name, \ - name##_execute, name##_complete, \ - carrier, &carrier->async_work)); \ - NAPI_STATUS_THROWS(napi_queue_async_work(env, carrier->async_work)); - -/*** this could/should be moved to napi-macros ***/ - -#define NAPI_DOUBLE(name, val) \ - double name; \ - if (napi_get_value_double(env, val, &name) != napi_ok) { \ - napi_throw_error(env, "EINVAL", "Expected double"); \ - return NULL; \ - } - -#define NAPI_ARGV_DOUBLE(name, i) \ - NAPI_DOUBLE(name, argv[i]) diff --git a/node/test/fixtures/avatar.png b/node/test/fixtures/avatar.png deleted file mode 100644 index 76e69ce4925840bad037d55a41a8a5499b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 zn&eO3tLl?=#?&Nd{v`QBw26yc)cYg6+4_}fTb|WP#xj_nP;hTUoKW^2(ZKy_;4m^R zi7|7zyt-U1g4i9^g$`EK=*tYoq4+cx3%{ji1xLL9jG@=2J&x-AyWL7={nA%E^^@9_ z>X*4!SyX*wE|0UYX*kHRw~79#g5ywmK}0*z>2kAgt~#1S6ma>{dF#J2Sj+doV{g3= zyvnLca`zCD?|Ylo-~-f<44AG}aHL`z^ZsjM@wvcdE`2zEqs{i`A%ageh0Ai$ve9t* zK5BjDh&N+F*yK~={II+BYQ4mPqz}emqZb!`_r5fbgd>-1 z_15i_jYq#YR;eF4mOSQpwG%O~%(p@|rD8k2^1!|&xcym(B*_h_FQRmr~rrGMBSv``?aaCv<#9C8Y(PwdkXc`{*Mxz3D3DpSD-I1qzDKvFK6NQ&$7ARr?0j( Of|9(tT%F8^u>S$cCOG#1 diff --git a/node/test/fixtures/image.jpeg b/node/test/fixtures/image.jpeg deleted file mode 100644 index 7e64c99307f3a83946729d1babda6fdd076fdec7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13096 zcmb8VWmsJ?(>A(rhm99^cUrW#ySr;~cX!>mON+a^yL-_VC{nDrmSUywZJy_Q&w09vZ`e)*Z*6@q}XU4sA(Ag$D>2@`yWR|;YJD&PM|Dd`}1bpZDyUn zuYYP`HW(TO<3;4bOD;bGDWIUEt?W$620|1=;B<+m5+spIH5AA^#<~7|@OYrw!{fZ%q%&mQl zT;H;-<2!d9jG<%R<+UH2e+G-clgt8;3H)K??Y@dEae<{n2l3X|9KPoMX4btX%4Ch7 z%-E^)7|y%@rPC<+E%Q{#aa$79OD0l-6`rlx`T=iaIy1ytkGAOVC24~7(ZQhDeDg?s z+R`VhwlClFQhk|qT9}VN^WTl>ODBz%AoF>{h&jxv_TsUS!p+dHXTOO<(rH$*%`Rm$ zj~0(vrNtYcNzq}=;LDCQ8^TbUVRU6Z_pNKiRRmaUztM6x$7#mb=I*QH`B#HhZT3d9 z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T7$ige0 zG;>nsX3#1H3?ZG%)Lg>bW>-1!fyYa8Sr(OrAKE;-ZL&`Bu{PQbT|J zgD~CYLa79m`ivzUxAdJYsDu7+bqF>(o8Kr8I@Mugs%?IV$p-Huao^xT@30y7Vy}>Z;Q6LA;FC|ph6=68}Cz-a;#m3l|DP=`@ihN47LyL?^B4pR+XGY) zE|0e5HF8E{pY9L`;yiN_6-)%EiTIRO)4y!RvK2(}zvUb7QvCxZsnNNp|KgA{xsNxs z!!*_nl6jP2IF(8ftAVjhQ7*)S0nj^)RHAL@;>?dzgxTnk5$wBLu*n^hFw5xs7`aPc zE_1r^1Kz?znd#RN^qHXoExB^sItwFyvRkFQNC?v=UePZap=+eKrTQC!`EH_Vt=fyv zbeuS4!Eirsyb6K1_>mV-v^8u@liC&ST)T~Mv1A@Wi(@)&ncf}l?=#g^>q>LYs6vt8 zjv&%o9eP~y=|`y&i`n6o6#;k;;hP_d}6A(wMf?$=zes>ugn>O@4hx zIf@-m<|iGNi~+kg`|bMis%%|k(Cll5^?^&HLS#Hib+RSDKIm=6^(Hx4&a}RWRjN>W z5gLj#Q$D8T(AghVD-wcY(bKzasRjJWLW`3!`bC{qBq$sH{nTqfg$llY#tMsW5j4Wa c<(~Gs5I<+N`Pj_dM2j;jvbn$#^t$$c0FIsNuK)l5 diff --git a/node/test/fixtures/logo.png b/node/test/fixtures/logo.png deleted file mode 100644 index 9408ad90b4379065e4353a3e2c00a7e93014b29c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 27597 zcmY&=1ys~u)a}qM-Q5UCOLw<~(%s!s(jg_?F*JyOTBN%h1f--pr5l0o`mOigT5r~j zs0-%zn|tp$XYYOXAxceE4g-}06#{`^D9B4|fUjr&UdV{xPtgwtN#F~-yQIQR_yudLow}Y^BBPV8rLfr0a6SLxYn^L2S!v^s~&f_MT z$C7X$ScHUx6qJ;d*yQBo1@D>hnNyiH*wRO(q@;ErSU5O1G^vV~Rr3pfJX;qXcwvHO z?d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{cd`Jz2@AOqEe9I# zd?>ZM7u_PE2LLAxIYbpV*pcDQ1|%L!ZZ)$mB6K(wIo0=~TOSb~s>~+0H?e->Qz4rkyI~}sNsZQ> z*lpUf-SO0sAGh(aF5y;$X-h$h31(DG0v(RxlP6q|b=)^Hs@sSPSp0F@!^_JCPWh8k z=u!nD(`muQOtbT$ZN)q70XT95weu{9;Urv_!2nV`;u!h&+H6cGf=sF1%-t)`QP>&1 zOXvt}MF8>C#WD-vQ8|Gg1Ls6+$3mGdyTW~9g?5WF1OD{)u%vFoSr2yy0f=Z`I7FVF zk;2V_FD5~R@%WHA!pI_XMrhdeA5Av;*Ca}02YQtourW8mSMTgNph1?75WFF80kaJM ziN~GTmerv`K1s=-{d~As0judUtc39~YUf4>zO-Ofj7)~jWX%&-REuAo#)E97mOqmV zf+1~_?jLJ9$`p(+zp^a{H|}2;Zr%8S{0bp)zlSU}1fG4mK`rL-ACzR7T~=RUpS;P) zfQy8{Rz1RdCXn=L{lSRVRRfA6`vKl%9-D>VkP|}FhOBD~ ze5${6Sn+SBDl=6WbCW^>1JT5###jIh@`W$&zEbr>uMRkB<5oq!9tp)8<*l6yN&S4y zruj3Q+Rp}Q-Sv^M5z1hM1aaF{gzAEmgyU9RyDoU>0?vdbo5Kr9%>%^wC8lw%yz4ED zsiUHsA>IJ5c^<3{r$hTGjsV-zkd1iH(b4h9xZdx;O@hYuwfYK*IhK~sZol?c2+ZPr x6+-#(rlt`1&M0QD8w3L!3vZ;wo3Q`UcB?*lHqZP19$dYJs3>U4m&lrh{SQ5y1{MGS diff --git a/node/test/test.mjs b/node/test/test.mjs deleted file mode 100644 index 11e4703ad..000000000 --- a/node/test/test.mjs +++ /dev/null @@ -1,943 +0,0 @@ -// @ts-check -import { DeltaChat } from '../dist/index.js' - -import { deepStrictEqual, strictEqual } from 'assert' -import chai, { expect } from 'chai' -import chaiAsPromised from 'chai-as-promised' -import { EventId2EventName, C } from '../dist/constants.js' -import { join } from 'path' -import { statSync } from 'fs' -import { Context } from '../dist/context.js' -import { fileURLToPath } from 'url'; - -const __dirname = fileURLToPath(new URL('.', import.meta.url)); - -chai.use(chaiAsPromised) -chai.config.truncateThreshold = 0 // Do not truncate assertion errors. - -function createTempUser(chatmailDomain) { - const charset = "2345789acdefghjkmnpqrstuvwxyz"; - let user = "ci-"; - for (let i = 0; i < 6; i++) { - user += charset[Math.floor(Math.random() * charset.length)]; - } - const email = user + "@" + chatmailDomain; - return { email: email, password: user + "$" + user }; -} - -describe('static tests', function () { - this.timeout(60 * 5 * 1000) // increase timeout to 5 min - - it('reverse lookup of events', function () { - const eventKeys = Object.keys(EventId2EventName).map((k) => Number(k)) - const eventValues = Object.values(EventId2EventName) - const reverse = eventValues.map((v) => C[v]) - expect(reverse).to.be.deep.equal(eventKeys) - }) - - it('event constants are consistent', function () { - const eventKeys = Object.keys(C) - .filter((k) => k.startsWith('DC_EVENT_')) - .sort() - const eventValues = Object.values(EventId2EventName).sort() - expect(eventKeys).to.be.deep.equal(eventValues) - }) - - it('static method maybeValidAddr()', function () { - expect(DeltaChat.maybeValidAddr(null)).to.equal(false) - expect(DeltaChat.maybeValidAddr('')).to.equal(false) - expect(DeltaChat.maybeValidAddr('uuu')).to.equal(false) - expect(DeltaChat.maybeValidAddr('dd.tt')).to.equal(false) - expect(DeltaChat.maybeValidAddr('tt.dd@yggmail')).to.equal(true) - expect(DeltaChat.maybeValidAddr('u@d')).to.equal(true) - //expect(DeltaChat.maybeValidAddr('u@d.')).to.equal(false) - //expect(DeltaChat.maybeValidAddr('u@d.t')).to.equal(false) - //expect(DeltaChat.maybeValidAddr('u@.tt')).to.equal(false) - expect(DeltaChat.maybeValidAddr('@d.tt')).to.equal(false) - expect(DeltaChat.maybeValidAddr('user@domain.tld')).to.equal(true) - expect(DeltaChat.maybeValidAddr('u@d.tt')).to.equal(true) - }) - - it('static getSystemInfo()', function () { - const info = Context.getSystemInfo() - expect(info).to.contain.keys([ - 'arch', - 'deltachat_core_version', - 'sqlite_version', - ]) - }) - - it('static context.getProviderFromEmail("example@example.com")', function () { - const provider = DeltaChat.getProviderFromEmail('example@example.com') - - expect(provider).to.deep.equal({ - before_login_hint: "Hush this provider doesn't exist!", - overview_page: 'https://providers.delta.chat/example-com', - status: 3, - }) - }) -}) - -describe('JSON RPC', function () { - it('smoketest', async function () { - const { dc } = DeltaChat.newTemporary() - let promise_resolve - const promise = new Promise((res, _rej) => { - promise_resolve = (response) => { - // ignore events - const answer = JSON.parse(response) - if (answer['method'] !== 'event') res(answer) - } - }) - dc.startJsonRpcHandler(promise_resolve) - dc.jsonRpcRequest( - JSON.stringify({ - jsonrpc: '2.0', - method: 'get_all_account_ids', - params: [], - id: 2, - }) - ) - deepStrictEqual( - { - jsonrpc: '2.0', - id: 2, - result: [1], - }, - await promise - ) - dc.close() - }) - - it('basic test', async function () { - const { dc } = DeltaChat.newTemporary() - - const promises = {} - dc.startJsonRpcHandler((msg) => { - const response = JSON.parse(msg) - if (response.hasOwnProperty('id')) promises[response.id](response) - delete promises[response.id] - }) - const call = (request) => { - dc.jsonRpcRequest(JSON.stringify(request)) - return new Promise((res, _rej) => { - promises[request.id] = res - }) - } - - deepStrictEqual( - { - jsonrpc: '2.0', - id: 2, - result: [1], - }, - await call({ - jsonrpc: '2.0', - method: 'get_all_account_ids', - params: [], - id: 2, - }) - ) - - deepStrictEqual( - { - jsonrpc: '2.0', - id: 3, - result: 2, - }, - await call({ - jsonrpc: '2.0', - method: 'add_account', - params: [], - id: 3, - }) - ) - - deepStrictEqual( - { - jsonrpc: '2.0', - id: 4, - result: [1, 2], - }, - await call({ - jsonrpc: '2.0', - method: 'get_all_account_ids', - params: [], - id: 4, - }) - ) - - dc.close() - }) -}) - -describe('Basic offline Tests', function () { - it('opens a context', async function () { - const { dc, context } = DeltaChat.newTemporary() - - strictEqual(context.isConfigured(), false) - dc.close() - }) - - it('set config', async function () { - const { dc, context } = DeltaChat.newTemporary() - - context.setConfig('bot', true) - strictEqual(context.getConfig('bot'), '1') - context.setConfig('bot', false) - strictEqual(context.getConfig('bot'), '0') - context.setConfig('bot', '1') - strictEqual(context.getConfig('bot'), '1') - context.setConfig('bot', '0') - strictEqual(context.getConfig('bot'), '0') - context.setConfig('bot', 1) - strictEqual(context.getConfig('bot'), '1') - context.setConfig('bot', 0) - strictEqual(context.getConfig('bot'), '0') - - context.setConfig('bot', null) - strictEqual(context.getConfig('bot'), '') - - strictEqual(context.getConfig('selfstatus'), '') - context.setConfig('selfstatus', 'hello') - strictEqual(context.getConfig('selfstatus'), 'hello') - context.setConfig('selfstatus', '') - strictEqual(context.getConfig('selfstatus'), '') - context.setConfig('selfstatus', null) - strictEqual(context.getConfig('selfstatus'), '') - - dc.close() - }) - - it('configure with either missing addr or missing mail_pw throws', async function () { - const { dc, context } = DeltaChat.newTemporary() - dc.startEvents() - - await expect( - context.configure({ addr: 'delta1@delta.localhost' }) - ).to.eventually.be.rejectedWith('Missing (IMAP) password.') - await expect(context.configure({ mailPw: 'delta1' })).to.eventually.be - .rejected - - context.stopOngoingProcess() - dc.close() - }) - - it('context.getInfo()', async function () { - const { dc, context } = DeltaChat.newTemporary() - - const info = await context.getInfo() - expect(typeof info).to.be.equal('object') - expect(info).to.contain.keys([ - 'arch', - 'bcc_self', - 'blobdir', - 'bot', - 'configured_mvbox_folder', - 'configured_sentbox_folder', - 'database_dir', - 'database_encrypted', - 'database_version', - 'delete_device_after', - 'delete_server_after', - 'deltachat_core_version', - 'displayname', - 'download_limit', - 'e2ee_enabled', - 'entered_account_settings', - 'fetch_existing_msgs', - 'fingerprint', - 'folders_configured', - 'is_configured', - 'journal_mode', - 'key_gen_type', - 'last_housekeeping', - 'last_cant_decrypt_outgoing_msgs', - 'level', - 'mdns_enabled', - 'media_quality', - 'messages_in_contact_requests', - 'mvbox_move', - 'num_cpus', - 'number_of_chat_messages', - 'number_of_chats', - 'number_of_contacts', - 'only_fetch_mvbox', - 'private_key_count', - 'public_key_count', - 'quota_exceeding', - 'scan_all_folders_debounce_secs', - 'selfavatar', - 'sync_msgs', - 'sentbox_watch', - 'show_emails', - 'proxy_enabled', - 'sqlite_version', - 'uptime', - 'used_account_settings', - 'webrtc_instance', - ]) - - dc.close() - }) -}) - -describe('Offline Tests with unconfigured account', function () { - let [dc, context, accountId, directory] = [null, null, null, null] - - this.beforeEach(async function () { - let tmp = DeltaChat.newTemporary() - dc = tmp.dc - context = tmp.context - accountId = tmp.accountId - directory = tmp.directory - dc.startEvents() - }) - - this.afterEach(async function () { - if (context) { - context.stopOngoingProcess() - } - if (dc) { - try { - dc.stopIO() - dc.close() - } catch (error) { - console.error(error) - } - } - - dc = null - context = null - accountId = null - directory = null - }) - - it('invalid context.joinSecurejoin', async function () { - expect(context.joinSecurejoin('test')).to.be.eq(0) - }) - - it('Device Chat', async function () { - const deviceChatMessageText = 'test234' - - expect((await context.getChatList(0, '', null)).getCount()).to.equal( - 0, - 'no device chat after setup' - ) - - await context.addDeviceMessage('test', deviceChatMessageText) - - const chatList = await context.getChatList(0, '', null) - expect(chatList.getCount()).to.equal( - 1, - 'device chat after adding device msg' - ) - - const deviceChatId = await chatList.getChatId(0) - const deviceChat = await context.getChat(deviceChatId) - expect(deviceChat.isDeviceTalk()).to.be.true - expect(deviceChat.toJson().isDeviceTalk).to.be.true - - const deviceChatMessages = await context.getChatMessages(deviceChatId, 0, 0) - expect(deviceChatMessages.length).to.be.equal( - 1, - 'device chat has added message' - ) - - const deviceChatMessage = await context.getMessage(deviceChatMessages[0]) - expect(deviceChatMessage.getText()).to.equal( - deviceChatMessageText, - 'device chat message has the inserted text' - ) - }) - - it('should have e2ee enabled and right blobdir', function () { - expect(context.getConfig('e2ee_enabled')).to.equal( - '1', - 'e2eeEnabled correct' - ) - expect( - String(context.getBlobdir()).startsWith(directory), - 'blobdir should be inside temp directory' - ) - expect( - String(context.getBlobdir()).endsWith('db.sqlite-blobs'), - 'blobdir end with "db.sqlite-blobs"' - ) - }) - - it('should create chat from contact and Chat methods', async function () { - const contactId = context.createContact('aaa', 'aaa@site.org') - - strictEqual(context.lookupContactIdByAddr('aaa@site.org'), contactId) - strictEqual(context.lookupContactIdByAddr('nope@site.net'), 0) - - let chatId = context.createChatByContactId(contactId) - let chat = context.getChat(chatId) - - strictEqual( - chat.getVisibility(), - C.DC_CHAT_VISIBILITY_NORMAL, - 'not archived' - ) - strictEqual(chat.getId(), chatId, 'chat id matches') - strictEqual(chat.getName(), 'aaa', 'chat name matches') - strictEqual(chat.getProfileImage(), null, 'no profile image') - strictEqual(chat.getType(), C.DC_CHAT_TYPE_SINGLE, 'single chat') - strictEqual(chat.isSelfTalk(), false, 'no self talk') - // TODO make sure this is really the case! - strictEqual(chat.isUnpromoted(), false, 'not unpromoted') - strictEqual(chat.isProtected(), false, 'not verified') - strictEqual(typeof chat.color, 'string', 'color is a string') - - strictEqual(context.getDraft(chatId), null, 'no draft message') - context.setDraft(chatId, context.messageNew().setText('w00t!')) - strictEqual( - context.getDraft(chatId).toJson().text, - 'w00t!', - 'draft text correct' - ) - context.setDraft(chatId, null) - strictEqual(context.getDraft(chatId), null, 'draft removed') - - strictEqual(context.getChatIdByContactId(contactId), chatId) - expect(context.getChatContacts(chatId)).to.deep.equal([contactId]) - - context.setChatVisibility(chatId, C.DC_CHAT_VISIBILITY_ARCHIVED) - strictEqual( - context.getChat(chatId).getVisibility(), - C.DC_CHAT_VISIBILITY_ARCHIVED, - 'chat archived' - ) - context.setChatVisibility(chatId, C.DC_CHAT_VISIBILITY_NORMAL) - strictEqual( - chat.getVisibility(), - C.DC_CHAT_VISIBILITY_NORMAL, - 'chat unarchived' - ) - - chatId = context.createGroupChat('unverified group', false) - chat = context.getChat(chatId) - strictEqual(chat.isProtected(), false, 'is not verified') - strictEqual(chat.getType(), C.DC_CHAT_TYPE_GROUP, 'group chat') - expect(context.getChatContacts(chatId)).to.deep.equal([ - C.DC_CONTACT_ID_SELF, - ]) - - const draft2 = context.getDraft(chatId) - expect(draft2 == null, 'unpromoted group has no draft by default') - - context.setChatName(chatId, 'NEW NAME') - strictEqual(context.getChat(chatId).getName(), 'NEW NAME', 'name updated') - - chatId = context.createGroupChat('a verified group', true) - chat = context.getChat(chatId) - strictEqual(chat.isProtected(), true, 'is verified') - }) - - it('test setting profile image', async function () { - const chatId = context.createGroupChat('testing profile image group', false) - const image = 'image.jpeg' - const imagePath = join(__dirname, 'fixtures', image) - const blobs = context.getBlobdir() - - context.setChatProfileImage(chatId, imagePath) - const blobPath = context.getChat(chatId).getProfileImage() - expect(blobPath.startsWith(blobs)).to.be.true - expect(blobPath.includes('image')).to.be.false - expect(blobPath.endsWith('.jpeg')).to.be.true - - context.setChatProfileImage(chatId, null) - expect(context.getChat(chatId).getProfileImage()).to.be.equal( - null, - 'image is null' - ) - }) - - it('test setting ephemeral timer', function () { - const chatId = context.createGroupChat('testing ephemeral timer') - - strictEqual( - context.getChatEphemeralTimer(chatId), - 0, - 'ephemeral timer is not set by default' - ) - - context.setChatEphemeralTimer(chatId, 60) - strictEqual( - context.getChatEphemeralTimer(chatId), - 60, - 'ephemeral timer is set to 1 minute' - ) - - context.setChatEphemeralTimer(chatId, 0) - strictEqual( - context.getChatEphemeralTimer(chatId), - 0, - 'ephemeral timer is reset' - ) - }) - - it('should create and delete chat', function () { - const chatId = context.createGroupChat('GROUPCHAT') - const chat = context.getChat(chatId) - strictEqual(chat.getId(), chatId, 'correct chatId') - context.deleteChat(chat.getId()) - strictEqual(context.getChat(chatId), null, 'chat removed') - }) - - it('new message and Message methods', function () { - const text = 'w00t!' - const msg = context.messageNew().setText(text) - - strictEqual(msg.getChatId(), 0, 'chat id 0 before sent') - strictEqual(msg.getDuration(), 0, 'duration 0 before sent') - strictEqual(msg.getFile(), '', 'no file set by default') - strictEqual(msg.getFilebytes(), 0, 'and file bytes is 0') - strictEqual(msg.getFilemime(), '', 'no filemime by default') - strictEqual(msg.getFilename(), '', 'no filename set by default') - strictEqual(msg.getFromId(), 0, 'no contact id set by default') - strictEqual(msg.getHeight(), 0, 'plain text message have height 0') - strictEqual(msg.getId(), 0, 'id 0 before sent') - strictEqual(msg.getSetupcodebegin(), '', 'no setupcode begin') - strictEqual(msg.getShowpadlock(), false, 'no padlock by default') - - const state = msg.getState() - strictEqual(state.isUndefined(), true, 'no state by default') - strictEqual(state.isFresh(), false, 'no state by default') - strictEqual(state.isNoticed(), false, 'no state by default') - strictEqual(state.isSeen(), false, 'no state by default') - strictEqual(state.isPending(), false, 'no state by default') - strictEqual(state.isFailed(), false, 'no state by default') - strictEqual(state.isDelivered(), false, 'no state by default') - strictEqual(state.isReceived(), false, 'no state by default') - - const summary = msg.getSummary() - strictEqual(summary.getId(), 0, 'no summary id') - strictEqual(summary.getState(), 0, 'no summary state') - strictEqual(summary.getText1(), null, 'no summary text1') - strictEqual(summary.getText1Meaning(), 0, 'no summary text1 meaning') - strictEqual(summary.getText2(), '', 'no summary text2') - strictEqual(summary.getTimestamp(), 0, 'no summary timestamp') - - //strictEqual(msg.getSummarytext(50), text, 'summary text is text') - strictEqual(msg.getText(), text, 'msg text set correctly') - strictEqual(msg.getTimestamp(), 0, 'no timestamp') - - const viewType = msg.getViewType() - strictEqual(viewType.isText(), true) - strictEqual(viewType.isImage(), false) - strictEqual(viewType.isGif(), false) - strictEqual(viewType.isAudio(), false) - strictEqual(viewType.isVoice(), false) - strictEqual(viewType.isVideo(), false) - strictEqual(viewType.isFile(), false) - - strictEqual(msg.getWidth(), 0, 'no message width') - strictEqual(msg.isDeadDrop(), false, 'not deaddrop') - strictEqual(msg.isForwarded(), false, 'not forwarded') - strictEqual(msg.isInfo(), false, 'not an info message') - strictEqual(msg.isSent(), false, 'messge is not sent') - strictEqual(msg.isSetupmessage(), false, 'not an autocrypt setup message') - - msg.latefilingMediasize(10, 20, 30) - strictEqual(msg.getWidth(), 10, 'message width set correctly') - strictEqual(msg.getHeight(), 20, 'message height set correctly') - strictEqual(msg.getDuration(), 30, 'message duration set correctly') - - msg.setDimension(100, 200) - strictEqual(msg.getWidth(), 100, 'message width set correctly') - strictEqual(msg.getHeight(), 200, 'message height set correctly') - - msg.setDuration(314) - strictEqual(msg.getDuration(), 314, 'message duration set correctly') - - expect(() => { - msg.setFile(null) - }).to.throw('Missing filename') - - const logo = join(__dirname, 'fixtures', 'logo.png') - const stat = statSync(logo) - msg.setFile(logo) - strictEqual(msg.getFilebytes(), stat.size, 'correct file size') - strictEqual(msg.getFile(), logo, 'correct file name') - strictEqual(msg.getFilemime(), 'image/png', 'mime set implicitly') - msg.setFile(logo, 'image/gif') - strictEqual(msg.getFilemime(), 'image/gif', 'mime set (in)correctly') - msg.setFile(logo, 'image/png') - strictEqual(msg.getFilemime(), 'image/png', 'mime set correctly') - - const json = msg.toJson() - expect(json).to.not.equal(null, 'not null') - strictEqual(typeof json, 'object', 'json object') - }) - - it('Contact methods', function () { - const contactId = context.createContact('First Last', 'first.last@site.org') - const contact = context.getContact(contactId) - - strictEqual(contact.getAddress(), 'first.last@site.org', 'correct address') - strictEqual(typeof contact.color, 'string', 'color is a string') - strictEqual(contact.getDisplayName(), 'First Last', 'correct display name') - strictEqual(contact.getId(), contactId, 'contact id matches') - strictEqual(contact.getName(), 'First Last', 'correct name') - strictEqual(contact.getNameAndAddress(), 'First Last (first.last@site.org)') - strictEqual(contact.getProfileImage(), null, 'no contact image') - strictEqual(contact.isBlocked(), false, 'not blocked') - strictEqual(contact.isVerified(), false, 'unverified status') - strictEqual(contact.lastSeen, 0, 'last seen unknown') - }) - - it('create contacts from address book', function () { - const addresses = [ - 'Name One', - 'name1@site.org', - 'Name Two', - 'name2@site.org', - 'Name Three', - 'name3@site.org', - ] - const count = context.addAddressBook(addresses.join('\n')) - strictEqual(count, addresses.length / 2) - context - .getContacts(0, 'Name ') - .map((id) => context.getContact(id)) - .forEach((contact) => { - expect(contact.getName().startsWith('Name ')).to.be.true - }) - }) - - it('delete contacts', function () { - const id = context.createContact('someuser', 'someuser@site.com') - const contact = context.getContact(id) - strictEqual(contact.getId(), id, 'contact id matches') - context.deleteContact(id) - strictEqual(context.getContact(id), null, 'contact is gone') - }) - - it('adding and removing a contact from a chat', function () { - const chatId = context.createGroupChat('adding_and_removing') - const contactId = context.createContact('Add Remove', 'add.remove@site.com') - strictEqual( - context.addContactToChat(chatId, contactId), - true, - 'contact added' - ) - strictEqual( - context.isContactInChat(chatId, contactId), - true, - 'contact in chat' - ) - strictEqual( - context.removeContactFromChat(chatId, contactId), - true, - 'contact removed' - ) - strictEqual( - context.isContactInChat(chatId, contactId), - false, - 'contact not in chat' - ) - }) - - it('blocking contacts', function () { - const id = context.createContact('badcontact', 'bad@site.com') - - strictEqual(context.getBlockedCount(), 0) - strictEqual(context.getContact(id).isBlocked(), false) - expect(context.getBlockedContacts()).to.be.empty - - context.blockContact(id, true) - strictEqual(context.getBlockedCount(), 1) - strictEqual(context.getContact(id).isBlocked(), true) - expect(context.getBlockedContacts()).to.deep.equal([id]) - - context.blockContact(id, false) - strictEqual(context.getBlockedCount(), 0) - strictEqual(context.getContact(id).isBlocked(), false) - expect(context.getBlockedContacts()).to.be.empty - }) - - it('ChatList methods', function () { - const ids = [ - context.createGroupChat('groupchat1'), - context.createGroupChat('groupchat11'), - context.createGroupChat('groupchat111'), - ] - - let chatList = context.getChatList(0, 'groupchat1', null) - strictEqual(chatList.getCount(), 3, 'should contain above chats') - expect(ids.indexOf(chatList.getChatId(0))).not.to.equal(-1) - expect(ids.indexOf(chatList.getChatId(1))).not.to.equal(-1) - expect(ids.indexOf(chatList.getChatId(2))).not.to.equal(-1) - - const lot = chatList.getSummary(0) - strictEqual(lot.getId(), 0, 'lot has no id') - strictEqual(lot.getState(), C.DC_STATE_IN_NOTICED, 'correct state') - - const text = 'Others will only see this group after you sent a first message.' - context.createGroupChat('groupchat1111') - chatList = context.getChatList(0, 'groupchat1111', null) - strictEqual( - chatList.getSummary(0).getText2(), - text, - 'custom new group message' - ) - - context.setChatVisibility(ids[0], C.DC_CHAT_VISIBILITY_ARCHIVED) - chatList = context.getChatList(C.DC_GCL_ARCHIVED_ONLY, 'groupchat1', null) - strictEqual(chatList.getCount(), 1, 'only one archived') - }) - - it('Remove quote from (draft) message', function () { - context.addDeviceMessage('test_quote', 'test') - const msgId = context.getChatMessages(10, 0, 0)[0] - const msg = context.messageNew() - - msg.setQuote(context.getMessage(msgId)) - expect(msg.getQuotedMessage()).to.not.be.null - msg.setQuote(null) - expect(msg.getQuotedMessage()).to.be.null - }) -}) - -describe('Integration tests', function () { - this.timeout(60 * 5 * 1000) // increase timeout to 5 min - - let [dc, context, accountId, directory, account] = [ - null, - null, - null, - null, - null, - ] - - let [dc2, context2, accountId2, directory2, account2] = [ - null, - null, - null, - null, - null, - ] - - this.beforeEach(async function () { - let tmp = DeltaChat.newTemporary() - dc = tmp.dc - context = tmp.context - accountId = tmp.accountId - directory = tmp.directory - dc.startEvents() - }) - - this.afterEach(async function () { - if (context) { - try { - context.stopOngoingProcess() - } catch (error) { - console.error(error) - } - } - if (context2) { - try { - context2.stopOngoingProcess() - } catch (error) { - console.error(error) - } - } - - if (dc) { - try { - dc.stopIO() - dc.close() - } catch (error) { - console.error(error) - } - } - - dc = null - context = null - accountId = null - directory = null - - context2 = null - accountId2 = null - directory2 = null - }) - - this.beforeAll(async function () { - account = createTempUser(process.env.CHATMAIL_DOMAIN) - if (!account || !account.email || !account.password) { - console.log( - "We didn't got back an account from the api, skip integration tests" - ) - this.skip() - } - }) - - it('configure', async function () { - strictEqual(context.isConfigured(), false, 'should not be configured') - - // Not sure what's the best way to check the events - // TODO: check the events - - // dc.once('DC_EVENT_CONFIGURE_PROGRESS', (data) => { - // t.pass('DC_EVENT_CONFIGURE_PROGRESS called at least once') - // }) - // dc.on('DC_EVENT_ERROR', (error) => { - // console.error('DC_EVENT_ERROR', error) - // }) - // dc.on('DC_EVENT_ERROR_NETWORK', (first, error) => { - // console.error('DC_EVENT_ERROR_NETWORK', error) - // }) - - // dc.on('ALL', (event, data1, data2) => console.log('ALL', event, data1, data2)) - - await expect( - context.configure({ - addr: account.email, - mail_pw: account.password, - - displayname: 'Delta One', - selfstatus: 'From Delta One with <3', - selfavatar: join(__dirname, 'fixtures', 'avatar.png'), - }) - ).to.be.eventually.fulfilled - - strictEqual(context.getConfig('addr'), account.email, 'addr correct') - strictEqual( - context.getConfig('displayname'), - 'Delta One', - 'displayName correct' - ) - strictEqual( - context.getConfig('selfstatus'), - 'From Delta One with <3', - 'selfStatus correct' - ) - expect( - context.getConfig('selfavatar').endsWith('avatar.png'), - 'selfavatar correct' - ) - strictEqual(context.getConfig('e2ee_enabled'), '1', 'e2ee_enabled correct') - strictEqual( - context.getConfig('save_mime_headers'), - '', - 'save_mime_headers correct' - ) - - expect(context.getBlobdir().endsWith('db.sqlite-blobs'), 'correct blobdir') - strictEqual(context.isConfigured(), true, 'is configured') - - // whole re-configure to only change displayname: what the heck? (copied this from the old test) - await expect( - context.configure({ - addr: account.email, - mail_pw: account.password, - displayname: 'Delta Two', - selfstatus: 'From Delta One with <3', - selfavatar: join(__dirname, 'fixtures', 'avatar.png'), - }) - ).to.be.eventually.fulfilled - strictEqual( - context.getConfig('displayname'), - 'Delta Two', - 'updated displayName correct' - ) - }) - - it('Autocrypt setup - key transfer', async function () { - // Spawn a second dc instance with same account - // dc.on('ALL', (event, data1, data2) => - // console.log('FIRST ', event, data1, data2) - // ) - dc.stopIO() - await expect( - context.configure({ - addr: account.email, - mail_pw: account.password, - - displayname: 'Delta One', - selfstatus: 'From Delta One with <3', - selfavatar: join(__dirname, 'fixtures', 'avatar.png'), - }) - ).to.be.eventually.fulfilled - - const accountId2 = dc.addAccount() - console.log('accountId2:', accountId2) - context2 = dc.accountContext(accountId2) - - let setupCode = null - const waitForSetupCode = waitForSomething() - const waitForEnd = waitForSomething() - - dc.on('ALL', (event, accountId, data1, data2) => { - console.log('[' + accountId + ']', event, data1, data2) - }) - - dc.on('DC_EVENT_MSGS_CHANGED', async (aId, chatId, msgId) => { - console.log('[' + accountId + '] DC_EVENT_MSGS_CHANGED', chatId, msgId) - if ( - aId != accountId || - !context.getChat(chatId).isSelfTalk() || - !context.getMessage(msgId).isSetupmessage() - ) { - return - } - console.log('Setupcode!') - let setupCode = await waitForSetupCode.promise - // console.log('incoming msg', { setupCode }) - const messages = context.getChatMessages(chatId, 0, 0) - expect(messages.indexOf(msgId) !== -1, 'msgId is in chat messages').to.be - .true - const result = await context.continueKeyTransfer(msgId, setupCode) - expect(result === true, 'continueKeyTransfer was successful').to.be.true - - waitForEnd.done() - }) - - dc.stopIO() - await expect( - context2.configure({ - addr: account.email, - mail_pw: account.password, - - displayname: 'Delta One', - selfstatus: 'From Delta One with <3', - selfavatar: join(__dirname, 'fixtures', 'avatar.png'), - }) - ).to.be.eventually.fulfilled - dc.startIO() - - console.log('Sending autocrypt setup code') - setupCode = await context2.initiateKeyTransfer() - console.log('Sent autocrypt setup code') - waitForSetupCode.done(setupCode) - console.log('setupCode is: ' + setupCode) - expect(typeof setupCode).to.equal('string', 'setupCode is string') - - await waitForEnd.promise - }) - - it('configure using invalid password should fail', async function () { - await expect( - context.configure({ - addr: 'hpk5@testrun.org', - mail_pw: 'asd', - }) - ).to.be.eventually.rejected - }) -}) - -/** - * @returns {{done: (result?)=>void, promise:Promise }} - */ -function waitForSomething() { - let resolvePromise - const promise = new Promise((res, rej) => { - resolvePromise = res - }) - return { - done: resolvePromise, - promise, - } -} diff --git a/node/tsconfig.json b/node/tsconfig.json deleted file mode 100644 index 25ce300f2..000000000 --- a/node/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "outDir": "dist", - "rootDir": "./lib", - "sourceMap": true, - "module": "commonjs", - "target": "es5", - "esModuleInterop": true, - "declaration": true, - "declarationMap": true, - "strictNullChecks": true, - "strict": true - }, - "exclude": ["node_modules", "deltachat-core-rust", "dist", "scripts"], - "typedocOptions": { - "out": "docs", - "excludePrivate": true, - "defaultCategory": "index", - "includeVersion": true, - "entryPoints": ["lib/index.ts"] - } -} \ No newline at end of file diff --git a/node/windows.md b/node/windows.md deleted file mode 100644 index df19b03d7..000000000 --- a/node/windows.md +++ /dev/null @@ -1,37 +0,0 @@ -> Steps on how to get windows set up properly for the node bindings - -## install git - -E.g via - -## install node - -Download and install `v18` from - -## install rust - -Download and run `rust-init.exe` from - -## configure node for native addons - -``` -$ npm i node-gyp -g -$ npm i windows-build-tools -g -``` - -`windows-build-tools` will install `Visual Studio 2017` by default and should not mess with existing installations of `Visual Studio C++`. - -## get the code - -``` -$ mkdir -p src/deltachat -$ cd src/deltachat -$ git clone https://github.com/deltachat/deltachat-node -``` - -## build the code - -``` -$ cd src/deltachat/deltachat-node -$ npm install -``` diff --git a/package.json b/package.json deleted file mode 100644 index 082616c3d..000000000 --- a/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "dependencies": { - "debug": "^4.1.1", - "napi-macros": "^2.0.0", - "node-gyp-build": "^4.6.1" - }, - "description": "node.js bindings for deltachat-core", - "devDependencies": { - "@types/debug": "^4.1.7", - "@types/node": "^20.8.10", - "chai": "~4.3.10", - "chai-as-promised": "^7.1.1", - "mocha": "^8.2.1", - "node-gyp": "~10.1.0", - "prebuildify": "^5.0.1", - "prebuildify-ci": "^1.0.5", - "prettier": "^3.0.3", - "typedoc": "^0.25.3", - "typescript": "^5.2.2" - }, - "engines": { - "node": ">=18.0.0" - }, - "files": [ - "node/scripts/*", - "*" - ], - "homepage": "https://github.com/deltachat/deltachat-core-rust/tree/master/node", - "license": "GPL-3.0-or-later", - "main": "node/dist/index.js", - "name": "deltachat-node", - "repository": { - "type": "git", - "url": "https://github.com/deltachat/deltachat-core-rust.git" - }, - "scripts": { - "build": "npm run build:core && npm run build:bindings", - "build:bindings": "npm run build:bindings:c && npm run build:bindings:ts", - "build:bindings:c": "npm run build:bindings:c:c && npm run build:bindings:c:postinstall", - "build:bindings:c:c": "cd node && node-gyp rebuild", - "build:bindings:c:postinstall": "node node/scripts/postinstall.js", - "build:bindings:ts": "cd node && tsc", - "build:core": "npm run build:core:rust && npm run build:core:constants", - "build:core:constants": "node node/scripts/generate-constants.js", - "build:core:rust": "node node/scripts/rebuild-core.js", - "clean": "rm -rf node/dist node/build node/prebuilds node/node_modules ./target", - "download-prebuilds": "prebuildify-ci download", - "install": "node node/scripts/install.js", - "install:prebuilds": "cd node && node-gyp-build \"npm run build:core\" \"npm run build:bindings:c:postinstall\"", - "lint": "prettier --check \"node/lib/**/*.{ts,tsx}\"", - "lint-fix": "prettier --write \"node/lib/**/*.{ts,tsx}\" \"node/test/**/*.js\"", - "prebuildify": "cd node && prebuildify -t 18.0.0 --napi --strip --postinstall \"node scripts/postinstall.js --prebuild\"", - "test": "npm run test:lint && npm run test:mocha", - "test:lint": "npm run lint", - "test:mocha": "mocha node/test/test.mjs --growl --reporter=spec --bail --exit" - }, - "types": "node/dist/index.d.ts", - "version": "1.155.5" -}