mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Extract SignalAccount from Manager
This commit is contained in:
parent
701328b8c2
commit
35c72f692f
30 changed files with 793 additions and 549 deletions
|
@ -129,13 +129,11 @@ public class Main {
|
|||
|
||||
m = new Manager(username, settingsPath);
|
||||
ts = m;
|
||||
if (m.userExists()) {
|
||||
try {
|
||||
m.init();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error loading state file \"" + m.getFileName() + "\": " + e.getMessage());
|
||||
return 2;
|
||||
}
|
||||
try {
|
||||
m.init();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error loading state file: " + e.getMessage());
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,9 +143,6 @@ public class Main {
|
|||
System.err.println("register is not yet implemented via dbus");
|
||||
return 1;
|
||||
}
|
||||
if (!m.userHasKeys()) {
|
||||
m.createNewIdentity();
|
||||
}
|
||||
try {
|
||||
m.register(ns.getBoolean("voice"));
|
||||
} catch (IOException e) {
|
||||
|
@ -252,9 +247,6 @@ public class Main {
|
|||
return 1;
|
||||
}
|
||||
|
||||
// When linking, username is null and we always have to create keys
|
||||
m.createNewIdentity();
|
||||
|
||||
String deviceName = ns.getString("name");
|
||||
if (deviceName == null) {
|
||||
deviceName = "cli";
|
||||
|
@ -736,7 +728,6 @@ public class Main {
|
|||
System.err.println("Aborting sending.");
|
||||
}
|
||||
|
||||
|
||||
private static void handleDBusExecutionException(DBusExecutionException e) {
|
||||
System.err.println("Cannot connect to dbus: " + e.getMessage());
|
||||
System.err.println("Aborting.");
|
||||
|
@ -949,6 +940,7 @@ public class Main {
|
|||
}
|
||||
|
||||
private static class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||
|
||||
final Manager m;
|
||||
|
||||
public ReceiveMessageHandler(Manager m) {
|
||||
|
@ -1212,6 +1204,7 @@ public class Main {
|
|||
}
|
||||
|
||||
private static class DbusReceiveMessageHandler extends ReceiveMessageHandler {
|
||||
|
||||
final DBusConnection conn;
|
||||
|
||||
public DbusReceiveMessageHandler(Manager m, DBusConnection conn) {
|
||||
|
@ -1228,6 +1221,7 @@ public class Main {
|
|||
}
|
||||
|
||||
private static class JsonReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||
|
||||
final Manager m;
|
||||
final ObjectMapper jsonProcessor;
|
||||
|
||||
|
@ -1259,6 +1253,7 @@ public class Main {
|
|||
}
|
||||
|
||||
private static class JsonDbusReceiveMessageHandler extends JsonReceiveMessageHandler {
|
||||
|
||||
final DBusConnection conn;
|
||||
|
||||
public JsonDbusReceiveMessageHandler(Manager m, DBusConnection conn) {
|
||||
|
@ -1266,13 +1261,6 @@ public class Main {
|
|||
this.conn = conn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(SignalServiceEnvelope envelope, SignalServiceContent content, Throwable exception) {
|
||||
super.handleMessage(envelope, content, exception);
|
||||
|
||||
sendReceivedMessageToDbus(envelope, content, conn, m);
|
||||
}
|
||||
|
||||
private static void sendReceivedMessageToDbus(SignalServiceEnvelope envelope, SignalServiceContent content, DBusConnection conn, Manager m) {
|
||||
if (envelope.isReceipt()) {
|
||||
try {
|
||||
|
@ -1313,5 +1301,12 @@ public class Main {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(SignalServiceEnvelope envelope, SignalServiceContent content, Throwable exception) {
|
||||
super.handleMessage(envelope, content, exception);
|
||||
|
||||
sendReceivedMessageToDbus(envelope, content, conn, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue