Browse Source

Fire an event when the channel password changes. (Issue #108)

pull/111/head
Shane Mc Cormack 8 years ago
parent
commit
d9cc3b6939

+ 48
- 0
common/src/com/dmdirc/parser/events/ChannelPasswordChangedEvent.java View File

@@ -0,0 +1,48 @@
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.parser.events;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelInfo;
26
+import com.dmdirc.parser.interfaces.Parser;
27
+
28
+import java.time.LocalDateTime;
29
+
30
+import static com.google.common.base.Preconditions.checkNotNull;
31
+
32
+/**
33
+ * Called when a channel password changes.
34
+ */
35
+public class ChannelPasswordChangedEvent extends ParserEvent {
36
+
37
+    private final ChannelInfo channel;
38
+
39
+    public ChannelPasswordChangedEvent(final Parser parser, final LocalDateTime date,
40
+                                  final ChannelInfo channel) {
41
+        super(parser, date);
42
+        this.channel = checkNotNull(channel);
43
+    }
44
+
45
+    public ChannelInfo getChannel() {
46
+        return channel;
47
+    }
48
+}

+ 2
- 0
irc/src/com/dmdirc/parser/irc/IRCChannelInfo.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.parser.irc;
24 24
 import com.dmdirc.parser.common.ChannelListModeItem;
25 25
 import com.dmdirc.parser.common.ParserError;
26 26
 import com.dmdirc.parser.common.QueuePriority;
27
+import com.dmdirc.parser.events.ChannelPasswordChangedEvent;
27 28
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
28 29
 import com.dmdirc.parser.interfaces.ChannelInfo;
29 30
 import com.dmdirc.parser.interfaces.ClientInfo;
@@ -454,6 +455,7 @@ public class IRCChannelInfo implements ChannelInfo {
454 455
      */
455 456
     public void setInternalPassword(final String newValue) {
456 457
         password = newValue;
458
+        parser.getCallbackManager().publish(new ChannelPasswordChangedEvent(parser, LocalDateTime.now(), this));
457 459
     }
458 460
 
459 461
     /**

Loading…
Cancel
Save