Skip to content

Commit

Permalink
Upgrade to latest core
Browse files Browse the repository at this point in the history
  • Loading branch information
rorbech committed Apr 29, 2024
1 parent 3f2f9aa commit 1b90390
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 71 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This release will bump the Realm file format from version 23 to 24. Opening a fi
* Minimum R8: 8.0.34.

### Internal
* None.
* Updated to Realm Core 14.5.2 commit e3578163cdb799eeda9e531f2ca33b8d80b2d2d2.


## 1.15.0 (2024-04-17)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,9 @@ expect enum class ErrorCode : CodeDescription {
RLM_ERR_BAD_SERVER_URL,
RLM_ERR_CUSTOM_ERROR,
RLM_ERR_CLIENT_USER_NOT_FOUND,
RLM_ERR_CLIENT_USER_NOT_LOGGED_IN,
RLM_ERR_CLIENT_APP_DEALLOCATED,
RLM_ERR_CLIENT_REDIRECT_ERROR,
RLM_ERR_CLIENT_TOO_MANY_REDIRECTS,
RLM_ERR_CLIENT_USER_ALREADY_NAMED,
RLM_ERR_BAD_TOKEN,
RLM_ERR_MALFORMED_JSON,
RLM_ERR_MISSING_JSON_KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@ expect object RealmInterop {
appId: String
)

