mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-02 20:40:38 +00:00
Dbus methods
implement setPin and removePin implement unregister (which kills the daemon upon success) updateProfile now implements given name and family name (as well as the former method with just a name) update documentation
This commit is contained in:
parent
da1bb918bf
commit
545eec12d8
4 changed files with 93 additions and 5 deletions
|
@ -63,8 +63,11 @@ updateGroup(base64GroupId<s>, name<s>, description<s>, addMembers<s>, removeMemb
|
|||
|
||||
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)
|
||||
|
@ -281,7 +284,7 @@ getObjectPath() -> objectPath<s>::
|
|||
|
||||
updateAccount() -> <>
|
||||
|
||||
This command reverses an `unregister` command.
|
||||
Updates the account attributes on the Signal server.
|
||||
|
||||
getObjectPath() -> objectPath<s>::
|
||||
* objectPath : The DBus object path associated with this connection
|
||||
|
@ -312,6 +315,15 @@ registerWithCaptcha(number<s>, voiceVerification<b>, captcha<s>) -> <>::
|
|||
* voiceVerification : true = use voice verification; false = use SMS verification
|
||||
* captcha : Captcha string
|
||||
|
||||
setPin(pin<s>) -> <>::
|
||||
* pin : PIN you set after registration (resets after 7 days of inactivity)
|
||||
|
||||
Sets a registration lock PIN, to prevent others from registering your number.
|
||||
|
||||
removePin() -> <>::
|
||||
|
||||
Removes registration PIN protection.
|
||||
|
||||
verify(number<s>, verificationCode<s>) -> <>
|
||||
* number : Phone number
|
||||
* verificationCode : Code received from Signal after successful registration request
|
||||
|
@ -321,7 +333,7 @@ Command fails if PIN was set after previous registration; use verifyWithPin inst
|
|||
verifyWithPin(number<s>, verificationCode<s>, pin<s>) -> <>
|
||||
* number : Phone number
|
||||
* verificationCode : Code received from Signal after successful registration request
|
||||
* pin : PIN you set after initial registration
|
||||
* pin : PIN you set with setPin command after verifying previous registration
|
||||
|
||||
== Signals
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.asamk;
|
||||
|
||||
import org.asamk.SignalControl;
|
||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||
import org.asamk.signal.manager.AvatarStore;
|
||||
import org.asamk.signal.manager.groups.GroupId;
|
||||
import org.freedesktop.dbus.exceptions.DBusException;
|
||||
|
@ -8,7 +10,10 @@ import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
|||
import org.freedesktop.dbus.interfaces.DBusInterface;
|
||||
import org.freedesktop.dbus.messages.DBusSignal;
|
||||
import org.whispersystems.libsignal.InvalidKeyException;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -128,9 +133,17 @@ public interface Signal extends DBusInterface {
|
|||
|
||||
List<Boolean> isRegistered(List<String> numbers);
|
||||
|
||||
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;
|
||||
|
||||
void removePin() throws Error.Failure;
|
||||
|
||||
void setPin(String registrationLockPin) throws Error.Failure;
|
||||
|
||||
String version();
|
||||
|
||||
|
@ -152,6 +165,8 @@ public interface Signal extends DBusInterface {
|
|||
final String number, final boolean voiceVerification, final String captcha
|
||||
) throws Error.Failure, Error.InvalidNumber, SignalControl.Error.RequiresCaptcha;
|
||||
|
||||
void unregister() throws Error.Failure;
|
||||
|
||||
void verify(String number, String verificationCode) throws Error.Failure, Error.InvalidNumber;
|
||||
|
||||
void verifyWithPin(String number, String verificationCode, String pin) throws Error.Failure, Error.InvalidNumber;
|
||||
|
|
|
@ -16,7 +16,7 @@ public class UpdateAccountCommand implements JsonRpcLocalCommand {
|
|||
}
|
||||
|
||||
public static void attachToSubparser(final Subparser subparser) {
|
||||
subparser.help("Update the account attributes on the signal server.");
|
||||
subparser.help("Update the account attributes on the Signal server.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,8 +7,10 @@ import org.asamk.signal.BaseConfig;
|
|||
import org.asamk.signal.OutputWriter;
|
||||
import org.asamk.signal.PlainTextWriter;
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.commands.GetUserStatusCommand;
|
||||
import org.asamk.signal.commands.UpdateGroupCommand;
|
||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||
import org.asamk.signal.manager.AttachmentInvalidException;
|
||||
import org.asamk.signal.manager.AvatarStore;
|
||||
|
@ -28,6 +30,8 @@ import org.asamk.signal.util.ErrorUtils;
|
|||
import org.asamk.signal.util.Hex;
|
||||
import org.asamk.signal.util.Util;
|
||||
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.libsignal.InvalidKeyException;
|
||||
import org.whispersystems.libsignal.util.Pair;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
@ -35,6 +39,7 @@ import org.whispersystems.signalservice.api.groupsv2.GroupLinkNotActiveException
|
|||
import org.whispersystems.signalservice.api.messages.SendMessageResult;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -56,6 +61,7 @@ public class DbusSignalImpl implements Signal {
|
|||
|
||||
private final Manager m;
|
||||
private final String objectPath;
|
||||
private final static Logger logger = LoggerFactory.getLogger(DbusSignalImpl.class);
|
||||
|
||||
public DbusSignalImpl(final Manager m, final String objectPath) {
|
||||
this.m = m;
|
||||
|
@ -683,6 +689,50 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
}
|
||||
|
||||
@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 removePin() {
|
||||
try {
|
||||
m.setRegistrationLockPin(Optional.absent());
|
||||
} catch (UnauthenticatedResponseException e) {
|
||||
throw new Error.Failure("Remove pin failed with unauthenticated response: " + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure("Remove pin error: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPin(String registrationLockPin) {
|
||||
try {
|
||||
m.setRegistrationLockPin(Optional.of(registrationLockPin));
|
||||
} catch (UnauthenticatedResponseException e) {
|
||||
throw new Error.Failure("Set pin error failed with unauthenticated response: " + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure("Set pin error: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Provide option to query a version string in order to react on potential
|
||||
// future interface changes
|
||||
@Override
|
||||
|
@ -734,6 +784,17 @@ public class DbusSignalImpl implements Signal {
|
|||
DbusSignalControlImpl.registerWithCaptcha(number, voiceVerification, captcha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
try {
|
||||
m.unregister();
|
||||
logger.info("Unregister succeeded, exiting.\n");
|
||||
System.exit(0);
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure(e.getClass().getSimpleName() + "Unregister error: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verify(String number, String verificationCode) {
|
||||
DbusSignalControlImpl.verify(number, verificationCode);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue