Skip to content

Commit 5481c06

Browse files
SessionHero01SessionHero01
andauthored
Added profile timestamp related functions (#22)
Co-authored-by: SessionHero01 <[email protected]>
1 parent 2056cbc commit 5481c06

File tree

6 files changed

+38
-7
lines changed

6 files changed

+38
-7
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.13.0"
3+
kotlin = "2.2.20"
44

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

library/build.gradle.kts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13
plugins {
24
alias(libs.plugins.android.library)
35
alias(libs.plugins.kotlin.android)
@@ -45,17 +47,19 @@ android {
4547
targetCompatibility = JavaVersion.VERSION_11
4648
}
4749

48-
kotlinOptions {
49-
jvmTarget = "11"
50-
}
51-
5250
publishing {
5351
singleVariant("release") {
5452
withSourcesJar()
5553
}
5654
}
5755
}
5856

57+
kotlin {
58+
compilerOptions {
59+
jvmTarget = JvmTarget.JVM_11
60+
}
61+
}
62+
5963
publishing {
6064
publications {
6165
create<MavenPublication>("release") {

library/src/main/cpp/user_profile.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,25 @@ Java_network_loki_messenger_libsession_1util_UserProfile_setCommunityMessageRequ
9292
auto profile = ptrToProfile(env, thiz);
9393
profile->set_blinded_msgreqs(std::optional{(bool)blocks});
9494
}
95+
9596
extern "C"
9697
JNIEXPORT jboolean JNICALL
9798
Java_network_loki_messenger_libsession_1util_UserProfile_isBlockCommunityMessageRequestsSet(
9899
JNIEnv *env, jobject thiz) {
99100
auto profile = ptrToProfile(env, thiz);
100101
return profile->get_blinded_msgreqs().has_value();
101102
}
103+
104+
extern "C"
105+
JNIEXPORT jlong JNICALL
106+
Java_network_loki_messenger_libsession_1util_UserProfile_getProfileUpdatedSeconds(JNIEnv *env,
107+
jobject thiz) {
108+
return ptrToProfile(env, thiz)->get_profile_updated().time_since_epoch().count();
109+
}
110+
111+
extern "C"
112+
JNIEXPORT void JNICALL
113+
Java_network_loki_messenger_libsession_1util_UserProfile_setReuploadedPic(JNIEnv *env, jobject thiz,
114+
jobject user_pic) {
115+
ptrToProfile(env, thiz)->set_reupload_profile_pic(util::deserialize_user_pic(env, user_pic));
116+
}

library/src/main/java/network/loki/messenger/libsession_util/Config.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ interface MutableContacts : ReadableContacts, MutableConfig {
7373
interface ReadableUserProfile: ReadableConfig {
7474
fun getName(): String?
7575
fun getPic(): UserPic
76+
fun getProfileUpdatedSeconds(): Long
7677
fun getNtsPriority(): Long
7778
fun getNtsExpiry(): ExpiryMode
7879
fun getCommunityMessageRequests(): Boolean
@@ -81,7 +82,16 @@ interface ReadableUserProfile: ReadableConfig {
8182

8283
interface MutableUserProfile : ReadableUserProfile, MutableConfig {
8384
fun setName(newName: String)
85+
86+
/**
87+
* Called when setting a new user pic
88+
*/
8489
fun setPic(userPic: UserPic)
90+
91+
/**
92+
* Called when setting a re-uploaded pic
93+
*/
94+
fun setReuploadedPic(userPic: UserPic)
8595
fun setNtsPriority(priority: Long)
8696
fun setNtsExpiry(expiryMode: ExpiryMode)
8797
fun setCommunityMessageRequests(blocks: Boolean)

library/src/main/java/network/loki/messenger/libsession_util/UserProfile.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class UserProfile private constructor(pointer: Long) : ConfigBase(pointer), Muta
1818
external override fun getName(): String?
1919
external override fun getPic(): UserPic
2020
external override fun setPic(userPic: UserPic)
21+
external override fun getProfileUpdatedSeconds(): Long
22+
external override fun setReuploadedPic(userPic: UserPic)
2123
external override fun setNtsPriority(priority: Long)
2224
external override fun getNtsPriority(): Long
2325
external override fun setNtsExpiry(expiryMode: ExpiryMode)

0 commit comments

Comments
 (0)