Search in sources :

Example 1 with JobManager

use of org.whispersystems.jobqueue.JobManager in project Signal-Android by WhisperSystems.

the class PushReceivedJob method handleMessage.

private void handleMessage(SignalServiceEnvelope envelope, boolean sendExplicitReceipt) {
    Recipients recipients = RecipientFactory.getRecipientsFromString(context, envelope.getSource(), false);
    JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
    if (!recipients.isBlocked()) {
        long messageId = DatabaseFactory.getPushDatabase(context).insert(envelope);
        jobManager.add(new PushDecryptJob(context, messageId, envelope.getSource()));
    } else {
        Log.w(TAG, "*** Received blocked push message, ignoring...");
    }
    if (sendExplicitReceipt) {
        jobManager.add(new DeliveryReceiptJob(context, envelope.getSource(), envelope.getTimestamp(), envelope.getRelay()));
    }
}
Also used : Recipients(org.thoughtcrime.securesms.recipients.Recipients) JobManager(org.whispersystems.jobqueue.JobManager)

Example 2 with JobManager

use of org.whispersystems.jobqueue.JobManager in project Signal-Android by WhisperSystems.

the class MessageSender method sendMediaPush.

private static void sendMediaPush(Context context, Recipients recipients, long messageId) {
    JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
    jobManager.add(new PushMediaSendJob(context, messageId, recipients.getPrimaryRecipient().getNumber()));
}
Also used : PushMediaSendJob(org.thoughtcrime.securesms.jobs.PushMediaSendJob) JobManager(org.whispersystems.jobqueue.JobManager)

Example 3 with JobManager

use of org.whispersystems.jobqueue.JobManager in project Signal-Android by WhisperSystems.

the class MessageSender method sendTextPush.

private static void sendTextPush(Context context, Recipients recipients, long messageId) {
    JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
    jobManager.add(new PushTextSendJob(context, messageId, recipients.getPrimaryRecipient().getNumber()));
}
Also used : JobManager(org.whispersystems.jobqueue.JobManager) PushTextSendJob(org.thoughtcrime.securesms.jobs.PushTextSendJob)

Example 4 with JobManager

use of org.whispersystems.jobqueue.JobManager in project Signal-Android by WhisperSystems.

the class SmsDeliveryListener method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
    long messageId = intent.getLongExtra("message_id", -1);
    switch(intent.getAction()) {
        case SENT_SMS_ACTION:
            int result = getResultCode();
            jobManager.add(new SmsSentJob(context, messageId, SENT_SMS_ACTION, result));
            break;
        case DELIVERED_SMS_ACTION:
            byte[] pdu = intent.getByteArrayExtra("pdu");
            if (pdu == null) {
                Log.w(TAG, "No PDU in delivery receipt!");
                break;
            }
            SmsMessage message = SmsMessage.createFromPdu(pdu);
            if (message == null) {
                Log.w(TAG, "Delivery receipt failed to parse!");
                break;
            }
            jobManager.add(new SmsSentJob(context, messageId, DELIVERED_SMS_ACTION, message.getStatus()));
            break;
        default:
            Log.w(TAG, "Unknown action: " + intent.getAction());
    }
}
Also used : SmsSentJob(org.thoughtcrime.securesms.jobs.SmsSentJob) SmsMessage(android.telephony.SmsMessage) JobManager(org.whispersystems.jobqueue.JobManager)

Example 5 with JobManager

use of org.whispersystems.jobqueue.JobManager in project Signal-Android by WhisperSystems.

the class MessageSender method sendGroupPush.

private static void sendGroupPush(Context context, Recipients recipients, long messageId, long filterRecipientId) {
    JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
    jobManager.add(new PushGroupSendJob(context, messageId, recipients.getPrimaryRecipient().getNumber(), filterRecipientId));
}
Also used : PushGroupSendJob(org.thoughtcrime.securesms.jobs.PushGroupSendJob) JobManager(org.whispersystems.jobqueue.JobManager)

Aggregations

JobManager (org.whispersystems.jobqueue.JobManager)7 SmsMessage (android.telephony.SmsMessage)1 MmsSendJob (org.thoughtcrime.securesms.jobs.MmsSendJob)1 PushGroupSendJob (org.thoughtcrime.securesms.jobs.PushGroupSendJob)1 PushMediaSendJob (org.thoughtcrime.securesms.jobs.PushMediaSendJob)1 PushTextSendJob (org.thoughtcrime.securesms.jobs.PushTextSendJob)1 SmsSendJob (org.thoughtcrime.securesms.jobs.SmsSendJob)1 SmsSentJob (org.thoughtcrime.securesms.jobs.SmsSentJob)1 Recipients (org.thoughtcrime.securesms.recipients.Recipients)1