mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Implement multi account commands for dbus client
This commit is contained in:
parent
00cda598c8
commit
805f976d9e
12 changed files with 335 additions and 29 deletions
|
@ -0,0 +1,53 @@
|
|||
package org.asamk.signal.dbus;
|
||||
|
||||
import org.asamk.SignalControl;
|
||||
import org.asamk.signal.manager.RegistrationManager;
|
||||
import org.asamk.signal.manager.api.CaptchaRequiredException;
|
||||
import org.asamk.signal.manager.api.IncorrectPinException;
|
||||
import org.asamk.signal.manager.api.PinLockedException;
|
||||
import org.freedesktop.dbus.connections.impl.DBusConnection;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* This class implements the RegistrationManager interface using the DBus Signal interface, where possible.
|
||||
* It's used for the signal-cli dbus client mode (--dbus, --dbus-system)
|
||||
*/
|
||||
public class DbusRegistrationManagerImpl implements RegistrationManager {
|
||||
|
||||
private final String number;
|
||||
private final SignalControl signalControl;
|
||||
private final DBusConnection connection;
|
||||
|
||||
public DbusRegistrationManagerImpl(String number, final SignalControl signalControl, DBusConnection connection) {
|
||||
this.number = number;
|
||||
this.signalControl = signalControl;
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(
|
||||
final boolean voiceVerification, final String captcha
|
||||
) throws IOException, CaptchaRequiredException {
|
||||
if (captcha == null) {
|
||||
signalControl.register(number, voiceVerification);
|
||||
} else {
|
||||
signalControl.registerWithCaptcha(number, voiceVerification, captcha);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verifyAccount(
|
||||
final String verificationCode, final String pin
|
||||
) throws IOException, PinLockedException, IncorrectPinException {
|
||||
if (pin == null) {
|
||||
signalControl.verify(number, verificationCode);
|
||||
} else {
|
||||
signalControl.verifyWithPin(number, verificationCode, pin);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue