mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 10:05:15 +00:00
clean
This commit is contained in:
parent
5cb3a79a27
commit
c7af1cabe3
@ -12,10 +12,10 @@ import android.util.Pair;
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
|
||||
import org.session.libsignal.service.loki.utilities.ThreadUtils;
|
||||
import org.session.libsignal.utilities.ThreadUtils;
|
||||
import org.session.libsession.utilities.Util;
|
||||
import org.session.libsession.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsession.utilities.concurrent.SettableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.SettableFuture;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
@ -8,7 +8,7 @@ import android.widget.ImageView;
|
||||
|
||||
import com.bumptech.glide.request.target.BitmapImageViewTarget;
|
||||
|
||||
import org.session.libsession.utilities.concurrent.SettableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.SettableFuture;
|
||||
|
||||
public class GlideBitmapListeningTarget extends BitmapImageViewTarget {
|
||||
|
||||
|
@ -7,7 +7,7 @@ import android.widget.ImageView;
|
||||
|
||||
import com.bumptech.glide.request.target.DrawableImageViewTarget;
|
||||
|
||||
import org.session.libsession.utilities.concurrent.SettableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.SettableFuture;
|
||||
|
||||
public class GlideDrawableListeningTarget extends DrawableImageViewTarget {
|
||||
|
||||
|
@ -44,8 +44,8 @@ import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.Util;
|
||||
import org.session.libsession.utilities.ViewUtil;
|
||||
import org.session.libsession.utilities.concurrent.AssertedSuccessListener;
|
||||
import org.session.libsession.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsession.utilities.concurrent.SettableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.SettableFuture;
|
||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -33,8 +33,8 @@ import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
|
||||
import org.session.libsession.utilities.Util;
|
||||
import org.session.libsession.utilities.ViewUtil;
|
||||
import org.session.libsession.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsession.utilities.concurrent.SettableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.SettableFuture;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
|
@ -11,8 +11,8 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.session.libsession.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsession.utilities.concurrent.SettableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.SettableFuture;
|
||||
|
||||
import org.session.libsession.utilities.ViewUtil;
|
||||
|
||||
|
@ -204,8 +204,8 @@ import org.session.libsession.utilities.ExpirationUtil;
|
||||
import org.session.libsession.utilities.views.Stub;
|
||||
import org.session.libsession.utilities.ViewUtil;
|
||||
import org.session.libsession.utilities.concurrent.AssertedSuccessListener;
|
||||
import org.session.libsession.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsession.utilities.concurrent.SettableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.SettableFuture;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.TextSecurePreferences.MediaKeyboardMode;
|
||||
|
||||
|
@ -10,11 +10,10 @@ import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.session.libsession.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.ListenableFuture;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
|
@ -27,6 +27,7 @@ import org.session.libsignal.metadata.ProtocolNoSessionException;
|
||||
import org.session.libsignal.metadata.ProtocolUntrustedIdentityException;
|
||||
import org.session.libsignal.metadata.SelfSendException;
|
||||
import org.session.libsignal.service.loki.api.crypto.SessionProtocol;
|
||||
import org.session.libsignal.utilities.PromiseUtilities;
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
|
||||
import org.session.libsession.messaging.sending_receiving.linkpreview.LinkPreview;
|
||||
@ -40,7 +41,6 @@ import org.session.libsession.messaging.sending_receiving.attachments.StickerLoc
|
||||
import org.session.libsession.messaging.threads.Address;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.session.libsession.messaging.sending_receiving.notifications.MessageNotifier;
|
||||
import org.session.libsession.utilities.PromiseUtilities;
|
||||
import org.session.libsession.utilities.GroupUtil;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
|
||||
|
@ -6,8 +6,8 @@ import androidx.annotation.WorkerThread;
|
||||
|
||||
import org.thoughtcrime.securesms.database.NoExternalStorageException;
|
||||
|
||||
import org.session.libsession.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsession.utilities.concurrent.SettableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.SettableFuture;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
|
@ -6,7 +6,6 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.database.Cursor
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableString
|
||||
@ -51,7 +50,7 @@ import org.session.libsignal.service.loki.protocol.meta.SessionMetaProtocol
|
||||
import org.session.libsignal.service.loki.protocol.sessionmanagement.SessionManagementProtocol
|
||||
import org.session.libsignal.service.loki.protocol.shelved.multidevice.MultiDeviceProtocol
|
||||
import org.session.libsignal.service.loki.protocol.shelved.syncmessages.SyncMessagesProtocol
|
||||
import org.session.libsignal.service.loki.utilities.ThreadUtils
|
||||
import org.session.libsignal.utilities.ThreadUtils
|
||||
import org.session.libsignal.service.loki.utilities.toHexString
|
||||
import org.thoughtcrime.securesms.loki.dialogs.*
|
||||
import org.thoughtcrime.securesms.loki.protocol.ClosedGroupsProtocolV2
|
||||
|
@ -8,9 +8,8 @@ import nl.komponents.kovenant.functional.map
|
||||
import org.thoughtcrime.securesms.jobs.PushContentReceiveJob
|
||||
import org.thoughtcrime.securesms.logging.Log
|
||||
import org.thoughtcrime.securesms.loki.database.SharedSenderKeysDatabase
|
||||
import org.session.libsession.utilities.successBackground
|
||||
import org.session.libsignal.utilities.successBackground
|
||||
import org.session.libsignal.service.api.messages.SignalServiceEnvelope
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||
import org.session.libsignal.service.loki.api.SnodeAPI
|
||||
import org.session.libsignal.service.loki.api.SwarmAPI
|
||||
import org.session.libsignal.service.loki.utilities.getRandomElementOrNull
|
||||
|
@ -14,10 +14,10 @@ import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.jobs.PushDecryptJob
|
||||
import org.thoughtcrime.securesms.jobs.RetrieveProfileAvatarJob
|
||||
import org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol
|
||||
import org.session.libsession.utilities.successBackground
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
import org.session.libsignal.libsignal.util.guava.Optional
|
||||
import org.session.libsignal.utilities.successBackground
|
||||
import org.session.libsignal.service.api.messages.SignalServiceAttachmentPointer
|
||||
import org.session.libsignal.service.api.messages.SignalServiceContent
|
||||
import org.session.libsignal.service.api.messages.SignalServiceDataMessage
|
||||
@ -31,7 +31,6 @@ import org.session.libsignal.service.loki.api.opengroups.PublicChatMessage
|
||||
import org.session.libsignal.service.loki.protocol.shelved.multidevice.MultiDeviceProtocol
|
||||
import java.security.MessageDigest
|
||||
import java.util.*
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
||||
class PublicChatPoller(private val context: Context, private val group: PublicChat) {
|
||||
private val handler by lazy { Handler() }
|
||||
|
@ -12,7 +12,7 @@ import org.session.libsignal.libsignal.ecc.ECKeyPair
|
||||
import org.session.libsignal.libsignal.util.guava.Optional
|
||||
import org.session.libsignal.service.api.messages.SignalServiceGroup
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||
import org.session.libsignal.service.loki.utilities.ThreadUtils
|
||||
import org.session.libsignal.utilities.ThreadUtils
|
||||
import org.session.libsignal.service.loki.utilities.hexEncodedPublicKey
|
||||
import org.session.libsignal.service.loki.utilities.removing05PrefixIfNeeded
|
||||
import org.session.libsignal.service.loki.utilities.toHexString
|
||||
|
@ -8,7 +8,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import org.thoughtcrime.securesms.logging.Log
|
||||
import com.opencsv.CSVReader
|
||||
import org.session.libsignal.service.loki.api.onionrequests.OnionRequestAPI
|
||||
import org.session.libsignal.service.loki.utilities.ThreadUtils
|
||||
import org.session.libsignal.utilities.ThreadUtils
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.FileReader
|
||||
|
@ -52,8 +52,8 @@ import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.session.libsession.utilities.Util;
|
||||
import org.session.libsession.utilities.views.Stub;
|
||||
import org.session.libsession.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsession.utilities.concurrent.SettableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.SettableFuture;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -67,9 +67,9 @@ import org.session.libsession.utilities.ViewUtil;
|
||||
import org.session.libsession.utilities.views.Stub;
|
||||
import org.session.libsession.utilities.Util;
|
||||
import org.session.libsession.utilities.concurrent.AssertedSuccessListener;
|
||||
import org.session.libsession.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsession.utilities.concurrent.ListenableFuture.Listener;
|
||||
import org.session.libsession.utilities.concurrent.SettableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.ListenableFuture.Listener;
|
||||
import org.session.libsignal.utilities.concurrent.SettableFuture;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -10,7 +10,7 @@ import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.loki.api.PublicChatManager;
|
||||
import org.thoughtcrime.securesms.util.Debouncer;
|
||||
import org.session.libsignal.service.loki.api.Poller;
|
||||
import org.session.libsignal.service.loki.utilities.ThreadUtils;
|
||||
import org.session.libsignal.utilities.ThreadUtils;
|
||||
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.session.libsession.messaging.sending_receiving.notifications.MessageNotifier;
|
||||
|
@ -9,15 +9,12 @@ import org.session.libsession.messaging.MessagingConfiguration
|
||||
|
||||
import org.session.libsession.messaging.utilities.DotNetAPI
|
||||
import org.session.libsession.messaging.fileserver.FileServerAPI
|
||||
import org.session.libsignal.service.loki.utilities.ThreadUtils
|
||||
import org.session.libsession.utilities.createContext
|
||||
|
||||
import org.session.libsignal.libsignal.logging.Log
|
||||
import org.session.libsignal.utilities.Hex
|
||||
import org.session.libsignal.utilities.Base64
|
||||
import org.session.libsignal.utilities.JsonUtil
|
||||
import org.session.libsignal.utilities.*
|
||||
import org.session.libsignal.service.loki.utilities.DownloadUtilities
|
||||
import org.session.libsignal.service.loki.utilities.retryIfNeeded
|
||||
import org.session.libsignal.utilities.Base64
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
@ -10,7 +10,7 @@ import org.session.libsession.messaging.jobs.JobQueue
|
||||
import org.session.libsession.messaging.jobs.MessageReceiveJob
|
||||
import org.session.libsession.messaging.utilities.MessageWrapper
|
||||
import org.session.libsession.snode.SnodeAPI
|
||||
import org.session.libsession.utilities.successBackground
|
||||
import org.session.libsignal.utilities.successBackground
|
||||
|
||||
import org.session.libsignal.libsignal.logging.Log
|
||||
import org.session.libsignal.utilities.Base64
|
||||
|
@ -11,9 +11,8 @@ import org.session.libsession.messaging.jobs.MessageReceiveJob
|
||||
import org.session.libsession.messaging.opengroups.OpenGroup
|
||||
import org.session.libsession.messaging.opengroups.OpenGroupAPI
|
||||
import org.session.libsession.messaging.opengroups.OpenGroupMessage
|
||||
import org.session.libsession.utilities.GroupUtil
|
||||
import org.session.libsession.utilities.successBackground
|
||||
|
||||
import org.session.libsignal.utilities.successBackground
|
||||
import org.session.libsignal.libsignal.logging.Log
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos.*
|
||||
|
||||
|
@ -26,6 +26,7 @@ import org.session.libsignal.utilities.Hex
|
||||
import org.session.libsignal.utilities.JsonUtil
|
||||
import org.session.libsignal.service.loki.api.utilities.HTTP
|
||||
import org.session.libsignal.service.loki.utilities.*
|
||||
import org.session.libsignal.utilities.*
|
||||
import org.session.libsignal.utilities.Base64
|
||||
|
||||
import java.io.File
|
||||
|
@ -9,12 +9,12 @@ import okhttp3.Request
|
||||
import org.session.libsession.utilities.AESGCM
|
||||
import org.session.libsignal.libsignal.logging.Log
|
||||
import org.session.libsignal.utilities.Base64
|
||||
import org.session.libsignal.utilities.JsonUtil
|
||||
import org.session.libsignal.utilities.*
|
||||
import org.session.libsignal.service.loki.api.*
|
||||
import org.session.libsignal.service.loki.api.fileserver.FileServerAPI
|
||||
import org.session.libsignal.service.loki.api.utilities.*
|
||||
import org.session.libsession.utilities.AESGCM.EncryptionResult
|
||||
import org.session.libsignal.service.loki.utilities.ThreadUtils
|
||||
import org.session.libsignal.utilities.ThreadUtils
|
||||
import org.session.libsession.utilities.getBodyForOnionRequest
|
||||
import org.session.libsession.utilities.getHeadersForOnionRequest
|
||||
import org.session.libsignal.service.loki.utilities.*
|
||||
|
@ -5,7 +5,7 @@ import nl.komponents.kovenant.deferred
|
||||
import org.session.libsignal.utilities.JsonUtil
|
||||
import org.session.libsession.utilities.AESGCM.EncryptionResult
|
||||
import org.session.libsession.utilities.AESGCM
|
||||
import org.session.libsignal.service.loki.utilities.ThreadUtils
|
||||
import org.session.libsignal.utilities.ThreadUtils
|
||||
import org.session.libsignal.service.loki.utilities.toHexString
|
||||
import java.nio.Buffer
|
||||
import java.nio.ByteBuffer
|
||||
|
@ -7,13 +7,12 @@ import nl.komponents.kovenant.functional.bind
|
||||
import nl.komponents.kovenant.functional.map
|
||||
|
||||
import org.session.libsession.snode.utilities.getRandomElement
|
||||
import org.session.libsignal.service.loki.utilities.ThreadUtils
|
||||
import org.session.libsession.utilities.createContext
|
||||
|
||||
import org.session.libsignal.libsignal.logging.Log
|
||||
import org.session.libsignal.service.loki.api.utilities.HTTP
|
||||
import org.session.libsignal.service.loki.utilities.prettifiedDescription
|
||||
import org.session.libsignal.service.loki.utilities.retryIfNeeded
|
||||
import org.session.libsignal.utilities.*
|
||||
|
||||
import java.security.SecureRandom
|
||||
|
||||
|
@ -39,8 +39,8 @@ import androidx.annotation.Nullable;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
|
||||
|
||||
import org.session.libsession.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsession.utilities.concurrent.SettableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.SettableFuture;
|
||||
import org.session.libsession.utilities.views.Stub;
|
||||
|
||||
public class ViewUtil {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.session.libsession.utilities.concurrent;
|
||||
|
||||
import org.session.libsession.utilities.concurrent.ListenableFuture.Listener;
|
||||
import org.session.libsignal.utilities.concurrent.ListenableFuture.Listener;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
|
@ -64,7 +64,7 @@ import org.session.libsignal.service.internal.push.http.OutputStreamFactory;
|
||||
import org.session.libsignal.utilities.Base64;
|
||||
import org.session.libsignal.service.internal.util.StaticCredentialsProvider;
|
||||
import org.session.libsignal.service.internal.util.Util;
|
||||
import org.session.libsignal.service.internal.util.concurrent.SettableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.SettableFuture;
|
||||
import org.session.libsignal.service.loki.api.LokiDotNetAPI;
|
||||
import org.session.libsignal.service.loki.api.PushNotificationAPI;
|
||||
import org.session.libsignal.service.loki.api.SignalMessageInfo;
|
||||
|
@ -1,13 +0,0 @@
|
||||
package org.session.libsignal.service.internal.util.concurrent;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public interface ListenableFuture<T> extends Future<T> {
|
||||
void addListener(Listener<T> listener);
|
||||
|
||||
public interface Listener<T> {
|
||||
public void onSuccess(T result);
|
||||
public void onFailure(ExecutionException e);
|
||||
}
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
package org.session.libsignal.service.internal.util.concurrent;
|
||||
|
||||
import org.session.libsignal.service.internal.util.concurrent.ListenableFuture;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
public class SettableFuture<T> implements ListenableFuture<T> {
|
||||
|
||||
private final List<Listener<T>> listeners = new LinkedList<Listener<T>>();
|
||||
|
||||
private boolean completed;
|
||||
private boolean canceled;
|
||||
private volatile T result;
|
||||
private volatile Throwable exception;
|
||||
|
||||
@Override
|
||||
public synchronized boolean cancel(boolean mayInterruptIfRunning) {
|
||||
if (!completed && !canceled) {
|
||||
canceled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isCancelled() {
|
||||
return canceled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isDone() {
|
||||
return completed;
|
||||
}
|
||||
|
||||
public boolean set(T result) {
|
||||
synchronized (this) {
|
||||
if (completed || canceled) return false;
|
||||
|
||||
this.result = result;
|
||||
this.completed = true;
|
||||
|
||||
notifyAll();
|
||||
}
|
||||
|
||||
notifyAllListeners();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setException(Throwable throwable) {
|
||||
synchronized (this) {
|
||||
if (completed || canceled) return false;
|
||||
|
||||
this.exception = throwable;
|
||||
this.completed = true;
|
||||
|
||||
notifyAll();
|
||||
}
|
||||
|
||||
notifyAllListeners();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized T get() throws InterruptedException, ExecutionException {
|
||||
while (!completed) wait();
|
||||
|
||||
if (exception != null) throw new ExecutionException(exception);
|
||||
else return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized T get(long timeout, TimeUnit unit)
|
||||
throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
while (!completed && System.currentTimeMillis() - startTime < unit.toMillis(timeout)) {
|
||||
wait(unit.toMillis(timeout));
|
||||
}
|
||||
|
||||
if (!completed) throw new TimeoutException();
|
||||
else return get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(Listener<T> listener) {
|
||||
synchronized (this) {
|
||||
listeners.add(listener);
|
||||
|
||||
if (!completed) return;
|
||||
}
|
||||
|
||||
notifyListener(listener);
|
||||
}
|
||||
|
||||
private void notifyAllListeners() {
|
||||
List<Listener<T>> localListeners;
|
||||
|
||||
synchronized (this) {
|
||||
localListeners = new LinkedList<Listener<T>>(listeners);
|
||||
}
|
||||
|
||||
for (Listener<T> listener : localListeners) {
|
||||
notifyListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyListener(Listener<T> listener) {
|
||||
if (exception != null) listener.onFailure(new ExecutionException(exception));
|
||||
else listener.onSuccess(result);
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ import org.session.libsignal.service.api.util.Tls12SocketFactory;
|
||||
import org.session.libsignal.service.api.websocket.ConnectivityListener;
|
||||
import org.session.libsignal.service.internal.util.BlacklistingTrustManager;
|
||||
import org.session.libsignal.service.internal.util.Util;
|
||||
import org.session.libsignal.service.internal.util.concurrent.SettableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.SettableFuture;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.KeyManagementException;
|
||||
|
@ -25,9 +25,9 @@ import org.session.libsignal.service.loki.api.fileserver.FileServerAPI
|
||||
import org.session.libsignal.service.loki.api.onionrequests.OnionRequestAPI
|
||||
import org.session.libsignal.service.loki.api.utilities.HTTP
|
||||
import org.session.libsignal.service.loki.database.LokiAPIDatabaseProtocol
|
||||
import org.session.libsignal.service.loki.utilities.recover
|
||||
import org.session.libsignal.service.loki.utilities.removing05PrefixIfNeeded
|
||||
import org.session.libsignal.service.loki.utilities.retryIfNeeded
|
||||
import org.session.libsignal.utilities.recover
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,7 @@ import org.session.libsignal.libsignal.logging.Log
|
||||
import org.session.libsignal.utilities.Base64
|
||||
import org.session.libsignal.service.loki.api.crypto.ProofOfWork
|
||||
import org.session.libsignal.service.loki.protocol.meta.TTLUtilities
|
||||
import org.session.libsignal.service.loki.utilities.ThreadUtils
|
||||
import org.session.libsignal.utilities.ThreadUtils
|
||||
import org.session.libsignal.service.loki.utilities.prettifiedDescription
|
||||
|
||||
internal data class LokiMessage(
|
||||
|
@ -13,6 +13,7 @@ import org.session.libsignal.service.loki.api.onionrequests.OnionRequestAPI
|
||||
import org.session.libsignal.service.loki.api.utilities.HTTP
|
||||
import org.session.libsignal.service.loki.database.LokiAPIDatabaseProtocol
|
||||
import org.session.libsignal.service.loki.utilities.*
|
||||
import org.session.libsignal.utilities.*
|
||||
import java.net.ConnectException
|
||||
import java.net.SocketTimeoutException
|
||||
|
||||
|
@ -8,7 +8,7 @@ import nl.komponents.kovenant.task
|
||||
import org.session.libsignal.libsignal.logging.Log
|
||||
import org.session.libsignal.service.loki.api.utilities.HTTP
|
||||
import org.session.libsignal.service.loki.database.LokiAPIDatabaseProtocol
|
||||
import org.session.libsignal.service.loki.utilities.ThreadUtils
|
||||
import org.session.libsignal.utilities.ThreadUtils
|
||||
import org.session.libsignal.service.loki.utilities.getRandomElement
|
||||
import org.session.libsignal.service.loki.utilities.prettifiedDescription
|
||||
import org.session.libsignal.service.loki.utilities.retryIfNeeded
|
||||
|
@ -16,6 +16,7 @@ import org.session.libsignal.service.loki.api.utilities.EncryptionResult
|
||||
import org.session.libsignal.service.loki.api.utilities.getBodyForOnionRequest
|
||||
import org.session.libsignal.service.loki.api.utilities.getHeadersForOnionRequest
|
||||
import org.session.libsignal.service.loki.utilities.*
|
||||
import org.session.libsignal.utilities.*
|
||||
|
||||
private typealias Path = List<Snode>
|
||||
|
||||
|
@ -5,7 +5,7 @@ import nl.komponents.kovenant.deferred
|
||||
import org.session.libsignal.utilities.JsonUtil
|
||||
import org.session.libsignal.service.loki.api.utilities.EncryptionResult
|
||||
import org.session.libsignal.service.loki.api.utilities.EncryptionUtilities
|
||||
import org.session.libsignal.service.loki.utilities.ThreadUtils
|
||||
import org.session.libsignal.utilities.ThreadUtils
|
||||
import org.session.libsignal.service.loki.utilities.toHexString
|
||||
import java.nio.Buffer
|
||||
import java.nio.ByteBuffer
|
||||
|
@ -16,8 +16,7 @@ import org.session.libsignal.service.loki.database.LokiAPIDatabaseProtocol
|
||||
import org.session.libsignal.service.loki.database.LokiOpenGroupDatabaseProtocol
|
||||
import org.session.libsignal.service.loki.database.LokiUserDatabaseProtocol
|
||||
import org.session.libsignal.service.loki.utilities.DownloadUtilities
|
||||
import org.session.libsignal.service.loki.utilities.ThreadUtils
|
||||
import org.session.libsignal.service.loki.utilities.createContext
|
||||
import org.session.libsignal.utilities.*
|
||||
import org.session.libsignal.service.loki.utilities.retryIfNeeded
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.text.SimpleDateFormat
|
||||
|
@ -1,40 +0,0 @@
|
||||
@file:JvmName("PromiseUtilities")
|
||||
package org.session.libsignal.service.loki.utilities
|
||||
|
||||
import nl.komponents.kovenant.*
|
||||
import nl.komponents.kovenant.jvm.asDispatcher
|
||||
import org.session.libsignal.libsignal.logging.Log
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
fun Kovenant.createContext(): Context {
|
||||
return createContext {
|
||||
callbackContext.dispatcher = Executors.newSingleThreadExecutor().asDispatcher()
|
||||
workerContext.dispatcher = ThreadUtils.executorPool.asDispatcher()
|
||||
multipleCompletion = { v1, v2 ->
|
||||
Log.d("Loki", "Promise resolved more than once (first with $v1, then with $v2); ignoring $v2.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <V, E : Throwable> Promise<V, E>.get(defaultValue: V): V {
|
||||
return try {
|
||||
get()
|
||||
} catch (e: Exception) {
|
||||
defaultValue
|
||||
}
|
||||
}
|
||||
|
||||
fun <V, E : Throwable> Promise<V, E>.recover(callback: (exception: E) -> V): Promise<V, E> {
|
||||
val deferred = deferred<V, E>()
|
||||
success {
|
||||
deferred.resolve(it)
|
||||
}.fail {
|
||||
try {
|
||||
val value = callback(it)
|
||||
deferred.resolve(value)
|
||||
} catch (e: Throwable) {
|
||||
deferred.reject(it)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
@file:JvmName("PromiseUtilities")
|
||||
package org.session.libsession.utilities
|
||||
package org.session.libsignal.utilities
|
||||
|
||||
import nl.komponents.kovenant.Context
|
||||
import nl.komponents.kovenant.Kovenant
|
||||
@ -7,7 +7,6 @@ import nl.komponents.kovenant.Promise
|
||||
import nl.komponents.kovenant.deferred
|
||||
import nl.komponents.kovenant.jvm.asDispatcher
|
||||
import org.session.libsignal.libsignal.logging.Log
|
||||
import org.session.libsignal.service.loki.utilities.ThreadUtils
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeoutException
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.session.libsignal.service.loki.utilities
|
||||
package org.session.libsignal.utilities
|
||||
|
||||
import java.util.concurrent.*
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.session.libsession.utilities.concurrent;
|
||||
package org.session.libsignal.utilities.concurrent;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
@ -1,4 +1,4 @@
|
||||
package org.session.libsession.utilities.concurrent;
|
||||
package org.session.libsignal.utilities.concurrent;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
Loading…
Reference in New Issue
Block a user