mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-18 02:38:26 +00:00
feat: add config base free instead of user profile
This commit is contained in:
parent
bd2a4fcfd6
commit
1b2e734453
@ -1,4 +0,0 @@
|
||||
package org.thoughtcrime.securesms.dependencies;
|
||||
|
||||
public interface InjectableType {
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package org.thoughtcrime.securesms.dependencies
|
||||
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.android.components.ActivityRetainedComponent
|
||||
import dagger.hilt.android.scopes.ActivityRetainedScoped
|
||||
import network.loki.messenger.libsession_util.UserProfile
|
||||
import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.crypto.KeyPairUtilities
|
||||
|
||||
@Module
|
||||
@InstallIn(ActivityRetainedComponent::class)
|
||||
abstract class SessionUtilModule {
|
||||
|
||||
private fun maybeUserEdSecretKey(context: ApplicationContext): ByteArray? {
|
||||
val edKey = KeyPairUtilities.getUserED25519KeyPair(context) ?: return null
|
||||
return edKey.secretKey.asBytes
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ActivityRetainedScoped
|
||||
fun provideUser(context: ApplicationContext): UserProfile {
|
||||
val key = maybeUserEdSecretKey(context)
|
||||
return UserProfile.newInstance(key ?: byteArrayOf())
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -33,6 +33,12 @@ Java_network_loki_messenger_libsession_1util_ConfigBase_push(JNIEnv *env, jobjec
|
||||
return returnObject;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_ConfigBase_free(JNIEnv *env, jobject thiz) {
|
||||
auto config = ptrToConfigBase(env, thiz);
|
||||
delete config;
|
||||
}
|
||||
|
||||
JNIEXPORT jbyteArray JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_ConfigBase_dump(JNIEnv *env, jobject thiz) {
|
||||
auto config = ptrToConfigBase(env, thiz);
|
||||
|
@ -54,12 +54,6 @@ Java_network_loki_messenger_libsession_1util_UserProfile_getName(JNIEnv *env, jo
|
||||
return returnString;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_UserProfile_free(JNIEnv *env, jobject thiz) {
|
||||
auto profile = ptrToProfile(env, thiz);
|
||||
delete profile;
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_UserProfile_getPic(JNIEnv *env, jobject thiz) {
|
||||
auto profile = ptrToProfile(env, thiz);
|
||||
|
@ -23,6 +23,14 @@ sealed class ConfigBase(protected val /* yucky */ pointer: Long) {
|
||||
|
||||
// Singular merge
|
||||
external fun merge(toMerge: ByteArray): Int
|
||||
|
||||
external fun free()
|
||||
|
||||
@Override
|
||||
fun finalize() {
|
||||
free()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Contacts(pointer: Long) : ConfigBase(pointer) {
|
||||
@ -53,7 +61,6 @@ class UserProfile(pointer: Long) : ConfigBase(pointer) {
|
||||
|
||||
external fun setName(newName: String)
|
||||
external fun getName(): String?
|
||||
external fun free()
|
||||
external fun getPic(): UserPic?
|
||||
external fun setPic(userPic: UserPic)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user