fun realm_sync_client_config_set_base_file_path(
syncClientConfig: RealmSyncClientConfigurationPointer,
fun realm_app_config_set_base_file_path(
appConfig: RealmAppConfigurationPointer,
basePath: String
)

Expand All @@ -583,13 +583,13 @@ expect object RealmInterop {

fun realm_set_log_level(level: CoreLogLevel)

fun realm_sync_client_config_set_metadata_mode(
syncClientConfig: RealmSyncClientConfigurationPointer,
fun realm_app_config_set_metadata_mode(
appConfig: RealmAppConfigurationPointer,
metadataMode: MetadataMode
)

fun realm_sync_client_config_set_metadata_encryption_key(
syncClientConfig: RealmSyncClientConfigurationPointer,
fun realm_app_config_set_metadata_encryption_key(
appConfig: RealmAppConfigurationPointer,
encryptionKey: ByteArray
)
fun realm_sync_client_config_set_user_agent_binding_info(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ actual enum class ErrorCode(actual override val description: String?, actual ove
RLM_ERR_BAD_SERVER_URL("BadServerUrl", realm_errno_e.RLM_ERR_BAD_SERVER_URL),
RLM_ERR_CUSTOM_ERROR("CustomError", realm_errno_e.RLM_ERR_CUSTOM_ERROR),
RLM_ERR_CLIENT_USER_NOT_FOUND("ClientUserNotFound", realm_errno_e.RLM_ERR_CLIENT_USER_NOT_FOUND),
RLM_ERR_CLIENT_USER_NOT_LOGGED_IN("ClientUserNotLoggedIn", realm_errno_e.RLM_ERR_CLIENT_USER_NOT_LOGGED_IN),
RLM_ERR_CLIENT_APP_DEALLOCATED("ClientAppDeallocated", realm_errno_e.RLM_ERR_CLIENT_APP_DEALLOCATED),
RLM_ERR_CLIENT_REDIRECT_ERROR("ClientRedirectError", realm_errno_e.RLM_ERR_CLIENT_REDIRECT_ERROR),
RLM_ERR_CLIENT_TOO_MANY_REDIRECTS("ClientTooManyRedirects", realm_errno_e.RLM_ERR_CLIENT_TOO_MANY_REDIRECTS),
RLM_ERR_CLIENT_USER_ALREADY_NAMED("ClientUserAlreadyNamed", realm_errno_e.RLM_ERR_CLIENT_USER_ALREADY_NAMED),
RLM_ERR_BAD_TOKEN("BadToken", realm_errno_e.RLM_ERR_BAD_TOKEN),
RLM_ERR_MALFORMED_JSON("MalformedJson", realm_errno_e.RLM_ERR_MALFORMED_JSON),
RLM_ERR_MISSING_JSON_KEY("MissingJsonKey", realm_errno_e.RLM_ERR_MISSING_JSON_KEY),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.realm.kotlin.internal.interop

import io.realm.kotlin.internal.interop.Constants.ENCRYPTION_KEY_LENGTH
import io.realm.kotlin.internal.interop.RealmInterop.cptr
import io.realm.kotlin.internal.interop.sync.ApiKeyWrapper
import io.realm.kotlin.internal.interop.sync.AuthProvider
import io.realm.kotlin.internal.interop.sync.CoreConnectionState
Expand Down Expand Up @@ -1099,7 +1098,7 @@ actual object RealmInterop {
syncClientConfig: RealmSyncClientConfigurationPointer,
basePath: String
): RealmAppPointer {
return LongPointerWrapper(realmc.realm_app_create(appConfig.cptr(), syncClientConfig.cptr()), managed = true)
return LongPointerWrapper(realmc.realm_app_create(appConfig.cptr()), managed = true)
}

actual fun realm_app_log_in_with_credentials(
Expand Down Expand Up @@ -1276,11 +1275,11 @@ actual object RealmInterop {
)
}

actual fun realm_sync_client_config_set_base_file_path(
syncClientConfig: RealmSyncClientConfigurationPointer,
actual fun realm_app_config_set_base_file_path(
appConfig: RealmAppConfigurationPointer,
basePath: String
) {
realmc.realm_sync_client_config_set_base_file_path(syncClientConfig.cptr(), basePath)
realmc.realm_app_config_set_base_file_path(appConfig.cptr(), basePath)
}

actual fun realm_sync_client_config_set_multiplex_sessions(syncClientConfig: RealmSyncClientConfigurationPointer, enabled: Boolean) {
Expand All @@ -1295,22 +1294,22 @@ actual object RealmInterop {
realmc.realm_set_log_level(level.priority)
}

actual fun realm_sync_client_config_set_metadata_mode(
syncClientConfig: RealmSyncClientConfigurationPointer,
actual fun realm_app_config_set_metadata_mode(
appConfig: RealmAppConfigurationPointer,
metadataMode: MetadataMode
) {
realmc.realm_sync_client_config_set_metadata_mode(
syncClientConfig.cptr(),
realmc.realm_app_config_set_metadata_mode(
appConfig.cptr(),
metadataMode.nativeValue
)
}

actual fun realm_sync_client_config_set_metadata_encryption_key(
syncClientConfig: RealmSyncClientConfigurationPointer,
actual fun realm_app_config_set_metadata_encryption_key(
appConfig: RealmAppConfigurationPointer,
encryptionKey: ByteArray
) {
realmc.realm_sync_client_config_set_metadata_encryption_key(
syncClientConfig.cptr(),
realmc.realm_app_config_set_metadata_encryption_key(
appConfig.cptr(),
encryptionKey
)
}
Expand Down
1 change: 1 addition & 0 deletions packages/cinterop/src/native/realm.def
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ actual enum class ErrorCode(
RLM_ERR_CUSTOM_ERROR("CustomError", realm_errno.RLM_ERR_CUSTOM_ERROR),
RLM_ERR_CLIENT_USER_NOT_FOUND("ClientUserNotFound", realm_errno.RLM_ERR_CLIENT_USER_NOT_FOUND),
RLM_ERR_CLIENT_USER_NOT_LOGGED_IN("ClientUserNotLoggedIn", realm_errno.RLM_ERR_CLIENT_USER_NOT_LOGGED_IN),
RLM_ERR_CLIENT_APP_DEALLOCATED("ClientAppDeallocated", realm_errno.RLM_ERR_CLIENT_APP_DEALLOCATED),
RLM_ERR_CLIENT_REDIRECT_ERROR("ClientRedirectError", realm_errno.RLM_ERR_CLIENT_REDIRECT_ERROR),
RLM_ERR_CLIENT_TOO_MANY_REDIRECTS("ClientTooManyRedirects", realm_errno.RLM_ERR_CLIENT_TOO_MANY_REDIRECTS),
RLM_ERR_CLIENT_USER_ALREADY_NAMED("ClientUserAlreadyNamed", realm_errno.RLM_ERR_CLIENT_USER_ALREADY_NAMED),
RLM_ERR_BAD_TOKEN("BadToken", realm_errno.RLM_ERR_BAD_TOKEN),
RLM_ERR_MALFORMED_JSON("MalformedJson", realm_errno.RLM_ERR_MALFORMED_JSON),
RLM_ERR_MISSING_JSON_KEY("MissingJsonKey", realm_errno.RLM_ERR_MISSING_JSON_KEY),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ 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_app_user_apikey_t
import realm_wrapper.realm_binary_t
import realm_wrapper.realm_class_info_t
import realm_wrapper.realm_class_key_tVar
Expand All @@ -123,7 +122,6 @@ 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_client_metadata_mode
import realm_wrapper.realm_sync_session_resync_mode
import realm_wrapper.realm_sync_session_state_e
import realm_wrapper.realm_sync_session_stop_policy_e
Expand All @@ -134,7 +132,6 @@ 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_identity
import realm_wrapper.realm_user_t
import realm_wrapper.realm_value_t
import realm_wrapper.realm_value_type
Expand Down Expand Up @@ -2001,7 +1998,7 @@ actual object RealmInterop {
syncClientConfig: RealmSyncClientConfigurationPointer,
basePath: String
): RealmAppPointer {
return CPointerWrapper(realm_wrapper.realm_app_create(appConfig.cptr(), syncClientConfig.cptr()), managed = true)
return CPointerWrapper(realm_wrapper.realm_app_create(appConfig.cptr()), managed = true)
}

actual fun realm_app_get_current_user(app: RealmAppPointer): RealmUserPointer? {
Expand Down Expand Up @@ -2068,7 +2065,7 @@ actual object RealmInterop {
app.cptr(),
user.cptr(),
name,
staticCFunction { userData: CPointer<out CPointed>?, apiKey: CPointer<realm_app_user_apikey_t>?, error: CPointer<realm_app_error_t>? ->
staticCFunction { userData: CPointer<out CPointed>?, apiKey: CPointer<realm_wrapper.realm_app_user_apikey>?, error: CPointer<realm_app_error_t>? ->
handleAppCallback(userData, error) {
apiKey!!.pointed.let {
ApiKeyWrapper(
Expand Down Expand Up @@ -2159,7 +2156,7 @@ actual object RealmInterop {
app.cptr(),
user.cptr(),
id.realm_object_id_t(),
staticCFunction { userData: CPointer<out CPointed>?, apiKey: CPointer<realm_app_user_apikey_t>?, error: CPointer<realm_app_error_t>? ->
staticCFunction { userData: CPointer<out CPointed>?, apiKey: CPointer<realm_wrapper.realm_app_user_apikey>?, error: CPointer<realm_app_error_t>? ->
handleAppCallback(userData, error) {
apiKey!!.pointed.let {
ApiKeyWrapper(
Expand Down Expand Up @@ -2188,7 +2185,7 @@ actual object RealmInterop {
realm_wrapper.realm_app_user_apikey_provider_client_fetch_apikeys(
app.cptr(),
user.cptr(),
staticCFunction { userData: CPointer<out CPointed>?, apiKeys: CPointer<realm_app_user_apikey_t>?, count: size_t, error: CPointer<realm_app_error_t>? ->
staticCFunction { userData: CPointer<out CPointed>?, apiKeys: CPointer<realm_wrapper.realm_app_user_apikey>?, count: size_t, error: CPointer<realm_app_error_t>? ->
handleAppCallback(userData, error) {
val result = arrayOfNulls<ApiKeyWrapper>(count.toInt())
for (i in 0 until count.toInt()) {
Expand Down Expand Up @@ -2312,8 +2309,8 @@ actual object RealmInterop {
actual fun realm_user_get_all_identities(user: RealmUserPointer): List<SyncUserIdentity> {
memScoped {
val count = AuthProvider.values().size
val properties = allocArray<realm_user_identity>(count)
val outCount = alloc<size_tVar>()
val properties = allocArray<realm_wrapper.realm_user_identity>(count)
val outCount: ULongVarOf<size_t> = alloc<size_tVar>()
realm_wrapper.realm_user_get_all_identities(
user.cptr(),
properties,
Expand Down Expand Up @@ -2407,11 +2404,11 @@ actual object RealmInterop {
)
}

actual fun realm_sync_client_config_set_base_file_path(
syncClientConfig: RealmSyncClientConfigurationPointer,
actual fun realm_app_config_set_base_file_path(
appConfig: RealmAppConfigurationPointer,
basePath: String
) {
realm_wrapper.realm_sync_client_config_set_base_file_path(syncClientConfig.cptr(), basePath)
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) {
Expand All @@ -2433,24 +2430,24 @@ actual object RealmInterop {
realm_wrapper.realm_set_log_level(level.priority.toUInt())
}

actual fun realm_sync_client_config_set_metadata_mode(
syncClientConfig: RealmSyncClientConfigurationPointer,
actual fun realm_app_config_set_metadata_mode(
appConfig: RealmAppConfigurationPointer,
metadataMode: MetadataMode
) {
realm_wrapper.realm_sync_client_config_set_metadata_mode(
syncClientConfig.cptr(),
realm_sync_client_metadata_mode.byValue(metadataMode.metadataValue.toUInt())
realm_wrapper.realm_app_config_set_metadata_mode(
appConfig.cptr(),
realm_wrapper.realm_sync_client_metadata_mode.byValue(metadataMode.metadataValue.toUInt())
)
}

actual fun realm_sync_client_config_set_metadata_encryption_key(
syncClientConfig: RealmSyncClientConfigurationPointer,
actual fun realm_app_config_set_metadata_encryption_key(
appConfig: RealmAppConfigurationPointer,
encryptionKey: ByteArray
) {
memScoped {
val encryptionKeyPointer = encryptionKey.refTo(0).getPointer(memScope)
realm_wrapper.realm_sync_client_config_set_metadata_encryption_key(
syncClientConfig.cptr(),
realm_wrapper.realm_app_config_set_metadata_encryption_key(
appConfig.cptr(),
encryptionKeyPointer as CPointer<uint8_tVar>
)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/external/core
Submodule core updated 305 files
4 changes: 4 additions & 0 deletions packages/jni-swig-stub/realm.i
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
%module(directors="1") realmc

#define REALM_APP_SERVICES 1

%{
#include "realm.h"
#include <cstring>
Expand Down Expand Up @@ -523,6 +525,8 @@ $result = SWIG_JavaArrayOutLonglong(jenv, (long long *)result, 2);
%ignore "realm_dictionary_add_notification_callback";
%ignore "realm_results_add_notification_callback";

%ignore "realm_app_config_get_sync_client_config";

// Swig doesn't understand __attribute__ so eliminate it
#define __attribute__(x)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public class AppConfigurationImpl @OptIn(ExperimentalKBsonSerializerApi::class)
bundleId: String,
networkTransport: NetworkTransport
): RealmAppConfigurationPointer {
return RealmInterop.realm_app_config_new(
val appConfigPtr = RealmInterop.realm_app_config_new(
appId = appId,
baseUrl = baseUrl,
networkTransport = RealmInterop.realm_network_transport_new(networkTransport),
Expand All @@ -146,6 +146,15 @@ public class AppConfigurationImpl @OptIn(ExperimentalKBsonSerializerApi::class)
frameworkVersion = RUNTIME_VERSION
)
)
RealmInterop.realm_app_config_set_base_file_path(appConfigPtr, syncRootDirectory)
RealmInterop.realm_app_config_set_metadata_mode(appConfigPtr, metadataMode)
encryptionKey?.let {
RealmInterop.realm_app_config_set_metadata_encryption_key(
appConfigPtr,
it
)
}
return appConfigPtr
}

private fun initializeSyncClientConfig(
Expand All @@ -157,21 +166,6 @@ public class AppConfigurationImpl @OptIn(ExperimentalKBsonSerializerApi::class)
.also { syncClientConfig ->
// Initialize client configuration first
RealmInterop.realm_sync_client_config_set_default_binding_thread_observer(syncClientConfig, appId)
RealmInterop.realm_sync_client_config_set_metadata_mode(
syncClientConfig,
metadataMode
)
RealmInterop.realm_sync_client_config_set_base_file_path(
syncClientConfig,
syncRootDirectory
)

encryptionKey?.let {
RealmInterop.realm_sync_client_config_set_metadata_encryption_key(
syncClientConfig,
it
)
}

sdkInfo?.let {
RealmInterop.realm_sync_client_config_set_user_agent_binding_info(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,8 @@ internal fun convertAppError(appError: AppError): Throwable {
ErrorCode.RLM_ERR_CLIENT_USER_NOT_FOUND -> {
IllegalStateException(msg)
}
ErrorCode.RLM_ERR_CLIENT_USER_NOT_LOGGED_IN -> {
InvalidCredentialsException(msg)
}
ErrorCode.RLM_ERR_CLIENT_APP_DEALLOCATED -> {
AppException(msg)
ErrorCode.RLM_ERR_CLIENT_USER_ALREADY_NAMED -> {
CredentialsCannotBeLinkedException(msg)
}
else -> {
AppException(msg)
Expand Down
2 changes: 1 addition & 1 deletion packages/test-base/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ kotlin {
}
targets.filterIsInstance<KotlinNativeTargetWithSimulatorTests>().forEach { simulatorTargets ->
simulatorTargets.testRuns.forEach { testRun ->
testRun.deviceId = project.findProperty("iosDevice")?.toString() ?: "iPhone 12"
testRun.deviceId = project.findProperty("iosDevice")?.toString() ?: "iPhone 14"
}
}
sourceSets {
Expand Down
2 changes: 1 addition & 1 deletion packages/test-sync/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ kotlin {
}
targets.filterIsInstance<KotlinNativeTargetWithSimulatorTests>().forEach { simulatorTargets ->
simulatorTargets.testRuns.forEach { testRun ->
testRun.deviceId = project.findProperty("iosDevice")?.toString() ?: "iPhone 12"
testRun.deviceId = project.findProperty("iosDevice")?.toString() ?: "iPhone 14"
}
}
sourceSets {
Expand Down
Loading

0 comments on commit 1b90390

Please sign in to comment.