Skip to content

Commit 1819ad2

Browse files
SessionHero01SessionHero01
authored andcommitted
Add session protocol binding
1 parent 2056cbc commit 1819ad2

File tree

15 files changed

+576
-5
lines changed

15 files changed

+576
-5
lines changed

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
2-
agp = "8.12.0"
3-
kotlin = "2.2.0"
2+
agp = "8.12.1"
3+
kotlin = "2.2.10"
44

55
[libraries]
66
junit = { module = "junit:junit", version = "4.13.2" }

library/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ android {
1212
compileSdk = 35
1313

1414
defaultConfig {
15-
minSdk = 24
15+
minSdk = 26
1616

1717
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1818

library/src/main/cpp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ set(SOURCES
4444
ed25519.cpp
4545
curve25519.cpp
4646
hash.cpp
47+
protocol.cpp
4748
)
4849

4950
add_library( # Sets the name of the library.

library/src/main/cpp/group_keys.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ Java_network_loki_messenger_libsession_1util_GroupKeysConfig_keys(JNIEnv *env, j
187187
return jni_utils::jlist_from_collection(env, ptr->group_keys(), util::bytes_from_span);
188188
}
189189

190+
extern "C"
191+
JNIEXPORT jobject JNICALL
192+
Java_network_loki_messenger_libsession_1util_GroupKeysConfig_groupEncKey(JNIEnv *env, jobject thiz) {
193+
auto ptr = ptrToKeys(env, thiz);
194+
return util::bytes_from_span(env, ptr->group_enc_key());
195+
}
196+
190197
extern "C"
191198
JNIEXPORT jobject JNICALL
192199
Java_network_loki_messenger_libsession_1util_GroupKeysConfig_activeHashes(JNIEnv *env,

library/src/main/cpp/jni_utils.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ namespace jni_utils {
6969
env_->DeleteLocalRef(ref_);
7070
}
7171
}
72+
JavaLocalRef(JavaLocalRef&& other) : env_(other.env_), ref_(other.ref_) {
73+
other.ref_ = nullptr;
74+
}
75+
76+
JavaLocalRef(const JavaLocalRef&) = delete;
7277

7378
inline JNIType get() const {
7479
return ref_;
@@ -162,6 +167,8 @@ namespace jni_utils {
162167
data = std::span<char>(const_cast<char *>(c_str), env->GetStringUTFLength(s));
163168
}
164169

170+
JavaStringRef(const JavaStringRef &) = delete;
171+
165172
~JavaStringRef() {
166173
env->ReleaseStringUTFChars(s, data.data());
167174
}
@@ -195,8 +202,18 @@ namespace jni_utils {
195202
data = std::span<unsigned char>(reinterpret_cast<unsigned char *>(env->GetByteArrayElements(byte_array, nullptr)), length);
196203
}
197204

205+
JavaByteArrayRef(const JavaByteArrayRef &) = delete;
206+
207+
JavaByteArrayRef(JavaByteArrayRef&& other) : env(other.env), byte_array(other.byte_array), data(other.data) {
208+
other.byte_array = nullptr;
209+
other.data = {};
210+
}
211+
198212
~JavaByteArrayRef() {
199-
env->ReleaseByteArrayElements(byte_array, reinterpret_cast<jbyte *>(data.data()), 0);
213+
if (byte_array) {
214+
env->ReleaseByteArrayElements(byte_array,
215+
reinterpret_cast<jbyte *>(data.data()), 0);
216+
}
200217
}
201218

202219
// Get the data as a span. Only valid during the lifetime of this object.

0 commit comments

Comments
 (0)