All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream.kt Maven / Gradle / Ivy

There is a newer version: 2.15.3_unofficial_107
Show newest version
/**
 * Copyright (C) 2014-2016 Open Whisper Systems
 *
 * Licensed according to the LICENSE file in this repository.
 */
package org.whispersystems.signalservice.api.messages

import org.whispersystems.signalservice.internal.push.http.CancelationSignal
import org.whispersystems.signalservice.internal.push.http.ResumableUploadSpec
import java.io.Closeable
import java.io.IOException
import java.io.InputStream
import java.util.Optional
import java.util.UUID

/**
 * Represents a local SignalServiceAttachment to be sent.
 */
class SignalServiceAttachmentStream(
  val inputStream: InputStream,
  contentType: String?,
  val length: Long,
  val fileName: Optional,
  val voiceNote: Boolean,
  val isBorderless: Boolean,
  val isGif: Boolean,
  val isFaststart: Boolean,
  val preview: Optional,
  val width: Int,
  val height: Int,
  val uploadTimestamp: Long,
  val caption: Optional,
  val blurHash: Optional,
  val listener: ProgressListener?,
  val cancelationSignal: CancelationSignal?,
  val resumableUploadSpec: Optional,
  val uuid: UUID?
) : SignalServiceAttachment(contentType!!), Closeable {
  constructor(
    inputStream: InputStream,
    contentType: String?,
    length: Long,
    fileName: Optional,
    voiceNote: Boolean,
    borderless: Boolean,
    gif: Boolean,
    faststart: Boolean,
    listener: ProgressListener?,
    cancelationSignal: CancelationSignal?
  ) : this(
    inputStream = inputStream,
    contentType = contentType,
    length = length,
    fileName = fileName,
    voiceNote = voiceNote,
    isBorderless = borderless,
    isGif = gif,
    isFaststart = faststart,
    preview = Optional.empty(),
    width = 0,
    height = 0,
    uploadTimestamp = System.currentTimeMillis(),
    caption = Optional.empty(),
    blurHash = Optional.empty(),
    listener = listener,
    cancelationSignal = cancelationSignal,
    resumableUploadSpec = Optional.empty(),
    uuid = UUID.randomUUID()
  )

  override fun isStream() = true
  override fun isPointer() = false

  @Throws(IOException::class)
  override fun close() {
    inputStream.close()
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy