|
@@ -22,22 +22,60 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.addons.channelwho;
|
24
|
24
|
|
|
25
|
+import com.dmdirc.DMDircMBassador;
|
|
26
|
+import com.dmdirc.events.ServerConnectingEvent;
|
|
27
|
+import com.dmdirc.events.ServerDisconnectedEvent;
|
|
28
|
+import com.dmdirc.interfaces.Connection;
|
|
29
|
+import com.dmdirc.interfaces.ConnectionManager;
|
25
|
30
|
import com.dmdirc.plugins.PluginDomain;
|
26
|
31
|
|
27
|
32
|
import javax.inject.Inject;
|
28
|
33
|
|
|
34
|
+import net.engio.mbassy.listener.Handler;
|
|
35
|
+
|
29
|
36
|
/**
|
30
|
37
|
* Provides channel who support in DMDirc.
|
31
|
38
|
*/
|
32
|
39
|
public class ChannelWhoManager {
|
33
|
40
|
|
|
41
|
+ private final ConnectionManager connectionManager;
|
|
42
|
+ private final DMDircMBassador eventBus;
|
|
43
|
+
|
34
|
44
|
@Inject
|
35
|
|
- public ChannelWhoManager(@PluginDomain(ChannelWhoPlugin.class) final String domain) {
|
|
45
|
+ public ChannelWhoManager(
|
|
46
|
+ @PluginDomain(ChannelWhoPlugin.class) final String domain,
|
|
47
|
+ final ConnectionManager connectionManager,
|
|
48
|
+ final DMDircMBassador eventBus) {
|
|
49
|
+ this.connectionManager = connectionManager;
|
|
50
|
+ this.eventBus = eventBus;
|
36
|
51
|
}
|
37
|
52
|
|
38
|
53
|
public void load() {
|
|
54
|
+ eventBus.subscribe(this);
|
|
55
|
+ connectionManager.getConnections().forEach(this::addConnectionHandler);
|
39
|
56
|
}
|
40
|
57
|
|
41
|
58
|
public void unload() {
|
|
59
|
+ connectionManager.getConnections().forEach(this::removeConnectionHandler);
|
|
60
|
+ eventBus.unsubscribe(this);
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ private void addConnectionHandler(final Connection connection) {
|
|
64
|
+ // TODO: Create a handler class which will monitor settings + handle timers.
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ private void removeConnectionHandler(final Connection connection) {
|
|
68
|
+ // TODO: Remove handlers
|
42
|
69
|
}
|
|
70
|
+
|
|
71
|
+ @Handler
|
|
72
|
+ private void handleServerConnectingEvent(final ServerConnectingEvent event) {
|
|
73
|
+ addConnectionHandler(event.getConnection());
|
|
74
|
+ }
|
|
75
|
+
|
|
76
|
+ @Handler
|
|
77
|
+ private void handleServerDisconnectedEvent(final ServerDisconnectedEvent event) {
|
|
78
|
+ removeConnectionHandler(event.getConnection());
|
|
79
|
+ }
|
|
80
|
+
|
43
|
81
|
}
|