mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-03 15:05:24 +00:00
ExpirationTimerUpdate implementation + classes structure changes
This commit is contained in:
parent
888eda4ba9
commit
8f409faefc
@ -53,7 +53,6 @@ class ClosedGroupUpdate() : ControlMessage() {
|
||||
return ClosedGroupUpdate(kind)
|
||||
}
|
||||
}
|
||||
//private val TAG: String = ClosedGroupUpdate::class.java.simpleName
|
||||
|
||||
// Kind enum
|
||||
sealed class Kind {
|
||||
@ -65,11 +64,12 @@ class ClosedGroupUpdate() : ControlMessage() {
|
||||
|
||||
var kind: Kind? = null
|
||||
|
||||
// constructors
|
||||
// constructor
|
||||
internal constructor(kind: Kind?) : this() {
|
||||
this.kind = kind
|
||||
}
|
||||
|
||||
// validation
|
||||
override fun isValid(): Boolean {
|
||||
if (!super.isValid() || kind == null) return false
|
||||
val kind = kind ?: return false
|
||||
|
@ -1,13 +1,51 @@
|
||||
package org.session.libsession.messaging.messages.control
|
||||
|
||||
import org.session.libsignal.libsignal.logging.Log
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||
|
||||
class ExpirationTimerUpdate : ControlMessage() {
|
||||
override fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
||||
TODO("Not yet implemented")
|
||||
class ExpirationTimerUpdate() : ControlMessage() {
|
||||
|
||||
var duration: Int? = 0
|
||||
|
||||
companion object {
|
||||
const val TAG = "ExpirationTimerUpdate"
|
||||
|
||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
||||
val dataMessageProto = proto.dataMessage ?: return null
|
||||
val isExpirationTimerUpdate = (dataMessageProto.flags and SignalServiceProtos.DataMessage.Flags.EXPIRATION_TIMER_UPDATE_VALUE) != 0
|
||||
if (!isExpirationTimerUpdate) return null
|
||||
val duration = dataMessageProto.expireTimer
|
||||
return ExpirationTimerUpdate(duration)
|
||||
}
|
||||
}
|
||||
|
||||
//constructor
|
||||
internal constructor(duration: Int) : this() {
|
||||
this.duration = duration
|
||||
}
|
||||
|
||||
// validation
|
||||
override fun isValid(): Boolean {
|
||||
if (!super.isValid()) return false
|
||||
return duration != null
|
||||
}
|
||||
|
||||
override fun toProto(): SignalServiceProtos.Content? {
|
||||
TODO("Not yet implemented")
|
||||
val duration = duration
|
||||
if (duration == null) {
|
||||
Log.w(TAG, "Couldn't construct expiration timer update proto from: $this")
|
||||
return null
|
||||
}
|
||||
val dataMessageProto = SignalServiceProtos.DataMessage.newBuilder()
|
||||
dataMessageProto.flags = SignalServiceProtos.DataMessage.Flags.EXPIRATION_TIMER_UPDATE_VALUE
|
||||
dataMessageProto.expireTimer = duration
|
||||
val contentProto = SignalServiceProtos.Content.newBuilder()
|
||||
try {
|
||||
contentProto.dataMessage = dataMessageProto.build()
|
||||
return contentProto.build()
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Couldn't construct expiration timer update proto from: $this")
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
@ -2,9 +2,13 @@ package org.session.libsession.messaging.messages.control
|
||||
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||
|
||||
class ReadReceipt : ControlMessage() {
|
||||
override fun fromProto(proto: SignalServiceProtos.Content): ReadReceipt? {
|
||||
TODO("Not yet implemented")
|
||||
class ReadReceipt() : ControlMessage() {
|
||||
|
||||
|
||||
companion object {
|
||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
||||
override fun toProto(): SignalServiceProtos.Content? {
|
||||
|
@ -3,8 +3,11 @@ package org.session.libsession.messaging.messages.control
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||
|
||||
class TypingIndicator : ControlMessage() {
|
||||
override fun fromProto(proto: SignalServiceProtos.Content): TypingIndicator?{
|
||||
TODO("Not yet implemented")
|
||||
|
||||
companion object {
|
||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
||||
override fun toProto(): SignalServiceProtos.Content? {
|
||||
|
@ -1,11 +1,16 @@
|
||||
package org.session.libsession.messaging.messages.control.unused
|
||||
|
||||
import org.session.libsession.messaging.messages.control.ControlMessage
|
||||
import org.session.libsession.messaging.messages.control.ExpirationTimerUpdate
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||
|
||||
class NullMessage : ControlMessage() {
|
||||
override fun fromProto(proto: SignalServiceProtos.Content): NullMessage? {
|
||||
TODO("Not yet implemented")
|
||||
class NullMessage() : ControlMessage() {
|
||||
|
||||
|
||||
companion object {
|
||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
||||
override fun toProto(): SignalServiceProtos.Content? {
|
||||
|
@ -1,11 +1,15 @@
|
||||
package org.session.libsession.messaging.messages.control.unused
|
||||
|
||||
import org.session.libsession.messaging.messages.control.ControlMessage
|
||||
import org.session.libsession.messaging.messages.control.ExpirationTimerUpdate
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||
|
||||
class SessionRequest : ControlMessage() {
|
||||
override fun fromProto(proto: SignalServiceProtos.Content): SessionRequest? {
|
||||
TODO("Not yet implemented")
|
||||
class SessionRequest() : ControlMessage() {
|
||||
|
||||
companion object {
|
||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
||||
override fun toProto(): SignalServiceProtos.Content? {
|
||||
|
@ -1,10 +1,14 @@
|
||||
package org.session.libsession.messaging.messages.visible
|
||||
|
||||
import org.session.libsession.messaging.messages.control.ExpirationTimerUpdate
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||
|
||||
internal class Contact : VisibleMessage() {
|
||||
override fun fromProto(proto: SignalServiceProtos.Content): Contact? {
|
||||
TODO("Not yet implemented")
|
||||
|
||||
companion object {
|
||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
||||
override fun toProto(): SignalServiceProtos.Content? {
|
||||
|
@ -1,10 +1,14 @@
|
||||
package org.session.libsession.messaging.messages.visible
|
||||
|
||||
import org.session.libsession.messaging.messages.control.ExpirationTimerUpdate
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||
|
||||
internal class LinkPreview : VisibleMessage(){
|
||||
override fun fromProto(proto: SignalServiceProtos.Content): LinkPreview? {
|
||||
TODO("Not yet implemented")
|
||||
|
||||
companion object {
|
||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
||||
override fun toProto(): SignalServiceProtos.Content? {
|
||||
|
@ -1,10 +1,14 @@
|
||||
package org.session.libsession.messaging.messages.visible
|
||||
|
||||
import org.session.libsession.messaging.messages.control.ExpirationTimerUpdate
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||
|
||||
internal class Profile : VisibleMessage() {
|
||||
override fun fromProto(proto: SignalServiceProtos.Content): Profile? {
|
||||
TODO("Not yet implemented")
|
||||
|
||||
companion object {
|
||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
||||
override fun toProto(): SignalServiceProtos.Content? {
|
||||
|
@ -1,10 +1,14 @@
|
||||
package org.session.libsession.messaging.messages.visible
|
||||
|
||||
import org.session.libsession.messaging.messages.control.ExpirationTimerUpdate
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||
|
||||
internal class Quote : VisibleMessage() {
|
||||
override fun fromProto(proto: SignalServiceProtos.Content): Quote? {
|
||||
TODO("Not yet implemented")
|
||||
|
||||
companion object {
|
||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
||||
override fun toProto(): SignalServiceProtos.Content? {
|
||||
|
@ -1,11 +1,15 @@
|
||||
package org.session.libsession.messaging.messages.visible.attachments
|
||||
|
||||
import org.session.libsession.messaging.messages.control.ExpirationTimerUpdate
|
||||
import org.session.libsession.messaging.messages.visible.VisibleMessage
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||
|
||||
internal class Attachment : VisibleMessage() {
|
||||
override fun fromProto(proto: SignalServiceProtos.Content): Attachment? {
|
||||
TODO("Not yet implemented")
|
||||
|
||||
companion object {
|
||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
||||
override fun toProto(): SignalServiceProtos.Content? {
|
||||
|
Loading…
Reference in New Issue
Block a user