Dbus get/setConfiguration methods

implement:

- getConfiguration() -> [readReceipts<b>, unidentifiedDeliveryIndicators<b>, typingIndicators<b>, linkPreviews<b>] -> <>::

- setConfiguration(readReceipts<b>, unidentifiedDeliveryIndicators<b>, typingIndicators<b>, linkPreviews<b>) -> <>::

Update documentation
This commit is contained in:
John Freed committed 2021-10-04 08:48:56 +02:00
1 parent 26594dd0ee
commit 8416d4ac47
6 files changed
+92 -4

No files matched your search

@@ -105,6 +105,8 @@ public interface Manager extends Closeable {
final Boolean linkPreviews
) throws IOException, NotMasterDeviceException;
List<Boolean> getConfiguration() throws IOException, NotMasterDeviceException;
void setProfile(
String givenName, String familyName, String about, String aboutEmoji, Optional<File> avatar
) throws IOException;
@@ -347,6 +347,19 @@ public class ManagerImpl implements Manager {
syncHelper.sendConfigurationMessage();
}
@Override
public List<Boolean> getConfiguration() throws IOException, NotMasterDeviceException {
if (!account.isMasterDevice()) {
throw new NotMasterDeviceException();
}
final var configurationStore = account.getConfigurationStore();
final Boolean readReceipts = configurationStore.getReadReceipts();
final Boolean unidentifiedDeliveryIndicators = configurationStore.getUnidentifiedDeliveryIndicators();
final Boolean typingIndicators = configurationStore.getTypingIndicators();
final Boolean linkPreviews = configurationStore.getLinkPreviews();
return List.of(readReceipts, unidentifiedDeliveryIndicators, typingIndicators, linkPreviews);
}
/**
* @param givenName if null, the previous givenName will be kept
* @param familyName if null, the previous familyName will be kept
+22 -2
View File
@@ -263,7 +263,7 @@ Exceptions: Failure, InvalidNumber
getContactName(number<s>) -> name<s>::
* number : Phone number
* name : Contact's name in local storage (from the master device for a linked account, or the one set with setContactName); if not set, contact's profile name is used
* name : Contact's name in local storage (from the primary device for a linked account, or the one set with setContactName); if not set, contact's profile name is used
setContactName(number<s>,name<>) -> <>::
* number : Phone number
@@ -361,7 +361,27 @@ uploadStickerPack(stickerPackPath<s>) -> url<s>::
* stickerPackPath : Path to the manifest.json file or a zip file in the same directory
* url : URL of sticker pack after successful upload
Exception: Failure
Exception: Failure, IOError
getConfiguration() -> [readReceipts<b>, unidentifiedDeliveryIndicators<b>, typingIndicators<b>, linkPreviews<b>] -> <>::
* readReceipts : Should Signal send read receipts (true/false).
* unidentifiedDeliveryIndicators : Should Signal show unidentified delivery indicators (true/false).
* typingIndicators : Should Signal send/show typing indicators (true/false).
* linkPreviews : Should Signal generate link previews (true/false).
Gets an array of four booleans as indicated. Only works from primary device.
Exceptions: IOError, UserError
setConfiguration(readReceipts<b>, unidentifiedDeliveryIndicators<b>, typingIndicators<b>, linkPreviews<b>) -> <>::
* readReceipts : Should Signal send read receipts (true/false).
* unidentifiedDeliveryIndicators : Should Signal show unidentified delivery indicators (true/false).
* typingIndicators : Should Signal send/show typing indicators (true/false).
* linkPreviews : Should Signal generate link previews (true/false).
Update Signal configurations and sync them to linked devices. Only works from primary device.
Exceptions: IOError, UserError
== Signals
+18
View File
@@ -141,6 +141,10 @@ public interface Signal extends DBusInterface {
String uploadStickerPack(String stickerPackPath) throws Error.Failure;
void setConfiguration(boolean readReceipts, boolean unidentifiedDeliveryIndicators, boolean typingIndicators, boolean linkPreviews) throws Error.IOError, Error.UserError;
List<Boolean> getConfiguration();
class MessageReceived extends DBusSignal {
private final long timestamp;
@@ -317,5 +321,19 @@ public interface Signal extends DBusInterface {
super(message);
}
}
class IOError extends DBusExecutionException {
public IOError(final String message) {
super(message);
}
}
class UserError extends DBusExecutionException {
public UserError(final String message) {
super(message);
}
}
}
}
@@ -108,7 +108,17 @@ public class DbusManagerImpl implements Manager {
final Boolean typingIndicators,
final Boolean linkPreviews
) throws IOException {
throw new UnsupportedOperationException();
signal.setConfiguration(
readReceipts,
unidentifiedDeliveryIndicators,
typingIndicators,
linkPreviews
);
}
@Override
public List<Boolean> getConfiguration() {
return signal.getConfiguration();
}
@Override
@@ -1,6 +1,7 @@
package org.asamk.signal.dbus;
import org.asamk.Signal;
import org.asamk.Signal.Error;
import org.asamk.signal.BaseConfig;
import org.asamk.signal.manager.AttachmentInvalidException;
import org.asamk.signal.manager.Manager;
@@ -683,12 +684,36 @@ public class DbusSignalImpl implements Signal {
try {
return m.uploadStickerPack(path).toString();
} catch (IOException e) {
throw new Error.Failure("Upload error (maybe image size is too large):" + e.getMessage());
throw new Error.IOError("Upload error (maybe image size is too large):" + e.getMessage());
} catch (StickerPackInvalidException e) {
throw new Error.Failure("Invalid sticker pack: " + e.getMessage());
}
}
@Override
public void setConfiguration(boolean readReceipts, boolean unidentifiedDeliveryIndicators, boolean typingIndicators, boolean linkPreviews) {
try {
m.updateConfiguration(readReceipts, unidentifiedDeliveryIndicators, typingIndicators, linkPreviews);
} catch (IOException e) {
throw new Error.IOError("UpdateAccount error: " + e.getMessage());
} catch (NotMasterDeviceException e) {
throw new Error.UserError("This command doesn't work on linked devices.");
}
}
@Override
public List<Boolean> getConfiguration() {
List<Boolean> config = new ArrayList<>(4);
try {
config = m.getConfiguration();
} catch (IOException e) {
throw new Error.IOError("Configuration storage error: " + e.getMessage());
} catch (NotMasterDeviceException e) {
throw new Error.UserError("This command doesn't work on linked devices.");
}
return config;
}
private static void checkSendMessageResult(long timestamp, SendMessageResult result) throws DBusExecutionException {
var error = ErrorUtils.getErrorMessageFromSendMessageResult(result);