Skip to content

Commit a6e1419

Browse files
authored
Release 2.2.1
2 parents 11a4b59 + 8921fce commit a6e1419

File tree

9 files changed

+28
-40
lines changed

9 files changed

+28
-40
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
publishPrivmxEndpoint = "2.2.0"
2+
publishPrivmxEndpoint = "2.2.1"
33
kotlinxIoCore = "0.7.0"
44
kotlin-serialization = "2.1.20"
55
serialization-json = "1.8.1"

privmx-endpoint-extra/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ publishing {
5454
pom {
5555
name = "PrivMX Endpoint Kotlin Extra"
5656
description =
57-
"PrivMX Endpoint Kotlin Extra is an extension of Privmx Endpoint Kotlin. It's extended with additional logic that makes using our libraries simpler and less error-prone."
57+
"PrivMX Endpoint Kotlin Extra is an extension of PrivMX Endpoint Kotlin. It's extended with additional logic that makes using our libraries simpler and less error-prone."
5858
}
5959
}
6060
}

privmx-endpoint/src/iosMain/kotlin/com/simplito/kotlin/privmx_endpoint/modules/core/Connection.ios.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,13 @@ actual class Connection private constructor() : AutoCloseable {
166166
*/
167167
@Throws( PrivmxException::class, NativeException::class, IllegalStateException::class)
168168
actual fun disconnect() = memScoped {
169-
val args = pson_new_object()
169+
val args = makeArgs()
170170
val result = allocPointerTo<pson_value>().apply {
171171
value = pson_new_object()
172172
}
173173
try {
174174
privmx_endpoint_execConnection(nativeConnection.value, 4, args, result.ptr)
175+
result.value?.asResponse?.getResultOrThrow()
175176
Unit
176177
} finally {
177178
pson_free_value(args)
@@ -203,9 +204,15 @@ actual class Connection private constructor() : AutoCloseable {
203204
* disconnects from PrivMX Bridge and frees memory making this instance not reusable.
204205
*/
205206
actual override fun close() {
206-
if (_nativeConnection.value == null) return
207-
disconnect()
207+
//Throws if native connection are closed
208+
nativeConnection
209+
try {
210+
disconnect()
211+
} catch (e: PrivmxException) {
212+
//if PrivMX Endpoint doesn’t throw exception about disconnected state
213+
if (e.getCode() != 131073u) throw e
214+
}
208215
privmx_endpoint_freeConnection(nativeConnection.value)
209216
_nativeConnection.value = null
210217
}
211-
}
218+
}

privmx-endpoint/src/iosMain/kotlin/com/simplito/kotlin/privmx_endpoint/modules/crypto/CryptoApi.ios.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,7 @@ actual class CryptoApi : AutoCloseable {
323323
* @throws Exception when instance is currently closed.
324324
*/
325325
actual override fun close() {
326-
if (_nativeCryptoApi.value == null) return
327-
privmx_endpoint_freeCryptoApi(_nativeCryptoApi.value)
326+
privmx_endpoint_freeCryptoApi(nativeCryptoApi.value)
328327
_nativeCryptoApi.value = null
329328
}
330329
}

privmx-endpoint/src/iosMain/kotlin/com/simplito/kotlin/privmx_endpoint/modules/inbox/InboxApi.ios.kt

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -73,31 +73,17 @@ actual constructor(
7373

7474
init {
7575
val tmpThreadApi = if (threadApi == null) {
76-
memScoped {
77-
allocPointerTo<cnames.structs.ThreadApi>().apply {
78-
privmx_endpoint_newThreadApi(
79-
connection.getConnectionPtr(),
80-
ptr,
81-
)
82-
}
83-
}
76+
ThreadApi(connection)
8477
} else null
8578

8679
val tmpStoreApi = if (storeApi == null) {
87-
memScoped {
88-
allocPointerTo<cnames.structs.StoreApi>().apply {
89-
privmx_endpoint_newStoreApi(
90-
connection.getConnectionPtr(),
91-
ptr,
92-
)
93-
}
94-
}
80+
StoreApi(connection)
9581
} else null
9682

9783
privmx_endpoint_newInboxApi(
9884
connection.getConnectionPtr(),
99-
threadApi?.getThreadPtr(),
100-
storeApi?.getStorePtr(),
85+
(threadApi ?: tmpThreadApi)?.getThreadPtr(),
86+
(storeApi ?: tmpStoreApi)?.getStorePtr(),
10187
_nativeInboxApi.ptr
10288
)
10389

@@ -110,8 +96,8 @@ actual constructor(
11096
} finally {
11197
pson_free_value(args)
11298
pson_free_result(pson_result.value)
113-
tmpThreadApi?.let { privmx_endpoint_freeThreadApi(it.value) }
114-
tmpStoreApi?.let { privmx_endpoint_freeStoreApi(it.value) }
99+
tmpThreadApi?.close()
100+
tmpStoreApi?.close()
115101
}
116102
}
117103
}
@@ -198,7 +184,6 @@ actual constructor(
198184
) = memScoped {
199185
val pson_result = allocPointerTo<pson_value>()
200186
val args = makeArgs(
201-
inboxId.pson,
202187
inboxId.pson,
203188
users.map { it.pson }.pson,
204189
managers.map { it.pson }.pson,
@@ -750,8 +735,7 @@ actual constructor(
750735
* @throws Exception when instance is currently closed
751736
*/
752737
actual override fun close() {
753-
if (_nativeInboxApi.value == null) return
754-
privmx_endpoint_freeInboxApi(_nativeInboxApi.value)
738+
privmx_endpoint_freeInboxApi(nativeInboxApi.value)
755739
_nativeInboxApi.value = null
756740
}
757741
}

privmx-endpoint/src/iosMain/kotlin/com/simplito/kotlin/privmx_endpoint/modules/store/StoreApi.ios.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,7 @@ actual constructor(connection: Connection) :
743743
* @throws Exception when instance is currently closed
744744
*/
745745
actual override fun close() {
746-
if (_nativeStoreApi.value == null) return
747-
privmx_endpoint_freeStoreApi(_nativeStoreApi.value)
746+
privmx_endpoint_freeStoreApi(nativeStoreApi.value)
748747
_nativeStoreApi.value = null
749748
}
750749
}

privmx-endpoint/src/iosMain/kotlin/com/simplito/kotlin/privmx_endpoint/modules/thread/ThreadApi.ios.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,7 @@ actual constructor(connection: Connection) : AutoCloseable {
506506
* @throws Exception when instance is currently closed
507507
*/
508508
actual override fun close() {
509-
if (_nativeThreadApi.value == null) return
510-
privmx_endpoint_freeThreadApi(_nativeThreadApi.value)
509+
privmx_endpoint_freeThreadApi(nativeThreadApi.value)
511510
_nativeThreadApi.value = null
512511
}
513512
}

privmx-endpoint/src/iosMain/kotlin/com/simplito/kotlin/privmx_endpoint/utils/ParsersFromPson.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ internal fun PsonObject.toContainerPolicy(): ContainerPolicy =
116116
ContainerPolicy(
117117
this["get"]?.typedValue(),
118118
this["update"]?.typedValue(),
119-
this["delete"]?.typedValue(),
119+
this["delete_"]?.typedValue(),
120120
this["updatePolicy"]?.typedValue(),
121121
this["updaterCanBeRemovedFromManagers"]?.typedValue(),
122122
this["ownerCanBeRemovedFromManagers"]?.typedValue(),
@@ -137,7 +137,7 @@ internal fun PsonObject.toItemPolicy(): ItemPolicy = ItemPolicy(
137137
this["listAll"]?.typedValue(),
138138
this["create"]?.typedValue(),
139139
this["update"]?.typedValue(),
140-
this["delete"]?.typedValue()
140+
this["delete_"]?.typedValue()
141141
)
142142

143143
internal fun PsonObject.toMessage() = Message(

privmx-endpoint/src/iosMain/kotlin/com/simplito/kotlin/privmx_endpoint/utils/ParsersToPson.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal val ItemPolicy.pson: PsonValue.PsonObject
2424
"listAll" to listAll.nullablePson,
2525
"create" to create.nullablePson,
2626
"update" to update.nullablePson,
27-
"delete" to delete.nullablePson,
27+
"delete_" to delete.nullablePson,
2828
).pson
2929

3030

@@ -38,7 +38,7 @@ internal val ContainerPolicy.pson: PsonValue.PsonObject
3838
get() = mapOfWithNulls(
3939
"get" to get.nullablePson,
4040
"update" to update.nullablePson,
41-
"delete" to delete.nullablePson,
41+
"delete_" to delete.nullablePson,
4242
"updatePolicy" to updatePolicy.nullablePson,
4343
"updaterCanBeRemovedFromManagers" to updaterCanBeRemovedFromManagers.nullablePson,
4444
"ownerCanBeRemovedFromManagers" to ownerCanBeRemovedFromManagers.nullablePson,
@@ -49,7 +49,7 @@ internal val ContainerPolicyWithoutItem.pson: PsonValue.PsonObject
4949
get() = mapOfWithNulls(
5050
"get" to get.nullablePson,
5151
"update" to update.nullablePson,
52-
"delete" to delete.nullablePson,
52+
"delete_" to delete.nullablePson,
5353
"updatePolicy" to updatePolicy.nullablePson,
5454
"updaterCanBeRemovedFromManagers" to updaterCanBeRemovedFromManagers.nullablePson,
5555
"ownerCanBeRemovedFromManagers" to ownerCanBeRemovedFromManagers.nullablePson,

0 commit comments

Comments
 (0)