소스 검색

Add some more actions.

Change-Id: Ib412a2b139ba1112c04f1f1b9b81d195554bf4e9
Reviewed-on: http://gerrit.dmdirc.com/3474
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
pull/1/head
Greg Holmes 10 년 전
부모
커밋
2b0daac17a

+ 23
- 8
src/com/dmdirc/ChannelEventHandler.java 파일 보기

@@ -24,10 +24,14 @@ package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.CoreActionType;
27
+import com.dmdirc.events.ChannelListmodesretrievedEvent;
28
+import com.dmdirc.events.ChannelModechangeEvent;
29
+import com.dmdirc.events.ChannelModesdiscoveredEvent;
27 30
 import com.dmdirc.events.ChannelNickchangeEvent;
28 31
 import com.dmdirc.events.ChannelTopicChangeEvent;
29 32
 import com.dmdirc.events.ChannelUserAwayEvent;
30 33
 import com.dmdirc.events.ChannelUserBackEvent;
34
+import com.dmdirc.events.ChannelUsermodechangeEvent;
31 35
 import com.dmdirc.events.DisplayableEvent;
32 36
 import com.dmdirc.interfaces.Connection;
33 37
 import com.dmdirc.interfaces.actions.ActionType;
@@ -269,14 +273,18 @@ public class ChannelEventHandler extends EventHandler implements
269 273
             if (host.isEmpty()) {
270 274
                 final StringBuffer messageType = new StringBuffer(
271 275
                         modes.length() <= 1 ? "channelNoModes" : "channelModeDiscovered");
272
-                triggerAction(messageType, CoreActionType.CHANNEL_MODESDISCOVERED,
276
+                final DisplayableEvent event = new ChannelModesdiscoveredEvent(owner,
273 277
                         modes.length() <= 1 ? "" : modes);
278
+                event.setDisplayFormat(host);
279
+                eventBus.post(event);
274 280
                 owner.doNotification(date, messageType.toString(),
275 281
                         modes.length() <= 1 ? "" : modes);
276 282
             } else {
277 283
                 final StringBuffer messageType = new StringBuffer(
278 284
                         isMyself(client) ? "channelSelfModeChanged" : "channelModeChanged");
279
-                triggerAction(messageType, CoreActionType.CHANNEL_MODECHANGE, client, modes);
285
+                final DisplayableEvent event = new ChannelModechangeEvent(owner, client, modes);
286
+                event.setDisplayFormat(messageType.toString());
287
+                eventBus.post(event);
280 288
                 owner.doNotification(date, messageType.toString(), client, modes);
281 289
             }
282 290
         }
@@ -298,8 +306,10 @@ public class ChannelEventHandler extends EventHandler implements
298 306
             }
299 307
 
300 308
             final StringBuffer messageType = new StringBuffer(format);
301
-            triggerAction(messageType, CoreActionType.CHANNEL_USERMODECHANGE, client,
309
+            final DisplayableEvent event = new ChannelUsermodechangeEvent(owner, client,
302 310
                     targetClient, mode);
311
+            event.setDisplayFormat(format);
312
+            eventBus.post(event);
303 313
             owner.doNotification(date, messageType.toString(), client, targetClient, mode);
304 314
         }
305 315
     }
@@ -362,14 +372,18 @@ public class ChannelEventHandler extends EventHandler implements
362 372
             if (host.isEmpty()) {
363 373
                 final StringBuffer messageType = new StringBuffer(
364 374
                         modes.length() <= 1 ? "channelNoModes" : "channelModeDiscovered");
365
-                triggerAction(messageType, CoreActionType.CHANNEL_MODESDISCOVERED,
375
+                final DisplayableEvent event = new ChannelModesdiscoveredEvent(owner,
366 376
                         modes.length() <= 1 ? "" : modes);
377
+                event.setDisplayFormat(host);
378
+                eventBus.post(event);
367 379
                 owner.doNotification(date, messageType.toString(),
368 380
                         modes.length() <= 1 ? "" : modes);
369 381
             } else {
370 382
                 final StringBuffer messageType = new StringBuffer(
371 383
                         isMyself(client) ? "channelSelfModeChanged" : "channelModeChanged");
372
-                triggerAction(messageType, CoreActionType.CHANNEL_MODECHANGE, client, modes);
384
+                final DisplayableEvent event = new ChannelModechangeEvent(owner, client, modes);
385
+                event.setDisplayFormat(messageType.toString());
386
+                eventBus.post(event);
373 387
                 owner.doNotification(date, messageType.toString(), client, modes);
374 388
             }
375 389
         }
@@ -396,9 +410,10 @@ public class ChannelEventHandler extends EventHandler implements
396 410
             final ChannelInfo channel, final char mode) {
397 411
         checkParser(parser);
398 412
 
399
-        final StringBuffer messageType = new StringBuffer("channelListModeRetrieved");
400
-        triggerAction(messageType, CoreActionType.CHANNEL_LISTMODERETRIEVED, mode);
401
-        owner.doNotification(date, messageType.toString(), mode);
413
+        final DisplayableEvent event = new ChannelListmodesretrievedEvent(owner, mode);
414
+        event.setDisplayFormat("channelListModeRetrieved");
415
+        eventBus.post(event);
416
+        owner.doNotification(date, "channelListModeRetrieved", mode);
402 417
     }
