diff --git a/.github/workflows/include-check-cache.yml b/.github/workflows/include-check-cache.yml
index 98cb33a9ed..e22d5a98d2 100644
--- a/.github/workflows/include-check-cache.yml
+++ b/.github/workflows/include-check-cache.yml
@@ -35,8 +35,6 @@ on:
value: ${{ jobs.android.outputs.packages-android-cache-hit }}
android-test-base-apk-cache-hit:
value: ${{ jobs.android-test-base.outputs.android-test-base-apk-cache-hit }}
- android-test-sync-apk-cache-hit:
- value: ${{ jobs.android-test-sync.outputs.android-test-sync-apk-cache-hit }}
packages-macos-x64-cache-hit:
value: ${{ jobs.macos-x64.outputs.packages-macos-x64-cache-hit }}
packages-macos-arm64-cache-hit:
@@ -295,36 +293,6 @@ jobs:
path: ./packages/test-base/build/outputs/apk/androidTest/debug/test-base-debug-androidTest.apk
retention-days: 1
- #
- # Android Sync Test APK
- #
- android-test-sync:
- runs-on: ubuntu-latest
- needs: checksum
- name: Android Sync Test APK
- outputs:
- android-test-sync-apk-cache-hit: ${{ steps.android-test-sync-apk.outputs.cache-hit }}
-
- steps:
- - name: Check Android Sync Test APK
- id: android-test-sync-apk
- uses: actions/cache@v4
- with:
- key: android-sync-test-apk-key-${{ needs.checksum.outputs.packages-sha }}
- path: |
- ./packages/test-sync/build/outputs/apk/androidTest/debug/test-sync-debug-androidTest.apk
- ./packages/test-sync/build/outputs/apk/debug/test-sync-debug.apk
-
- - name: Save Android Sync Test APK
- uses: actions/upload-artifact@v4
- if: always() && !cancelled() && steps.android-test-sync-apk.outputs.cache-hit == 'true'
- with:
- name: android-sync-test-apk-${{ needs.checksum.outputs.version-label }}
- retention-days: 1
- path: |
- ./packages/test-sync/build/outputs/apk/androidTest/debug/test-sync-debug-androidTest.apk
- ./packages/test-sync/build/outputs/apk/debug/test-sync-debug.apk
-
#
# MacOS arm64
#
diff --git a/.github/workflows/include-integration-tests.yml b/.github/workflows/include-integration-tests.yml
index 2d3349ec8e..8149ce46ef 100644
--- a/.github/workflows/include-integration-tests.yml
+++ b/.github/workflows/include-integration-tests.yml
@@ -7,11 +7,6 @@ on:
required: true
type: string
-env:
- REALM_DISABLE_ANALYTICS: true
- REALM_PRINT_ANALYTICS: true
- REALM_FAIL_ON_ANALYTICS_ERRORS: true
-
jobs:
# TODO: The Monkey seems to crash the app all the time, but with failures that are not coming from the app. Figure out why.
diff --git a/.github/workflows/include-static-analysis.yml b/.github/workflows/include-static-analysis.yml
index 60ec663580..6101bbd7cc 100644
--- a/.github/workflows/include-static-analysis.yml
+++ b/.github/workflows/include-static-analysis.yml
@@ -44,7 +44,6 @@ jobs:
rsync -a --delete --ignore-errors examples/kmm-sample/shared/build/reports/ktlint/ /tmp/ktlint/example/ || true
rsync -a --delete --ignore-errors packages/cinterop/build/reports/ktlint/ /tmp/ktlint/cinterop/ || true
rsync -a --delete --ignore-errors packages/library-base/build/reports/ktlint/ /tmp/ktlint/library-base/ || true
- rsync -a --delete --ignore-errors packages/library-sync/build/reports/ktlint/ /tmp/ktlint/library-sync/ || true
rsync -a --delete --ignore-errors packages/plugin-compiler/build/reports/ktlint/ /tmp/ktlint/plugin-compiler/ || true
rsync -a --delete --ignore-errors packages/gradle-plugin/build/reports/ktlint/ /tmp/ktlint/plugin-gradle/ || true
rsync -a --delete --ignore-errors benchmarks/build/reports/ktlint/ /tmp/ktlint/benchmarks/ || true
@@ -95,7 +94,6 @@ jobs:
rsync -a --delete --ignore-errors examples/kmm-sample/shared/build/reports/detekt/ /tmp/detekt/example/ || true
rsync -a --delete --ignore-errors packages/cinterop/build/reports/detekt/ /tmp/detekt/cinterop/ || true
rsync -a --delete --ignore-errors packages/library-base/build/reports/detekt/ /tmp/detekt/library-base/ || true
- rsync -a --delete --ignore-errors packages/library-sync/build/reports/detekt/ /tmp/detekt/library-sync/ || true
rsync -a --delete --ignore-errors packages/plugin-compiler/build/reports/detekt/ /tmp/detekt/plugin-compiler/ || true
rsync -a --delete --ignore-errors packages/gradle-plugin/build/reports/detekt/ /tmp/detekt/plugin-gradle/ || true
rsync -a --delete --ignore-errors benchmarks/build/reports/detekt/ /tmp/detekt/benchmarks/ || true
diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
index bf138c4591..a4c9ef5d13 100644
--- a/.github/workflows/pr.yml
+++ b/.github/workflows/pr.yml
@@ -14,8 +14,6 @@ concurrency:
cancel-in-progress: true
env:
- REALM_DISABLE_ANALYTICS: true
- REALM_PRINT_ANALYTICS: true
CMAKE_C_COMPILER: /usr/local/bin/ccache-clang
CMAKE_CXX_COMPILER: /usr/local/bin/ccache-clang++
# Workflow environment variables are not available in Job if statements: https://github.com/actions/runner/issues/1661
@@ -147,7 +145,6 @@ jobs:
mkdir realmLinuxBuild
cd realmLinuxBuild
cmake -DCMAKE_BUILD_TYPE=Release \
- -DREALM_ENABLE_SYNC=1 \
-DREALM_NO_TESTS=1 \
-DREALM_BUILD_LIB_ONLY=true \
-DCMAKE_CXX_VISIBILITY_PRESET=hidden \
@@ -220,7 +217,6 @@ jobs:
..\..\src\jvm `
-DCMAKE_GENERATOR_PLATFORM=x64 `
-DCMAKE_BUILD_TYPE=Release `
- -DREALM_ENABLE_SYNC=ON `
-DREALM_NO_TESTS=1 `
-DCMAKE_CXX_VISIBILITY_PRESET=hidden `
-DVCPKG_TARGET_TRIPLET=x64-windows-static
@@ -537,8 +533,7 @@ jobs:
if: |
always() && !cancelled() &&
(needs.check-cache.outputs.packages-android-cache-hit != 'true' ||
- needs.check-cache.outputs.android-test-base-apk-cache-hit != 'true' ||
- needs.check-cache.outputs.android-test-sync-apk-cache-hit != 'true')
+ needs.check-cache.outputs.android-test-base-apk-cache-hit != 'true')
steps:
- name: Remove unnecessary files
@@ -627,10 +622,6 @@ jobs:
working-directory: packages
run: ./gradlew :test-base:assembleAndroidTest -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.mainHost=false
- - name: Build Android Sync Test Apk
- working-directory: packages
- run: ./gradlew :test-sync:packageDebug :test-sync:assembleAndroidTest -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.mainHost=false
-
- name: Build packages
working-directory: packages
run: ./gradlew publishCIPackages -Prealm.kotlin.targets=android -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.mainHost=false
@@ -647,15 +638,6 @@ jobs:
path: ./packages/test-base/build/outputs/apk/androidTest/debug/test-base-debug-androidTest.apk
key: android-base-test-apk-key-${{ needs.check-cache.outputs.packages-sha }}
- # Must match naming found in include-check-cache.yml
- - name: Store build cache for Android Sync Test APK
- uses: actions/cache@v4
- with:
- key: android-sync-test-apk-key-${{ needs.check-cache.outputs.packages-sha }}
- path: |
- ./packages/test-sync/build/outputs/apk/androidTest/debug/test-sync-debug-androidTest.apk
- ./packages/test-sync/build/outputs/apk/debug/test-sync-debug.apk
-
# Must match naming found in include-check-cache.yml
# Must match naming found in include-check-cache.yml
- name: Upload artifacts
@@ -672,16 +654,6 @@ jobs:
path: ./packages/test-base/build/outputs/apk/androidTest/debug/test-base-debug-androidTest.apk
retention-days: 1
- - name: Upload Android Sync Test APK
- uses: actions/upload-artifact@v4
- with:
- name: android-sync-test-apk-${{ needs.check-cache.outputs.version-label }}
- retention-days: 1
- path: |
- ./packages/test-sync/build/outputs/apk/androidTest/debug/test-sync-debug-androidTest.apk
- ./packages/test-sync/build/outputs/apk/debug/test-sync-debug.apk
-
-
# TODO: ccache is not being used by this build for some reason
build-macos-x64-packages:
runs-on: macos-14 # x64 builds fine on an arm64 node
@@ -973,25 +945,15 @@ jobs:
path: ./packages/build/m2-buildrepo/**/*
retention-days: 1
-
- # TODO Split into base and sync tests
- # TODO If we hook up to Device Farm we can use ubuntu runners instead
- # TODO Compare speed between emulator and Device Farm
- # TODO We should be able to move this into a reusable work-flow
-
- # TODO Compare speed between emulator and Device Farm
- # TODO We should be able to move this into a reusable work-flow
test-android-packages-emulator:
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
- type: [base, sync]
+ type: [base]
include:
- type: base
test-title: Unit Test Results - Android Base (Emulator)
- - type: sync
- test-title: Unit Test Results - Android Sync (Emulator)
runs-on: macos-12 # android emulator does not run on arm64 - https://github.com/ReactiveCircus/android-emulator-runner/issues/350
needs: [check-cache, build-android-packages, build-jvm-packages, build-kotlin-metadata-package]
@@ -1007,27 +969,6 @@ jobs:
with:
submodules: "recursive"
- # checkout BAAS CLI repo
- - name: Checkout BAAS repo
- if: matrix.type == 'sync'
- run: |
- echo ${{ secrets.BAAS_CLI }} | gh auth login --with-token
- gh repo clone 10gen/baasaas
-
- # Start BAAS instance in the background
- # We save the container id to poll against and get the hostname info later
- - name: Start Baas instance in the background
- id: baas_cli_start
- if: matrix.type == 'sync'
- working-directory: baasaas
- env:
- APIKEY: ${{ secrets.BAAS_CLI_API_KEY }}
- run: |
- # Adding a dummy tag (foo=bar) to avoid the following issue on macos-runner
- # curl: option --data: error encountered when reading a file
- OUTPUT=$(bash cli.sh start | jq -r '.id')
- echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT
-
- name: Setup Java 11
uses: actions/setup-java@v4
with:
@@ -1057,17 +998,6 @@ jobs:
name: packages-jvm-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
- # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests
- - name: Fetching the BAAS CLI hostname
- id: baas_cli_poll
- if: matrix.type == 'sync'
- working-directory: baasaas
- env:
- APIKEY: ${{ secrets.BAAS_CLI_API_KEY }}
- run: |
- OUTPUT=$(bash cli.sh poll ${{ steps.baas_cli_start.outputs.baas_container_id }} | jq -r '.httpUrl')
- echo "baas_container_hostname=$OUTPUT" >> $GITHUB_OUTPUT
-
# TODO This action does not support using `\` to split multiline scripts.
- name: Run Integration Tests
env:
@@ -1086,7 +1016,7 @@ jobs:
script: |
adb logcat -c
adb logcat > logcat.txt &
- cd packages && ./gradlew :test-${{ matrix.type }}:connectedCheck -PsyncUsePlatformNetworking=true -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }} -PincludeSdkModules=false --info --no-daemon
+ cd packages && ./gradlew :test-${{ matrix.type }}:connectedCheck -PincludeSdkModules=false --info --no-daemon
- name: Archive LogCat data
uses: actions/upload-artifact@v4
@@ -1107,161 +1037,24 @@ jobs:
list-tests: failed
fail-on-error: true
- - name: Stopping the BAAS container
- if: always() && matrix.type == 'sync'
- working-directory: baasaas
- env:
- APIKEY: ${{ secrets.BAAS_CLI_API_KEY }}
- run: |
- if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then
- bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }}
- fi
-
- # Disable device farm test for Base, because running two in parallel seems to interfer somehow
- test-android-packages-device-farm:
- name: AWS Device Farm
- timeout-minutes: 60
- runs-on: ubuntu-latest
- needs: [ check-cache, build-android-packages, build-jvm-packages ]
- if: |
- false &&
- always() &&
- !cancelled() &&
- !contains(needs.*.result, 'failure') &&
- !contains(needs.*.result, 'cancelled')
-
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Restore Android Test APK
- uses: actions/download-artifact@v4
- with:
- name: android-base-test-apk-${{ needs.check-cache.outputs.version-label }}
- path: ./packages/test-base/build/outputs/apk/androidTest/debug
-
- - name: Configure AWS Credentials
- uses: aws-actions/configure-aws-credentials@v4
- with:
- aws-access-key-id: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }}
- aws-secret-access-key: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }}
- aws-region: us-west-2
-
- - name: Run the tests
- uses: ./.github/actions/run-android-device-farm-test
- id: run_android_tests
- with:
- apk-path: ${{ github.workspace }}/packages/test-base/build/outputs/apk/androidTest/debug/test-base-debug-androidTest.apk
- app-id: io.realm.testapp
- project-arn: ${{ secrets.DEVICEFARM_PROJECT_ARN }}
- device-pool-arn: ${{ secrets.DEVICEFARM_POOL_ARN }}
-
-
- test-android-packages-device-farm-sync:
- name: AWS Device Farm Sync Tests
- timeout-minutes: 60
- runs-on: ubuntu-latest
- needs: [ check-cache, build-android-packages, build-jvm-packages ]
- if: |
- always() &&
- !cancelled() &&
- !contains(needs.*.result, 'failure') &&
- !contains(needs.*.result, 'cancelled') &&
- endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') &&
- (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' || github.ref == 'refs/heads/release/k2')
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- # checkout BAAS CLI repo
- - name: Checkout BAAS repo
- run: |
- echo ${{ secrets.BAAS_CLI }} | gh auth login --with-token
- gh repo clone 10gen/baasaas
-
- # Start BAAS instance in the background
- # We save the container id to poll against and get the hostname info later
- - name: Start Baas instance in the background
- id: baas_cli_start
- working-directory: baasaas
- env:
- APIKEY: ${{ secrets.BAAS_CLI_API_KEY }}
- run: |
- OUTPUT=$(bash cli.sh start | jq -r '.id')
- echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT
-
- - name: Restore Android Sync Test APK
- uses: actions/download-artifact@v4
- with:
- name: android-sync-test-apk-${{ needs.check-cache.outputs.version-label }}
- path: ./packages/test-sync/build/outputs/apk/
-
- - name: Configure AWS Credentials
- uses: aws-actions/configure-aws-credentials@v4
- with:
- aws-access-key-id: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }}
- aws-secret-access-key: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }}
- aws-region: us-west-2
-
- # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests
- - name: Fetching the BAAS CLI hostname
- id: baas_cli_poll
- working-directory: baasaas
- env:
- APIKEY: ${{ secrets.BAAS_CLI_API_KEY }}
- run: |
- OUTPUT=$(bash cli.sh poll ${{ steps.baas_cli_start.outputs.baas_container_id }} | jq -r '.httpUrl')
- echo "baas_container_hostname=$OUTPUT" >> $GITHUB_OUTPUT
-
- - name: Run the Sync tests
- uses: ./.github/actions/run-android-device-farm-test
- id: run_android_tests
- with:
- apk-path: ${{ github.workspace }}/packages/test-sync/build/outputs/apk/androidTest/debug/test-sync-debug-androidTest.apk
- apk-auxiliary-path: ${{ github.workspace }}/packages/test-sync/build/outputs/apk/debug/test-sync-debug.apk
- baas_url: ${{ steps.baas_cli_poll.outputs.baas_container_hostname }}
- app-id: io.realm.sync.testapp.test
- project-arn: ${{ secrets.DEVICEFARM_PROJECT_ARN }}
- device-pool-arn: ${{ secrets.DEVICEFARM_POOL_ARN }}
-
- - name: Stopping the BAAS container
- if: always()
- working-directory: baasaas
- env:
- APIKEY: ${{ secrets.BAAS_CLI_API_KEY }}
- run: |
- if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then
- bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }}
- fi
-
test-macos-packages:
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
os: [macos-12, macos-14]
- type: [base, sync]
+ type: [base]
include:
- os: macos-12
type: base
os-id: macos
package-prefix: macos-x64
test-title: Unit Test Results - MacOS x64 Base
- - os: macos-12
- type: sync
- os-id: macos
- package-prefix: macos-x64
- test-title: Unit Test Results - MacOS x64 Sync
- os: macos-14
type: base
os-id: macos
package-prefix: macos-arm64
test-title: Unit Test Results - MacOS arm64 Base
- - os: macos-14
- type: sync
- os-id: macos
- package-prefix: macos-arm64
- test-title: Unit Test Results - MacOS arm64 Sync
runs-on: ${{ matrix.os }}
# TODO Unclear why MacOS needs the metadata package when the Android Tests do not
@@ -1277,27 +1070,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- # checkout BAAS CLI repo
- - name: Checkout BAAS repo
- if: matrix.type == 'sync'
- run: |
- echo ${{ secrets.BAAS_CLI }} | gh auth login --with-token
- gh repo clone 10gen/baasaas
-
- # Start BAAS instance in the background
- # We save the container id to poll against and get the hostname info later
- - name: Start Baas instance in the background
- id: baas_cli_start
- if: matrix.type == 'sync'
- working-directory: baasaas
- env:
- APIKEY: ${{ secrets.BAAS_CLI_API_KEY }}
- run: |
- # Adding a dummy tag (foo=bar) to avoid the following issue on macos-runner
- # curl: option --data: error encountered when reading a file
- OUTPUT=$(bash cli.sh start | jq -r '.id')
- echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT
-
- name: Setup Java 11
uses: actions/setup-java@v4
with:
@@ -1321,23 +1093,10 @@ jobs:
name: packages-metadata-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
-
- # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests
- - name: Fetching the BAAS CLI hostname
- id: baas_cli_poll
- if: matrix.type == 'sync'
- working-directory: baasaas
- env:
- APIKEY: ${{ secrets.BAAS_CLI_API_KEY }}
- run: |
- OUTPUT=$(bash cli.sh poll ${{ steps.baas_cli_start.outputs.baas_container_id }} | jq -r '.httpUrl')
- echo "baas_container_hostname=$OUTPUT" >> $GITHUB_OUTPUT
-
- name: Run tests
working-directory: packages
run: >
./gradlew :test-${{ matrix.type }}:macosTest
- -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }}
-PincludeSdkModules=false
--info --no-daemon
@@ -1352,45 +1111,24 @@ jobs:
list-tests: failed
fail-on-error: true
- - name: Stopping the BAAS container
- if: always() && matrix.type == 'sync'
- working-directory: baasaas
- env:
- APIKEY: ${{ secrets.BAAS_CLI_API_KEY }}
- run: |
- if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then
- bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }}
- fi
-
-
test-ios-packages:
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
os: [macos-12, macos-14]
- type: [base, sync]
+ type: [base]
include:
- os: macos-12
type: base
package-prefix: x64
test-title: Unit Test Results - iOS x64 Base
test-task: iosTest
- - os: macos-12
- type: sync
- package-prefix: x64
- test-title: Unit Test Results - iOS x64 Sync
- test-task: iosTest
- os: macos-14
type: base
package-prefix: arm64
test-title: Unit Test Results - iOS arm64 Base
test-task: iosTest
- - os: macos-14
- type: sync
- package-prefix: arm64
- test-title: Unit Test Results - iOS arm64 Sync
- test-task: iosTest
runs-on: ${{ matrix.os }}
# TODO Unclear why MacOS needs the metadata package when the Android Tests do not
@@ -1406,27 +1144,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- # checkout BAAS CLI repo
- - name: Checkout BAAS repo
- if: matrix.type == 'sync'
- run: |
- echo ${{ secrets.BAAS_CLI }} | gh auth login --with-token
- gh repo clone 10gen/baasaas
-
- # Start BAAS instance in the background
- # We save the container id to poll against and get the hostname info later
- - name: Start Baas instance in the background
- id: baas_cli_start
- if: matrix.type == 'sync'
- working-directory: baasaas
- env:
- APIKEY: ${{ secrets.BAAS_CLI_API_KEY }}
- run: |
- # Adding a dummy tag (foo=bar) to avoid the following issue on macos-runner
- # curl: option --data: error encountered when reading a file
- OUTPUT=$(bash cli.sh start | jq -r '.id')
- echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT
-
- name: Setup Java 11
uses: actions/setup-java@v4
with:
@@ -1451,23 +1168,11 @@ jobs:
path: ./packages/build/m2-buildrepo
- # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests
- - name: Fetching the BAAS CLI hostname
- id: baas_cli_poll
- if: matrix.type == 'sync'
- working-directory: baasaas
- env:
- APIKEY: ${{ secrets.BAAS_CLI_API_KEY }}
- run: |
- OUTPUT=$(bash cli.sh poll ${{ steps.baas_cli_start.outputs.baas_container_id }} | jq -r '.httpUrl')
- echo "baas_container_hostname=$OUTPUT" >> $GITHUB_OUTPUT
-
# App names are limited to 32 characters, so the appNamePrefix should not exceed 22 characters.
- name: Run tests
working-directory: packages
run: >
./gradlew :test-${{ matrix.type }}:${{ matrix.test-task }}
- -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }}
-PincludeSdkModules=false
--info --no-daemon
@@ -1482,23 +1187,13 @@ jobs:
list-tests: failed
fail-on-error: true
- - name: Stopping the BAAS container
- if: always() && matrix.type == 'sync'
- working-directory: baasaas
- env:
- APIKEY: ${{ secrets.BAAS_CLI_API_KEY }}
- run: |
- if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then
- bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }}
- fi
-
test-jvm-packages:
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
os: [macos-12, macos-14, ubuntu-latest, windows-latest]
- type: [base, sync]
+ type: [base]
include:
- os: macos-12
os-id: mac
@@ -1516,25 +1211,6 @@ jobs:
os-id: win
type: base
test-title: Unit Test Results - Base JVM Windows
- - os: macos-12
- os-id: mac
- type: sync
- test-title: Unit Test Results - Sync JVM MacOS x64
- - os: macos-14
- os-id: mac
- type: sync
- test-title: Unit Test Results - Sync JVM MacOS arm64
- - os: ubuntu-latest
- os-id: ubu
- type: sync
- test-title: Unit Test Results - Sync JVM Linux
- exclude:
- # Do not run Windows Sync Tests, because the bash script for
- # starting the BAAS container doesn not work on Windows.
- - os: windows-latest
- #os-id: win
- type: sync
- #test-title: Unit Test Results - Sync JVM Windows
runs-on: ${{ matrix.os }}
needs: [check-cache, build-jvm-packages, build-kotlin-metadata-package]
@@ -1548,27 +1224,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- # checkout BAAS CLI repo
- - name: Checkout BAAS repo
- if: matrix.type == 'sync'
- run: |
- echo ${{ secrets.BAAS_CLI }} | gh auth login --with-token
- gh repo clone 10gen/baasaas
-
- # Start BAAS instance in the background
- # We save the container id to poll against and get the hostname info later
- - name: Start Baas instance in the background
- id: baas_cli_start
- if: matrix.type == 'sync'
- working-directory: baasaas
- env:
- APIKEY: ${{ secrets.BAAS_CLI_API_KEY }}
- run: |
- # Adding a dummy tag (foo=bar) to avoid the following issue on macos-runner
- # curl: option --data: error encountered when reading a file
- OUTPUT=$(bash cli.sh start | jq -r '.id')
- echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT
-
- name: Setup Java 11
uses: actions/setup-java@v4
with:
@@ -1592,24 +1247,11 @@ jobs:
name: packages-jvm-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
- # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests
- - name: Fetching the BAAS CLI hostname
- id: baas_cli_poll
- if: matrix.type == 'sync'
- working-directory: baasaas
- env:
- APIKEY: ${{ secrets.BAAS_CLI_API_KEY }}
- run: |
- OUTPUT=$(bash cli.sh poll ${{ steps.baas_cli_start.outputs.baas_container_id }} | jq -r '.httpUrl')
- echo "baas_container_hostname=$OUTPUT" >> $GITHUB_OUTPUT
-
# App names are limited to 32 characters, so the appNamePrefix should not exceed 22 characters.
- name: Run tests
working-directory: packages
run: >
./gradlew :test-${{ matrix.type }}:jvmTest
- -PsyncUsePlatformNetworking=true
- -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }}
-PincludeSdkModules=false
--info --no-daemon
@@ -1624,16 +1266,6 @@ jobs:
list-tests: failed
fail-on-error: true
- - name: Stopping the BAAS container
- if: always() && matrix.type == 'sync'
- working-directory: baasaas
- env:
- APIKEY: ${{ secrets.BAAS_CLI_API_KEY }}
- run: |
- if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then
- bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }}
- fi
-
package-all-artifacts:
runs-on: ubuntu-latest
needs: [check-cache, build-jvm-packages, build-android-packages, build-macos-x64-packages, build-macos-arm64-packages, build-ios-x64-packages, build-ios-arm64-packages, build-kotlin-metadata-package]
@@ -1719,8 +1351,6 @@ jobs:
test-macos-packages,
test-ios-packages,
test-android-packages-emulator,
- # test-android-packages-device-farm,
- test-android-packages-device-farm-sync,
package-all-artifacts
]
if: |
@@ -1782,8 +1412,6 @@ jobs:
test-macos-packages,
test-ios-packages,
test-android-packages-emulator,
- # test-android-packages-device-farm,
- test-android-packages-device-farm-sync,
package-all-artifacts
]
if: |
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 19f4386c27..8ff1cac353 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,8 @@
+
## 3.0.0-SNAPSHOT (YYYY-MM-DD)
### Breaking Changes
-* None.
+* [Sync] Atlas Device Sync related functionality has been removed from the project.
### Enhancements
* None.
@@ -33,6 +34,36 @@
### Breaking Changes
* None.
+### Enhancements
+* None.
+
+### Fixed
+* Via https://github.com/realm/realm-kotlin/pull/1826. Fix compiler crash caused by a change in Kotlin 2.0.20. (Issue [#1825](https://github.com/realm/realm-kotlin/issues/1825)). Thanks @KitsuneAlex.
+
+### Compatibility
+* File format: Generates Realms with file format v24 (reads and upgrades file format v10 or later).
+* Realm Studio 15.0.0 or above is required to open Realms created by this version.
+* This release is compatible with the following Kotlin releases:
+ * Kotlin 2.0.20 and above. Support for experimental K2-compilation with `kotlin.experimental.tryK2=true`.
+ * Ktor 2.1.2 and above.
+ * Coroutines 1.7.0 and above.
+ * AtomicFu 0.18.3 and above.
+ * The new memory model only. See https://github.com/realm/realm-kotlin#kotlin-memory-model-and-coroutine-compatibility
+* Minimum Kbson 0.4.0.
+* Minimum Gradle version: 7.2.
+* Minimum Android Gradle Plugin version: 7.1.3.
+* Minimum Android SDK: 16.
+* Minimum R8: 8.0.34.
+
+### Internal
+* None.
+
+
+## 2.2.0 (2024-09-13)
+
+### Breaking Changes
+* None.
+
### Enhancements
* Support Android 15 page size 16 KB. (Issue [#1787](https://github.com/realm/realm-kotlin/issues/1787) [JIRA](https://jira.mongodb.org/browse/RKOTLIN-1105)).
* Reduce the size of the local transaction log produced by creating objects, improving the performance of insertion-heavy transactions (Core issue [realm/realm-core#7734](https://github.com/realm/realm-core/pull/7734)).
@@ -49,7 +80,6 @@
* [Sync] Client reset cycle detection now checks if the previous recovery attempt was made by the same core version, and if not attempts recovery again (Core issue [realm/realm-core#7944](https://github.com/realm/realm-core/pull/7944)).
### Fixed
-* Via https://github.com/realm/realm-kotlin/pull/1826. Fix compiler crash caused by a change in Kotlin 2.0.20. (Issue [#1825](https://github.com/realm/realm-kotlin/issues/1825)). Thanks @KitsuneAlex.
* Comparing a numeric property with an argument list containing a string would throw. (Core issue [realm/realm-core#7714](https://github.com/realm/realm-core/issues/7714), since v2.0.0).
* After compacting, a file upgrade would be triggered. This could cause loss of data if schema mode is SoftResetFile (Core issue [realm/realm-core#7747](https://github.com/realm/realm-core/issues/7747), since v1.15.0).
* Encrypted files on Windows had a maximum size of 2GB even on x64 due to internal usage of `off_t`, which is a 32-bit type on 64-bit Windows (Core issue [realm/realm-core#7698](https://github.com/realm/realm-core/pull/7698)).
@@ -93,36 +123,6 @@
* Updated to Sync protocol version 14 to support server intiated bootstraps and role change updates without a client reset. (Core issue [realm/realm-core#7440](https://github.com/realm/realm-core/pull/7440)).
-## 2.1.1-SNAPSHOT (YYYY-MM-DD)
-
-### Breaking Changes
-* None.
-
-### Enhancements
-* None.
-
-### Fixed
-* None.
-
-### Compatibility
-* File format: Generates Realms with file format v24 (reads and upgrades file format v10 or later).
-* Realm Studio 15.0.0 or above is required to open Realms created by this version.
-* This release is compatible with the following Kotlin releases:
- * Kotlin 2.0.0 and above. Support for experimental K2-compilation with `kotlin.experimental.tryK2=true`.
- * Ktor 2.1.2 and above.
- * Coroutines 1.7.0 and above.
- * AtomicFu 0.18.3 and above.
- * The new memory model only. See https://github.com/realm/realm-kotlin#kotlin-memory-model-and-coroutine-compatibility
-* Minimum Kbson 0.4.0.
-* Minimum Gradle version: 7.2.
-* Minimum Android Gradle Plugin version: 7.1.3.
-* Minimum Android SDK: 16.
-* Minimum R8: 8.0.34.
-
-### Internal
-* None.
-
-
## 2.1.0 (2024-07-12)
### Breaking Changes
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 0cd3db7f53..385832da54 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -50,10 +50,6 @@ platforms with:
cd packages
./gradlew :test-base:jvmTest :test-base:connectedAndroidTest :test-base:macosTest :test-base:iosTest
-# Note that running the test-sync suite requires running a local server
-# (see `tools/sync_test_server/start_local_server.sh` and `tools/sync_test_server/stop_local_server.sh`)
-
-./gradlew :test-sync:jvmTest :test-sync:connectedAndroidTest :test-sync:macosTest :test-sync:iosTest
```
You can also the test across all modules on the various platforms with
```sh
@@ -230,9 +226,9 @@ All platform differentiated implementations are kept in `platform`-packages with
Inside the various `packages/test-X/` modules there are 3 locations the files can be placed in:
-* `packages/test-/src/commonTest`
-* `package/test-/src/androidAndroidTest`
-* `package/test-/src/nativeDarwinTest` (macOS)
+* `packages/test-base/src/commonTest`
+* `package/test-base/src/androidAndroidTest`
+* `package/test-base/src/nativeDarwinTest` (macOS)
Ideally all shared tests should be in `commonTest` with specific platform tests in `androidAndroidTest`/`nativeDarwinTest`. However IntelliJ does [not yet allow you to run common tests on Android from within the IDE](https://youtrack.jetbrains.com/issue/KT-46452), so we
are using the following work-around:
diff --git a/README.md b/README.md
index 83478678f9..b450bfa5ff 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,6 @@ This repository holds the source code for the Kotlin SDK for Realm, which runs o
* **Intuitive to Developers:** Realm’s object-oriented data model is simple to learn, doesn’t need an ORM, and lets you write less code.
* **Built for Mobile:** Realm is fully-featured, lightweight, and efficiently uses memory, disk space, and battery life.
* **Designed for Offline Use:** Realm’s local database persists data on-disk, so apps work as well offline as they do online.
-* **[Atlas Device Sync](https://www.mongodb.com/docs/atlas/app-services/sync/)**: Makes it simple to keep data in sync across users, devices, and your backend in real-time. Get started for free with [a template application](https://github.com/mongodb/template-app-kotlin-todo) and [create the cloud backend](http://mongodb.com/realm/register?utm_medium=github_atlas_CTA&utm_source=realm_kotlin_github).
# General Availability
@@ -37,7 +36,7 @@ If you are migrating from [Realm Java](https://github.com/realm/realm-java), ple
## Installation
-Installation differs slightly depending on the type of project and whether or not you are using Device Sync. See the details in the documentation:
+Installation differs slightly depending on the type of project. See the details in the documentation:
* [Android](https://www.mongodb.com/docs/atlas/device-sdks/sdk/kotlin/install/#std-label-kotlin-install-android)
* [Kotlin Multiplatform](https://www.mongodb.com/docs/atlas/device-sdks/sdk/kotlin/install/#std-label-kotlin-install-kotlin-multiplatform)
diff --git a/benchmarks/androidApp/build.gradle.kts b/benchmarks/androidApp/build.gradle.kts
index 2d3a387568..b3356b5986 100644
--- a/benchmarks/androidApp/build.gradle.kts
+++ b/benchmarks/androidApp/build.gradle.kts
@@ -47,7 +47,7 @@ android {
}
dependencies {
- androidTestImplementation("io.realm.kotlin:library-sync:${Realm.version}")
+ androidTestImplementation("io.realm.kotlin:library-base:${Realm.version}")
androidTestImplementation("androidx.test:runner:${Versions.androidxTest}")
androidTestImplementation("androidx.test.ext:junit:${Versions.androidxJunit}")
androidTestImplementation("junit:junit:${Versions.junit}")
diff --git a/benchmarks/jvmApp/build.gradle.kts b/benchmarks/jvmApp/build.gradle.kts
index 3244a5ee05..3d36f17cf8 100644
--- a/benchmarks/jvmApp/build.gradle.kts
+++ b/benchmarks/jvmApp/build.gradle.kts
@@ -6,7 +6,7 @@ apply(plugin = "kotlin")
dependencies {
jmh(project(":shared"))
- jmh("io.realm.kotlin:library-sync:${Realm.version}")
+ jmh("io.realm.kotlin:library-base:${Realm.version}")
jmh("org.openjdk.jmh:jmh-core:${Versions.jmh}")
jmh("org.openjdk.jmh:jmh-generator-annprocess:${Versions.jmh}")
}
diff --git a/benchmarks/shared/build.gradle.kts b/benchmarks/shared/build.gradle.kts
index 6fda4e66dd..fe13d1dfd3 100644
--- a/benchmarks/shared/build.gradle.kts
+++ b/benchmarks/shared/build.gradle.kts
@@ -28,7 +28,7 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
- implementation("io.realm.kotlin:library-sync:${Realm.version}")
+ implementation("io.realm.kotlin:library-base:${Realm.version}")
}
}
val androidMain by getting
diff --git a/examples/realm-java-compatibility/app/build.gradle b/examples/realm-java-compatibility/app/build.gradle
index da72b4e451..c06f0e3c23 100644
--- a/examples/realm-java-compatibility/app/build.gradle
+++ b/examples/realm-java-compatibility/app/build.gradle
@@ -51,10 +51,6 @@ android {
}
}
-realm {
- syncEnabled = true
-}
-
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
@@ -62,7 +58,7 @@ dependencies {
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
- implementation "io.realm.kotlin:library-sync:${Realm.version}"
+ implementation "io.realm.kotlin:library-base:${Realm.version}"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
diff --git a/packages/build.gradle.kts b/packages/build.gradle.kts
index 3af7043487..f7c43c95d5 100644
--- a/packages/build.gradle.kts
+++ b/packages/build.gradle.kts
@@ -102,15 +102,12 @@ tasks.register("publishCIPackages") {
":cinterop:publishIosSimulatorArm64PublicationToTestRepository",
":library-base:publishIosArm64PublicationToTestRepository",
":library-base:publishIosSimulatorArm64PublicationToTestRepository",
- ":library-sync:publishIosArm64PublicationToTestRepository",
- ":library-sync:publishIosSimulatorArm64PublicationToTestRepository",
)
}
"iosX64" -> {
dependsOn(
":cinterop:publishIosX64PublicationToTestRepository",
":library-base:publishIosX64PublicationToTestRepository",
- ":library-sync:publishIosX64PublicationToTestRepository",
)
}
"jvm" -> {
@@ -118,21 +115,18 @@ tasks.register("publishCIPackages") {
":jni-swig-stub:publishAllPublicationsToTestRepository",
":cinterop:publishJvmPublicationToTestRepository",
":library-base:publishJvmPublicationToTestRepository",
- ":library-sync:publishJvmPublicationToTestRepository",
)
}
"macosX64" -> {
dependsOn(
":cinterop:publishMacosX64PublicationToTestRepository",
":library-base:publishMacosX64PublicationToTestRepository",
- ":library-sync:publishMacosX64PublicationToTestRepository",
)
}
"macosArm64" -> {
dependsOn(
":cinterop:publishMacosArm64PublicationToTestRepository",
":library-base:publishMacosArm64PublicationToTestRepository",
- ":library-sync:publishMacosArm64PublicationToTestRepository",
)
}
"android" -> {
@@ -140,14 +134,12 @@ tasks.register("publishCIPackages") {
":jni-swig-stub:publishAllPublicationsToTestRepository",
":cinterop:publishAndroidReleasePublicationToTestRepository",
":library-base:publishAndroidReleasePublicationToTestRepository",
- ":library-sync:publishAndroidReleasePublicationToTestRepository",
)
}
"metadata" -> {
dependsOn(
":cinterop:publishKotlinMultiplatformPublicationToTestRepository",
":library-base:publishKotlinMultiplatformPublicationToTestRepository",
- ":library-sync:publishKotlinMultiplatformPublicationToTestRepository",
)
}
"compilerPlugin" -> {
diff --git a/packages/cinterop/build.gradle.kts b/packages/cinterop/build.gradle.kts
index 32a61dd7ca..3a01d95007 100644
--- a/packages/cinterop/build.gradle.kts
+++ b/packages/cinterop/build.gradle.kts
@@ -83,7 +83,6 @@ val nativeLibraryIncludesMacosUniversalRelease = includeBinaries(
"Release/librealm.a",
"parser/Release/librealm-parser.a",
"object-store/Release/librealm-object-store.a",
- "sync/Release/librealm-sync.a"
).map { "$absoluteCorePath/build-macos_universal/src/realm/$it" }
)
val nativeLibraryIncludesMacosUniversalDebug = includeBinaries(
@@ -92,7 +91,6 @@ val nativeLibraryIncludesMacosUniversalDebug = includeBinaries(
"Debug/librealm-dbg.a",
"parser/Debug/librealm-parser-dbg.a",
"object-store/Debug/librealm-object-store-dbg.a",
- "sync/Debug/librealm-sync-dbg.a"
).map { "$absoluteCorePath/build-macos_universal-dbg/src/realm/$it" }
)
val releaseLibs = listOf(
@@ -100,14 +98,12 @@ val releaseLibs = listOf(
"librealm.a",
"librealm-parser.a",
"librealm-object-store.a",
- "librealm-sync.a"
)
val debugLibs = listOf(
"librealm-ffi-static-dbg.a",
"librealm-dbg.a",
"librealm-parser-dbg.a",
"librealm-object-store-dbg.a",
- "librealm-sync-dbg.a"
)
val nativeLibraryIncludesIosArm64Debug =
includeBinaries(debugLibs.map { "$absoluteCorePath/build-capi_ios_Arm64-dbg/lib/$it" })
@@ -490,7 +486,6 @@ fun getSharedCMakeFlags(buildType: BuildType, ccache: Boolean = true): Array
- ErrorCategory.of(nativeValue)
- }
- assertEquals(ErrorCategory.values().size, CategoryFlags.CATEGORY_ORDER.size)
- }
-
- @Test
- fun authProvider() {
- checkEnum(realm_auth_provider_e::class) { nativeValue ->
- AuthProvider.of(nativeValue)
- }
- }
-
- @Test
- fun clientErrorCode() {
- checkEnum(realm_errno_e::class) { nativeValue ->
- ErrorCode.of(nativeValue)
- }
- }
-
- @Test
- fun coreUserState() {
- checkEnum(realm_user_state_e::class) { nativeValue ->
- CoreUserState.of(nativeValue)
- }
- }
-
- @Test
- fun metadataMode() {
- checkEnum(realm_sync_client_metadata_mode_e::class) { nativeValue ->
- MetadataMode.of(nativeValue)
- }
- }
-
- @Test
- fun syncConnectionErrorCode() {
- checkEnum(realm_sync_errno_connection_e::class) { nativeValue ->
- SyncConnectionErrorCode.of(nativeValue)
- }
- }
-
- @Test
- fun syncSessionErrorCode() {
- checkEnum(realm_sync_errno_session_e::class) { nativeValue ->
- SyncSessionErrorCode.of(nativeValue)
- }
- }
-
- @Test
- fun websocketErrorCode() {
- checkEnum(realm_web_socket_errno_e::class) { nativeValue ->
- WebsocketErrorCode.of(nativeValue)
- }
- }
-
- @Test
- fun syncSessionResyncMode() {
- checkEnum(realm_sync_session_resync_mode_e::class) { nativeValue ->
- SyncSessionResyncMode.of(nativeValue)
- }
- }
-
- @Test
- fun syncSessionState() {
- checkEnum(realm_sync_session_state_e::class) { nativeValue ->
- CoreSyncSessionState.of(nativeValue)
- }
- }
-
- @Test
- fun syncSessionConnectionState() {
- checkEnum(realm_sync_connection_state_e::class) { nativeValue ->
- CoreConnectionState.of(nativeValue)
- }
- }
-
- @Test
- fun syncSubscriptionSetState() {
- checkEnum(realm_flx_sync_subscription_set_state_e::class) { nativeValue ->
- CoreSubscriptionSetState.of(nativeValue)
- }
- }
-
- @Test
- fun websocketResultCode() {
- checkEnum(realm_sync_socket_callback_result_e::class) { nativeValue ->
- WebsocketCallbackResult.of(nativeValue)
- }
- }
-
- private inline fun checkEnum(
- enumClass: KClass,
- mapNativeValue: (Int) -> T?
- ) {
- // Fetch all native values
- val coreNativeValues: IntArray = enumClass.java.fields
- .map { it.getInt(null) }
- .toIntArray()
-
- // Find all enums mapping to those values
- val mappedKotlinEnums: Set = coreNativeValues
- .map {
- mapNativeValue(it) ?: fail("${enumClass.simpleName}: unmapped native value $it")
- }
- .toSet()
-
- // Validate we have a different enum defined for each core native value.
- // Note, we cannot check that the name is mapped correctly, but the chance
- // of that happening should be really low and we will catch all the common
- // cases of adding, removing and renaming enums.
- assertEquals(coreNativeValues.size, mappedKotlinEnums.size)
- }
-}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/Callback.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/Callback.kt
index fbef8d286e..e568fe7087 100644
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/Callback.kt
+++ b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/Callback.kt
@@ -16,49 +16,16 @@
package io.realm.kotlin.internal.interop
-import io.realm.kotlin.internal.interop.sync.AppError
-import io.realm.kotlin.internal.interop.sync.CoreConnectionState
-import io.realm.kotlin.internal.interop.sync.CoreSubscriptionSetState
-import io.realm.kotlin.internal.interop.sync.SyncError
-
// TODO Could be replace by lambda. See realm_app_config_new networkTransportFactory for example.
interface Callback {
fun onChange(change: T)
}
-// Callback from asynchronous sync methods. Use AppCallback for void callbacks and
-// AppCallback for callbacks with native pointers to core objects.
-interface AppCallback {
- fun onSuccess(result: T)
- fun onError(error: AppError)
-}
-
-fun interface SyncErrorCallback {
- fun onSyncError(pointer: RealmSyncSessionPointer, error: SyncError)
-}
-
-// Interface exposed towards `library-sync`
-interface SyncSessionTransferCompletionCallback {
- fun invoke(error: CoreError?)
-}
-
interface LogCallback {
// Passes core log levels as shorts to avoid unnecessary jumping between the SDK and JNI
fun log(logLevel: Short, categoryValue: String, message: String?)
}
-interface SyncBeforeClientResetHandler {
- fun onBeforeReset(realmBefore: FrozenRealmPointer)
-}
-
-interface SyncAfterClientResetHandler {
- fun onAfterReset(
- realmBefore: FrozenRealmPointer,
- realmAfter: LiveRealmPointer,
- didRecover: Boolean
- )
-}
-
fun interface CompactOnLaunchCallback {
fun invoke(totalBytes: Long, usedBytes: Long): Boolean
}
@@ -71,28 +38,12 @@ fun interface MigrationCallback {
)
}
-fun interface SubscriptionSetCallback {
- fun onChange(state: CoreSubscriptionSetState)
-}
-
// The underlying Core implementation can also pass in Realm pointer, but since it is not
// useful during construction, we omit it from this callback as it is only used as a signal.
fun interface DataInitializationCallback {
fun invoke()
}
-fun interface AsyncOpenCallback {
- fun invoke(error: Throwable?)
-}
-
-fun interface ProgressCallback {
- fun onChange(progressEstimate: Double)
-}
-
-fun interface ConnectionStateChangeCallback {
- fun onChange(oldState: CoreConnectionState, newState: CoreConnectionState)
-}
-
interface SyncThreadObserver {
// Should return the name of the Java Sync thread.
fun threadName(): String
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/ClassInfo.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/ClassInfo.kt
index c2598aba25..9f27258a1b 100644
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/ClassInfo.kt
+++ b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/ClassInfo.kt
@@ -29,7 +29,6 @@ data class ClassInfo(
) {
val isEmbedded = flags and ClassFlags.RLM_CLASS_EMBEDDED != 0
- val isAsymmetric = flags and ClassFlags.RLM_CLASS_ASYMMETRIC != 0
companion object {
// Convenience wrapper to ease maintaining compiler plugin
@@ -38,11 +37,9 @@ data class ClassInfo(
primaryKey: String?,
numProperties: Long,
isEmbedded: Boolean = false,
- isAsymmetric: Boolean = false
): ClassInfo {
val flags: Int = when {
isEmbedded -> ClassFlags.RLM_CLASS_EMBEDDED
- isAsymmetric -> ClassFlags.RLM_CLASS_ASYMMETRIC
else -> ClassFlags.RLM_CLASS_NORMAL
}
return ClassInfo(name, primaryKey ?: SCHEMA_NO_VALUE, numProperties, 0, flags = flags)
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/CoreError.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/CoreError.kt
index 3d7334fcd7..829073c4f9 100644
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/CoreError.kt
+++ b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/CoreError.kt
@@ -34,17 +34,9 @@ data class CategoryFlags(val categoryFlags: Int) {
* associated either.
*/
val CATEGORY_ORDER: List = listOf(
- ErrorCategory.RLM_ERR_CAT_CUSTOM_ERROR,
- ErrorCategory.RLM_ERR_CAT_WEBSOCKET_ERROR,
- ErrorCategory.RLM_ERR_CAT_SYNC_ERROR,
- ErrorCategory.RLM_ERR_CAT_SERVICE_ERROR,
- ErrorCategory.RLM_ERR_CAT_JSON_ERROR,
- ErrorCategory.RLM_ERR_CAT_CLIENT_ERROR,
ErrorCategory.RLM_ERR_CAT_SYSTEM_ERROR,
ErrorCategory.RLM_ERR_CAT_FILE_ACCESS,
- ErrorCategory.RLM_ERR_CAT_HTTP_ERROR,
ErrorCategory.RLM_ERR_CAT_INVALID_ARG,
- ErrorCategory.RLM_ERR_CAT_APP_ERROR,
ErrorCategory.RLM_ERR_CAT_LOGIC,
ErrorCategory.RLM_ERR_CAT_RUNTIME,
)
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/CoreErrorConverter.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/CoreErrorConverter.kt
index 0a60a8aa7b..60605a4453 100644
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/CoreErrorConverter.kt
+++ b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/CoreErrorConverter.kt
@@ -38,9 +38,7 @@ object CoreErrorConverter {
return userError ?: when {
ErrorCode.RLM_ERR_INDEX_OUT_OF_BOUNDS == errorCode ->
IndexOutOfBoundsException(message)
- ErrorCategory.RLM_ERR_CAT_INVALID_ARG in categories && ErrorCategory.RLM_ERR_CAT_SYNC_ERROR !in categories -> {
- // Some sync errors flagged as both logical and illegal. In our case, we consider those
- // IllegalState, so discard them them here and let them fall through to the bottom case
+ ErrorCategory.RLM_ERR_CAT_INVALID_ARG in categories -> {
IllegalArgumentException(message)
}
ErrorCategory.RLM_ERR_CAT_LOGIC in categories || ErrorCategory.RLM_ERR_CAT_RUNTIME in categories ->
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/ErrorCategory.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/ErrorCategory.kt
index 1cb48dacf7..2f1687eaea 100644
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/ErrorCategory.kt
+++ b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/ErrorCategory.kt
@@ -25,15 +25,7 @@ expect enum class ErrorCategory : CodeDescription {
RLM_ERR_CAT_RUNTIME,
RLM_ERR_CAT_INVALID_ARG,
RLM_ERR_CAT_FILE_ACCESS,
- RLM_ERR_CAT_SYSTEM_ERROR,
- RLM_ERR_CAT_APP_ERROR,
- RLM_ERR_CAT_CLIENT_ERROR,
- RLM_ERR_CAT_JSON_ERROR,
- RLM_ERR_CAT_SERVICE_ERROR,
- RLM_ERR_CAT_HTTP_ERROR,
- RLM_ERR_CAT_CUSTOM_ERROR,
- RLM_ERR_CAT_WEBSOCKET_ERROR,
- RLM_ERR_CAT_SYNC_ERROR;
+ RLM_ERR_CAT_SYSTEM_ERROR;
override val nativeValue: Int
override val description: String?
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmEnums.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmEnums.kt
index 36f25fa852..37d2af5a52 100644
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmEnums.kt
+++ b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmEnums.kt
@@ -31,7 +31,6 @@ expect enum class SchemaMode {
expect object ClassFlags {
val RLM_CLASS_NORMAL: Int
val RLM_CLASS_EMBEDDED: Int
- val RLM_CLASS_ASYMMETRIC: Int
}
expect enum class PropertyType {
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt
index 2595d08e98..d908df1144 100644
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt
+++ b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt
@@ -18,22 +18,7 @@
package io.realm.kotlin.internal.interop
-import io.realm.kotlin.internal.interop.sync.ApiKeyWrapper
-import io.realm.kotlin.internal.interop.sync.AuthProvider
-import io.realm.kotlin.internal.interop.sync.CoreConnectionState
-import io.realm.kotlin.internal.interop.sync.CoreSubscriptionSetState
-import io.realm.kotlin.internal.interop.sync.CoreSyncSessionState
-import io.realm.kotlin.internal.interop.sync.CoreUserState
-import io.realm.kotlin.internal.interop.sync.MetadataMode
-import io.realm.kotlin.internal.interop.sync.NetworkTransport
-import io.realm.kotlin.internal.interop.sync.ProgressDirection
-import io.realm.kotlin.internal.interop.sync.SyncSessionResyncMode
-import io.realm.kotlin.internal.interop.sync.SyncUserIdentity
-import io.realm.kotlin.internal.interop.sync.WebSocketTransport
-import io.realm.kotlin.internal.interop.sync.WebsocketCallbackResult
-import io.realm.kotlin.internal.interop.sync.WebsocketErrorCode
import kotlinx.coroutines.CoroutineDispatcher
-import org.mongodb.kbson.ObjectId
import kotlin.jvm.JvmInline
import kotlin.jvm.JvmMultifileClass
import kotlin.jvm.JvmName
@@ -96,87 +81,6 @@ typealias RealmChangesPointer = NativePointer
typealias RealmSchedulerPointer = NativePointer
typealias RealmKeyPathArrayPointer = NativePointer
-// Sync types
-// Pure marker interfaces corresponding to the C-API realm_x_t struct types
-interface RealmAsyncOpenTaskT : CapiT
-interface RealmAppT : CapiT
-interface RealmAppConfigT : CapiT
-interface RealmSyncConfigT : CapiT
-interface RealmSyncClientConfigT : CapiT
-interface RealmCredentialsT : CapiT
-interface RealmUserT : CapiT
-interface RealmNetworkTransportT : CapiT
-interface RealmSyncSessionT : CapiT
-interface RealmSubscriptionT : CapiT
-interface RealmSyncSocketObserverPointerT : CapiT
-interface RealmSyncSocketCallbackPointerT : CapiT
-
-interface RealmBaseSubscriptionSet : CapiT
-interface RealmSyncSocket : CapiT
-interface RealmSubscriptionSetT : RealmBaseSubscriptionSet
-interface RealmMutableSubscriptionSetT : RealmBaseSubscriptionSet
-interface RealmSyncSocketT : RealmSyncSocket
-
-// Public type aliases binding to internal verbose type safe type definitions. This should allow us
-// to easily change implementation details later on.
-typealias RealmAsyncOpenTaskPointer = NativePointer
-typealias RealmAppPointer = NativePointer
-typealias RealmAppConfigurationPointer = NativePointer
-typealias RealmSyncConfigurationPointer = NativePointer
-typealias RealmSyncClientConfigurationPointer = NativePointer
-typealias RealmCredentialsPointer = NativePointer
-typealias RealmUserPointer = NativePointer
-typealias RealmNetworkTransportPointer = NativePointer
-typealias RealmSyncSessionPointer = NativePointer
-typealias RealmSubscriptionPointer = NativePointer
-typealias RealmBaseSubscriptionSetPointer = NativePointer
-typealias RealmSubscriptionSetPointer = NativePointer
-typealias RealmMutableSubscriptionSetPointer = NativePointer
-typealias RealmSyncSocketPointer = NativePointer
-typealias RealmSyncSocketObserverPointer = NativePointer
-typealias RealmSyncSocketCallbackPointer = NativePointer
-typealias RealmWebsocketHandlerCallbackPointer = NativePointer
-typealias RealmWebsocketProviderPointer = NativePointer
-/**
- * Class for grouping and normalizing values we want to send as part of
- * logging in Sync Users.
- */
-@Suppress("LongParameterList")
-class SyncConnectionParams(
- sdkVersion: String,
- bundleId: String,
- platformVersion: String,
- device: String,
- deviceVersion: String,
- framework: Runtime,
- frameworkVersion: String
-) {
- val sdkName = "Kotlin"
- val bundleId: String
- val sdkVersion: String
- val platformVersion: String
- val device: String
- val deviceVersion: String
- val framework: String
- val frameworkVersion: String
-
- enum class Runtime(public val description: String) {
- JVM("JVM"),
- ANDROID("Android"),
- NATIVE("Native")
- }
-
- init {
- this.sdkVersion = sdkVersion
- this.bundleId = bundleId
- this.platformVersion = platformVersion
- this.device = device
- this.deviceVersion = deviceVersion
- this.framework = framework.description
- this.frameworkVersion = frameworkVersion
- }
-}
-
@Suppress("FunctionNaming", "LongParameterList")
expect object RealmInterop {
fun realm_value_get(value: RealmValue): Any?
@@ -227,11 +131,6 @@ expect object RealmInterop {
// dispatcher. The realm itself must also be opened on the same thread
fun realm_open(config: RealmConfigurationPointer, scheduler: RealmSchedulerPointer): Pair
- // Opening a Realm asynchronously. Only supported for synchronized realms.
- fun realm_open_synchronized(config: RealmConfigurationPointer): RealmAsyncOpenTaskPointer
- fun realm_async_open_task_start(task: RealmAsyncOpenTaskPointer, callback: AsyncOpenCallback)
- fun realm_async_open_task_cancel(task: RealmAsyncOpenTaskPointer)
-
fun realm_add_realm_changed_callback(realm: LiveRealmPointer, block: () -> Unit): RealmCallbackTokenPointer
fun realm_add_schema_changed_callback(realm: LiveRealmPointer, block: (RealmSchemaPointer) -> Unit): RealmCallbackTokenPointer
@@ -516,102 +415,6 @@ expect object RealmInterop {
builder: DictionaryChangeSetBuilder
)
- // App
- fun realm_app_get(
- appConfig: RealmAppConfigurationPointer,
- basePath: String,
- ): RealmAppPointer
- fun realm_app_get_current_user(app: RealmAppPointer): RealmUserPointer?
- fun realm_app_get_all_users(app: RealmAppPointer): List
- fun realm_app_log_in_with_credentials(app: RealmAppPointer, credentials: RealmCredentialsPointer, callback: AppCallback)
- fun realm_app_log_out(app: RealmAppPointer, user: RealmUserPointer, callback: AppCallback)
- fun realm_app_remove_user(app: RealmAppPointer, user: RealmUserPointer, callback: AppCallback)
- fun realm_app_delete_user(app: RealmAppPointer, user: RealmUserPointer, callback: AppCallback)
- fun realm_app_link_credentials(app: RealmAppPointer, user: RealmUserPointer, credentials: RealmCredentialsPointer, callback: AppCallback)
- fun realm_app_switch_user(app: RealmAppPointer, user: RealmUserPointer)
- fun realm_clear_cached_apps()
- fun realm_app_sync_client_get_default_file_path_for_realm(
- syncConfig: RealmSyncConfigurationPointer,
- overriddenName: String?
- ): String
- fun realm_app_user_apikey_provider_client_create_apikey(
- app: RealmAppPointer,
- user: RealmUserPointer,
- name: String,
- callback: AppCallback
- )
-
- fun realm_app_user_apikey_provider_client_delete_apikey(
- app: RealmAppPointer,
- user: RealmUserPointer,
- id: ObjectId,
- callback: AppCallback,
- )
-
- fun realm_app_user_apikey_provider_client_disable_apikey(
- app: RealmAppPointer,
- user: RealmUserPointer,
- id: ObjectId,
- callback: AppCallback,
- )
-
- fun realm_app_user_apikey_provider_client_enable_apikey(
- app: RealmAppPointer,
- user: RealmUserPointer,
- id: ObjectId,
- callback: AppCallback,
- )
-
- fun realm_app_user_apikey_provider_client_fetch_apikey(
- app: RealmAppPointer,
- user: RealmUserPointer,
- id: ObjectId,
- callback: AppCallback,
- )
-
- fun realm_app_user_apikey_provider_client_fetch_apikeys(
- app: RealmAppPointer,
- user: RealmUserPointer,
- callback: AppCallback>,
- )
-
- fun realm_app_get_base_url(
- app: RealmAppPointer,
- ): String
-
- fun realm_app_update_base_url(
- app: RealmAppPointer,
- baseUrl: String?,
- callback: AppCallback,
- )
-
- // User
- fun realm_user_get_all_identities(user: RealmUserPointer): List
- fun realm_user_get_identity(user: RealmUserPointer): String
- fun realm_user_get_access_token(user: RealmUserPointer): String
- fun realm_user_get_refresh_token(user: RealmUserPointer): String
- fun realm_user_get_device_id(user: RealmUserPointer): String
- fun realm_user_is_logged_in(user: RealmUserPointer): Boolean
- fun realm_user_log_out(user: RealmUserPointer)
- fun realm_user_get_state(user: RealmUserPointer): CoreUserState
- fun realm_user_get_profile(user: RealmUserPointer): String
- fun realm_user_get_custom_data(user: RealmUserPointer): String?
- fun realm_user_refresh_custom_data(app: RealmAppPointer, user: RealmUserPointer, callback: AppCallback)
-
- // Sync client config
- fun realm_app_config_get_sync_client_config(configPointer: RealmAppConfigurationPointer): RealmSyncClientConfigurationPointer
- fun realm_sync_client_config_set_default_binding_thread_observer(
- syncClientConfig: RealmSyncClientConfigurationPointer,
- appId: String
- )
-
- fun realm_app_config_set_base_file_path(
- appConfig: RealmAppConfigurationPointer,
- basePath: String
- )
-
- fun realm_sync_client_config_set_multiplex_sessions(syncClientConfig: RealmSyncClientConfigurationPointer, enabled: Boolean)
-
fun realm_set_log_callback(callback: LogCallback)
fun realm_set_log_level(level: CoreLogLevel)
@@ -621,251 +424,4 @@ expect object RealmInterop {
fun realm_get_log_level_category(category: String): CoreLogLevel
fun realm_get_category_names(): List
-
- fun realm_app_config_set_metadata_mode(
- appConfig: RealmAppConfigurationPointer,
- metadataMode: MetadataMode
- )
-
- fun realm_app_config_set_metadata_encryption_key(
- appConfig: RealmAppConfigurationPointer,
- encryptionKey: ByteArray
- )
- fun realm_sync_client_config_set_user_agent_binding_info(
- syncClientConfig: RealmSyncClientConfigurationPointer,
- bindingInfo: String
- )
- fun realm_sync_client_config_set_user_agent_application_info(
- syncClientConfig: RealmSyncClientConfigurationPointer,
- applicationInfo: String
- )
-
- fun realm_sync_client_config_set_connect_timeout(syncClientConfig: RealmSyncClientConfigurationPointer, timeoutMs: ULong)
- fun realm_sync_client_config_set_connection_linger_time(syncClientConfig: RealmSyncClientConfigurationPointer, timeoutMs: ULong)
- fun realm_sync_client_config_set_ping_keepalive_period(syncClientConfig: RealmSyncClientConfigurationPointer, timeoutMs: ULong)
- fun realm_sync_client_config_set_pong_keepalive_timeout(syncClientConfig: RealmSyncClientConfigurationPointer, timeoutMs: ULong)
- fun realm_sync_client_config_set_fast_reconnect_limit(syncClientConfig: RealmSyncClientConfigurationPointer, timeoutMs: ULong)
-
- fun realm_sync_config_new(
- user: RealmUserPointer,
- partition: String
- ): RealmSyncConfigurationPointer
- // Flexible Sync
- fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer
- fun realm_sync_config_set_error_handler(
- syncConfig: RealmSyncConfigurationPointer,
- errorHandler: SyncErrorCallback
- )
- fun realm_sync_config_set_resync_mode(
- syncConfig: RealmSyncConfigurationPointer,
- resyncMode: SyncSessionResyncMode
- )
- fun realm_sync_config_set_before_client_reset_handler(
- syncConfig: RealmSyncConfigurationPointer,
- beforeHandler: SyncBeforeClientResetHandler
- )
- fun realm_sync_config_set_after_client_reset_handler(
- syncConfig: RealmSyncConfigurationPointer,
- afterHandler: SyncAfterClientResetHandler
- )
- fun realm_sync_immediately_run_file_actions(app: RealmAppPointer, syncPath: String): Boolean
-
- // SyncSession
- fun realm_sync_session_get(realm: RealmPointer): RealmSyncSessionPointer
- fun realm_sync_session_wait_for_download_completion(
- syncSession: RealmSyncSessionPointer,
- callback: SyncSessionTransferCompletionCallback
- )
- fun realm_sync_session_wait_for_upload_completion(
- syncSession: RealmSyncSessionPointer,
- callback: SyncSessionTransferCompletionCallback
- )
- fun realm_sync_session_state(syncSession: RealmSyncSessionPointer): CoreSyncSessionState
- fun realm_sync_connection_state(syncSession: RealmSyncSessionPointer): CoreConnectionState
- fun realm_sync_session_pause(syncSession: RealmSyncSessionPointer)
- fun realm_sync_session_resume(syncSession: RealmSyncSessionPointer)
- fun realm_sync_session_handle_error_for_testing(
- syncSession: RealmSyncSessionPointer,
- error: ErrorCode,
- errorMessage: String,
- isFatal: Boolean
- )
-
- fun realm_sync_session_register_progress_notifier(
- syncSession: RealmSyncSessionPointer /* = io.realm.kotlin.internal.interop.NativePointer */,
- direction: ProgressDirection,
- isStreaming: Boolean,
- callback: ProgressCallback,
- ): RealmNotificationTokenPointer
-
- fun realm_sync_session_register_connection_state_change_callback(
- syncSession: RealmSyncSessionPointer,
- callback: ConnectionStateChangeCallback,
- ): RealmNotificationTokenPointer
-
- // AppConfig
- fun realm_network_transport_new(networkTransport: NetworkTransport): RealmNetworkTransportPointer
- fun realm_app_config_new(
- appId: String,
- networkTransport: RealmNetworkTransportPointer,
- baseUrl: String? = null,
- connectionParams: SyncConnectionParams
- ): RealmAppConfigurationPointer
- fun realm_app_config_set_base_url(appConfig: RealmAppConfigurationPointer, baseUrl: String)
-
- // Credentials
- fun realm_app_credentials_new_anonymous(reuseExisting: Boolean): RealmCredentialsPointer
- fun realm_app_credentials_new_email_password(username: String, password: String): RealmCredentialsPointer
- fun realm_app_credentials_new_api_key(key: String): RealmCredentialsPointer
- fun realm_app_credentials_new_apple(idToken: String): RealmCredentialsPointer
- fun realm_app_credentials_new_facebook(accessToken: String): RealmCredentialsPointer
- fun realm_app_credentials_new_google_id_token(idToken: String): RealmCredentialsPointer
- fun realm_app_credentials_new_google_auth_code(authCode: String): RealmCredentialsPointer
- fun realm_app_credentials_new_jwt(jwtToken: String): RealmCredentialsPointer
- fun realm_app_credentials_new_custom_function(serializedEjsonPayload: String): RealmCredentialsPointer
- fun realm_auth_credentials_get_provider(credentials: RealmCredentialsPointer): AuthProvider
- fun realm_app_credentials_serialize_as_json(credentials: RealmCredentialsPointer): String
-
- // Email Password Authentication
- fun realm_app_email_password_provider_client_register_email(
- app: RealmAppPointer,
- email: String,
- password: String,
- callback: AppCallback
- )
- fun realm_app_email_password_provider_client_confirm_user(
- app: RealmAppPointer,
- token: String,
- tokenId: String,
- callback: AppCallback
- )
- fun realm_app_email_password_provider_client_resend_confirmation_email(
- app: RealmAppPointer,
- email: String,
- callback: AppCallback
- )
- fun realm_app_email_password_provider_client_retry_custom_confirmation(
- app: RealmAppPointer,
- email: String,
- callback: AppCallback
- )
- fun realm_app_email_password_provider_client_send_reset_password_email(
- app: RealmAppPointer,
- email: String,
- callback: AppCallback
- )
- fun realm_app_email_password_provider_client_reset_password(
- app: RealmAppPointer,
- token: String,
- tokenId: String,
- newPassword: String,
- callback: AppCallback
- )
- fun realm_app_call_reset_password_function(
- app: RealmAppPointer,
- email: String,
- newPassword: String,
- serializedEjsonPayload: String,
- callback: AppCallback
- )
-
- fun realm_app_call_function(
- app: RealmAppPointer,
- user: RealmUserPointer,
- name: String,
- serviceName: String? = null,
- serializedEjsonArgs: String, // as ejson
- callback: AppCallback
- )
-
- // Sync Client
- fun realm_app_sync_client_reconnect(app: RealmAppPointer)
- fun realm_app_sync_client_has_sessions(app: RealmAppPointer): Boolean
- fun realm_app_sync_client_wait_for_sessions_to_terminate(app: RealmAppPointer)
-
- // Sync config
- fun realm_config_set_sync_config(
- realmConfiguration: RealmConfigurationPointer,
- syncConfiguration: RealmSyncConfigurationPointer
- )
-
- // Flexible Sync Subscription
- fun realm_sync_subscription_id(subscription: RealmSubscriptionPointer): ObjectId
- fun realm_sync_subscription_name(subscription: RealmSubscriptionPointer): String?
- fun realm_sync_subscription_object_class_name(subscription: RealmSubscriptionPointer): String
- fun realm_sync_subscription_query_string(subscription: RealmSubscriptionPointer): String
- fun realm_sync_subscription_created_at(subscription: RealmSubscriptionPointer): Timestamp
- fun realm_sync_subscription_updated_at(subscription: RealmSubscriptionPointer): Timestamp
-
- // Flexible Sync Subscription Set
- fun realm_sync_get_latest_subscriptionset(realm: RealmPointer): RealmSubscriptionSetPointer
- fun realm_sync_on_subscriptionset_state_change_async(
- subscriptionSet: RealmSubscriptionSetPointer,
- destinationState: CoreSubscriptionSetState,
- callback: SubscriptionSetCallback
- )
- fun realm_sync_subscriptionset_version(subscriptionSet: RealmBaseSubscriptionSetPointer): Long
- fun realm_sync_subscriptionset_state(subscriptionSet: RealmBaseSubscriptionSetPointer): CoreSubscriptionSetState
- fun realm_sync_subscriptionset_error_str(subscriptionSet: RealmBaseSubscriptionSetPointer): String?
- fun realm_sync_subscriptionset_size(subscriptionSet: RealmBaseSubscriptionSetPointer): Long
- fun realm_sync_subscription_at(
- subscriptionSet: RealmBaseSubscriptionSetPointer,
- index: Long
- ): RealmSubscriptionPointer
- fun realm_sync_find_subscription_by_name(
- subscriptionSet: RealmBaseSubscriptionSetPointer,
- name: String
- ): RealmSubscriptionPointer?
- fun realm_sync_find_subscription_by_query(
- subscriptionSet: RealmBaseSubscriptionSetPointer,
- query: RealmQueryPointer
- ): RealmSubscriptionPointer?
- fun realm_sync_subscriptionset_refresh(subscriptionSet: RealmSubscriptionSetPointer): Boolean
- fun realm_sync_make_subscriptionset_mutable(
- subscriptionSet: RealmSubscriptionSetPointer
- ): RealmMutableSubscriptionSetPointer
-
- // Flexible Sync Mutable Subscription Set
- fun realm_sync_subscriptionset_clear(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer
- ): Boolean
- // Returns a Pair of (, )
- fun realm_sync_subscriptionset_insert_or_assign(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer,
- query: RealmQueryPointer,
- name: String?
- ): Pair
- fun realm_sync_subscriptionset_erase_by_name(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer,
- name: String
- ): Boolean
- fun realm_sync_subscriptionset_erase_by_query(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer,
- query: RealmQueryPointer
- ): Boolean
- fun realm_sync_subscriptionset_erase_by_id(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer,
- sub: RealmSubscriptionPointer
- ): Boolean
- fun realm_sync_subscriptionset_commit(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer
- ): RealmSubscriptionSetPointer
-
- fun realm_sync_set_websocket_transport(
- syncClientConfig: RealmSyncClientConfigurationPointer,
- webSocketTransport: WebSocketTransport
- )
-
- fun realm_sync_socket_callback_complete(nativePointer: RealmWebsocketHandlerCallbackPointer, cancelled: Boolean = false, status: WebsocketCallbackResult = WebsocketCallbackResult.RLM_ERR_SYNC_SOCKET_SUCCESS, reason: String = "")
-
- fun realm_sync_socket_websocket_connected(nativePointer: RealmWebsocketProviderPointer, protocol: String)
-
- fun realm_sync_socket_websocket_error(nativePointer: RealmWebsocketProviderPointer)
-
- fun realm_sync_socket_websocket_message(
- nativePointer: RealmWebsocketProviderPointer,
- data: ByteArray
- ): Boolean
-
- fun realm_sync_socket_websocket_closed(nativePointer: RealmWebsocketProviderPointer, wasClean: Boolean, errorCode: WebsocketErrorCode, reason: String = "")
}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ApiKeyWrapper.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ApiKeyWrapper.kt
deleted file mode 100644
index 2ccb0799ad..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ApiKeyWrapper.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.realm.kotlin.internal.interop.sync
-
-import org.mongodb.kbson.ObjectId
-
-public data class ApiKeyWrapper internal constructor(
- public val id: ObjectId,
- public val value: String?,
- public val name: String,
- public val disabled: Boolean
-) {
-
- // Used by JNI
- internal constructor(
- id: ByteArray,
- value: String?,
- name: String,
- disabled: Boolean
- ) : this(ObjectId(id), value, name, disabled)
-}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/AppError.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/AppError.kt
deleted file mode 100644
index d458d3eb87..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/AppError.kt
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2021 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.CodeDescription
-import io.realm.kotlin.internal.interop.ErrorCategory
-import io.realm.kotlin.internal.interop.ErrorCode
-import io.realm.kotlin.internal.interop.UnknownCodeDescription
-import kotlin.jvm.JvmStatic
-
-/**
- * Wrapper for C-API `realm_app_error`.
- * See https://github.com/realm/realm-core/blob/master/src/realm.h#L2638
- */
-data class AppError internal constructor(
- val categoryFlags: Int,
- val code: CodeDescription,
- val httpStatusCode: Int, // If the category is HTTP, this is equal to errorCode
- val message: String?,
- val linkToServerLog: String?
-) {
- companion object {
- @JvmStatic
- fun newInstance(
- categoryFlags: Int,
- errorCode: Int,
- httpStatusCode: Int,
- message: String?,
- linkToServerLog: String?
- ): AppError {
- val code = ErrorCode.of(errorCode) ?: UnknownCodeDescription(errorCode)
-
- return AppError(
- categoryFlags,
- code,
- httpStatusCode,
- message,
- linkToServerLog
- )
- }
- }
-
- /**
- * This method allows to check whether a error categories value contains a category or not.
- *
- * Core defines app categories as flag based values.
- *
- * Any App category is also a [ErrorCategory.RLM_ERR_CAT_RUNTIME] and [ErrorCategory.RLM_ERR_CAT_APP_ERROR].
- */
- operator fun contains(flag: ErrorCategory): Boolean =
- this.categoryFlags and flag.nativeValue != 0
-}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/AuthProvider.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/AuthProvider.kt
deleted file mode 100644
index 7f96431b4d..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/AuthProvider.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2021 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-/**
- * Wrapper for C-API `realm_auth_provider`.
- * See https://github.com/realm/realm-core/blob/master/src/realm.h#L2615
- */
-expect enum class AuthProvider {
- RLM_AUTH_PROVIDER_ANONYMOUS,
- RLM_AUTH_PROVIDER_ANONYMOUS_NO_REUSE,
- RLM_AUTH_PROVIDER_FACEBOOK,
- RLM_AUTH_PROVIDER_GOOGLE,
- RLM_AUTH_PROVIDER_APPLE,
- RLM_AUTH_PROVIDER_CUSTOM,
- RLM_AUTH_PROVIDER_EMAIL_PASSWORD,
- RLM_AUTH_PROVIDER_FUNCTION,
- RLM_AUTH_PROVIDER_API_KEY,
-}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/CoreCompensatingWriteInfo.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/CoreCompensatingWriteInfo.kt
deleted file mode 100644
index ed6b052d9f..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/CoreCompensatingWriteInfo.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2023 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.RealmValue
-
-expect class CoreCompensatingWriteInfo {
- val reason: String
- val objectName: String
- val primaryKey: RealmValue
-}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/CoreConnectionState.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/CoreConnectionState.kt
deleted file mode 100644
index 5d7c871ca5..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/CoreConnectionState.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2023 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-expect enum class CoreConnectionState {
- RLM_SYNC_CONNECTION_STATE_DISCONNECTED,
- RLM_SYNC_CONNECTION_STATE_CONNECTING,
- RLM_SYNC_CONNECTION_STATE_CONNECTED;
-}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/CoreSubscriptionSetState.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/CoreSubscriptionSetState.kt
deleted file mode 100644
index 6544f6653e..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/CoreSubscriptionSetState.kt
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-/**
- * Wrapper around C-API `realm_flx_sync_subscription_set_state`
- * See https://github.com/realm/realm-core/blob/master/src/realm.h#L3356
- */
-expect enum class CoreSubscriptionSetState {
- RLM_SYNC_SUBSCRIPTION_UNCOMMITTED,
- RLM_SYNC_SUBSCRIPTION_PENDING,
- RLM_SYNC_SUBSCRIPTION_BOOTSTRAPPING,
- RLM_SYNC_SUBSCRIPTION_COMPLETE,
- RLM_SYNC_SUBSCRIPTION_ERROR,
- RLM_SYNC_SUBSCRIPTION_SUPERSEDED,
- RLM_SYNC_SUBSCRIPTION_AWAITING_MARK;
-}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/CoreSyncSessionState.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/CoreSyncSessionState.kt
deleted file mode 100644
index 7ce49223ba..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/CoreSyncSessionState.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-/**
- * Wrapper around C-API `realm_sync_session_state`
- * See https://github.com/realm/realm-core/blob/master/src/realm.h#L3177
- */
-expect enum class CoreSyncSessionState {
- RLM_SYNC_SESSION_STATE_DYING,
- RLM_SYNC_SESSION_STATE_ACTIVE,
- RLM_SYNC_SESSION_STATE_INACTIVE,
- RLM_SYNC_SESSION_STATE_WAITING_FOR_ACCESS_TOKEN,
- RLM_SYNC_SESSION_STATE_PAUSED;
-}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/CoreUserState.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/CoreUserState.kt
deleted file mode 100644
index e362966bd9..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/CoreUserState.kt
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-/**
- * Wrapper for C-API `realm_user_state`.
- * See https://github.com/realm/realm-core/blob/master/src/realm.h#L2513
- */
-expect enum class CoreUserState {
- RLM_USER_STATE_LOGGED_OUT,
- RLM_USER_STATE_LOGGED_IN,
- RLM_USER_STATE_REMOVED
-}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/MetadataMode.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/MetadataMode.kt
deleted file mode 100644
index 4e27cef7d0..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/MetadataMode.kt
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2021 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-/**
- * Wrapper for C-API `realm_sync_client_metadata_mode`.
- * See https://github.com/realm/realm-core/blob/master/src/realm.h#L3155
- */
-expect enum class MetadataMode {
- RLM_SYNC_CLIENT_METADATA_MODE_DISABLED,
- RLM_SYNC_CLIENT_METADATA_MODE_PLAINTEXT,
- RLM_SYNC_CLIENT_METADATA_MODE_ENCRYPTED
-}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/NetworkTransport.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/NetworkTransport.kt
deleted file mode 100644
index 5e25135dd3..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/NetworkTransport.kt
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2020 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-interface NetworkTransport {
-
- companion object {
- const val GET = "get"
- const val POST = "post"
- const val PATCH = "patch"
- const val PUT = "put"
- const val DELETE = "delete"
- }
-
- val authorizationHeaderName: String?
- val customHeaders: Map
-
- fun sendRequest(
- method: String,
- url: String,
- headers: Map,
- body: String,
- callback: ResponseCallback
- )
-
- /**
- * Close any native resources associated with running a NetworkClient.
- * E.g. in Ktor, the HttpClient should be closed
- */
- fun close()
-}
-
-fun interface ResponseCallback {
- fun response(response: Response)
-}
-
-data class Response(
- val httpResponseCode: Int,
- val customResponseCode: Int,
- val headers: Map,
- val body: String
-) {
- // Returns the HTTP headers in a JNI friendly way where it is being serialized to a
- // String array consisting of pairs of { key , value } pairs.
- fun getJNIFriendlyHeaders(): Array {
- val jniHeaders = arrayOfNulls(headers.size * 2)
- var i = 0
- for ((key, value) in headers) {
- jniHeaders[i] = key
- jniHeaders[i + 1] = value
- i += 2
- }
- return jniHeaders
- }
-}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ProgressDirection.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ProgressDirection.kt
deleted file mode 100644
index d8fae36986..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ProgressDirection.kt
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-expect enum class ProgressDirection {
- RLM_SYNC_PROGRESS_DIRECTION_UPLOAD,
- RLM_SYNC_PROGRESS_DIRECTION_DOWNLOAD,
-}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt
deleted file mode 100644
index 5a2483d04d..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.CodeDescription
-
-/**
- * Wrapper for C-API `realm_sync_errno_connection`.
- * See https://github.com/realm/realm-core/blob/master/src/realm/error_codes.h#L209
- */
-expect enum class SyncConnectionErrorCode : CodeDescription {
- RLM_SYNC_ERR_CONNECTION_CONNECTION_CLOSED,
- RLM_SYNC_ERR_CONNECTION_OTHER_ERROR,
- RLM_SYNC_ERR_CONNECTION_UNKNOWN_MESSAGE,
- RLM_SYNC_ERR_CONNECTION_BAD_SYNTAX,
- RLM_SYNC_ERR_CONNECTION_LIMITS_EXCEEDED,
- RLM_SYNC_ERR_CONNECTION_WRONG_PROTOCOL_VERSION,
- RLM_SYNC_ERR_CONNECTION_BAD_SESSION_IDENT,
- RLM_SYNC_ERR_CONNECTION_REUSE_OF_SESSION_IDENT,
- RLM_SYNC_ERR_CONNECTION_BOUND_IN_OTHER_SESSION,
- RLM_SYNC_ERR_CONNECTION_BAD_MESSAGE_ORDER,
- RLM_SYNC_ERR_CONNECTION_BAD_DECOMPRESSION,
- RLM_SYNC_ERR_CONNECTION_BAD_CHANGESET_HEADER_SYNTAX,
- RLM_SYNC_ERR_CONNECTION_BAD_CHANGESET_SIZE,
- RLM_SYNC_ERR_CONNECTION_SWITCH_TO_FLX_SYNC,
- RLM_SYNC_ERR_CONNECTION_SWITCH_TO_PBS;
-
- override val nativeValue: Int
- override val description: String?
-}
-
-/**
- * Wrapper for C-API `realm_sync_errno_session`.
- * See https://github.com/realm/realm-core/blob/master/src/realm/error_codes.h#L228
- */
-expect enum class SyncSessionErrorCode : CodeDescription {
- RLM_SYNC_ERR_SESSION_SESSION_CLOSED,
- RLM_SYNC_ERR_SESSION_OTHER_SESSION_ERROR,
- RLM_SYNC_ERR_SESSION_TOKEN_EXPIRED,
- RLM_SYNC_ERR_SESSION_BAD_AUTHENTICATION,
- RLM_SYNC_ERR_SESSION_ILLEGAL_REALM_PATH,
- RLM_SYNC_ERR_SESSION_NO_SUCH_REALM,
- RLM_SYNC_ERR_SESSION_PERMISSION_DENIED,
- RLM_SYNC_ERR_SESSION_BAD_SERVER_FILE_IDENT,
- RLM_SYNC_ERR_SESSION_BAD_CLIENT_FILE_IDENT,
- RLM_SYNC_ERR_SESSION_BAD_SERVER_VERSION,
- RLM_SYNC_ERR_SESSION_BAD_CLIENT_VERSION,
- RLM_SYNC_ERR_SESSION_DIVERGING_HISTORIES,
- RLM_SYNC_ERR_SESSION_BAD_CHANGESET,
- RLM_SYNC_ERR_SESSION_PARTIAL_SYNC_DISABLED,
- RLM_SYNC_ERR_SESSION_UNSUPPORTED_SESSION_FEATURE,
- RLM_SYNC_ERR_SESSION_BAD_ORIGIN_FILE_IDENT,
- RLM_SYNC_ERR_SESSION_BAD_CLIENT_FILE,
- RLM_SYNC_ERR_SESSION_SERVER_FILE_DELETED,
- RLM_SYNC_ERR_SESSION_CLIENT_FILE_BLACKLISTED,
- RLM_SYNC_ERR_SESSION_USER_BLACKLISTED,
- RLM_SYNC_ERR_SESSION_TRANSACT_BEFORE_UPLOAD,
- RLM_SYNC_ERR_SESSION_CLIENT_FILE_EXPIRED,
- RLM_SYNC_ERR_SESSION_USER_MISMATCH,
- RLM_SYNC_ERR_SESSION_TOO_MANY_SESSIONS,
- RLM_SYNC_ERR_SESSION_INVALID_SCHEMA_CHANGE,
- RLM_SYNC_ERR_SESSION_BAD_QUERY,
- RLM_SYNC_ERR_SESSION_OBJECT_ALREADY_EXISTS,
- RLM_SYNC_ERR_SESSION_SERVER_PERMISSIONS_CHANGED,
- RLM_SYNC_ERR_SESSION_INITIAL_SYNC_NOT_COMPLETED,
- RLM_SYNC_ERR_SESSION_WRITE_NOT_ALLOWED,
- RLM_SYNC_ERR_SESSION_COMPENSATING_WRITE,
- RLM_SYNC_ERR_SESSION_MIGRATE_TO_FLX,
- RLM_SYNC_ERR_SESSION_BAD_PROGRESS,
- RLM_SYNC_ERR_SESSION_REVERT_TO_PBS,
- RLM_SYNC_ERR_SESSION_BAD_SCHEMA_VERSION,
- RLM_SYNC_ERR_SESSION_SCHEMA_VERSION_CHANGED;
-
- override val nativeValue: Int
- override val description: String?
-}
-
-/**
- * Wrapper for C-API `realm_web_socket_errno`.
- * See https://github.com/realm/realm-core/blob/master/src/realm/error_codes.h#L266
- */
-expect enum class WebsocketErrorCode : CodeDescription {
- RLM_ERR_WEBSOCKET_OK,
- RLM_ERR_WEBSOCKET_GOINGAWAY,
- RLM_ERR_WEBSOCKET_PROTOCOLERROR,
- RLM_ERR_WEBSOCKET_UNSUPPORTEDDATA,
- RLM_ERR_WEBSOCKET_RESERVED,
- RLM_ERR_WEBSOCKET_NOSTATUSRECEIVED,
- RLM_ERR_WEBSOCKET_ABNORMALCLOSURE,
- RLM_ERR_WEBSOCKET_INVALIDPAYLOADDATA,
- RLM_ERR_WEBSOCKET_POLICYVIOLATION,
- RLM_ERR_WEBSOCKET_MESSAGETOOBIG,
- RLM_ERR_WEBSOCKET_INAVALIDEXTENSION,
- RLM_ERR_WEBSOCKET_INTERNALSERVERERROR,
- RLM_ERR_WEBSOCKET_TLSHANDSHAKEFAILED,
- RLM_ERR_WEBSOCKET_UNAUTHORIZED,
- RLM_ERR_WEBSOCKET_FORBIDDEN,
- RLM_ERR_WEBSOCKET_MOVEDPERMANENTLY,
- RLM_ERR_WEBSOCKET_RESOLVE_FAILED,
- RLM_ERR_WEBSOCKET_CONNECTION_FAILED,
- RLM_ERR_WEBSOCKET_READ_ERROR,
- RLM_ERR_WEBSOCKET_WRITE_ERROR,
- RLM_ERR_WEBSOCKET_RETRY_ERROR,
- RLM_ERR_WEBSOCKET_FATAL_ERROR;
-
- override val nativeValue: Int
- override val description: String?
-}
-
-/**
- * Wrapper for C-API `realm_sync_socket_callback_result`
- * See https://github.com/realm/realm-core/blob/master/src/realm/error_codes.h#L298
- */
-expect enum class WebsocketCallbackResult : CodeDescription {
- RLM_ERR_SYNC_SOCKET_SUCCESS,
- RLM_ERR_SYNC_SOCKET_OPERATION_ABORTED,
- RLM_ERR_SYNC_SOCKET_RUNTIME,
- RLM_ERR_SYNC_SOCKET_OUT_OF_MEMORY,
- RLM_ERR_SYNC_SOCKET_ADDRESS_SPACE_EXHAUSTED,
- RLM_ERR_SYNC_SOCKET_CONNECTION_CLOSED,
- RLM_ERR_SYNC_SOCKET_NOT_SUPPORTED,
- RLM_ERR_SYNC_SOCKET_INVALID_ARGUMENT;
-
- override val nativeValue: Int
- override val description: String?
-}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/SyncError.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/SyncError.kt
deleted file mode 100644
index f1d27b8b48..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/SyncError.kt
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.CoreError
-
-/**
- * Wrapper for C-API `realm_sync_error`.
- * See https://github.com/realm/realm-core/blob/master/src/realm.h#L3321
- */
-data class SyncError constructor(
- val errorCode: CoreError,
- val originalFilePath: String?,
- val recoveryFilePath: String?,
- val isFatal: Boolean,
- val isUnrecognizedByClient: Boolean,
- val isClientResetRequested: Boolean,
- val compensatingWrites: Array,
- val userError: Throwable?,
-) {
- // Constructs an SyncError out from a simple code. There are some situations (SyncSessionTransferCompletionCallback)
- // where we receive an error code rather than a full SyncErrorCode, wrapping the code
- // simplifies the error handling logic.
- constructor(
- error: CoreError,
- ) : this(
- errorCode = error,
- originalFilePath = null,
- recoveryFilePath = null,
- isFatal = false,
- isUnrecognizedByClient = false,
- isClientResetRequested = false,
- compensatingWrites = emptyArray(),
- userError = null,
- )
-
- // Constructor used by JNI so we avoid creating too many objects on the JNI side.
- constructor(
- categoryFlags: Int,
- value: Int,
- message: String,
- originalFilePath: String?,
- recoveryFilePath: String?,
- isFatal: Boolean,
- isUnrecognizedByClient: Boolean,
- isClientResetRequested: Boolean,
- compensatingWrites: Array,
- userError: Throwable?,
- ) : this(
- CoreError(categoryFlags, value, message),
- originalFilePath,
- recoveryFilePath,
- isFatal,
- isUnrecognizedByClient,
- isClientResetRequested,
- compensatingWrites,
- userError,
- )
-}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/SyncSessionResyncMode.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/SyncSessionResyncMode.kt
deleted file mode 100644
index 7eeb9804dd..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/SyncSessionResyncMode.kt
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-/**
- * Wrapper for C-API `realm_sync_session_resync_mode`.
- * See https://github.com/realm/realm-core/blob/master/src/realm.h#L3166
- */
-expect enum class SyncSessionResyncMode {
- RLM_SYNC_SESSION_RESYNC_MODE_MANUAL,
- RLM_SYNC_SESSION_RESYNC_MODE_DISCARD_LOCAL,
- RLM_SYNC_SESSION_RESYNC_MODE_RECOVER,
- RLM_SYNC_SESSION_RESYNC_MODE_RECOVER_OR_DISCARD;
-}
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/SyncUserIdentity.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/SyncUserIdentity.kt
deleted file mode 100644
index 3fbca71c76..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/SyncUserIdentity.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-/**
- * Wrapper for `realm_user_identity`.
- * @see https://github.com/realm/realm-core/blob/master/src/realm.h
- */
-data class SyncUserIdentity(val id: String, val provider: AuthProvider)
diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/WebSocketTransport.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/WebSocketTransport.kt
deleted file mode 100644
index 136a535c05..0000000000
--- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/WebSocketTransport.kt
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2023 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.RealmInterop
-import io.realm.kotlin.internal.interop.RealmWebsocketHandlerCallbackPointer
-import io.realm.kotlin.internal.interop.RealmWebsocketProviderPointer
-import kotlinx.coroutines.Job
-
-/**
- * Interface to be implemented by the websocket provider. This helps un-bundle the implementation
- * from Core to leverage the platform capabilities (Proxy, firewall, vpn etc.).
- */
-interface WebSocketTransport {
- /**
- * Submit a handler function to be executed by the event loop.
- */
- fun post(handlerCallback: RealmWebsocketHandlerCallbackPointer)
-
- /**
- * Create and register a new timer whose handler function will be posted
- * to the event loop when the provided delay expires.
- * @return [CancellableTimer] to be called if the timer is to be cancelled before the delay.
- */
- fun createTimer(
- delayInMilliseconds: Long,
- handlerCallback: RealmWebsocketHandlerCallbackPointer,
- ): CancellableTimer
-
- /**
- * Create a new websocket pointed to the server indicated by endpoint and
- * connect to the server. Any events that occur during the execution of the
- * websocket will call directly to the handlers provided by the observer (new messages, error, close events)
- *
- * @return [WebSocketClient] instance to be used by Core to send data, and signal a close session.
- */
- @Suppress("LongParameterList")
- fun connect(
- observer: WebSocketObserver,
- path: String,
- address: String,
- port: Long,
- isSsl: Boolean,
- numProtocols: Long,
- supportedSyncProtocols: String
- ): WebSocketClient
-
- /**
- * Writes to the previously created websocket in [connect] the binary data. The provided [handlerCallback] needs
- * to run in the event loop after a successful write or in case of an error.
- */
- fun write(
- webSocketClient: WebSocketClient,
- data: ByteArray,
- length: Long,
- handlerCallback: RealmWebsocketHandlerCallbackPointer
- )
-
- /**
- * This helper function run the provided function pointer. It needs to be called within the same event loop context (thread)
- * as the rest of the other functions.
- */
- fun runCallback(
- handlerCallback: RealmWebsocketHandlerCallbackPointer,
- cancelled: Boolean = false,
- status: WebsocketCallbackResult = WebsocketCallbackResult.RLM_ERR_SYNC_SOCKET_SUCCESS,
- reason: String = ""
- ) {
- RealmInterop.realm_sync_socket_callback_complete(
- handlerCallback, cancelled, status, reason
- )
- }
-
- /**
- * Core signal the transport, all websockets previously created with [connect] would have been closed at this point
- * this is useful to do any resource cleanup like shutting down the engine or closing coroutine dispatcher.
- */
- fun close()
-}
-
-/**
- * Cancel a previously scheduled timer created via [WebSocketTransport.createTimer].
- */
-class CancellableTimer(
- private val job: Job,
- private val cancelCallback: () -> Unit
-) {
- fun cancel() {
- job.cancel()
- cancelCallback()
- }
-}
-
-/**
- * Define an interface to interact with the websocket created via [WebSocketTransport.connect].
- * This will be called from Core.
- */
-interface WebSocketClient {
- /**
- * Send a binary Frame to the remote peer.
- */
- fun send(message: ByteArray, handlerCallback: RealmWebsocketHandlerCallbackPointer)
-
- /**
- * Close the websocket.
- */
- fun close()
-}
-
-/**
- * Defines an abstraction of the underlying Http engine used to create the websocket.
- * This abstraction is needed in order to deterministically create and shutdown the engine at the transport level.
- * All websocket within the same App share the same transport and by definition the same engine.
- */
-interface WebsocketEngine {
- fun shutdown()
- fun getInstance(): T
-}
-
-/**
- * Wrapper around Core callback pointer (observer). This will delegate calls for all incoming messages from the remote peer.
- */
-class WebSocketObserver(private val webSocketObserverPointer: RealmWebsocketProviderPointer) {
- /**
- * Communicate the negotiated Sync protocol.
- */
- fun onConnected(protocol: String) {
- RealmInterop.realm_sync_socket_websocket_connected(webSocketObserverPointer, protocol)
- }
-
- /**
- * Notify an error.
- */
- fun onError() {
- RealmInterop.realm_sync_socket_websocket_error(webSocketObserverPointer)
- }
-
- /**
- * Forward received message to Core.
- */
- fun onNewMessage(data: ByteArray): Boolean {
- return RealmInterop.realm_sync_socket_websocket_message(webSocketObserverPointer, data)
- }
-
- /**
- * Notify closure message.
- */
- fun onClose(wasClean: Boolean, errorCode: WebsocketErrorCode, reason: String) {
- RealmInterop.realm_sync_socket_websocket_closed(
- webSocketObserverPointer, wasClean, errorCode, reason
- )
- }
-}
diff --git a/packages/cinterop/src/jvm/jni/java_class_global_def.hpp b/packages/cinterop/src/jvm/jni/java_class_global_def.hpp
index 2c202ca1f6..cd721f9c15 100644
--- a/packages/cinterop/src/jvm/jni/java_class_global_def.hpp
+++ b/packages/cinterop/src/jvm/jni/java_class_global_def.hpp
@@ -48,30 +48,10 @@ class JavaClassGlobalDef {
, m_java_lang_string(env, "java/lang/String", false)
, m_kotlin_jvm_functions_function0(env, "kotlin/jvm/functions/Function0", false)
, m_kotlin_jvm_functions_function1(env, "kotlin/jvm/functions/Function1", false)
- , m_io_realm_kotlin_internal_interop_sync_network_transport(env, "io/realm/kotlin/internal/interop/sync/NetworkTransport", false)
- , m_io_realm_kotlin_internal_interop_sync_response(env, "io/realm/kotlin/internal/interop/sync/Response", false)
, m_io_realm_kotlin_internal_interop_long_pointer_wrapper(env, "io/realm/kotlin/internal/interop/LongPointerWrapper", false)
- , m_io_realm_kotlin_internal_interop_sync_sync_error(env, "io/realm/kotlin/internal/interop/sync/SyncError", false)
- , m_io_realm_kotlin_internal_interop_sync_core_compensating_write_info(env, "io/realm/kotlin/internal/interop/sync/CoreCompensatingWriteInfo", false)
- , m_io_realm_kotlin_internal_interop_sync_app_error(env, "io/realm/kotlin/internal/interop/sync/AppError", false)
, m_io_realm_kotlin_internal_interop_log_callback(env, "io/realm/kotlin/internal/interop/LogCallback", false)
- , m_io_realm_kotlin_internal_interop_sync_error_callback(env, "io/realm/kotlin/internal/interop/SyncErrorCallback", false)
- , m_io_realm_kotlin_internal_interop_sync_jvm_sync_session_transfer_completion_callback(env, "io/realm/kotlin/internal/interop/sync/JVMSyncSessionTransferCompletionCallback", false)
- , m_io_realm_kotlin_internal_interop_sync_response_callback_impl(env, "io/realm/kotlin/internal/interop/sync/ResponseCallbackImpl", false)
- , m_io_realm_kotlin_internal_interop_subscription_set_callback(env, "io/realm/kotlin/internal/interop/SubscriptionSetCallback", false)
- , m_io_realm_kotlin_internal_interop_sync_before_client_reset_handler(env, "io/realm/kotlin/internal/interop/SyncBeforeClientResetHandler", false)
- , m_io_realm_kotlin_internal_interop_sync_after_client_reset_handler(env, "io/realm/kotlin/internal/interop/SyncAfterClientResetHandler", false)
, m_io_realm_kotlin_internal_interop_core_error_converter(env, "io/realm/kotlin/internal/interop/CoreErrorConverter", false)
- , m_io_realm_kotlin_internal_interop_sync_async_open_callback(env, "io/realm/kotlin/internal/interop/AsyncOpenCallback", false)
- , m_io_realm_kotlin_internal_interop_progress_callback(env, "io/realm/kotlin/internal/interop/ProgressCallback", false)
- , m_io_realm_kotlin_internal_interop_app_callback(env, "io/realm/kotlin/internal/interop/AppCallback", false)
- , m_io_realm_kotlin_internal_interop_connection_state_change_callback(env, "io/realm/kotlin/internal/interop/ConnectionStateChangeCallback", false)
- , m_io_realm_kotlin_internal_interop_sync_thread_observer(env, "io/realm/kotlin/internal/interop/SyncThreadObserver", false)
- , m_io_realm_kotlin_internal_interop_sync_websocket_transport(env, "io/realm/kotlin/internal/interop/sync/WebSocketTransport", false)
- , m_io_realm_kotlin_internal_interop_sync_websocket_client(env, "io/realm/kotlin/internal/interop/sync/WebSocketClient", false)
, m_io_realm_kotlin_internal_interop_notification_callback(env, "io/realm/kotlin/internal/interop/NotificationCallback", false)
- , m_io_realm_kotlin_internal_interop_sync_connection_state(env, "io/realm/kotlin/internal/interop/sync/CoreConnectionState", false)
-
{
}
@@ -80,29 +60,10 @@ class JavaClassGlobalDef {
jni_util::JavaClass m_java_lang_string;
jni_util::JavaClass m_kotlin_jvm_functions_function0;
jni_util::JavaClass m_kotlin_jvm_functions_function1;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_sync_network_transport;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_sync_response;
jni_util::JavaClass m_io_realm_kotlin_internal_interop_long_pointer_wrapper;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_sync_sync_error;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_sync_core_compensating_write_info;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_sync_app_error;
jni_util::JavaClass m_io_realm_kotlin_internal_interop_log_callback;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_sync_error_callback;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_sync_jvm_sync_session_transfer_completion_callback;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_sync_response_callback_impl;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_subscription_set_callback;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_sync_before_client_reset_handler;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_sync_after_client_reset_handler;
jni_util::JavaClass m_io_realm_kotlin_internal_interop_core_error_converter;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_sync_async_open_callback;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_progress_callback;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_app_callback;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_connection_state_change_callback;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_sync_thread_observer;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_sync_websocket_transport;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_sync_websocket_client;
jni_util::JavaClass m_io_realm_kotlin_internal_interop_notification_callback;
- jni_util::JavaClass m_io_realm_kotlin_internal_interop_sync_connection_state;
inline static std::unique_ptr& instance()
{
@@ -143,103 +104,20 @@ class JavaClassGlobalDef {
return instance()->m_java_lang_string;
}
- inline static const jni_util::JavaClass& network_transport_class()
- {
- return instance()->m_io_realm_kotlin_internal_interop_sync_network_transport;
- }
-
- inline static const jni_util::JavaClass& network_transport_response_class()
- {
- return instance()->m_io_realm_kotlin_internal_interop_sync_response;
- }
-
inline static const jni_util::JavaClass& long_pointer_wrapper()
{
return instance()->m_io_realm_kotlin_internal_interop_long_pointer_wrapper;
}
-
- inline static const jni_util::JavaClass& sync_error()
- {
- return instance()->m_io_realm_kotlin_internal_interop_sync_sync_error;
- }
-
- inline static const jni_util::JavaClass& core_compensating_write_info()
- {
- return instance()->m_io_realm_kotlin_internal_interop_sync_core_compensating_write_info;
- }
-
- inline static const jni_util::JavaClass& app_error()
- {
- return instance()->m_io_realm_kotlin_internal_interop_sync_app_error;
- }
-
- inline static const jni_util::JavaClass& connection_state()
- {
- return instance()->m_io_realm_kotlin_internal_interop_sync_connection_state;
- }
-
inline static const jni_util::JavaClass& log_callback()
{
return instance()->m_io_realm_kotlin_internal_interop_log_callback;
}
- inline static const jni_util::JavaClass& sync_error_callback()
- {
- return instance()->m_io_realm_kotlin_internal_interop_sync_error_callback;
- }
-
- inline static const jni_util::JavaClass& sync_session_transfer_completion_callback()
- {
- return instance()->m_io_realm_kotlin_internal_interop_sync_jvm_sync_session_transfer_completion_callback;
- };
-
- inline static const jni_util::JavaClass& app_response_callback()
- {
- return instance()->m_io_realm_kotlin_internal_interop_sync_response_callback_impl;
- };
-
- inline static const jni_util::JavaClass& subscriptionset_changed_callback() {
- return instance()->m_io_realm_kotlin_internal_interop_subscription_set_callback;
- }
-
- inline static const jni_util::JavaClass& sync_before_client_reset() {
- return instance()->m_io_realm_kotlin_internal_interop_sync_before_client_reset_handler;
- }
-
- inline static const jni_util::JavaClass& sync_after_client_reset() {
- return instance()->m_io_realm_kotlin_internal_interop_sync_after_client_reset_handler;
- }
-
inline static const jni_util::JavaClass& core_error_converter()
{
return instance()->m_io_realm_kotlin_internal_interop_core_error_converter;
}
- inline static const jni_util::JavaClass& async_open_callback()
- {
- return instance()->m_io_realm_kotlin_internal_interop_sync_async_open_callback;
- }
-
- inline static const jni_util::JavaClass& progress_callback()
- {
- return instance()->m_io_realm_kotlin_internal_interop_progress_callback;
- }
-
- inline static const jni_util::JavaClass& app_callback()
- {
- return instance()->m_io_realm_kotlin_internal_interop_app_callback;
- }
-
- inline static const jni_util::JavaClass& connection_state_change_callback()
- {
- return instance()->m_io_realm_kotlin_internal_interop_connection_state_change_callback;
- }
-
- inline static const jni_util::JavaClass& sync_thread_observer()
- {
- return instance()->m_io_realm_kotlin_internal_interop_sync_thread_observer;
- }
-
inline static const jni_util::JavaClass& notification_callback()
{
return instance()->m_io_realm_kotlin_internal_interop_notification_callback;
@@ -254,14 +132,6 @@ class JavaClassGlobalDef {
return jni_util::JavaMethod(env, instance()->m_kotlin_jvm_functions_function1, "invoke",
"(Ljava/lang/Object;)Ljava/lang/Object;");
}
-
- inline static const jni_util::JavaClass& sync_websocket_transport() {
- return instance()->m_io_realm_kotlin_internal_interop_sync_websocket_transport;
- }
-
- inline static const jni_util::JavaClass& sync_websocket_client() {
- return instance()->m_io_realm_kotlin_internal_interop_sync_websocket_client;
- }
};
} // namespace realm
diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/ClassFlags.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/ClassFlags.kt
index bc0cf17331..04ab279c73 100644
--- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/ClassFlags.kt
+++ b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/ClassFlags.kt
@@ -19,5 +19,4 @@ package io.realm.kotlin.internal.interop
actual object ClassFlags {
actual val RLM_CLASS_NORMAL = realm_class_flags_e.RLM_CLASS_NORMAL
actual val RLM_CLASS_EMBEDDED = realm_class_flags_e.RLM_CLASS_EMBEDDED
- actual val RLM_CLASS_ASYMMETRIC = realm_class_flags_e.RLM_CLASS_ASYMMETRIC
}
diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/ErrorCategory.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/ErrorCategory.kt
index c7afdac182..9bd1e05b6c 100644
--- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/ErrorCategory.kt
+++ b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/ErrorCategory.kt
@@ -24,15 +24,7 @@ actual enum class ErrorCategory(
RLM_ERR_CAT_RUNTIME("Runtime", realm_error_category_e.RLM_ERR_CAT_RUNTIME),
RLM_ERR_CAT_INVALID_ARG("InvalidArg", realm_error_category_e.RLM_ERR_CAT_INVALID_ARG),
RLM_ERR_CAT_FILE_ACCESS("File", realm_error_category_e.RLM_ERR_CAT_FILE_ACCESS),
- RLM_ERR_CAT_SYSTEM_ERROR("System", realm_error_category_e.RLM_ERR_CAT_SYSTEM_ERROR),
- RLM_ERR_CAT_APP_ERROR("App", realm_error_category_e.RLM_ERR_CAT_APP_ERROR),
- RLM_ERR_CAT_CLIENT_ERROR("Client", realm_error_category_e.RLM_ERR_CAT_CLIENT_ERROR),
- RLM_ERR_CAT_JSON_ERROR("Json", realm_error_category_e.RLM_ERR_CAT_JSON_ERROR),
- RLM_ERR_CAT_SERVICE_ERROR("Service", realm_error_category_e.RLM_ERR_CAT_SERVICE_ERROR),
- RLM_ERR_CAT_HTTP_ERROR("Http", realm_error_category_e.RLM_ERR_CAT_HTTP_ERROR),
- RLM_ERR_CAT_CUSTOM_ERROR("Custom", realm_error_category_e.RLM_ERR_CAT_CUSTOM_ERROR),
- RLM_ERR_CAT_WEBSOCKET_ERROR("Websocket", realm_error_category_e.RLM_ERR_CAT_WEBSOCKET_ERROR),
- RLM_ERR_CAT_SYNC_ERROR("Sync", realm_error_category_e.RLM_ERR_CAT_SYNC_ERROR);
+ RLM_ERR_CAT_SYSTEM_ERROR("System", realm_error_category_e.RLM_ERR_CAT_SYSTEM_ERROR);
actual companion object {
internal actual fun of(nativeValue: Int): ErrorCategory? =
diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt
index 849e75f94d..b127f9b710 100644
--- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt
+++ b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt
@@ -17,21 +17,6 @@
package io.realm.kotlin.internal.interop
import io.realm.kotlin.internal.interop.Constants.ENCRYPTION_KEY_LENGTH
-import io.realm.kotlin.internal.interop.sync.ApiKeyWrapper
-import io.realm.kotlin.internal.interop.sync.AuthProvider
-import io.realm.kotlin.internal.interop.sync.CoreConnectionState
-import io.realm.kotlin.internal.interop.sync.CoreSubscriptionSetState
-import io.realm.kotlin.internal.interop.sync.CoreSyncSessionState
-import io.realm.kotlin.internal.interop.sync.CoreUserState
-import io.realm.kotlin.internal.interop.sync.JVMSyncSessionTransferCompletionCallback
-import io.realm.kotlin.internal.interop.sync.MetadataMode
-import io.realm.kotlin.internal.interop.sync.NetworkTransport
-import io.realm.kotlin.internal.interop.sync.ProgressDirection
-import io.realm.kotlin.internal.interop.sync.SyncSessionResyncMode
-import io.realm.kotlin.internal.interop.sync.SyncUserIdentity
-import io.realm.kotlin.internal.interop.sync.WebSocketTransport
-import io.realm.kotlin.internal.interop.sync.WebsocketCallbackResult
-import io.realm.kotlin.internal.interop.sync.WebsocketErrorCode
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
@@ -241,18 +226,6 @@ actual object RealmInterop {
return Pair(realmPtr, fileCreated)
}
- actual fun realm_open_synchronized(config: RealmConfigurationPointer): RealmAsyncOpenTaskPointer {
- return LongPointerWrapper(realmc.realm_open_synchronized(config.cptr()))
- }
-
- actual fun realm_async_open_task_start(task: RealmAsyncOpenTaskPointer, callback: AsyncOpenCallback) {
- realmc.realm_async_open_task_start(task.cptr(), callback)
- }
-
- actual fun realm_async_open_task_cancel(task: RealmAsyncOpenTaskPointer) {
- realmc.realm_async_open_task_cancel(task.cptr())
- }
-
actual fun realm_add_realm_changed_callback(realm: LiveRealmPointer, block: () -> Unit): RealmCallbackTokenPointer {
return LongPointerWrapper(
realmc.realm_add_realm_changed_callback(realm.cptr(), block),
@@ -1152,215 +1125,6 @@ actual object RealmInterop {
builder.initModifications(modifiedKeys.toTypedArray())
}
- actual fun realm_app_get(
- appConfig: RealmAppConfigurationPointer,
- basePath: String
- ): RealmAppPointer {
- return LongPointerWrapper(realmc.realm_app_create(appConfig.cptr()), managed = true)
- }
-
- actual fun realm_app_log_in_with_credentials(
- app: RealmAppPointer,
- credentials: RealmCredentialsPointer,
- callback: AppCallback
- ) {
- realmc.realm_app_log_in_with_credentials(app.cptr(), credentials.cptr(), callback)
- }
-
- actual fun realm_app_log_out(
- app: RealmAppPointer,
- user: RealmUserPointer,
- callback: AppCallback
- ) {
- realmc.realm_app_log_out(app.cptr(), user.cptr(), callback)
- }
-
- actual fun realm_app_remove_user(
- app: RealmAppPointer,
- user: RealmUserPointer,
- callback: AppCallback
- ) {
- realmc.realm_app_remove_user(app.cptr(), user.cptr(), callback)
- }
-
- actual fun realm_app_delete_user(
- app: RealmAppPointer,
- user: RealmUserPointer,
- callback: AppCallback
- ) {
- realmc.realm_app_delete_user(app.cptr(), user.cptr(), callback)
- }
-
- actual fun realm_app_link_credentials(
- app: RealmAppPointer,
- user: RealmUserPointer,
- credentials: RealmCredentialsPointer,
- callback: AppCallback
- ) {
- realmc.realm_app_link_user(app.cptr(), user.cptr(), credentials.cptr(), callback)
- }
-
- actual fun realm_app_switch_user(app: RealmAppPointer, user: RealmUserPointer) {
- realmc.realm_app_switch_user(app.cptr(), user.cptr())
- }
-
- actual fun realm_app_get_current_user(app: RealmAppPointer): RealmUserPointer? {
- val ptr = realmc.realm_app_get_current_user(app.cptr())
- return nativePointerOrNull(ptr)
- }
-
- actual fun realm_app_get_all_users(app: RealmAppPointer): List {
- // We get the current amount of users by providing a zero-sized array and `out_n`
- // argument. Then the current count is written to `out_n`.
- // See https://github.com/realm/realm-core/blob/master/src/realm.h#L2634
- val capacityCount = LongArray(1)
- realmc.realm_app_get_all_users(app.cptr(), LongArray(0), 0, capacityCount)
-
- // Read actual users. We don't care about the small chance of missing a new user
- // between these two calls as that indicate two sections of user code running on
- // different threads and not coordinating.
- val actualUsersCount = LongArray(1)
- val users = LongArray(capacityCount[0].toInt())
- realmc.realm_app_get_all_users(app.cptr(), users, capacityCount[0], actualUsersCount)
- val result: MutableList = mutableListOf()
- for (i in 0 until actualUsersCount[0].toInt()) {
- users[i].let { ptr: Long ->
- result.add(LongPointerWrapper(ptr, managed = true))
- }
- }
- return result
- }
-
- actual fun realm_app_get_base_url(
- app: RealmAppPointer,
- ): String = realmc.realm_app_get_base_url(app.cptr())
-
- actual fun realm_app_update_base_url(
- app: RealmAppPointer,
- baseUrl: String?,
- callback: AppCallback,
- ) {
- realmc.realm_app_update_base_url(app.cptr(), baseUrl, callback)
- }
-
- actual fun realm_user_get_all_identities(user: RealmUserPointer): List {
- val count = AuthProvider.values().size.toLong() // Optimistically allocate the max size of the array
- val keys = realmc.new_identityArray(count.toInt())
- val outCount = longArrayOf(0)
- realmc.realm_user_get_all_identities(user.cptr(), keys, count, outCount)
- return if (outCount[0] > 0) {
- (0 until outCount[0]).map { i ->
- with(realmc.identityArray_getitem(keys, i.toInt())) {
- SyncUserIdentity(this.id, AuthProvider.of(this.provider_type))
- }
- }
- } else {
- emptyList()
- }.also {
- realmc.delete_identityArray(keys)
- }
- }
-
- actual fun realm_user_get_identity(user: RealmUserPointer): String {
- return realmc.realm_user_get_identity(user.cptr())
- }
-
- actual fun realm_user_get_access_token(user: RealmUserPointer): String {
- return realmc.realm_user_get_access_token(user.cptr())
- }
-
- actual fun realm_user_get_refresh_token(user: RealmUserPointer): String {
- return realmc.realm_user_get_refresh_token(user.cptr())
- }
-
- actual fun realm_user_get_device_id(user: RealmUserPointer): String {
- return realmc.realm_user_get_device_id(user.cptr())
- }
-
- actual fun realm_user_is_logged_in(user: RealmUserPointer): Boolean {
- return realmc.realm_user_is_logged_in(user.cptr())
- }
-
- actual fun realm_user_log_out(user: RealmUserPointer) {
- realmc.realm_user_log_out(user.cptr())
- }
-
- actual fun realm_user_get_state(user: RealmUserPointer): CoreUserState {
- return CoreUserState.of(realmc.realm_user_get_state(user.cptr()))
- }
-
- actual fun realm_user_get_profile(user: RealmUserPointer): String =
- realmc.realm_user_get_profile_data(user.cptr())
-
- actual fun realm_user_get_custom_data(user: RealmUserPointer): String? =
- realmc.realm_user_get_custom_data(user.cptr())
-
- actual fun realm_user_refresh_custom_data(app: RealmAppPointer, user: RealmUserPointer, callback: AppCallback) {
- realmc.realm_app_refresh_custom_data(app.cptr(), user.cptr(), callback)
- }
-
- actual fun realm_clear_cached_apps() {
- realmc.realm_clear_cached_apps()
- }
-
- actual fun realm_app_sync_client_get_default_file_path_for_realm(
- syncConfig: RealmSyncConfigurationPointer,
- overriddenName: String?
- ): String {
- return realmc.realm_app_sync_client_get_default_file_path_for_realm(
- syncConfig.cptr(),
- overriddenName
- )
- }
-
- actual fun realm_app_config_get_sync_client_config(configPointer: RealmAppConfigurationPointer): RealmSyncClientConfigurationPointer {
- // The configuration is owned by Core so don't track and release it through garbage collection of the NativePointer
- return LongPointerWrapper(realmc.realm_app_config_get_sync_client_config(configPointer.cptr()), false)
- }
-
- actual fun realm_sync_client_config_set_default_binding_thread_observer(syncClientConfig: RealmSyncClientConfigurationPointer, appId: String) {
- realmc.realm_sync_client_config_set_default_binding_thread_observer(
- syncClientConfig.cptr(),
- object : SyncThreadObserver {
- override fun threadName(): String {
- return "SyncThread-$appId"
- }
-
- override fun onCreated() {
- // We cannot set the name on JNI side as it would require access to JNIEnv before
- // we attach it, so we set the thread name after it is created.
- Thread.currentThread().name = threadName()
- }
-
- override fun onDestroyed() {
- // Do nothing
- // Thread is destroyed in the JNI side
- }
-
- @Suppress("TooGenericExceptionThrown")
- override fun onError(error: String) {
- // TODO Wait for https://github.com/realm/realm-core/issues/4194 to correctly
- // log errors. For now, just throw an Error as exceptions from the Sync Client
- // indicate that something is fundamentally wrong on the Sync Thread.
- // In Realm Java this has only been reported during development of new
- // features, so throwing an Error seems appropriate to increase visibility.
- throw Error("[${threadName()}] Error on sync thread : $error")
- }
- }
- )
- }
-
- actual fun realm_app_config_set_base_file_path(
- appConfig: RealmAppConfigurationPointer,
- basePath: String
- ) {
- realmc.realm_app_config_set_base_file_path(appConfig.cptr(), basePath)
- }
-
- actual fun realm_sync_client_config_set_multiplex_sessions(syncClientConfig: RealmSyncClientConfigurationPointer, enabled: Boolean) {
- realmc.realm_sync_client_config_set_multiplex_sessions(syncClientConfig.cptr(), enabled)
- }
-
actual fun realm_set_log_callback(callback: LogCallback) {
realmc.set_log_callback(callback)
}
@@ -1382,394 +1146,6 @@ actual object RealmInterop {
return names.asList()
}
- actual fun realm_app_config_set_metadata_mode(
- appConfig: RealmAppConfigurationPointer,
- metadataMode: MetadataMode,
- ) {
- realmc.realm_app_config_set_metadata_mode(
- appConfig.cptr(),
- metadataMode.nativeValue
- )
- }
-
- actual fun realm_app_config_set_metadata_encryption_key(
- appConfig: RealmAppConfigurationPointer,
- encryptionKey: ByteArray
- ) {
- realmc.realm_app_config_set_metadata_encryption_key(
- appConfig.cptr(),
- encryptionKey
- )
- }
-
- actual fun realm_sync_client_config_set_user_agent_binding_info(
- syncClientConfig: RealmSyncClientConfigurationPointer,
- bindingInfo: String
- ) {
- realmc.realm_sync_client_config_set_user_agent_binding_info(
- syncClientConfig.cptr(),
- bindingInfo
- )
- }
-
- actual fun realm_sync_client_config_set_user_agent_application_info(
- syncClientConfig: RealmSyncClientConfigurationPointer,
- applicationInfo: String
- ) {
- realmc.realm_sync_client_config_set_user_agent_application_info(
- syncClientConfig.cptr(),
- applicationInfo
- )
- }
-
- actual fun realm_sync_client_config_set_connect_timeout(syncClientConfig: RealmSyncClientConfigurationPointer, timeoutMs: ULong) {
- realmc.realm_sync_client_config_set_connect_timeout(syncClientConfig.cptr(), timeoutMs.toLong())
- }
-
- actual fun realm_sync_client_config_set_connection_linger_time(syncClientConfig: RealmSyncClientConfigurationPointer, timeoutMs: ULong) {
- realmc.realm_sync_client_config_set_connection_linger_time(syncClientConfig.cptr(), timeoutMs.toLong())
- }
-
- actual fun realm_sync_client_config_set_ping_keepalive_period(syncClientConfig: RealmSyncClientConfigurationPointer, timeoutMs: ULong) {
- realmc.realm_sync_client_config_set_ping_keepalive_period(syncClientConfig.cptr(), timeoutMs.toLong())
- }
-
- actual fun realm_sync_client_config_set_pong_keepalive_timeout(syncClientConfig: RealmSyncClientConfigurationPointer, timeoutMs: ULong) {
- realmc.realm_sync_client_config_set_pong_keepalive_timeout(syncClientConfig.cptr(), timeoutMs.toLong())
- }
-
- actual fun realm_sync_client_config_set_fast_reconnect_limit(syncClientConfig: RealmSyncClientConfigurationPointer, timeoutMs: ULong) {
- realmc.realm_sync_client_config_set_fast_reconnect_limit(syncClientConfig.cptr(), timeoutMs.toLong())
- }
-
- actual fun realm_network_transport_new(networkTransport: NetworkTransport): RealmNetworkTransportPointer {
- return LongPointerWrapper(realmc.realm_network_transport_new(networkTransport))
- }
-
- actual fun realm_sync_config_set_error_handler(
- syncConfig: RealmSyncConfigurationPointer,
- errorHandler: SyncErrorCallback
- ) {
- realmc.sync_set_error_handler(syncConfig.cptr(), errorHandler)
- }
-
- actual fun realm_sync_config_set_resync_mode(
- syncConfig: RealmSyncConfigurationPointer,
- resyncMode: SyncSessionResyncMode
- ) {
- realmc.realm_sync_config_set_resync_mode(syncConfig.cptr(), resyncMode.nativeValue)
- }
-
- actual fun realm_sync_config_set_before_client_reset_handler(
- syncConfig: RealmSyncConfigurationPointer,
- beforeHandler: SyncBeforeClientResetHandler
- ) {
- realmc.sync_before_client_reset_handler(syncConfig.cptr(), beforeHandler)
- }
-
- actual fun realm_sync_config_set_after_client_reset_handler(
- syncConfig: RealmSyncConfigurationPointer,
- afterHandler: SyncAfterClientResetHandler
- ) {
- realmc.sync_after_client_reset_handler(syncConfig.cptr(), afterHandler)
- }
-
- actual fun realm_sync_immediately_run_file_actions(app: RealmAppPointer, syncPath: String): Boolean {
- val didRun = booleanArrayOf(false)
- realmc.realm_sync_immediately_run_file_actions(app.cptr(), syncPath, didRun)
- return didRun.first()
- }
-
- actual fun realm_sync_session_get(realm: RealmPointer): RealmSyncSessionPointer {
- return LongPointerWrapper(realmc.realm_sync_session_get(realm.cptr()))
- }
-
- actual fun realm_sync_session_wait_for_download_completion(
- syncSession: RealmSyncSessionPointer,
- callback: SyncSessionTransferCompletionCallback
- ) {
- realmc.realm_sync_session_wait_for_download_completion(
- syncSession.cptr(),
- JVMSyncSessionTransferCompletionCallback(callback)
- )
- }
-
- actual fun realm_sync_session_wait_for_upload_completion(
- syncSession: RealmSyncSessionPointer,
- callback: SyncSessionTransferCompletionCallback
- ) {
- realmc.realm_sync_session_wait_for_upload_completion(
- syncSession.cptr(),
- JVMSyncSessionTransferCompletionCallback(callback)
- )
- }
-
- actual fun realm_sync_session_state(syncSession: RealmSyncSessionPointer): CoreSyncSessionState {
- return CoreSyncSessionState.of(realmc.realm_sync_session_get_state(syncSession.cptr()))
- }
- actual fun realm_sync_connection_state(syncSession: RealmSyncSessionPointer): CoreConnectionState {
- return CoreConnectionState.of(realmc.realm_sync_session_get_connection_state(syncSession.cptr()))
- }
-
- actual fun realm_sync_session_pause(syncSession: RealmSyncSessionPointer) {
- realmc.realm_sync_session_pause(syncSession.cptr())
- }
-
- actual fun realm_sync_session_resume(syncSession: RealmSyncSessionPointer) {
- realmc.realm_sync_session_resume(syncSession.cptr())
- }
-
- actual fun realm_sync_session_handle_error_for_testing(
- syncSession: RealmSyncSessionPointer,
- error: ErrorCode,
- errorMessage: String,
- isFatal: Boolean
- ) {
- realmc.realm_sync_session_handle_error_for_testing(
- syncSession.cptr(),
- error.nativeValue,
- errorMessage,
- isFatal
- )
- }
-
- actual fun realm_sync_session_register_progress_notifier(
- syncSession: RealmSyncSessionPointer,
- direction: ProgressDirection,
- isStreaming: Boolean,
- callback: ProgressCallback,
- ): RealmNotificationTokenPointer {
- return LongPointerWrapper(
- realmc.realm_sync_session_register_progress_notifier_wrapper(
- syncSession.cptr(),
- direction.nativeValue,
- isStreaming,
- callback
- ),
- managed = false
- )
- }
-
- actual fun realm_sync_session_register_connection_state_change_callback(
- syncSession: RealmSyncSessionPointer,
- callback: ConnectionStateChangeCallback,
- ): RealmNotificationTokenPointer {
- return LongPointerWrapper(
- realmc.realm_sync_session_register_connection_state_change_callback(
- syncSession.cptr(),
- callback
- ),
- managed = false
- )
- }
-
- @Suppress("LongParameterList")
- actual fun realm_app_config_new(
- appId: String,
- networkTransport: RealmNetworkTransportPointer,
- baseUrl: String?,
- connectionParams: SyncConnectionParams
- ): RealmAppConfigurationPointer {
- val config = realmc.realm_app_config_new(appId, networkTransport.cptr())
-
- baseUrl?.let { realmc.realm_app_config_set_base_url(config, it) }
-
- // Sync Connection Parameters
- realmc.realm_app_config_set_sdk(config, connectionParams.sdkName)
- realmc.realm_app_config_set_sdk_version(config, connectionParams.sdkVersion)
- realmc.realm_app_config_set_platform_version(config, connectionParams.platformVersion)
- realmc.realm_app_config_set_device_name(config, connectionParams.device)
- realmc.realm_app_config_set_device_version(config, connectionParams.deviceVersion)
- realmc.realm_app_config_set_framework_name(config, connectionParams.framework)
- realmc.realm_app_config_set_framework_version(config, connectionParams.frameworkVersion)
- realmc.realm_app_config_set_bundle_id(config, connectionParams.bundleId)
-
- return LongPointerWrapper(config)
- }
-
- actual fun realm_app_config_set_base_url(appConfig: RealmAppConfigurationPointer, baseUrl: String) {
- realmc.realm_app_config_set_base_url(appConfig.cptr(), baseUrl)
- }
-
- actual fun realm_app_credentials_new_anonymous(reuseExisting: Boolean): RealmCredentialsPointer {
- return LongPointerWrapper(realmc.realm_app_credentials_new_anonymous(reuseExisting))
- }
-
- actual fun realm_app_credentials_new_email_password(username: String, password: String): RealmCredentialsPointer {
- return LongPointerWrapper(realmc.realm_app_credentials_new_email_password(username, password))
- }
-
- actual fun realm_app_credentials_new_api_key(key: String): RealmCredentialsPointer {
- return LongPointerWrapper(realmc.realm_app_credentials_new_api_key(key))
- }
-
- actual fun realm_app_credentials_new_apple(idToken: String): RealmCredentialsPointer {
- return LongPointerWrapper(realmc.realm_app_credentials_new_apple(idToken))
- }
-
- actual fun realm_app_credentials_new_facebook(accessToken: String): RealmCredentialsPointer {
- return LongPointerWrapper(realmc.realm_app_credentials_new_facebook(accessToken))
- }
-
- actual fun realm_app_credentials_new_google_id_token(idToken: String): RealmCredentialsPointer {
- return LongPointerWrapper(realmc.realm_app_credentials_new_google_id_token(idToken))
- }
-
- actual fun realm_app_credentials_new_google_auth_code(authCode: String): RealmCredentialsPointer {
- return LongPointerWrapper(realmc.realm_app_credentials_new_google_auth_code(authCode))
- }
-
- actual fun realm_app_credentials_new_jwt(jwtToken: String): RealmCredentialsPointer {
- return LongPointerWrapper(realmc.realm_app_credentials_new_jwt(jwtToken))
- }
-
- actual fun realm_app_credentials_new_custom_function(serializedEjsonPayload: String): RealmCredentialsPointer {
- return LongPointerWrapper(realmc.realm_app_credentials_new_function(serializedEjsonPayload))
- }
-
- actual fun realm_auth_credentials_get_provider(credentials: RealmCredentialsPointer): AuthProvider {
- return AuthProvider.of(realmc.realm_auth_credentials_get_provider(credentials.cptr()))
- }
-
- actual fun realm_app_credentials_serialize_as_json(credentials: RealmCredentialsPointer): String {
- return realmc.realm_app_credentials_serialize_as_json(credentials.cptr())
- }
-
- actual fun realm_app_email_password_provider_client_register_email(
- app: RealmAppPointer,
- email: String,
- password: String,
- callback: AppCallback
- ) {
- realmc.realm_app_email_password_provider_client_register_email(
- app.cptr(),
- email,
- password,
- callback
- )
- }
-
- actual fun realm_app_email_password_provider_client_confirm_user(
- app: RealmAppPointer,
- token: String,
- tokenId: String,
- callback: AppCallback
- ) {
- realmc.realm_app_email_password_provider_client_confirm_user(
- app.cptr(),
- token,
- tokenId,
- callback
- )
- }
-
- actual fun realm_app_email_password_provider_client_resend_confirmation_email(
- app: RealmAppPointer,
- email: String,
- callback: AppCallback
- ) {
- realmc.realm_app_email_password_provider_client_resend_confirmation_email(
- app.cptr(),
- email,
- callback
- )
- }
-
- actual fun realm_app_email_password_provider_client_retry_custom_confirmation(
- app: RealmAppPointer,
- email: String,
- callback: AppCallback
- ) {
- realmc.realm_app_email_password_provider_client_retry_custom_confirmation(
- app.cptr(),
- email,
- callback
- )
- }
-
- actual fun realm_app_email_password_provider_client_send_reset_password_email(
- app: RealmAppPointer,
- email: String,
- callback: AppCallback
- ) {
- realmc.realm_app_email_password_provider_client_send_reset_password_email(
- app.cptr(),
- email,
- callback
- )
- }
-
- actual fun realm_app_email_password_provider_client_reset_password(
- app: RealmAppPointer,
- token: String,
- tokenId: String,
- newPassword: String,
- callback: AppCallback
- ) {
- realmc.realm_app_email_password_provider_client_reset_password(
- app.cptr(),
- token,
- tokenId,
- newPassword,
- callback
- )
- }
-
- @Suppress("LongParameterList")
- actual fun realm_app_call_function(
- app: RealmAppPointer,
- user: RealmUserPointer,
- name: String,
- serviceName: String?,
- serializedEjsonArgs: String,
- callback: AppCallback
- ) {
- realmc.realm_app_call_function(app.cptr(), user.cptr(), name, serializedEjsonArgs, serviceName, callback)
- }
-
- actual fun realm_app_call_reset_password_function(
- app: RealmAppPointer,
- email: String,
- newPassword: String,
- serializedEjsonPayload: String,
- callback: AppCallback
- ) {
- realmc.realm_app_email_password_provider_client_call_reset_password_function(
- app.cptr(),
- email,
- newPassword,
- serializedEjsonPayload,
- callback
- )
- }
-
- actual fun realm_app_sync_client_reconnect(app: RealmAppPointer) {
- realmc.realm_app_sync_client_reconnect(app.cptr())
- }
- actual fun realm_app_sync_client_has_sessions(app: RealmAppPointer): Boolean {
- return realmc.realm_app_sync_client_has_sessions(app.cptr())
- }
-
- actual fun realm_app_sync_client_wait_for_sessions_to_terminate(app: RealmAppPointer) {
- realmc.realm_app_sync_client_wait_for_sessions_to_terminate(app.cptr())
- }
-
- actual fun realm_sync_config_new(user: RealmUserPointer, partition: String): RealmSyncConfigurationPointer {
- return LongPointerWrapper(realmc.realm_sync_config_new(user.cptr(), partition)).also { ptr ->
- // Stop the session immediately when the Realm is closed, so the lifecycle of the
- // Sync Client thread is manageable.
- realmc.realm_sync_config_set_session_stop_policy(ptr.cptr(), realm_sync_session_stop_policy_e.RLM_SYNC_SESSION_STOP_POLICY_IMMEDIATELY)
- }
- }
-
- actual fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer {
- return LongPointerWrapper(realmc.realm_flx_sync_config_new(user.cptr()))
- }
-
- actual fun realm_config_set_sync_config(realmConfiguration: RealmConfigurationPointer, syncConfiguration: RealmSyncConfigurationPointer) {
- realmc.realm_config_set_sync_config(realmConfiguration.cptr(), syncConfiguration.cptr())
- }
-
private fun classInfo(realm: RealmPointer, className: String): realm_class_info_t {
val found = booleanArrayOf(false)
val classInfo = realm_class_info_t()
@@ -1988,214 +1364,6 @@ actual object RealmInterop {
realmc.realm_object_delete(obj.cptr())
}
- actual fun realm_sync_subscription_id(subscription: RealmSubscriptionPointer): ObjectId {
- val nativeBytes: ShortArray = realmc.realm_sync_subscription_id(subscription.cptr()).bytes
- val byteArray = ByteArray(nativeBytes.size)
- nativeBytes.mapIndexed { index, b -> byteArray[index] = b.toByte() }
- return ObjectId(byteArray)
- }
-
- actual fun realm_sync_subscription_name(subscription: RealmSubscriptionPointer): String? {
- return realmc.realm_sync_subscription_name(subscription.cptr())
- }
-
- actual fun realm_sync_subscription_object_class_name(subscription: RealmSubscriptionPointer): String {
- return realmc.realm_sync_subscription_object_class_name(subscription.cptr())
- }
-
- actual fun realm_sync_subscription_query_string(subscription: RealmSubscriptionPointer): String {
- return realmc.realm_sync_subscription_query_string(subscription.cptr())
- }
-
- actual fun realm_sync_subscription_created_at(subscription: RealmSubscriptionPointer): Timestamp {
- val ts: realm_timestamp_t = realmc.realm_sync_subscription_created_at(subscription.cptr())
- return TimestampImpl(ts.seconds, ts.nanoseconds)
- }
-
- actual fun realm_sync_subscription_updated_at(subscription: RealmSubscriptionPointer): Timestamp {
- val ts: realm_timestamp_t = realmc.realm_sync_subscription_updated_at(subscription.cptr())
- return TimestampImpl(ts.seconds, ts.nanoseconds)
- }
-
- actual fun realm_sync_get_latest_subscriptionset(realm: RealmPointer): RealmSubscriptionSetPointer {
- return LongPointerWrapper(realmc.realm_sync_get_latest_subscription_set(realm.cptr()))
- }
-
- actual fun realm_sync_on_subscriptionset_state_change_async(
- subscriptionSet: RealmSubscriptionSetPointer,
- destinationState: CoreSubscriptionSetState,
- callback: SubscriptionSetCallback
- ) {
- val jvmWrapper: (Int) -> Any = { value: Int ->
- callback.onChange(CoreSubscriptionSetState.of(value))
- }
- realmc.realm_sync_on_subscription_set_state_change_async(
- subscriptionSet.cptr(),
- destinationState.nativeValue,
- jvmWrapper
- )
- }
-
- actual fun realm_sync_subscriptionset_version(subscriptionSet: RealmBaseSubscriptionSetPointer): Long {
- return realmc.realm_sync_subscription_set_version(subscriptionSet.cptr())
- }
-
- actual fun realm_sync_subscriptionset_state(subscriptionSet: RealmBaseSubscriptionSetPointer): CoreSubscriptionSetState {
- return CoreSubscriptionSetState.of(realmc.realm_sync_subscription_set_state(subscriptionSet.cptr()))
- }
-
- actual fun realm_sync_subscriptionset_error_str(subscriptionSet: RealmBaseSubscriptionSetPointer): String? {
- return realmc.realm_sync_subscription_set_error_str(subscriptionSet.cptr())
- }
-
- actual fun realm_sync_subscriptionset_size(subscriptionSet: RealmBaseSubscriptionSetPointer): Long {
- return realmc.realm_sync_subscription_set_size(subscriptionSet.cptr())
- }
-
- actual fun realm_sync_subscription_at(
- subscriptionSet: RealmBaseSubscriptionSetPointer,
- index: Long
- ): RealmSubscriptionPointer {
- return LongPointerWrapper(realmc.realm_sync_subscription_at(subscriptionSet.cptr(), index))
- }
-
- actual fun realm_sync_find_subscription_by_name(
- subscriptionSet: RealmBaseSubscriptionSetPointer,
- name: String
- ): RealmSubscriptionPointer? {
- val ptr = realmc.realm_sync_find_subscription_by_name(subscriptionSet.cptr(), name)
- return nativePointerOrNull(ptr)
- }
-
- actual fun realm_sync_find_subscription_by_query(
- subscriptionSet: RealmBaseSubscriptionSetPointer,
- query: RealmQueryPointer
- ): RealmSubscriptionPointer? {
- val ptr = realmc.realm_sync_find_subscription_by_query(subscriptionSet.cptr(), query.cptr())
- return nativePointerOrNull(ptr)
- }
-
- actual fun realm_sync_subscriptionset_refresh(subscriptionSet: RealmSubscriptionSetPointer): Boolean {
- return realmc.realm_sync_subscription_set_refresh(subscriptionSet.cptr())
- }
-
- actual fun realm_sync_make_subscriptionset_mutable(
- subscriptionSet: RealmSubscriptionSetPointer
- ): RealmMutableSubscriptionSetPointer {
- return LongPointerWrapper(
- realmc.realm_sync_make_subscription_set_mutable(subscriptionSet.cptr()),
- managed = false
- )
- }
-
- actual fun realm_sync_subscriptionset_clear(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer
- ): Boolean {
- val erased = realmc.realm_sync_subscription_set_size(mutableSubscriptionSet.cptr()) > 0
- realmc.realm_sync_subscription_set_clear(mutableSubscriptionSet.cptr())
- return erased
- }
-
- actual fun realm_sync_subscriptionset_insert_or_assign(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer,
- query: RealmQueryPointer,
- name: String?
- ): Pair {
- val outIndex = longArrayOf(1)
- val outInserted = BooleanArray(1)
- realmc.realm_sync_subscription_set_insert_or_assign_query(
- mutableSubscriptionSet.cptr(),
- query.cptr(),
- name,
- outIndex,
- outInserted
- )
- @Suppress("UNCHECKED_CAST")
- return Pair(
- realm_sync_subscription_at(
- mutableSubscriptionSet as RealmSubscriptionSetPointer,
- outIndex[0]
- ),
- outInserted[0]
- )
- }
-
- actual fun realm_sync_subscriptionset_erase_by_name(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer,
- name: String
- ): Boolean {
- val erased = BooleanArray(1)
- realmc.realm_sync_subscription_set_erase_by_name(
- mutableSubscriptionSet.cptr(),
- name,
- erased
- )
- return erased[0]
- }
-
- actual fun realm_sync_subscriptionset_erase_by_query(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer,
- query: RealmQueryPointer
- ): Boolean {
- val erased = BooleanArray(1)
- realmc.realm_sync_subscription_set_erase_by_query(
- mutableSubscriptionSet.cptr(),
- query.cptr(),
- erased
- )
- return erased[0]
- }
-
- actual fun realm_sync_subscriptionset_erase_by_id(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer,
- sub: RealmSubscriptionPointer
- ): Boolean {
- val id = realmc.realm_sync_subscription_id(sub.cptr())
- val erased = BooleanArray(1)
- realmc.realm_sync_subscription_set_erase_by_id(
- mutableSubscriptionSet.cptr(),
- id,
- erased
- )
- return erased[0]
- }
-
- actual fun realm_sync_subscriptionset_commit(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer
- ): RealmSubscriptionSetPointer {
- return LongPointerWrapper(realmc.realm_sync_subscription_set_commit(mutableSubscriptionSet.cptr()))
- }
-
- actual fun realm_sync_set_websocket_transport(
- syncClientConfig: RealmSyncClientConfigurationPointer,
- webSocketTransport: WebSocketTransport
- ) {
- realmc.realm_sync_websocket_new(syncClientConfig.cptr(), webSocketTransport)
- }
-
- actual fun realm_sync_socket_callback_complete(nativePointer: RealmWebsocketHandlerCallbackPointer, cancelled: Boolean, status: WebsocketCallbackResult, reason: String) {
- realmc.realm_sync_websocket_callback_complete(cancelled, nativePointer.cptr(), status.nativeValue, reason)
- }
-
- actual fun realm_sync_socket_websocket_connected(nativePointer: RealmWebsocketProviderPointer, protocol: String) {
- realmc.realm_sync_websocket_connected(nativePointer.cptr(), protocol)
- }
-
- actual fun realm_sync_socket_websocket_error(nativePointer: RealmWebsocketProviderPointer) {
- realmc.realm_sync_websocket_error(nativePointer.cptr())
- }
-
- actual fun realm_sync_socket_websocket_message(
- nativePointer: RealmWebsocketProviderPointer,
- data: ByteArray
- ): Boolean {
- return realmc.realm_sync_websocket_message(nativePointer.cptr(), data, data.size.toLong())
- }
-
- actual fun realm_sync_socket_websocket_closed(nativePointer: RealmWebsocketProviderPointer, wasClean: Boolean, errorCode: WebsocketErrorCode, reason: String) {
- realmc.realm_sync_websocket_closed(nativePointer.cptr(), wasClean, errorCode.nativeValue, reason)
- }
-
fun NativePointer.cptr(): Long {
return (this as LongPointerWrapper).ptr
}
@@ -2207,88 +1375,6 @@ actual object RealmInterop {
null
}
}
-
- actual fun realm_app_user_apikey_provider_client_create_apikey(
- app: RealmAppPointer,
- user: RealmUserPointer,
- name: String,
- callback: AppCallback
- ) {
- realmc.realm_app_user_apikey_provider_client_create_apikey(
- app.cptr(),
- user.cptr(),
- name,
- callback
- )
- }
-
- actual fun realm_app_user_apikey_provider_client_delete_apikey(
- app: RealmAppPointer,
- user: RealmUserPointer,
- id: ObjectId,
- callback: AppCallback
- ) {
- realmc.realm_app_user_apikey_provider_client_delete_apikey(
- app.cptr(),
- user.cptr(),
- id.asRealmObjectIdT(),
- callback
- )
- }
-
- actual fun realm_app_user_apikey_provider_client_disable_apikey(
- app: RealmAppPointer,
- user: RealmUserPointer,
- id: ObjectId,
- callback: AppCallback
- ) {
- realmc.realm_app_user_apikey_provider_client_disable_apikey(
- app.cptr(),
- user.cptr(),
- id.asRealmObjectIdT(),
- callback
- )
- }
-
- actual fun realm_app_user_apikey_provider_client_enable_apikey(
- app: RealmAppPointer,
- user: RealmUserPointer,
- id: ObjectId,
- callback: AppCallback
- ) {
- realmc.realm_app_user_apikey_provider_client_enable_apikey(
- app.cptr(),
- user.cptr(),
- id.asRealmObjectIdT(),
- callback
- )
- }
-
- actual fun realm_app_user_apikey_provider_client_fetch_apikey(
- app: RealmAppPointer,
- user: RealmUserPointer,
- id: ObjectId,
- callback: AppCallback,
- ) {
- realmc.realm_app_user_apikey_provider_client_fetch_apikey(
- app.cptr(),
- user.cptr(),
- id.asRealmObjectIdT(),
- callback
- )
- }
-
- actual fun realm_app_user_apikey_provider_client_fetch_apikeys(
- app: RealmAppPointer,
- user: RealmUserPointer,
- callback: AppCallback>,
- ) {
- realmc.realm_app_user_apikey_provider_client_fetch_apikeys(
- app.cptr(),
- user.cptr(),
- callback
- )
- }
}
fun realm_value_t.asTimestamp(): Timestamp {
diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/AuthProvider.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/AuthProvider.kt
deleted file mode 100644
index 063f666b1c..0000000000
--- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/AuthProvider.kt
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2021 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.NativeEnumerated
-import io.realm.kotlin.internal.interop.realm_auth_provider_e
-
-actual enum class AuthProvider(override val nativeValue: Int) : NativeEnumerated {
- RLM_AUTH_PROVIDER_ANONYMOUS(realm_auth_provider_e.RLM_AUTH_PROVIDER_ANONYMOUS),
- RLM_AUTH_PROVIDER_ANONYMOUS_NO_REUSE(realm_auth_provider_e.RLM_AUTH_PROVIDER_ANONYMOUS_NO_REUSE),
- RLM_AUTH_PROVIDER_FACEBOOK(realm_auth_provider_e.RLM_AUTH_PROVIDER_FACEBOOK),
- RLM_AUTH_PROVIDER_GOOGLE(realm_auth_provider_e.RLM_AUTH_PROVIDER_GOOGLE),
- RLM_AUTH_PROVIDER_APPLE(realm_auth_provider_e.RLM_AUTH_PROVIDER_APPLE),
- RLM_AUTH_PROVIDER_CUSTOM(realm_auth_provider_e.RLM_AUTH_PROVIDER_CUSTOM),
- RLM_AUTH_PROVIDER_EMAIL_PASSWORD(realm_auth_provider_e.RLM_AUTH_PROVIDER_EMAIL_PASSWORD),
- RLM_AUTH_PROVIDER_FUNCTION(realm_auth_provider_e.RLM_AUTH_PROVIDER_FUNCTION),
- RLM_AUTH_PROVIDER_API_KEY(realm_auth_provider_e.RLM_AUTH_PROVIDER_API_KEY);
-
- companion object {
- // TODO Optimize
- fun of(id: Int): AuthProvider {
- for (value in AuthProvider.values()) {
- if (value.nativeValue == id) {
- return value
- }
- }
- error("Unknown authentication provider $id")
- }
- }
-}
diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/CoreCompensatingWriteInfo.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/CoreCompensatingWriteInfo.kt
deleted file mode 100644
index 4ac2ce056e..0000000000
--- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/CoreCompensatingWriteInfo.kt
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2023 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.RealmValue
-import io.realm.kotlin.internal.interop.wrapPtrAsRealmValueT
-
-actual class CoreCompensatingWriteInfo(
- actual val reason: String,
- actual val objectName: String,
- primaryKeyPtr: Long
-) {
-
- actual val primaryKey: RealmValue = RealmValue(primaryKeyPtr.wrapPtrAsRealmValueT())
-}
diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/CoreConnectionState.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/CoreConnectionState.kt
deleted file mode 100644
index bac74a88e6..0000000000
--- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/CoreConnectionState.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2023 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.realm_sync_connection_state_e
-
-actual enum class CoreConnectionState(val value: Int) {
- RLM_SYNC_CONNECTION_STATE_DISCONNECTED(realm_sync_connection_state_e.RLM_SYNC_CONNECTION_STATE_DISCONNECTED),
- RLM_SYNC_CONNECTION_STATE_CONNECTING(realm_sync_connection_state_e.RLM_SYNC_CONNECTION_STATE_CONNECTING),
- RLM_SYNC_CONNECTION_STATE_CONNECTED(realm_sync_connection_state_e.RLM_SYNC_CONNECTION_STATE_CONNECTED);
-
- companion object {
- @JvmStatic
- fun of(value: Int): CoreConnectionState =
- entries.find { it.value == value }
- ?: error("Unknown connection state: $value")
- }
-}
diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/CoreSubscriptionSetState.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/CoreSubscriptionSetState.kt
deleted file mode 100644
index dbcfe0f8ca..0000000000
--- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/CoreSubscriptionSetState.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.NativeEnumerated
-import io.realm.kotlin.internal.interop.realm_flx_sync_subscription_set_state_e
-
-actual enum class CoreSubscriptionSetState(override val nativeValue: Int) : NativeEnumerated {
- RLM_SYNC_SUBSCRIPTION_UNCOMMITTED(realm_flx_sync_subscription_set_state_e.RLM_SYNC_SUBSCRIPTION_UNCOMMITTED),
- RLM_SYNC_SUBSCRIPTION_PENDING(realm_flx_sync_subscription_set_state_e.RLM_SYNC_SUBSCRIPTION_PENDING),
- RLM_SYNC_SUBSCRIPTION_BOOTSTRAPPING(realm_flx_sync_subscription_set_state_e.RLM_SYNC_SUBSCRIPTION_BOOTSTRAPPING),
- RLM_SYNC_SUBSCRIPTION_COMPLETE(realm_flx_sync_subscription_set_state_e.RLM_SYNC_SUBSCRIPTION_COMPLETE),
- RLM_SYNC_SUBSCRIPTION_ERROR(realm_flx_sync_subscription_set_state_e.RLM_SYNC_SUBSCRIPTION_ERROR),
- RLM_SYNC_SUBSCRIPTION_SUPERSEDED(realm_flx_sync_subscription_set_state_e.RLM_SYNC_SUBSCRIPTION_SUPERSEDED),
- RLM_SYNC_SUBSCRIPTION_AWAITING_MARK(realm_flx_sync_subscription_set_state_e.RLM_SYNC_SUBSCRIPTION_AWAITING_MARK);
-
- companion object {
- fun of(state: Int): CoreSubscriptionSetState {
- for (value in entries) {
- if (value.nativeValue == state) {
- return value
- }
- }
- error("Unknown subscription set state: $state")
- }
- }
-}
diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/CoreSyncSessionState.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/CoreSyncSessionState.kt
deleted file mode 100644
index 4120e446b5..0000000000
--- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/CoreSyncSessionState.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.NativeEnumerated
-import io.realm.kotlin.internal.interop.realm_sync_session_state_e
-
-actual enum class CoreSyncSessionState(override val nativeValue: Int) : NativeEnumerated {
- RLM_SYNC_SESSION_STATE_DYING(realm_sync_session_state_e.RLM_SYNC_SESSION_STATE_DYING),
- RLM_SYNC_SESSION_STATE_ACTIVE(realm_sync_session_state_e.RLM_SYNC_SESSION_STATE_ACTIVE),
- RLM_SYNC_SESSION_STATE_INACTIVE(realm_sync_session_state_e.RLM_SYNC_SESSION_STATE_INACTIVE),
- RLM_SYNC_SESSION_STATE_WAITING_FOR_ACCESS_TOKEN(realm_sync_session_state_e.RLM_SYNC_SESSION_STATE_WAITING_FOR_ACCESS_TOKEN),
- RLM_SYNC_SESSION_STATE_PAUSED(realm_sync_session_state_e.RLM_SYNC_SESSION_STATE_PAUSED);
-
- companion object {
- fun of(state: Int): CoreSyncSessionState =
- entries.find { it.nativeValue == state }
- ?: error("Unknown sync session state: $state")
- }
-}
diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/CoreUserState.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/CoreUserState.kt
deleted file mode 100644
index 96f72ee39e..0000000000
--- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/CoreUserState.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.NativeEnumerated
-import io.realm.kotlin.internal.interop.realm_user_state_e
-
-actual enum class CoreUserState(
- override val nativeValue: Int
-) : NativeEnumerated {
-
- RLM_USER_STATE_LOGGED_OUT(realm_user_state_e.RLM_USER_STATE_LOGGED_OUT),
- RLM_USER_STATE_LOGGED_IN(realm_user_state_e.RLM_USER_STATE_LOGGED_IN),
- RLM_USER_STATE_REMOVED(realm_user_state_e.RLM_USER_STATE_REMOVED);
-
- companion object {
- // TODO Optimize
- fun of(state: Int): CoreUserState {
- for (value in values()) {
- if (value.nativeValue == state) {
- return value
- }
- }
- error("Unknown user state: $state")
- }
- }
-}
diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/JVMSyncSessionTransferCompletionCallback.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/JVMSyncSessionTransferCompletionCallback.kt
deleted file mode 100644
index 8c3cf2c981..0000000000
--- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/JVMSyncSessionTransferCompletionCallback.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.CoreError
-import io.realm.kotlin.internal.interop.SyncSessionTransferCompletionCallback
-
-// Interface used internally as a bridge between Kotlin (JVM) and JNI.
-// We pass all required primitive parameters to JVM and construct the objects there, rather than
-// having to do this on the JNI side, which is both a ton of boilerplate, but also expensive in
-// terms of the number of JNI traversals.
-internal class JVMSyncSessionTransferCompletionCallback(
- private val callback: SyncSessionTransferCompletionCallback
-) {
- fun onSuccess() {
- callback.invoke(null)
- }
- fun onError(categoryFlags: Int, value: Int, message: String) {
- callback.invoke(CoreError(categoryFlags, value, message))
- }
-}
diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/MetadataMode.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/MetadataMode.kt
deleted file mode 100644
index 7f19585dc8..0000000000
--- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/MetadataMode.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2021 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.NativeEnumerated
-import io.realm.kotlin.internal.interop.realm_sync_client_metadata_mode_e
-
-actual enum class MetadataMode(override val nativeValue: Int) : NativeEnumerated {
- RLM_SYNC_CLIENT_METADATA_MODE_DISABLED(realm_sync_client_metadata_mode_e.RLM_SYNC_CLIENT_METADATA_MODE_DISABLED),
- RLM_SYNC_CLIENT_METADATA_MODE_PLAINTEXT(realm_sync_client_metadata_mode_e.RLM_SYNC_CLIENT_METADATA_MODE_PLAINTEXT),
- RLM_SYNC_CLIENT_METADATA_MODE_ENCRYPTED(realm_sync_client_metadata_mode_e.RLM_SYNC_CLIENT_METADATA_MODE_ENCRYPTED);
-
- companion object {
- fun of(state: Int): MetadataMode {
- for (value in values()) {
- if (value.nativeValue == state) {
- return value
- }
- }
- error("Unknown metadata mode state: $state")
- }
- }
-}
diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ProgressDirection.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ProgressDirection.kt
deleted file mode 100644
index 0db767f44a..0000000000
--- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ProgressDirection.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.NativeEnumerated
-import io.realm.kotlin.internal.interop.realm_sync_progress_direction_e
-
-actual enum class ProgressDirection(override val nativeValue: Int) : NativeEnumerated {
- RLM_SYNC_PROGRESS_DIRECTION_UPLOAD(realm_sync_progress_direction_e.RLM_SYNC_PROGRESS_DIRECTION_UPLOAD),
- RLM_SYNC_PROGRESS_DIRECTION_DOWNLOAD(realm_sync_progress_direction_e.RLM_SYNC_PROGRESS_DIRECTION_DOWNLOAD),
-}
diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt
deleted file mode 100644
index 452136341e..0000000000
--- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.CodeDescription
-import io.realm.kotlin.internal.interop.realm_sync_errno_connection_e
-import io.realm.kotlin.internal.interop.realm_sync_errno_session_e
-import io.realm.kotlin.internal.interop.realm_sync_socket_callback_result_e
-import io.realm.kotlin.internal.interop.realm_web_socket_errno_e
-
-actual enum class SyncConnectionErrorCode(
- actual override val description: String?,
- actual override val nativeValue: Int
-) : CodeDescription {
- RLM_SYNC_ERR_CONNECTION_CONNECTION_CLOSED("ConnectionClosed", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_CONNECTION_CLOSED),
- RLM_SYNC_ERR_CONNECTION_OTHER_ERROR("OtherError", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_OTHER_ERROR),
- RLM_SYNC_ERR_CONNECTION_UNKNOWN_MESSAGE("UnknownMessage", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_UNKNOWN_MESSAGE),
- RLM_SYNC_ERR_CONNECTION_BAD_SYNTAX("BadSyntax", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_BAD_SYNTAX),
- RLM_SYNC_ERR_CONNECTION_LIMITS_EXCEEDED("LimitsExceeded", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_LIMITS_EXCEEDED),
- RLM_SYNC_ERR_CONNECTION_WRONG_PROTOCOL_VERSION("WrongBadSyncPartitionValueProtocolVersion", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_WRONG_PROTOCOL_VERSION),
- RLM_SYNC_ERR_CONNECTION_BAD_SESSION_IDENT("BadSessionIdent", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_BAD_SESSION_IDENT),
- RLM_SYNC_ERR_CONNECTION_REUSE_OF_SESSION_IDENT("ReuseOfSessionIdent", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_REUSE_OF_SESSION_IDENT),
- RLM_SYNC_ERR_CONNECTION_BOUND_IN_OTHER_SESSION("BoundInOtherSession", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_BOUND_IN_OTHER_SESSION),
- RLM_SYNC_ERR_CONNECTION_BAD_MESSAGE_ORDER("BadMessageOrder", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_BAD_MESSAGE_ORDER),
- RLM_SYNC_ERR_CONNECTION_BAD_DECOMPRESSION("BadDecompression", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_BAD_DECOMPRESSION),
- RLM_SYNC_ERR_CONNECTION_BAD_CHANGESET_HEADER_SYNTAX("BadChangesetHeaderSyntax", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_BAD_CHANGESET_HEADER_SYNTAX),
- RLM_SYNC_ERR_CONNECTION_BAD_CHANGESET_SIZE("BadChangesetSize", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_BAD_CHANGESET_SIZE),
- RLM_SYNC_ERR_CONNECTION_SWITCH_TO_FLX_SYNC("SwitchToFlxSync", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_SWITCH_TO_FLX_SYNC),
- RLM_SYNC_ERR_CONNECTION_SWITCH_TO_PBS("SwitchToPbs", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_SWITCH_TO_PBS);
-
- companion object {
- internal fun of(nativeValue: Int): SyncConnectionErrorCode? =
- entries.firstOrNull { value ->
- value.nativeValue == nativeValue
- }
- }
-}
-
-actual enum class SyncSessionErrorCode(
- actual override val description: String?,
- actual override val nativeValue: Int
-) : CodeDescription {
- RLM_SYNC_ERR_SESSION_SESSION_CLOSED("SessionClosed", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_SESSION_CLOSED),
- RLM_SYNC_ERR_SESSION_OTHER_SESSION_ERROR("OtherSessioError", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_OTHER_SESSION_ERROR),
- RLM_SYNC_ERR_SESSION_TOKEN_EXPIRED("TokenExpired", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_TOKEN_EXPIRED),
- RLM_SYNC_ERR_SESSION_BAD_AUTHENTICATION("BadAuthentication", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_BAD_AUTHENTICATION),
- RLM_SYNC_ERR_SESSION_ILLEGAL_REALM_PATH("IllegalRealmPath", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_ILLEGAL_REALM_PATH),
- RLM_SYNC_ERR_SESSION_NO_SUCH_REALM("NoSuchRealm", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_NO_SUCH_REALM),
- RLM_SYNC_ERR_SESSION_PERMISSION_DENIED("PermissionDenied", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_PERMISSION_DENIED),
- RLM_SYNC_ERR_SESSION_BAD_SERVER_FILE_IDENT("BadServerFileIdent", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_BAD_SERVER_FILE_IDENT),
- RLM_SYNC_ERR_SESSION_BAD_CLIENT_FILE_IDENT("BadClientFileIdent", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_BAD_CLIENT_FILE_IDENT),
- RLM_SYNC_ERR_SESSION_BAD_SERVER_VERSION("BadServerVersion", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_BAD_SERVER_VERSION),
- RLM_SYNC_ERR_SESSION_BAD_CLIENT_VERSION("BadClientVersion", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_BAD_CLIENT_VERSION),
- RLM_SYNC_ERR_SESSION_DIVERGING_HISTORIES("DivergingHistories", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_DIVERGING_HISTORIES),
- RLM_SYNC_ERR_SESSION_BAD_CHANGESET("BadChangeset", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_BAD_CHANGESET),
- RLM_SYNC_ERR_SESSION_PARTIAL_SYNC_DISABLED("PartialSyncDisabled", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_PARTIAL_SYNC_DISABLED),
- RLM_SYNC_ERR_SESSION_UNSUPPORTED_SESSION_FEATURE("UnsupportedSessionFeature", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_UNSUPPORTED_SESSION_FEATURE),
- RLM_SYNC_ERR_SESSION_BAD_ORIGIN_FILE_IDENT("BadOriginFileIdent", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_BAD_ORIGIN_FILE_IDENT),
- RLM_SYNC_ERR_SESSION_BAD_CLIENT_FILE("BadClientFile", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_BAD_CLIENT_FILE),
- RLM_SYNC_ERR_SESSION_SERVER_FILE_DELETED("ServerFileDeleted", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_SERVER_FILE_DELETED),
- RLM_SYNC_ERR_SESSION_CLIENT_FILE_BLACKLISTED("ClientFileBlacklisted", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_CLIENT_FILE_BLACKLISTED),
- RLM_SYNC_ERR_SESSION_USER_BLACKLISTED("UserBlacklisted", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_USER_BLACKLISTED),
- RLM_SYNC_ERR_SESSION_TRANSACT_BEFORE_UPLOAD("TransactBeforeUpload", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_TRANSACT_BEFORE_UPLOAD),
- RLM_SYNC_ERR_SESSION_CLIENT_FILE_EXPIRED("ClientFileExpired", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_CLIENT_FILE_EXPIRED),
- RLM_SYNC_ERR_SESSION_USER_MISMATCH("UserMismatch", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_USER_MISMATCH),
- RLM_SYNC_ERR_SESSION_TOO_MANY_SESSIONS("TooManySession", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_TOO_MANY_SESSIONS),
- RLM_SYNC_ERR_SESSION_INVALID_SCHEMA_CHANGE("InvalidSchemaChange", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_INVALID_SCHEMA_CHANGE),
- RLM_SYNC_ERR_SESSION_BAD_QUERY("BadQuery", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_BAD_QUERY),
- RLM_SYNC_ERR_SESSION_OBJECT_ALREADY_EXISTS("ObjectAlreadyExists", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_OBJECT_ALREADY_EXISTS),
- RLM_SYNC_ERR_SESSION_SERVER_PERMISSIONS_CHANGED("ServerPermissionsChanged", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_SERVER_PERMISSIONS_CHANGED),
- RLM_SYNC_ERR_SESSION_INITIAL_SYNC_NOT_COMPLETED("InitialSyncNotCompleted", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_INITIAL_SYNC_NOT_COMPLETED),
- RLM_SYNC_ERR_SESSION_WRITE_NOT_ALLOWED("WriteNotAllowed", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_WRITE_NOT_ALLOWED),
- RLM_SYNC_ERR_SESSION_COMPENSATING_WRITE("CompensatingWrite", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_COMPENSATING_WRITE),
- RLM_SYNC_ERR_SESSION_MIGRATE_TO_FLX("MigrateToFlexibleSync", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_MIGRATE_TO_FLX),
- RLM_SYNC_ERR_SESSION_BAD_PROGRESS("BadProgress", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_BAD_PROGRESS),
- RLM_SYNC_ERR_SESSION_REVERT_TO_PBS("RevertToPartitionBasedSync", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_REVERT_TO_PBS),
- RLM_SYNC_ERR_SESSION_BAD_SCHEMA_VERSION("BadSchemaVersion", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_BAD_SCHEMA_VERSION),
- RLM_SYNC_ERR_SESSION_SCHEMA_VERSION_CHANGED("SchemaVersionChanged", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_SCHEMA_VERSION_CHANGED);
-
- companion object {
- internal fun of(nativeValue: Int): SyncSessionErrorCode? =
- entries.firstOrNull { value ->
- value.nativeValue == nativeValue
- }
- }
-}
-
-actual enum class WebsocketErrorCode(
- actual override val description: String?,
- actual override val nativeValue: Int
-) : CodeDescription {
- RLM_ERR_WEBSOCKET_OK("Ok", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_OK),
- RLM_ERR_WEBSOCKET_GOINGAWAY("GoingAway", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_GOINGAWAY),
- RLM_ERR_WEBSOCKET_PROTOCOLERROR("ProtocolError", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_PROTOCOLERROR),
- RLM_ERR_WEBSOCKET_UNSUPPORTEDDATA("UnsupportedData", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_UNSUPPORTEDDATA),
- RLM_ERR_WEBSOCKET_RESERVED("Reserved", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_RESERVED),
- RLM_ERR_WEBSOCKET_NOSTATUSRECEIVED("NoStatusReceived", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_NOSTATUSRECEIVED),
- RLM_ERR_WEBSOCKET_ABNORMALCLOSURE("AbnormalClosure", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_ABNORMALCLOSURE),
- RLM_ERR_WEBSOCKET_INVALIDPAYLOADDATA("InvalidPayloadData", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_INVALIDPAYLOADDATA),
- RLM_ERR_WEBSOCKET_POLICYVIOLATION("PolicyViolation", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_POLICYVIOLATION),
- RLM_ERR_WEBSOCKET_MESSAGETOOBIG("MessageToBig", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_MESSAGETOOBIG),
- RLM_ERR_WEBSOCKET_INAVALIDEXTENSION("InvalidExtension", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_INAVALIDEXTENSION),
- RLM_ERR_WEBSOCKET_INTERNALSERVERERROR("InternalServerError", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_INTERNALSERVERERROR),
- RLM_ERR_WEBSOCKET_TLSHANDSHAKEFAILED("TlsHandshakeFailed", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_TLSHANDSHAKEFAILED),
-
- RLM_ERR_WEBSOCKET_UNAUTHORIZED("Unauthorized", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_UNAUTHORIZED),
- RLM_ERR_WEBSOCKET_FORBIDDEN("Forbidden", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_FORBIDDEN),
- RLM_ERR_WEBSOCKET_MOVEDPERMANENTLY("MovedPermanently", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_MOVEDPERMANENTLY),
-
- RLM_ERR_WEBSOCKET_RESOLVE_FAILED("ResolveFailed", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_RESOLVE_FAILED),
- RLM_ERR_WEBSOCKET_CONNECTION_FAILED("ConnectionFailed", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_CONNECTION_FAILED),
- RLM_ERR_WEBSOCKET_READ_ERROR("ReadError", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_READ_ERROR),
- RLM_ERR_WEBSOCKET_WRITE_ERROR("WriteError", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_WRITE_ERROR),
- RLM_ERR_WEBSOCKET_RETRY_ERROR("RetryError", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_RETRY_ERROR),
- RLM_ERR_WEBSOCKET_FATAL_ERROR("FatalError", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_FATAL_ERROR);
-
- companion object {
- fun of(nativeValue: Int): WebsocketErrorCode? =
- entries.firstOrNull { value ->
- value.nativeValue == nativeValue
- }
- }
-}
-
-actual enum class WebsocketCallbackResult(actual override val description: String?, actual override val nativeValue: Int) : CodeDescription {
-
- RLM_ERR_SYNC_SOCKET_SUCCESS(
- "Websocket callback success",
- realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_SUCCESS
- ),
- RLM_ERR_SYNC_SOCKET_OPERATION_ABORTED(
- "Websocket callback aborted",
- realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_OPERATION_ABORTED
- ),
- RLM_ERR_SYNC_SOCKET_RUNTIME(
- "Websocket Runtime error",
- realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_RUNTIME
- ),
- RLM_ERR_SYNC_SOCKET_OUT_OF_MEMORY(
- "Websocket out of memory ",
- realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_OUT_OF_MEMORY
- ),
- RLM_ERR_SYNC_SOCKET_ADDRESS_SPACE_EXHAUSTED(
- "Websocket address space exhausted",
- realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_ADDRESS_SPACE_EXHAUSTED
- ),
- RLM_ERR_SYNC_SOCKET_CONNECTION_CLOSED(
- "Websocket connection closed",
- realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_CONNECTION_CLOSED
- ),
- RLM_ERR_SYNC_SOCKET_NOT_SUPPORTED(
- "Websocket not supported",
- realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_NOT_SUPPORTED
- ),
- RLM_ERR_SYNC_SOCKET_INVALID_ARGUMENT(
- "Websocket invalid argument",
- realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_INVALID_ARGUMENT
- );
-
- companion object {
- fun of(nativeValue: Int): WebsocketCallbackResult? =
- entries.firstOrNull { value ->
- value.nativeValue == nativeValue
- }
- }
-}
diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ResponseCallbackImpl.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ResponseCallbackImpl.kt
deleted file mode 100644
index a45b68ff3b..0000000000
--- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ResponseCallbackImpl.kt
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2021 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.realmc
-
-// Implementation of network response callback that is initialized from JNI and passed to
-// NetworkTransport.sendRequest to signal response back to JNI
-class ResponseCallbackImpl(val userData: NetworkTransport, val requestContext: Long) :
- ResponseCallback {
- override fun response(response: Response) {
- realmc.complete_http_request(requestContext, response)
- }
-}
diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/SyncSessionResyncMode.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/SyncSessionResyncMode.kt
deleted file mode 100644
index 77186f4cde..0000000000
--- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/SyncSessionResyncMode.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2022 Realm Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.realm.kotlin.internal.interop.sync
-
-import io.realm.kotlin.internal.interop.NativeEnumerated
-import io.realm.kotlin.internal.interop.realm_sync_session_resync_mode_e
-
-actual enum class SyncSessionResyncMode(override val nativeValue: Int) : NativeEnumerated {
- RLM_SYNC_SESSION_RESYNC_MODE_MANUAL(realm_sync_session_resync_mode_e.RLM_SYNC_SESSION_RESYNC_MODE_MANUAL),
- RLM_SYNC_SESSION_RESYNC_MODE_DISCARD_LOCAL(realm_sync_session_resync_mode_e.RLM_SYNC_SESSION_RESYNC_MODE_DISCARD_LOCAL),
- RLM_SYNC_SESSION_RESYNC_MODE_RECOVER(realm_sync_session_resync_mode_e.RLM_SYNC_SESSION_RESYNC_MODE_RECOVER),
- RLM_SYNC_SESSION_RESYNC_MODE_RECOVER_OR_DISCARD(realm_sync_session_resync_mode_e.RLM_SYNC_SESSION_RESYNC_MODE_RECOVER_OR_DISCARD);
-
- companion object {
- fun of(nativeValue: Int): SyncSessionResyncMode {
- for (value in entries) {
- if (value.nativeValue == nativeValue) {
- return value
- }
- }
- error("Unknown session resync mode: $nativeValue")
- }
- }
-}
diff --git a/packages/cinterop/src/native/realm.def b/packages/cinterop/src/native/realm.def
index 925f075c04..8cd5753cfb 100644
--- a/packages/cinterop/src/native/realm.def
+++ b/packages/cinterop/src/native/realm.def
@@ -1,6 +1,5 @@
headers = realm.h realm/error_codes.h
headerFilter = realm.h realm/error_codes.h
-compilerOpts = -DREALM_APP_SERVICES=1
// Relative paths in def file depends are resolved differently dependent on execution
// location
// https://youtrack.jetbrains.com/issue/KT-43439
@@ -12,7 +11,7 @@ compilerOpts = -DREALM_APP_SERVICES=1
// libraryPaths.macos_x64 = ../external/core/build-macos_x64/src/realm/object-store/c_api ../external/core/build-macos_x64/src/realm ../external/core/build-macos_x64/src/realm/parser ../external/core/build-macos_x64/src/realm/object-store/
// libraryPaths.ios_x64 = ../external/core/build-macos_x64/src/realm/object-store/c_api ../external/core/build-macos_x64/src/realm ../external/core/build-macos_x64/src/realm/parser ../external/core/build-macos_x64/src/realm/object-store/
linkerOpts = -lcompression -lz -framework Foundation -framework CoreFoundation -framework Security
-strictEnums = realm_errno realm_error_category realm_sync_errno_client realm_sync_errno_connection realm_sync_errno_session realm_web_socket_errno realm_sync_socket_callback_result
+strictEnums = realm_errno realm_error_category
// We don't want to convert Websocket binary data to String
noStringConversion = realm_sync_socket_websocket_message
diff --git a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/ErrorCategory.kt b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/ErrorCategory.kt
index 6b50a14d6c..905f74b5ae 100644
--- a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/ErrorCategory.kt
+++ b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/ErrorCategory.kt
@@ -28,15 +28,7 @@ actual enum class ErrorCategory(
RLM_ERR_CAT_RUNTIME("Runtime", realm_error_category.RLM_ERR_CAT_RUNTIME.value.toInt()),
RLM_ERR_CAT_INVALID_ARG("InvalidArg", realm_error_category.RLM_ERR_CAT_INVALID_ARG.value.toInt()),
RLM_ERR_CAT_FILE_ACCESS("File", realm_error_category.RLM_ERR_CAT_FILE_ACCESS.value.toInt()),
- RLM_ERR_CAT_SYSTEM_ERROR("System", realm_error_category.RLM_ERR_CAT_SYSTEM_ERROR.value.toInt()),
- RLM_ERR_CAT_APP_ERROR("App", realm_error_category.RLM_ERR_CAT_APP_ERROR.value.toInt()),
- RLM_ERR_CAT_CLIENT_ERROR("Client", realm_error_category.RLM_ERR_CAT_CLIENT_ERROR.value.toInt()),
- RLM_ERR_CAT_JSON_ERROR("Json", realm_error_category.RLM_ERR_CAT_JSON_ERROR.value.toInt()),
- RLM_ERR_CAT_SERVICE_ERROR("Service", realm_error_category.RLM_ERR_CAT_SERVICE_ERROR.value.toInt()),
- RLM_ERR_CAT_HTTP_ERROR("Http", realm_error_category.RLM_ERR_CAT_HTTP_ERROR.value.toInt()),
- RLM_ERR_CAT_CUSTOM_ERROR("Custom", realm_error_category.RLM_ERR_CAT_CUSTOM_ERROR.value.toInt()),
- RLM_ERR_CAT_WEBSOCKET_ERROR("Websocket", realm_error_category.RLM_ERR_CAT_WEBSOCKET_ERROR.value.toInt()),
- RLM_ERR_CAT_SYNC_ERROR("Sync", realm_error_category.RLM_ERR_CAT_SYNC_ERROR.value.toInt());
+ RLM_ERR_CAT_SYSTEM_ERROR("System", realm_error_category.RLM_ERR_CAT_SYSTEM_ERROR.value.toInt());
actual companion object {
diff --git a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmEnums.kt b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmEnums.kt
index a6b1a413ff..0112512925 100644
--- a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmEnums.kt
+++ b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmEnums.kt
@@ -48,7 +48,6 @@ actual enum class SchemaMode(override val nativeValue: realm_schema_mode) : Nati
actual object ClassFlags {
actual val RLM_CLASS_NORMAL = realm_wrapper.RLM_CLASS_NORMAL.toInt()
actual val RLM_CLASS_EMBEDDED = realm_wrapper.RLM_CLASS_EMBEDDED.toInt()
- actual val RLM_CLASS_ASYMMETRIC = realm_wrapper.RLM_CLASS_ASYMMETRIC.toInt()
}
actual enum class PropertyType(override val nativeValue: UInt) : NativeEnumerated {
diff --git a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt
index f39b2e8772..e55b4fe91d 100644
--- a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt
+++ b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt
@@ -19,27 +19,6 @@
package io.realm.kotlin.internal.interop
import io.realm.kotlin.internal.interop.Constants.ENCRYPTION_KEY_LENGTH
-import io.realm.kotlin.internal.interop.sync.ApiKeyWrapper
-import io.realm.kotlin.internal.interop.sync.AppError
-import io.realm.kotlin.internal.interop.sync.AuthProvider
-import io.realm.kotlin.internal.interop.sync.CancellableTimer
-import io.realm.kotlin.internal.interop.sync.CoreCompensatingWriteInfo
-import io.realm.kotlin.internal.interop.sync.CoreConnectionState
-import io.realm.kotlin.internal.interop.sync.CoreSubscriptionSetState
-import io.realm.kotlin.internal.interop.sync.CoreSyncSessionState
-import io.realm.kotlin.internal.interop.sync.CoreUserState
-import io.realm.kotlin.internal.interop.sync.MetadataMode
-import io.realm.kotlin.internal.interop.sync.NetworkTransport
-import io.realm.kotlin.internal.interop.sync.ProgressDirection
-import io.realm.kotlin.internal.interop.sync.Response
-import io.realm.kotlin.internal.interop.sync.SyncError
-import io.realm.kotlin.internal.interop.sync.SyncSessionResyncMode
-import io.realm.kotlin.internal.interop.sync.SyncUserIdentity
-import io.realm.kotlin.internal.interop.sync.WebSocketClient
-import io.realm.kotlin.internal.interop.sync.WebSocketObserver
-import io.realm.kotlin.internal.interop.sync.WebSocketTransport
-import io.realm.kotlin.internal.interop.sync.WebsocketCallbackResult
-import io.realm.kotlin.internal.interop.sync.WebsocketErrorCode
import kotlinx.atomicfu.AtomicBoolean
import kotlinx.atomicfu.atomic
import kotlinx.cinterop.AutofreeScope
@@ -59,7 +38,6 @@ import kotlinx.cinterop.MemScope
import kotlinx.cinterop.StableRef
import kotlinx.cinterop.UIntVar
import kotlinx.cinterop.ULongVar
-import kotlinx.cinterop.ULongVarOf
import kotlinx.cinterop.addressOf
import kotlinx.cinterop.alloc
import kotlinx.cinterop.allocArray
@@ -78,7 +56,6 @@ import kotlinx.cinterop.refTo
import kotlinx.cinterop.set
import kotlinx.cinterop.staticCFunction
import kotlinx.cinterop.toCStringArray
-import kotlinx.cinterop.toCValues
import kotlinx.cinterop.toKString
import kotlinx.cinterop.useContents
import kotlinx.cinterop.usePinned
@@ -87,16 +64,13 @@ import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import org.mongodb.kbson.BsonObjectId
-import org.mongodb.kbson.ObjectId
import platform.posix.memcpy
import platform.posix.posix_errno
import platform.posix.pthread_threadid_np
-import platform.posix.size_t
import platform.posix.size_tVar
import platform.posix.strerror
import platform.posix.uint64_t
import platform.posix.uint8_tVar
-import realm_wrapper.realm_app_error_t
import realm_wrapper.realm_binary_t
import realm_wrapper.realm_class_info_t
import realm_wrapper.realm_class_key_tVar
@@ -105,12 +79,7 @@ import realm_wrapper.realm_clone
import realm_wrapper.realm_dictionary_t
import realm_wrapper.realm_error_t
import realm_wrapper.realm_find_property
-import realm_wrapper.realm_flx_sync_subscription_set_state_e
import realm_wrapper.realm_get_last_error
-import realm_wrapper.realm_http_header_t
-import realm_wrapper.realm_http_request_method
-import realm_wrapper.realm_http_request_t
-import realm_wrapper.realm_http_response_t
import realm_wrapper.realm_link_t
import realm_wrapper.realm_list_t
import realm_wrapper.realm_object_id_t
@@ -122,21 +91,11 @@ import realm_wrapper.realm_results_t
import realm_wrapper.realm_scheduler_t
import realm_wrapper.realm_set_t
import realm_wrapper.realm_string_t
-import realm_wrapper.realm_sync_session_state_e
-import realm_wrapper.realm_sync_session_stop_policy_e
-import realm_wrapper.realm_sync_socket_post_callback_t
-import realm_wrapper.realm_sync_socket_t
-import realm_wrapper.realm_sync_socket_timer_callback_t
-import realm_wrapper.realm_sync_socket_timer_t
-import realm_wrapper.realm_sync_socket_websocket_t
-import realm_wrapper.realm_sync_socket_write_callback_t
import realm_wrapper.realm_t
-import realm_wrapper.realm_user_t
import realm_wrapper.realm_value_t
import realm_wrapper.realm_value_type
import realm_wrapper.realm_version_id_t
import realm_wrapper.realm_work_queue_t
-import kotlin.collections.set
import kotlin.experimental.ExperimentalNativeApi
import kotlin.native.ref.createCleaner
@@ -556,6 +515,38 @@ actual object RealmInterop {
return Pair(realmPtr, fileCreated.value)
}
+ actual fun realm_add_realm_changed_callback(realm: LiveRealmPointer, block: () -> Unit): RealmCallbackTokenPointer {
+ return CPointerWrapper(
+ realm_wrapper.realm_add_realm_changed_callback(
+ realm.cptr(),
+ staticCFunction { userData ->
+ safeUserData<() -> Unit>(userData)()
+ },
+ StableRef.create(block).asCPointer(),
+ staticCFunction { userdata ->
+ disposeUserData<(() -> Unit) -> Unit>(userdata)
+ }
+ ),
+ managed = false
+ )
+ }
+
+ actual fun realm_add_schema_changed_callback(realm: LiveRealmPointer, block: (RealmSchemaPointer) -> Unit): RealmCallbackTokenPointer {
+ return CPointerWrapper(
+ realm_wrapper.realm_add_schema_changed_callback(
+ realm.cptr(),
+ staticCFunction { userData, schema ->
+ safeUserData<(RealmSchemaPointer) -> Unit>(userData)(CPointerWrapper(realm_clone(schema)))
+ },
+ StableRef.create(block).asCPointer(),
+ staticCFunction { userdata ->
+ disposeUserData<(RealmSchemaPointer) -> Unit>(userdata)
+ }
+ ),
+ managed = false
+ )
+ }
+
actual fun realm_create_scheduler(): RealmSchedulerPointer {
// If there is no notification dispatcher use the default scheduler.
// Re-verify if this is actually needed when notification scheduler is fully in place.
@@ -619,76 +610,6 @@ actual object RealmInterop {
return CPointerWrapper(capi_scheduler)
}
- actual fun realm_open_synchronized(config: RealmConfigurationPointer): RealmAsyncOpenTaskPointer {
- return CPointerWrapper(realm_wrapper.realm_open_synchronized(config.cptr()))
- }
-
- actual fun realm_async_open_task_start(task: RealmAsyncOpenTaskPointer, callback: AsyncOpenCallback) {
- realm_wrapper.realm_async_open_task_start(
- task.cptr(),
- staticCFunction { userData, realm, error ->
- memScoped {
- var exception: Throwable? = null
- if (error != null) {
- val err = alloc()
- realm_wrapper.realm_get_async_error(error, err.ptr)
- exception = CoreErrorConverter.asThrowable(
- categoriesNativeValue = err.categories.toInt(),
- errorCodeNativeValue = err.error.value.toInt(),
- messageNativeValue = err.message?.toKString(),
- path = err.path?.toKString(),
- userError = err.user_code_error?.asStableRef()?.get()
- )
- err.user_code_error?.let { disposeUserData(it) }
- } else {
- realm_release(realm)
- }
- safeUserData(userData).invoke(exception)
- }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userData ->
- disposeUserData(userData)
- }
- )
- }
-
- actual fun realm_async_open_task_cancel(task: RealmAsyncOpenTaskPointer) {
- realm_wrapper.realm_async_open_task_cancel(task.cptr())
- }
-
- actual fun realm_add_realm_changed_callback(realm: LiveRealmPointer, block: () -> Unit): RealmCallbackTokenPointer {
- return CPointerWrapper(
- realm_wrapper.realm_add_realm_changed_callback(
- realm.cptr(),
- staticCFunction { userData ->
- safeUserData<() -> Unit>(userData)()
- },
- StableRef.create(block).asCPointer(),
- staticCFunction { userdata ->
- disposeUserData<(LiveRealmPointer, SyncErrorCallback) -> Unit>(userdata)
- }
- ),
- managed = false
- )
- }
-
- actual fun realm_add_schema_changed_callback(realm: LiveRealmPointer, block: (RealmSchemaPointer) -> Unit): RealmCallbackTokenPointer {
- return CPointerWrapper(
- realm_wrapper.realm_add_schema_changed_callback(
- realm.cptr(),
- staticCFunction { userData, schema ->
- safeUserData<(RealmSchemaPointer) -> Unit>(userData)(CPointerWrapper(realm_clone(schema)))
- },
- StableRef.create(block).asCPointer(),
- staticCFunction { userdata ->
- disposeUserData<(RealmSchemaT, SyncErrorCallback) -> Unit>(userdata)
- }
- ),
- managed = false
- )
- }
-
actual fun realm_freeze(liveRealm: LiveRealmPointer): FrozenRealmPointer {
return CPointerWrapper(realm_wrapper.realm_freeze(liveRealm.cptr()))
}
@@ -2060,459 +1981,6 @@ actual object RealmInterop {
}
}
- actual fun realm_app_get(
- appConfig: RealmAppConfigurationPointer,
- basePath: String
- ): RealmAppPointer {
- return CPointerWrapper(realm_wrapper.realm_app_create(appConfig.cptr()), managed = true)
- }
-
- actual fun realm_app_get_current_user(app: RealmAppPointer): RealmUserPointer? {
- val currentUserPtr: CPointer? = realm_wrapper.realm_app_get_current_user(app.cptr())
- return nativePointerOrNull(currentUserPtr)
- }
-
- actual fun realm_app_get_all_users(app: RealmAppPointer): List {
- memScoped {
- // We get the current amount of users by providing a `null` array and `out_n`
- // argument. Then the current count is written to `out_n`.
- // See https://github.com/realm/realm-core/blob/master/src/realm.h#L2634
- val capacityCount: ULongVarOf = alloc()
- checkedBooleanResult(
- realm_wrapper.realm_app_get_all_users(
- app.cptr(),
- null,
- 0UL,
- capacityCount.ptr
- )
- )
-
- // Read actual users. We don't care about the small chance of missing a new user
- // between these two calls as that indicate two sections of user code running on
- // different threads and not coordinating.
- val actualUsersCount: ULongVarOf = alloc()
- val users = allocArray>(capacityCount.value.toInt())
- checkedBooleanResult(realm_wrapper.realm_app_get_all_users(app.cptr(), users, capacityCount.value, actualUsersCount.ptr))
- val result: MutableList = mutableListOf()
- for (i in 0 until actualUsersCount.value.toInt()) {
- users[i]?.let { ptr: CPointer ->
- result.add(CPointerWrapper(ptr, managed = true))
- }
- }
- return result
- }
- }
-
- actual fun realm_app_log_in_with_credentials(
- app: RealmAppPointer,
- credentials: RealmCredentialsPointer,
- callback: AppCallback
- ) {
- realm_wrapper.realm_app_log_in_with_credentials(
- app.cptr(),
- credentials.cptr(),
- staticCFunction { userData, user, error: CPointer? ->
- // Remember to clone user object or else it will go out of scope right after we leave this callback
- handleAppCallback(userData, error) { CPointerWrapper(realm_clone(user)) }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userdata -> disposeUserData>(userdata) }
- )
- }
-
- actual fun realm_app_user_apikey_provider_client_create_apikey(
- app: RealmAppPointer,
- user: RealmUserPointer,
- name: String,
- callback: AppCallback
- ) {
- checkedBooleanResult(
- realm_wrapper.realm_app_user_apikey_provider_client_create_apikey(
- app.cptr(),
- user.cptr(),
- name,
- staticCFunction { userData: CPointer?, apiKey: CPointer?, error: CPointer? ->
- handleAppCallback(userData, error) {
- apiKey!!.pointed.let {
- ApiKeyWrapper(
- ObjectId(
- it.id.bytes.readBytes(OBJECT_ID_BYTES_SIZE),
- ),
- it.key.safeKString(),
- it.name.safeKString(),
- it.disabled
- )
- }
- }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userdata -> disposeUserData>(userdata) }
- )
- )
- }
-
- actual fun realm_app_user_apikey_provider_client_delete_apikey(
- app: RealmAppPointer,
- user: RealmUserPointer,
- id: BsonObjectId,
- callback: AppCallback,
- ) {
- checkedBooleanResult(
- realm_wrapper.realm_app_user_apikey_provider_client_delete_apikey(
- app.cptr(),
- user.cptr(),
- id.realm_object_id_t(),
- staticCFunction { userData, error ->
- handleAppCallback(userData, error) { /* No-op, returns Unit */ }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userData -> disposeUserData>(userData) }
- )
- )
- }
-
- actual fun realm_app_user_apikey_provider_client_disable_apikey(
- app: RealmAppPointer,
- user: RealmUserPointer,
- id: BsonObjectId,
- callback: AppCallback,
- ) {
- checkedBooleanResult(
- realm_wrapper.realm_app_user_apikey_provider_client_disable_apikey(
- app.cptr(),
- user.cptr(),
- id.realm_object_id_t(),
- staticCFunction { userData, error ->
- handleAppCallback(userData, error) { /* No-op, returns Unit */ }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userData -> disposeUserData>(userData) }
- )
- )
- }
-
- actual fun realm_app_user_apikey_provider_client_enable_apikey(
- app: RealmAppPointer,
- user: RealmUserPointer,
- id: BsonObjectId,
- callback: AppCallback,
- ) {
- checkedBooleanResult(
- realm_wrapper.realm_app_user_apikey_provider_client_enable_apikey(
- app.cptr(),
- user.cptr(),
- id.realm_object_id_t(),
- staticCFunction { userData, error ->
- handleAppCallback(userData, error) { /* No-op, returns Unit */ }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userData -> disposeUserData>(userData) }
- )
- )
- }
-
- actual fun realm_app_user_apikey_provider_client_fetch_apikey(
- app: RealmAppPointer,
- user: RealmUserPointer,
- id: ObjectId,
- callback: AppCallback
- ) {
- checkedBooleanResult(
- realm_wrapper.realm_app_user_apikey_provider_client_fetch_apikey(
- app.cptr(),
- user.cptr(),
- id.realm_object_id_t(),
- staticCFunction { userData: CPointer?, apiKey: CPointer?, error: CPointer? ->
- handleAppCallback(userData, error) {
- apiKey!!.pointed.let {
- ApiKeyWrapper(
- ObjectId(
- it.id.bytes.readBytes(OBJECT_ID_BYTES_SIZE),
- ),
- null,
- it.name.safeKString(),
- it.disabled
- )
- }
- }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userdata -> disposeUserData>(userdata) }
- )
- )
- }
-
- actual fun realm_app_user_apikey_provider_client_fetch_apikeys(
- app: RealmAppPointer,
- user: RealmUserPointer,
- callback: AppCallback>,
- ) {
- checkedBooleanResult(
- realm_wrapper.realm_app_user_apikey_provider_client_fetch_apikeys(
- app.cptr(),
- user.cptr(),
- staticCFunction { userData: CPointer?, apiKeys: CPointer?, count: size_t, error: CPointer? ->
- handleAppCallback(userData, error) {
- val result = arrayOfNulls(count.toInt())
- for (i in 0 until count.toInt()) {
- apiKeys!![i].let {
- result[i] = ApiKeyWrapper(
- ObjectId(
- it.id.bytes.readBytes(OBJECT_ID_BYTES_SIZE),
- ),
- null,
- it.name.safeKString(),
- it.disabled
- )
- }
- }
- result
- }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userdata -> disposeUserData>>(userdata) }
- )
- )
- }
-
- actual fun realm_app_log_out(
- app: RealmAppPointer,
- user: RealmUserPointer,
- callback: AppCallback
- ) {
- checkedBooleanResult(
- realm_wrapper.realm_app_log_out(
- app.cptr(),
- user.cptr(),
- staticCFunction { userData, error ->
- handleAppCallback(userData, error) { /* No-op, returns Unit */ }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userdata -> disposeUserData>(userdata) }
- )
- )
- }
-
- actual fun realm_app_remove_user(
- app: RealmAppPointer,
- user: RealmUserPointer,
- callback: AppCallback
- ) {
- checkedBooleanResult(
- realm_wrapper.realm_app_remove_user(
- app.cptr(),
- user.cptr(),
- staticCFunction { userData, error ->
- handleAppCallback(userData, error) { /* No-op, returns Unit */ }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userdata ->
- disposeUserData>(userdata)
- }
- )
- )
- }
-
- actual fun realm_app_delete_user(
- app: RealmAppPointer,
- user: RealmUserPointer,
- callback: AppCallback
- ) {
- checkedBooleanResult(
- realm_wrapper.realm_app_delete_user(
- app.cptr(),
- user.cptr(),
- staticCFunction { userData, error ->
- handleAppCallback(userData, error) { /* No-op, returns Unit */ }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userdata ->
- disposeUserData>(userdata)
- }
- )
- )
- }
-
- actual fun realm_app_link_credentials(
- app: RealmAppPointer,
- user: RealmUserPointer,
- credentials: RealmCredentialsPointer,
- callback: AppCallback
- ) {
- checkedBooleanResult(
- realm_wrapper.realm_app_link_user(
- app.cptr(),
- user.cptr(),
- credentials.cptr(),
- staticCFunction { userData, user, error: CPointer? ->
- // Remember to clone user object or else it will go out of scope right after we leave this callback
- handleAppCallback(userData, error) { CPointerWrapper(realm_clone(user)) }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userdata ->
- disposeUserData>(userdata)
- }
- )
- )
- }
-
- actual fun realm_app_switch_user(app: RealmAppPointer, user: RealmUserPointer) {
- checkedBooleanResult(realm_wrapper.realm_app_switch_user(app.cptr(), user.cptr()))
- }
-
- actual fun realm_clear_cached_apps() {
- realm_wrapper.realm_clear_cached_apps()
- }
-
- actual fun realm_app_sync_client_get_default_file_path_for_realm(
- syncConfig: RealmSyncConfigurationPointer,
- overriddenName: String?
- ): String {
- val cPath = realm_wrapper.realm_app_sync_client_get_default_file_path_for_realm(
- syncConfig.cptr(),
- overriddenName
- )
- return cPath.safeKString()
- .also { realm_wrapper.realm_free(cPath) }
- }
-
- actual fun realm_app_get_base_url(
- app: RealmAppPointer,
- ): String = realm_wrapper.realm_app_get_base_url(app.cptr())?.toKString()!!
-
- actual fun realm_app_update_base_url(
- app: RealmAppPointer,
- baseUrl: String?,
- callback: AppCallback,
- ) {
- checkedBooleanResult(
- realm_wrapper.realm_app_update_base_url(
- app.cptr(),
- baseUrl,
- callback = staticCFunction { userData, error ->
- handleAppCallback(
- userData,
- error
- ) { /* No-op, returns Unit */ }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userdata ->
- disposeUserData>(userdata)
- }
- )
- )
- }
-
- actual fun realm_user_get_all_identities(user: RealmUserPointer): List {
- memScoped {
- val count = AuthProvider.values().size
- val properties = allocArray(count)
- val outCount: ULongVarOf = alloc()
- realm_wrapper.realm_user_get_all_identities(
- user.cptr(),
- properties,
- count.convert(),
- outCount.ptr
- )
- outCount.value.toLong().let { count ->
- return if (count > 0) {
- (0 until outCount.value.toLong()).map {
- with(properties[it]) {
- SyncUserIdentity(this.id!!.toKString(), AuthProvider.of(this.provider_type))
- }
- }
- } else {
- emptyList()
- }
- }
- }
- }
-
- actual fun realm_user_get_identity(user: RealmUserPointer): String {
- return realm_wrapper.realm_user_get_identity(user.cptr()).safeKString("identity")
- }
-
- actual fun realm_user_is_logged_in(user: RealmUserPointer): Boolean {
- return realm_wrapper.realm_user_is_logged_in(user.cptr())
- }
-
- actual fun realm_user_log_out(user: RealmUserPointer) {
- checkedBooleanResult(realm_wrapper.realm_user_log_out(user.cptr()))
- }
-
- actual fun realm_user_get_state(user: RealmUserPointer): CoreUserState {
- return CoreUserState.of(realm_wrapper.realm_user_get_state(user.cptr()))
- }
-
- actual fun realm_user_get_profile(user: RealmUserPointer): String =
- realm_wrapper.realm_user_get_profile_data(user.cptr()).safeKString()
-
- actual fun realm_user_get_custom_data(user: RealmUserPointer): String? =
- realm_wrapper.realm_user_get_custom_data(user.cptr())?.toKString()
-
- actual fun realm_user_refresh_custom_data(
- app: RealmAppPointer,
- user: RealmUserPointer,
- callback: AppCallback
- ) {
- checkedBooleanResult(
- realm_wrapper.realm_app_refresh_custom_data(
- app = app.cptr(),
- user = user.cptr(),
- callback = staticCFunction { userData, error ->
- handleAppCallback(userData, error) { /* No-op, returns Unit */ }
- },
- userdata = StableRef.create(callback).asCPointer(),
- userdata_free = staticCFunction { userData -> disposeUserData>(userData) }
- )
- )
- }
-
- actual fun realm_app_config_get_sync_client_config(configPointer: RealmAppConfigurationPointer): RealmSyncClientConfigurationPointer {
- // The configuration is owned by Core so don't track and release it through garbage collection of the NativePointer
- return CPointerWrapper(realm_wrapper.realm_app_config_get_sync_client_config(configPointer.cptr()), false)
- }
-
- actual fun realm_sync_client_config_set_default_binding_thread_observer(
- syncClientConfig: RealmSyncClientConfigurationPointer,
- appId: String
- ) {
- realm_wrapper.realm_sync_client_config_set_default_binding_thread_observer(
- config = syncClientConfig.cptr(),
- on_thread_create = staticCFunction { _ ->
- // Do nothing
- },
- on_thread_destroy = staticCFunction { _ ->
- // Do nothing. Threads in Kotlin Native are cleaned up correctly without us
- // having to do anything.
- },
- on_error = staticCFunction { userdata, error ->
- // TODO Wait for https://github.com/realm/realm-core/issues/4194 to correctly
- // log errors. For now, just throw an Error as exceptions from the Sync Client
- // indicate that something is fundamentally wrong on the Sync Thread.
- // In Realm Java this has only been reported during development of new
- // features, so throwing an Error seems appropriate to increase visibility.
- val threadId = safeUserData(userdata)
- throw Error("[SyncThread-$threadId] Error on sync thread: ${error?.toKString()}")
- },
- user_data = StableRef.create(appId).asCPointer(),
- free_userdata = staticCFunction { userdata ->
- disposeUserData(userdata)
- }
- )
- }
-
- actual fun realm_app_config_set_base_file_path(
- appConfig: RealmAppConfigurationPointer,
- basePath: String
- ) {
- realm_wrapper.realm_app_config_set_base_file_path(appConfig.cptr(), basePath)
- }
-
- actual fun realm_sync_client_config_set_multiplex_sessions(syncClientConfig: RealmSyncClientConfigurationPointer, enabled: Boolean) {
- realm_wrapper.realm_sync_client_config_set_multiplex_sessions(syncClientConfig.cptr(), enabled)
- }
-
actual fun realm_set_log_callback(callback: LogCallback) {
realm_wrapper.realm_set_log_callback(
staticCFunction { userData, category, logLevel, message ->
@@ -2547,1004 +2015,6 @@ actual object RealmInterop {
}
}
- actual fun realm_app_config_set_metadata_mode(
- appConfig: RealmAppConfigurationPointer,
- metadataMode: MetadataMode,
- ) {
- realm_wrapper.realm_app_config_set_metadata_mode(
- appConfig.cptr(),
- metadataMode.metadataValue
- )
- }
-
- actual fun realm_app_config_set_metadata_encryption_key(
- appConfig: RealmAppConfigurationPointer,
- encryptionKey: ByteArray
- ) {
- memScoped {
- val encryptionKeyPointer = encryptionKey.refTo(0).getPointer(memScope)
- @Suppress("UNCHECKED_CAST")
- realm_wrapper.realm_app_config_set_metadata_encryption_key(
- appConfig.cptr(),
- encryptionKeyPointer as CPointer
- )
- }
- }
-
- actual fun realm_sync_client_config_set_user_agent_binding_info(
- syncClientConfig: RealmSyncClientConfigurationPointer,
- bindingInfo: String
- ) {
- realm_wrapper.realm_sync_client_config_set_user_agent_binding_info(
- syncClientConfig.cptr(),
- bindingInfo
- )
- }
-
- actual fun realm_sync_client_config_set_user_agent_application_info(
- syncClientConfig: RealmSyncClientConfigurationPointer,
- applicationInfo: String
- ) {
- realm_wrapper.realm_sync_client_config_set_user_agent_application_info(
- syncClientConfig.cptr(),
- applicationInfo
- )
- }
-
- actual fun realm_sync_client_config_set_connect_timeout(syncClientConfig: RealmSyncClientConfigurationPointer, timeoutMs: ULong) {
- realm_wrapper.realm_sync_client_config_set_connect_timeout(syncClientConfig.cptr(), timeoutMs)
- }
-
- actual fun realm_sync_client_config_set_connection_linger_time(syncClientConfig: RealmSyncClientConfigurationPointer, timeoutMs: ULong) {
- realm_wrapper.realm_sync_client_config_set_connection_linger_time(syncClientConfig.cptr(), timeoutMs)
- }
-
- actual fun realm_sync_client_config_set_ping_keepalive_period(syncClientConfig: RealmSyncClientConfigurationPointer, timeoutMs: ULong) {
- realm_wrapper.realm_sync_client_config_set_ping_keepalive_period(syncClientConfig.cptr(), timeoutMs)
- }
-
- actual fun realm_sync_client_config_set_pong_keepalive_timeout(syncClientConfig: RealmSyncClientConfigurationPointer, timeoutMs: ULong) {
- realm_wrapper.realm_sync_client_config_set_pong_keepalive_timeout(syncClientConfig.cptr(), timeoutMs)
- }
-
- actual fun realm_sync_client_config_set_fast_reconnect_limit(syncClientConfig: RealmSyncClientConfigurationPointer, timeoutMs: ULong) {
- realm_wrapper.realm_sync_client_config_set_fast_reconnect_limit(syncClientConfig.cptr(), timeoutMs)
- }
-
- actual fun realm_sync_config_set_error_handler(
- syncConfig: RealmSyncConfigurationPointer,
- errorHandler: SyncErrorCallback
- ) {
- realm_wrapper.realm_sync_config_set_error_handler(
- syncConfig.cptr(),
- staticCFunction { userData, syncSession, error ->
- val syncError: SyncError = error.useContents {
- val code = CoreError(
- this.status.categories.toInt(),
- this.status.error.value.toInt(),
- this.status.message.safeKString()
- )
-
- val userInfoMap = (0 until user_info_length.toInt())
- .mapNotNull {
- user_info_map?.get(it)
- }.mapNotNull {
- when {
- it.key != null && it.value != null ->
- Pair(it.key.safeKString(), it.value.safeKString())
- else -> null
- }
- }.toMap()
-
- val compensatingWrites =
- Array(compensating_writes_length.toInt()) { index ->
- compensating_writes!![index].let { compensatingWriteInfo ->
- CoreCompensatingWriteInfo(
- reason = compensatingWriteInfo.reason.safeKString(),
- objectName = compensatingWriteInfo.object_name.safeKString(),
- primaryKey = RealmValue(compensatingWriteInfo.primary_key)
- )
- }
- }
-
- SyncError(
- errorCode = code,
- originalFilePath = userInfoMap[c_original_file_path_key.safeKString()],
- recoveryFilePath = userInfoMap[c_recovery_file_path_key.safeKString()],
- isFatal = is_fatal,
- isUnrecognizedByClient = is_unrecognized_by_client,
- isClientResetRequested = is_client_reset_requested,
- compensatingWrites = compensatingWrites,
- userError = user_code_error?.asStableRef()?.get()
- ).also {
- user_code_error?.let { disposeUserData(it) }
- }
- }
- val errorCallback = safeUserData(userData)
- val session = CPointerWrapper(realm_clone(syncSession))
- errorCallback.onSyncError(session, syncError)
- },
- StableRef.create(errorHandler).asCPointer(),
- staticCFunction { userdata ->
- disposeUserData<(RealmSyncSessionPointer, SyncErrorCallback) -> Unit>(userdata)
- }
- )
- }
-
- actual fun realm_sync_config_set_resync_mode(
- syncConfig: RealmSyncConfigurationPointer,
- resyncMode: SyncSessionResyncMode
- ) {
- realm_wrapper.realm_sync_config_set_resync_mode(
- syncConfig.cptr(),
- resyncMode.value
- )
- }
-
- actual fun realm_sync_config_set_before_client_reset_handler(
- syncConfig: RealmSyncConfigurationPointer,
- beforeHandler: SyncBeforeClientResetHandler
- ) {
- realm_wrapper.realm_sync_config_set_before_client_reset_handler(
- syncConfig.cptr(),
- staticCFunction { userData, beforeRealm ->
- stableUserDataWithErrorPropagation(userData) {
- val beforeDb = CPointerWrapper(beforeRealm, false)
- onBeforeReset(beforeDb)
- true
- }
- },
- StableRef.create(beforeHandler).asCPointer(),
- staticCFunction { userdata ->
- disposeUserData(userdata)
- }
- )
- }
-
- actual fun realm_sync_config_set_after_client_reset_handler(
- syncConfig: RealmSyncConfigurationPointer,
- afterHandler: SyncAfterClientResetHandler
- ) {
- realm_wrapper.realm_sync_config_set_after_client_reset_handler(
- syncConfig.cptr(),
- staticCFunction { userData, beforeRealm, afterRealm, didRecover ->
- stableUserDataWithErrorPropagation(userData) {
- val beforeDb = CPointerWrapper(beforeRealm, false)
-
- // afterRealm is wrapped inside a ThreadSafeReference so the pointer needs to be resolved
- val afterRealmPtr = realm_wrapper.realm_from_thread_safe_reference(afterRealm, null)
- val afterDb = CPointerWrapper(afterRealmPtr, false)
-
- try {
- onAfterReset(beforeDb, afterDb, didRecover)
- true
- } finally {
- realm_wrapper.realm_close(afterRealmPtr)
- }
- }
- },
- StableRef.create(afterHandler).asCPointer(),
- staticCFunction { userdata ->
- disposeUserData(userdata)
- }
- )
- }
-
- actual fun realm_sync_immediately_run_file_actions(app: RealmAppPointer, syncPath: String): Boolean {
- memScoped {
- val didRun = alloc()
- checkedBooleanResult(
- realm_wrapper.realm_sync_immediately_run_file_actions(app.cptr(), syncPath, didRun.ptr)
- )
- return didRun.value
- }
- }
-
- actual fun realm_sync_session_get(realm: RealmPointer): RealmSyncSessionPointer {
- return CPointerWrapper(realm_wrapper.realm_sync_session_get(realm.cptr()))
- }
-
- actual fun realm_sync_session_wait_for_download_completion(
- syncSession: RealmSyncSessionPointer,
- callback: SyncSessionTransferCompletionCallback
- ) {
- realm_wrapper.realm_sync_session_wait_for_download_completion(
- syncSession.cptr(),
- staticCFunction?, Unit> { userData, error ->
- handleCompletionCallback(userData, error)
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userdata ->
- disposeUserData<(RealmSyncSessionPointer, SyncSessionTransferCompletionCallback) -> Unit>(userdata)
- }
- )
- }
-
- actual fun realm_sync_session_wait_for_upload_completion(
- syncSession: RealmSyncSessionPointer,
- callback: SyncSessionTransferCompletionCallback
- ) {
- realm_wrapper.realm_sync_session_wait_for_upload_completion(
- syncSession.cptr(),
- staticCFunction?, Unit> { userData, error ->
- handleCompletionCallback(userData, error)
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userdata ->
- disposeUserData<(RealmSyncSessionPointer, SyncSessionTransferCompletionCallback) -> Unit>(userdata)
- }
- )
- }
-
- actual fun realm_sync_session_state(syncSession: RealmSyncSessionPointer): CoreSyncSessionState {
- val value: realm_sync_session_state_e =
- realm_wrapper.realm_sync_session_get_state(syncSession.cptr())
- return CoreSyncSessionState.of(value)
- }
-
- actual fun realm_sync_connection_state(syncSession: RealmSyncSessionPointer): CoreConnectionState =
- CoreConnectionState.of(
- realm_wrapper.realm_sync_session_get_connection_state(syncSession.cptr())
- )
-
- actual fun realm_sync_session_pause(syncSession: RealmSyncSessionPointer) {
- realm_wrapper.realm_sync_session_pause(syncSession.cptr())
- }
-
- actual fun realm_sync_session_resume(syncSession: RealmSyncSessionPointer) {
- realm_wrapper.realm_sync_session_resume(syncSession.cptr())
- }
-
- actual fun realm_sync_session_handle_error_for_testing(
- syncSession: RealmSyncSessionPointer,
- error: ErrorCode,
- errorMessage: String,
- isFatal: Boolean
- ) {
- realm_wrapper.realm_sync_session_handle_error_for_testing(
- syncSession.cptr(),
- error.asNativeEnum,
- errorMessage,
- isFatal
- )
- }
-
- actual fun realm_sync_session_register_progress_notifier(
- syncSession: RealmSyncSessionPointer,
- direction: ProgressDirection,
- isStreaming: Boolean,
- callback: ProgressCallback,
- ): RealmNotificationTokenPointer {
- return CPointerWrapper(
- realm_wrapper.realm_sync_session_register_progress_notifier(
- syncSession.cptr(),
- staticCFunction { userData, _, _, progress_estimate ->
- safeUserData(userData).run {
- onChange(progress_estimate)
- }
- },
- direction.nativeValue,
- isStreaming,
- StableRef.create(callback).asCPointer(),
- staticCFunction { userdata ->
- disposeUserData(userdata)
- }
- ),
- managed = false
- )
- }
-
- actual fun realm_sync_session_register_connection_state_change_callback(
- syncSession: RealmSyncSessionPointer,
- callback: ConnectionStateChangeCallback,
- ): RealmNotificationTokenPointer {
- return CPointerWrapper(
- realm_wrapper.realm_sync_session_register_connection_state_change_callback(
- syncSession.cptr(),
- staticCFunction { userData, oldState, newState ->
- safeUserData(userData).run {
- onChange(CoreConnectionState.of(oldState), CoreConnectionState.of(newState))
- }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userdata ->
- disposeUserData(userdata)
- }
- ),
- managed = false
- )
- }
-
- private fun handleCompletionCallback(
- userData: CPointer?,
- error: CPointer?
- ) {
- val completionCallback = safeUserData(userData)
- if (error != null) {
- val category = error.pointed.categories.toInt()
- val value: Int = error.pointed.error.value.toInt()
- val message = error.pointed.message.safeKString()
- completionCallback.invoke(CoreError(category, value, message))
- } else {
- completionCallback.invoke(null)
- }
- }
-
- actual fun realm_network_transport_new(networkTransport: NetworkTransport): RealmNetworkTransportPointer {
- return CPointerWrapper(
- realm_wrapper.realm_http_transport_new(
- newRequestLambda,
- StableRef.create(networkTransport).asCPointer(),
- staticCFunction { userdata: CPointer? ->
- disposeUserData(userdata)
- }
- )
- )
- }
-
- actual fun realm_sync_set_websocket_transport(
- syncClientConfig: RealmSyncClientConfigurationPointer,
- webSocketTransport: WebSocketTransport
- ) {
- val realmSyncSocketNew: CPointer =
- checkedPointerResult(
- realm_wrapper.realm_sync_socket_new(
- userdata = StableRef.create(webSocketTransport).asCPointer(),
- userdata_free = staticCFunction { userdata: CPointer? ->
- safeUserData(userdata).close()
- disposeUserData(userdata)
- },
- post_func = staticCFunction { userdata: CPointer?, syncSocketCallback: CPointer? ->
- val callback: WebsocketFunctionHandlerCallback = { cancelled, _, _ ->
- realm_wrapper.realm_sync_socket_post_complete(
- syncSocketCallback,
- if (cancelled) WebsocketCallbackResult.RLM_ERR_SYNC_SOCKET_OPERATION_ABORTED.asNativeEnum else WebsocketCallbackResult.RLM_ERR_SYNC_SOCKET_SUCCESS.asNativeEnum,
- ""
- )
- }
-
- safeUserData(userdata).post(
- CPointerWrapper(StableRef.create(callback).asCPointer())
- )
- },
- create_timer_func = staticCFunction { userdata: CPointer?, delayInMilliseconds: uint64_t, syncSocketCallback: CPointer? ->
- val callback: WebsocketFunctionHandlerCallback = { cancelled, _, _ ->
- if (cancelled) {
- realm_wrapper.realm_sync_socket_timer_canceled(syncSocketCallback)
- } else {
- realm_wrapper.realm_sync_socket_timer_complete(
- syncSocketCallback,
- WebsocketCallbackResult.RLM_ERR_SYNC_SOCKET_SUCCESS.asNativeEnum,
- ""
- )
- }
- }
-
- safeUserData(userdata).let { ws ->
- val job: CancellableTimer = ws.createTimer(
- delayInMilliseconds.toLong(),
- CPointerWrapper(StableRef.create(callback).asCPointer())
- )
- StableRef.create(job).asCPointer()
- }
- },
- cancel_timer_func = staticCFunction { userdata: CPointer?, timer: realm_sync_socket_timer_t? ->
- safeUserData(timer).cancel()
- },
- free_timer_func = staticCFunction { userdata: CPointer?, timer: realm_sync_socket_timer_t? ->
- disposeUserData(timer)
- },
- websocket_connect_func = staticCFunction { userdata: CPointer?, endpoint: CValue, observer: CPointer? ->
- safeUserData(userdata).let { websocketTransport ->
- endpoint.useContents {
- val managedObserver = WebSocketObserver(CPointerWrapper(observer))
-
- val supportedProtocols = mutableListOf()
- for (i in 0 until this.num_protocols.toInt()) {
- val protocol: CPointer>? =
- this.protocols?.get(i)
- supportedProtocols.add(protocol.safeKString())
- }
- val webSocketClient: WebSocketClient = websocketTransport.connect(
- managedObserver,
- this.path.safeKString(),
- this.address.safeKString(),
- this.port.toLong(),
- this.is_ssl,
- this.num_protocols.toLong(),
- supportedProtocols.joinToString(", ")
- )
- StableRef.create(webSocketClient).asCPointer()
- }
- }
- },
- websocket_write_func = staticCFunction { userdata: CPointer?, websocket: realm_sync_socket_websocket_t?, data: CPointer?, length: size_t, callback: CPointer? ->
- val postWriteCallback: WebsocketFunctionHandlerCallback =
- { cancelled, status, reason ->
- realm_wrapper.realm_sync_socket_write_complete(
- callback,
- if (cancelled) WebsocketCallbackResult.RLM_ERR_SYNC_SOCKET_OPERATION_ABORTED.asNativeEnum else WebsocketCallbackResult.RLM_ERR_SYNC_SOCKET_SUCCESS.asNativeEnum,
- reason
- )
- }
-
- safeUserData(userdata).let { websocketTransport ->
- safeUserData(websocket).let { webSocketClient ->
- data?.readBytes(length.toInt())?.run {
- websocketTransport.write(
- webSocketClient,
- this,
- length.toLong(),
- CPointerWrapper(
- StableRef.create(postWriteCallback).asCPointer()
- )
- )
- }
- }
- }
- Unit
- },
- websocket_free_func = staticCFunction { userdata: CPointer?, websocket: realm_sync_socket_websocket_t? ->
- safeUserData(websocket).close()
- disposeUserData(websocket)
- }
- )
- ) ?: error("Couldn't create Sync Socket")
- realm_wrapper.realm_sync_client_config_set_sync_socket(
- syncClientConfig.cptr(),
- realmSyncSocketNew
- )
- realm_release(realmSyncSocketNew)
- }
-
- actual fun realm_sync_socket_callback_complete(nativePointer: RealmWebsocketHandlerCallbackPointer, cancelled: Boolean, status: WebsocketCallbackResult, reason: String) {
- safeUserData(nativePointer.cptr())(cancelled, status, reason)
- disposeUserData(nativePointer.cptr())
- }
-
- actual fun realm_sync_socket_websocket_connected(nativePointer: RealmWebsocketProviderPointer, protocol: String) {
- realm_wrapper.realm_sync_socket_websocket_connected(nativePointer.cptr(), protocol)
- }
-
- actual fun realm_sync_socket_websocket_error(nativePointer: RealmWebsocketProviderPointer) {
- realm_wrapper.realm_sync_socket_websocket_error(nativePointer.cptr())
- }
-
- actual fun realm_sync_socket_websocket_message(
- nativePointer: RealmWebsocketProviderPointer,
- data: ByteArray
- ): Boolean {
- return realm_wrapper.realm_sync_socket_websocket_message(
- nativePointer.cptr(),
- data.toCValues(),
- data.size.toULong()
- )
- }
-
- actual fun realm_sync_socket_websocket_closed(nativePointer: RealmWebsocketProviderPointer, wasClean: Boolean, errorCode: WebsocketErrorCode, reason: String) {
- realm_wrapper.realm_sync_socket_websocket_closed(nativePointer.cptr(), wasClean, errorCode.asNativeEnum, reason)
- }
-
- @Suppress("LongParameterList")
- actual fun realm_app_config_new(
- appId: String,
- networkTransport: RealmNetworkTransportPointer,
- baseUrl: String?,
- connectionParams: SyncConnectionParams
- ): RealmAppConfigurationPointer {
- val appConfig = realm_wrapper.realm_app_config_new(appId, networkTransport.cptr())
- baseUrl?.let { realm_wrapper.realm_app_config_set_base_url(appConfig, it) }
-
- // Sync Connection Parameters
- realm_wrapper.realm_app_config_set_sdk(appConfig, connectionParams.sdkName)
- realm_wrapper.realm_app_config_set_sdk_version(appConfig, connectionParams.sdkVersion)
- realm_wrapper.realm_app_config_set_platform_version(appConfig, connectionParams.platformVersion)
- realm_wrapper.realm_app_config_set_device_name(appConfig, connectionParams.device)
- realm_wrapper.realm_app_config_set_device_version(appConfig, connectionParams.deviceVersion)
- realm_wrapper.realm_app_config_set_framework_name(appConfig, connectionParams.framework)
- realm_wrapper.realm_app_config_set_framework_version(appConfig, connectionParams.frameworkVersion)
- realm_wrapper.realm_app_config_set_bundle_id(appConfig, connectionParams.bundleId)
-
- return CPointerWrapper(appConfig)
- }
-
- actual fun realm_app_config_set_base_url(appConfig: RealmAppConfigurationPointer, baseUrl: String) {
- realm_wrapper.realm_app_config_set_base_url(appConfig.cptr(), baseUrl)
- }
-
- actual fun realm_app_credentials_new_anonymous(reuseExisting: Boolean): RealmCredentialsPointer {
- return CPointerWrapper(realm_wrapper.realm_app_credentials_new_anonymous(reuseExisting))
- }
-
- actual fun realm_app_credentials_new_email_password(
- username: String,
- password: String
- ): RealmCredentialsPointer {
- memScoped {
- val realmStringPassword = password.toRString(this)
- return CPointerWrapper(
- realm_wrapper.realm_app_credentials_new_email_password(
- username,
- realmStringPassword
- )
- )
- }
- }
-
- actual fun realm_app_credentials_new_api_key(key: String): RealmCredentialsPointer {
- memScoped {
- return CPointerWrapper(realm_wrapper.realm_app_credentials_new_api_key(key))
- }
- }
-
- actual fun realm_app_credentials_new_apple(idToken: String): RealmCredentialsPointer {
- memScoped {
- return CPointerWrapper(realm_wrapper.realm_app_credentials_new_apple(idToken))
- }
- }
-
- actual fun realm_app_credentials_new_facebook(accessToken: String): RealmCredentialsPointer {
- memScoped {
- return CPointerWrapper(realm_wrapper.realm_app_credentials_new_facebook(accessToken))
- }
- }
-
- actual fun realm_app_credentials_new_google_id_token(idToken: String): RealmCredentialsPointer {
- memScoped {
- return CPointerWrapper(realm_wrapper.realm_app_credentials_new_google_id_token(idToken))
- }
- }
-
- actual fun realm_app_credentials_new_google_auth_code(authCode: String): RealmCredentialsPointer {
- memScoped {
- return CPointerWrapper(realm_wrapper.realm_app_credentials_new_google_auth_code(authCode))
- }
- }
-
- actual fun realm_app_credentials_new_jwt(jwtToken: String): RealmCredentialsPointer {
- memScoped {
- return CPointerWrapper(realm_wrapper.realm_app_credentials_new_jwt(jwtToken))
- }
- }
-
- actual fun realm_app_credentials_new_custom_function(serializedEjsonPayload: String): RealmCredentialsPointer {
- memScoped {
- return CPointerWrapper(realm_wrapper.realm_app_credentials_new_function(serializedEjsonPayload))
- }
- }
-
- actual fun realm_auth_credentials_get_provider(credentials: RealmCredentialsPointer): AuthProvider {
- return AuthProvider.of(realm_wrapper.realm_auth_credentials_get_provider(credentials.cptr()))
- }
-
- actual fun realm_user_get_access_token(user: RealmUserPointer): String {
- return realm_wrapper.realm_user_get_access_token(user.cptr()).safeKString()
- }
-
- actual fun realm_user_get_refresh_token(user: RealmUserPointer): String {
- return realm_wrapper.realm_user_get_refresh_token(user.cptr()).safeKString()
- }
-
- actual fun realm_user_get_device_id(user: RealmUserPointer): String {
- return realm_wrapper.realm_user_get_device_id(user.cptr()).safeKString()
- }
-
- actual fun realm_app_credentials_serialize_as_json(credentials: RealmCredentialsPointer): String {
- return realm_wrapper
- .realm_app_credentials_serialize_as_json(credentials.cptr())
- .safeKString("credentials")
- }
-
- actual fun realm_app_email_password_provider_client_register_email(
- app: RealmAppPointer,
- email: String,
- password: String,
- callback: AppCallback
- ) {
- memScoped {
- checkedBooleanResult(
- realm_wrapper.realm_app_email_password_provider_client_register_email(
- app.cptr(),
- email,
- password.toRString(this),
- staticCFunction { userData, error ->
- handleAppCallback(userData, error) { /* No-op, returns Unit */ }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userData -> disposeUserData>(userData) }
- )
- )
- }
- }
- actual fun realm_app_email_password_provider_client_confirm_user(
- app: RealmAppPointer,
- token: String,
- tokenId: String,
- callback: AppCallback
- ) {
- memScoped {
- checkedBooleanResult(
- realm_wrapper.realm_app_email_password_provider_client_confirm_user(
- app.cptr(),
- token,
- tokenId,
- staticCFunction { userData, error ->
- handleAppCallback(userData, error) { /* No-op, returns Unit */ }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userData -> disposeUserData>(userData) }
- )
- )
- }
- }
-
- actual fun realm_app_email_password_provider_client_resend_confirmation_email(
- app: RealmAppPointer,
- email: String,
- callback: AppCallback
- ) {
- memScoped {
- checkedBooleanResult(
- realm_wrapper.realm_app_email_password_provider_client_resend_confirmation_email(
- app.cptr(),
- email,
- staticCFunction { userData, error ->
- handleAppCallback(userData, error) { /* No-op, returns Unit */ }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userData -> disposeUserData>(userData) }
- )
- )
- }
- }
-
- actual fun realm_app_email_password_provider_client_retry_custom_confirmation(
- app: RealmAppPointer,
- email: String,
- callback: AppCallback
- ) {
- memScoped {
- checkedBooleanResult(
- realm_wrapper.realm_app_email_password_provider_client_retry_custom_confirmation(
- app.cptr(),
- email,
- staticCFunction { userData, error ->
- handleAppCallback(userData, error) { /* No-op, returns Unit */ }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userData -> disposeUserData>(userData) }
- )
- )
- }
- }
-
- actual fun realm_app_email_password_provider_client_send_reset_password_email(
- app: RealmAppPointer,
- email: String,
- callback: AppCallback
- ) {
- memScoped {
- checkedBooleanResult(
- realm_wrapper.realm_app_email_password_provider_client_send_reset_password_email(
- app.cptr(),
- email,
- staticCFunction { userData, error ->
- handleAppCallback(userData, error) { /* No-op, returns Unit */ }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userData -> disposeUserData>(userData) }
- )
- )
- }
- }
-
- actual fun realm_app_email_password_provider_client_reset_password(
- app: RealmAppPointer,
- token: String,
- tokenId: String,
- newPassword: String,
- callback: AppCallback
- ) {
- memScoped {
- checkedBooleanResult(
- realm_wrapper.realm_app_email_password_provider_client_reset_password(
- app.cptr(),
- newPassword.toRString(this),
- token,
- tokenId,
- staticCFunction { userData, error ->
- handleAppCallback(userData, error) { /* No-op, returns Unit */ }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userData -> disposeUserData>(userData) }
- )
- )
- }
- }
-
- actual fun realm_app_call_function(
- app: RealmAppPointer,
- user: RealmUserPointer,
- name: String,
- serviceName: String?,
- serializedEjsonArgs: String,
- callback: AppCallback
- ) {
- realm_wrapper.realm_app_call_function(
- app.cptr(),
- user.cptr(),
- name,
- serializedEjsonArgs,
- serviceName,
- staticCFunction { userData: CPointer?, data: CPointer>?, error: CPointer? ->
- handleAppCallback(userData, error) {
- data.safeKString()
- }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userData -> disposeUserData>(userData) }
- )
- }
-
- actual fun realm_app_call_reset_password_function(
- app: RealmAppPointer,
- email: String,
- newPassword: String,
- serializedEjsonPayload: String,
- callback: AppCallback
- ) {
- memScoped {
- checkedBooleanResult(
- realm_wrapper.realm_app_email_password_provider_client_call_reset_password_function(
- app.cptr(),
- email,
- newPassword.toRString(this),
- serializedEjsonPayload,
- staticCFunction { userData, error ->
- handleAppCallback(userData, error) { /* No-op, returns Unit */ }
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userData -> disposeUserData>(userData) }
- )
- )
- }
- }
-
- actual fun realm_sync_config_new(
- user: RealmUserPointer,
- partition: String
- ): RealmSyncConfigurationPointer {
- return CPointerWrapper(realm_wrapper.realm_sync_config_new(user.cptr(), partition)).also { ptr ->
- // Stop the session immediately when the Realm is closed, so the lifecycle of the
- // Sync Client thread is manageable.
- realm_wrapper.realm_sync_config_set_session_stop_policy(ptr.cptr(), realm_sync_session_stop_policy_e.RLM_SYNC_SESSION_STOP_POLICY_IMMEDIATELY)
- }
- }
-
- actual fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer {
- return CPointerWrapper(realm_wrapper.realm_flx_sync_config_new((user.cptr())))
- }
-
- actual fun realm_app_sync_client_reconnect(app: RealmAppPointer) {
- realm_wrapper.realm_app_sync_client_reconnect(app.cptr())
- }
- actual fun realm_app_sync_client_has_sessions(app: RealmAppPointer): Boolean {
- return realm_wrapper.realm_app_sync_client_has_sessions(app.cptr())
- }
-
- actual fun realm_app_sync_client_wait_for_sessions_to_terminate(app: RealmAppPointer) {
- realm_wrapper.realm_app_sync_client_wait_for_sessions_to_terminate(app.cptr())
- }
-
- actual fun realm_config_set_sync_config(realmConfiguration: RealmConfigurationPointer, syncConfiguration: RealmSyncConfigurationPointer) {
- realm_wrapper.realm_config_set_sync_config(realmConfiguration.cptr(), syncConfiguration.cptr())
- }
-
- actual fun realm_sync_subscription_id(subscription: RealmSubscriptionPointer): ObjectId {
- return ObjectId(realm_wrapper.realm_sync_subscription_id(subscription.cptr()).getBytes())
- }
-
- actual fun realm_sync_subscription_name(subscription: RealmSubscriptionPointer): String? {
- return realm_wrapper.realm_sync_subscription_name(subscription.cptr()).useContents {
- this.toNullableKotlinString()
- }
- }
-
- actual fun realm_sync_subscription_object_class_name(subscription: RealmSubscriptionPointer): String {
- return realm_wrapper.realm_sync_subscription_object_class_name(subscription.cptr()).useContents {
- this.toKotlinString()
- }
- }
-
- actual fun realm_sync_subscription_query_string(subscription: RealmSubscriptionPointer): String {
- return realm_wrapper.realm_sync_subscription_query_string(subscription.cptr()).useContents {
- this.toKotlinString()
- }
- }
-
- actual fun realm_sync_subscription_created_at(subscription: RealmSubscriptionPointer): Timestamp {
- return realm_wrapper.realm_sync_subscription_created_at(subscription.cptr()).useContents {
- TimestampImpl(this.seconds, this.nanoseconds)
- }
- }
-
- actual fun realm_sync_subscription_updated_at(subscription: RealmSubscriptionPointer): Timestamp {
- return realm_wrapper.realm_sync_subscription_updated_at(subscription.cptr()).useContents {
- TimestampImpl(this.seconds, this.nanoseconds)
- }
- }
-
- actual fun realm_sync_get_latest_subscriptionset(realm: RealmPointer): RealmSubscriptionSetPointer {
- return CPointerWrapper(realm_wrapper.realm_sync_get_latest_subscription_set(realm.cptr()))
- }
-
- actual fun realm_sync_on_subscriptionset_state_change_async(
- subscriptionSet: RealmSubscriptionSetPointer,
- destinationState: CoreSubscriptionSetState,
- callback: SubscriptionSetCallback
- ) {
- realm_wrapper.realm_sync_on_subscription_set_state_change_async(
- subscriptionSet.cptr(),
- destinationState.nativeValue,
- staticCFunction { userData, state ->
- val callback = safeUserData(userData)
- callback.onChange(CoreSubscriptionSetState.of(state))
- },
- StableRef.create(callback).asCPointer(),
- staticCFunction { userdata ->
- disposeUserData<(SubscriptionSetCallback) -> Unit>(userdata)
- }
- )
- }
-
- actual fun realm_sync_subscriptionset_version(subscriptionSet: RealmBaseSubscriptionSetPointer): Long {
- return realm_wrapper.realm_sync_subscription_set_version(subscriptionSet.cptr())
- }
-
- actual fun realm_sync_subscriptionset_state(subscriptionSet: RealmBaseSubscriptionSetPointer): CoreSubscriptionSetState {
- val value: realm_flx_sync_subscription_set_state_e =
- realm_wrapper.realm_sync_subscription_set_state(subscriptionSet.cptr())
- return CoreSubscriptionSetState.of(value)
- }
-
- actual fun realm_sync_subscriptionset_error_str(subscriptionSet: RealmBaseSubscriptionSetPointer): String? {
- return realm_wrapper.realm_sync_subscription_set_error_str(subscriptionSet.cptr())?.toKString()
- }
-
- actual fun realm_sync_subscriptionset_size(subscriptionSet: RealmBaseSubscriptionSetPointer): Long {
- return realm_wrapper.realm_sync_subscription_set_size(subscriptionSet.cptr()).toLong()
- }
-
- actual fun realm_sync_subscription_at(
- subscriptionSet: RealmBaseSubscriptionSetPointer,
- index: Long
- ): RealmSubscriptionPointer {
- return CPointerWrapper(realm_wrapper.realm_sync_subscription_at(subscriptionSet.cptr(), index.toULong()))
- }
-
- actual fun realm_sync_find_subscription_by_name(
- subscriptionSet: RealmBaseSubscriptionSetPointer,
- name: String
- ): RealmSubscriptionPointer? {
- val ptr = realm_wrapper.realm_sync_find_subscription_by_name(subscriptionSet.cptr(), name)
- return nativePointerOrNull(ptr)
- }
-
- actual fun realm_sync_find_subscription_by_query(
- subscriptionSet: RealmBaseSubscriptionSetPointer,
- query: RealmQueryPointer
- ): RealmSubscriptionPointer? {
- val ptr = realm_wrapper.realm_sync_find_subscription_by_query(subscriptionSet.cptr(), query.cptr())
- return nativePointerOrNull(ptr)
- }
-
- actual fun realm_sync_subscriptionset_refresh(subscriptionSet: RealmSubscriptionSetPointer): Boolean {
- return realm_wrapper.realm_sync_subscription_set_refresh(subscriptionSet.cptr())
- }
-
- actual fun realm_sync_make_subscriptionset_mutable(
- subscriptionSet: RealmSubscriptionSetPointer
- ): RealmMutableSubscriptionSetPointer {
- return CPointerWrapper(
- realm_wrapper.realm_sync_make_subscription_set_mutable(subscriptionSet.cptr()),
- managed = false
- )
- }
-
- actual fun realm_sync_subscriptionset_clear(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer
- ): Boolean {
- val erased = realm_wrapper.realm_sync_subscription_set_size(mutableSubscriptionSet.cptr()).toLong() > 0
- checkedBooleanResult(
- realm_wrapper.realm_sync_subscription_set_clear(mutableSubscriptionSet.cptr())
- )
- return erased
- }
-
- actual fun realm_sync_subscriptionset_insert_or_assign(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer,
- query: RealmQueryPointer,
- name: String?
- ): Pair {
- memScoped {
- val outIndex = alloc()
- val outInserted = alloc()
- realm_wrapper.realm_sync_subscription_set_insert_or_assign_query(
- mutableSubscriptionSet.cptr(),
- query.cptr(),
- name,
- outIndex.ptr,
- outInserted.ptr
- )
- @Suppress("UNCHECKED_CAST")
- return Pair(
- realm_sync_subscription_at(
- mutableSubscriptionSet as RealmSubscriptionSetPointer,
- outIndex.value.toLong()
- ),
- outInserted.value
- )
- }
- }
-
- actual fun realm_sync_subscriptionset_erase_by_name(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer,
- name: String
- ): Boolean {
- memScoped {
- val erased = alloc()
- checkedBooleanResult(
- realm_wrapper.realm_sync_subscription_set_erase_by_name(
- mutableSubscriptionSet.cptr(),
- name,
- erased.ptr
- )
- )
- return erased.value
- }
- }
-
- actual fun realm_sync_subscriptionset_erase_by_query(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer,
- query: RealmQueryPointer
- ): Boolean {
- memScoped {
- val erased = alloc()
- checkedBooleanResult(
- realm_wrapper.realm_sync_subscription_set_erase_by_query(
- mutableSubscriptionSet.cptr(),
- query.cptr(),
- erased.ptr
- )
- )
- return erased.value
- }
- }
-
- actual fun realm_sync_subscriptionset_erase_by_id(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer,
- sub: RealmSubscriptionPointer
- ): Boolean {
- memScoped {
- val id = realm_wrapper.realm_sync_subscription_id(sub.cptr())
- val erased = alloc()
- checkedBooleanResult(
- realm_wrapper.realm_sync_subscription_set_erase_by_id(
- mutableSubscriptionSet.cptr(),
- id,
- erased.ptr
- )
- )
- return erased.value
- }
- }
-
- actual fun realm_sync_subscriptionset_commit(
- mutableSubscriptionSet: RealmMutableSubscriptionSetPointer
- ): RealmSubscriptionSetPointer {
- return CPointerWrapper(realm_wrapper.realm_sync_subscription_set_commit(mutableSubscriptionSet.cptr()))
- }
-
/**
* C-API functions for queries receive a pointer to one or more 'realm_query_arg_t' query
* arguments. In turn, said arguments contain individual values or lists of values (in
@@ -3621,85 +2091,6 @@ actual object RealmInterop {
?: throw NullPointerException(identifier?.let { "'$identifier' shouldn't be null." })
}
- private fun handleAppCallback(
- userData: COpaquePointer?,
- error: CPointer?,
- getValue: () -> R
- ) {
- val userDataCallback = safeUserData>(userData)
- if (error == null) {
- userDataCallback.onSuccess(getValue())
- } else {
- val err: realm_app_error_t = error.pointed
- val ex = AppError.newInstance(
- err.categories.toInt(),
- err.error.value.toInt(),
- err.http_status_code,
- err.message?.toKString(),
- err.link_to_server_logs?.toKString()
- )
- userDataCallback.onError(ex)
- }
- }
-
- private val newRequestLambda = staticCFunction,
- COpaquePointer?,
- Unit>
- { userdata, request, requestContext ->
- safeUserData(userdata).let { networkTransport ->
- request.useContents { // this : realm_http_request_t ->
- val headerMap = mutableMapOf()
- for (i in 0 until num_headers.toInt()) {
- headers?.get(i)?.let { header ->
- headerMap[header.name!!.toKString()] = header.value!!.toKString()
- } ?: error("Header at index $i within range ${num_headers.toInt()} should not be null")
- }
-
- networkTransport.sendRequest(
- method = when (method) {
- realm_http_request_method.RLM_HTTP_REQUEST_METHOD_GET -> NetworkTransport.GET
- realm_http_request_method.RLM_HTTP_REQUEST_METHOD_POST -> NetworkTransport.POST
- realm_http_request_method.RLM_HTTP_REQUEST_METHOD_PATCH -> NetworkTransport.PATCH
- realm_http_request_method.RLM_HTTP_REQUEST_METHOD_PUT -> NetworkTransport.PUT
- realm_http_request_method.RLM_HTTP_REQUEST_METHOD_DELETE -> NetworkTransport.DELETE
- else -> error("Unknown method: $method")
- },
- url = url!!.toKString(),
- headers = headerMap,
- body = body!!.toKString()
- ) { response: Response ->
- memScoped {
- val headersSize = response.headers.entries.size
- val cResponseHeaders =
- allocArray(headersSize)
-
- response.headers.entries.forEachIndexed { i, entry ->
- cResponseHeaders[i].let { header ->
- header.name = entry.key.cstr.getPointer(memScope)
- header.value = entry.value.cstr.getPointer(memScope)
- }
- }
-
- val cResponse =
- alloc {
- body = response.body.cstr.getPointer(memScope)
- body_size = response.body.cstr.getBytes().size.toULong()
- custom_status_code = response.customResponseCode
- status_code = response.httpResponseCode
- num_headers = response.headers.entries.size.toULong()
- headers = cResponseHeaders
- }
- realm_wrapper.realm_http_transport_complete_request(
- requestContext,
- cResponse.ptr
- )
- }
- }
- }
- }
- }
-
interface Scheduler {
fun notify(work_queue: CPointer