Merge branch 'main' into adb/allow-to-edit-and-delete-for-all

This commit is contained in:
adb
2025-03-12 18:50:17 +00:00
committed by GitHub
96 changed files with 1596 additions and 870 deletions
@@ -17,6 +17,7 @@ public class DcContext {
public final static int DC_EVENT_MSG_READ = 2015;
public final static int DC_EVENT_CHAT_MODIFIED = 2020;
public final static int DC_EVENT_CHAT_EPHEMERAL_TIMER_MODIFIED = 2021;
public final static int DC_EVENT_CHAT_DELETED = 2023;
public final static int DC_EVENT_CONTACTS_CHANGED = 2030;
public final static int DC_EVENT_LOCATION_CHANGED = 2035;
public final static int DC_EVENT_CONFIGURE_PROGRESS = 2041;
@@ -17,6 +17,7 @@ public class Rpc {
private final Map<Integer, SettableFuture<JsonElement>> requestFutures = new ConcurrentHashMap<>();
private final DcJsonrpcInstance dcJsonrpcInstance;
private int requestId = 0;
private boolean started = false;
private final Gson gson = new GsonBuilder().serializeNulls().create();
public Rpc(DcJsonrpcInstance dcJsonrpcInstance) {
@@ -46,6 +47,7 @@ public class Rpc {
}
public void start() {
started = true;
new Thread(() -> {
while (true) {
try {
@@ -57,7 +59,9 @@ public class Rpc {
}, "jsonrpcThread").start();
}
public SettableFuture<JsonElement> call(String method, Object... params) {
public SettableFuture<JsonElement> call(String method, Object... params) throws RpcException {
if (!started) throw new RpcException("RPC not started yet.");
int id;
synchronized (this) {
id = ++requestId;