Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions library/src/main/cpp/user_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<jboolean>(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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down Expand Up @@ -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?)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Loading