Skip to content

Commit 3378f77

Browse files
committed
Merge remote-tracking branch 'origin/main' into hoc/channels-encryption-only-qrcodes
2 parents 694c36a + a07e931 commit 3378f77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+970
-656
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
* warn if the app has not been updated after 6 months instead of 1 year
1616
* avoid "unknown sender for this chat" error
1717
* properly display "Messages are end-to-end encrypted." in all encrypted groups
18+
* show dialog if user has permanently denied camera permission and tries to take picture for group avatar
1819
* several small fixes and improvements
19-
* update to core 2.13.0
20+
* update to core 2.17.0
2021

2122
## v2.11.0
2223
2025-08

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,28 @@ subproject _deltachat-core-rust_:
2323
or later by `git submodule update --init --recursive`. If you do this in your
2424
home directory, this results in the folder `~/deltachat-android` which is just fine.
2525

26+
# Generate JSON-RPC bindings
27+
28+
To generate the JSON-RPC bindings (ex. `chat.delta.rpc.*` package)
29+
install the [dcrpcgen tool](https://github.com/chatmail/dcrpcgen)
30+
then generate the `schema.json` file:
31+
32+
```
33+
# install deltachat-rpc-server program:
34+
cargo install --path ./jni/deltachat-core-rust/deltachat-rpc-server
35+
# check the version of core matches:
36+
deltachat-rpc-server --version
37+
# generate the schema:
38+
deltachat-rpc-server --openrpc > schema.json
39+
```
40+
41+
then pass the schema file to the `dcrpcgen` tool to generate the
42+
code:
43+
44+
```
45+
dcrpcgen java --schema schema.json -o ./src/main/java/
46+
```
47+
2648
# Build Using Nix
2749

2850
The repository contains [Nix](https://nixos.org/) development environment

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ dependencies {
173173
implementation 'com.google.zxing:core:3.3.0' // fixed version to support SDK<24
174174
implementation ('com.journeyapps:zxing-android-embedded:4.3.0') { transitive = false } // QR Code scanner
175175
implementation 'com.fasterxml.jackson.core:jackson-databind:2.11.1' // used as JSON library
176-
implementation 'com.google.code.gson:gson:2.12.1' // used as JSON library.
177176
implementation 'com.github.Baseflow:PhotoView:2.3.0' // does the zooming on photos / media
178177
implementation 'com.github.penfeizhou.android.animation:awebp:3.0.5' // animated webp support.
179178
implementation 'com.caverock:androidsvg-aar:1.4' // SVG support.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/* Autogenerated file, do not edit manually */
2+
package chat.delta.rpc;
3+
4+
import chat.delta.util.SettableFuture;
5+
6+
import com.fasterxml.jackson.core.JsonProcessingException;
7+
import com.fasterxml.jackson.core.type.TypeReference;
8+
import com.fasterxml.jackson.databind.JsonNode;
9+
import com.fasterxml.jackson.databind.ObjectMapper;
10+
11+
import java.io.IOException;
12+
import java.util.Map;
13+
import java.util.concurrent.ConcurrentHashMap;
14+
import java.util.concurrent.ExecutionException;
15+
16+
/* Basic RPC Transport implementation */
17+
public abstract class BaseTransport implements Rpc.Transport {
18+
private final Map<Integer, SettableFuture<JsonNode>> requestFutures = new ConcurrentHashMap<>();
19+
private int requestId = 0;
20+
private final ObjectMapper mapper = new ObjectMapper();
21+
private Thread worker;
22+
23+
/* Send a Request as raw JSON String to the RPC server */
24+
protected abstract void sendRequest(String jsonRequest);
25+
26+
/* Get next Response as raw JSON String from the RPC server */
27+
protected abstract String getResponse();
28+
29+
public ObjectMapper getObjectMapper() {
30+
return mapper;
31+
}
32+
33+
public void call(String method, JsonNode... params) throws RpcException {
34+
innerCall(method, params);
35+
}
36+
37+
public <T> T callForResult(TypeReference<T> resultType, String method, JsonNode... params) throws RpcException {
38+
try {
39+
JsonNode node = innerCall(method, params);
40+
if (node.isNull()) return null;
41+
return mapper.readValue(node.traverse(), resultType);
42+
} catch (IOException e) {
43+
throw new RpcException(e.getMessage());
44+
}
45+
}
46+
47+
private JsonNode innerCall(String method, JsonNode... params) throws RpcException {
48+
int id;
49+
synchronized (this) {
50+
id = ++requestId;
51+
ensureWorkerThread();
52+
}
53+
try {
54+
String jsonRequest = mapper.writeValueAsString(new Request(method, params, id));
55+
SettableFuture<JsonNode> future = new SettableFuture<>();
56+
requestFutures.put(id, future);
57+
sendRequest(jsonRequest);
58+
return future.get();
59+
} catch (ExecutionException e) {
60+
throw (RpcException)e.getCause();
61+
} catch (InterruptedException e) {
62+
throw new RpcException(e.getMessage());
63+
} catch (JsonProcessingException e) {
64+
throw new RpcException(e.getMessage());
65+
}
66+
}
67+
68+
private void ensureWorkerThread() {
69+
if (worker != null) return;
70+
71+
worker = new Thread(() -> {
72+
while (true) {
73+
try {
74+
processResponse();
75+
} catch (JsonProcessingException e) {
76+
e.printStackTrace();
77+
}
78+
}
79+
}, "jsonrpcThread");
80+
worker.start();
81+
}
82+
83+
private void processResponse() throws JsonProcessingException {
84+
String jsonResponse = getResponse();
85+
Response response = mapper.readValue(jsonResponse, Response.class);
86+
87+
if (response.id == 0) { // Got JSON-RPC notification/event, ignore
88+
return;
89+
}
90+
91+
SettableFuture<JsonNode> future = requestFutures.remove(response.id);
92+
if (future == null) { // Got a response with unknown ID, ignore
93+
return;
94+
}
95+
96+
if (response.error != null) {
97+
future.setException(new RpcException(response.error.toString()));
98+
} else if (response.result != null) {
99+
future.set(response.result);
100+
} else {
101+
future.setException(new RpcException("Got JSON-RPC response without result or error: " + jsonResponse));
102+
}
103+
}
104+
105+
private static class Request {
106+
private final String jsonrpc = "2.0";
107+
public final String method;
108+
public final JsonNode[] params;
109+
public final int id;
110+
111+
public Request(String method, JsonNode[] params, int id) {
112+
this.method = method;
113+
this.params = params;
114+
this.id = id;
115+
}
116+
}
117+
118+
private static class Response {
119+
public String jsonrpc;
120+
public int id;
121+
public JsonNode result;
122+
public JsonNode error;
123+
}
124+
}

0 commit comments

Comments
 (0)