Rename main/master device to primary device

This commit is contained in:
AsamK 2022-05-24 14:36:33 +02:00
parent ad65eb7ea2
commit 9ad24614cb
22 changed files with 74 additions and 74 deletions

View file

@ -10,7 +10,7 @@ import org.asamk.signal.manager.api.InvalidDeviceLinkException;
import org.asamk.signal.manager.api.InvalidStickerException;
import org.asamk.signal.manager.api.Message;
import org.asamk.signal.manager.api.MessageEnvelope;
import org.asamk.signal.manager.api.NotMasterDeviceException;
import org.asamk.signal.manager.api.NotPrimaryDeviceException;
import org.asamk.signal.manager.api.Pair;
import org.asamk.signal.manager.api.RecipientIdentifier;
import org.asamk.signal.manager.api.SendGroupMessageResults;
@ -65,7 +65,7 @@ public interface Manager extends Closeable {
Configuration getConfiguration();
void updateConfiguration(Configuration configuration) throws IOException, NotMasterDeviceException;
void updateConfiguration(Configuration configuration) throws IOException, NotPrimaryDeviceException;
/**
* Update the user's profile.
@ -85,7 +85,7 @@ public interface Manager extends Closeable {
void addDeviceLink(URI linkUri) throws IOException, InvalidDeviceLinkException;
void setRegistrationLockPin(Optional<String> pin) throws IOException, NotMasterDeviceException;
void setRegistrationLockPin(Optional<String> pin) throws IOException, NotPrimaryDeviceException;
Profile getRecipientProfile(RecipientIdentifier.Single recipient) throws IOException, UnregisteredRecipientException;
@ -149,15 +149,15 @@ public interface Manager extends Closeable {
void setContactName(
RecipientIdentifier.Single recipient, String name
) throws NotMasterDeviceException, IOException, UnregisteredRecipientException;
) throws NotPrimaryDeviceException, IOException, UnregisteredRecipientException;
void setContactsBlocked(
Collection<RecipientIdentifier.Single> recipient, boolean blocked
) throws NotMasterDeviceException, IOException, UnregisteredRecipientException;
) throws NotPrimaryDeviceException, IOException, UnregisteredRecipientException;
void setGroupsBlocked(
Collection<GroupId> groupId, boolean blocked
) throws GroupNotFoundException, IOException, NotMasterDeviceException;
) throws GroupNotFoundException, IOException, NotPrimaryDeviceException;
/**
* Change the expiration timer for a contact

View file

@ -25,7 +25,7 @@ import org.asamk.signal.manager.api.InactiveGroupLinkException;
import org.asamk.signal.manager.api.InvalidDeviceLinkException;
import org.asamk.signal.manager.api.InvalidStickerException;
import org.asamk.signal.manager.api.Message;
import org.asamk.signal.manager.api.NotMasterDeviceException;
import org.asamk.signal.manager.api.NotPrimaryDeviceException;
import org.asamk.signal.manager.api.Pair;
import org.asamk.signal.manager.api.RecipientIdentifier;
import org.asamk.signal.manager.api.SendGroupMessageResults;
@ -241,9 +241,9 @@ class ManagerImpl implements Manager {
@Override
public void updateConfiguration(
Configuration configuration
) throws NotMasterDeviceException {
if (!account.isMasterDevice()) {
throw new NotMasterDeviceException();
) throws NotPrimaryDeviceException {
if (!account.isPrimaryDevice()) {
throw new NotPrimaryDeviceException();
}
final var configurationStore = account.getConfigurationStore();
@ -327,9 +327,9 @@ class ManagerImpl implements Manager {
}
@Override
public void setRegistrationLockPin(Optional<String> pin) throws IOException, NotMasterDeviceException {
if (!account.isMasterDevice()) {
throw new NotMasterDeviceException();
public void setRegistrationLockPin(Optional<String> pin) throws IOException, NotPrimaryDeviceException {
if (!account.isPrimaryDevice()) {
throw new NotPrimaryDeviceException();
}
if (pin.isPresent()) {
context.getAccountHelper().setRegistrationPin(pin.get());
@ -692,9 +692,9 @@ class ManagerImpl implements Manager {
@Override
public void setContactName(
RecipientIdentifier.Single recipient, String name
) throws NotMasterDeviceException, UnregisteredRecipientException {
if (!account.isMasterDevice()) {
throw new NotMasterDeviceException();
) throws NotPrimaryDeviceException, UnregisteredRecipientException {
if (!account.isPrimaryDevice()) {
throw new NotPrimaryDeviceException();
}
context.getContactHelper().setContactName(context.getRecipientHelper().resolveRecipient(recipient), name);
}
@ -702,9 +702,9 @@ class ManagerImpl implements Manager {
@Override
public void setContactsBlocked(
Collection<RecipientIdentifier.Single> recipients, boolean blocked
) throws NotMasterDeviceException, IOException, UnregisteredRecipientException {
if (!account.isMasterDevice()) {
throw new NotMasterDeviceException();
) throws NotPrimaryDeviceException, IOException, UnregisteredRecipientException {
if (!account.isPrimaryDevice()) {
throw new NotPrimaryDeviceException();
}
if (recipients.size() == 0) {
return;
@ -734,9 +734,9 @@ class ManagerImpl implements Manager {
@Override
public void setGroupsBlocked(
final Collection<GroupId> groupIds, final boolean blocked
) throws GroupNotFoundException, NotMasterDeviceException, IOException {
if (!account.isMasterDevice()) {
throw new NotMasterDeviceException();
) throws GroupNotFoundException, NotPrimaryDeviceException, IOException {
if (!account.isPrimaryDevice()) {
throw new NotPrimaryDeviceException();
}
if (groupIds.size() == 0) {
return;

View file

@ -206,8 +206,8 @@ class ProvisioningManagerImpl implements ProvisioningManager {
}
try (signalAccount) {
if (signalAccount.isMasterDevice()) {
logger.debug("Account is a master device.");
if (signalAccount.isPrimaryDevice()) {
logger.debug("Account is a primary device.");
return false;
}
if (signalAccount.isRegistered()

View file

@ -17,7 +17,7 @@ public class RetrieveStorageDataAction implements HandleAction {
public void execute(Context context) throws Throwable {
if (context.getAccount().getStorageKey() != null) {
context.getStorageHelper().readDataFromStorage();
} else if (!context.getAccount().isMasterDevice()) {
} else if (!context.getAccount().isPrimaryDevice()) {
context.getSyncHelper().requestSyncKeys();
}
}

View file

@ -1,8 +1,8 @@
package org.asamk.signal.manager.api;
public class NotMasterDeviceException extends Exception {
public class NotPrimaryDeviceException extends Exception {
public NotMasterDeviceException() {
public NotPrimaryDeviceException() {
super("This function is not supported for linked devices.");
}
}

View file

@ -60,7 +60,7 @@ public class AccountHelper {
if (account.getAci() == null || account.getPni() == null) {
checkWhoAmiI();
}
if (!account.isMasterDevice() && account.getPniIdentityKeyPair() == null) {
if (!account.isPrimaryDevice() && account.getPniIdentityKeyPair() == null) {
context.getSyncHelper().requestSyncPniIdentity();
}
updateAccountAttributes();
@ -175,7 +175,7 @@ public class AccountHelper {
public void unregister() throws IOException {
// When setting an empty GCM id, the Signal-Server also sets the fetchesMessages property to false.
// If this is the master device, other users can't send messages to this number anymore.
// If this is the primary device, other users can't send messages to this number anymore.
// If this is a linked device, other users can still send messages, but this device doesn't receive them anymore.
dependencies.getAccountManager().setGcmId(Optional.empty());

View file

@ -336,7 +336,7 @@ public final class IncomingMessageHandler {
ignoreAttachments));
}
}
if (syncMessage.getRequest().isPresent() && account.isMasterDevice()) {
if (syncMessage.getRequest().isPresent() && account.isPrimaryDevice()) {
var rm = syncMessage.getRequest().get();
if (rm.isContactsRequest()) {
actions.add(SendSyncContactsAction.create());

View file

@ -388,7 +388,7 @@ public class SignalAccount implements Closeable {
}
save();
}
if (isMasterDevice() && getPniIdentityKeyPair() == null) {
if (isPrimaryDevice() && getPniIdentityKeyPair() == null) {
setPniIdentityKeyPair(KeyUtils.generateIdentityKeyPair());
}
}
@ -1203,7 +1203,7 @@ public class SignalAccount implements Closeable {
return deviceId;
}
public boolean isMasterDevice() {
public boolean isPrimaryDevice() {
return deviceId == SignalServiceAddress.DEFAULT_DEVICE_ID;
}

View file

@ -85,7 +85,7 @@ public class SessionStore implements SignalServiceSessionStore {
synchronized (cachedSessions) {
return getKeysLocked(recipientId).stream()
// get all sessions for recipient except main device session
// get all sessions for recipient except primary device session
.filter(key -> key.deviceId() != 1 && key.recipientId().equals(recipientId))
.map(Key::deviceId)
.toList();