feat: Move to addTransport / addTransportFromQr API (#3676), remove AEAP message (#3698)

This commit is contained in:
Hocuri 2025-04-02 18:14:49 +02:00 committed by GitHub
parent e2d7f2c3d3
commit 10c4a105bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 256 additions and 54 deletions

View file

@ -1,5 +1,7 @@
package com.b44t.messenger.rpc;
import android.util.Log;
import com.b44t.messenger.DcJsonrpcInstance;
import com.b44t.messenger.util.concurrent.SettableFuture;
import com.google.gson.Gson;
@ -8,12 +10,16 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import org.thoughtcrime.securesms.qr.QrShowFragment;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
public class Rpc {
private final static String TAG = Rpc.class.getSimpleName();
private final Map<Integer, SettableFuture<JsonElement>> requestFutures = new ConcurrentHashMap<>();
private final DcJsonrpcInstance dcJsonrpcInstance;
private int requestId = 0;
@ -38,7 +44,14 @@ public class Rpc {
}
if (response.error != null) {
future.setException(new RpcException(response.error.toString()));
String message;
try {
message = response.error.getAsJsonObject().get("message").getAsString();
} catch (Exception e) {
Log.e(TAG, "Can't get response error message: " + e);
message = response.error.toString();
}
future.setException(new RpcException(message));
} else if (response.result != null) {
future.set(response.result);
} else {
@ -137,6 +150,14 @@ public class Rpc {
return getResult("add_account").getAsInt();
}
public void addTransportFromQr(int accountId, String qrCode) throws RpcException {
getResult("add_transport_from_qr", accountId, qrCode);
}
public void addTransport(int accountId, EnteredLoginParam param) throws RpcException {
getResult("add_transport", accountId, param);
}
private static class Request {
private final String jsonrpc = "2.0";
public final String method;