Add parameter to specify DBus name

This way multiple instances of signal-cli can run in daemon-mode in
parallel. This was not possible previously as they tried to create the
same DBus.

This is rather my own quick fix and I guess there exists a cleaner way.
(Maybe let the parser parse the busname directly to `SIGNAL_BUSNAME`.)
This commit is contained in:
user-invalid 2019-01-15 13:54:34 +01:00
parent f3ecddba6f
commit 29b538677a
2 changed files with 9 additions and 1 deletions

View file

@ -182,6 +182,8 @@ public class Main {
.action(Arguments.version());
parser.addArgument("--config")
.help("Set the path, where to store the config (Default: $XDG_DATA_HOME/signal-cli , $HOME/.local/share/signal-cli).");
parser.addArgument("-n", "--busname")
.help("Name of the DBus.");
MutuallyExclusiveGroup mut = parser.addMutuallyExclusiveGroup();
mut.addArgument("-u", "--username")

View file

@ -42,6 +42,7 @@ public class DaemonCommand implements LocalCommand {
try {
try {
int busType;
String busName;
if (ns.getBoolean("system")) {
busType = DBusConnection.SYSTEM;
} else {
@ -49,7 +50,12 @@ public class DaemonCommand implements LocalCommand {
}
conn = DBusConnection.getConnection(busType);
conn.exportObject(SIGNAL_OBJECTPATH, m);
conn.requestBusName(SIGNAL_BUSNAME);
busName = ns.getString("busname");
if (busName == null) {
conn.requestBusName(SIGNAL_BUSNAME);
} else {
conn.requestBusName(busName);
}
} catch (UnsatisfiedLinkError e) {
System.err.println("Missing native library dependency for dbus service: " + e.getMessage());
return 1;