From 88bbc0b67716fe9de6bdae21396cab0a74e7c015 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Mon, 22 Feb 2021 10:21:06 +1100 Subject: [PATCH] clean up stickers --- .../securesms/jobs/PushGroupSendJob.java | 1 - .../securesms/jobs/PushSendJob.java | 24 - .../libsignal/util/IdentityKeyComparator.java | 13 - .../api/messages/SendMessageResult.java | 4 - .../SignalServiceAttachmentStream.java | 4 - .../messages/SignalServiceDataMessage.java | 44 - .../api/messages/SignalServiceEnvelope.java | 142 -- .../api/messages/SignalServiceGroup.java | 4 - .../SignalServiceStickerManifest.java | 56 - .../internal/sticker/StickerProtos.java | 1798 ----------------- .../websocket/WebSocketConnection.java | 340 ---- .../websocket/WebSocketEventListener.java | 9 - 12 files changed, 2439 deletions(-) delete mode 100644 libsignal/src/main/java/org/session/libsignal/libsignal/util/IdentityKeyComparator.java delete mode 100644 libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceStickerManifest.java delete mode 100644 libsignal/src/main/java/org/session/libsignal/service/internal/sticker/StickerProtos.java delete mode 100644 libsignal/src/main/java/org/session/libsignal/service/internal/websocket/WebSocketConnection.java delete mode 100644 libsignal/src/main/java/org/session/libsignal/service/internal/websocket/WebSocketEventListener.java diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java index 5e7b0194d8..772f3855cb 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java @@ -274,7 +274,6 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType { String groupId = address.toGroupString(); Optional profileKey = getProfileKey(message.getRecipient()); Optional quote = getQuoteFor(message); - Optional sticker = getStickerFor(message); List sharedContacts = getSharedContactsFor(message); List previews = getPreviewsFor(message); List attachments = Stream.of(message.getAttachments()).filterNot(Attachment::isSticker).toList(); diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushSendJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushSendJob.java index 2ba7b7502b..cd12987501 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushSendJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushSendJob.java @@ -212,26 +212,6 @@ public abstract class PushSendJob extends SendJob { return Optional.of(new SignalServiceDataMessage.Quote(quoteId, new SignalServiceAddress(quoteAuthor.serialize()), quoteBody, quoteAttachments)); } - protected Optional getStickerFor(OutgoingMediaMessage message) { - Attachment stickerAttachment = Stream.of(message.getAttachments()).filter(Attachment::isSticker).findFirst().orElse(null); - - if (stickerAttachment == null) { - return Optional.absent(); - } - - try { - byte[] packId = Hex.fromStringCondensed(stickerAttachment.getSticker().getPackId()); - byte[] packKey = Hex.fromStringCondensed(stickerAttachment.getSticker().getPackKey()); - int stickerId = stickerAttachment.getSticker().getStickerId(); - SignalServiceAttachment attachment = getAttachmentPointerFor(stickerAttachment); - - return Optional.of(new SignalServiceDataMessage.Sticker(packId, packKey, stickerId, attachment)); - } catch (IOException e) { - Log.w(TAG, "Failed to decode sticker id/key", e); - return Optional.absent(); - } - } - List getSharedContactsFor(OutgoingMediaMessage mediaMessage) { List sharedContacts = new LinkedList<>(); @@ -259,9 +239,5 @@ public abstract class PushSendJob extends SendJob { }).toList(); } - protected void rotateSenderCertificateIfNecessary() throws IOException { - // Loki - We don't need verification on sender certificates - } - protected abstract void onPushSend() throws Exception; } diff --git a/libsignal/src/main/java/org/session/libsignal/libsignal/util/IdentityKeyComparator.java b/libsignal/src/main/java/org/session/libsignal/libsignal/util/IdentityKeyComparator.java deleted file mode 100644 index a58938f2af..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/libsignal/util/IdentityKeyComparator.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.session.libsignal.libsignal.util; - -import org.session.libsignal.libsignal.IdentityKey; - -import java.util.Comparator; - -public class IdentityKeyComparator extends ByteArrayComparator implements Comparator { - - @Override - public int compare(IdentityKey first, IdentityKey second) { - return compare(first.getPublicKey().serialize(), second.getPublicKey().serialize()); - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SendMessageResult.java b/libsignal/src/main/java/org/session/libsignal/service/api/messages/SendMessageResult.java index 5c3da74046..9221e4481f 100644 --- a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SendMessageResult.java +++ b/libsignal/src/main/java/org/session/libsignal/service/api/messages/SendMessageResult.java @@ -46,10 +46,6 @@ public class SendMessageResult { return networkFailure; } - public boolean isUnregisteredFailure() { - return unregisteredFailure; - } - public IdentityFailure getIdentityFailure() { return identityFailure; } diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceAttachmentStream.java b/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceAttachmentStream.java index 10848781a7..b5df001012 100644 --- a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceAttachmentStream.java +++ b/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceAttachmentStream.java @@ -25,10 +25,6 @@ public class SignalServiceAttachmentStream extends SignalServiceAttachment { private final int height; private final Optional caption; - public SignalServiceAttachmentStream(InputStream inputStream, String contentType, long length, Optional fileName, boolean voiceNote, ProgressListener listener) { - this(inputStream, contentType, length, fileName, voiceNote, Optional.absent(), 0, 0, Optional.absent(), listener); - } - public SignalServiceAttachmentStream(InputStream inputStream, String contentType, long length, Optional fileName, boolean voiceNote, Optional preview, int width, int height, Optional caption, ProgressListener listener) { super(contentType); this.inputStream = inputStream; diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceDataMessage.java b/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceDataMessage.java index c0d93f9b6e..cbc8c8fafe 100644 --- a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceDataMessage.java +++ b/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceDataMessage.java @@ -276,11 +276,6 @@ public class SignalServiceDataMessage { return this; } - public Builder withAttachment(SignalServiceAttachment attachment) { - this.attachments.add(attachment); - return this; - } - public Builder withAttachments(List attachments) { this.attachments.addAll(attachments); return this; @@ -296,10 +291,6 @@ public class SignalServiceDataMessage { return this; } - public Builder asExpirationUpdate() { - return asExpirationUpdate(true); - } - public Builder asExpirationUpdate(boolean expirationUpdate) { this.expirationUpdate = expirationUpdate; return this; @@ -320,11 +311,6 @@ public class SignalServiceDataMessage { return this; } - public Builder withSharedContact(SharedContact contact) { - this.sharedContacts.add(contact); - return this; - } - public Builder withSharedContacts(List contacts) { this.sharedContacts.addAll(contacts); return this; @@ -420,34 +406,4 @@ public class SignalServiceDataMessage { return image; } } - - public static class Sticker { - private final byte[] packId; - private final byte[] packKey; - private final int stickerId; - private final SignalServiceAttachment attachment; - - public Sticker(byte[] packId, byte[] packKey, int stickerId, SignalServiceAttachment attachment) { - this.packId = packId; - this.packKey = packKey; - this.stickerId = stickerId; - this.attachment = attachment; - } - - public byte[] getPackId() { - return packId; - } - - public byte[] getPackKey() { - return packKey; - } - - public int getStickerId() { - return stickerId; - } - - public SignalServiceAttachment getAttachment() { - return attachment; - } - } } diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceEnvelope.java b/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceEnvelope.java index efd2744fb2..273fcdffc1 100644 --- a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceEnvelope.java +++ b/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceEnvelope.java @@ -39,63 +39,8 @@ import javax.crypto.spec.SecretKeySpec; */ public class SignalServiceEnvelope { - private static final String TAG = SignalServiceEnvelope.class.getSimpleName(); - - private static final int SUPPORTED_VERSION = 1; - private static final int CIPHER_KEY_SIZE = 32; - private static final int MAC_KEY_SIZE = 20; - private static final int MAC_SIZE = 10; - - private static final int VERSION_OFFSET = 0; - private static final int VERSION_LENGTH = 1; - private static final int IV_OFFSET = VERSION_OFFSET + VERSION_LENGTH; - private static final int IV_LENGTH = 16; - private static final int CIPHERTEXT_OFFSET = IV_OFFSET + IV_LENGTH; - private final Envelope envelope; - /** - * Construct an envelope from a serialized, Base64 encoded SignalServiceEnvelope, encrypted - * with a signaling key. - * - * @param message The serialized SignalServiceEnvelope, base64 encoded and encrypted. - * @param signalingKey The signaling key. - * @throws IOException - * @throws InvalidVersionException - */ - public SignalServiceEnvelope(String message, String signalingKey, boolean isSignalingKeyEncrypted) - throws IOException, InvalidVersionException - { - this(Base64.decode(message), signalingKey, isSignalingKeyEncrypted); - } - - /** - * Construct an envelope from a serialized SignalServiceEnvelope, encrypted with a signaling key. - * - * @param input The serialized and (optionally) encrypted SignalServiceEnvelope. - * @param signalingKey The signaling key. - * @throws InvalidVersionException - * @throws IOException - */ - public SignalServiceEnvelope(byte[] input, String signalingKey, boolean isSignalingKeyEncrypted) - throws InvalidVersionException, IOException - { - if (!isSignalingKeyEncrypted) { - this.envelope = Envelope.parseFrom(input); - } else { - if (input.length < VERSION_LENGTH || input[VERSION_OFFSET] != SUPPORTED_VERSION) { - throw new InvalidVersionException("Unsupported version!"); - } - - SecretKeySpec cipherKey = getCipherKey(signalingKey); - SecretKeySpec macKey = getMacKey(signalingKey); - - verifyMac(input, macKey); - - this.envelope = Envelope.parseFrom(getPlaintext(input, cipherKey)); - } - } - public SignalServiceEnvelope(Envelope proto) { Envelope.Builder builder = Envelope.newBuilder(); builder.setType(Envelope.Type.valueOf(proto.getType().getNumber())); @@ -126,17 +71,6 @@ public class SignalServiceEnvelope { this.envelope = builder.build(); } - public SignalServiceEnvelope(int type, long timestamp, byte[] content, long serverTimestamp) { - Envelope.Builder builder = Envelope.newBuilder() - .setType(Envelope.Type.valueOf(type)) - .setTimestamp(timestamp) - .setServerTimestamp(serverTimestamp); - - if (content != null) builder.setContent(ByteString.copyFrom(content)); - - this.envelope = builder.build(); - } - public boolean hasSource() { return envelope.hasSource() && envelope.getSource().length() > 0; } @@ -205,80 +139,4 @@ public class SignalServiceEnvelope { public boolean isClosedGroupCiphertext() { return envelope.getType().getNumber() == Envelope.Type.CLOSED_GROUP_CIPHERTEXT_VALUE; } - - private byte[] getPlaintext(byte[] ciphertext, SecretKeySpec cipherKey) throws IOException { - try { - byte[] ivBytes = new byte[IV_LENGTH]; - System.arraycopy(ciphertext, IV_OFFSET, ivBytes, 0, ivBytes.length); - IvParameterSpec iv = new IvParameterSpec(ivBytes); - - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - cipher.init(Cipher.DECRYPT_MODE, cipherKey, iv); - - return cipher.doFinal(ciphertext, CIPHERTEXT_OFFSET, - ciphertext.length - VERSION_LENGTH - IV_LENGTH - MAC_SIZE); - } catch (NoSuchAlgorithmException e) { - throw new AssertionError(e); - } catch (NoSuchPaddingException e) { - throw new AssertionError(e); - } catch (InvalidKeyException e) { - throw new AssertionError(e); - } catch (InvalidAlgorithmParameterException e) { - throw new AssertionError(e); - } catch (IllegalBlockSizeException e) { - throw new AssertionError(e); - } catch (BadPaddingException e) { - Log.w(TAG, e); - throw new IOException("Bad padding?"); - } - } - - private void verifyMac(byte[] ciphertext, SecretKeySpec macKey) throws IOException { - try { - Mac mac = Mac.getInstance("HmacSHA256"); - mac.init(macKey); - - if (ciphertext.length < MAC_SIZE + 1) - throw new IOException("Invalid MAC!"); - - mac.update(ciphertext, 0, ciphertext.length - MAC_SIZE); - - byte[] ourMacFull = mac.doFinal(); - byte[] ourMacBytes = new byte[MAC_SIZE]; - System.arraycopy(ourMacFull, 0, ourMacBytes, 0, ourMacBytes.length); - - byte[] theirMacBytes = new byte[MAC_SIZE]; - System.arraycopy(ciphertext, ciphertext.length-MAC_SIZE, theirMacBytes, 0, theirMacBytes.length); - - Log.w(TAG, "Our MAC: " + Hex.toString(ourMacBytes)); - Log.w(TAG, "Thr MAC: " + Hex.toString(theirMacBytes)); - - if (!Arrays.equals(ourMacBytes, theirMacBytes)) { - throw new IOException("Invalid MAC compare!"); - } - } catch (NoSuchAlgorithmException e) { - throw new AssertionError(e); - } catch (InvalidKeyException e) { - throw new AssertionError(e); - } - } - - - private SecretKeySpec getCipherKey(String signalingKey) throws IOException { - byte[] signalingKeyBytes = Base64.decode(signalingKey); - byte[] cipherKey = new byte[CIPHER_KEY_SIZE]; - System.arraycopy(signalingKeyBytes, 0, cipherKey, 0, cipherKey.length); - - return new SecretKeySpec(cipherKey, "AES"); - } - - - private SecretKeySpec getMacKey(String signalingKey) throws IOException { - byte[] signalingKeyBytes = Base64.decode(signalingKey); - byte[] macKey = new byte[MAC_KEY_SIZE]; - System.arraycopy(signalingKeyBytes, CIPHER_KEY_SIZE, macKey, 0, macKey.length); - - return new SecretKeySpec(macKey, "HmacSHA256"); - } - } diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceGroup.java b/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceGroup.java index b64c80a0f6..b503531097 100644 --- a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceGroup.java +++ b/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceGroup.java @@ -105,10 +105,6 @@ public class SignalServiceGroup { return admins; } - public static Builder newUpdateBuilder() { - return new Builder(Type.UPDATE); - } - public static Builder newBuilder(Type type) { return new Builder(type); } diff --git a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceStickerManifest.java b/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceStickerManifest.java deleted file mode 100644 index d9fe5d315d..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/service/api/messages/SignalServiceStickerManifest.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.session.libsignal.service.api.messages; - -import org.session.libsignal.libsignal.util.guava.Optional; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class SignalServiceStickerManifest { - - private final Optional title; - private final Optional author; - private final Optional cover; - private final List stickers; - - public SignalServiceStickerManifest(String title, String author, StickerInfo cover, List stickers) { - this.title = Optional.of(title); - this.author = Optional.of(author); - this.cover = Optional.of(cover); - this.stickers = (stickers == null) ? Collections.emptyList() : new ArrayList(stickers); - } - - public Optional getTitle() { - return title; - } - - public Optional getAuthor() { - return author; - } - - public Optional getCover() { - return cover; - } - - public List getStickers() { - return stickers; - } - - public static final class StickerInfo { - private final int id; - private final String emoji; - - public StickerInfo(int id, String emoji) { - this.id = id; - this.emoji = emoji; - } - - public int getId() { - return id; - } - - public String getEmoji() { - return emoji; - } - } -} diff --git a/libsignal/src/main/java/org/session/libsignal/service/internal/sticker/StickerProtos.java b/libsignal/src/main/java/org/session/libsignal/service/internal/sticker/StickerProtos.java deleted file mode 100644 index 08a818b96b..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/service/internal/sticker/StickerProtos.java +++ /dev/null @@ -1,1798 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: StickerResources.proto - -package org.session.libsignal.service.internal.sticker; - -public final class StickerProtos { - private StickerProtos() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - public interface PackOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional string title = 1; - /** - * optional string title = 1; - */ - boolean hasTitle(); - /** - * optional string title = 1; - */ - java.lang.String getTitle(); - /** - * optional string title = 1; - */ - com.google.protobuf.ByteString - getTitleBytes(); - - // optional string author = 2; - /** - * optional string author = 2; - */ - boolean hasAuthor(); - /** - * optional string author = 2; - */ - java.lang.String getAuthor(); - /** - * optional string author = 2; - */ - com.google.protobuf.ByteString - getAuthorBytes(); - - // optional .signalservice.Pack.Sticker cover = 3; - /** - * optional .signalservice.Pack.Sticker cover = 3; - */ - boolean hasCover(); - /** - * optional .signalservice.Pack.Sticker cover = 3; - */ - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker getCover(); - /** - * optional .signalservice.Pack.Sticker cover = 3; - */ - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.StickerOrBuilder getCoverOrBuilder(); - - // repeated .signalservice.Pack.Sticker stickers = 4; - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - java.util.List - getStickersList(); - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker getStickers(int index); - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - int getStickersCount(); - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - java.util.List - getStickersOrBuilderList(); - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.StickerOrBuilder getStickersOrBuilder( - int index); - } - /** - * Protobuf type {@code signalservice.Pack} - */ - public static final class Pack extends - com.google.protobuf.GeneratedMessage - implements PackOrBuilder { - // Use Pack.newBuilder() to construct. - private Pack(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private Pack(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final Pack defaultInstance; - public static Pack getDefaultInstance() { - return defaultInstance; - } - - public Pack getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Pack( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - bitField0_ |= 0x00000001; - title_ = input.readBytes(); - break; - } - case 18: { - bitField0_ |= 0x00000002; - author_ = input.readBytes(); - break; - } - case 26: { - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder subBuilder = null; - if (((bitField0_ & 0x00000004) == 0x00000004)) { - subBuilder = cover_.toBuilder(); - } - cover_ = input.readMessage(org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(cover_); - cover_ = subBuilder.buildPartial(); - } - bitField0_ |= 0x00000004; - break; - } - case 34: { - if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - stickers_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000008; - } - stickers_.add(input.readMessage(org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.PARSER, extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - stickers_ = java.util.Collections.unmodifiableList(stickers_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.service.internal.sticker.StickerProtos.internal_static_signalservice_Pack_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.service.internal.sticker.StickerProtos.internal_static_signalservice_Pack_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.class, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Pack parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Pack(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public interface StickerOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // optional uint32 id = 1; - /** - * optional uint32 id = 1; - */ - boolean hasId(); - /** - * optional uint32 id = 1; - */ - int getId(); - - // optional string emoji = 2; - /** - * optional string emoji = 2; - */ - boolean hasEmoji(); - /** - * optional string emoji = 2; - */ - java.lang.String getEmoji(); - /** - * optional string emoji = 2; - */ - com.google.protobuf.ByteString - getEmojiBytes(); - } - /** - * Protobuf type {@code signalservice.Pack.Sticker} - */ - public static final class Sticker extends - com.google.protobuf.GeneratedMessage - implements StickerOrBuilder { - // Use Sticker.newBuilder() to construct. - private Sticker(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private Sticker(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final Sticker defaultInstance; - public static Sticker getDefaultInstance() { - return defaultInstance; - } - - public Sticker getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Sticker( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - id_ = input.readUInt32(); - break; - } - case 18: { - bitField0_ |= 0x00000002; - emoji_ = input.readBytes(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.service.internal.sticker.StickerProtos.internal_static_signalservice_Pack_Sticker_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.service.internal.sticker.StickerProtos.internal_static_signalservice_Pack_Sticker_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.class, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Sticker parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Sticker(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // optional uint32 id = 1; - public static final int ID_FIELD_NUMBER = 1; - private int id_; - /** - * optional uint32 id = 1; - */ - public boolean hasId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 id = 1; - */ - public int getId() { - return id_; - } - - // optional string emoji = 2; - public static final int EMOJI_FIELD_NUMBER = 2; - private java.lang.Object emoji_; - /** - * optional string emoji = 2; - */ - public boolean hasEmoji() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional string emoji = 2; - */ - public java.lang.String getEmoji() { - java.lang.Object ref = emoji_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - emoji_ = s; - } - return s; - } - } - /** - * optional string emoji = 2; - */ - public com.google.protobuf.ByteString - getEmojiBytes() { - java.lang.Object ref = emoji_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - emoji_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private void initFields() { - id_ = 0; - emoji_ = ""; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeUInt32(1, id_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, getEmojiBytes()); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(1, id_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, getEmojiBytes()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code signalservice.Pack.Sticker} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.service.internal.sticker.StickerProtos.Pack.StickerOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.service.internal.sticker.StickerProtos.internal_static_signalservice_Pack_Sticker_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.service.internal.sticker.StickerProtos.internal_static_signalservice_Pack_Sticker_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.class, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder.class); - } - - // Construct using org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - id_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); - emoji_ = ""; - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.service.internal.sticker.StickerProtos.internal_static_signalservice_Pack_Sticker_descriptor; - } - - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker getDefaultInstanceForType() { - return org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.getDefaultInstance(); - } - - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker build() { - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker buildPartial() { - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker result = new org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.id_ = id_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.emoji_ = emoji_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker) { - return mergeFrom((org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker other) { - if (other == org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.getDefaultInstance()) return this; - if (other.hasId()) { - setId(other.getId()); - } - if (other.hasEmoji()) { - bitField0_ |= 0x00000002; - emoji_ = other.emoji_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional uint32 id = 1; - private int id_ ; - /** - * optional uint32 id = 1; - */ - public boolean hasId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 id = 1; - */ - public int getId() { - return id_; - } - /** - * optional uint32 id = 1; - */ - public Builder setId(int value) { - bitField0_ |= 0x00000001; - id_ = value; - onChanged(); - return this; - } - /** - * optional uint32 id = 1; - */ - public Builder clearId() { - bitField0_ = (bitField0_ & ~0x00000001); - id_ = 0; - onChanged(); - return this; - } - - // optional string emoji = 2; - private java.lang.Object emoji_ = ""; - /** - * optional string emoji = 2; - */ - public boolean hasEmoji() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional string emoji = 2; - */ - public java.lang.String getEmoji() { - java.lang.Object ref = emoji_; - if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - emoji_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string emoji = 2; - */ - public com.google.protobuf.ByteString - getEmojiBytes() { - java.lang.Object ref = emoji_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - emoji_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string emoji = 2; - */ - public Builder setEmoji( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - emoji_ = value; - onChanged(); - return this; - } - /** - * optional string emoji = 2; - */ - public Builder clearEmoji() { - bitField0_ = (bitField0_ & ~0x00000002); - emoji_ = getDefaultInstance().getEmoji(); - onChanged(); - return this; - } - /** - * optional string emoji = 2; - */ - public Builder setEmojiBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - emoji_ = value; - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:signalservice.Pack.Sticker) - } - - static { - defaultInstance = new Sticker(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:signalservice.Pack.Sticker) - } - - private int bitField0_; - // optional string title = 1; - public static final int TITLE_FIELD_NUMBER = 1; - private java.lang.Object title_; - /** - * optional string title = 1; - */ - public boolean hasTitle() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional string title = 1; - */ - public java.lang.String getTitle() { - java.lang.Object ref = title_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - title_ = s; - } - return s; - } - } - /** - * optional string title = 1; - */ - public com.google.protobuf.ByteString - getTitleBytes() { - java.lang.Object ref = title_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - title_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - // optional string author = 2; - public static final int AUTHOR_FIELD_NUMBER = 2; - private java.lang.Object author_; - /** - * optional string author = 2; - */ - public boolean hasAuthor() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional string author = 2; - */ - public java.lang.String getAuthor() { - java.lang.Object ref = author_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - author_ = s; - } - return s; - } - } - /** - * optional string author = 2; - */ - public com.google.protobuf.ByteString - getAuthorBytes() { - java.lang.Object ref = author_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - author_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - // optional .signalservice.Pack.Sticker cover = 3; - public static final int COVER_FIELD_NUMBER = 3; - private org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker cover_; - /** - * optional .signalservice.Pack.Sticker cover = 3; - */ - public boolean hasCover() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional .signalservice.Pack.Sticker cover = 3; - */ - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker getCover() { - return cover_; - } - /** - * optional .signalservice.Pack.Sticker cover = 3; - */ - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack.StickerOrBuilder getCoverOrBuilder() { - return cover_; - } - - // repeated .signalservice.Pack.Sticker stickers = 4; - public static final int STICKERS_FIELD_NUMBER = 4; - private java.util.List stickers_; - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public java.util.List getStickersList() { - return stickers_; - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public java.util.List - getStickersOrBuilderList() { - return stickers_; - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public int getStickersCount() { - return stickers_.size(); - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker getStickers(int index) { - return stickers_.get(index); - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack.StickerOrBuilder getStickersOrBuilder( - int index) { - return stickers_.get(index); - } - - private void initFields() { - title_ = ""; - author_ = ""; - cover_ = org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.getDefaultInstance(); - stickers_ = java.util.Collections.emptyList(); - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeBytes(1, getTitleBytes()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, getAuthorBytes()); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeMessage(3, cover_); - } - for (int i = 0; i < stickers_.size(); i++) { - output.writeMessage(4, stickers_.get(i)); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, getTitleBytes()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, getAuthorBytes()); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, cover_); - } - for (int i = 0; i < stickers_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, stickers_.get(i)); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static org.session.libsignal.service.internal.sticker.StickerProtos.Pack parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.session.libsignal.service.internal.sticker.StickerProtos.Pack prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code signalservice.Pack} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.session.libsignal.service.internal.sticker.StickerProtos.PackOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.session.libsignal.service.internal.sticker.StickerProtos.internal_static_signalservice_Pack_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.session.libsignal.service.internal.sticker.StickerProtos.internal_static_signalservice_Pack_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.class, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Builder.class); - } - - // Construct using org.session.libsignal.service.internal.sticker.StickerProtos.Pack.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getCoverFieldBuilder(); - getStickersFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - title_ = ""; - bitField0_ = (bitField0_ & ~0x00000001); - author_ = ""; - bitField0_ = (bitField0_ & ~0x00000002); - if (coverBuilder_ == null) { - cover_ = org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.getDefaultInstance(); - } else { - coverBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000004); - if (stickersBuilder_ == null) { - stickers_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); - } else { - stickersBuilder_.clear(); - } - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.session.libsignal.service.internal.sticker.StickerProtos.internal_static_signalservice_Pack_descriptor; - } - - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack getDefaultInstanceForType() { - return org.session.libsignal.service.internal.sticker.StickerProtos.Pack.getDefaultInstance(); - } - - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack build() { - org.session.libsignal.service.internal.sticker.StickerProtos.Pack result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack buildPartial() { - org.session.libsignal.service.internal.sticker.StickerProtos.Pack result = new org.session.libsignal.service.internal.sticker.StickerProtos.Pack(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.title_ = title_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.author_ = author_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - if (coverBuilder_ == null) { - result.cover_ = cover_; - } else { - result.cover_ = coverBuilder_.build(); - } - if (stickersBuilder_ == null) { - if (((bitField0_ & 0x00000008) == 0x00000008)) { - stickers_ = java.util.Collections.unmodifiableList(stickers_); - bitField0_ = (bitField0_ & ~0x00000008); - } - result.stickers_ = stickers_; - } else { - result.stickers_ = stickersBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.session.libsignal.service.internal.sticker.StickerProtos.Pack) { - return mergeFrom((org.session.libsignal.service.internal.sticker.StickerProtos.Pack)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.session.libsignal.service.internal.sticker.StickerProtos.Pack other) { - if (other == org.session.libsignal.service.internal.sticker.StickerProtos.Pack.getDefaultInstance()) return this; - if (other.hasTitle()) { - bitField0_ |= 0x00000001; - title_ = other.title_; - onChanged(); - } - if (other.hasAuthor()) { - bitField0_ |= 0x00000002; - author_ = other.author_; - onChanged(); - } - if (other.hasCover()) { - mergeCover(other.getCover()); - } - if (stickersBuilder_ == null) { - if (!other.stickers_.isEmpty()) { - if (stickers_.isEmpty()) { - stickers_ = other.stickers_; - bitField0_ = (bitField0_ & ~0x00000008); - } else { - ensureStickersIsMutable(); - stickers_.addAll(other.stickers_); - } - onChanged(); - } - } else { - if (!other.stickers_.isEmpty()) { - if (stickersBuilder_.isEmpty()) { - stickersBuilder_.dispose(); - stickersBuilder_ = null; - stickers_ = other.stickers_; - bitField0_ = (bitField0_ & ~0x00000008); - stickersBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getStickersFieldBuilder() : null; - } else { - stickersBuilder_.addAllMessages(other.stickers_); - } - } - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.session.libsignal.service.internal.sticker.StickerProtos.Pack parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.session.libsignal.service.internal.sticker.StickerProtos.Pack) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // optional string title = 1; - private java.lang.Object title_ = ""; - /** - * optional string title = 1; - */ - public boolean hasTitle() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional string title = 1; - */ - public java.lang.String getTitle() { - java.lang.Object ref = title_; - if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - title_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string title = 1; - */ - public com.google.protobuf.ByteString - getTitleBytes() { - java.lang.Object ref = title_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - title_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string title = 1; - */ - public Builder setTitle( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - title_ = value; - onChanged(); - return this; - } - /** - * optional string title = 1; - */ - public Builder clearTitle() { - bitField0_ = (bitField0_ & ~0x00000001); - title_ = getDefaultInstance().getTitle(); - onChanged(); - return this; - } - /** - * optional string title = 1; - */ - public Builder setTitleBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - title_ = value; - onChanged(); - return this; - } - - // optional string author = 2; - private java.lang.Object author_ = ""; - /** - * optional string author = 2; - */ - public boolean hasAuthor() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional string author = 2; - */ - public java.lang.String getAuthor() { - java.lang.Object ref = author_; - if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - author_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string author = 2; - */ - public com.google.protobuf.ByteString - getAuthorBytes() { - java.lang.Object ref = author_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - author_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string author = 2; - */ - public Builder setAuthor( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - author_ = value; - onChanged(); - return this; - } - /** - * optional string author = 2; - */ - public Builder clearAuthor() { - bitField0_ = (bitField0_ & ~0x00000002); - author_ = getDefaultInstance().getAuthor(); - onChanged(); - return this; - } - /** - * optional string author = 2; - */ - public Builder setAuthorBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - author_ = value; - onChanged(); - return this; - } - - // optional .signalservice.Pack.Sticker cover = 3; - private org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker cover_ = org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.getDefaultInstance(); - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.StickerOrBuilder> coverBuilder_; - /** - * optional .signalservice.Pack.Sticker cover = 3; - */ - public boolean hasCover() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional .signalservice.Pack.Sticker cover = 3; - */ - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker getCover() { - if (coverBuilder_ == null) { - return cover_; - } else { - return coverBuilder_.getMessage(); - } - } - /** - * optional .signalservice.Pack.Sticker cover = 3; - */ - public Builder setCover(org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker value) { - if (coverBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - cover_ = value; - onChanged(); - } else { - coverBuilder_.setMessage(value); - } - bitField0_ |= 0x00000004; - return this; - } - /** - * optional .signalservice.Pack.Sticker cover = 3; - */ - public Builder setCover( - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder builderForValue) { - if (coverBuilder_ == null) { - cover_ = builderForValue.build(); - onChanged(); - } else { - coverBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000004; - return this; - } - /** - * optional .signalservice.Pack.Sticker cover = 3; - */ - public Builder mergeCover(org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker value) { - if (coverBuilder_ == null) { - if (((bitField0_ & 0x00000004) == 0x00000004) && - cover_ != org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.getDefaultInstance()) { - cover_ = - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.newBuilder(cover_).mergeFrom(value).buildPartial(); - } else { - cover_ = value; - } - onChanged(); - } else { - coverBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000004; - return this; - } - /** - * optional .signalservice.Pack.Sticker cover = 3; - */ - public Builder clearCover() { - if (coverBuilder_ == null) { - cover_ = org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.getDefaultInstance(); - onChanged(); - } else { - coverBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000004); - return this; - } - /** - * optional .signalservice.Pack.Sticker cover = 3; - */ - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder getCoverBuilder() { - bitField0_ |= 0x00000004; - onChanged(); - return getCoverFieldBuilder().getBuilder(); - } - /** - * optional .signalservice.Pack.Sticker cover = 3; - */ - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack.StickerOrBuilder getCoverOrBuilder() { - if (coverBuilder_ != null) { - return coverBuilder_.getMessageOrBuilder(); - } else { - return cover_; - } - } - /** - * optional .signalservice.Pack.Sticker cover = 3; - */ - private com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.StickerOrBuilder> - getCoverFieldBuilder() { - if (coverBuilder_ == null) { - coverBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.StickerOrBuilder>( - cover_, - getParentForChildren(), - isClean()); - cover_ = null; - } - return coverBuilder_; - } - - // repeated .signalservice.Pack.Sticker stickers = 4; - private java.util.List stickers_ = - java.util.Collections.emptyList(); - private void ensureStickersIsMutable() { - if (!((bitField0_ & 0x00000008) == 0x00000008)) { - stickers_ = new java.util.ArrayList(stickers_); - bitField0_ |= 0x00000008; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.StickerOrBuilder> stickersBuilder_; - - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public java.util.List getStickersList() { - if (stickersBuilder_ == null) { - return java.util.Collections.unmodifiableList(stickers_); - } else { - return stickersBuilder_.getMessageList(); - } - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public int getStickersCount() { - if (stickersBuilder_ == null) { - return stickers_.size(); - } else { - return stickersBuilder_.getCount(); - } - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker getStickers(int index) { - if (stickersBuilder_ == null) { - return stickers_.get(index); - } else { - return stickersBuilder_.getMessage(index); - } - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public Builder setStickers( - int index, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker value) { - if (stickersBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureStickersIsMutable(); - stickers_.set(index, value); - onChanged(); - } else { - stickersBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public Builder setStickers( - int index, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder builderForValue) { - if (stickersBuilder_ == null) { - ensureStickersIsMutable(); - stickers_.set(index, builderForValue.build()); - onChanged(); - } else { - stickersBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public Builder addStickers(org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker value) { - if (stickersBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureStickersIsMutable(); - stickers_.add(value); - onChanged(); - } else { - stickersBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public Builder addStickers( - int index, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker value) { - if (stickersBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureStickersIsMutable(); - stickers_.add(index, value); - onChanged(); - } else { - stickersBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public Builder addStickers( - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder builderForValue) { - if (stickersBuilder_ == null) { - ensureStickersIsMutable(); - stickers_.add(builderForValue.build()); - onChanged(); - } else { - stickersBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public Builder addStickers( - int index, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder builderForValue) { - if (stickersBuilder_ == null) { - ensureStickersIsMutable(); - stickers_.add(index, builderForValue.build()); - onChanged(); - } else { - stickersBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public Builder addAllStickers( - java.lang.Iterable values) { - if (stickersBuilder_ == null) { - ensureStickersIsMutable(); - super.addAll(values, stickers_); - onChanged(); - } else { - stickersBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public Builder clearStickers() { - if (stickersBuilder_ == null) { - stickers_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); - onChanged(); - } else { - stickersBuilder_.clear(); - } - return this; - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public Builder removeStickers(int index) { - if (stickersBuilder_ == null) { - ensureStickersIsMutable(); - stickers_.remove(index); - onChanged(); - } else { - stickersBuilder_.remove(index); - } - return this; - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder getStickersBuilder( - int index) { - return getStickersFieldBuilder().getBuilder(index); - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack.StickerOrBuilder getStickersOrBuilder( - int index) { - if (stickersBuilder_ == null) { - return stickers_.get(index); } else { - return stickersBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public java.util.List - getStickersOrBuilderList() { - if (stickersBuilder_ != null) { - return stickersBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(stickers_); - } - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder addStickersBuilder() { - return getStickersFieldBuilder().addBuilder( - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.getDefaultInstance()); - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder addStickersBuilder( - int index) { - return getStickersFieldBuilder().addBuilder( - index, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.getDefaultInstance()); - } - /** - * repeated .signalservice.Pack.Sticker stickers = 4; - */ - public java.util.List - getStickersBuilderList() { - return getStickersFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.StickerOrBuilder> - getStickersFieldBuilder() { - if (stickersBuilder_ == null) { - stickersBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.Sticker.Builder, org.session.libsignal.service.internal.sticker.StickerProtos.Pack.StickerOrBuilder>( - stickers_, - ((bitField0_ & 0x00000008) == 0x00000008), - getParentForChildren(), - isClean()); - stickers_ = null; - } - return stickersBuilder_; - } - - // @@protoc_insertion_point(builder_scope:signalservice.Pack) - } - - static { - defaultInstance = new Pack(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:signalservice.Pack) - } - - private static com.google.protobuf.Descriptors.Descriptor - internal_static_signalservice_Pack_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_signalservice_Pack_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_signalservice_Pack_Sticker_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_signalservice_Pack_Sticker_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\026StickerResources.proto\022\rsignalservice\"" + - "\246\001\n\004Pack\022\r\n\005title\030\001 \001(\t\022\016\n\006author\030\002 \001(\t\022" + - "*\n\005cover\030\003 \001(\0132\033.signalservice.Pack.Stic" + - "ker\022-\n\010stickers\030\004 \003(\0132\033.signalservice.Pa" + - "ck.Sticker\032$\n\007Sticker\022\n\n\002id\030\001 \001(\r\022\r\n\005emo" + - "ji\030\002 \001(\tB?\n.org.session.libsignal.servic" + - "e.internal.stickerB\rStickerProtos" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - internal_static_signalservice_Pack_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_signalservice_Pack_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_signalservice_Pack_descriptor, - new java.lang.String[] { "Title", "Author", "Cover", "Stickers", }); - internal_static_signalservice_Pack_Sticker_descriptor = - internal_static_signalservice_Pack_descriptor.getNestedTypes().get(0); - internal_static_signalservice_Pack_Sticker_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_signalservice_Pack_Sticker_descriptor, - new java.lang.String[] { "Id", "Emoji", }); - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/libsignal/src/main/java/org/session/libsignal/service/internal/websocket/WebSocketConnection.java b/libsignal/src/main/java/org/session/libsignal/service/internal/websocket/WebSocketConnection.java deleted file mode 100644 index d6c7fea9e0..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/service/internal/websocket/WebSocketConnection.java +++ /dev/null @@ -1,340 +0,0 @@ -package org.session.libsignal.service.internal.websocket; - -import com.google.protobuf.InvalidProtocolBufferException; - -import org.session.libsignal.utilities.logging.Log; -import org.session.libsignal.libsignal.util.Pair; -import org.session.libsignal.libsignal.util.guava.Optional; -import org.session.libsignal.service.api.push.TrustStore; -import org.session.libsignal.service.api.util.CredentialsProvider; -import org.session.libsignal.service.api.util.SleepTimer; -import org.session.libsignal.service.api.util.Tls12SocketFactory; -import org.session.libsignal.service.api.websocket.ConnectivityListener; -import org.session.libsignal.service.internal.util.BlacklistingTrustManager; -import org.session.libsignal.service.internal.util.Util; -import org.session.libsignal.utilities.concurrent.SettableFuture; - -import java.io.IOException; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Map; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import okhttp3.ConnectionSpec; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.WebSocket; -import okhttp3.WebSocketListener; -import okio.ByteString; - -import static org.session.libsignal.service.internal.websocket.WebSocketProtos.WebSocketMessage; -import static org.session.libsignal.service.internal.websocket.WebSocketProtos.WebSocketRequestMessage; -import static org.session.libsignal.service.internal.websocket.WebSocketProtos.WebSocketResponseMessage; - -public class WebSocketConnection extends WebSocketListener { - - private static final String TAG = WebSocketConnection.class.getSimpleName(); - private static final int KEEPALIVE_TIMEOUT_SECONDS = 55; - - private final LinkedList incomingRequests = new LinkedList(); - private final Map>> outgoingRequests = new HashMap>>(); - - private final String wsUri; - private final TrustStore trustStore; - private final Optional credentialsProvider; - private final String userAgent; - private final ConnectivityListener listener; - private final SleepTimer sleepTimer; - - private WebSocket client; - private KeepAliveSender keepAliveSender; - private int attempts; - private boolean connected; - - public WebSocketConnection(String httpUri, - TrustStore trustStore, - Optional credentialsProvider, - String userAgent, - ConnectivityListener listener, - SleepTimer timer) - { - this.trustStore = trustStore; - this.credentialsProvider = credentialsProvider; - this.userAgent = userAgent; - this.listener = listener; - this.sleepTimer = timer; - this.attempts = 0; - this.connected = false; - - String uri = httpUri.replace("https://", "wss://").replace("http://", "ws://"); - - if (credentialsProvider.isPresent()) this.wsUri = uri + "/v1/websocket/?login=%s&password=%s"; - else this.wsUri = uri + "/v1/websocket/"; - } - - public synchronized void connect() { - Log.w(TAG, "WSC connect()..."); - - if (client == null) { - String filledUri; - - if (credentialsProvider.isPresent()) { - filledUri = String.format(wsUri, credentialsProvider.get().getUser(), credentialsProvider.get().getPassword()); - } else { - filledUri = wsUri; - } - - Pair socketFactory = createTlsSocketFactory(trustStore); - - OkHttpClient okHttpClient = new OkHttpClient.Builder() - .sslSocketFactory(new Tls12SocketFactory(socketFactory.first()), socketFactory.second()) - .connectionSpecs(Util.immutableList(ConnectionSpec.RESTRICTED_TLS)) - .readTimeout(KEEPALIVE_TIMEOUT_SECONDS + 10, TimeUnit.SECONDS) - .connectTimeout(KEEPALIVE_TIMEOUT_SECONDS + 10, TimeUnit.SECONDS) - .build(); - - Request.Builder requestBuilder = new Request.Builder().url(filledUri); - - if (userAgent != null) { - requestBuilder.addHeader("X-Signal-Agent", userAgent); - } - - if (listener != null) { - listener.onConnecting(); - } - - this.connected = false; - this.client = okHttpClient.newWebSocket(requestBuilder.build(), this); - } - } - - public synchronized void disconnect() { - Log.w(TAG, "WSC disconnect()..."); - - if (client != null) { - client.close(1000, "OK"); - client = null; - connected = false; - } - - if (keepAliveSender != null) { - keepAliveSender.shutdown(); - keepAliveSender = null; - } - } - - public synchronized WebSocketRequestMessage readRequest(long timeoutMillis) - throws TimeoutException, IOException - { - if (client == null) { - throw new IOException("Connection closed!"); - } - - long startTime = System.currentTimeMillis(); - - while (client != null && incomingRequests.isEmpty() && elapsedTime(startTime) < timeoutMillis) { - Util.wait(this, Math.max(1, timeoutMillis - elapsedTime(startTime))); - } - - if (incomingRequests.isEmpty() && client == null) throw new IOException("Connection closed!"); - else if (incomingRequests.isEmpty()) throw new TimeoutException("Timeout exceeded"); - else return incomingRequests.removeFirst(); - } - - public synchronized Future> sendRequest(WebSocketRequestMessage request) throws IOException { - if (client == null || !connected) throw new IOException("No connection!"); - - WebSocketMessage message = WebSocketMessage.newBuilder() - .setType(WebSocketMessage.Type.REQUEST) - .setRequest(request) - .build(); - - SettableFuture> future = new SettableFuture>(); - outgoingRequests.put(request.getId(), future); - - if (!client.send(ByteString.of(message.toByteArray()))) { - throw new IOException("Write failed!"); - } - - return future; - } - - public synchronized void sendResponse(WebSocketResponseMessage response) throws IOException { - if (client == null) { - throw new IOException("Connection closed!"); - } - - WebSocketMessage message = WebSocketMessage.newBuilder() - .setType(WebSocketMessage.Type.RESPONSE) - .setResponse(response) - .build(); - - if (!client.send(ByteString.of(message.toByteArray()))) { - throw new IOException("Write failed!"); - } - } - - private synchronized void sendKeepAlive() throws IOException { - if (keepAliveSender != null && client != null) { - byte[] message = WebSocketMessage.newBuilder() - .setType(WebSocketMessage.Type.REQUEST) - .setRequest(WebSocketRequestMessage.newBuilder() - .setId(System.currentTimeMillis()) - .setPath("/v1/keepalive") - .setVerb("GET") - .build()).build() - .toByteArray(); - - if (!client.send(ByteString.of(message))) { - throw new IOException("Write failed!"); - } - } - } - - @Override - public synchronized void onOpen(WebSocket webSocket, Response response) { - if (client != null && keepAliveSender == null) { - Log.w(TAG, "onConnected()"); - attempts = 0; - connected = true; - keepAliveSender = new KeepAliveSender(); - keepAliveSender.start(); - - if (listener != null) listener.onConnected(); - } - } - - @Override - public synchronized void onMessage(WebSocket webSocket, ByteString payload) { - Log.w(TAG, "WSC onMessage()"); - try { - WebSocketMessage message = WebSocketMessage.parseFrom(payload.toByteArray()); - - Log.w(TAG, "Message Type: " + message.getType().getNumber()); - - if (message.getType().getNumber() == WebSocketMessage.Type.REQUEST_VALUE) { - incomingRequests.add(message.getRequest()); - } else if (message.getType().getNumber() == WebSocketMessage.Type.RESPONSE_VALUE) { - SettableFuture> listener = outgoingRequests.get(message.getResponse().getId()); - if (listener != null) listener.set(new Pair(message.getResponse().getStatus(), - new String(message.getResponse().getBody().toByteArray()))); - } - - notifyAll(); - } catch (InvalidProtocolBufferException e) { - Log.w(TAG, e); - } - } - - @Override - public synchronized void onClosed(WebSocket webSocket, int code, String reason) { - Log.w(TAG, "onClose()..."); - this.connected = false; - - Iterator>>> iterator = outgoingRequests.entrySet().iterator(); - - while (iterator.hasNext()) { - Map.Entry>> entry = iterator.next(); - entry.getValue().setException(new IOException("Closed: " + code + ", " + reason)); - iterator.remove(); - } - - if (keepAliveSender != null) { - keepAliveSender.shutdown(); - keepAliveSender = null; - } - - if (listener != null) { - listener.onDisconnected(); - } - - Util.wait(this, Math.min(++attempts * 200, TimeUnit.SECONDS.toMillis(15))); - - if (client != null) { - client.close(1000, "OK"); - client = null; - connected = false; - connect(); - } - - notifyAll(); - } - - @Override - public synchronized void onFailure(WebSocket webSocket, Throwable t, Response response) { - Log.w(TAG, "onFailure()"); - Log.w(TAG, t); - - if (response != null && (response.code() == 401 || response.code() == 403)) { - if (listener != null) listener.onAuthenticationFailure(); - } - - if (client != null) { - onClosed(webSocket, 1000, "OK"); - } - } - - @Override - public void onMessage(WebSocket webSocket, String text) { - Log.w(TAG, "onMessage(text)! " + text); - } - - @Override - public synchronized void onClosing(WebSocket webSocket, int code, String reason) { - Log.w(TAG, "onClosing()!..."); - webSocket.close(1000, "OK"); - } - - private long elapsedTime(long startTime) { - return System.currentTimeMillis() - startTime; - } - - private Pair createTlsSocketFactory(TrustStore trustStore) { - try { - SSLContext context = SSLContext.getInstance("TLS"); - TrustManager[] trustManagers = BlacklistingTrustManager.createFor(trustStore); - context.init(null, trustManagers, null); - - return new Pair(context.getSocketFactory(), (X509TrustManager)trustManagers[0]); - } catch (NoSuchAlgorithmException e) { - throw new AssertionError(e); - } catch (KeyManagementException e) { - throw new AssertionError(e); - } - } - - private class KeepAliveSender extends Thread { - - private AtomicBoolean stop = new AtomicBoolean(false); - - public void run() { - while (!stop.get()) { - try { - sleepTimer.sleep(TimeUnit.SECONDS.toMillis(KEEPALIVE_TIMEOUT_SECONDS)); - - Log.w(TAG, "Sending keep alive..."); - sendKeepAlive(); - } catch (Throwable e) { - Log.w(TAG, e); - } - } - } - - public void shutdown() { - stop.set(true); - } - } - -} diff --git a/libsignal/src/main/java/org/session/libsignal/service/internal/websocket/WebSocketEventListener.java b/libsignal/src/main/java/org/session/libsignal/service/internal/websocket/WebSocketEventListener.java deleted file mode 100644 index 8586be9abf..0000000000 --- a/libsignal/src/main/java/org/session/libsignal/service/internal/websocket/WebSocketEventListener.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.session.libsignal.service.internal.websocket; - -public interface WebSocketEventListener { - - public void onMessage(byte[] payload); - public void onClose(); - public void onConnected(); - -}