Kaynağa Gözat

Add NickList events.

pull/275/head
Greg Holmes 9 yıl önce
ebeveyn
işleme
a9b5f86a96

+ 10
- 0
src/com/dmdirc/Channel.java Dosyayı Görüntüle

@@ -28,6 +28,10 @@ import com.dmdirc.config.ConfigBinding;
28 28
 import com.dmdirc.events.ChannelClosedEvent;
29 29
 import com.dmdirc.events.ChannelSelfActionEvent;
30 30
 import com.dmdirc.events.ChannelSelfMessageEvent;
31
+import com.dmdirc.events.NickListClientAddedEvent;
32
+import com.dmdirc.events.NickListClientRemovedEvent;
33
+import com.dmdirc.events.NickListClientsChangedEvent;
34
+import com.dmdirc.events.NickListUpdatedEvent;
31 35
 import com.dmdirc.interfaces.CommandController;
32 36
 import com.dmdirc.interfaces.Connection;
33 37
 import com.dmdirc.interfaces.GroupChat;
@@ -285,6 +289,8 @@ public class Channel extends MessageTarget implements GroupChat {
285 289
 
286 290
         listenerList.getCallable(NicklistListener.class)
287 291
                 .clientListUpdated(Collections.<ChannelClientInfo>emptyList());
292
+        getEventBus().publishAsync(new NickListClientsChangedEvent(this,
293
+                Collections.<ChannelClientInfo>emptyList()));
288 294
     }
289 295
 
290 296
     @Override
@@ -326,6 +332,7 @@ public class Channel extends MessageTarget implements GroupChat {
326 332
      */
327 333
     public void addClient(final ChannelClientInfo client) {
328 334
         listenerList.getCallable(NicklistListener.class).clientAdded(client);
335
+        getEventBus().publishAsync(new NickListClientAddedEvent(this, client));
329 336
 
330 337
         getTabCompleter().addEntry(TabCompletionType.CHANNEL_NICK,
331 338
                 client.getClient().getNickname());
@@ -338,6 +345,7 @@ public class Channel extends MessageTarget implements GroupChat {
338 345
      */
339 346
     public void removeClient(final ChannelClientInfo client) {
340 347
         listenerList.getCallable(NicklistListener.class).clientRemoved(client);
348
+        getEventBus().publishAsync(new NickListClientRemovedEvent(this, client));
341 349
 
342 350
         getTabCompleter().removeEntry(TabCompletionType.CHANNEL_NICK,
343 351
                 client.getClient().getNickname());
@@ -354,6 +362,7 @@ public class Channel extends MessageTarget implements GroupChat {
354 362
      */
355 363
     public void setClients(final Collection<ChannelClientInfo> clients) {
356 364
         listenerList.getCallable(NicklistListener.class).clientListUpdated(clients);
365
+        getEventBus().publishAsync(new NickListClientsChangedEvent(this, clients));
357 366
 
358 367
         getTabCompleter().clear(TabCompletionType.CHANNEL_NICK);
359 368
 
@@ -383,6 +392,7 @@ public class Channel extends MessageTarget implements GroupChat {
383 392
         }
384 393
 
385 394
         listenerList.getCallable(NicklistListener.class).clientListUpdated();
395
+        getEventBus().publishAsync(new NickListUpdatedEvent(this));
386 396
     }
387 397
 
388 398
     /**

+ 49
- 0
src/com/dmdirc/events/NickListClientAddedEvent.java Dosyayı Görüntüle

@@ -0,0 +1,49 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.Channel;
26
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
27
+
28
+/**
29
+ * Fired when a user is added to the list of users.
30
+ */
31
+public class NickListClientAddedEvent extends NickListEvent {
32
+
33
+    private final ChannelClientInfo user;
34
+
35
+    public NickListClientAddedEvent(final long timestamp, final Channel channel,
36
+            final ChannelClientInfo user) {
37
+        super(timestamp, channel);
38
+        this.user = user;
39
+    }
40
+
41
+    public NickListClientAddedEvent(final Channel channel, final ChannelClientInfo user) {
42
+        super(channel);
43
+        this.user = user;
44
+    }
45
+
46
+    public ChannelClientInfo getUser() {
47
+        return user;
48
+    }
49
+}

+ 49
- 0
src/com/dmdirc/events/NickListClientRemovedEvent.java Dosyayı Görüntüle

@@ -0,0 +1,49 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.Channel;
26
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
27
+
28
+/**
29
+ * Fired when a user is removed from the list of users.
30
+ */
31
+public class NickListClientRemovedEvent extends NickListEvent {
32
+
33
+    private final ChannelClientInfo user;
34
+
35
+    public NickListClientRemovedEvent(final long timestamp, final Channel channel,
36
+            final ChannelClientInfo user) {
37
+        super(timestamp, channel);
38
+        this.user = user;
39
+    }
40
+
41
+    public NickListClientRemovedEvent(final Channel channel, final ChannelClientInfo user) {
42
+        super(channel);
43
+        this.user = user;
44
+    }
45
+
46
+    public ChannelClientInfo getUser() {
47
+        return user;
48
+    }
49
+}

+ 55
- 0
src/com/dmdirc/events/NickListClientsChangedEvent.java Dosyayı Görüntüle

@@ -0,0 +1,55 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.Channel;
26
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
27
+
28
+import java.util.Collection;
29
+import java.util.Collections;
30
+
31
+import autovalue.shaded.com.google.common.common.collect.Lists;
32
+
33
+/**
34
+ * Fired when there is a major change to the list of users.
35
+ */
36
+public class NickListClientsChangedEvent extends NickListEvent {
37
+
38
+    private final Collection<ChannelClientInfo> users;
39
+
40
+    public NickListClientsChangedEvent(final long timestamp, final Channel channel,
41
+            final Iterable<ChannelClientInfo> users) {
42
+        super(timestamp, channel);
43
+        this.users = Lists.newArrayList(users);
44
+    }
45
+
46
+    public NickListClientsChangedEvent(final Channel channel,
47
+            final Iterable<ChannelClientInfo> users) {
48
+        super(channel);
49
+        this.users = Lists.newArrayList(users);
50
+    }
51
+
52
+    public Collection<ChannelClientInfo> getUsers() {
53
+        return Collections.unmodifiableCollection(users);
54
+    }
55
+}

+ 18
- 0
src/com/dmdirc/events/NickListEvent.java Dosyayı Görüntüle

@@ -0,0 +1,18 @@
1
+package com.dmdirc.events;
2
+
3
+import com.dmdirc.Channel;
4
+import com.dmdirc.interfaces.GroupChat;
5
+
6
+/**
7
+ * Base class for all nicklist events in a {@link GroupChat}.
8
+ */
9
+public abstract class NickListEvent extends ChannelEvent {
10
+
11
+    public NickListEvent(final long timestamp, final Channel channel) {
12
+        super(timestamp, channel);
13
+    }
14
+
15
+    public NickListEvent(final Channel channel) {
16
+        super(channel);
17
+    }
18
+}

+ 39
- 0
src/com/dmdirc/events/NickListUpdatedEvent.java Dosyayı Görüntüle

@@ -0,0 +1,39 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.Channel;
26
+
27
+/**
28
+ * Fired when the properties of the users in a list changes.
29
+ */
30
+public class NickListUpdatedEvent extends NickListEvent {
31
+
32
+    public NickListUpdatedEvent(final long timestamp, final Channel channel) {
33
+        super(timestamp, channel);
34
+    }
35
+
36
+    public NickListUpdatedEvent(final Channel channel) {
37
+        super(channel);
38
+    }
39
+}

Loading…
İptal
Kaydet