From: John Freed Date: Tue, 28 Sep 2021 16:41:10 +0000 (+0200) Subject: Implement Dbus updateProfile with givenName (#734) X-Git-Tag: v0.9.1~44 X-Git-Url: https://git.nmode.ca/signal-cli/commitdiff_plain/ba817e2ae4147b201fbb3e5eb8c86e359873ec02?ds=sidebyside Implement Dbus updateProfile with givenName (#734) two versions of updateProfile implemented: - one with givenName and familyName - one with just name update documentation --- diff --git a/man/signal-cli-dbus.5.adoc b/man/signal-cli-dbus.5.adoc index 6b5d1a86..e7cd083f 100755 --- a/man/signal-cli-dbus.5.adoc +++ b/man/signal-cli-dbus.5.adoc @@ -110,12 +110,15 @@ updateGroup(groupId, newName, members, avatar) -> groupId:: Exceptions: AttachmentInvalid, Failure, InvalidNumber, GroupNotFound -updateProfile(newName, about , aboutEmoji , avatar, remove) -> <>:: -* newName : New name for your own profile (empty if unchanged) +updateProfile(name, about, aboutEmoji , avatar, remove) -> <>:: +updateProfile(givenName, familyName, about, aboutEmoji , avatar, remove) -> <>:: +* name : Name for your own profile (empty if unchanged) +* givenName : Given name for your own profile (empty if unchanged) +* familyName : Family name for your own profile (empty if unchanged) * about : About message for profile (empty if unchanged) * aboutEmoji : Emoji for profile (empty if unchanged) * avatar : Filename of avatar picture for profile (empty if unchanged) -* remove : Set to 1 if the existing avatar picture should be removed +* remove : Set to true if the existing avatar picture should be removed Exceptions: Failure diff --git a/src/main/java/org/asamk/Signal.java b/src/main/java/org/asamk/Signal.java index 3bfeb5bd..59aa03ce 100644 --- a/src/main/java/org/asamk/Signal.java +++ b/src/main/java/org/asamk/Signal.java @@ -101,6 +101,10 @@ public interface Signal extends DBusInterface { void updateDeviceName(String deviceName) throws Error.Failure; + void updateProfile( + String givenName, String familyName, String about, String aboutEmoji, String avatarPath, boolean removeAvatar + ) throws Error.Failure; + void updateProfile( String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar ) throws Error.Failure; diff --git a/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java b/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java index 63764a2f..c73918ef 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java @@ -497,6 +497,28 @@ public class DbusSignalImpl implements Signal { }).collect(Collectors.toList()); } + @Override + public void updateProfile( + final String givenName, + final String familyName, + final String about, + final String aboutEmoji, + String avatarPath, + final boolean removeAvatar + ) { + try { + if (avatarPath.isEmpty()) { + avatarPath = null; + } + Optional avatarFile = removeAvatar + ? Optional.absent() + : avatarPath == null ? null : Optional.of(new File(avatarPath)); + m.setProfile(givenName, familyName, about, aboutEmoji, avatarFile); + } catch (IOException e) { + throw new Error.Failure(e.getMessage()); + } + } + @Override public void updateProfile( final String name,