private TextSecureDataMessage createTextSecureMessage(TextSecureEnvelope envelope, DataMessage content)
        {
            TextSecureGroup groupInfo = createGroupInfo(envelope, content);
            LinkedList <TextSecureAttachment> attachments = new LinkedList <TextSecureAttachment>();
            bool endSession = ((content.Flags & (uint)DataMessage.Types.Flags.END_SESSION) != 0);

            foreach (AttachmentPointer pointer in content.AttachmentsList)
            {
                attachments.AddLast(new TextSecureAttachmentPointer(pointer.Id,
                                                                    pointer.ContentType,
                                                                    pointer.Key.ToByteArray(),
                                                                    envelope.getRelay(),
                                                                    pointer.HasSize ? new May <uint>(pointer.Size) : May <uint> .NoValue,
                                                                    pointer.HasThumbnail ? new May <byte[]>(pointer.Thumbnail.ToByteArray()) : May <byte[]> .NoValue));
            }

            return(new TextSecureDataMessage(envelope.getTimestamp(), groupInfo, attachments,
                                             content.Body, endSession));
        }
Example #2
0
        public long Insert(TextSecureEnvelope envelope)
        {
            // TODO check if exists
            var push = new Push()
            {
                Type          = envelope.getType(),
                Source        = envelope.getSource(),
                DeviceId      = envelope.getSourceDevice(),
                LegacyMessage = envelope.hasLegacyMessage() ? Base64.encodeBytes(envelope.getLegacyMessage()) : "",
                Content       = envelope.hasContent() ? Base64.encodeBytes(envelope.getContent()) : "",
                Timestamp     = TimeUtil.GetDateTime(envelope.getTimestamp())
            };

            try
            {
                conn.Insert(push);
            } catch (Exception e) { Debug.WriteLine(e.Message); }


            return(push.PushId);
        }
Example #3
0
 private void handleReceipt(TextSecureEnvelope envelope)
 {
     Debug.WriteLine($"Received receipt: (XXXXX, {envelope.getTimestamp()})");
     DatabaseFactory.getMessageDatabase().incrementDeliveryReceiptCount(envelope.getSource(),
                                                                        (long)envelope.getTimestamp());
 }