private void writeGroupDetails(DeviceGroup group)// throws IOException
        {
            GroupDetails groupDetails = new GroupDetails { };
            groupDetails.Id = ByteString.CopyFrom(group.getId());

            if (group.getName().HasValue)
            {
                groupDetails.Name = group.getName().Match(e => e, () => { throw new Exception(); });
            }

            if (group.getAvatar().HasValue)
            {
                GroupDetails.Types.Avatar avatarBuilder = new GroupDetails.Types.Avatar { };
                SignalServiceAttachmentStream avatar = group.getAvatar().Match(e => e, () => { throw new Exception(); });
                avatarBuilder.ContentType = avatar.getContentType();
                avatarBuilder.Length = (uint)avatar.getLength();
                groupDetails.Avatar = avatarBuilder;
            }

            groupDetails.Members.AddRange(group.getMembers());
            groupDetails.Active = group.isActive();

            byte[] serializedContactDetails = groupDetails.ToByteArray();

            writeVarint32(serializedContactDetails.Length);
            output.Write(serializedContactDetails, 0, serializedContactDetails.Length);
        }
Esempio n. 2
0
        private void writeGroupDetails(DeviceGroup group)// throws IOException
        {
            SignalServiceProtos.GroupDetails.Builder groupDetails = SignalServiceProtos.GroupDetails.CreateBuilder();
            groupDetails.SetId(ByteString.CopyFrom(group.getId()));

            if (group.getName().HasValue)
            {
                groupDetails.SetName(group.getName().Match(e => e, () => { throw new Exception(); }));
            }

            if (group.getAvatar().HasValue)
            {
                SignalServiceProtos.GroupDetails.Types.Avatar.Builder avatarBuilder = SignalServiceProtos.GroupDetails.Types.Avatar.CreateBuilder();
                SignalServiceAttachmentStream avatar = group.getAvatar().Match(e => e, () => { throw new Exception(); });
                avatarBuilder.SetContentType(avatar.getContentType());
                avatarBuilder.SetLength((uint)avatar.getLength());
                groupDetails.SetAvatar(avatarBuilder);
            }

            groupDetails.AddRangeMembers(group.getMembers());
            groupDetails.SetActive(group.isActive());

            byte[] serializedContactDetails = groupDetails.Build().ToByteArray();

            writeVarint32(serializedContactDetails.Length);
            output.Write(serializedContactDetails, 0, serializedContactDetails.Length);
        }