mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 02:55:23 +00:00
feat: update shared library to use priority only, fix compile errors, fix group member sync problem
This commit is contained in:
parent
5acaffda56
commit
6193fe4668
@ -117,10 +117,12 @@ class Storage(context: Context, helper: SQLCipherOpenHelper, private val configF
|
|||||||
// don't update our own address into the contacts DB
|
// don't update our own address into the contacts DB
|
||||||
if (getUserPublicKey() != address.serialize()) {
|
if (getUserPublicKey() != address.serialize()) {
|
||||||
val contacts = configFactory.contacts ?: return
|
val contacts = configFactory.contacts ?: return
|
||||||
contacts.upsertContact(address.serialize())
|
contacts.upsertContact(address.serialize()) {
|
||||||
|
priority = ConfigBase.PRIORITY_VISIBLE
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
val userProfile = configFactory.user ?: return
|
val userProfile = configFactory.user ?: return
|
||||||
userProfile.setNtsHidden(false)
|
userProfile.setNtsPriority(ConfigBase.PRIORITY_VISIBLE)
|
||||||
}
|
}
|
||||||
val newVolatileParams = volatile.getOrConstructOneToOne(address.serialize()).copy(
|
val newVolatileParams = volatile.getOrConstructOneToOne(address.serialize()).copy(
|
||||||
lastRead = SnodeAPI.nowWithOffset
|
lastRead = SnodeAPI.nowWithOffset
|
||||||
@ -146,11 +148,11 @@ class Storage(context: Context, helper: SQLCipherOpenHelper, private val configF
|
|||||||
if (getUserPublicKey() != address.serialize()) {
|
if (getUserPublicKey() != address.serialize()) {
|
||||||
val contacts = configFactory.contacts ?: return
|
val contacts = configFactory.contacts ?: return
|
||||||
contacts.upsertContact(address.serialize()) {
|
contacts.upsertContact(address.serialize()) {
|
||||||
// hidden = true TODO: maybe this?
|
priority = ConfigBase.PRIORITY_HIDDEN
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val userProfile = configFactory.user ?: return
|
val userProfile = configFactory.user ?: return
|
||||||
userProfile.setNtsHidden(true)
|
userProfile.setNtsPriority(ConfigBase.PRIORITY_HIDDEN)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(context)
|
ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(context)
|
||||||
@ -414,7 +416,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper, private val configF
|
|||||||
profileManager.setProfileKey(context, recipient, userPic.key)
|
profileManager.setProfileKey(context, recipient, userPic.key)
|
||||||
setUserProfilePictureURL(userPic.url)
|
setUserProfilePictureURL(userPic.url)
|
||||||
}
|
}
|
||||||
if (userProfile.getNtsHidden()) {
|
if (userProfile.getNtsPriority() == ConfigBase.PRIORITY_HIDDEN) {
|
||||||
// delete nts thread if needed
|
// delete nts thread if needed
|
||||||
val ourThread = getThreadId(recipient) ?: return
|
val ourThread = getThreadId(recipient) ?: return
|
||||||
deleteConversation(ourThread)
|
deleteConversation(ourThread)
|
||||||
@ -524,8 +526,8 @@ class Storage(context: Context, helper: SQLCipherOpenHelper, private val configF
|
|||||||
val existingThread = existingGroup?.let { getThreadId(existingGroup.encodedId) }
|
val existingThread = existingGroup?.let { getThreadId(existingGroup.encodedId) }
|
||||||
if (existingGroup != null) {
|
if (existingGroup != null) {
|
||||||
Log.d("Loki-DBG", "Existing closed group, don't add")
|
Log.d("Loki-DBG", "Existing closed group, don't add")
|
||||||
if (group.hidden && existingThread != null) {
|
if (group.priority == ConfigBase.PRIORITY_HIDDEN && existingThread != null) {
|
||||||
threadDb.setThreadArchived(existingThread)
|
threadDb.deleteConversation(existingThread)
|
||||||
} else if (existingThread == null) {
|
} else if (existingThread == null) {
|
||||||
Log.w("Loki-DBG", "Existing group had no thread to hide")
|
Log.w("Loki-DBG", "Existing group had no thread to hide")
|
||||||
}
|
}
|
||||||
@ -766,7 +768,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper, private val configF
|
|||||||
sessionId = groupPublicKey,
|
sessionId = groupPublicKey,
|
||||||
name = name,
|
name = name,
|
||||||
members = members,
|
members = members,
|
||||||
hidden = false,
|
priority = ConfigBase.PRIORITY_VISIBLE,
|
||||||
encPubKey = encryptionKeyPair.publicKey.serialize(),
|
encPubKey = encryptionKeyPair.publicKey.serialize(),
|
||||||
encSecKey = encryptionKeyPair.privateKey.serialize(),
|
encSecKey = encryptionKeyPair.privateKey.serialize(),
|
||||||
disappearingTimer = 0L
|
disappearingTimer = 0L
|
||||||
@ -801,7 +803,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper, private val configF
|
|||||||
members = membersMap,
|
members = membersMap,
|
||||||
encPubKey = latestKeyPair.publicKey.serialize(),
|
encPubKey = latestKeyPair.publicKey.serialize(),
|
||||||
encSecKey = latestKeyPair.privateKey.serialize(),
|
encSecKey = latestKeyPair.privateKey.serialize(),
|
||||||
priority = if (isPinned(threadID)) 1 else 0,
|
priority = if (isPinned(threadID)) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE,
|
||||||
disappearingTimer = recipientSettings.expireMessages.toLong()
|
disappearingTimer = recipientSettings.expireMessages.toLong()
|
||||||
)
|
)
|
||||||
userGroups.set(groupInfo)
|
userGroups.set(groupInfo)
|
||||||
@ -1070,7 +1072,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper, private val configF
|
|||||||
profileManager.setUnidentifiedAccessMode(context, recipient, Recipient.UnidentifiedAccessMode.UNKNOWN)
|
profileManager.setUnidentifiedAccessMode(context, recipient, Recipient.UnidentifiedAccessMode.UNKNOWN)
|
||||||
profileManager.setProfilePictureURL(context, recipient, url)
|
profileManager.setProfilePictureURL(context, recipient, url)
|
||||||
}
|
}
|
||||||
if (contact.hidden) {
|
if (contact.priority == ConfigBase.PRIORITY_HIDDEN) {
|
||||||
getThreadId(fromSerialized(contact.id))?.let { conversationThreadId ->
|
getThreadId(fromSerialized(contact.id))?.let { conversationThreadId ->
|
||||||
deleteConversation(conversationThreadId)
|
deleteConversation(conversationThreadId)
|
||||||
}
|
}
|
||||||
@ -1146,25 +1148,25 @@ class Storage(context: Context, helper: SQLCipherOpenHelper, private val configF
|
|||||||
val threadRecipient = getRecipientForThread(threadID) ?: return
|
val threadRecipient = getRecipientForThread(threadID) ?: return
|
||||||
if (threadRecipient.isLocalNumber) {
|
if (threadRecipient.isLocalNumber) {
|
||||||
val user = configFactory.user ?: return
|
val user = configFactory.user ?: return
|
||||||
user.setNtsPriority(if (isPinned) 1 else 0)
|
user.setNtsPriority(if (isPinned) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE)
|
||||||
} else if (threadRecipient.isContactRecipient) {
|
} else if (threadRecipient.isContactRecipient) {
|
||||||
val contacts = configFactory.contacts ?: return
|
val contacts = configFactory.contacts ?: return
|
||||||
contacts.upsertContact(threadRecipient.address.serialize()) {
|
contacts.upsertContact(threadRecipient.address.serialize()) {
|
||||||
priority = if (isPinned) 1 else 0
|
priority = if (isPinned) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE
|
||||||
}
|
}
|
||||||
} else if (threadRecipient.isGroupRecipient) {
|
} else if (threadRecipient.isGroupRecipient) {
|
||||||
val groups = configFactory.userGroups ?: return
|
val groups = configFactory.userGroups ?: return
|
||||||
if (threadRecipient.isClosedGroupRecipient) {
|
if (threadRecipient.isClosedGroupRecipient) {
|
||||||
val sessionId = GroupUtil.doubleDecodeGroupId(threadRecipient.address.serialize())
|
val sessionId = GroupUtil.doubleDecodeGroupId(threadRecipient.address.serialize())
|
||||||
val newGroupInfo = groups.getOrConstructLegacyGroupInfo(sessionId).copy (
|
val newGroupInfo = groups.getOrConstructLegacyGroupInfo(sessionId).copy (
|
||||||
priority = if (isPinned) 1 else 0
|
priority = if (isPinned) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE
|
||||||
)
|
)
|
||||||
groups.set(newGroupInfo)
|
groups.set(newGroupInfo)
|
||||||
} else if (threadRecipient.isOpenGroupRecipient) {
|
} else if (threadRecipient.isOpenGroupRecipient) {
|
||||||
val openGroup = getOpenGroup(threadID) ?: return
|
val openGroup = getOpenGroup(threadID) ?: return
|
||||||
val (baseUrl, room, pubKeyHex) = BaseCommunityInfo.parseFullUrl(openGroup.joinURL) ?: return
|
val (baseUrl, room, pubKeyHex) = BaseCommunityInfo.parseFullUrl(openGroup.joinURL) ?: return
|
||||||
val newGroupInfo = groups.getOrConstructCommunityInfo(baseUrl, room, Hex.toStringCondensed(pubKeyHex)).copy (
|
val newGroupInfo = groups.getOrConstructCommunityInfo(baseUrl, room, Hex.toStringCondensed(pubKeyHex)).copy (
|
||||||
priority = if (isPinned) 1 else 0
|
priority = if (isPinned) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE
|
||||||
)
|
)
|
||||||
groups.set(newGroupInfo)
|
groups.set(newGroupInfo)
|
||||||
}
|
}
|
||||||
@ -1187,7 +1189,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper, private val configF
|
|||||||
// TODO: handle contact
|
// TODO: handle contact
|
||||||
val contacts = configFactory.contacts ?: return
|
val contacts = configFactory.contacts ?: return
|
||||||
contacts.upsertContact(recipient.address.serialize()) {
|
contacts.upsertContact(recipient.address.serialize()) {
|
||||||
this.hidden = true
|
this.priority = ConfigBase.PRIORITY_HIDDEN
|
||||||
}
|
}
|
||||||
ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(context)
|
ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(context)
|
||||||
} else if (recipient.isClosedGroupRecipient) {
|
} else if (recipient.isClosedGroupRecipient) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.thoughtcrime.securesms.groups
|
package org.thoughtcrime.securesms.groups
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import network.loki.messenger.libsession_util.util.GroupInfo
|
import network.loki.messenger.libsession_util.ConfigBase
|
||||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.messaging.sending_receiving.notifications.PushNotificationAPI
|
import org.session.libsession.messaging.sending_receiving.notifications.PushNotificationAPI
|
||||||
import org.session.libsession.messaging.sending_receiving.pollers.ClosedGroupPollerV2
|
import org.session.libsession.messaging.sending_receiving.pollers.ClosedGroupPollerV2
|
||||||
@ -9,7 +9,6 @@ import org.session.libsession.utilities.Address
|
|||||||
import org.session.libsession.utilities.GroupRecord
|
import org.session.libsession.utilities.GroupRecord
|
||||||
import org.session.libsession.utilities.GroupUtil
|
import org.session.libsession.utilities.GroupUtil
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsignal.utilities.toHexString
|
|
||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
import org.thoughtcrime.securesms.dependencies.ConfigFactory
|
import org.thoughtcrime.securesms.dependencies.ConfigFactory
|
||||||
|
|
||||||
@ -54,7 +53,7 @@ object ClosedGroupManager {
|
|||||||
members = latestMemberMap,
|
members = latestMemberMap,
|
||||||
name = group.title,
|
name = group.title,
|
||||||
disappearingTimer = groupRecipientSettings.expireMessages.toLong(),
|
disappearingTimer = groupRecipientSettings.expireMessages.toLong(),
|
||||||
priority = if (storage.isPinned(threadId)) 1 else 0,
|
priority = if (storage.isPinned(threadId)) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE,
|
||||||
encSecKey = latestKeyPair.privateKey.serialize(),
|
encSecKey = latestKeyPair.privateKey.serialize(),
|
||||||
encPubKey = latestKeyPair.publicKey.serialize()
|
encPubKey = latestKeyPair.publicKey.serialize()
|
||||||
)
|
)
|
||||||
|
@ -27,7 +27,7 @@ import org.session.libsignal.utilities.Hex
|
|||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
import org.session.libsignal.utilities.toHexString
|
import org.session.libsignal.utilities.toHexString
|
||||||
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
||||||
import java.util.*
|
import java.util.Timer
|
||||||
|
|
||||||
object ConfigurationMessageUtilities {
|
object ConfigurationMessageUtilities {
|
||||||
|
|
||||||
@ -123,7 +123,11 @@ object ConfigurationMessageUtilities {
|
|||||||
profile.setPic(UserPic(picUrl, picKey))
|
profile.setPic(UserPic(picUrl, picKey))
|
||||||
}
|
}
|
||||||
val ownThreadId = storage.getThreadId(Address.fromSerialized(ownPublicKey))
|
val ownThreadId = storage.getThreadId(Address.fromSerialized(ownPublicKey))
|
||||||
profile.setNtsHidden(ownThreadId != null)
|
profile.setNtsPriority(
|
||||||
|
if (ownThreadId != null)
|
||||||
|
if (storage.isPinned(ownThreadId)) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE
|
||||||
|
else ConfigBase.PRIORITY_HIDDEN
|
||||||
|
)
|
||||||
if (ownThreadId != null) {
|
if (ownThreadId != null) {
|
||||||
// have NTS thread
|
// have NTS thread
|
||||||
val ntsPinned = storage.isPinned(ownThreadId)
|
val ntsPinned = storage.isPinned(ownThreadId)
|
||||||
@ -248,8 +252,7 @@ object ConfigurationMessageUtilities {
|
|||||||
sessionId = sessionId,
|
sessionId = sessionId,
|
||||||
name = group.title,
|
name = group.title,
|
||||||
members = admins + members,
|
members = admins + members,
|
||||||
hidden = threadId == null,
|
priority = if (isPinned) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE,
|
||||||
priority = if (isPinned) 1 else 0,
|
|
||||||
encPubKey = encryptionKeyPair.publicKey.serialize(),
|
encPubKey = encryptionKeyPair.publicKey.serialize(),
|
||||||
encSecKey = encryptionKeyPair.privateKey.serialize(),
|
encSecKey = encryptionKeyPair.privateKey.serialize(),
|
||||||
disappearingTimer = recipient.expireMessages.toLong()
|
disappearingTimer = recipient.expireMessages.toLong()
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 5241878bb20a9232b011f709adb87d1e6e7496b4
|
Subproject commit 3817b543f5f862b58afd50c285fbccc26bc82ee0
|
@ -13,18 +13,17 @@ inline session::config::Contacts *ptrToContacts(JNIEnv *env, jobject obj) {
|
|||||||
|
|
||||||
inline jobject serialize_contact(JNIEnv *env, session::config::contact_info info) {
|
inline jobject serialize_contact(JNIEnv *env, session::config::contact_info info) {
|
||||||
jclass contactClass = env->FindClass("network/loki/messenger/libsession_util/util/Contact");
|
jclass contactClass = env->FindClass("network/loki/messenger/libsession_util/util/Contact");
|
||||||
jmethodID constructor = env->GetMethodID(contactClass, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZZZLnetwork/loki/messenger/libsession_util/util/UserPic;ILnetwork/loki/messenger/libsession_util/util/ExpiryMode;)V");
|
jmethodID constructor = env->GetMethodID(contactClass, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZZLnetwork/loki/messenger/libsession_util/util/UserPic;ILnetwork/loki/messenger/libsession_util/util/ExpiryMode;)V");
|
||||||
jstring id = env->NewStringUTF(info.session_id.data());
|
jstring id = env->NewStringUTF(info.session_id.data());
|
||||||
jstring name = env->NewStringUTF(info.name.data());
|
jstring name = env->NewStringUTF(info.name.data());
|
||||||
jstring nickname = env->NewStringUTF(info.nickname.data());
|
jstring nickname = env->NewStringUTF(info.nickname.data());
|
||||||
jboolean approved, approvedMe, blocked, hidden;
|
jboolean approved, approvedMe, blocked;
|
||||||
approved = info.approved;
|
approved = info.approved;
|
||||||
approvedMe = info.approved_me;
|
approvedMe = info.approved_me;
|
||||||
blocked = info.blocked;
|
blocked = info.blocked;
|
||||||
hidden = info.hidden;
|
|
||||||
jobject profilePic = util::serialize_user_pic(env, info.profile_picture);
|
jobject profilePic = util::serialize_user_pic(env, info.profile_picture);
|
||||||
jobject returnObj = env->NewObject(contactClass, constructor, id, name, nickname, approved,
|
jobject returnObj = env->NewObject(contactClass, constructor, id, name, nickname, approved,
|
||||||
approvedMe, blocked, hidden, profilePic, info.priority,
|
approvedMe, blocked, profilePic, info.priority,
|
||||||
util::serialize_expiry(env, info.exp_mode, info.exp_timer));
|
util::serialize_expiry(env, info.exp_mode, info.exp_timer));
|
||||||
return returnObj;
|
return returnObj;
|
||||||
}
|
}
|
||||||
@ -40,7 +39,6 @@ deserialize_contact(JNIEnv *env, jobject info, session::config::Contacts *conf)
|
|||||||
getApproved = env->GetFieldID(contactClass, "approved", "Z");
|
getApproved = env->GetFieldID(contactClass, "approved", "Z");
|
||||||
getApprovedMe = env->GetFieldID(contactClass, "approvedMe", "Z");
|
getApprovedMe = env->GetFieldID(contactClass, "approvedMe", "Z");
|
||||||
getBlocked = env->GetFieldID(contactClass, "blocked", "Z");
|
getBlocked = env->GetFieldID(contactClass, "blocked", "Z");
|
||||||
getHidden = env->GetFieldID(contactClass, "hidden", "Z");
|
|
||||||
getUserPic = env->GetFieldID(contactClass, "profilePicture",
|
getUserPic = env->GetFieldID(contactClass, "profilePicture",
|
||||||
"Lnetwork/loki/messenger/libsession_util/util/UserPic;");
|
"Lnetwork/loki/messenger/libsession_util/util/UserPic;");
|
||||||
getPriority = env->GetFieldID(contactClass, "priority", "I");
|
getPriority = env->GetFieldID(contactClass, "priority", "I");
|
||||||
@ -54,7 +52,6 @@ deserialize_contact(JNIEnv *env, jobject info, session::config::Contacts *conf)
|
|||||||
approved = env->GetBooleanField(info, getApproved);
|
approved = env->GetBooleanField(info, getApproved);
|
||||||
approvedMe = env->GetBooleanField(info, getApprovedMe);
|
approvedMe = env->GetBooleanField(info, getApprovedMe);
|
||||||
blocked = env->GetBooleanField(info, getBlocked);
|
blocked = env->GetBooleanField(info, getBlocked);
|
||||||
hidden = env->GetBooleanField(info, getHidden);
|
|
||||||
jobject user_pic = env->GetObjectField(info, getUserPic);
|
jobject user_pic = env->GetObjectField(info, getUserPic);
|
||||||
jobject expiry_mode = env->GetObjectField(info, getExpiry);
|
jobject expiry_mode = env->GetObjectField(info, getExpiry);
|
||||||
|
|
||||||
@ -86,7 +83,6 @@ deserialize_contact(JNIEnv *env, jobject info, session::config::Contacts *conf)
|
|||||||
contact_info.approved = approved;
|
contact_info.approved = approved;
|
||||||
contact_info.approved_me = approvedMe;
|
contact_info.approved_me = approvedMe;
|
||||||
contact_info.blocked = blocked;
|
contact_info.blocked = blocked;
|
||||||
contact_info.hidden = hidden;
|
|
||||||
if (!url.empty() && !key.empty()) {
|
if (!url.empty() && !key.empty()) {
|
||||||
contact_info.profile_picture = session::config::profile_pic(url, key);
|
contact_info.profile_picture = session::config::profile_pic(url, key);
|
||||||
} else {
|
} else {
|
||||||
|
@ -47,7 +47,6 @@ inline session::config::legacy_group_info deserialize_legacy_group_info(JNIEnv *
|
|||||||
auto id_field = env->GetFieldID(clazz, "sessionId", "Ljava/lang/String;");
|
auto id_field = env->GetFieldID(clazz, "sessionId", "Ljava/lang/String;");
|
||||||
auto name_field = env->GetFieldID(clazz, "name", "Ljava/lang/String;");
|
auto name_field = env->GetFieldID(clazz, "name", "Ljava/lang/String;");
|
||||||
auto members_field = env->GetFieldID(clazz, "members", "Ljava/util/Map;");
|
auto members_field = env->GetFieldID(clazz, "members", "Ljava/util/Map;");
|
||||||
auto hidden_field = env->GetFieldID(clazz, "hidden", "Z");
|
|
||||||
auto enc_pub_key_field = env->GetFieldID(clazz, "encPubKey", "[B");
|
auto enc_pub_key_field = env->GetFieldID(clazz, "encPubKey", "[B");
|
||||||
auto enc_sec_key_field = env->GetFieldID(clazz, "encSecKey", "[B");
|
auto enc_sec_key_field = env->GetFieldID(clazz, "encSecKey", "[B");
|
||||||
auto priority_field = env->GetFieldID(clazz, "priority", "I");
|
auto priority_field = env->GetFieldID(clazz, "priority", "I");
|
||||||
@ -55,7 +54,6 @@ inline session::config::legacy_group_info deserialize_legacy_group_info(JNIEnv *
|
|||||||
jstring id = static_cast<jstring>(env->GetObjectField(info, id_field));
|
jstring id = static_cast<jstring>(env->GetObjectField(info, id_field));
|
||||||
jstring name = static_cast<jstring>(env->GetObjectField(info, name_field));
|
jstring name = static_cast<jstring>(env->GetObjectField(info, name_field));
|
||||||
jobject members_map = env->GetObjectField(info, members_field);
|
jobject members_map = env->GetObjectField(info, members_field);
|
||||||
bool hidden = env->GetBooleanField(info, hidden_field);
|
|
||||||
jbyteArray enc_pub_key = static_cast<jbyteArray>(env->GetObjectField(info, enc_pub_key_field));
|
jbyteArray enc_pub_key = static_cast<jbyteArray>(env->GetObjectField(info, enc_pub_key_field));
|
||||||
jbyteArray enc_sec_key = static_cast<jbyteArray>(env->GetObjectField(info, enc_sec_key_field));
|
jbyteArray enc_sec_key = static_cast<jbyteArray>(env->GetObjectField(info, enc_sec_key_field));
|
||||||
int priority = env->GetIntField(info, priority_field);
|
int priority = env->GetIntField(info, priority_field);
|
||||||
@ -67,10 +65,12 @@ inline session::config::legacy_group_info deserialize_legacy_group_info(JNIEnv *
|
|||||||
|
|
||||||
auto info_deserialized = conf->get_or_construct_legacy_group(id_bytes);
|
auto info_deserialized = conf->get_or_construct_legacy_group(id_bytes);
|
||||||
|
|
||||||
info_deserialized.priority = priority;
|
auto current_members = info_deserialized.members();
|
||||||
|
for (auto member = current_members.begin(); member != current_members.end(); ++member) {
|
||||||
|
info_deserialized.erase(member->first);
|
||||||
|
}
|
||||||
deserialize_members_into(env, members_map, info_deserialized);
|
deserialize_members_into(env, members_map, info_deserialized);
|
||||||
info_deserialized.name = name_bytes;
|
info_deserialized.name = name_bytes;
|
||||||
info_deserialized.hidden = hidden;
|
|
||||||
info_deserialized.enc_pubkey = enc_pub_key_bytes;
|
info_deserialized.enc_pubkey = enc_pub_key_bytes;
|
||||||
info_deserialized.enc_seckey = enc_sec_key_bytes;
|
info_deserialized.enc_seckey = enc_sec_key_bytes;
|
||||||
info_deserialized.disappearing_timer = std::chrono::seconds(env->GetLongField(info, disappearing_timer_field));
|
info_deserialized.disappearing_timer = std::chrono::seconds(env->GetLongField(info, disappearing_timer_field));
|
||||||
@ -116,11 +116,10 @@ inline jobject serialize_legacy_group_info(JNIEnv *env, session::config::legacy_
|
|||||||
jbyteArray enc_pubkey = util::bytes_from_ustring(env, info.enc_pubkey);
|
jbyteArray enc_pubkey = util::bytes_from_ustring(env, info.enc_pubkey);
|
||||||
jbyteArray enc_seckey = util::bytes_from_ustring(env, info.enc_seckey);
|
jbyteArray enc_seckey = util::bytes_from_ustring(env, info.enc_seckey);
|
||||||
int priority = info.priority;
|
int priority = info.priority;
|
||||||
bool hidden = info.hidden;
|
|
||||||
|
|
||||||
jclass legacy_group_class = env->FindClass("network/loki/messenger/libsession_util/util/GroupInfo$LegacyGroupInfo");
|
jclass legacy_group_class = env->FindClass("network/loki/messenger/libsession_util/util/GroupInfo$LegacyGroupInfo");
|
||||||
jmethodID constructor = env->GetMethodID(legacy_group_class, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Z[B[BIJ)V");
|
jmethodID constructor = env->GetMethodID(legacy_group_class, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;[B[BIJ)V");
|
||||||
jobject serialized = env->NewObject(legacy_group_class, constructor, session_id, name, members, hidden, enc_pubkey, enc_seckey, priority, (jlong) info.disappearing_timer.count());
|
jobject serialized = env->NewObject(legacy_group_class, constructor, session_id, name, members, enc_pubkey, enc_seckey, priority, (jlong) info.disappearing_timer.count());
|
||||||
return serialized;
|
return serialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,21 +84,8 @@ Java_network_loki_messenger_libsession_1util_UserProfile_setNtsPriority(JNIEnv *
|
|||||||
profile->set_nts_priority(priority);
|
profile->set_nts_priority(priority);
|
||||||
}
|
}
|
||||||
extern "C"
|
extern "C"
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_network_loki_messenger_libsession_1util_UserProfile_setNtsHidden(JNIEnv *env, jobject thiz,
|
|
||||||
jboolean is_hidden) {
|
|
||||||
auto profile = ptrToProfile(env, thiz);
|
|
||||||
profile->set_nts_hidden(is_hidden);
|
|
||||||
}
|
|
||||||
extern "C"
|
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Java_network_loki_messenger_libsession_1util_UserProfile_getNtsPriority(JNIEnv *env, jobject thiz) {
|
Java_network_loki_messenger_libsession_1util_UserProfile_getNtsPriority(JNIEnv *env, jobject thiz) {
|
||||||
auto profile = ptrToProfile(env, thiz);
|
auto profile = ptrToProfile(env, thiz);
|
||||||
return profile->get_nts_priority();
|
return profile->get_nts_priority();
|
||||||
}
|
}
|
||||||
extern "C"
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_network_loki_messenger_libsession_1util_UserProfile_getNtsHidden(JNIEnv *env, jobject thiz) {
|
|
||||||
auto profile = ptrToProfile(env, thiz);
|
|
||||||
return profile->get_nts_hidden();
|
|
||||||
}
|
|
@ -25,6 +25,10 @@ sealed class ConfigBase(protected val /* yucky */ pointer: Long) {
|
|||||||
|
|
||||||
const val isNewConfigEnabled = true
|
const val isNewConfigEnabled = true
|
||||||
|
|
||||||
|
const val PRIORITY_HIDDEN = -1
|
||||||
|
const val PRIORITY_VISIBLE = 0
|
||||||
|
const val PRIORITY_PINNED = 1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
external fun dirty(): Boolean
|
external fun dirty(): Boolean
|
||||||
@ -96,8 +100,6 @@ class UserProfile(pointer: Long) : ConfigBase(pointer) {
|
|||||||
external fun setPic(userPic: UserPic)
|
external fun setPic(userPic: UserPic)
|
||||||
external fun setNtsPriority(priority: Int)
|
external fun setNtsPriority(priority: Int)
|
||||||
external fun getNtsPriority(): Int
|
external fun getNtsPriority(): Int
|
||||||
external fun setNtsHidden(isHidden: Boolean)
|
|
||||||
external fun getNtsHidden(): Boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConversationVolatileConfig(pointer: Long): ConfigBase(pointer) {
|
class ConversationVolatileConfig(pointer: Long): ConfigBase(pointer) {
|
||||||
|
@ -7,7 +7,6 @@ data class Contact(
|
|||||||
var approved: Boolean = false,
|
var approved: Boolean = false,
|
||||||
var approvedMe: Boolean = false,
|
var approvedMe: Boolean = false,
|
||||||
var blocked: Boolean = false,
|
var blocked: Boolean = false,
|
||||||
var hidden: Boolean = false,
|
|
||||||
var profilePicture: UserPic = UserPic.DEFAULT,
|
var profilePicture: UserPic = UserPic.DEFAULT,
|
||||||
var priority: Int = 0,
|
var priority: Int = 0,
|
||||||
var expiryMode: ExpiryMode
|
var expiryMode: ExpiryMode
|
||||||
|
@ -8,10 +8,9 @@ sealed class GroupInfo {
|
|||||||
val sessionId: String,
|
val sessionId: String,
|
||||||
val name: String,
|
val name: String,
|
||||||
val members: Map<String, Boolean>,
|
val members: Map<String, Boolean>,
|
||||||
val hidden: Boolean,
|
|
||||||
val encPubKey: ByteArray,
|
val encPubKey: ByteArray,
|
||||||
val encSecKey: ByteArray,
|
val encSecKey: ByteArray,
|
||||||
val priority: Int = 0,
|
val priority: Int,
|
||||||
val disappearingTimer: Long
|
val disappearingTimer: Long
|
||||||
): GroupInfo() {
|
): GroupInfo() {
|
||||||
companion object {
|
companion object {
|
||||||
@ -28,7 +27,6 @@ sealed class GroupInfo {
|
|||||||
if (sessionId != other.sessionId) return false
|
if (sessionId != other.sessionId) return false
|
||||||
if (name != other.name) return false
|
if (name != other.name) return false
|
||||||
if (members != other.members) return false
|
if (members != other.members) return false
|
||||||
if (hidden != other.hidden) return false
|
|
||||||
if (!encPubKey.contentEquals(other.encPubKey)) return false
|
if (!encPubKey.contentEquals(other.encPubKey)) return false
|
||||||
if (!encSecKey.contentEquals(other.encSecKey)) return false
|
if (!encSecKey.contentEquals(other.encSecKey)) return false
|
||||||
if (priority != other.priority) return false
|
if (priority != other.priority) return false
|
||||||
@ -40,7 +38,6 @@ sealed class GroupInfo {
|
|||||||
var result = sessionId.hashCode()
|
var result = sessionId.hashCode()
|
||||||
result = 31 * result + name.hashCode()
|
result = 31 * result + name.hashCode()
|
||||||
result = 31 * result + members.hashCode()
|
result = 31 * result + members.hashCode()
|
||||||
result = 31 * result + hidden.hashCode()
|
|
||||||
result = 31 * result + encPubKey.contentHashCode()
|
result = 31 * result + encPubKey.contentHashCode()
|
||||||
result = 31 * result + encSecKey.contentHashCode()
|
result = 31 * result + encSecKey.contentHashCode()
|
||||||
result = 31 * result + priority
|
result = 31 * result + priority
|
||||||
|
Loading…
Reference in New Issue
Block a user