diff --git a/library/src/main/cpp/user_profile.cpp b/library/src/main/cpp/user_profile.cpp index 593bfdc..80800c9 100644 --- a/library/src/main/cpp/user_profile.cpp +++ b/library/src/main/cpp/user_profile.cpp @@ -180,6 +180,25 @@ Java_network_loki_messenger_libsession_1util_UserProfile_removeProAccessExpiry(J ptrToProfile(env, thiz)->set_pro_access_expiry(std::nullopt); } +extern "C" +JNIEXPORT jboolean JNICALL +Java_network_loki_messenger_libsession_1util_UserProfile_getProAutoRenewing(JNIEnv *env, + jobject thiz) { + return static_cast(ptrToProfile(env, thiz)->get_pro_auto_renewing()); +} + +extern "C" +JNIEXPORT void JNICALL +Java_network_loki_messenger_libsession_1util_UserProfile_setProAutoRenewing(JNIEnv *env, + jobject thiz, + jboolean auto_renewing) { + // Presence-only upstream: set_pro_auto_renewing uses set_nonzero_int, so writing false ERASES + // the key rather than storing it. Absent therefore means "terminal/unknown", and a caller + // cannot distinguish it from an explicit false through this binding — which is the whole of + // libsession PR #121's tri-state limitation, not something introduced here. + ptrToProfile(env, thiz)->set_pro_auto_renewing(auto_renewing); +} + extern "C" JNIEXPORT jlong JNICALL Java_network_loki_messenger_libsession_1util_UserProfile_getProFeaturesRaw(JNIEnv *env, diff --git a/library/src/main/java/network/loki/messenger/libsession_util/Config.kt b/library/src/main/java/network/loki/messenger/libsession_util/Config.kt index 98385bd..c609a10 100644 --- a/library/src/main/java/network/loki/messenger/libsession_util/Config.kt +++ b/library/src/main/java/network/loki/messenger/libsession_util/Config.kt @@ -87,6 +87,15 @@ interface ReadableUserProfile: ReadableConfig { fun getProConfig(): ProConfig? fun getProAccessExpiry(): Long? + /** + * Whether the subscription is auto-renewing, from synced config (key `A`, libsession #121). + * + * **Presence-only.** `setProAutoRenewing(false)` ERASES the key, so `false` here means either + * "not auto-renewing" or "never written" — absent reads as terminal/unknown. Callers that need + * to tell those apart cannot, through this API. + */ + fun getProAutoRenewing(): Boolean + /** When a refund was requested (unix seconds), or null if none (values >1 week old read as null). */ fun getRefundRequested(): Long? @@ -123,6 +132,9 @@ interface MutableUserProfile : ReadableUserProfile, MutableConfig { fun setProAccessExpiry(epochSeconds: Long) fun removeProAccessExpiry() + /** See [getProAutoRenewing] — writing `false` erases the key rather than storing it. */ + fun setProAutoRenewing(autoRenewing: Boolean) + /** Record (epochSeconds) or clear (null) the "refund requested" flag; synced across devices. */ fun setRefundRequested(epochSeconds: Long?) diff --git a/library/src/main/java/network/loki/messenger/libsession_util/UserProfile.kt b/library/src/main/java/network/loki/messenger/libsession_util/UserProfile.kt index 92aa47a..78d4936 100644 --- a/library/src/main/java/network/loki/messenger/libsession_util/UserProfile.kt +++ b/library/src/main/java/network/loki/messenger/libsession_util/UserProfile.kt @@ -47,6 +47,8 @@ class UserProfile private constructor(pointer: Long) : ConfigBase(pointer), Muta external override fun setAnimatedAvatar(animatedAvatar: Boolean) external override fun setProAccessExpiry(epochSeconds: Long) external override fun removeProAccessExpiry() + external override fun getProAutoRenewing(): Boolean + external override fun setProAutoRenewing(autoRenewing: Boolean) private external fun getProFeaturesRaw(): Long override fun getProFeatures(): ProProfileFeatures = ProProfileFeatures(getProFeaturesRaw()) external override fun getProConfig(): ProConfig? diff --git a/libsession-util b/libsession-util index e241a48..8e5634b 160000 --- a/libsession-util +++ b/libsession-util @@ -1 +1 @@ -Subproject commit e241a489fde5385a3677e8f3401627095c23eed6 +Subproject commit 8e5634b81acadb23203cb7fb8474c96db3a406ee