mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
Merge branch 'refactor' of https://github.com/RyanRory/loki-messenger-android into refactor
This commit is contained in:
commit
e6fd57fa58
@ -1,347 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms.jobmanager;
|
|
||||||
|
|
||||||
import android.os.Parcelable;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.util.ParcelableUtil;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
// TODO AC: For now parcelable objects utilize byteArrays field to store their data into.
|
|
||||||
// Introduce a dedicated Map<String, byte[]> field specifically for parcelable needs.
|
|
||||||
public class Data {
|
|
||||||
|
|
||||||
public static final Data EMPTY = new Data.Builder().build();
|
|
||||||
|
|
||||||
@JsonProperty private final Map<String, String> strings;
|
|
||||||
@JsonProperty private final Map<String, String[]> stringArrays;
|
|
||||||
@JsonProperty private final Map<String, Integer> integers;
|
|
||||||
@JsonProperty private final Map<String, int[]> integerArrays;
|
|
||||||
@JsonProperty private final Map<String, Long> longs;
|
|
||||||
@JsonProperty private final Map<String, long[]> longArrays;
|
|
||||||
@JsonProperty private final Map<String, Float> floats;
|
|
||||||
@JsonProperty private final Map<String, float[]> floatArrays;
|
|
||||||
@JsonProperty private final Map<String, Double> doubles;
|
|
||||||
@JsonProperty private final Map<String, double[]> doubleArrays;
|
|
||||||
@JsonProperty private final Map<String, Boolean> booleans;
|
|
||||||
@JsonProperty private final Map<String, boolean[]> booleanArrays;
|
|
||||||
@JsonProperty private final Map<String, byte[]> byteArrays;
|
|
||||||
|
|
||||||
public Data(@JsonProperty("strings") @NonNull Map<String, String> strings,
|
|
||||||
@JsonProperty("stringArrays") @NonNull Map<String, String[]> stringArrays,
|
|
||||||
@JsonProperty("integers") @NonNull Map<String, Integer> integers,
|
|
||||||
@JsonProperty("integerArrays") @NonNull Map<String, int[]> integerArrays,
|
|
||||||
@JsonProperty("longs") @NonNull Map<String, Long> longs,
|
|
||||||
@JsonProperty("longArrays") @NonNull Map<String, long[]> longArrays,
|
|
||||||
@JsonProperty("floats") @NonNull Map<String, Float> floats,
|
|
||||||
@JsonProperty("floatArrays") @NonNull Map<String, float[]> floatArrays,
|
|
||||||
@JsonProperty("doubles") @NonNull Map<String, Double> doubles,
|
|
||||||
@JsonProperty("doubleArrays") @NonNull Map<String, double[]> doubleArrays,
|
|
||||||
@JsonProperty("booleans") @NonNull Map<String, Boolean> booleans,
|
|
||||||
@JsonProperty("booleanArrays") @NonNull Map<String, boolean[]> booleanArrays,
|
|
||||||
@JsonProperty("byteArrays") @NonNull Map<String, byte[]> byteArrays)
|
|
||||||
{
|
|
||||||
this.strings = strings;
|
|
||||||
this.stringArrays = stringArrays;
|
|
||||||
this.integers = integers;
|
|
||||||
this.integerArrays = integerArrays;
|
|
||||||
this.longs = longs;
|
|
||||||
this.longArrays = longArrays;
|
|
||||||
this.floats = floats;
|
|
||||||
this.floatArrays = floatArrays;
|
|
||||||
this.doubles = doubles;
|
|
||||||
this.doubleArrays = doubleArrays;
|
|
||||||
this.booleans = booleans;
|
|
||||||
this.booleanArrays = booleanArrays;
|
|
||||||
this.byteArrays = byteArrays;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasString(@NonNull String key) {
|
|
||||||
return strings.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getString(@NonNull String key) {
|
|
||||||
throwIfAbsent(strings, key);
|
|
||||||
return strings.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStringOrDefault(@NonNull String key, String defaultValue) {
|
|
||||||
if (hasString(key)) return getString(key);
|
|
||||||
else return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasStringArray(@NonNull String key) {
|
|
||||||
return stringArrays.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getStringArray(@NonNull String key) {
|
|
||||||
throwIfAbsent(stringArrays, key);
|
|
||||||
return stringArrays.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasInt(@NonNull String key) {
|
|
||||||
return integers.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getInt(@NonNull String key) {
|
|
||||||
throwIfAbsent(integers, key);
|
|
||||||
return integers.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIntOrDefault(@NonNull String key, int defaultValue) {
|
|
||||||
if (hasInt(key)) return getInt(key);
|
|
||||||
else return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasIntegerArray(@NonNull String key) {
|
|
||||||
return integerArrays.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] getIntegerArray(@NonNull String key) {
|
|
||||||
throwIfAbsent(integerArrays, key);
|
|
||||||
return integerArrays.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasLong(@NonNull String key) {
|
|
||||||
return longs.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getLong(@NonNull String key) {
|
|
||||||
throwIfAbsent(longs, key);
|
|
||||||
return longs.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getLongOrDefault(@NonNull String key, long defaultValue) {
|
|
||||||
if (hasLong(key)) return getLong(key);
|
|
||||||
else return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasLongArray(@NonNull String key) {
|
|
||||||
return longArrays.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public long[] getLongArray(@NonNull String key) {
|
|
||||||
throwIfAbsent(longArrays, key);
|
|
||||||
return longArrays.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasFloat(@NonNull String key) {
|
|
||||||
return floats.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getFloat(@NonNull String key) {
|
|
||||||
throwIfAbsent(floats, key);
|
|
||||||
return floats.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getFloatOrDefault(@NonNull String key, float defaultValue) {
|
|
||||||
if (hasFloat(key)) return getFloat(key);
|
|
||||||
else return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasFloatArray(@NonNull String key) {
|
|
||||||
return floatArrays.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public float[] getFloatArray(@NonNull String key) {
|
|
||||||
throwIfAbsent(floatArrays, key);
|
|
||||||
return floatArrays.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasDouble(@NonNull String key) {
|
|
||||||
return doubles.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getDouble(@NonNull String key) {
|
|
||||||
throwIfAbsent(doubles, key);
|
|
||||||
return doubles.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getDoubleOrDefault(@NonNull String key, double defaultValue) {
|
|
||||||
if (hasDouble(key)) return getDouble(key);
|
|
||||||
else return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasDoubleArray(@NonNull String key) {
|
|
||||||
return floatArrays.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double[] getDoubleArray(@NonNull String key) {
|
|
||||||
throwIfAbsent(doubleArrays, key);
|
|
||||||
return doubleArrays.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasBoolean(@NonNull String key) {
|
|
||||||
return booleans.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getBoolean(@NonNull String key) {
|
|
||||||
throwIfAbsent(booleans, key);
|
|
||||||
return booleans.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getBooleanOrDefault(@NonNull String key, boolean defaultValue) {
|
|
||||||
if (hasBoolean(key)) return getBoolean(key);
|
|
||||||
else return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasBooleanArray(@NonNull String key) {
|
|
||||||
return booleanArrays.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean[] getBooleanArray(@NonNull String key) {
|
|
||||||
throwIfAbsent(booleanArrays, key);
|
|
||||||
return booleanArrays.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasByteArray(@NonNull String key) {
|
|
||||||
return byteArrays.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getByteArray(@NonNull String key) {
|
|
||||||
throwIfAbsent(byteArrays, key);
|
|
||||||
return byteArrays.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasParcelable(@NonNull String key) {
|
|
||||||
return byteArrays.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends Parcelable> T getParcelable(@NonNull String key, @NonNull Parcelable.Creator<T> creator) {
|
|
||||||
throwIfAbsent(byteArrays, key);
|
|
||||||
byte[] bytes = byteArrays.get(key);
|
|
||||||
return ParcelableUtil.unmarshall(bytes, creator);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void throwIfAbsent(@NonNull Map map, @NonNull String key) {
|
|
||||||
if (!map.containsKey(key)) {
|
|
||||||
throw new IllegalStateException("Tried to retrieve a value with key '" + key + "', but it wasn't present.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static class Builder {
|
|
||||||
|
|
||||||
private final Map<String, String> strings = new HashMap<>();
|
|
||||||
private final Map<String, String[]> stringArrays = new HashMap<>();
|
|
||||||
private final Map<String, Integer> integers = new HashMap<>();
|
|
||||||
private final Map<String, int[]> integerArrays = new HashMap<>();
|
|
||||||
private final Map<String, Long> longs = new HashMap<>();
|
|
||||||
private final Map<String, long[]> longArrays = new HashMap<>();
|
|
||||||
private final Map<String, Float> floats = new HashMap<>();
|
|
||||||
private final Map<String, float[]> floatArrays = new HashMap<>();
|
|
||||||
private final Map<String, Double> doubles = new HashMap<>();
|
|
||||||
private final Map<String, double[]> doubleArrays = new HashMap<>();
|
|
||||||
private final Map<String, Boolean> booleans = new HashMap<>();
|
|
||||||
private final Map<String, boolean[]> booleanArrays = new HashMap<>();
|
|
||||||
private final Map<String, byte[]> byteArrays = new HashMap<>();
|
|
||||||
|
|
||||||
public Builder putString(@NonNull String key, @Nullable String value) {
|
|
||||||
strings.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder putStringArray(@NonNull String key, @NonNull String[] value) {
|
|
||||||
stringArrays.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder putInt(@NonNull String key, int value) {
|
|
||||||
integers.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder putIntArray(@NonNull String key, @NonNull int[] value) {
|
|
||||||
integerArrays.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder putLong(@NonNull String key, long value) {
|
|
||||||
longs.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder putLongArray(@NonNull String key, @NonNull long[] value) {
|
|
||||||
longArrays.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder putFloat(@NonNull String key, float value) {
|
|
||||||
floats.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder putFloatArray(@NonNull String key, @NonNull float[] value) {
|
|
||||||
floatArrays.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder putDouble(@NonNull String key, double value) {
|
|
||||||
doubles.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder putDoubleArray(@NonNull String key, @NonNull double[] value) {
|
|
||||||
doubleArrays.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder putBoolean(@NonNull String key, boolean value) {
|
|
||||||
booleans.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder putBooleanArray(@NonNull String key, @NonNull boolean[] value) {
|
|
||||||
booleanArrays.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder putByteArray(@NonNull String key, @NonNull byte[] value) {
|
|
||||||
byteArrays.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder putParcelable(@NonNull String key, @NonNull Parcelable value) {
|
|
||||||
byte[] bytes = ParcelableUtil.marshall(value);
|
|
||||||
byteArrays.put(key, bytes);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Data build() {
|
|
||||||
return new Data(strings,
|
|
||||||
stringArrays,
|
|
||||||
integers,
|
|
||||||
integerArrays,
|
|
||||||
longs,
|
|
||||||
longArrays,
|
|
||||||
floats,
|
|
||||||
floatArrays,
|
|
||||||
doubles,
|
|
||||||
doubleArrays,
|
|
||||||
booleans,
|
|
||||||
booleanArrays,
|
|
||||||
byteArrays);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface Serializer {
|
|
||||||
@NonNull String serialize(@NonNull Data data);
|
|
||||||
@NonNull Data deserialize(@NonNull String serialized);
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,6 +5,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.WorkerThread;
|
import androidx.annotation.WorkerThread;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -7,6 +7,7 @@ import androidx.annotation.WorkerThread;
|
|||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.jobmanager.persistence.ConstraintSpec;
|
import org.thoughtcrime.securesms.jobmanager.persistence.ConstraintSpec;
|
||||||
import org.thoughtcrime.securesms.jobmanager.persistence.DependencySpec;
|
import org.thoughtcrime.securesms.jobmanager.persistence.DependencySpec;
|
||||||
import org.thoughtcrime.securesms.jobmanager.persistence.FullSpec;
|
import org.thoughtcrime.securesms.jobmanager.persistence.FullSpec;
|
||||||
|
@ -2,6 +2,8 @@ package org.thoughtcrime.securesms.jobmanager;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import android.content.Intent;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.DefaultExecutorFactory;
|
import org.thoughtcrime.securesms.jobmanager.impl.DefaultExecutorFactory;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.JsonDataSerializer;
|
import org.thoughtcrime.securesms.jobmanager.impl.JsonDataSerializer;
|
||||||
import org.thoughtcrime.securesms.jobmanager.persistence.JobStorage;
|
import org.thoughtcrime.securesms.jobmanager.persistence.JobStorage;
|
||||||
|
@ -2,7 +2,7 @@ package org.thoughtcrime.securesms.jobmanager.impl;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.session.libsession.utilities.JsonUtils;
|
import org.session.libsession.utilities.JsonUtils;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package org.thoughtcrime.securesms.jobmanager.migration;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
@ -6,6 +6,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.session.libsignal.libsignal.InvalidMessageException;
|
import org.session.libsignal.libsignal.InvalidMessageException;
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||||
import org.session.libsignal.service.api.crypto.AttachmentCipherInputStream;
|
import org.session.libsignal.service.api.crypto.AttachmentCipherInputStream;
|
||||||
@ -21,7 +22,6 @@ import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
|||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.events.PartProgressEvent;
|
import org.thoughtcrime.securesms.events.PartProgressEvent;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
@ -75,7 +75,8 @@ public class AttachmentDownloadJob extends BaseJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putLong(KEY_MESSAGE_ID, messageId)
|
return new Data.Builder().putLong(KEY_MESSAGE_ID, messageId)
|
||||||
.putLong(KEY_PART_ROW_ID, partRowId)
|
.putLong(KEY_PART_ROW_ID, partRowId)
|
||||||
.putLong(KEY_PAR_UNIQUE_ID, partUniqueId)
|
.putLong(KEY_PAR_UNIQUE_ID, partUniqueId)
|
||||||
|
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.jobs;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId;
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId;
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment;
|
||||||
@ -12,7 +13,6 @@ import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
|||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.events.PartProgressEvent;
|
import org.thoughtcrime.securesms.events.PartProgressEvent;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
@ -65,7 +65,8 @@ public class AttachmentUploadJob extends BaseJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putLong(KEY_ROW_ID, attachmentId.getRowId())
|
return new Data.Builder().putLong(KEY_ROW_ID, attachmentId.getRowId())
|
||||||
.putLong(KEY_UNIQUE_ID, attachmentId.getUniqueId())
|
.putLong(KEY_UNIQUE_ID, attachmentId.getUniqueId())
|
||||||
.putString(KEY_DESTINATION, destination.serialize())
|
.putString(KEY_DESTINATION, destination.serialize())
|
||||||
@ -161,7 +162,7 @@ public class AttachmentUploadJob extends BaseJob implements InjectableType {
|
|||||||
|
|
||||||
public static final class Factory implements Job.Factory<AttachmentUploadJob> {
|
public static final class Factory implements Job.Factory<AttachmentUploadJob> {
|
||||||
@Override
|
@Override
|
||||||
public @NonNull AttachmentUploadJob create(@NonNull Parameters parameters, @NonNull org.thoughtcrime.securesms.jobmanager.Data data) {
|
public @NonNull AttachmentUploadJob create(@NonNull Parameters parameters, @NonNull Data data) {
|
||||||
return new AttachmentUploadJob(parameters, new AttachmentId(data.getLong(KEY_ROW_ID), data.getLong(KEY_UNIQUE_ID)), Address.Companion.fromSerialized(data.getString(KEY_DESTINATION)));
|
return new AttachmentUploadJob(parameters, new AttachmentId(data.getLong(KEY_ROW_ID), data.getLong(KEY_UNIQUE_ID)), Address.Companion.fromSerialized(data.getString(KEY_DESTINATION)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,11 @@ package org.thoughtcrime.securesms.jobs;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||||
import org.session.libsession.messaging.threads.GroupRecord;
|
import org.session.libsession.messaging.threads.GroupRecord;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
|
@ -2,8 +2,8 @@ package org.thoughtcrime.securesms.jobs;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.database.NoExternalStorageException;
|
import org.thoughtcrime.securesms.database.NoExternalStorageException;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.loki.database.BackupFileRecord;
|
import org.thoughtcrime.securesms.loki.database.BackupFileRecord;
|
||||||
@ -35,7 +35,8 @@ public class LocalBackupJob extends BaseJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return Data.EMPTY;
|
return Data.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,12 +10,12 @@ import com.google.android.mms.pdu_alt.PduBody;
|
|||||||
import com.google.android.mms.pdu_alt.PduPart;
|
import com.google.android.mms.pdu_alt.PduPart;
|
||||||
import com.google.android.mms.pdu_alt.RetrieveConf;
|
import com.google.android.mms.pdu_alt.RetrieveConf;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult;
|
import org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult;
|
||||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.mms.ApnUnavailableException;
|
import org.thoughtcrime.securesms.mms.ApnUnavailableException;
|
||||||
@ -82,7 +82,8 @@ public class MmsDownloadJob extends BaseJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putLong(KEY_MESSAGE_ID, messageId)
|
return new Data.Builder().putLong(KEY_MESSAGE_ID, messageId)
|
||||||
.putLong(KEY_THREAD_ID, threadId)
|
.putLong(KEY_THREAD_ID, threadId)
|
||||||
.putBoolean(KEY_AUTOMATIC, automatic)
|
.putBoolean(KEY_AUTOMATIC, automatic)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.thoughtcrime.securesms.jobs;
|
package org.thoughtcrime.securesms.jobs;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
|
|
||||||
@ -46,7 +46,8 @@ public class MmsReceiveJob extends BaseJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putString(KEY_DATA, Base64.encodeBytes(data))
|
return new Data.Builder().putString(KEY_DATA, Base64.encodeBytes(data))
|
||||||
.putInt(KEY_SUBSCRIPTION_ID, subscriptionId)
|
.putInt(KEY_SUBSCRIPTION_ID, subscriptionId)
|
||||||
.build();
|
.build();
|
||||||
|
@ -19,6 +19,7 @@ import com.google.android.mms.pdu_alt.SendReq;
|
|||||||
import com.google.android.mms.smil.SmilHelper;
|
import com.google.android.mms.smil.SmilHelper;
|
||||||
import com.klinker.android.send_message.Utils;
|
import com.klinker.android.send_message.Utils;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
@ -26,7 +27,6 @@ import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|||||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||||
import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
||||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
@ -74,7 +74,8 @@ public class MmsSendJob extends SendJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putLong(KEY_MESSAGE_ID, messageId).build();
|
return new Data.Builder().putLong(KEY_MESSAGE_ID, messageId).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.jobs;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
|
|
||||||
public class PushContentReceiveJob extends PushReceivedJob {
|
public class PushContentReceiveJob extends PushReceivedJob {
|
||||||
@ -20,7 +20,8 @@ public class PushContentReceiveJob extends PushReceivedJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return Data.EMPTY;
|
return Data.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import androidx.core.app.NotificationManagerCompat;
|
|||||||
import com.annimon.stream.Collectors;
|
import com.annimon.stream.Collectors;
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.session.libsignal.metadata.InvalidMetadataMessageException;
|
import org.session.libsignal.metadata.InvalidMetadataMessageException;
|
||||||
import org.session.libsignal.metadata.InvalidMetadataVersionException;
|
import org.session.libsignal.metadata.InvalidMetadataVersionException;
|
||||||
import org.session.libsignal.metadata.ProtocolDuplicateMessageException;
|
import org.session.libsignal.metadata.ProtocolDuplicateMessageException;
|
||||||
@ -66,7 +67,6 @@ import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
|||||||
import org.thoughtcrime.securesms.database.model.StickerRecord;
|
import org.thoughtcrime.securesms.database.model.StickerRecord;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.groups.GroupMessageProcessor;
|
import org.thoughtcrime.securesms.groups.GroupMessageProcessor;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||||
import org.thoughtcrime.securesms.linkpreview.Link;
|
import org.thoughtcrime.securesms.linkpreview.Link;
|
||||||
@ -175,7 +175,8 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putLong(KEY_MESSAGE_ID, messageId)
|
return new Data.Builder().putLong(KEY_MESSAGE_ID, messageId)
|
||||||
.putLong(KEY_SMS_MESSAGE_ID, smsMessageId)
|
.putLong(KEY_SMS_MESSAGE_ID, smsMessageId)
|
||||||
.build();
|
.build();
|
||||||
|
@ -8,6 +8,7 @@ import androidx.annotation.WorkerThread;
|
|||||||
import com.annimon.stream.Collectors;
|
import com.annimon.stream.Collectors;
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment;
|
||||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||||
@ -22,7 +23,6 @@ import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
|||||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
||||||
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
|
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||||
@ -118,7 +118,8 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putLong(KEY_MESSAGE_ID, messageId)
|
return new Data.Builder().putLong(KEY_MESSAGE_ID, messageId)
|
||||||
.putString(KEY_FILTER_ADDRESS, filterAddress)
|
.putString(KEY_FILTER_ADDRESS, filterAddress)
|
||||||
.build();
|
.build();
|
||||||
@ -292,7 +293,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
|||||||
|
|
||||||
public static class Factory implements Job.Factory<PushGroupSendJob> {
|
public static class Factory implements Job.Factory<PushGroupSendJob> {
|
||||||
@Override
|
@Override
|
||||||
public @NonNull PushGroupSendJob create(@NonNull Parameters parameters, @NonNull org.thoughtcrime.securesms.jobmanager.Data data) {
|
public @NonNull PushGroupSendJob create(@NonNull Parameters parameters, @NonNull Data data) {
|
||||||
String address = data.getString(KEY_FILTER_ADDRESS);
|
String address = data.getString(KEY_FILTER_ADDRESS);
|
||||||
Address filter = address != null ? Address.Companion.fromSerialized(data.getString(KEY_FILTER_ADDRESS)) : null;
|
Address filter = address != null ? Address.Companion.fromSerialized(data.getString(KEY_FILTER_ADDRESS)) : null;
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.jobs;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
import org.session.libsession.messaging.threads.GroupRecord;
|
import org.session.libsession.messaging.threads.GroupRecord;
|
||||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||||
@ -12,7 +13,6 @@ import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
|||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
@ -67,7 +67,8 @@ public class PushGroupUpdateJob extends BaseJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putString(KEY_SOURCE, source)
|
return new Data.Builder().putString(KEY_SOURCE, source)
|
||||||
.putString(KEY_GROUP_ID, GroupUtil.getEncodedClosedGroupID(groupId))
|
.putString(KEY_GROUP_ID, GroupUtil.getEncodedClosedGroupID(groupId))
|
||||||
.build();
|
.build();
|
||||||
@ -142,7 +143,7 @@ public class PushGroupUpdateJob extends BaseJob implements InjectableType {
|
|||||||
|
|
||||||
public static final class Factory implements Job.Factory<PushGroupUpdateJob> {
|
public static final class Factory implements Job.Factory<PushGroupUpdateJob> {
|
||||||
@Override
|
@Override
|
||||||
public @NonNull PushGroupUpdateJob create(@NonNull Parameters parameters, @NonNull org.thoughtcrime.securesms.jobmanager.Data data) {
|
public @NonNull PushGroupUpdateJob create(@NonNull Parameters parameters, @NonNull Data data) {
|
||||||
return new PushGroupUpdateJob(parameters,
|
return new PushGroupUpdateJob(parameters,
|
||||||
data.getString(KEY_SOURCE),
|
data.getString(KEY_SOURCE),
|
||||||
GroupUtil.getDecodedGroupIDAsData(data.getString(KEY_GROUP_ID)));
|
GroupUtil.getDecodedGroupIDAsData(data.getString(KEY_GROUP_ID)));
|
||||||
|
@ -6,6 +6,7 @@ import androidx.annotation.WorkerThread;
|
|||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment;
|
||||||
@ -19,7 +20,6 @@ import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
|||||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||||
import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
@ -130,7 +130,8 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder()
|
return new Data.Builder()
|
||||||
.putLong(KEY_TEMPLATE_MESSAGE_ID, templateMessageId)
|
.putLong(KEY_TEMPLATE_MESSAGE_ID, templateMessageId)
|
||||||
.putLong(KEY_MESSAGE_ID, messageId)
|
.putLong(KEY_MESSAGE_ID, messageId)
|
||||||
|
@ -3,8 +3,8 @@ package org.thoughtcrime.securesms.jobs;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
@ -40,7 +40,8 @@ public class PushNotificationReceiveJob extends PushReceivedJob implements Injec
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return Data.EMPTY;
|
return Data.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package org.thoughtcrime.securesms.jobs;
|
package org.thoughtcrime.securesms.jobs;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
|
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
@ -16,7 +18,6 @@ import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
|||||||
import org.thoughtcrime.securesms.database.SmsDatabase;
|
import org.thoughtcrime.securesms.database.SmsDatabase;
|
||||||
import org.thoughtcrime.securesms.database.model.SmsMessageRecord;
|
import org.thoughtcrime.securesms.database.model.SmsMessageRecord;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.loki.database.LokiMessageDatabase;
|
import org.thoughtcrime.securesms.loki.database.LokiMessageDatabase;
|
||||||
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
||||||
@ -71,7 +72,8 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder()
|
return new Data.Builder()
|
||||||
.putLong(KEY_TEMPLATE_MESSAGE_ID, templateMessageId)
|
.putLong(KEY_TEMPLATE_MESSAGE_ID, templateMessageId)
|
||||||
.putLong(KEY_MESSAGE_ID, messageId)
|
.putLong(KEY_MESSAGE_ID, messageId)
|
||||||
|
@ -2,13 +2,13 @@ package org.thoughtcrime.securesms.jobs;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
import org.session.libsession.utilities.GroupUtil;
|
import org.session.libsession.utilities.GroupUtil;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||||
import org.session.libsignal.service.api.SignalServiceMessageSender;
|
import org.session.libsignal.service.api.SignalServiceMessageSender;
|
||||||
@ -58,7 +58,8 @@ public class RequestGroupInfoJob extends BaseJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putString(KEY_SOURCE, source)
|
return new Data.Builder().putString(KEY_SOURCE, source)
|
||||||
.putString(KEY_GROUP_ID, GroupUtil.getEncodedClosedGroupID(groupId))
|
.putString(KEY_GROUP_ID, GroupUtil.getEncodedClosedGroupID(groupId))
|
||||||
.build();
|
.build();
|
||||||
|
@ -5,12 +5,12 @@ import android.app.Application;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||||
import org.session.libsession.messaging.contacts.avatars.AvatarHelper;
|
import org.session.libsession.messaging.contacts.avatars.AvatarHelper;
|
||||||
import org.session.libsession.utilities.Util;
|
import org.session.libsession.utilities.Util;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
@ -64,7 +64,8 @@ public class RetrieveProfileAvatarJob extends BaseJob implements InjectableType
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putString(KEY_PROFILE_AVATAR, profileAvatar)
|
return new Data.Builder().putString(KEY_PROFILE_AVATAR, profileAvatar)
|
||||||
.putString(KEY_ADDRESS, recipient.getAddress().serialize())
|
.putString(KEY_ADDRESS, recipient.getAddress().serialize())
|
||||||
.build();
|
.build();
|
||||||
|
@ -3,10 +3,10 @@ package org.thoughtcrime.securesms.jobs;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
@ -64,7 +64,8 @@ public class SendDeliveryReceiptJob extends BaseJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putString(KEY_ADDRESS, address)
|
return new Data.Builder().putString(KEY_ADDRESS, address)
|
||||||
.putLong(KEY_MESSAGE_ID, messageId)
|
.putLong(KEY_MESSAGE_ID, messageId)
|
||||||
.putLong(KEY_TIMESTAMP, timestamp)
|
.putLong(KEY_TIMESTAMP, timestamp)
|
||||||
|
@ -3,10 +3,10 @@ package org.thoughtcrime.securesms.jobs;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
@ -65,7 +65,8 @@ public class SendReadReceiptJob extends BaseJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
long[] ids = new long[messageIds.size()];
|
long[] ids = new long[messageIds.size()];
|
||||||
for (int i = 0; i < ids.length; i++) {
|
for (int i = 0; i < ids.length; i++) {
|
||||||
ids[i] = messageIds.get(i);
|
ids[i] = messageIds.get(i);
|
||||||
|
@ -4,8 +4,8 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.telephony.SmsMessage;
|
import android.telephony.SmsMessage;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.SqlCipherMigrationConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.SqlCipherMigrationConstraint;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
@ -55,7 +55,8 @@ public class SmsReceiveJob extends BaseJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
String[] encoded = new String[pdus.length];
|
String[] encoded = new String[pdus.length];
|
||||||
for (int i = 0; i < pdus.length; i++) {
|
for (int i = 0; i < pdus.length; i++) {
|
||||||
encoded[i] = Base64.encodeBytes((byte[]) pdus[i]);
|
encoded[i] = Base64.encodeBytes((byte[]) pdus[i]);
|
||||||
|
@ -9,8 +9,8 @@ import androidx.annotation.NonNull;
|
|||||||
import android.telephony.PhoneNumberUtils;
|
import android.telephony.PhoneNumberUtils;
|
||||||
import android.telephony.SmsManager;
|
import android.telephony.SmsManager;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkOrCellServiceConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkOrCellServiceConstraint;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.CellServiceConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.CellServiceConstraint;
|
||||||
@ -56,7 +56,8 @@ public class SmsSendJob extends SendJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putLong(KEY_MESSAGE_ID, messageId)
|
return new Data.Builder().putLong(KEY_MESSAGE_ID, messageId)
|
||||||
.putInt(KEY_RUN_ATTEMPT, runAttempt)
|
.putInt(KEY_RUN_ATTEMPT, runAttempt)
|
||||||
.build();
|
.build();
|
||||||
@ -241,7 +242,7 @@ public class SmsSendJob extends SendJob {
|
|||||||
|
|
||||||
public static class Factory implements Job.Factory<SmsSendJob> {
|
public static class Factory implements Job.Factory<SmsSendJob> {
|
||||||
@Override
|
@Override
|
||||||
public @NonNull SmsSendJob create(@NonNull Parameters parameters, @NonNull org.thoughtcrime.securesms.jobmanager.Data data) {
|
public @NonNull SmsSendJob create(@NonNull Parameters parameters, @NonNull Data data) {
|
||||||
return new SmsSendJob(parameters, data.getLong(KEY_MESSAGE_ID), data.getInt(KEY_RUN_ATTEMPT));
|
return new SmsSendJob(parameters, data.getLong(KEY_MESSAGE_ID), data.getInt(KEY_RUN_ATTEMPT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import android.app.Activity;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.telephony.SmsManager;
|
import android.telephony.SmsManager;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
|
|
||||||
@ -49,7 +49,8 @@ public class SmsSentJob extends BaseJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putLong(KEY_MESSAGE_ID, messageId)
|
return new Data.Builder().putLong(KEY_MESSAGE_ID, messageId)
|
||||||
.putString(KEY_ACTION, action)
|
.putString(KEY_ACTION, action)
|
||||||
.putInt(KEY_RESULT, result)
|
.putInt(KEY_RESULT, result)
|
||||||
|
@ -2,11 +2,11 @@ package org.thoughtcrime.securesms.jobs;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.StickerDatabase;
|
import org.thoughtcrime.securesms.database.StickerDatabase;
|
||||||
import org.thoughtcrime.securesms.database.model.IncomingSticker;
|
import org.thoughtcrime.securesms.database.model.IncomingSticker;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
@ -78,7 +78,8 @@ public class StickerDownloadJob extends BaseJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putString(KEY_PACK_ID, sticker.getPackId())
|
return new Data.Builder().putString(KEY_PACK_ID, sticker.getPackId())
|
||||||
.putString(KEY_PACK_KEY, sticker.getPackKey())
|
.putString(KEY_PACK_KEY, sticker.getPackKey())
|
||||||
.putString(KEY_PACK_TITLE, sticker.getPackTitle())
|
.putString(KEY_PACK_TITLE, sticker.getPackTitle())
|
||||||
|
@ -2,12 +2,12 @@ package org.thoughtcrime.securesms.jobs;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.StickerDatabase;
|
import org.thoughtcrime.securesms.database.StickerDatabase;
|
||||||
import org.thoughtcrime.securesms.database.model.IncomingSticker;
|
import org.thoughtcrime.securesms.database.model.IncomingSticker;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||||
@ -130,7 +130,8 @@ public class StickerPackDownloadJob extends BaseJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putString(KEY_PACK_ID, packId)
|
return new Data.Builder().putString(KEY_PACK_ID, packId)
|
||||||
.putString(KEY_PACK_KEY, packKey)
|
.putString(KEY_PACK_KEY, packKey)
|
||||||
.putBoolean(KEY_REFERENCE_PACK, isReferencePack)
|
.putBoolean(KEY_REFERENCE_PACK, isReferencePack)
|
||||||
|
@ -18,8 +18,8 @@ package org.thoughtcrime.securesms.jobs;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
|
|
||||||
@ -45,7 +45,8 @@ public class TrimThreadJob extends BaseJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putLong(KEY_THREAD_ID, threadId).build();
|
return new Data.Builder().putLong(KEY_THREAD_ID, threadId).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,10 +4,10 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||||
@ -60,7 +60,8 @@ public class TypingSendJob extends BaseJob implements InjectableType {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return new Data.Builder().putLong(KEY_THREAD_ID, threadId)
|
return new Data.Builder().putLong(KEY_THREAD_ID, threadId)
|
||||||
.putBoolean(KEY_TYPING, typing)
|
.putBoolean(KEY_TYPING, typing)
|
||||||
.build();
|
.build();
|
||||||
|
@ -13,7 +13,7 @@ import androidx.annotation.Nullable;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
import org.session.libsession.messaging.jobs.Data;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
@ -51,7 +51,8 @@ public class UpdateApkJob extends BaseJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Data serialize() {
|
public @NonNull
|
||||||
|
Data serialize() {
|
||||||
return Data.EMPTY;
|
return Data.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,11 +5,11 @@ import android.os.Build
|
|||||||
import org.thoughtcrime.securesms.logging.Log
|
import org.thoughtcrime.securesms.logging.Log
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
|
import org.session.libsession.messaging.jobs.Data
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachmentAudioExtras
|
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachmentAudioExtras
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job
|
import org.thoughtcrime.securesms.jobmanager.Job
|
||||||
import org.thoughtcrime.securesms.jobs.BaseJob
|
import org.thoughtcrime.securesms.jobs.BaseJob
|
||||||
import org.thoughtcrime.securesms.loki.utilities.audio.DecodedAudio
|
import org.thoughtcrime.securesms.loki.utilities.audio.DecodedAudio
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.thoughtcrime.securesms.loki.api
|
package org.thoughtcrime.securesms.loki.api
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.jobs.Data
|
||||||
import org.session.libsession.messaging.threads.Address
|
import org.session.libsession.messaging.threads.Address
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job
|
import org.thoughtcrime.securesms.jobmanager.Job
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||||
import org.thoughtcrime.securesms.jobs.BaseJob
|
import org.thoughtcrime.securesms.jobs.BaseJob
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
package org.thoughtcrime.securesms.loki.database
|
||||||
|
|
||||||
|
class SessionJobDatabase {
|
||||||
|
}
|
@ -1,9 +1,9 @@
|
|||||||
package org.thoughtcrime.securesms.loki.protocol
|
package org.thoughtcrime.securesms.loki.protocol
|
||||||
|
|
||||||
import com.google.protobuf.ByteString
|
import com.google.protobuf.ByteString
|
||||||
|
import org.session.libsession.messaging.jobs.Data
|
||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil
|
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job
|
import org.thoughtcrime.securesms.jobmanager.Job
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||||
import org.thoughtcrime.securesms.jobs.BaseJob
|
import org.thoughtcrime.securesms.jobs.BaseJob
|
||||||
|
@ -5,6 +5,7 @@ import kotlinx.serialization.Serializable
|
|||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
import org.session.libsession.messaging.jobs.Data
|
||||||
import org.session.libsignal.libsignal.ecc.DjbECPrivateKey
|
import org.session.libsignal.libsignal.ecc.DjbECPrivateKey
|
||||||
import org.session.libsignal.libsignal.ecc.DjbECPublicKey
|
import org.session.libsignal.libsignal.ecc.DjbECPublicKey
|
||||||
import org.session.libsignal.libsignal.ecc.ECKeyPair
|
import org.session.libsignal.libsignal.ecc.ECKeyPair
|
||||||
@ -16,7 +17,6 @@ import org.session.libsignal.service.loki.utilities.toHexString
|
|||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil
|
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil
|
||||||
import org.thoughtcrime.securesms.crypto.storage.SignalProtocolStoreImpl
|
import org.thoughtcrime.securesms.crypto.storage.SignalProtocolStoreImpl
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job
|
import org.thoughtcrime.securesms.jobmanager.Job
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||||
import org.thoughtcrime.securesms.jobs.BaseJob
|
import org.thoughtcrime.securesms.jobs.BaseJob
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package org.thoughtcrime.securesms.loki.protocol
|
package org.thoughtcrime.securesms.loki.protocol
|
||||||
|
|
||||||
import com.google.protobuf.ByteString
|
import com.google.protobuf.ByteString
|
||||||
|
import org.session.libsession.messaging.jobs.Data
|
||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil
|
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil
|
||||||
import org.session.libsession.messaging.threads.Address
|
import org.session.libsession.messaging.threads.Address
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job
|
import org.thoughtcrime.securesms.jobmanager.Job
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||||
import org.thoughtcrime.securesms.jobs.BaseJob
|
import org.thoughtcrime.securesms.jobs.BaseJob
|
||||||
|
@ -53,6 +53,7 @@ dependencies {
|
|||||||
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
||||||
implementation 'com.annimon:stream:1.1.8'
|
implementation 'com.annimon:stream:1.1.8'
|
||||||
implementation 'com.makeramen:roundedimageview:2.1.0'
|
implementation 'com.makeramen:roundedimageview:2.1.0'
|
||||||
|
implementation 'com.esotericsoftware:kryo:4.0.1'
|
||||||
|
|
||||||
// from libsignal:
|
// from libsignal:
|
||||||
implementation "com.google.protobuf:protobuf-java:$protobufVersion"
|
implementation "com.google.protobuf:protobuf-java:$protobufVersion"
|
||||||
|
@ -25,6 +25,10 @@ class AttachmentDownloadJob(val attachmentID: Long, val tsIncomingMessageID: Lon
|
|||||||
override val maxFailureCount: Int = 20
|
override val maxFailureCount: Int = 20
|
||||||
companion object {
|
companion object {
|
||||||
val collection: String = "AttachmentDownloadJobCollection"
|
val collection: String = "AttachmentDownloadJobCollection"
|
||||||
|
|
||||||
|
//keys used for database storage purpose
|
||||||
|
private val KEY_ATTACHMENT_ID = "attachment_id"
|
||||||
|
private val KEY_TS_INCOMING_MESSAGE_ID = "tsIncoming_message_id"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun execute() {
|
override fun execute() {
|
||||||
@ -81,4 +85,21 @@ class AttachmentDownloadJob(val attachmentID: Long, val tsIncomingMessageID: Lon
|
|||||||
file.deleteOnExit()
|
file.deleteOnExit()
|
||||||
return file
|
return file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//database functions
|
||||||
|
|
||||||
|
override fun serialize(): Data {
|
||||||
|
val builder = this.createJobDataBuilder()
|
||||||
|
return builder.putLong(KEY_ATTACHMENT_ID, attachmentID)
|
||||||
|
.putLong(KEY_TS_INCOMING_MESSAGE_ID, tsIncomingMessageID)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
class Factory: Job.Factory<AttachmentDownloadJob> {
|
||||||
|
override fun create(data: Data): AttachmentDownloadJob {
|
||||||
|
val job = AttachmentDownloadJob(data.getLong(KEY_ATTACHMENT_ID), data.getLong(KEY_TS_INCOMING_MESSAGE_ID))
|
||||||
|
job.initJob(data)
|
||||||
|
return job
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,5 +1,8 @@
|
|||||||
package org.session.libsession.messaging.jobs
|
package org.session.libsession.messaging.jobs
|
||||||
|
|
||||||
|
import com.esotericsoftware.kryo.Kryo
|
||||||
|
import com.esotericsoftware.kryo.io.Input
|
||||||
|
import com.esotericsoftware.kryo.io.Output
|
||||||
import org.session.libsession.messaging.MessagingConfiguration
|
import org.session.libsession.messaging.MessagingConfiguration
|
||||||
import org.session.libsession.messaging.fileserver.FileServerAPI
|
import org.session.libsession.messaging.fileserver.FileServerAPI
|
||||||
import org.session.libsession.messaging.messages.Message
|
import org.session.libsession.messaging.messages.Message
|
||||||
@ -29,6 +32,12 @@ class AttachmentUploadJob(val attachmentID: Long, val threadID: String, val mess
|
|||||||
|
|
||||||
val collection: String = "AttachmentUploadJobCollection"
|
val collection: String = "AttachmentUploadJobCollection"
|
||||||
val maxFailureCount: Int = 20
|
val maxFailureCount: Int = 20
|
||||||
|
|
||||||
|
//keys used for database storage purpose
|
||||||
|
private val KEY_ATTACHMENT_ID = "attachment_id"
|
||||||
|
private val KEY_THREAD_ID = "thread_id"
|
||||||
|
private val KEY_MESSAGE = "message"
|
||||||
|
private val KEY_MESSAGE_SEND_JOB_ID = "message_send_job_id"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun execute() {
|
override fun execute() {
|
||||||
@ -91,4 +100,36 @@ class AttachmentUploadJob(val attachmentID: Long, val threadID: String, val mess
|
|||||||
storage.markJobAsFailed(messageSendJob)
|
storage.markJobAsFailed(messageSendJob)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//database functions
|
||||||
|
|
||||||
|
override fun serialize(): Data {
|
||||||
|
val builder = this.createJobDataBuilder()
|
||||||
|
//serialize Message property
|
||||||
|
val kryo = Kryo()
|
||||||
|
kryo.isRegistrationRequired = false
|
||||||
|
val serializedMessage = ByteArray(4096)
|
||||||
|
val output = Output(serializedMessage)
|
||||||
|
kryo.writeObject(output, message)
|
||||||
|
output.close()
|
||||||
|
return builder.putLong(KEY_ATTACHMENT_ID, attachmentID)
|
||||||
|
.putString(KEY_THREAD_ID, threadID)
|
||||||
|
.putByteArray(KEY_MESSAGE, serializedMessage)
|
||||||
|
.putString(KEY_MESSAGE_SEND_JOB_ID, messageSendJobID)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
class Factory: Job.Factory<AttachmentUploadJob> {
|
||||||
|
override fun create(data: Data): AttachmentUploadJob {
|
||||||
|
val serializedMessage = data.getByteArray(KEY_MESSAGE)
|
||||||
|
//deserialize Message property
|
||||||
|
val kryo = Kryo()
|
||||||
|
val input = Input(serializedMessage)
|
||||||
|
val message: Message = kryo.readObject(input, Message::class.java)
|
||||||
|
input.close()
|
||||||
|
val job = AttachmentUploadJob(data.getLong(KEY_ATTACHMENT_ID), data.getString(KEY_THREAD_ID)!!, message, data.getString(KEY_MESSAGE_SEND_JOB_ID)!!)
|
||||||
|
job.initJob(data)
|
||||||
|
return job
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,348 @@
|
|||||||
|
package org.session.libsession.messaging.jobs;
|
||||||
|
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import org.session.libsession.utilities.ParcelableUtil;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
// TODO AC: For now parcelable objects utilize byteArrays field to store their data into.
|
||||||
|
// Introduce a dedicated Map<String, byte[]> field specifically for parcelable needs.
|
||||||
|
public class Data {
|
||||||
|
|
||||||
|
public static final Data EMPTY = new Data.Builder().build();
|
||||||
|
|
||||||
|
@JsonProperty private final Map<String, String> strings;
|
||||||
|
@JsonProperty private final Map<String, String[]> stringArrays;
|
||||||
|
@JsonProperty private final Map<String, Integer> integers;
|
||||||
|
@JsonProperty private final Map<String, int[]> integerArrays;
|
||||||
|
@JsonProperty private final Map<String, Long> longs;
|
||||||
|
@JsonProperty private final Map<String, long[]> longArrays;
|
||||||
|
@JsonProperty private final Map<String, Float> floats;
|
||||||
|
@JsonProperty private final Map<String, float[]> floatArrays;
|
||||||
|
@JsonProperty private final Map<String, Double> doubles;
|
||||||
|
@JsonProperty private final Map<String, double[]> doubleArrays;
|
||||||
|
@JsonProperty private final Map<String, Boolean> booleans;
|
||||||
|
@JsonProperty private final Map<String, boolean[]> booleanArrays;
|
||||||
|
@JsonProperty private final Map<String, byte[]> byteArrays;
|
||||||
|
|
||||||
|
public Data(@JsonProperty("strings") @NonNull Map<String, String> strings,
|
||||||
|
@JsonProperty("stringArrays") @NonNull Map<String, String[]> stringArrays,
|
||||||
|
@JsonProperty("integers") @NonNull Map<String, Integer> integers,
|
||||||
|
@JsonProperty("integerArrays") @NonNull Map<String, int[]> integerArrays,
|
||||||
|
@JsonProperty("longs") @NonNull Map<String, Long> longs,
|
||||||
|
@JsonProperty("longArrays") @NonNull Map<String, long[]> longArrays,
|
||||||
|
@JsonProperty("floats") @NonNull Map<String, Float> floats,
|
||||||
|
@JsonProperty("floatArrays") @NonNull Map<String, float[]> floatArrays,
|
||||||
|
@JsonProperty("doubles") @NonNull Map<String, Double> doubles,
|
||||||
|
@JsonProperty("doubleArrays") @NonNull Map<String, double[]> doubleArrays,
|
||||||
|
@JsonProperty("booleans") @NonNull Map<String, Boolean> booleans,
|
||||||
|
@JsonProperty("booleanArrays") @NonNull Map<String, boolean[]> booleanArrays,
|
||||||
|
@JsonProperty("byteArrays") @NonNull Map<String, byte[]> byteArrays)
|
||||||
|
{
|
||||||
|
this.strings = strings;
|
||||||
|
this.stringArrays = stringArrays;
|
||||||
|
this.integers = integers;
|
||||||
|
this.integerArrays = integerArrays;
|
||||||
|
this.longs = longs;
|
||||||
|
this.longArrays = longArrays;
|
||||||
|
this.floats = floats;
|
||||||
|
this.floatArrays = floatArrays;
|
||||||
|
this.doubles = doubles;
|
||||||
|
this.doubleArrays = doubleArrays;
|
||||||
|
this.booleans = booleans;
|
||||||
|
this.booleanArrays = booleanArrays;
|
||||||
|
this.byteArrays = byteArrays;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasString(@NonNull String key) {
|
||||||
|
return strings.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getString(@NonNull String key) {
|
||||||
|
throwIfAbsent(strings, key);
|
||||||
|
return strings.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStringOrDefault(@NonNull String key, String defaultValue) {
|
||||||
|
if (hasString(key)) return getString(key);
|
||||||
|
else return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasStringArray(@NonNull String key) {
|
||||||
|
return stringArrays.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getStringArray(@NonNull String key) {
|
||||||
|
throwIfAbsent(stringArrays, key);
|
||||||
|
return stringArrays.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasInt(@NonNull String key) {
|
||||||
|
return integers.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInt(@NonNull String key) {
|
||||||
|
throwIfAbsent(integers, key);
|
||||||
|
return integers.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIntOrDefault(@NonNull String key, int defaultValue) {
|
||||||
|
if (hasInt(key)) return getInt(key);
|
||||||
|
else return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasIntegerArray(@NonNull String key) {
|
||||||
|
return integerArrays.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getIntegerArray(@NonNull String key) {
|
||||||
|
throwIfAbsent(integerArrays, key);
|
||||||
|
return integerArrays.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasLong(@NonNull String key) {
|
||||||
|
return longs.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getLong(@NonNull String key) {
|
||||||
|
throwIfAbsent(longs, key);
|
||||||
|
return longs.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getLongOrDefault(@NonNull String key, long defaultValue) {
|
||||||
|
if (hasLong(key)) return getLong(key);
|
||||||
|
else return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasLongArray(@NonNull String key) {
|
||||||
|
return longArrays.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long[] getLongArray(@NonNull String key) {
|
||||||
|
throwIfAbsent(longArrays, key);
|
||||||
|
return longArrays.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasFloat(@NonNull String key) {
|
||||||
|
return floats.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getFloat(@NonNull String key) {
|
||||||
|
throwIfAbsent(floats, key);
|
||||||
|
return floats.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getFloatOrDefault(@NonNull String key, float defaultValue) {
|
||||||
|
if (hasFloat(key)) return getFloat(key);
|
||||||
|
else return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasFloatArray(@NonNull String key) {
|
||||||
|
return floatArrays.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float[] getFloatArray(@NonNull String key) {
|
||||||
|
throwIfAbsent(floatArrays, key);
|
||||||
|
return floatArrays.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasDouble(@NonNull String key) {
|
||||||
|
return doubles.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDouble(@NonNull String key) {
|
||||||
|
throwIfAbsent(doubles, key);
|
||||||
|
return doubles.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDoubleOrDefault(@NonNull String key, double defaultValue) {
|
||||||
|
if (hasDouble(key)) return getDouble(key);
|
||||||
|
else return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasDoubleArray(@NonNull String key) {
|
||||||
|
return floatArrays.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double[] getDoubleArray(@NonNull String key) {
|
||||||
|
throwIfAbsent(doubleArrays, key);
|
||||||
|
return doubleArrays.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasBoolean(@NonNull String key) {
|
||||||
|
return booleans.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getBoolean(@NonNull String key) {
|
||||||
|
throwIfAbsent(booleans, key);
|
||||||
|
return booleans.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getBooleanOrDefault(@NonNull String key, boolean defaultValue) {
|
||||||
|
if (hasBoolean(key)) return getBoolean(key);
|
||||||
|
else return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasBooleanArray(@NonNull String key) {
|
||||||
|
return booleanArrays.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean[] getBooleanArray(@NonNull String key) {
|
||||||
|
throwIfAbsent(booleanArrays, key);
|
||||||
|
return booleanArrays.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasByteArray(@NonNull String key) {
|
||||||
|
return byteArrays.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getByteArray(@NonNull String key) {
|
||||||
|
throwIfAbsent(byteArrays, key);
|
||||||
|
return byteArrays.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasParcelable(@NonNull String key) {
|
||||||
|
return byteArrays.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends Parcelable> T getParcelable(@NonNull String key, @NonNull Parcelable.Creator<T> creator) {
|
||||||
|
throwIfAbsent(byteArrays, key);
|
||||||
|
byte[] bytes = byteArrays.get(key);
|
||||||
|
return ParcelableUtil.unmarshall(bytes, creator);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void throwIfAbsent(@NonNull Map map, @NonNull String key) {
|
||||||
|
if (!map.containsKey(key)) {
|
||||||
|
throw new IllegalStateException("Tried to retrieve a value with key '" + key + "', but it wasn't present.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private final Map<String, String> strings = new HashMap<>();
|
||||||
|
private final Map<String, String[]> stringArrays = new HashMap<>();
|
||||||
|
private final Map<String, Integer> integers = new HashMap<>();
|
||||||
|
private final Map<String, int[]> integerArrays = new HashMap<>();
|
||||||
|
private final Map<String, Long> longs = new HashMap<>();
|
||||||
|
private final Map<String, long[]> longArrays = new HashMap<>();
|
||||||
|
private final Map<String, Float> floats = new HashMap<>();
|
||||||
|
private final Map<String, float[]> floatArrays = new HashMap<>();
|
||||||
|
private final Map<String, Double> doubles = new HashMap<>();
|
||||||
|
private final Map<String, double[]> doubleArrays = new HashMap<>();
|
||||||
|
private final Map<String, Boolean> booleans = new HashMap<>();
|
||||||
|
private final Map<String, boolean[]> booleanArrays = new HashMap<>();
|
||||||
|
private final Map<String, byte[]> byteArrays = new HashMap<>();
|
||||||
|
|
||||||
|
public Builder putString(@NonNull String key, @Nullable String value) {
|
||||||
|
strings.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder putStringArray(@NonNull String key, @NonNull String[] value) {
|
||||||
|
stringArrays.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder putInt(@NonNull String key, int value) {
|
||||||
|
integers.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder putIntArray(@NonNull String key, @NonNull int[] value) {
|
||||||
|
integerArrays.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder putLong(@NonNull String key, long value) {
|
||||||
|
longs.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder putLongArray(@NonNull String key, @NonNull long[] value) {
|
||||||
|
longArrays.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder putFloat(@NonNull String key, float value) {
|
||||||
|
floats.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder putFloatArray(@NonNull String key, @NonNull float[] value) {
|
||||||
|
floatArrays.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder putDouble(@NonNull String key, double value) {
|
||||||
|
doubles.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder putDoubleArray(@NonNull String key, @NonNull double[] value) {
|
||||||
|
doubleArrays.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder putBoolean(@NonNull String key, boolean value) {
|
||||||
|
booleans.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder putBooleanArray(@NonNull String key, @NonNull boolean[] value) {
|
||||||
|
booleanArrays.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder putByteArray(@NonNull String key, @NonNull byte[] value) {
|
||||||
|
byteArrays.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder putParcelable(@NonNull String key, @NonNull Parcelable value) {
|
||||||
|
byte[] bytes = ParcelableUtil.marshall(value);
|
||||||
|
byteArrays.put(key, bytes);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Data build() {
|
||||||
|
return new Data(strings,
|
||||||
|
stringArrays,
|
||||||
|
integers,
|
||||||
|
integerArrays,
|
||||||
|
longs,
|
||||||
|
longArrays,
|
||||||
|
floats,
|
||||||
|
floatArrays,
|
||||||
|
doubles,
|
||||||
|
doubleArrays,
|
||||||
|
booleans,
|
||||||
|
booleanArrays,
|
||||||
|
byteArrays);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Serializer {
|
||||||
|
@NonNull String serialize(@NonNull Data data);
|
||||||
|
@NonNull Data deserialize(@NonNull String serialized);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,5 +7,29 @@ interface Job {
|
|||||||
|
|
||||||
val maxFailureCount: Int
|
val maxFailureCount: Int
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
//keys used for database storage purpose
|
||||||
|
private val KEY_ID = "id"
|
||||||
|
private val KEY_FAILURE_COUNT = "failure_count"
|
||||||
|
}
|
||||||
|
|
||||||
fun execute()
|
fun execute()
|
||||||
|
|
||||||
|
//database functions
|
||||||
|
|
||||||
|
fun serialize(): Data
|
||||||
|
|
||||||
|
fun initJob(data: Data) {
|
||||||
|
id = data.getString(KEY_ID)
|
||||||
|
failureCount = data.getInt(KEY_FAILURE_COUNT)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun createJobDataBuilder(): Data.Builder {
|
||||||
|
return Data.Builder().putString(KEY_ID, id)
|
||||||
|
.putInt(KEY_FAILURE_COUNT, failureCount)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Factory<T : Job> {
|
||||||
|
fun create(data: Data): T
|
||||||
|
}
|
||||||
}
|
}
|
@ -18,6 +18,12 @@ class MessageReceiveJob(val data: ByteArray, val isBackgroundPoll: Boolean, val
|
|||||||
val TAG = MessageReceiveJob::class.qualifiedName
|
val TAG = MessageReceiveJob::class.qualifiedName
|
||||||
|
|
||||||
val collection: String = "MessageReceiveJobCollection"
|
val collection: String = "MessageReceiveJobCollection"
|
||||||
|
|
||||||
|
//keys used for database storage purpose
|
||||||
|
private val KEY_DATA = "data"
|
||||||
|
private val KEY_IS_BACKGROUND_POLL = "is_background_poll"
|
||||||
|
private val KEY_OPEN_GROUP_MESSAGE_SERVER_ID = "openGroupMessageServerID"
|
||||||
|
private val KEY_OPEN_GROUP_ID = "open_group_id"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun execute() {
|
override fun execute() {
|
||||||
@ -54,4 +60,24 @@ class MessageReceiveJob(val data: ByteArray, val isBackgroundPoll: Boolean, val
|
|||||||
private fun handleFailure(e: Exception) {
|
private fun handleFailure(e: Exception) {
|
||||||
delegate?.handleJobFailed(this, e)
|
delegate?.handleJobFailed(this, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//database functions
|
||||||
|
|
||||||
|
override fun serialize(): Data {
|
||||||
|
val builder = this.createJobDataBuilder()
|
||||||
|
builder.putByteArray(KEY_DATA, data)
|
||||||
|
.putBoolean(KEY_IS_BACKGROUND_POLL, isBackgroundPoll)
|
||||||
|
openGroupMessageServerID?.let { builder.putLong(KEY_OPEN_GROUP_MESSAGE_SERVER_ID, openGroupMessageServerID) }
|
||||||
|
openGroupID?.let { builder.putString(KEY_OPEN_GROUP_ID, openGroupID) }
|
||||||
|
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
class Factory: Job.Factory<MessageReceiveJob> {
|
||||||
|
override fun create(data: Data): MessageReceiveJob {
|
||||||
|
val job = MessageReceiveJob(data.getByteArray(KEY_DATA), data.getBoolean(KEY_IS_BACKGROUND_POLL), data.getLong(KEY_OPEN_GROUP_MESSAGE_SERVER_ID), data.getString(KEY_OPEN_GROUP_ID))
|
||||||
|
job.initJob(data)
|
||||||
|
return job
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,12 +1,14 @@
|
|||||||
package org.session.libsession.messaging.jobs
|
package org.session.libsession.messaging.jobs
|
||||||
|
|
||||||
|
import com.esotericsoftware.kryo.Kryo
|
||||||
|
import com.esotericsoftware.kryo.io.Input
|
||||||
|
import com.esotericsoftware.kryo.io.Output
|
||||||
import org.session.libsession.messaging.MessagingConfiguration
|
import org.session.libsession.messaging.MessagingConfiguration
|
||||||
import org.session.libsession.messaging.messages.Destination
|
import org.session.libsession.messaging.messages.Destination
|
||||||
import org.session.libsession.messaging.messages.Message
|
import org.session.libsession.messaging.messages.Message
|
||||||
import org.session.libsession.messaging.messages.visible.VisibleMessage
|
import org.session.libsession.messaging.messages.visible.VisibleMessage
|
||||||
import org.session.libsession.messaging.sending_receiving.MessageSender
|
import org.session.libsession.messaging.sending_receiving.MessageSender
|
||||||
import org.session.libsignal.libsignal.logging.Log
|
import org.session.libsignal.libsignal.logging.Log
|
||||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
|
||||||
|
|
||||||
class MessageSendJob(val message: Message, val destination: Destination) : Job {
|
class MessageSendJob(val message: Message, val destination: Destination) : Job {
|
||||||
|
|
||||||
@ -20,6 +22,10 @@ class MessageSendJob(val message: Message, val destination: Destination) : Job {
|
|||||||
val TAG = MessageSendJob::class.qualifiedName
|
val TAG = MessageSendJob::class.qualifiedName
|
||||||
|
|
||||||
val collection: String = "MessageSendJobCollection"
|
val collection: String = "MessageSendJobCollection"
|
||||||
|
|
||||||
|
//keys used for database storage purpose
|
||||||
|
private val KEY_MESSAGE = "message"
|
||||||
|
private val KEY_DESTINATION = "destination"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun execute() {
|
override fun execute() {
|
||||||
@ -67,4 +73,42 @@ class MessageSendJob(val message: Message, val destination: Destination) : Job {
|
|||||||
}
|
}
|
||||||
delegate?.handleJobFailed(this, error)
|
delegate?.handleJobFailed(this, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//database functions
|
||||||
|
|
||||||
|
override fun serialize(): Data {
|
||||||
|
val builder = this.createJobDataBuilder()
|
||||||
|
//serialize Message and Destination properties
|
||||||
|
val kryo = Kryo()
|
||||||
|
kryo.isRegistrationRequired = false
|
||||||
|
val serializedMessage = ByteArray(4096)
|
||||||
|
val serializedDestination = ByteArray(4096)
|
||||||
|
var output = Output(serializedMessage)
|
||||||
|
kryo.writeObject(output, message)
|
||||||
|
output.close()
|
||||||
|
output = Output(serializedDestination)
|
||||||
|
kryo.writeObject(output, destination)
|
||||||
|
output.close()
|
||||||
|
return builder.putByteArray(KEY_MESSAGE, serializedMessage)
|
||||||
|
.putByteArray(KEY_DESTINATION, serializedDestination)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
class Factory: Job.Factory<MessageSendJob> {
|
||||||
|
override fun create(data: Data): MessageSendJob {
|
||||||
|
val serializedMessage = data.getByteArray(KEY_MESSAGE)
|
||||||
|
val serializedDestination = data.getByteArray(KEY_DESTINATION)
|
||||||
|
//deserialize Message and Destination properties
|
||||||
|
val kryo = Kryo()
|
||||||
|
var input = Input(serializedMessage)
|
||||||
|
val message: Message = kryo.readObject(input, Message::class.java)
|
||||||
|
input.close()
|
||||||
|
input = Input(serializedDestination)
|
||||||
|
val destination: Destination = kryo.readObject(input, Destination::class.java)
|
||||||
|
input.close()
|
||||||
|
val job = MessageSendJob(message, destination)
|
||||||
|
job.initJob(data)
|
||||||
|
return job
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,5 +1,8 @@
|
|||||||
package org.session.libsession.messaging.jobs
|
package org.session.libsession.messaging.jobs
|
||||||
|
|
||||||
|
import com.esotericsoftware.kryo.Kryo
|
||||||
|
import com.esotericsoftware.kryo.io.Input
|
||||||
|
import com.esotericsoftware.kryo.io.Output
|
||||||
import nl.komponents.kovenant.functional.map
|
import nl.komponents.kovenant.functional.map
|
||||||
import okhttp3.MediaType
|
import okhttp3.MediaType
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
@ -22,6 +25,9 @@ class NotifyPNServerJob(val message: SnodeMessage) : Job {
|
|||||||
override val maxFailureCount: Int = 20
|
override val maxFailureCount: Int = 20
|
||||||
companion object {
|
companion object {
|
||||||
val collection: String = "NotifyPNServerJobCollection"
|
val collection: String = "NotifyPNServerJobCollection"
|
||||||
|
|
||||||
|
//keys used for database storage purpose
|
||||||
|
private val KEY_MESSAGE = "message"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Running
|
// Running
|
||||||
@ -54,4 +60,33 @@ class NotifyPNServerJob(val message: SnodeMessage) : Job {
|
|||||||
private fun handleFailure(error: Exception) {
|
private fun handleFailure(error: Exception) {
|
||||||
delegate?.handleJobFailed(this, error)
|
delegate?.handleJobFailed(this, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//database functions
|
||||||
|
|
||||||
|
override fun serialize(): Data {
|
||||||
|
val builder = this.createJobDataBuilder()
|
||||||
|
//serialize SnodeMessage property
|
||||||
|
val kryo = Kryo()
|
||||||
|
kryo.isRegistrationRequired = false
|
||||||
|
val serializedMessage = ByteArray(4096)
|
||||||
|
val output = Output(serializedMessage)
|
||||||
|
kryo.writeObject(output, message)
|
||||||
|
output.close()
|
||||||
|
return builder.putByteArray(KEY_MESSAGE, serializedMessage)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
class Factory: Job.Factory<NotifyPNServerJob> {
|
||||||
|
override fun create(data: Data): NotifyPNServerJob {
|
||||||
|
val serializedMessage = data.getByteArray(KEY_MESSAGE)
|
||||||
|
//deserialize SnodeMessage property
|
||||||
|
val kryo = Kryo()
|
||||||
|
val input = Input(serializedMessage)
|
||||||
|
val message: SnodeMessage = kryo.readObject(input, SnodeMessage::class.java)
|
||||||
|
input.close()
|
||||||
|
val job = NotifyPNServerJob(message)
|
||||||
|
job.initJob(data)
|
||||||
|
return job
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package org.thoughtcrime.securesms.util
|
package org.session.libsession.utilities
|
||||||
|
|
||||||
import android.os.Parcel
|
import android.os.Parcel
|
||||||
|
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
|
|
||||||
object ParcelableUtil {
|
object ParcelableUtil {
|
Loading…
Reference in New Issue
Block a user