Search in sources :

Example 16 with MmsDatabase

use of org.thoughtcrime.securesms.database.MmsDatabase 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 17 with MmsDatabase

use of org.thoughtcrime.securesms.database.MmsDatabase in project Signal-Android by WhisperSystems.

the class MessageSender method sendMediaSelf.

private static void sendMediaSelf(Context context, MasterSecret masterSecret, long messageId, long expiresIn) throws MmsException {
    ExpiringMessageManager expiringMessageManager = ApplicationContext.getInstance(context).getExpiringMessageManager();
    MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
    database.markAsSent(messageId, true);
    database.copyMessageInbox(masterSecret, messageId);
    if (expiresIn > 0) {
        database.markExpireStarted(messageId);
        expiringMessageManager.scheduleDeletion(messageId, true, expiresIn);
    }
}
Also used : ExpiringMessageManager(org.thoughtcrime.securesms.service.ExpiringMessageManager) MmsDatabase(org.thoughtcrime.securesms.database.MmsDatabase)

Aggregations

MmsDatabase (org.thoughtcrime.securesms.database.MmsDatabase)17 Recipients (org.thoughtcrime.securesms.recipients.Recipients)7 OutgoingMediaMessage (org.thoughtcrime.securesms.mms.OutgoingMediaMessage)4 MasterSecretUnion (org.thoughtcrime.securesms.crypto.MasterSecretUnion)3 EncryptingSmsDatabase (org.thoughtcrime.securesms.database.EncryptingSmsDatabase)3 InsertResult (org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult)3 IncomingMediaMessage (org.thoughtcrime.securesms.mms.IncomingMediaMessage)3 MmsException (ws.com.google.android.mms.MmsException)3 Nullable (android.support.annotation.Nullable)2 IOException (java.io.IOException)2 LinkedList (java.util.LinkedList)2 DatabaseAttachment (org.thoughtcrime.securesms.attachments.DatabaseAttachment)2 SmsDatabase (org.thoughtcrime.securesms.database.SmsDatabase)2 CompatMmsConnection (org.thoughtcrime.securesms.mms.CompatMmsConnection)2 ExpiringMessageManager (org.thoughtcrime.securesms.service.ExpiringMessageManager)2 InsecureFallbackApprovalException (org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException)2 UndeliverableMessageException (org.thoughtcrime.securesms.transport.UndeliverableMessageException)2 InvalidMessageException (org.whispersystems.libsignal.InvalidMessageException)2 UntrustedIdentityException (org.whispersystems.signalservice.api.crypto.UntrustedIdentityException)2 Uri (android.net.Uri)1