Remove libsignal-service from manager lib API

This commit is contained in:
AsamK 2021-11-06 13:29:26 +01:00
parent 9075cc1a30
commit 2ab42ca547
31 changed files with 269 additions and 96 deletions

View file

@ -33,8 +33,6 @@ import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.connections.impl.DBusConnection;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
import org.whispersystems.signalservice.api.util.UuidUtil;
import java.io.File;
import java.io.IOException;
@ -84,7 +82,7 @@ public class DbusManagerImpl implements Manager {
final var result = new HashMap<String, Pair<String, UUID>>();
for (var i = 0; i < numbersList.size(); i++) {
result.put(numbersList.get(i),
new Pair<>(numbersList.get(i), registered.get(i) ? UuidUtil.UNKNOWN_UUID : null));
new Pair<>(numbersList.get(i), registered.get(i) ? RecipientAddress.UNKNOWN_UUID : null));
}
return result;
}
@ -173,7 +171,7 @@ public class DbusManagerImpl implements Manager {
}
@Override
public Profile getRecipientProfile(final RecipientIdentifier.Single recipient) throws UnregisteredUserException {
public Profile getRecipientProfile(final RecipientIdentifier.Single recipient) {
throw new UnsupportedOperationException();
}
@ -370,7 +368,7 @@ public class DbusManagerImpl implements Manager {
@Override
public void setContactName(
final RecipientIdentifier.Single recipient, final String name
) throws NotMasterDeviceException, UnregisteredUserException {
) throws NotMasterDeviceException {
signal.setContactName(recipient.getIdentifier(), name);
}

View file

@ -8,12 +8,11 @@ import org.asamk.signal.manager.Manager;
import org.asamk.signal.manager.ProvisioningManager;
import org.asamk.signal.manager.RegistrationManager;
import org.asamk.signal.manager.UserAlreadyExists;
import org.asamk.signal.manager.api.CaptchaRequiredException;
import org.asamk.signal.manager.api.IncorrectPinException;
import org.asamk.signal.manager.api.Pair;
import org.asamk.signal.manager.api.PinLockedException;
import org.freedesktop.dbus.DBusPath;
import org.whispersystems.signalservice.api.KeyBackupServicePinException;
import org.whispersystems.signalservice.api.KeyBackupSystemNoDataException;
import org.whispersystems.signalservice.api.push.exceptions.CaptchaRequiredException;
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
import java.io.IOException;
import java.net.URI;
@ -100,7 +99,7 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
public void registerWithCaptcha(
final String number, final boolean voiceVerification, final String captcha
) throws Error.Failure, Error.InvalidNumber {
if (!PhoneNumberFormatter.isValidNumber(number, null)) {
if (!Manager.isValidNumber(number, null)) {
throw new SignalControl.Error.InvalidNumber(
"Invalid username (phone number), make sure you include the country code.");
}
@ -126,7 +125,7 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
try (final RegistrationManager registrationManager = c.getNewRegistrationManager(number)) {
final Manager manager = registrationManager.verifyAccount(verificationCode, pin);
addManager(manager);
} catch (IOException | KeyBackupSystemNoDataException | KeyBackupServicePinException e) {
} catch (IOException | PinLockedException | IncorrectPinException e) {
throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
}
}

View file

@ -11,9 +11,11 @@ import org.asamk.signal.manager.UntrustedIdentityException;
import org.asamk.signal.manager.api.Identity;
import org.asamk.signal.manager.api.InactiveGroupLinkException;
import org.asamk.signal.manager.api.InvalidDeviceLinkException;
import org.asamk.signal.manager.api.InvalidNumberException;
import org.asamk.signal.manager.api.Message;
import org.asamk.signal.manager.api.Pair;
import org.asamk.signal.manager.api.RecipientIdentifier;
import org.asamk.signal.manager.api.SendMessageResult;
import org.asamk.signal.manager.api.TypingAction;
import org.asamk.signal.manager.api.UpdateGroup;
import org.asamk.signal.manager.groups.GroupId;
@ -32,8 +34,6 @@ import org.freedesktop.dbus.connections.impl.DBusConnection;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
import org.freedesktop.dbus.types.Variant;
import org.whispersystems.signalservice.api.messages.SendMessageResult;
import org.whispersystems.signalservice.api.util.InvalidNumberException;
import java.io.File;
import java.io.IOException;
@ -719,7 +719,7 @@ public class DbusSignalImpl implements Signal {
final var message = timestamp + "\nFailed to send message:\n" + error + '\n';
if (result.getIdentityFailure() != null) {
if (result.isIdentityFailure()) {
throw new Error.UntrustedIdentity(message);
} else {
throw new Error.Failure(message);