Sfoglia il codice sorgente

Start migrating to channel events.

Change-Id: Ie503350804b28e1c682d53017e849b0eba8c00c0
Reviewed-on: http://gerrit.dmdirc.com/3473
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
pull/1/head
Greg Holmes 10 anni fa
parent
commit
71618c12bc

+ 10
- 3
src/com/dmdirc/ChannelEventHandler.java Vedi File

@@ -24,6 +24,8 @@ package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.CoreActionType;
27
+import com.dmdirc.events.ChannelNickchangeEvent;
28
+import com.dmdirc.events.ChannelTopicChangeEvent;
27 29
 import com.dmdirc.events.ChannelUserAwayEvent;
28 30
 import com.dmdirc.events.ChannelUserBackEvent;
29 31
 import com.dmdirc.events.DisplayableEvent;
@@ -153,8 +155,11 @@ public class ChannelEventHandler extends EventHandler implements
153 155
             final StringBuffer messageType = new StringBuffer(
154 156
                     Strings.isNullOrEmpty(channel.getTopic())
155 157
                     ? "channelTopicRemoved" : "channelTopicChanged");
156
-            triggerAction(messageType, CoreActionType.CHANNEL_TOPICCHANGE,
157
-                    channel.getChannelClient(channel.getTopicSetter(), true), channel.getTopic());
158
+            final DisplayableEvent event = new ChannelTopicChangeEvent(owner,
159
+                    channel.getChannelClient(channel.getTopicSetter(), true),
160
+                    channel.getTopic());
161
+            event.setDisplayFormat(messageType.toString());
162
+            eventBus.post(event);
158 163
             owner.doNotification(date, messageType.toString(),
159 164
                     channel.getChannelClient(channel.getTopicSetter(), true), channel.getTopic());
160 165
         }
@@ -246,7 +251,9 @@ public class ChannelEventHandler extends EventHandler implements
246 251
         final StringBuffer messageType = new StringBuffer(
247 252
                 isMyself(client) ? "channelSelfNickChange" : "channelNickChange");
248 253
 
249
-        triggerAction(messageType, CoreActionType.CHANNEL_NICKCHANGE, client, oldNick);
254
+        final DisplayableEvent event = new ChannelNickchangeEvent(owner, client, oldNick);
255
+        event.setDisplayFormat(messageType.toString());
256
+        eventBus.post(event);
250 257
         owner.doNotification(date, messageType.toString(), client, oldNick);
251 258
         owner.renameClient(oldNick, client.getClient().getNickname());
252 259
     }

+ 2
- 0
src/com/dmdirc/actions/CoreActionType.java Vedi File

@@ -199,8 +199,10 @@ public enum CoreActionType implements ActionType {
199 199
     CHANNEL_USERMODECHANGE(ChannelEvents.CHANNEL_SOURCED_EVENT_WITH_VICTIM,
200 200
             "Someone changed someone else's modes"),
201 201
     /** Someone changed nickname. */
202
+    @Deprecated
202 203
     CHANNEL_NICKCHANGE(ChannelEvents.CHANNEL_NICKEVENT, "Someone changed nicknames"),
203 204
     /** Someone changed a topic. */
205
+    @Deprecated
204 206
     CHANNEL_TOPICCHANGE(ChannelEvents.CHANNEL_SOURCED_EVENT_WITH_ARG,
205 207
             "Someone changed channel topic"),
206 208
     /** Query opened. */

+ 59
- 0
src/com/dmdirc/events/ChannelNickchangeEvent.java Vedi File

@@ -0,0 +1,59 @@
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 changes nickname in a channel.
30
+ */
31
+public class ChannelNickchangeEvent extends ChannelDisplayableEvent {
32
+
33
+    private final ChannelClientInfo client;
34
+    private final String oldNick;
35
+
36
+    public ChannelNickchangeEvent(final long timestamp, final Channel channel,
37
+            final ChannelClientInfo client,
38
+            final String oldNick) {
39
+        super(timestamp, channel);
40
+        this.client = client;
41
+        this.oldNick = oldNick;
42
+    }
43
+
44
+    public ChannelNickchangeEvent(final Channel channel, final ChannelClientInfo client,
45
+            final String oldNick) {
46
+        super(channel);
47
+        this.client = client;
48
+        this.oldNick = oldNick;
49
+    }
50
+
51
+    public ChannelClientInfo getClient() {
52
+        return client;
53
+    }
54
+
55
+    public String getOldNick() {
56
+        return oldNick;
57
+    }
58
+
59
+}

+ 60
- 0
src/com/dmdirc/events/ChannelTopicChangeEvent.java Vedi File

@@ -0,0 +1,60 @@
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 javax.annotation.Nullable;
29
+
30
+/**
31
+ * Fired when a topic is changed.
32
+ */
33
+public class ChannelTopicChangeEvent extends ChannelDisplayableEvent {
34
+
35
+    private final ChannelClientInfo client;
36
+    @Nullable private final String topic;
37
+
38
+    public ChannelTopicChangeEvent(final long timestamp, final Channel channel,
39
+            final ChannelClientInfo client, @Nullable final String topic) {
40
+        super(timestamp, channel);
41
+        this.client = client;
42
+        this.topic = topic;
43
+    }
44
+
45
+    public ChannelTopicChangeEvent(final Channel channel, final ChannelClientInfo client,
46
+            @Nullable final String topic) {
47
+        super(channel);
48
+        this.client = client;
49
+        this.topic = topic;
50
+    }
51
+
52
+    public ChannelClientInfo getClient() {
53
+        return client;
54
+    }
55
+
56
+    public String getTopic() {
57
+        return topic;
58
+    }
59
+
60
+}

Loading…
Annulla
Salva