]> nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/manager/HandleAction.java
Update dependencies
[signal-cli] / src / main / java / org / asamk / signal / manager / HandleAction.java
1 package org.asamk.signal.manager;
2
3 import org.whispersystems.signalservice.api.push.SignalServiceAddress;
4
5 import java.util.Arrays;
6 import java.util.Objects;
7
8 interface HandleAction {
9
10 void execute(Manager m) throws Throwable;
11 }
12
13 class SendReceiptAction implements HandleAction {
14
15 private final SignalServiceAddress address;
16 private final long timestamp;
17
18 public SendReceiptAction(final SignalServiceAddress address, final long timestamp) {
19 this.address = address;
20 this.timestamp = timestamp;
21 }
22
23 @Override
24 public void execute(Manager m) throws Throwable {
25 m.sendReceipt(address, timestamp);
26 }
27
28 @Override
29 public boolean equals(final Object o) {
30 if (this == o) return true;
31 if (o == null || getClass() != o.getClass()) return false;
32 final SendReceiptAction that = (SendReceiptAction) o;
33 return timestamp == that.timestamp &&
34 address.equals(that.address);
35 }
36
37 @Override
38 public int hashCode() {
39 return Objects.hash(address, timestamp);
40 }
41 }
42
43 class SendSyncContactsAction implements HandleAction {
44
45 private static final SendSyncContactsAction INSTANCE = new SendSyncContactsAction();
46
47 private SendSyncContactsAction() {
48 }
49
50 public static SendSyncContactsAction create() {
51 return INSTANCE;
52 }
53
54 @Override
55 public void execute(Manager m) throws Throwable {
56 m.sendContacts();
57 }
58 }
59
60 class SendSyncGroupsAction implements HandleAction {
61
62 private static final SendSyncGroupsAction INSTANCE = new SendSyncGroupsAction();
63
64 private SendSyncGroupsAction() {
65 }
66
67 public static SendSyncGroupsAction create() {
68 return INSTANCE;
69 }
70
71 @Override
72 public void execute(Manager m) throws Throwable {
73 m.sendGroups();
74 }
75 }
76
77 class SendSyncBlockedListAction implements HandleAction {
78
79 private static final SendSyncBlockedListAction INSTANCE = new SendSyncBlockedListAction();
80
81 private SendSyncBlockedListAction() {
82 }
83
84 public static SendSyncBlockedListAction create() {
85 return INSTANCE;
86 }
87
88 @Override
89 public void execute(Manager m) throws Throwable {
90 m.sendBlockedList();
91 }
92 }
93
94 class SendGroupInfoRequestAction implements HandleAction {
95
96 private final SignalServiceAddress address;
97 private final byte[] groupId;
98
99 public SendGroupInfoRequestAction(final SignalServiceAddress address, final byte[] groupId) {
100 this.address = address;
101 this.groupId = groupId;
102 }
103
104 @Override
105 public void execute(Manager m) throws Throwable {
106 m.sendGroupInfoRequest(groupId, address);
107 }
108
109 @Override
110 public boolean equals(final Object o) {
111 if (this == o) return true;
112 if (o == null || getClass() != o.getClass()) return false;
113 final SendGroupInfoRequestAction that = (SendGroupInfoRequestAction) o;
114 return address.equals(that.address) &&
115 Arrays.equals(groupId, that.groupId);
116 }
117
118 @Override
119 public int hashCode() {
120 int result = Objects.hash(address);
121 result = 31 * result + Arrays.hashCode(groupId);
122 return result;
123 }
124 }
125
126 class SendGroupUpdateAction implements HandleAction {
127
128 private final SignalServiceAddress address;
129 private final byte[] groupId;
130
131 public SendGroupUpdateAction(final SignalServiceAddress address, final byte[] groupId) {
132 this.address = address;
133 this.groupId = groupId;
134 }
135
136 @Override
137 public void execute(Manager m) throws Throwable {
138 m.sendUpdateGroupMessage(groupId, address);
139 }
140
141 @Override
142 public boolean equals(final Object o) {
143 if (this == o) return true;
144 if (o == null || getClass() != o.getClass()) return false;
145 final SendGroupUpdateAction that = (SendGroupUpdateAction) o;
146 return address.equals(that.address) &&
147 Arrays.equals(groupId, that.groupId);
148 }
149
150 @Override
151 public int hashCode() {
152 int result = Objects.hash(address);
153 result = 31 * result + Arrays.hashCode(groupId);
154 return result;
155 }
156 }