Przeglądaj źródła

Add Channel unset event.

Fixes #120
pull/285/head
Greg Holmes 9 lat temu
rodzic
commit
bb3c224bd0

+ 16
- 6
src/com/dmdirc/ChannelEventHandler.java Wyświetl plik

@@ -24,6 +24,7 @@ package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.events.ChannelActionEvent;
26 26
 import com.dmdirc.events.ChannelCtcpEvent;
27
+import com.dmdirc.events.ChannelDisplayableEvent;
27 28
 import com.dmdirc.events.ChannelGotnamesEvent;
28 29
 import com.dmdirc.events.ChannelGottopicEvent;
29 30
 import com.dmdirc.events.ChannelJoinEvent;
@@ -39,6 +40,7 @@ import com.dmdirc.events.ChannelNotopicEvent;
39 40
 import com.dmdirc.events.ChannelPartEvent;
40 41
 import com.dmdirc.events.ChannelQuitEvent;
41 42
 import com.dmdirc.events.ChannelTopicChangeEvent;
43
+import com.dmdirc.events.ChannelTopicUnsetEvent;
42 44
 import com.dmdirc.events.ChannelUserAwayEvent;
43 45
 import com.dmdirc.events.ChannelUserBackEvent;
44 46
 import com.dmdirc.events.ChannelUserEvent;
@@ -170,12 +172,20 @@ public class ChannelEventHandler extends EventHandler implements
170 172
                 owner.doNotification(date, format, newTopic);
171 173
             }
172 174
         } else {
173
-            final ChannelTopicChangeEvent event = new ChannelTopicChangeEvent(owner,
174
-                    channel.getChannelClient(channel.getTopicSetter(), true),
175
-                    channel.getTopic());
176
-            final String format = EventUtils.postDisplayable(eventBus, event,
177
-                    Strings.isNullOrEmpty(channel.getTopic())
178
-                    ? "channelTopicRemoved" : "channelTopicChanged");
175
+            final ChannelDisplayableEvent event;
176
+            final String format;
177
+            if (Strings.isNullOrEmpty(channel.getTopic())) {
178
+                event = new ChannelTopicChangeEvent(owner,
179
+                        channel.getChannelClient(channel.getTopicSetter(), true),
180
+                        channel.getTopic());
181
+                format = EventUtils.postDisplayable(eventBus, event,
182
+                        "channelTopicRemoved");
183
+            } else {
184
+                event = new ChannelTopicUnsetEvent(owner,
185
+                        channel.getChannelClient(channel.getTopicSetter(), true));
186
+                format = EventUtils.postDisplayable(eventBus, event,
187
+                        "channelTopicChanged");
188
+            }
179 189
             eventBus.publish(event);
180 190
             owner.doNotification(date, format, channel.getChannelClient(channel.getTopicSetter(),
181 191
                     true), channel.getTopic());

+ 50
- 0
src/com/dmdirc/events/ChannelTopicUnsetEvent.java Wyświetl plik

@@ -0,0 +1,50 @@
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 topic is cleared.
30
+ */
31
+public class ChannelTopicUnsetEvent extends ChannelDisplayableEvent {
32
+
33
+    private final ChannelClientInfo client;
34
+
35
+    public ChannelTopicUnsetEvent(final long timestamp, final Channel channel,
36
+            final ChannelClientInfo client) {
37
+        super(timestamp, channel);
38
+        this.client = client;
39
+    }
40
+
41
+    public ChannelTopicUnsetEvent(final Channel channel, final ChannelClientInfo client) {
42
+        super(channel);
43
+        this.client = client;
44
+    }
45
+
46
+    public ChannelClientInfo getClient() {
47
+        return client;
48
+    }
49
+
50
+}

Ładowanie…
Anuluj
Zapisz