403 418
 
404 419
     private boolean triggerAction(final StringBuffer messageType, final ActionType actionType,

+ 5
- 3
src/com/dmdirc/actions/CoreActionType.java 파일 보기

@@ -186,16 +186,18 @@ public enum CoreActionType implements ActionType {
186 186
     /** Someone marked as back. */
187 187
     @Deprecated
188 188
     CHANNEL_USERBACK(ChannelEvents.CHANNEL_SOURCED_EVENT, "Someone is marked as 'back'"),
189
-    /** Channel list mode retrieved.
190
-     *
191
-     * @since 0.6.3 */
189
+    /** Channel list mode retrieved. */
190
+    @Deprecated
192 191
     CHANNEL_LISTMODERETRIEVED(ChannelEvents.CHANNEL_LISTMODEEVENT,
193 192
             "Channel list mode value retrieved"),
194 193
     /** Channel mode discovered. */
194
+    @Deprecated
195 195
     CHANNEL_MODESDISCOVERED(ChannelEvents.CHANNEL_MODEEVENT, "Channel modes discovered"),
196 196
     /** Channel mode changes. */
197
+    @Deprecated
197 198
     CHANNEL_MODECHANGE(ChannelEvents.CHANNEL_SOURCED_EVENT_WITH_ARG, "Someone changed channel modes"),
198 199
     /** Someone changed someone else's user modes. */
200
+    @Deprecated
199 201
     CHANNEL_USERMODECHANGE(ChannelEvents.CHANNEL_SOURCED_EVENT_WITH_VICTIM,
200 202
             "Someone changed someone else's modes"),
201 203
     /** Someone changed nickname. */

+ 49
- 0
src/com/dmdirc/events/ChannelListmodesretrievedEvent.java 파일 보기

@@ -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
+
27
+/**
28
+ * Fired when channel list modes are retrieved.
29
+ */
30
+public class ChannelListmodesretrievedEvent extends ChannelDisplayableEvent {
31
+
32
+    private final char mode;
33
+
34
+    public ChannelListmodesretrievedEvent(final long timestamp, final Channel channel,
35
+            final char mode) {
36
+        super(timestamp, channel);
37
+        this.mode = mode;
38
+    }
39
+
40
+    public ChannelListmodesretrievedEvent(final Channel channel, final char mode) {
41
+        super(channel);
42
+        this.mode = mode;
43
+    }
44
+
45
+    public char getMode() {
46
+        return mode;
47
+    }
48
+
49
+}

+ 58
- 0
src/com/dmdirc/events/ChannelModechangeEvent.java 파일 보기

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

+ 49
- 0
src/com/dmdirc/events/ChannelModesdiscoveredEvent.java 파일 보기

@@ -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
+
27
+/**
28
+ * Fired when channel modes are discovered.
29
+ */
30
+public class ChannelModesdiscoveredEvent extends ChannelDisplayableEvent {
31
+
32
+    private final String modes;
33
+
34
+    public ChannelModesdiscoveredEvent(final long timestamp, final Channel channel,
35
+            final String modes) {
36
+        super(timestamp, channel);
37
+        this.modes = modes;
38
+    }
39
+
40
+    public ChannelModesdiscoveredEvent(final Channel channel, final String modes) {
41
+        super(channel);
42
+        this.modes = modes;
43
+    }
44
+
45
+    public String getModes() {
46
+        return modes;
47
+    }
48
+
49
+}

+ 65
- 0
src/com/dmdirc/events/ChannelUsermodechangeEvent.java 파일 보기

@@ -0,0 +1,65 @@
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 channel user mode change occurs.
30
+ */
31
+public class ChannelUsermodechangeEvent extends ChannelDisplayableEvent {
32
+
33
+    private final ChannelClientInfo user;
34
+    private final ChannelClientInfo victim;
35
+    private final String modes;
36
+
37
+    public ChannelUsermodechangeEvent(final long timestamp, final Channel channel,
38
+            final ChannelClientInfo user, final ChannelClientInfo victim, final String modes) {
39
+        super(timestamp, channel);
40
+        this.user = user;
41
+        this.victim = victim;
42
+        this.modes = modes;
43
+    }
44
+
45
+    public ChannelUsermodechangeEvent(final Channel channel,
46
+            final ChannelClientInfo user, final ChannelClientInfo victim, final String modes) {
47
+        super(channel);
48
+        this.user = user;
49
+        this.victim = victim;
50
+        this.modes = modes;
51
+    }
52
+
53
+    public ChannelClientInfo getUser() {
54
+        return user;
55
+    }
56
+
57
+    public ChannelClientInfo getVictim() {
58
+        return victim;
59
+    }
60
+
61
+    public String getModes() {
62
+        return modes;
63
+    }
64
+
65
+}

Loading…
취소
저장