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

org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage Maven / Gradle / Ivy

There is a newer version: 2.15.3
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.multidevice;

import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class SignalServiceSyncMessage {

  private final Optional             sent;
  private final Optional                   contacts;
  private final Optional           groups;
  private final Optional                blockedList;
  private final Optional                    request;
  private final Optional>                 reads;
  private final Optional                   verified;
  private final Optional              configuration;
  private final Optional> stickerPackOperations;

  private SignalServiceSyncMessage(Optional             sent,
                                   Optional                   contacts,
                                   Optional           groups,
                                   Optional                blockedList,
                                   Optional                    request,
                                   Optional>                 reads,
                                   Optional                   verified,
                                   Optional              configuration,
                                   Optional> stickerPackOperations)
  {
    this.sent                  = sent;
    this.contacts              = contacts;
    this.groups                = groups;
    this.blockedList           = blockedList;
    this.request               = request;
    this.reads                 = reads;
    this.verified              = verified;
    this.configuration         = configuration;
    this.stickerPackOperations = stickerPackOperations;
  }

  public static SignalServiceSyncMessage forSentTranscript(SentTranscriptMessage sent) {
    return new SignalServiceSyncMessage(Optional.of(sent),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent());
  }

  public static SignalServiceSyncMessage forContacts(ContactsMessage contacts) {
    return new SignalServiceSyncMessage(Optional.absent(),
                                        Optional.of(contacts),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent());
  }

  public static SignalServiceSyncMessage forGroups(SignalServiceAttachment groups) {
    return new SignalServiceSyncMessage(Optional.absent(),
                                        Optional.absent(),
                                        Optional.of(groups),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent());
  }

  public static SignalServiceSyncMessage forRequest(RequestMessage request) {
    return new SignalServiceSyncMessage(Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.of(request),
                                        Optional.>absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent());
  }

  public static SignalServiceSyncMessage forRead(List reads) {
    return new SignalServiceSyncMessage(Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.of(reads),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent());
  }

  public static SignalServiceSyncMessage forRead(ReadMessage read) {
    List reads = new LinkedList<>();
    reads.add(read);

    return new SignalServiceSyncMessage(Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.of(reads),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent());
  }

  public static SignalServiceSyncMessage forVerified(VerifiedMessage verifiedMessage) {
    return new SignalServiceSyncMessage(Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent(),
                                        Optional.of(verifiedMessage),
                                        Optional.absent(),
                                        Optional.>absent());
  }

  public static SignalServiceSyncMessage forBlocked(BlockedListMessage blocked) {
    return new SignalServiceSyncMessage(Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.of(blocked),
                                        Optional.absent(),
                                        Optional.>absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent());
  }

  public static SignalServiceSyncMessage forConfiguration(ConfigurationMessage configuration) {
    return new SignalServiceSyncMessage(Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent(),
                                        Optional.absent(),
                                        Optional.of(configuration),
                                        Optional.>absent());
  }

  public static SignalServiceSyncMessage forStickerPackOperations(List stickerPackOperations) {
    return new SignalServiceSyncMessage(Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.of(stickerPackOperations));
  }

  public static SignalServiceSyncMessage empty() {
    return new SignalServiceSyncMessage(Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent(),
                                        Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent());
  }

  public Optional getSent() {
    return sent;
  }

  public Optional getGroups() {
    return groups;
  }

  public Optional getContacts() {
    return contacts;
  }

  public Optional getRequest() {
    return request;
  }

  public Optional> getRead() {
    return reads;
  }

  public Optional getBlockedList() {
    return blockedList;
  }

  public Optional getVerified() {
    return verified;
  }

  public Optional getConfiguration() {
    return configuration;
  }

  public Optional> getStickerPackOperations() {
    return stickerPackOperations;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy