private void writeAvatarImage(DeviceContact contact)// throws IOException
 {
     if (contact.Avatar != null)
     {
         //writeStream(contact.getAvatar().get().getInputStream());
     }
 }
예제 #2
0
 private void WriteAvatarImage(DeviceContact contact)
 {
     if (contact.Avatar != null)
     {
         WriteStream(contact.Avatar.InputStream);
     }
 }
        private void writeContactDetails(DeviceContact contact)// throws IOException
        {
            //SignalServiceProtos.ContactDetails.Builder contactDetails = SignalServiceProtos.ContactDetails.CreateBuilder();
            //contactDetails.SetNumber(contact.getNumber());

            /*if (contact.getName().HasValue)
             * {
             *  contactDetails.SetName(contact.getName().ForceGetValue());
             * }
             *
             * if (contact.getAvatar().HasValue)
             * {
             *  SignalServiceProtos.ContactDetails.Avatar.Builder avatarBuilder = ContactDetails.Avatar.CreateBuilder();
             *  avatarBuilder.setContentType(contact.getAvatar().ForceGetValue().getContentType());
             *  avatarBuilder.setLength((int)contact.getAvatar().ForceGetValue().getLength());
             *  contactDetails.SetAvatar(avatarBuilder);
             * }
             *
             * byte[] serializedContactDetails = contactDetails.Build().ToByteArray();
             *
             * writeVarint32(serializedContactDetails.Length);
             * output.write(serializedContactDetails);*/
            throw new NotImplementedException();
        }
 public void write(DeviceContact contact)// throws IOException
 {
     writeContactDetails(contact);
     writeAvatarImage(contact);
 }
예제 #5
0
        private void WriteContactDetails(DeviceContact contact)
        {
            ContactDetails contactDetails = new ContactDetails();

            if (contact.Address.Uuid.HasValue)
            {
                contactDetails.Uuid = contact.Address.Uuid.Value.ToString();
            }

            if (contact.Address.GetNumber() != null)
            {
                contactDetails.Number = contact.Address.GetNumber();
            }

            if (contact.Name != null)
            {
                contactDetails.Name = contact.Name;
            }

            if (contact.Avatar != null)
            {
                ContactDetails.Types.Avatar avatarBuilder = new ContactDetails.Types.Avatar();
                avatarBuilder.ContentType = contact.Avatar.ContentType;
                avatarBuilder.Length      = (uint)contact.Avatar.Length;
                contactDetails.Avatar     = avatarBuilder;
            }

            if (contact.Color != null)
            {
                contactDetails.Color = contact.Color;
            }

            if (contact.Verified != null)
            {
                Verified.Types.State state;

                switch (contact.Verified.Verified)
                {
                case VerifiedMessage.VerifiedState.Verified: state = Verified.Types.State.Verified; break;

                case VerifiedMessage.VerifiedState.Unverified: state = Verified.Types.State.Unverified; break;

                default: state = Verified.Types.State.Default; break;
                }

                Verified verifiedBuilder = new Verified()
                {
                    IdentityKey = ByteString.CopyFrom(contact.Verified.IdentityKey.serialize()),
                    State       = state
                };

                if (contact.Verified.Destination.Uuid.HasValue)
                {
                    verifiedBuilder.DestinationUuid = contact.Verified.Destination.Uuid.Value.ToString();
                }

                if (contact.Verified.Destination.GetNumber() != null)
                {
                    verifiedBuilder.DestinationE164 = contact.Verified.Destination.GetNumber();
                }

                contactDetails.Verified = verifiedBuilder;
            }

            if (contact.ProfileKey != null)
            {
                contactDetails.ProfileKey = ByteString.CopyFrom(contact.ProfileKey);
            }

            if (contact.ExpirationTimer.HasValue)
            {
                contactDetails.ExpireTimer = contact.ExpirationTimer.Value;
            }

            contactDetails.Blocked = contact.Blocked;

            byte[] serializedContactDetails = contactDetails.ToByteArray();

            WriteVarint32(serializedContactDetails.Length);
            output.Write(serializedContactDetails, 0, serializedContactDetails.Length);
        }
예제 #6
0
 public void Write(DeviceContact contact)
 {
     WriteContactDetails(contact);
     WriteAvatarImage(contact);
 }