]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java
Add --bus-name option to use different D-Bus bus name
[signal-cli] / src / main / java / org / asamk / signal / dbus / DbusManagerImpl.java
index 9ba193489cc1713c3b8daf1c7cd8447da76343f5..f56a3ba48a8de57b61348bc983896e5e4ac30641 100644 (file)
@@ -1,7 +1,6 @@
 package org.asamk.signal.dbus;
 
 import org.asamk.Signal;
-import org.asamk.signal.DbusConfig;
 import org.asamk.signal.manager.Manager;
 import org.asamk.signal.manager.api.AlreadyReceivingException;
 import org.asamk.signal.manager.api.AttachmentInvalidException;
@@ -90,14 +89,16 @@ public class DbusManagerImpl implements Manager {
     private final Set<ReceiveMessageHandler> weakHandlers = new HashSet<>();
     private final Set<ReceiveMessageHandler> messageHandlers = new HashSet<>();
     private final List<Runnable> closedListeners = new ArrayList<>();
+    private final String busname;
     private DBusSigHandler<Signal.MessageReceivedV2> dbusMsgHandler;
     private DBusSigHandler<Signal.EditMessageReceived> dbusEditMsgHandler;
     private DBusSigHandler<Signal.ReceiptReceivedV2> dbusRcptHandler;
     private DBusSigHandler<Signal.SyncMessageReceivedV2> dbusSyncHandler;
 
-    public DbusManagerImpl(final Signal signal, DBusConnection connection) {
+    public DbusManagerImpl(final Signal signal, DBusConnection connection, final String busname) {
         this.signal = signal;
         this.connection = connection;
+        this.busname = busname;
     }
 
     @Override
@@ -670,7 +671,18 @@ public class DbusManagerImpl implements Manager {
             }
             return Recipient.newBuilder()
                     .withAddress(new RecipientAddress(null, n))
-                    .withContact(new Contact(contactName, null, null, 0, contactBlocked, false, false, false))
+                    .withContact(new Contact(contactName,
+                            null,
+                            null,
+                            null,
+                            0,
+                            0,
+                            false,
+                            contactBlocked,
+                            false,
+                            false,
+                            false,
+                            null))
                     .build();
         }).filter(Objects::nonNull).toList();
     }
@@ -809,7 +821,7 @@ public class DbusManagerImpl implements Manager {
 
     private <T extends DBusInterface> T getRemoteObject(final DBusPath path, final Class<T> type) {
         try {
-            return connection.getRemoteObject(DbusConfig.getBusname(), path.getPath(), type);
+            return connection.getRemoteObject(busname, path.getPath(), type);
         } catch (DBusException e) {
             throw new AssertionError(e);
         }