mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Cleanup manager package
This commit is contained in:
parent
3040da99c4
commit
5cccf52103
55 changed files with 190 additions and 160 deletions
|
@ -1,5 +1,7 @@
|
||||||
package org.asamk.signal.manager;
|
package org.asamk.signal.manager;
|
||||||
|
|
||||||
|
import org.asamk.signal.manager.api.AccountCheckException;
|
||||||
|
import org.asamk.signal.manager.api.AttachmentInvalidException;
|
||||||
import org.asamk.signal.manager.api.Configuration;
|
import org.asamk.signal.manager.api.Configuration;
|
||||||
import org.asamk.signal.manager.api.Device;
|
import org.asamk.signal.manager.api.Device;
|
||||||
import org.asamk.signal.manager.api.Group;
|
import org.asamk.signal.manager.api.Group;
|
||||||
|
@ -9,11 +11,14 @@ import org.asamk.signal.manager.api.InvalidDeviceLinkException;
|
||||||
import org.asamk.signal.manager.api.InvalidStickerException;
|
import org.asamk.signal.manager.api.InvalidStickerException;
|
||||||
import org.asamk.signal.manager.api.Message;
|
import org.asamk.signal.manager.api.Message;
|
||||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||||
|
import org.asamk.signal.manager.api.NotMasterDeviceException;
|
||||||
|
import org.asamk.signal.manager.api.NotRegisteredException;
|
||||||
import org.asamk.signal.manager.api.Pair;
|
import org.asamk.signal.manager.api.Pair;
|
||||||
import org.asamk.signal.manager.api.RecipientIdentifier;
|
import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||||
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
||||||
import org.asamk.signal.manager.api.SendMessageResults;
|
import org.asamk.signal.manager.api.SendMessageResults;
|
||||||
import org.asamk.signal.manager.api.StickerPack;
|
import org.asamk.signal.manager.api.StickerPack;
|
||||||
|
import org.asamk.signal.manager.api.StickerPackInvalidException;
|
||||||
import org.asamk.signal.manager.api.StickerPackUrl;
|
import org.asamk.signal.manager.api.StickerPackUrl;
|
||||||
import org.asamk.signal.manager.api.TypingAction;
|
import org.asamk.signal.manager.api.TypingAction;
|
||||||
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
|
@ -38,7 +43,6 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -53,7 +57,7 @@ public interface Manager extends Closeable {
|
||||||
ServiceEnvironment serviceEnvironment,
|
ServiceEnvironment serviceEnvironment,
|
||||||
String userAgent,
|
String userAgent,
|
||||||
TrustNewIdentity trustNewIdentity
|
TrustNewIdentity trustNewIdentity
|
||||||
) throws IOException, NotRegisteredException {
|
) throws IOException, NotRegisteredException, AccountCheckException {
|
||||||
var pathConfig = PathConfig.createDefault(settingsPath);
|
var pathConfig = PathConfig.createDefault(settingsPath);
|
||||||
|
|
||||||
if (!SignalAccount.userExists(pathConfig.dataPath(), number)) {
|
if (!SignalAccount.userExists(pathConfig.dataPath(), number)) {
|
||||||
|
@ -70,7 +74,16 @@ public interface Manager extends Closeable {
|
||||||
account.initDatabase();
|
account.initDatabase();
|
||||||
final var serviceEnvironmentConfig = ServiceConfig.getServiceEnvironmentConfig(serviceEnvironment, userAgent);
|
final var serviceEnvironmentConfig = ServiceConfig.getServiceEnvironmentConfig(serviceEnvironment, userAgent);
|
||||||
|
|
||||||
return new ManagerImpl(account, pathConfig, serviceEnvironmentConfig, userAgent);
|
final var manager = new ManagerImpl(account, pathConfig, serviceEnvironmentConfig, userAgent);
|
||||||
|
|
||||||
|
try {
|
||||||
|
manager.checkAccountState();
|
||||||
|
} catch (IOException e) {
|
||||||
|
manager.close();
|
||||||
|
throw new AccountCheckException("Error while checking account " + account + ": " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initLogger() {
|
static void initLogger() {
|
||||||
|
@ -81,26 +94,8 @@ public interface Manager extends Closeable {
|
||||||
return PhoneNumberFormatter.isValidNumber(e164Number, countryCode);
|
return PhoneNumberFormatter.isValidNumber(e164Number, countryCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<String> getAllLocalAccountNumbers(File settingsPath) {
|
|
||||||
var pathConfig = PathConfig.createDefault(settingsPath);
|
|
||||||
final var dataPath = pathConfig.dataPath();
|
|
||||||
final var files = dataPath.listFiles();
|
|
||||||
|
|
||||||
if (files == null) {
|
|
||||||
return List.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Arrays.stream(files)
|
|
||||||
.filter(File::isFile)
|
|
||||||
.map(File::getName)
|
|
||||||
.filter(file -> PhoneNumberFormatter.isValidNumber(file, null))
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
String getSelfNumber();
|
String getSelfNumber();
|
||||||
|
|
||||||
void checkAccountState() throws IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used for checking a set of phone numbers for registration on Signal
|
* This is used for checking a set of phone numbers for registration on Signal
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.asamk.signal.manager;
|
package org.asamk.signal.manager;
|
||||||
|
|
||||||
|
import org.asamk.signal.manager.api.AttachmentInvalidException;
|
||||||
import org.asamk.signal.manager.api.Configuration;
|
import org.asamk.signal.manager.api.Configuration;
|
||||||
import org.asamk.signal.manager.api.Device;
|
import org.asamk.signal.manager.api.Device;
|
||||||
import org.asamk.signal.manager.api.Group;
|
import org.asamk.signal.manager.api.Group;
|
||||||
|
@ -24,6 +25,7 @@ import org.asamk.signal.manager.api.InactiveGroupLinkException;
|
||||||
import org.asamk.signal.manager.api.InvalidDeviceLinkException;
|
import org.asamk.signal.manager.api.InvalidDeviceLinkException;
|
||||||
import org.asamk.signal.manager.api.InvalidStickerException;
|
import org.asamk.signal.manager.api.InvalidStickerException;
|
||||||
import org.asamk.signal.manager.api.Message;
|
import org.asamk.signal.manager.api.Message;
|
||||||
|
import org.asamk.signal.manager.api.NotMasterDeviceException;
|
||||||
import org.asamk.signal.manager.api.Pair;
|
import org.asamk.signal.manager.api.Pair;
|
||||||
import org.asamk.signal.manager.api.RecipientIdentifier;
|
import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||||
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
||||||
|
@ -31,6 +33,7 @@ import org.asamk.signal.manager.api.SendMessageResult;
|
||||||
import org.asamk.signal.manager.api.SendMessageResults;
|
import org.asamk.signal.manager.api.SendMessageResults;
|
||||||
import org.asamk.signal.manager.api.StickerPack;
|
import org.asamk.signal.manager.api.StickerPack;
|
||||||
import org.asamk.signal.manager.api.StickerPackId;
|
import org.asamk.signal.manager.api.StickerPackId;
|
||||||
|
import org.asamk.signal.manager.api.StickerPackInvalidException;
|
||||||
import org.asamk.signal.manager.api.StickerPackUrl;
|
import org.asamk.signal.manager.api.StickerPackUrl;
|
||||||
import org.asamk.signal.manager.api.TypingAction;
|
import org.asamk.signal.manager.api.TypingAction;
|
||||||
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
|
@ -50,6 +53,8 @@ import org.asamk.signal.manager.storage.recipients.Contact;
|
||||||
import org.asamk.signal.manager.storage.recipients.Profile;
|
import org.asamk.signal.manager.storage.recipients.Profile;
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
||||||
|
import org.asamk.signal.manager.storage.stickerPacks.JsonStickerPack;
|
||||||
|
import org.asamk.signal.manager.storage.stickerPacks.StickerPackStore;
|
||||||
import org.asamk.signal.manager.storage.stickers.Sticker;
|
import org.asamk.signal.manager.storage.stickers.Sticker;
|
||||||
import org.asamk.signal.manager.util.AttachmentUtils;
|
import org.asamk.signal.manager.util.AttachmentUtils;
|
||||||
import org.asamk.signal.manager.util.KeyUtils;
|
import org.asamk.signal.manager.util.KeyUtils;
|
||||||
|
@ -89,7 +94,7 @@ import java.util.stream.Stream;
|
||||||
|
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class ManagerImpl implements Manager {
|
class ManagerImpl implements Manager {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(ManagerImpl.class);
|
private final static Logger logger = LoggerFactory.getLogger(ManagerImpl.class);
|
||||||
|
|
||||||
|
@ -166,8 +171,7 @@ public class ManagerImpl implements Manager {
|
||||||
return account.getAccount();
|
return account.getAccount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
void checkAccountState() throws IOException {
|
||||||
public void checkAccountState() throws IOException {
|
|
||||||
context.getAccountHelper().checkAccountState();
|
context.getAccountHelper().checkAccountState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,58 @@
|
||||||
package org.asamk.signal.manager;
|
package org.asamk.signal.manager;
|
||||||
|
|
||||||
|
import org.asamk.signal.manager.api.AccountCheckException;
|
||||||
|
import org.asamk.signal.manager.api.NotRegisteredException;
|
||||||
|
import org.asamk.signal.manager.config.ServiceEnvironment;
|
||||||
|
import org.asamk.signal.manager.storage.identities.TrustNewIdentity;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public interface MultiAccountManager extends AutoCloseable {
|
public interface MultiAccountManager extends AutoCloseable {
|
||||||
|
|
||||||
|
static MultiAccountManager init(
|
||||||
|
final File settingsPath,
|
||||||
|
final ServiceEnvironment serviceEnvironment,
|
||||||
|
final String userAgent,
|
||||||
|
final TrustNewIdentity trustNewIdentity
|
||||||
|
) {
|
||||||
|
final var logger = LoggerFactory.getLogger(MultiAccountManager.class);
|
||||||
|
final var managers = getAllLocalAccountNumbers(settingsPath).stream().map(a -> {
|
||||||
|
try {
|
||||||
|
return Manager.init(a, settingsPath, serviceEnvironment, userAgent, trustNewIdentity);
|
||||||
|
} catch (NotRegisteredException | IOException | AccountCheckException e) {
|
||||||
|
logger.warn("Ignoring {}: {} ({})", a, e.getMessage(), e.getClass().getSimpleName());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}).filter(Objects::nonNull).toList();
|
||||||
|
|
||||||
|
return new MultiAccountManagerImpl(managers, settingsPath, serviceEnvironment, userAgent);
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<String> getAllLocalAccountNumbers(File settingsPath) {
|
||||||
|
var pathConfig = PathConfig.createDefault(settingsPath);
|
||||||
|
final var dataPath = pathConfig.dataPath();
|
||||||
|
final var files = dataPath.listFiles();
|
||||||
|
|
||||||
|
if (files == null) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Arrays.stream(files)
|
||||||
|
.filter(File::isFile)
|
||||||
|
.map(File::getName)
|
||||||
|
.filter(file -> PhoneNumberFormatter.isValidNumber(file, null))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
List<String> getAccountNumbers();
|
List<String> getAccountNumbers();
|
||||||
|
|
||||||
List<Manager> getManagers();
|
List<Manager> getManagers();
|
||||||
|
|
|
@ -17,7 +17,7 @@ import java.util.Set;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class MultiAccountManagerImpl implements MultiAccountManager {
|
class MultiAccountManagerImpl implements MultiAccountManager {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(MultiAccountManagerImpl.class);
|
private final static Logger logger = LoggerFactory.getLogger(MultiAccountManagerImpl.class);
|
||||||
|
|
||||||
|
@ -25,19 +25,19 @@ public class MultiAccountManagerImpl implements MultiAccountManager {
|
||||||
private final Set<Consumer<Manager>> onManagerRemovedHandlers = new HashSet<>();
|
private final Set<Consumer<Manager>> onManagerRemovedHandlers = new HashSet<>();
|
||||||
private final Set<Manager> managers = new HashSet<>();
|
private final Set<Manager> managers = new HashSet<>();
|
||||||
private final Map<URI, ProvisioningManager> provisioningManagers = new HashMap<>();
|
private final Map<URI, ProvisioningManager> provisioningManagers = new HashMap<>();
|
||||||
private final File dataPath;
|
private final File settingsPath;
|
||||||
private final ServiceEnvironment serviceEnvironment;
|
private final ServiceEnvironment serviceEnvironment;
|
||||||
private final String userAgent;
|
private final String userAgent;
|
||||||
|
|
||||||
public MultiAccountManagerImpl(
|
public MultiAccountManagerImpl(
|
||||||
final Collection<Manager> managers,
|
final Collection<Manager> managers,
|
||||||
final File dataPath,
|
final File settingsPath,
|
||||||
final ServiceEnvironment serviceEnvironment,
|
final ServiceEnvironment serviceEnvironment,
|
||||||
final String userAgent
|
final String userAgent
|
||||||
) {
|
) {
|
||||||
this.managers.addAll(managers);
|
this.managers.addAll(managers);
|
||||||
managers.forEach(m -> m.addClosedListener(() -> this.removeManager(m)));
|
managers.forEach(m -> m.addClosedListener(() -> this.removeManager(m)));
|
||||||
this.dataPath = dataPath;
|
this.settingsPath = settingsPath;
|
||||||
this.serviceEnvironment = serviceEnvironment;
|
this.serviceEnvironment = serviceEnvironment;
|
||||||
this.userAgent = userAgent;
|
this.userAgent = userAgent;
|
||||||
}
|
}
|
||||||
|
@ -119,12 +119,12 @@ public class MultiAccountManagerImpl implements MultiAccountManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProvisioningManager getNewProvisioningManager() {
|
private ProvisioningManager getNewProvisioningManager() {
|
||||||
return ProvisioningManager.init(dataPath, serviceEnvironment, userAgent, this::addManager);
|
return ProvisioningManager.init(settingsPath, serviceEnvironment, userAgent, this::addManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RegistrationManager getNewRegistrationManager(String account) throws IOException {
|
public RegistrationManager getNewRegistrationManager(String account) throws IOException {
|
||||||
return RegistrationManager.init(account, dataPath, serviceEnvironment, userAgent, this::addManager);
|
return RegistrationManager.init(account, settingsPath, serviceEnvironment, userAgent, this::addManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,11 +2,11 @@ package org.asamk.signal.manager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public record PathConfig(
|
record PathConfig(
|
||||||
File dataPath, File attachmentsPath, File avatarsPath, File stickerPacksPath
|
File dataPath, File attachmentsPath, File avatarsPath, File stickerPacksPath
|
||||||
) {
|
) {
|
||||||
|
|
||||||
public static PathConfig createDefault(final File settingsPath) {
|
static PathConfig createDefault(final File settingsPath) {
|
||||||
return new PathConfig(new File(settingsPath, "data"),
|
return new PathConfig(new File(settingsPath, "data"),
|
||||||
new File(settingsPath, "attachments"),
|
new File(settingsPath, "attachments"),
|
||||||
new File(settingsPath, "avatars"),
|
new File(settingsPath, "avatars"),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.asamk.signal.manager;
|
package org.asamk.signal.manager;
|
||||||
|
|
||||||
|
import org.asamk.signal.manager.api.UserAlreadyExistsException;
|
||||||
import org.asamk.signal.manager.config.ServiceConfig;
|
import org.asamk.signal.manager.config.ServiceConfig;
|
||||||
import org.asamk.signal.manager.config.ServiceEnvironment;
|
import org.asamk.signal.manager.config.ServiceEnvironment;
|
||||||
|
|
||||||
|
@ -32,5 +33,5 @@ public interface ProvisioningManager {
|
||||||
|
|
||||||
URI getDeviceLinkUri() throws TimeoutException, IOException;
|
URI getDeviceLinkUri() throws TimeoutException, IOException;
|
||||||
|
|
||||||
String finishDeviceLink(String deviceName) throws IOException, TimeoutException, UserAlreadyExists;
|
String finishDeviceLink(String deviceName) throws IOException, TimeoutException, UserAlreadyExistsException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.asamk.signal.manager;
|
package org.asamk.signal.manager;
|
||||||
|
|
||||||
|
import org.asamk.signal.manager.api.UserAlreadyExistsException;
|
||||||
import org.asamk.signal.manager.config.ServiceConfig;
|
import org.asamk.signal.manager.config.ServiceConfig;
|
||||||
import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
|
import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
|
||||||
import org.asamk.signal.manager.storage.SignalAccount;
|
import org.asamk.signal.manager.storage.SignalAccount;
|
||||||
|
@ -38,7 +39,7 @@ import java.net.URI;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class ProvisioningManagerImpl implements ProvisioningManager {
|
class ProvisioningManagerImpl implements ProvisioningManager {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(ProvisioningManagerImpl.class);
|
private final static Logger logger = LoggerFactory.getLogger(ProvisioningManagerImpl.class);
|
||||||
|
|
||||||
|
@ -87,14 +88,14 @@ public class ProvisioningManagerImpl implements ProvisioningManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String finishDeviceLink(String deviceName) throws IOException, TimeoutException, UserAlreadyExists {
|
public String finishDeviceLink(String deviceName) throws IOException, TimeoutException, UserAlreadyExistsException {
|
||||||
var ret = accountManager.getNewDeviceRegistration(tempIdentityKey);
|
var ret = accountManager.getNewDeviceRegistration(tempIdentityKey);
|
||||||
var number = ret.getNumber();
|
var number = ret.getNumber();
|
||||||
|
|
||||||
logger.info("Received link information from {}, linking in progress ...", number);
|
logger.info("Received link information from {}, linking in progress ...", number);
|
||||||
|
|
||||||
if (SignalAccount.userExists(pathConfig.dataPath(), number) && !canRelinkExistingAccount(number)) {
|
if (SignalAccount.userExists(pathConfig.dataPath(), number) && !canRelinkExistingAccount(number)) {
|
||||||
throw new UserAlreadyExists(number, SignalAccount.getFileName(pathConfig.dataPath(), number));
|
throw new UserAlreadyExistsException(number, SignalAccount.getFileName(pathConfig.dataPath(), number));
|
||||||
}
|
}
|
||||||
|
|
||||||
var encryptedDeviceName = deviceName == null
|
var encryptedDeviceName = deviceName == null
|
||||||
|
|
|
@ -47,7 +47,7 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
import static org.asamk.signal.manager.config.ServiceConfig.capabilities;
|
import static org.asamk.signal.manager.config.ServiceConfig.capabilities;
|
||||||
|
|
||||||
public class RegistrationManagerImpl implements RegistrationManager {
|
class RegistrationManagerImpl implements RegistrationManager {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(RegistrationManagerImpl.class);
|
private final static Logger logger = LoggerFactory.getLogger(RegistrationManagerImpl.class);
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class SignalDependencies {
|
||||||
private ProfileService profileService;
|
private ProfileService profileService;
|
||||||
private SignalServiceCipher cipher;
|
private SignalServiceCipher cipher;
|
||||||
|
|
||||||
public SignalDependencies(
|
SignalDependencies(
|
||||||
final ServiceEnvironmentConfig serviceEnvironmentConfig,
|
final ServiceEnvironmentConfig serviceEnvironmentConfig,
|
||||||
final String userAgent,
|
final String userAgent,
|
||||||
final DynamicCredentialsProvider credentialsProvider,
|
final DynamicCredentialsProvider credentialsProvider,
|
||||||
|
|
|
@ -21,7 +21,7 @@ import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
* The monitor is also responsible for sending heartbeats/keep-alive messages to prevent
|
* The monitor is also responsible for sending heartbeats/keep-alive messages to prevent
|
||||||
* timeouts.
|
* timeouts.
|
||||||
*/
|
*/
|
||||||
public final class SignalWebSocketHealthMonitor implements HealthMonitor {
|
final class SignalWebSocketHealthMonitor implements HealthMonitor {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(SignalWebSocketHealthMonitor.class);
|
private final static Logger logger = LoggerFactory.getLogger(SignalWebSocketHealthMonitor.class);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package org.asamk.signal.manager.api;
|
||||||
|
|
||||||
|
public class AccountCheckException extends Exception {
|
||||||
|
|
||||||
|
public AccountCheckException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccountCheckException(String message, Exception e) {
|
||||||
|
super(message, e);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.asamk.signal.manager;
|
package org.asamk.signal.manager.api;
|
||||||
|
|
||||||
public class AttachmentInvalidException extends Exception {
|
public class AttachmentInvalidException extends Exception {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.asamk.signal.manager.api;
|
package org.asamk.signal.manager.api;
|
||||||
|
|
||||||
import org.asamk.signal.manager.TrustLevel;
|
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
||||||
import org.whispersystems.libsignal.IdentityKey;
|
import org.whispersystems.libsignal.IdentityKey;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.asamk.signal.manager;
|
package org.asamk.signal.manager.api;
|
||||||
|
|
||||||
public class NotMasterDeviceException extends Exception {
|
public class NotMasterDeviceException extends Exception {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.asamk.signal.manager;
|
package org.asamk.signal.manager.api;
|
||||||
|
|
||||||
public class NotRegisteredException extends Exception {
|
public class NotRegisteredException extends Exception {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.asamk.signal.manager;
|
package org.asamk.signal.manager.api;
|
||||||
|
|
||||||
public class StickerPackInvalidException extends Exception {
|
public class StickerPackInvalidException extends Exception {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.asamk.signal.manager;
|
package org.asamk.signal.manager.api;
|
||||||
|
|
||||||
import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage;
|
import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage;
|
||||||
import org.whispersystems.signalservice.internal.storage.protos.ContactRecord;
|
import org.whispersystems.signalservice.internal.storage.protos.ContactRecord;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.asamk.signal.manager;
|
package org.asamk.signal.manager.api;
|
||||||
|
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package org.asamk.signal.manager;
|
package org.asamk.signal.manager.api;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class UserAlreadyExists extends Exception {
|
public class UserAlreadyExistsException extends Exception {
|
||||||
|
|
||||||
private final String number;
|
private final String number;
|
||||||
private final File fileName;
|
private final File fileName;
|
||||||
|
|
||||||
public UserAlreadyExists(String number, File fileName) {
|
public UserAlreadyExistsException(String number, File fileName) {
|
||||||
this.number = number;
|
this.number = number;
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package org.asamk.signal.manager.helper;
|
package org.asamk.signal.manager.helper;
|
||||||
|
|
||||||
import org.asamk.signal.manager.AttachmentInvalidException;
|
|
||||||
import org.asamk.signal.manager.AttachmentStore;
|
import org.asamk.signal.manager.AttachmentStore;
|
||||||
import org.asamk.signal.manager.SignalDependencies;
|
import org.asamk.signal.manager.SignalDependencies;
|
||||||
|
import org.asamk.signal.manager.api.AttachmentInvalidException;
|
||||||
import org.asamk.signal.manager.config.ServiceConfig;
|
import org.asamk.signal.manager.config.ServiceConfig;
|
||||||
import org.asamk.signal.manager.util.AttachmentUtils;
|
import org.asamk.signal.manager.util.AttachmentUtils;
|
||||||
import org.asamk.signal.manager.util.IOUtils;
|
import org.asamk.signal.manager.util.IOUtils;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import org.asamk.signal.manager.AttachmentStore;
|
||||||
import org.asamk.signal.manager.AvatarStore;
|
import org.asamk.signal.manager.AvatarStore;
|
||||||
import org.asamk.signal.manager.JobExecutor;
|
import org.asamk.signal.manager.JobExecutor;
|
||||||
import org.asamk.signal.manager.SignalDependencies;
|
import org.asamk.signal.manager.SignalDependencies;
|
||||||
import org.asamk.signal.manager.StickerPackStore;
|
import org.asamk.signal.manager.storage.stickerPacks.StickerPackStore;
|
||||||
import org.asamk.signal.manager.storage.SignalAccount;
|
import org.asamk.signal.manager.storage.SignalAccount;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.asamk.signal.manager.helper;
|
package org.asamk.signal.manager.helper;
|
||||||
|
|
||||||
import org.asamk.signal.manager.AttachmentInvalidException;
|
|
||||||
import org.asamk.signal.manager.SignalDependencies;
|
import org.asamk.signal.manager.SignalDependencies;
|
||||||
|
import org.asamk.signal.manager.api.AttachmentInvalidException;
|
||||||
import org.asamk.signal.manager.api.InactiveGroupLinkException;
|
import org.asamk.signal.manager.api.InactiveGroupLinkException;
|
||||||
import org.asamk.signal.manager.api.Pair;
|
import org.asamk.signal.manager.api.Pair;
|
||||||
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.asamk.signal.manager.helper;
|
package org.asamk.signal.manager.helper;
|
||||||
|
|
||||||
import org.asamk.signal.manager.TrustLevel;
|
import org.asamk.signal.manager.api.TrustLevel;
|
||||||
import org.asamk.signal.manager.storage.SignalAccount;
|
import org.asamk.signal.manager.storage.SignalAccount;
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
||||||
import org.asamk.signal.manager.util.Utils;
|
import org.asamk.signal.manager.util.Utils;
|
||||||
|
|
|
@ -2,8 +2,8 @@ package org.asamk.signal.manager.helper;
|
||||||
|
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.SignalDependencies;
|
import org.asamk.signal.manager.SignalDependencies;
|
||||||
import org.asamk.signal.manager.TrustLevel;
|
import org.asamk.signal.manager.api.TrustLevel;
|
||||||
import org.asamk.signal.manager.UntrustedIdentityException;
|
import org.asamk.signal.manager.api.UntrustedIdentityException;
|
||||||
import org.asamk.signal.manager.actions.HandleAction;
|
import org.asamk.signal.manager.actions.HandleAction;
|
||||||
import org.asamk.signal.manager.actions.RefreshPreKeysAction;
|
import org.asamk.signal.manager.actions.RefreshPreKeysAction;
|
||||||
import org.asamk.signal.manager.actions.RenewSessionAction;
|
import org.asamk.signal.manager.actions.RenewSessionAction;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.asamk.signal.manager.helper;
|
||||||
|
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.SignalDependencies;
|
import org.asamk.signal.manager.SignalDependencies;
|
||||||
import org.asamk.signal.manager.UntrustedIdentityException;
|
import org.asamk.signal.manager.api.UntrustedIdentityException;
|
||||||
import org.asamk.signal.manager.actions.HandleAction;
|
import org.asamk.signal.manager.actions.HandleAction;
|
||||||
import org.asamk.signal.manager.storage.SignalAccount;
|
import org.asamk.signal.manager.storage.SignalAccount;
|
||||||
import org.asamk.signal.manager.storage.messageCache.CachedMessage;
|
import org.asamk.signal.manager.storage.messageCache.CachedMessage;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package org.asamk.signal.manager.helper;
|
package org.asamk.signal.manager.helper;
|
||||||
|
|
||||||
import org.asamk.signal.manager.JsonStickerPack;
|
|
||||||
import org.asamk.signal.manager.SignalDependencies;
|
import org.asamk.signal.manager.SignalDependencies;
|
||||||
import org.asamk.signal.manager.api.InvalidStickerException;
|
import org.asamk.signal.manager.api.InvalidStickerException;
|
||||||
import org.asamk.signal.manager.api.StickerPackId;
|
import org.asamk.signal.manager.api.StickerPackId;
|
||||||
import org.asamk.signal.manager.storage.SignalAccount;
|
import org.asamk.signal.manager.storage.SignalAccount;
|
||||||
|
import org.asamk.signal.manager.storage.stickerPacks.JsonStickerPack;
|
||||||
import org.asamk.signal.manager.util.IOUtils;
|
import org.asamk.signal.manager.util.IOUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.asamk.signal.manager.helper;
|
package org.asamk.signal.manager.helper;
|
||||||
|
|
||||||
import org.asamk.signal.manager.SignalDependencies;
|
import org.asamk.signal.manager.SignalDependencies;
|
||||||
import org.asamk.signal.manager.TrustLevel;
|
import org.asamk.signal.manager.api.TrustLevel;
|
||||||
import org.asamk.signal.manager.api.PhoneNumberSharingMode;
|
import org.asamk.signal.manager.api.PhoneNumberSharingMode;
|
||||||
import org.asamk.signal.manager.groups.GroupId;
|
import org.asamk.signal.manager.groups.GroupId;
|
||||||
import org.asamk.signal.manager.storage.SignalAccount;
|
import org.asamk.signal.manager.storage.SignalAccount;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.asamk.signal.manager.helper;
|
package org.asamk.signal.manager.helper;
|
||||||
|
|
||||||
import org.asamk.signal.manager.TrustLevel;
|
import org.asamk.signal.manager.api.TrustLevel;
|
||||||
import org.asamk.signal.manager.storage.SignalAccount;
|
import org.asamk.signal.manager.storage.SignalAccount;
|
||||||
import org.asamk.signal.manager.storage.groups.GroupInfoV1;
|
import org.asamk.signal.manager.storage.groups.GroupInfoV1;
|
||||||
import org.asamk.signal.manager.storage.recipients.Contact;
|
import org.asamk.signal.manager.storage.recipients.Contact;
|
||||||
|
|
|
@ -3,7 +3,7 @@ package org.asamk.signal.manager.storage;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import org.asamk.signal.manager.TrustLevel;
|
import org.asamk.signal.manager.api.TrustLevel;
|
||||||
import org.asamk.signal.manager.api.Pair;
|
import org.asamk.signal.manager.api.Pair;
|
||||||
import org.asamk.signal.manager.groups.GroupId;
|
import org.asamk.signal.manager.groups.GroupId;
|
||||||
import org.asamk.signal.manager.storage.configuration.ConfigurationStore;
|
import org.asamk.signal.manager.storage.configuration.ConfigurationStore;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.asamk.signal.manager.storage.identities;
|
package org.asamk.signal.manager.storage.identities;
|
||||||
|
|
||||||
import org.asamk.signal.manager.TrustLevel;
|
import org.asamk.signal.manager.api.TrustLevel;
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
||||||
import org.whispersystems.libsignal.IdentityKey;
|
import org.whispersystems.libsignal.IdentityKey;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.asamk.signal.manager.storage.identities;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import org.asamk.signal.manager.TrustLevel;
|
import org.asamk.signal.manager.api.TrustLevel;
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientResolver;
|
import org.asamk.signal.manager.storage.recipients.RecipientResolver;
|
||||||
import org.asamk.signal.manager.util.IOUtils;
|
import org.asamk.signal.manager.util.IOUtils;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.asamk.signal.manager.storage.protocol;
|
package org.asamk.signal.manager.storage.protocol;
|
||||||
|
|
||||||
import org.asamk.signal.manager.TrustLevel;
|
import org.asamk.signal.manager.api.TrustLevel;
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
||||||
import org.whispersystems.libsignal.IdentityKey;
|
import org.whispersystems.libsignal.IdentityKey;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
import org.asamk.signal.manager.TrustLevel;
|
import org.asamk.signal.manager.api.TrustLevel;
|
||||||
import org.asamk.signal.manager.storage.Utils;
|
import org.asamk.signal.manager.storage.Utils;
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.asamk.signal.manager;
|
package org.asamk.signal.manager.storage.stickerPacks;
|
||||||
|
|
||||||
import org.asamk.signal.manager.api.StickerPack;
|
import org.asamk.signal.manager.api.StickerPack;
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package org.asamk.signal.manager;
|
package org.asamk.signal.manager.storage.stickerPacks;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import org.asamk.signal.manager.api.StickerPackId;
|
import org.asamk.signal.manager.api.StickerPackId;
|
||||||
|
import org.asamk.signal.manager.storage.stickerPacks.JsonStickerPack;
|
||||||
import org.asamk.signal.manager.util.IOUtils;
|
import org.asamk.signal.manager.util.IOUtils;
|
||||||
import org.asamk.signal.manager.util.Utils;
|
import org.asamk.signal.manager.util.Utils;
|
||||||
import org.whispersystems.signalservice.api.util.StreamDetails;
|
import org.whispersystems.signalservice.api.util.StreamDetails;
|
|
@ -1,6 +1,6 @@
|
||||||
package org.asamk.signal.manager.util;
|
package org.asamk.signal.manager.util;
|
||||||
|
|
||||||
import org.asamk.signal.manager.AttachmentInvalidException;
|
import org.asamk.signal.manager.api.AttachmentInvalidException;
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream;
|
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream;
|
||||||
|
|
|
@ -2,9 +2,9 @@ package org.asamk.signal.manager.util;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import org.asamk.signal.manager.JsonStickerPack;
|
import org.asamk.signal.manager.api.StickerPackInvalidException;
|
||||||
import org.asamk.signal.manager.StickerPackInvalidException;
|
|
||||||
import org.asamk.signal.manager.api.Pair;
|
import org.asamk.signal.manager.api.Pair;
|
||||||
|
import org.asamk.signal.manager.storage.stickerPacks.JsonStickerPack;
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceStickerManifestUpload;
|
import org.whispersystems.signalservice.api.messages.SignalServiceStickerManifestUpload;
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,11 @@ import org.asamk.signal.dbus.DbusMultiAccountManagerImpl;
|
||||||
import org.asamk.signal.dbus.DbusProvisioningManagerImpl;
|
import org.asamk.signal.dbus.DbusProvisioningManagerImpl;
|
||||||
import org.asamk.signal.dbus.DbusRegistrationManagerImpl;
|
import org.asamk.signal.dbus.DbusRegistrationManagerImpl;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.MultiAccountManagerImpl;
|
import org.asamk.signal.manager.MultiAccountManager;
|
||||||
import org.asamk.signal.manager.NotRegisteredException;
|
|
||||||
import org.asamk.signal.manager.ProvisioningManager;
|
import org.asamk.signal.manager.ProvisioningManager;
|
||||||
import org.asamk.signal.manager.RegistrationManager;
|
import org.asamk.signal.manager.RegistrationManager;
|
||||||
|
import org.asamk.signal.manager.api.AccountCheckException;
|
||||||
|
import org.asamk.signal.manager.api.NotRegisteredException;
|
||||||
import org.asamk.signal.manager.config.ServiceConfig;
|
import org.asamk.signal.manager.config.ServiceConfig;
|
||||||
import org.asamk.signal.manager.config.ServiceEnvironment;
|
import org.asamk.signal.manager.config.ServiceEnvironment;
|
||||||
import org.asamk.signal.manager.storage.identities.TrustNewIdentity;
|
import org.asamk.signal.manager.storage.identities.TrustNewIdentity;
|
||||||
|
@ -46,8 +47,6 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static net.sourceforge.argparse4j.DefaultSettings.VERSION_0_9_0_DEFAULT_SETTINGS;
|
import static net.sourceforge.argparse4j.DefaultSettings.VERSION_0_9_0_DEFAULT_SETTINGS;
|
||||||
|
|
||||||
|
@ -143,18 +142,18 @@ public class App {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final File dataPath;
|
|
||||||
var config = ns.getString("config");
|
|
||||||
if (config != null) {
|
|
||||||
dataPath = new File(config);
|
|
||||||
} else {
|
|
||||||
dataPath = getDefaultDataPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ServiceConfig.isSignalClientAvailable()) {
|
if (!ServiceConfig.isSignalClientAvailable()) {
|
||||||
throw new UserErrorException("Missing required native library dependency: libsignal-client");
|
throw new UserErrorException("Missing required native library dependency: libsignal-client");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final File configPath;
|
||||||
|
var config = ns.getString("config");
|
||||||
|
if (config != null) {
|
||||||
|
configPath = new File(config);
|
||||||
|
} else {
|
||||||
|
configPath = getDefaultConfigPath();
|
||||||
|
}
|
||||||
|
|
||||||
final var serviceEnvironmentCli = ns.<ServiceEnvironmentCli>get("service-environment");
|
final var serviceEnvironmentCli = ns.<ServiceEnvironmentCli>get("service-environment");
|
||||||
final var serviceEnvironment = serviceEnvironmentCli == ServiceEnvironmentCli.LIVE
|
final var serviceEnvironment = serviceEnvironmentCli == ServiceEnvironmentCli.LIVE
|
||||||
? ServiceEnvironment.LIVE
|
? ServiceEnvironment.LIVE
|
||||||
|
@ -170,23 +169,21 @@ public class App {
|
||||||
throw new UserErrorException("You cannot specify a account (phone number) when linking");
|
throw new UserErrorException("You cannot specify a account (phone number) when linking");
|
||||||
}
|
}
|
||||||
|
|
||||||
handleProvisioningCommand(provisioningCommand, dataPath, serviceEnvironment, outputWriter);
|
handleProvisioningCommand(provisioningCommand, configPath, serviceEnvironment, outputWriter);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
var accounts = Manager.getAllLocalAccountNumbers(dataPath);
|
|
||||||
|
|
||||||
if (command instanceof MultiLocalCommand multiLocalCommand) {
|
if (command instanceof MultiLocalCommand multiLocalCommand) {
|
||||||
handleMultiLocalCommand(multiLocalCommand,
|
handleMultiLocalCommand(multiLocalCommand,
|
||||||
dataPath,
|
configPath,
|
||||||
serviceEnvironment,
|
serviceEnvironment,
|
||||||
accounts,
|
|
||||||
outputWriter,
|
outputWriter,
|
||||||
trustNewIdentity);
|
trustNewIdentity);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var accounts = MultiAccountManager.getAllLocalAccountNumbers(configPath);
|
||||||
if (accounts.size() == 0) {
|
if (accounts.size() == 0) {
|
||||||
throw new UserErrorException("No local users found, you first need to register or link an account");
|
throw new UserErrorException("No local users found, you first need to register or link an account");
|
||||||
} else if (accounts.size() > 1) {
|
} else if (accounts.size() > 1) {
|
||||||
|
@ -200,7 +197,7 @@ public class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command instanceof RegistrationCommand registrationCommand) {
|
if (command instanceof RegistrationCommand registrationCommand) {
|
||||||
handleRegistrationCommand(registrationCommand, account, dataPath, serviceEnvironment);
|
handleRegistrationCommand(registrationCommand, account, configPath, serviceEnvironment);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +207,7 @@ public class App {
|
||||||
|
|
||||||
handleLocalCommand((LocalCommand) command,
|
handleLocalCommand((LocalCommand) command,
|
||||||
account,
|
account,
|
||||||
dataPath,
|
configPath,
|
||||||
serviceEnvironment,
|
serviceEnvironment,
|
||||||
outputWriter,
|
outputWriter,
|
||||||
trustNewIdentity);
|
trustNewIdentity);
|
||||||
|
@ -218,11 +215,11 @@ public class App {
|
||||||
|
|
||||||
private void handleProvisioningCommand(
|
private void handleProvisioningCommand(
|
||||||
final ProvisioningCommand command,
|
final ProvisioningCommand command,
|
||||||
final File dataPath,
|
final File configPath,
|
||||||
final ServiceEnvironment serviceEnvironment,
|
final ServiceEnvironment serviceEnvironment,
|
||||||
final OutputWriter outputWriter
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
var pm = ProvisioningManager.init(dataPath, serviceEnvironment, BaseConfig.USER_AGENT);
|
var pm = ProvisioningManager.init(configPath, serviceEnvironment, BaseConfig.USER_AGENT);
|
||||||
command.handleCommand(ns, pm, outputWriter);
|
command.handleCommand(ns, pm, outputWriter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,12 +242,12 @@ public class App {
|
||||||
private void handleRegistrationCommand(
|
private void handleRegistrationCommand(
|
||||||
final RegistrationCommand command,
|
final RegistrationCommand command,
|
||||||
final String account,
|
final String account,
|
||||||
final File dataPath,
|
final File configPath,
|
||||||
final ServiceEnvironment serviceEnvironment
|
final ServiceEnvironment serviceEnvironment
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final RegistrationManager manager;
|
final RegistrationManager manager;
|
||||||
try {
|
try {
|
||||||
manager = RegistrationManager.init(account, dataPath, serviceEnvironment, BaseConfig.USER_AGENT);
|
manager = RegistrationManager.init(account, configPath, serviceEnvironment, BaseConfig.USER_AGENT);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new UnexpectedErrorException("Error loading or creating state file: "
|
throw new UnexpectedErrorException("Error loading or creating state file: "
|
||||||
+ e.getMessage()
|
+ e.getMessage()
|
||||||
|
@ -283,12 +280,12 @@ public class App {
|
||||||
private void handleLocalCommand(
|
private void handleLocalCommand(
|
||||||
final LocalCommand command,
|
final LocalCommand command,
|
||||||
final String account,
|
final String account,
|
||||||
final File dataPath,
|
final File configPath,
|
||||||
final ServiceEnvironment serviceEnvironment,
|
final ServiceEnvironment serviceEnvironment,
|
||||||
final OutputWriter outputWriter,
|
final OutputWriter outputWriter,
|
||||||
final TrustNewIdentity trustNewIdentity
|
final TrustNewIdentity trustNewIdentity
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
try (var m = loadManager(account, dataPath, serviceEnvironment, trustNewIdentity)) {
|
try (var m = loadManager(account, configPath, serviceEnvironment, trustNewIdentity)) {
|
||||||
command.handleCommand(ns, m, outputWriter);
|
command.handleCommand(ns, m, outputWriter);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Cleanup failed", e);
|
logger.warn("Cleanup failed", e);
|
||||||
|
@ -313,25 +310,15 @@ public class App {
|
||||||
|
|
||||||
private void handleMultiLocalCommand(
|
private void handleMultiLocalCommand(
|
||||||
final MultiLocalCommand command,
|
final MultiLocalCommand command,
|
||||||
final File dataPath,
|
final File configPath,
|
||||||
final ServiceEnvironment serviceEnvironment,
|
final ServiceEnvironment serviceEnvironment,
|
||||||
final List<String> accounts,
|
|
||||||
final OutputWriter outputWriter,
|
final OutputWriter outputWriter,
|
||||||
final TrustNewIdentity trustNewIdentity
|
final TrustNewIdentity trustNewIdentity
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final var managers = new ArrayList<Manager>();
|
try (var multiAccountManager = MultiAccountManager.init(configPath,
|
||||||
for (String a : accounts) {
|
|
||||||
try {
|
|
||||||
managers.add(loadManager(a, dataPath, serviceEnvironment, trustNewIdentity));
|
|
||||||
} catch (CommandException e) {
|
|
||||||
logger.warn("Ignoring {}: {}", a, e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try (var multiAccountManager = new MultiAccountManagerImpl(managers,
|
|
||||||
dataPath,
|
|
||||||
serviceEnvironment,
|
serviceEnvironment,
|
||||||
BaseConfig.USER_AGENT)) {
|
BaseConfig.USER_AGENT,
|
||||||
|
trustNewIdentity)) {
|
||||||
command.handleCommand(ns, multiAccountManager, outputWriter);
|
command.handleCommand(ns, multiAccountManager, outputWriter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,16 +338,22 @@ public class App {
|
||||||
|
|
||||||
private Manager loadManager(
|
private Manager loadManager(
|
||||||
final String account,
|
final String account,
|
||||||
final File dataPath,
|
final File configPath,
|
||||||
final ServiceEnvironment serviceEnvironment,
|
final ServiceEnvironment serviceEnvironment,
|
||||||
final TrustNewIdentity trustNewIdentity
|
final TrustNewIdentity trustNewIdentity
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
Manager manager;
|
|
||||||
logger.trace("Loading account file for {}", account);
|
logger.trace("Loading account file for {}", account);
|
||||||
try {
|
try {
|
||||||
manager = Manager.init(account, dataPath, serviceEnvironment, BaseConfig.USER_AGENT, trustNewIdentity);
|
return Manager.init(account, configPath, serviceEnvironment, BaseConfig.USER_AGENT, trustNewIdentity);
|
||||||
} catch (NotRegisteredException e) {
|
} catch (NotRegisteredException e) {
|
||||||
throw new UserErrorException("User " + account + " is not registered.");
|
throw new UserErrorException("User " + account + " is not registered.");
|
||||||
|
} catch (AccountCheckException ace) {
|
||||||
|
if (ace.getCause() instanceof IOException e) {
|
||||||
|
throw new IOErrorException("Error while checking account " + account + ": " + e.getMessage(), e);
|
||||||
|
} else {
|
||||||
|
throw new UnexpectedErrorException("Error while checking account " + account + ": " + ace.getMessage(),
|
||||||
|
ace);
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new UnexpectedErrorException("Error loading state file for user "
|
throw new UnexpectedErrorException("Error loading state file for user "
|
||||||
+ account
|
+ account
|
||||||
|
@ -370,20 +363,6 @@ public class App {
|
||||||
+ e.getClass().getSimpleName()
|
+ e.getClass().getSimpleName()
|
||||||
+ ")", e);
|
+ ")", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.trace("Checking account state");
|
|
||||||
try {
|
|
||||||
manager.checkAccountState();
|
|
||||||
} catch (IOException e) {
|
|
||||||
try {
|
|
||||||
manager.close();
|
|
||||||
} catch (IOException ie) {
|
|
||||||
logger.warn("Failed to close broken account", ie);
|
|
||||||
}
|
|
||||||
throw new IOErrorException("Error while checking account " + account + ": " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return manager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initDbusClient(
|
private void initDbusClient(
|
||||||
|
@ -457,7 +436,7 @@ public class App {
|
||||||
/**
|
/**
|
||||||
* @return the default data directory to be used by signal-cli.
|
* @return the default data directory to be used by signal-cli.
|
||||||
*/
|
*/
|
||||||
private static File getDefaultDataPath() {
|
private static File getDefaultConfigPath() {
|
||||||
return new File(IOUtils.getDataHomeDir(), "signal-cli");
|
return new File(IOUtils.getDataHomeDir(), "signal-cli");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.asamk.signal;
|
package org.asamk.signal;
|
||||||
|
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.UntrustedIdentityException;
|
import org.asamk.signal.manager.api.UntrustedIdentityException;
|
||||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||||
import org.asamk.signal.manager.api.RecipientIdentifier;
|
import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||||
import org.asamk.signal.manager.groups.GroupId;
|
import org.asamk.signal.manager.groups.GroupId;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
import org.asamk.signal.manager.api.NotMasterDeviceException;
|
||||||
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
||||||
import org.asamk.signal.output.OutputWriter;
|
import org.asamk.signal.output.OutputWriter;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.MultiAccountManager;
|
import org.asamk.signal.manager.MultiAccountManager;
|
||||||
import org.asamk.signal.manager.UserAlreadyExists;
|
import org.asamk.signal.manager.api.UserAlreadyExistsException;
|
||||||
import org.asamk.signal.output.JsonWriter;
|
import org.asamk.signal.output.JsonWriter;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -56,7 +56,7 @@ public class FinishLinkCommand implements JsonRpcMultiCommand<FinishLinkCommand.
|
||||||
throw new UserErrorException("Link request timed out, please try again.");
|
throw new UserErrorException("Link request timed out, please try again.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IOErrorException("Link request error: " + e.getMessage(), e);
|
throw new IOErrorException("Link request error: " + e.getMessage(), e);
|
||||||
} catch (UserAlreadyExists e) {
|
} catch (UserAlreadyExistsException e) {
|
||||||
throw new UserErrorException("The user "
|
throw new UserErrorException("The user "
|
||||||
+ e.getNumber()
|
+ e.getNumber()
|
||||||
+ " already exists\nDelete \""
|
+ " already exists\nDelete \""
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.ProvisioningManager;
|
import org.asamk.signal.manager.ProvisioningManager;
|
||||||
import org.asamk.signal.manager.UserAlreadyExists;
|
import org.asamk.signal.manager.api.UserAlreadyExistsException;
|
||||||
import org.asamk.signal.output.OutputWriter;
|
import org.asamk.signal.output.OutputWriter;
|
||||||
import org.asamk.signal.output.PlainTextWriter;
|
import org.asamk.signal.output.PlainTextWriter;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -49,7 +49,7 @@ public class LinkCommand implements ProvisioningCommand {
|
||||||
throw new UserErrorException("Link request timed out, please try again.");
|
throw new UserErrorException("Link request timed out, please try again.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IOErrorException("Link request error: " + e.getMessage(), e);
|
throw new IOErrorException("Link request error: " + e.getMessage(), e);
|
||||||
} catch (UserAlreadyExists e) {
|
} catch (UserAlreadyExistsException e) {
|
||||||
throw new UserErrorException("The user "
|
throw new UserErrorException("The user "
|
||||||
+ e.getNumber()
|
+ e.getNumber()
|
||||||
+ " already exists\nDelete \""
|
+ " already exists\nDelete \""
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
import org.asamk.signal.manager.api.NotMasterDeviceException;
|
||||||
import org.asamk.signal.output.OutputWriter;
|
import org.asamk.signal.output.OutputWriter;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
|
@ -7,8 +7,8 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
||||||
import org.asamk.signal.commands.exceptions.CommandException;
|
import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.AttachmentInvalidException;
|
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
|
import org.asamk.signal.manager.api.AttachmentInvalidException;
|
||||||
import org.asamk.signal.manager.api.InvalidStickerException;
|
import org.asamk.signal.manager.api.InvalidStickerException;
|
||||||
import org.asamk.signal.manager.api.Message;
|
import org.asamk.signal.manager.api.Message;
|
||||||
import org.asamk.signal.manager.api.RecipientIdentifier;
|
import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
import org.asamk.signal.manager.api.NotMasterDeviceException;
|
||||||
import org.asamk.signal.output.OutputWriter;
|
import org.asamk.signal.output.OutputWriter;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
import org.asamk.signal.manager.api.NotMasterDeviceException;
|
||||||
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
||||||
import org.asamk.signal.output.OutputWriter;
|
import org.asamk.signal.output.OutputWriter;
|
||||||
|
|
|
@ -7,8 +7,8 @@ import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
|
||||||
import org.asamk.signal.manager.api.Configuration;
|
import org.asamk.signal.manager.api.Configuration;
|
||||||
|
import org.asamk.signal.manager.api.NotMasterDeviceException;
|
||||||
import org.asamk.signal.output.OutputWriter;
|
import org.asamk.signal.output.OutputWriter;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
import org.asamk.signal.manager.api.NotMasterDeviceException;
|
||||||
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.output.OutputWriter;
|
import org.asamk.signal.output.OutputWriter;
|
||||||
import org.asamk.signal.util.CommandUtil;
|
import org.asamk.signal.util.CommandUtil;
|
||||||
|
|
|
@ -7,8 +7,8 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
||||||
import org.asamk.signal.commands.exceptions.CommandException;
|
import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.AttachmentInvalidException;
|
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
|
import org.asamk.signal.manager.api.AttachmentInvalidException;
|
||||||
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
||||||
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.api.UpdateGroup;
|
import org.asamk.signal.manager.api.UpdateGroup;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.StickerPackInvalidException;
|
import org.asamk.signal.manager.api.StickerPackInvalidException;
|
||||||
import org.asamk.signal.output.JsonWriter;
|
import org.asamk.signal.output.JsonWriter;
|
||||||
import org.asamk.signal.output.OutputWriter;
|
import org.asamk.signal.output.OutputWriter;
|
||||||
import org.asamk.signal.output.PlainTextWriter;
|
import org.asamk.signal.output.PlainTextWriter;
|
||||||
|
|
|
@ -2,10 +2,9 @@ package org.asamk.signal.dbus;
|
||||||
|
|
||||||
import org.asamk.Signal;
|
import org.asamk.Signal;
|
||||||
import org.asamk.signal.DbusConfig;
|
import org.asamk.signal.DbusConfig;
|
||||||
import org.asamk.signal.manager.AttachmentInvalidException;
|
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
import org.asamk.signal.manager.api.StickerPackInvalidException;
|
||||||
import org.asamk.signal.manager.StickerPackInvalidException;
|
import org.asamk.signal.manager.api.AttachmentInvalidException;
|
||||||
import org.asamk.signal.manager.api.Configuration;
|
import org.asamk.signal.manager.api.Configuration;
|
||||||
import org.asamk.signal.manager.api.Device;
|
import org.asamk.signal.manager.api.Device;
|
||||||
import org.asamk.signal.manager.api.Group;
|
import org.asamk.signal.manager.api.Group;
|
||||||
|
@ -14,6 +13,7 @@ import org.asamk.signal.manager.api.InactiveGroupLinkException;
|
||||||
import org.asamk.signal.manager.api.InvalidDeviceLinkException;
|
import org.asamk.signal.manager.api.InvalidDeviceLinkException;
|
||||||
import org.asamk.signal.manager.api.Message;
|
import org.asamk.signal.manager.api.Message;
|
||||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||||
|
import org.asamk.signal.manager.api.NotMasterDeviceException;
|
||||||
import org.asamk.signal.manager.api.Pair;
|
import org.asamk.signal.manager.api.Pair;
|
||||||
import org.asamk.signal.manager.api.RecipientIdentifier;
|
import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||||
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
||||||
|
@ -84,11 +84,6 @@ public class DbusManagerImpl implements Manager {
|
||||||
return signal.getSelfNumber();
|
return signal.getSelfNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void checkAccountState() throws IOException {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Pair<String, UUID>> areUsersRegistered(final Set<String> numbers) throws IOException {
|
public Map<String, Pair<String, UUID>> areUsersRegistered(final Set<String> numbers) throws IOException {
|
||||||
final var numbersList = new ArrayList<>(numbers);
|
final var numbersList = new ArrayList<>(numbers);
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.asamk.signal.dbus;
|
||||||
|
|
||||||
import org.asamk.SignalControl;
|
import org.asamk.SignalControl;
|
||||||
import org.asamk.signal.manager.ProvisioningManager;
|
import org.asamk.signal.manager.ProvisioningManager;
|
||||||
import org.asamk.signal.manager.UserAlreadyExists;
|
import org.asamk.signal.manager.api.UserAlreadyExistsException;
|
||||||
import org.freedesktop.dbus.connections.impl.DBusConnection;
|
import org.freedesktop.dbus.connections.impl.DBusConnection;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -27,9 +27,7 @@ public class DbusProvisioningManagerImpl implements ProvisioningManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbusProvisioningManagerImpl(
|
public DbusProvisioningManagerImpl(
|
||||||
final SignalControl signalControl,
|
final SignalControl signalControl, DBusConnection connection, URI deviceLinkUri
|
||||||
DBusConnection connection,
|
|
||||||
URI deviceLinkUri
|
|
||||||
) {
|
) {
|
||||||
this.signalControl = signalControl;
|
this.signalControl = signalControl;
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
|
@ -47,7 +45,7 @@ public class DbusProvisioningManagerImpl implements ProvisioningManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String finishDeviceLink(final String deviceName) throws IOException, TimeoutException, UserAlreadyExists {
|
public String finishDeviceLink(final String deviceName) throws IOException, TimeoutException, UserAlreadyExistsException {
|
||||||
return signalControl.finishLink(deviceLinkUri.toString(), deviceName);
|
return signalControl.finishLink(deviceLinkUri.toString(), deviceName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.MultiAccountManager;
|
import org.asamk.signal.manager.MultiAccountManager;
|
||||||
import org.asamk.signal.manager.ProvisioningManager;
|
import org.asamk.signal.manager.ProvisioningManager;
|
||||||
import org.asamk.signal.manager.RegistrationManager;
|
import org.asamk.signal.manager.RegistrationManager;
|
||||||
import org.asamk.signal.manager.UserAlreadyExists;
|
import org.asamk.signal.manager.api.UserAlreadyExistsException;
|
||||||
import org.asamk.signal.manager.api.CaptchaRequiredException;
|
import org.asamk.signal.manager.api.CaptchaRequiredException;
|
||||||
import org.asamk.signal.manager.api.IncorrectPinException;
|
import org.asamk.signal.manager.api.IncorrectPinException;
|
||||||
import org.asamk.signal.manager.api.PinLockedException;
|
import org.asamk.signal.manager.api.PinLockedException;
|
||||||
|
@ -100,7 +100,7 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
||||||
final ProvisioningManager provisioningManager = c.getProvisioningManagerFor(deviceLinkUri);
|
final ProvisioningManager provisioningManager = c.getProvisioningManagerFor(deviceLinkUri);
|
||||||
try {
|
try {
|
||||||
provisioningManager.finishDeviceLink(newDeviceName);
|
provisioningManager.finishDeviceLink(newDeviceName);
|
||||||
} catch (IOException | TimeoutException | UserAlreadyExists e) {
|
} catch (IOException | TimeoutException | UserAlreadyExistsException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -127,7 +127,7 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
||||||
try {
|
try {
|
||||||
final var provisioningManager = c.getProvisioningManagerFor(new URI(deviceLinkUri));
|
final var provisioningManager = c.getProvisioningManagerFor(new URI(deviceLinkUri));
|
||||||
return provisioningManager.finishDeviceLink(newDeviceName);
|
return provisioningManager.finishDeviceLink(newDeviceName);
|
||||||
} catch (TimeoutException | IOException | UserAlreadyExists | URISyntaxException e) {
|
} catch (TimeoutException | IOException | UserAlreadyExistsException | URISyntaxException e) {
|
||||||
throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
|
throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,16 +2,16 @@ package org.asamk.signal.dbus;
|
||||||
|
|
||||||
import org.asamk.Signal;
|
import org.asamk.Signal;
|
||||||
import org.asamk.signal.BaseConfig;
|
import org.asamk.signal.BaseConfig;
|
||||||
import org.asamk.signal.manager.AttachmentInvalidException;
|
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
import org.asamk.signal.manager.api.StickerPackInvalidException;
|
||||||
import org.asamk.signal.manager.StickerPackInvalidException;
|
import org.asamk.signal.manager.api.AttachmentInvalidException;
|
||||||
import org.asamk.signal.manager.api.Identity;
|
import org.asamk.signal.manager.api.Identity;
|
||||||
import org.asamk.signal.manager.api.InactiveGroupLinkException;
|
import org.asamk.signal.manager.api.InactiveGroupLinkException;
|
||||||
import org.asamk.signal.manager.api.InvalidDeviceLinkException;
|
import org.asamk.signal.manager.api.InvalidDeviceLinkException;
|
||||||
import org.asamk.signal.manager.api.InvalidNumberException;
|
import org.asamk.signal.manager.api.InvalidNumberException;
|
||||||
import org.asamk.signal.manager.api.InvalidStickerException;
|
import org.asamk.signal.manager.api.InvalidStickerException;
|
||||||
import org.asamk.signal.manager.api.Message;
|
import org.asamk.signal.manager.api.Message;
|
||||||
|
import org.asamk.signal.manager.api.NotMasterDeviceException;
|
||||||
import org.asamk.signal.manager.api.Pair;
|
import org.asamk.signal.manager.api.Pair;
|
||||||
import org.asamk.signal.manager.api.RecipientIdentifier;
|
import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||||
import org.asamk.signal.manager.api.SendMessageResult;
|
import org.asamk.signal.manager.api.SendMessageResult;
|
||||||
|
|
|
@ -3,7 +3,7 @@ package org.asamk.signal.json;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.UntrustedIdentityException;
|
import org.asamk.signal.manager.api.UntrustedIdentityException;
|
||||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||||
import org.asamk.signal.manager.api.RecipientIdentifier;
|
import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue