Search in sources :

Example 6 with MasterSecretUnion

use of org.thoughtcrime.securesms.crypto.MasterSecretUnion in project Signal-Android by WhisperSystems.

the class MessageSender method send.

public static long send(final Context context, final MasterSecret masterSecret, final OutgoingMediaMessage message, final long threadId, final boolean forceSms) {
    try {
        ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
        MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
        long allocatedThreadId;
        if (threadId == -1) {
            allocatedThreadId = threadDatabase.getThreadIdFor(message.getRecipients(), message.getDistributionType());
        } else {
            allocatedThreadId = threadId;
        }
        Recipients recipients = message.getRecipients();
        long messageId = database.insertMessageOutbox(new MasterSecretUnion(masterSecret), message, allocatedThreadId, forceSms);
        sendMediaMessage(context, masterSecret, recipients, forceSms, messageId, message.getExpiresIn());
        return allocatedThreadId;
    } catch (MmsException e) {
        Log.w(TAG, e);
        return threadId;
    }
}
Also used : MasterSecretUnion(org.thoughtcrime.securesms.crypto.MasterSecretUnion) MmsException(ws.com.google.android.mms.MmsException) Recipients(org.thoughtcrime.securesms.recipients.Recipients) ThreadDatabase(org.thoughtcrime.securesms.database.ThreadDatabase) MmsDatabase(org.thoughtcrime.securesms.database.MmsDatabase)

Example 7 with MasterSecretUnion

use of org.thoughtcrime.securesms.crypto.MasterSecretUnion in project Signal-Android by WhisperSystems.

the class MessageSender method send.

public static long send(final Context context, final MasterSecret masterSecret, final OutgoingTextMessage message, final long threadId, final boolean forceSms) {
    EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
    Recipients recipients = message.getRecipients();
    boolean keyExchange = message.isKeyExchange();
    long allocatedThreadId;
    if (threadId == -1) {
        allocatedThreadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);
    } else {
        allocatedThreadId = threadId;
    }
    long messageId = database.insertMessageOutbox(new MasterSecretUnion(masterSecret), allocatedThreadId, message, forceSms, System.currentTimeMillis());
    sendTextMessage(context, recipients, forceSms, keyExchange, messageId, message.getExpiresIn());
    return allocatedThreadId;
}
Also used : MasterSecretUnion(org.thoughtcrime.securesms.crypto.MasterSecretUnion) Recipients(org.thoughtcrime.securesms.recipients.Recipients) EncryptingSmsDatabase(org.thoughtcrime.securesms.database.EncryptingSmsDatabase)

Aggregations

MasterSecretUnion (org.thoughtcrime.securesms.crypto.MasterSecretUnion)7 MmsDatabase (org.thoughtcrime.securesms.database.MmsDatabase)3 LinkedList (java.util.LinkedList)2 Attachment (org.thoughtcrime.securesms.attachments.Attachment)2 MasterSecret (org.thoughtcrime.securesms.crypto.MasterSecret)2 EncryptingSmsDatabase (org.thoughtcrime.securesms.database.EncryptingSmsDatabase)2 InsertResult (org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult)2 Recipients (org.thoughtcrime.securesms.recipients.Recipients)2 MmsException (ws.com.google.android.mms.MmsException)2 ContentValues (android.content.ContentValues)1 Uri (android.net.Uri)1 DatabaseAttachment (org.thoughtcrime.securesms.attachments.DatabaseAttachment)1 MmsNotificationAttachment (org.thoughtcrime.securesms.attachments.MmsNotificationAttachment)1 UriAttachment (org.thoughtcrime.securesms.attachments.UriAttachment)1 PushDatabase (org.thoughtcrime.securesms.database.PushDatabase)1 SmsDatabase (org.thoughtcrime.securesms.database.SmsDatabase)1 ThreadDatabase (org.thoughtcrime.securesms.database.ThreadDatabase)1 MessageRecord (org.thoughtcrime.securesms.database.model.MessageRecord)1 SmsMessageRecord (org.thoughtcrime.securesms.database.model.SmsMessageRecord)1 IncomingMediaMessage (org.thoughtcrime.securesms.mms.IncomingMediaMessage)1