mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Add helper method to create valid dbus object path
This commit is contained in:
parent
c852bd8a85
commit
d0d3e20713
3 changed files with 18 additions and 6 deletions
|
@ -1,5 +1,7 @@
|
||||||
package org.asamk.signal;
|
package org.asamk.signal;
|
||||||
|
|
||||||
|
import org.asamk.signal.dbus.DbusUtils;
|
||||||
|
|
||||||
public class DbusConfig {
|
public class DbusConfig {
|
||||||
|
|
||||||
private static final String SIGNAL_BUSNAME = "org.asamk.Signal";
|
private static final String SIGNAL_BUSNAME = "org.asamk.Signal";
|
||||||
|
@ -18,6 +20,6 @@ public class DbusConfig {
|
||||||
return SIGNAL_OBJECT_BASE_PATH;
|
return SIGNAL_OBJECT_BASE_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SIGNAL_OBJECT_BASE_PATH + "/" + account.replace('+', '_');
|
return SIGNAL_OBJECT_BASE_PATH + "/" + DbusUtils.makeValidObjectPathElement(account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,8 @@ import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static org.asamk.signal.dbus.DbusUtils.makeValidObjectPathElement;
|
||||||
|
|
||||||
public class DbusSignalImpl implements Signal {
|
public class DbusSignalImpl implements Signal {
|
||||||
|
|
||||||
private final Manager m;
|
private final Manager m;
|
||||||
|
@ -980,11 +982,7 @@ public class DbusSignalImpl implements Signal {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getGroupObjectPath(String basePath, byte[] groupId) {
|
private static String getGroupObjectPath(String basePath, byte[] groupId) {
|
||||||
return basePath + "/Groups/" + Base64.getEncoder()
|
return basePath + "/Groups/" + makeValidObjectPathElement(Base64.getEncoder().encodeToString(groupId));
|
||||||
.encodeToString(groupId)
|
|
||||||
.replace("+", "_")
|
|
||||||
.replace("/", "_")
|
|
||||||
.replace("=", "_");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateGroups() {
|
private void updateGroups() {
|
||||||
|
|
12
src/main/java/org/asamk/signal/dbus/DbusUtils.java
Normal file
12
src/main/java/org/asamk/signal/dbus/DbusUtils.java
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
package org.asamk.signal.dbus;
|
||||||
|
|
||||||
|
public final class DbusUtils {
|
||||||
|
|
||||||
|
private DbusUtils() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String makeValidObjectPathElement(String pathElement) {
|
||||||
|
return pathElement.replaceAll("[^A-Za-z0-9_]", "_");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue