-/**
- * Copyright (C) 2015 AsamK
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/*
+ Copyright (C) 2015-2018 AsamK
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.asamk.signal;
import net.sourceforge.argparse4j.inf.*;
import org.apache.http.util.TextUtils;
import org.asamk.Signal;
+import org.asamk.signal.manager.BaseConfig;
+import org.asamk.signal.manager.Manager;
import org.asamk.signal.storage.contacts.ContactInfo;
import org.asamk.signal.storage.groups.GroupInfo;
import org.asamk.signal.storage.protocol.JsonIdentityKeyStore;
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;
}
}
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) {
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";
System.err.println("Aborting sending.");
}
-
private static void handleDBusExecutionException(DBusExecutionException e) {
System.err.println("Cannot connect to dbus: " + e.getMessage());
System.err.println("Aborting.");
.build()
.defaultHelp(true)
.description("Commandline interface for Signal.")
- .version(Manager.PROJECT_NAME + " " + Manager.PROJECT_VERSION);
+ .version(BaseConfig.PROJECT_NAME + " " + BaseConfig.PROJECT_VERSION);
parser.addArgument("-v", "--version")
.help("Show package version.")
}
private static class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
+
final Manager m;
public ReceiveMessageHandler(Manager m) {
}
private static class DbusReceiveMessageHandler extends ReceiveMessageHandler {
+
final DBusConnection conn;
public DbusReceiveMessageHandler(Manager m, DBusConnection conn) {
}
private static class JsonReceiveMessageHandler implements Manager.ReceiveMessageHandler {
+
final Manager m;
final ObjectMapper jsonProcessor;
}
private static class JsonDbusReceiveMessageHandler extends JsonReceiveMessageHandler {
+
final DBusConnection conn;
public JsonDbusReceiveMessageHandler(Manager m, DBusConnection conn) {
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 {
}
}
}
+
+ @Override
+ public void handleMessage(SignalServiceEnvelope envelope, SignalServiceContent content, Throwable exception) {
+ super.handleMessage(envelope, content, exception);
+
+ sendReceivedMessageToDbus(envelope, content, conn, m);
+ }
}
}