|
@@ -27,18 +27,17 @@ import com.dmdirc.Query;
|
27
|
27
|
import com.dmdirc.events.ChannelUserAwayEvent;
|
28
|
28
|
import com.dmdirc.events.ChannelUserBackEvent;
|
29
|
29
|
import com.dmdirc.events.FrameClosingEvent;
|
|
30
|
+import com.dmdirc.events.NickListClientAddedEvent;
|
|
31
|
+import com.dmdirc.events.NickListClientsChangedEvent;
|
30
|
32
|
import com.dmdirc.interfaces.GroupChat;
|
31
|
|
-import com.dmdirc.interfaces.NicklistListener;
|
32
|
33
|
import com.dmdirc.parser.interfaces.ChannelClientInfo;
|
33
|
34
|
|
34
|
|
-import java.util.Collection;
|
35
|
|
-
|
36
|
35
|
import net.engio.mbassy.listener.Handler;
|
37
|
36
|
|
38
|
37
|
/**
|
39
|
38
|
* Listens for contact list related events.
|
40
|
39
|
*/
|
41
|
|
-public class ContactListListener implements NicklistListener {
|
|
40
|
+public class ContactListListener {
|
42
|
41
|
|
43
|
42
|
/** The group chat this listener is for. */
|
44
|
43
|
private final GroupChat groupChat;
|
|
@@ -59,7 +58,6 @@ public class ContactListListener implements NicklistListener {
|
59
|
58
|
* Adds all necessary listeners for this contact list listener to function.
|
60
|
59
|
*/
|
61
|
60
|
public void addListeners() {
|
62
|
|
- groupChat.addNicklistListener(this);
|
63
|
61
|
eventBus.subscribe(this);
|
64
|
62
|
}
|
65
|
63
|
|
|
@@ -67,31 +65,17 @@ public class ContactListListener implements NicklistListener {
|
67
|
65
|
* Removes the listeners added by {@link #addListeners()}.
|
68
|
66
|
*/
|
69
|
67
|
public void removeListeners() {
|
70
|
|
- groupChat.removeNicklistListener(this);
|
71
|
68
|
eventBus.unsubscribe(this);
|
72
|
69
|
}
|
73
|
70
|
|
74
|
|
- @Override
|
75
|
|
- public void clientListUpdated(final Collection<ChannelClientInfo> clients) {
|
76
|
|
- clients.forEach(this::clientAdded);
|
77
|
|
- }
|
78
|
|
-
|
79
|
|
- @Override
|
80
|
|
- public void clientListUpdated() {
|
81
|
|
- // Do nothing
|
82
|
|
- }
|
83
|
|
-
|
84
|
|
- @Override
|
85
|
|
- public void clientAdded(final ChannelClientInfo client) {
|
86
|
|
- final Query query = groupChat.getConnection().get()
|
87
|
|
- .getQuery(client.getClient().getNickname(), false);
|
88
|
|
-
|
89
|
|
- query.setIcon("query-" + client.getClient().getAwayState().name().toLowerCase());
|
|
71
|
+ @Handler
|
|
72
|
+ public void handleClientsUpdated(final NickListClientsChangedEvent event) {
|
|
73
|
+ event.getUsers().forEach(this::clientAdded);
|
90
|
74
|
}
|
91
|
75
|
|
92
|
|
- @Override
|
93
|
|
- public void clientRemoved(final ChannelClientInfo client) {
|
94
|
|
- // Do nothing
|
|
76
|
+ @Handler
|
|
77
|
+ public void handleClientAdded(final NickListClientAddedEvent event) {
|
|
78
|
+ clientAdded(event.getUser());
|
95
|
79
|
}
|
96
|
80
|
|
97
|
81
|
@Handler
|
|
@@ -109,4 +93,11 @@ public class ContactListListener implements NicklistListener {
|
109
|
93
|
removeListeners();
|
110
|
94
|
}
|
111
|
95
|
|
|
96
|
+ private void clientAdded(final ChannelClientInfo client) {
|
|
97
|
+ final Query query = groupChat.getConnection().get()
|
|
98
|
+ .getQuery(client.getClient().getNickname(), false);
|
|
99
|
+
|
|
100
|
+ query.setIcon("query-" + client.getClient().getAwayState().name().toLowerCase());
|
|
101
|
+ }
|
|
102
|
+
|
112
|
103
|
}
|