private async Task deliver(TextMessageRecord message)
        {
            try
            {
                SignalServiceAddress     address           = getPushAddress(message.IndividualRecipient.Number);
                SignalServiceDataMessage textSecureMessage = SignalServiceDataMessage.newBuilder()
                                                             .withTimestamp(TimeUtil.GetUnixTimestampMillis(message.DateSent))
                                                             .withBody(message.Body.Body)
                                                             .asEndSessionMessage(message.IsEndSession)
                                                             .build();

                Debug.WriteLine("TextSendTask deliver");
                await messageSender.sendMessage(address, textSecureMessage);
            }
            catch (InvalidNumberException /*| UnregisteredUserException e*/)
            {
                //Log.w(TAG, e);
                //throw new InsecureFallbackApprovalException(e);
            }
            catch (Exception)
            {
                Log.Warn("Delivery of message failed");
                OnCanceled();
            }
        }
Exemple #2
0
        public long InsertMessageOutbox(long threadId, OutgoingTextMessage message, DateTime date)
        {
            var type = MessageTypes.BASE_OUTBOX_TYPE;

            if (message.IsKeyExchange)
            {
                type |= MessageTypes.KEY_EXCHANGE_BIT;
            }
            else if (message.IsSecureMessage)
            {
                type |= MessageTypes.SECURE_MESSAGE_BIT;
            }
            else if (message.IsEndSession)
            {
                type |= MessageTypes.END_SESSION_BIT;
            }

            var insert = new Message();

            insert.Address      = message.Recipients.PrimaryRecipient.Number; // PhoneNumberUtils.formatNumber(message.Recipients.getPrimaryRecipient().getNumber()); // TODO:
            insert.ThreadId     = threadId;
            insert.Body         = message.MessageBody;
            insert.DateReceived = TimeUtil.GetDateTimeMillis();
            insert.DateSent     = date;
            insert.Read         = true;
            insert.Type         = type;

            var tmp = new TextMessageRecord(insert); // TODO: debug

            conn.Insert(insert);

            long messageId = insert.MessageId;

            DatabaseFactory.getThreadDatabase().Update(threadId);
            notifyConversationListeners(threadId);
            //jobManager.add(new TrimThreadJob(context, threadId));

            return(messageId);
        }
Exemple #3
0
        public long InsertMessageOutbox(long threadId, OutgoingTextMessage message, DateTime date)
        {
            var type = MessageTypes.BASE_OUTBOX_TYPE;

            if (message.IsKeyExchange) type |= MessageTypes.KEY_EXCHANGE_BIT;
            else if (message.IsSecureMessage) type |= MessageTypes.SECURE_MESSAGE_BIT;
            else if (message.IsEndSession) type |= MessageTypes.END_SESSION_BIT;

            var insert = new Message();
            insert.Address = message.Recipients.PrimaryRecipient.Number; // PhoneNumberUtils.formatNumber(message.Recipients.getPrimaryRecipient().getNumber()); // TODO: 
            insert.ThreadId = threadId;
            insert.Body = message.MessageBody;
            insert.DateReceived = TimeUtil.GetDateTimeMillis();
            insert.DateSent = date;
            insert.Read = true;
            insert.Type = type;

            var tmp = new TextMessageRecord(insert); // TODO: debug

            conn.Insert(insert);

            long messageId = insert.MessageId;

            DatabaseFactory.getThreadDatabase().Update(threadId);
            notifyConversationListeners(threadId);
            //jobManager.add(new TrimThreadJob(context, threadId));

            return messageId;
        }
Exemple #4
0
        public void MarkAsSending(long id)
        {
            UpdateTypeBitmask(id, MessageTypes.BASE_TYPE_MASK, MessageTypes.BASE_SENDING_TYPE);
            var tmp = new TextMessageRecord(Get(id)); // TODO: debug

        }
        private async Task deliver(TextMessageRecord message)
        {
            try
            {
                TextSecureAddress address = getPushAddress(message.IndividualRecipient.Number);
                TextSecureDataMessage textSecureMessage = TextSecureDataMessage.newBuilder()
                    .withTimestamp((ulong) TimeUtil.GetUnixTimestampMillis(message.DateSent))
                    .withBody(message.Body.Body)
                    .asEndSessionMessage(message.IsEndSession)
                    .build();

                Debug.WriteLine("TextSendTask deliver");
                await messageSender.sendMessage(address, textSecureMessage);
            }
            catch (InvalidNumberException e /*| UnregisteredUserException e*/)
            {
                //Log.w(TAG, e);
                //throw new InsecureFallbackApprovalException(e);
            }
            catch (Exception e)
            {
                Log.Warn("Delivery of message failed");
                OnCanceled();
            }
        }
Exemple #6
0
 public void MarkAsSending(long id)
 {
     UpdateTypeBitmask(id, MessageTypes.BASE_TYPE_MASK, MessageTypes.BASE_SENDING_TYPE);
     var tmp = new TextMessageRecord(Get(id)); // TODO: debug
 }