package org.asamk.signal.manager;
+import org.asamk.signal.manager.api.Configuration;
import org.asamk.signal.manager.api.Device;
import org.asamk.signal.manager.api.Group;
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.Message;
+import org.asamk.signal.manager.api.MessageEnvelope;
import org.asamk.signal.manager.api.Pair;
import org.asamk.signal.manager.api.RecipientIdentifier;
import org.asamk.signal.manager.api.SendGroupMessageResults;
import org.asamk.signal.manager.storage.recipients.Contact;
import org.asamk.signal.manager.storage.recipients.Profile;
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
-import org.whispersystems.libsignal.InvalidKeyException;
-import org.whispersystems.signalservice.api.groupsv2.GroupLinkNotActiveException;
-import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentRemoteId;
-import org.whispersystems.signalservice.api.messages.SignalServiceContent;
-import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
-import org.whispersystems.signalservice.api.push.SignalServiceAddress;
-import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
-import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
import java.io.Closeable;
import java.io.File;
return new ManagerImpl(account, pathConfig, serviceEnvironmentConfig, userAgent);
}
- static List<String> getAllLocalNumbers(File settingsPath) {
+ static void initLogger() {
+ LibSignalLogger.initLogger();
+ }
+
+ static boolean isValidNumber(final String e164Number, final String 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();
void updateAccountAttributes(String deviceName) throws IOException;
- void updateConfiguration(
- final Boolean readReceipts,
- final Boolean unidentifiedDeliveryIndicators,
- final Boolean typingIndicators,
- final Boolean linkPreviews
- ) throws IOException, NotMasterDeviceException;
+ Configuration getConfiguration();
+
+ void updateConfiguration(Configuration configuration) throws IOException, NotMasterDeviceException;
void setProfile(
String givenName, String familyName, String about, String aboutEmoji, Optional<File> avatar
void removeLinkedDevices(long deviceId) throws IOException;
- void addDeviceLink(URI linkUri) throws IOException, InvalidKeyException;
+ void addDeviceLink(URI linkUri) throws IOException, InvalidDeviceLinkException;
- void setRegistrationLockPin(Optional<String> pin) throws IOException, UnauthenticatedResponseException;
+ void setRegistrationLockPin(Optional<String> pin) throws IOException;
- Profile getRecipientProfile(RecipientIdentifier.Single recipient) throws UnregisteredUserException;
+ Profile getRecipientProfile(RecipientIdentifier.Single recipient) throws IOException;
List<Group> getGroups();
Pair<GroupId, SendGroupMessageResults> joinGroup(
GroupInviteLinkUrl inviteLinkUrl
- ) throws IOException, GroupLinkNotActiveException;
+ ) throws IOException, InactiveGroupLinkException;
- void sendTypingMessage(
+ SendMessageResults sendTypingMessage(
TypingAction action, Set<RecipientIdentifier> recipients
- ) throws IOException, UntrustedIdentityException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException;
+ ) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException;
- void sendReadReceipt(
+ SendMessageResults sendReadReceipt(
RecipientIdentifier.Single sender, List<Long> messageIds
- ) throws IOException, UntrustedIdentityException;
+ ) throws IOException;
- void sendViewedReceipt(
+ SendMessageResults sendViewedReceipt(
RecipientIdentifier.Single sender, List<Long> messageIds
- ) throws IOException, UntrustedIdentityException;
+ ) throws IOException;
SendMessageResults sendMessage(
Message message, Set<RecipientIdentifier> recipients
void setContactName(
RecipientIdentifier.Single recipient, String name
- ) throws NotMasterDeviceException, UnregisteredUserException;
+ ) throws NotMasterDeviceException, IOException;
void setContactBlocked(
RecipientIdentifier.Single recipient, boolean blocked
* Add a handler to receive new messages.
* Will start receiving messages from server, if not already started.
*/
- void addReceiveHandler(ReceiveMessageHandler handler);
+ default void addReceiveHandler(ReceiveMessageHandler handler) {
+ addReceiveHandler(handler, false);
+ }
+
+ void addReceiveHandler(ReceiveMessageHandler handler, final boolean isWeakListener);
/**
* Remove a handler to receive new messages.
boolean isContactBlocked(RecipientIdentifier.Single recipient);
- File getAttachmentFile(SignalServiceAttachmentRemoteId attachmentId);
-
void sendContacts() throws IOException;
List<Pair<RecipientAddress, Contact>> getContacts();
boolean trustIdentityAllKeys(RecipientIdentifier.Single recipient);
- SignalServiceAddress resolveSignalServiceAddress(SignalServiceAddress address);
+ void addClosedListener(Runnable listener);
@Override
void close() throws IOException;
interface ReceiveMessageHandler {
- void handleMessage(SignalServiceEnvelope envelope, SignalServiceContent decryptedContent, Throwable e);
+ ReceiveMessageHandler EMPTY = (envelope, e) -> {
+ };
+
+ void handleMessage(MessageEnvelope envelope, Throwable e);
}
}