1 package org
.asamk
.signal
.manager
.storage
.configuration
;
3 import org
.asamk
.signal
.manager
.api
.PhoneNumberSharingMode
;
4 import org
.asamk
.signal
.manager
.storage
.keyValue
.KeyValueEntry
;
5 import org
.asamk
.signal
.manager
.storage
.keyValue
.KeyValueStore
;
6 import org
.asamk
.signal
.manager
.storage
.recipients
.RecipientStore
;
8 import java
.sql
.Connection
;
9 import java
.sql
.SQLException
;
11 public class ConfigurationStore
{
13 private final KeyValueStore keyValueStore
;
14 private final RecipientStore recipientStore
;
16 private final KeyValueEntry
<Boolean
> readReceipts
= new KeyValueEntry
<>("config-read-receipts", Boolean
.class);
17 private final KeyValueEntry
<Boolean
> unidentifiedDeliveryIndicators
= new KeyValueEntry
<>(
18 "config-unidentified-delivery-indicators",
20 private final KeyValueEntry
<Boolean
> typingIndicators
= new KeyValueEntry
<>("config-typing-indicators",
22 private final KeyValueEntry
<Boolean
> linkPreviews
= new KeyValueEntry
<>("config-link-previews", Boolean
.class);
23 private final KeyValueEntry
<Boolean
> phoneNumberUnlisted
= new KeyValueEntry
<>("config-phone-number-unlisted",
25 private final KeyValueEntry
<PhoneNumberSharingMode
> phoneNumberSharingMode
= new KeyValueEntry
<>(
26 "config-phone-number-sharing-mode",
27 PhoneNumberSharingMode
.class);
28 private final KeyValueEntry
<String
> usernameLinkColor
= new KeyValueEntry
<>("username-link-color", String
.class);
30 public ConfigurationStore(final KeyValueStore keyValueStore
, RecipientStore recipientStore
) {
31 this.keyValueStore
= keyValueStore
;
32 this.recipientStore
= recipientStore
;
35 public Boolean
getReadReceipts() {
36 return keyValueStore
.getEntry(readReceipts
);
39 public void setReadReceipts(final boolean value
) {
40 if (keyValueStore
.storeEntry(readReceipts
, value
)) {
41 recipientStore
.rotateSelfStorageId();
45 public void setReadReceipts(final Connection connection
, final boolean value
) throws SQLException
{
46 if (keyValueStore
.storeEntry(connection
, readReceipts
, value
)) {
47 recipientStore
.rotateSelfStorageId(connection
);
51 public Boolean
getUnidentifiedDeliveryIndicators() {
52 return keyValueStore
.getEntry(unidentifiedDeliveryIndicators
);
55 public void setUnidentifiedDeliveryIndicators(final boolean value
) {
56 if (keyValueStore
.storeEntry(unidentifiedDeliveryIndicators
, value
)) {
57 recipientStore
.rotateSelfStorageId();
61 public void setUnidentifiedDeliveryIndicators(
62 final Connection connection
, final boolean value
63 ) throws SQLException
{
64 if (keyValueStore
.storeEntry(connection
, unidentifiedDeliveryIndicators
, value
)) {
65 recipientStore
.rotateSelfStorageId(connection
);
69 public Boolean
getTypingIndicators() {
70 return keyValueStore
.getEntry(typingIndicators
);
73 public void setTypingIndicators(final boolean value
) {
74 if (keyValueStore
.storeEntry(typingIndicators
, value
)) {
75 recipientStore
.rotateSelfStorageId();
79 public void setTypingIndicators(final Connection connection
, final boolean value
) throws SQLException
{
80 if (keyValueStore
.storeEntry(connection
, typingIndicators
, value
)) {
81 recipientStore
.rotateSelfStorageId(connection
);
85 public Boolean
getLinkPreviews() {
86 return keyValueStore
.getEntry(linkPreviews
);
89 public void setLinkPreviews(final boolean value
) {
90 if (keyValueStore
.storeEntry(linkPreviews
, value
)) {
91 recipientStore
.rotateSelfStorageId();
95 public void setLinkPreviews(final Connection connection
, final boolean value
) throws SQLException
{
96 if (keyValueStore
.storeEntry(connection
, linkPreviews
, value
)) {
97 recipientStore
.rotateSelfStorageId(connection
);
101 public Boolean
getPhoneNumberUnlisted() {
102 return keyValueStore
.getEntry(phoneNumberUnlisted
);
105 public void setPhoneNumberUnlisted(final boolean value
) {
106 if (keyValueStore
.storeEntry(phoneNumberUnlisted
, value
)) {
107 recipientStore
.rotateSelfStorageId();
111 public void setPhoneNumberUnlisted(final Connection connection
, final boolean value
) throws SQLException
{
112 if (keyValueStore
.storeEntry(connection
, phoneNumberUnlisted
, value
)) {
113 recipientStore
.rotateSelfStorageId(connection
);
117 public PhoneNumberSharingMode
getPhoneNumberSharingMode() {
118 return keyValueStore
.getEntry(phoneNumberSharingMode
);
121 public void setPhoneNumberSharingMode(final PhoneNumberSharingMode value
) {
122 if (keyValueStore
.storeEntry(phoneNumberSharingMode
, value
)) {
123 recipientStore
.rotateSelfStorageId();
127 public void setPhoneNumberSharingMode(
128 final Connection connection
, final PhoneNumberSharingMode value
129 ) throws SQLException
{
130 if (keyValueStore
.storeEntry(connection
, phoneNumberSharingMode
, value
)) {
131 recipientStore
.rotateSelfStorageId(connection
);
135 public String
getUsernameLinkColor() {
136 return keyValueStore
.getEntry(usernameLinkColor
);
139 public void setUsernameLinkColor(final String color
) {
140 if (keyValueStore
.storeEntry(usernameLinkColor
, color
)) {
141 recipientStore
.rotateSelfStorageId();
145 public void setUsernameLinkColor(final Connection connection
, final String color
) throws SQLException
{
146 if (keyValueStore
.storeEntry(connection
, usernameLinkColor
, color
)) {
147 recipientStore
.rotateSelfStorageId(connection
);