]> nmode's Git Repositories - signal-cli/commitdiff
Implement Dbus updateProfile with givenName (#734)
authorJohn Freed <okgithub@johnfreed.com>
Tue, 28 Sep 2021 16:41:10 +0000 (18:41 +0200)
committerGitHub <noreply@github.com>
Tue, 28 Sep 2021 16:41:10 +0000 (18:41 +0200)
two versions of updateProfile implemented:
- one with givenName and familyName
- one with just name

update documentation

man/signal-cli-dbus.5.adoc
src/main/java/org/asamk/Signal.java
src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java

index 6b5d1a8607c2b6652776b4b98e1dc186acb425fb..e7cd083f16305891151f167b6dec0dffcaa370d8 100755 (executable)
@@ -110,12 +110,15 @@ updateGroup(groupId<ay>, newName<s>, members<as>, avatar<s>) -> groupId<ay>::
 
 Exceptions: AttachmentInvalid, Failure, InvalidNumber, GroupNotFound
 
-updateProfile(newName<s>, about <s>, aboutEmoji <s>, avatar<s>, remove<b>) -> <>::
-* newName     : New name for your own profile (empty if unchanged)
+updateProfile(name<s>, about<s>, aboutEmoji <s>, avatar<s>, remove<b>) -> <>::
+updateProfile(givenName<s>, familyName<s>, about<s>, aboutEmoji <s>, avatar<s>, remove<b>) -> <>::
+* 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
 
index 3bfeb5bdf0f6b56189068990ba0870f3cad66219..59aa03ce09c1e22d327e9a1347c52b63349c52ec 100644 (file)
@@ -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;
index 63764a2fab5eed038cc114b12b6ccdf30794334a..c73918ef6c506a757d09cd19f05226d6953799d5 100644 (file)
@@ -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<File> 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,