package org.thoughtcrime.securesms.jobs; import android.content.Context; import android.util.Log; import org.thoughtcrime.securesms.crypto.MasterSecret; import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.TextSecureDirectory; import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement; import org.thoughtcrime.securesms.mms.PartAuthority; import org.thoughtcrime.securesms.notifications.MessageNotifier; import org.thoughtcrime.securesms.recipients.Recipients; import org.thoughtcrime.securesms.util.GroupUtil; import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.Util; import org.whispersystems.jobqueue.JobParameters; import org.whispersystems.jobqueue.requirements.NetworkRequirement; import org.whispersystems.libaxolotl.util.guava.Optional; import org.whispersystems.textsecure.api.messages.TextSecureAttachment; import org.whispersystems.textsecure.api.messages.TextSecureAttachmentStream; import org.whispersystems.textsecure.api.push.TextSecureAddress; import org.whispersystems.textsecure.api.util.InvalidNumberException; import java.io.IOException; import java.io.InputStream; import java.util.LinkedList; import java.util.List; import ws.com.google.android.mms.ContentType; import ws.com.google.android.mms.pdu.PduPart; import ws.com.google.android.mms.pdu.SendReq; public abstract class PushSendJob extends SendJob { private static final String TAG = PushSendJob.class.getSimpleName(); protected PushSendJob(Context context, JobParameters parameters) { super(context, parameters); } protected static JobParameters constructParameters(Context context, String destination) { JobParameters.Builder builder = JobParameters.newBuilder(); builder.withPersistence(); builder.withGroupId(destination); builder.withRequirement(new MasterSecretRequirement(context)); builder.withRequirement(new NetworkRequirement(context)); builder.withRetryCount(5); return builder.create(); } protected TextSecureAddress getPushAddress(String number) throws InvalidNumberException { String e164number = Util.canonicalizeNumber(context, number); String relay = TextSecureDirectory.getInstance(context).getRelay(e164number); return new TextSecureAddress(e164number, Optional.fromNullable(relay)); } protected List getAttachments(final MasterSecret masterSecret, final SendReq message) { List attachments = new LinkedList<>(); for (int i=0;i