public static SignalServiceSyncMessage ForVerified(VerifiedMessage verifiedMessage) { return(new SignalServiceSyncMessage(null, null, null, null, null, null, verifiedMessage, null)); }
private SignalServiceSyncMessage(SentTranscriptMessage sent, ContactsMessage contacts, SignalServiceAttachment groups, BlockedListMessage blockedList, RequestMessage request, List <ReadMessage> reads, VerifiedMessage verified, ConfigurationMessage configuration) { Sent = sent; Contacts = contacts; Groups = groups; BlockedList = blockedList; Request = request; Reads = reads; Verified = verified; Configuration = configuration; }
public DeviceContact Read()// throws IOException { int detailsLength = ReadRawVarint32(); if (detailsLength == -1) { return(null); } byte[] detailsSerialized = new byte[(int)detailsLength]; Util.ReadFully(InputStream, detailsSerialized); var details = ContactDetails.Parser.ParseFrom(detailsSerialized); string number = details.Number; string name = details.Name; SignalServiceAttachmentStream avatar = null; string color = details.ColorOneofCase == ContactDetails.ColorOneofOneofCase.Color ? details.Color : null; VerifiedMessage verified = null; byte[] profileKey = null; bool blocked = false; uint? expireTimer = null; if (details.AvatarOneofCase == ContactDetails.AvatarOneofOneofCase.Avatar) { long avatarLength = details.Avatar.Length; Stream avatarStream = new LimitedInputStream(InputStream, avatarLength); String avatarContentType = details.Avatar.ContentType; avatar = new SignalServiceAttachmentStream(avatarStream, avatarContentType, avatarLength, null, false, null); } if (details.VerifiedOneofCase == ContactDetails.VerifiedOneofOneofCase.Verified) { string destination = details.Verified.Destination; IdentityKey identityKey = new IdentityKey(details.Verified.IdentityKey.ToByteArray(), 0); VerifiedState state; switch (details.Verified.State) { case Verified.Types.State.Verified: state = VerifiedState.Verified; break; case Verified.Types.State.Unverified: state = VerifiedState.Unverified; break; case Verified.Types.State.Default: state = VerifiedState.Default; break; default: throw new InvalidMessageException("Unknown state: " + details.Verified.State); } verified = new VerifiedMessage(destination, identityKey, state, Util.CurrentTimeMillis()); } if (details.ProfileKeyOneofCase == ContactDetails.ProfileKeyOneofOneofCase.ProfileKey) { profileKey = details.ProfileKey.ToByteArray(); } if (details.ExpireTimerOneofCase == ContactDetails.ExpireTimerOneofOneofCase.ExpireTimer && details.ExpireTimer > 0) { expireTimer = details.ExpireTimer; } return(new DeviceContact(number, name, avatar, color, verified, profileKey, blocked, expireTimer)); }
public DeviceContact?Read() { int detailsLength = ReadRawVarint32(); if (detailsLength == -1) { return(null); } byte[] detailsSerialized = new byte[(int)detailsLength]; Util.ReadFully(inputStream, detailsSerialized); var details = ContactDetails.Parser.ParseFrom(detailsSerialized); SignalServiceAddress address = new SignalServiceAddress(UuidUtil.ParseOrNull(details.Uuid), details.Number); string?name = details.Name; SignalServiceAttachmentStream?avatar = null; string? color = details.HasColor ? details.Color : null; VerifiedMessage?verified = null; byte[]? profileKey = null; bool blocked = false; uint?expireTimer = null; if (details.Avatar != null) { long avatarLength = details.Avatar.Length; Stream avatarStream = new LimitedInputStream(inputStream, avatarLength); string avatarContentType = details.Avatar.ContentType; avatar = new SignalServiceAttachmentStream(avatarStream, avatarContentType, avatarLength, null, false, null); } if (details.Verified != null) { try { IdentityKey identityKey = new IdentityKey(details.Verified.IdentityKey.ToByteArray(), 0); SignalServiceAddress destination = new SignalServiceAddress(UuidUtil.ParseOrNull(details.Verified.DestinationUuid), details.Verified.Destination); VerifiedState state; switch (details.Verified.State) { case Verified.Types.State.Verified: state = VerifiedState.Verified; break; case Verified.Types.State.Unverified: state = VerifiedState.Unverified; break; case Verified.Types.State.Default: state = VerifiedState.Default; break; default: throw new InvalidMessageException("Unknown state: " + details.Verified.State); } verified = new VerifiedMessage(destination, identityKey, state, Util.CurrentTimeMillis()); } catch (Exception ex) when(ex is InvalidKeyException || ex is InvalidMessageException) { logger.LogWarning(new EventId(), ex, ""); verified = null; } } if (details.HasProfileKey) { profileKey = details.ProfileKey.ToByteArray(); } if (details.HasExpireTimer && details.ExpireTimer > 0) { expireTimer = details.ExpireTimer; } return(new DeviceContact(address, name, avatar, color, verified, profileKey, blocked, expireTimer)); }