SignalServiceAttachment classes renamed to SessionServiceAttachment to avoid confusion

This commit is contained in:
Brice 2020-12-17 14:36:32 +11:00
parent 26b2ead673
commit c286efae9d
3 changed files with 13 additions and 14 deletions

View File

@ -5,7 +5,7 @@ import org.session.libsignal.libsignal.util.guava.Optional
import org.session.libsignal.service.api.messages.SignalServiceAttachment
import java.io.InputStream
abstract class SignalServiceAttachment protected constructor(val contentType: String?) {
abstract class SessionServiceAttachment protected constructor(val contentType: String?) {
var attachmentId: Long = 0
var isGif: Boolean = false
@ -17,12 +17,12 @@ abstract class SignalServiceAttachment protected constructor(val contentType: St
abstract fun isStream(): Boolean
abstract fun isPointer(): Boolean
fun asStream(): SignalServiceAttachmentStream {
return this as SignalServiceAttachmentStream
fun asStream(): SessionServiceAttachmentStream {
return this as SessionServiceAttachmentStream
}
fun asPointer(): SignalServiceAttachmentPointer {
return this as SignalServiceAttachmentPointer
fun asPointer(): SessionServiceAttachmentPointer {
return this as SessionServiceAttachmentPointer
}
fun shouldHaveImageSize(): Boolean {
@ -84,11 +84,11 @@ abstract class SignalServiceAttachment protected constructor(val contentType: St
return this
}
fun build(): SignalServiceAttachmentStream {
fun build(): SessionServiceAttachmentStream {
requireNotNull(inputStream) { "Must specify stream!" }
requireNotNull(contentType) { "No content type specified!" }
require(length != 0L) { "No length specified!" }
return SignalServiceAttachmentStream(inputStream, contentType, length, Optional.fromNullable(fileName), voiceNote, Optional.absent(), width, height, Optional.fromNullable(caption), listener)
return SessionServiceAttachmentStream(inputStream, contentType, length, Optional.fromNullable(fileName), voiceNote, Optional.absent(), width, height, Optional.fromNullable(caption), listener)
}
}

View File

@ -6,7 +6,6 @@
package org.session.libsession.messaging.sending_receiving.attachments
import org.session.libsignal.libsignal.util.guava.Optional
import org.session.libsignal.service.api.messages.SignalServiceAttachment
/**
* Represents a received SignalServiceAttachment "handle." This
@ -15,11 +14,11 @@ import org.session.libsignal.service.api.messages.SignalServiceAttachment
*
* @author Moxie Marlinspike
*/
class SignalServiceAttachmentPointer(val id: Long, contentType: String?, val key: ByteArray?,
val size: Optional<Int>, val preview: Optional<ByteArray>,
val width: Int, val height: Int,
val digest: Optional<ByteArray>, val fileName: Optional<String>,
val voiceNote: Boolean, val caption: Optional<String>, val url: String) : SignalServiceAttachment(contentType) {
class SessionServiceAttachmentPointer(val id: Long, contentType: String?, key: ByteArray?,
val size: Optional<Int>, val preview: Optional<ByteArray>,
val width: Int, val height: Int,
val digest: Optional<ByteArray>, val fileName: Optional<String>,
val voiceNote: Boolean, val caption: Optional<String>, url: String) : SessionServiceAttachment(contentType) {
override fun isStream(): Boolean {
return false
}

View File

@ -16,7 +16,7 @@ import kotlin.math.round
/**
* Represents a local SignalServiceAttachment to be sent.
*/
class SignalServiceAttachmentStream(val inputStream: InputStream?, contentType: String?, val length: Long, val fileName: Optional<String?>?, val voiceNote: Boolean, val preview: Optional<ByteArray?>, val width: Int, val height: Int, val caption: Optional<String?>, val listener: SAttachment.ProgressListener?) : SignalServiceAttachment(contentType) {
class SessionServiceAttachmentStream(val inputStream: InputStream?, contentType: String?, val length: Long, val fileName: Optional<String?>?, val voiceNote: Boolean, val preview: Optional<ByteArray?>, val width: Int, val height: Int, val caption: Optional<String?>, val listener: SAttachment.ProgressListener?) : SessionServiceAttachment(contentType) {
constructor(inputStream: InputStream?, contentType: String?, length: Long, fileName: Optional<String?>?, voiceNote: Boolean, listener: SAttachment.ProgressListener?) : this(inputStream, contentType, length, fileName, voiceNote, Optional.absent<ByteArray?>(), 0, 0, Optional.absent<String?>(), listener) {}