Sfoglia il codice sorgente

Merge pull request #514 from csmith/master

Make some server events use the new formatter.
pull/515/head
Greg Holmes 9 anni fa
parent
commit
ea490e3f50

+ 12
- 4
res/com/dmdirc/ui/messages/format.yml Vedi File

@@ -8,6 +8,18 @@ ServerCtcpEvent:
8 8
 ServerCtcpReplyEvent:
9 9
   format: "-!- CTCP {{type}} reply from {{user.nickname}}: {{content}}."
10 10
   colour: 4
11
+ServerDisconnectedEvent:
12
+  format: "-!- You have been disconnected from the server."
13
+  colour: 2
14
+ServerConnectErrorEvent:
15
+  format: "Error connecting: {{message}}"
16
+  colour: 2
17
+ServerReconnectScheduledEvent:
18
+  format: "Reconnecting in {{seconds}} seconds..."
19
+  colour: 2
20
+ServerStonedEvent:
21
+  format: "-!- Disconnected from a non-responsive server."
22
+  colour: 2
11 23
 
12 24
 ################## Channel join/part/quit events ###################################################
13 25
 
@@ -142,8 +154,6 @@ CommandOutputEvent:
142 154
 #  selfCTCP=4->- [%1$s] %2$s
143 155
 #  selfNotice=5>%1$s> %2$s
144 156
 #  selfMessage=>[%1$s]> %2$s
145
-#  connectError=2Error connecting: %2$s
146
-#  connectRetry=2Reconnecting in %2$u...
147 157
 #  serverConnecting=Connecting to %1$s:%2$s...
148 158
 #  back=14You are no longer marked as away.
149 159
 #  serverDisconnectInProgress=A disconnection attempt is in progress, please wait...
@@ -152,8 +162,6 @@ CommandOutputEvent:
152 162
 #  away=14You are now marked as away (%1$s14).
153 163
 #  rawCommand=10>>> %1$s
154 164
 #  unknownCommand=14Unknown command %1$s.
155
-#  socketClosed=2-!- You have been disconnected from the server.
156
-#  stonedServer=2-!- Disconnected from a non-responsive server.
157 165
 #  motdStart=10%1$s
158 166
 #  motdLine=10%1$s
159 167
 #  motdEnd=10%1$s

+ 2
- 5
src/com/dmdirc/Server.java Vedi File

@@ -30,6 +30,7 @@ import com.dmdirc.events.ServerConnectErrorEvent;
30 30
 import com.dmdirc.events.ServerConnectedEvent;
31 31
 import com.dmdirc.events.ServerConnectingEvent;
32 32
 import com.dmdirc.events.ServerDisconnectedEvent;
33
+import com.dmdirc.events.ServerReconnectScheduledEvent;
33 34
 import com.dmdirc.interfaces.Connection;
34 35
 import com.dmdirc.interfaces.GroupChatManager;
35 36
 import com.dmdirc.interfaces.InviteManager;
@@ -439,7 +440,7 @@ public class Server extends FrameContainer implements Connection {
439 440
             final int delay = Math.max(1000,
440 441
                     getConfigManager().getOptionInt(DOMAIN_GENERAL, "reconnectdelay"));
441 442
 
442
-            handleNotification("connectRetry", getAddress(), delay / 1000);
443
+            getEventBus().publishAsync(new ServerReconnectScheduledEvent(this, delay / 1000));
443 444
 
444 445
             reconnectTimerFuture = executorService.schedule(() -> {
445 446
                 synchronized (myStateLock) {
@@ -850,8 +851,6 @@ public class Server extends FrameContainer implements Connection {
850 851
             return;
851 852
         }
852 853
 
853
-        handleNotification("socketClosed", getAddress());
854
-
855 854
         getEventBus().publish(new ServerDisconnectedEvent(this));
856 855
 
857 856
         eventHandler.unregisterCallbacks();
@@ -956,8 +955,6 @@ public class Server extends FrameContainer implements Connection {
956 955
 
957 956
             getEventBus().publish(new ServerConnectErrorEvent(this, description));
958 957
 
959
-            handleNotification("connectError", getAddress(), description);
960
-
961 958
             if (getConfigManager().getOptionBool(DOMAIN_GENERAL, "reconnectonconnectfailure")) {
962 959
                 doDelayedReconnect();
963 960
             }

+ 2
- 1
src/com/dmdirc/ServerEventHandler.java Vedi File

@@ -42,6 +42,7 @@ import com.dmdirc.events.ServerNoticeEvent;
42 42
 import com.dmdirc.events.ServerNumericEvent;
43 43
 import com.dmdirc.events.ServerPingSentEvent;
44 44
 import com.dmdirc.events.ServerServerNoticeEvent;
45
+import com.dmdirc.events.ServerStonedEvent;
45 46
 import com.dmdirc.events.ServerUnknownActionEvent;
46 47
 import com.dmdirc.events.ServerUnknownMessageEvent;
47 48
 import com.dmdirc.events.ServerUnknownNoticeEvent;
@@ -331,7 +332,7 @@ public class ServerEventHandler extends EventHandler implements
331 332
         if (parser.getPingTime()
332 333
                 >= owner.getConfigManager().getOptionInt("server", "pingtimeout")) {
333 334
             LOG.warn("Server appears to be stoned, reconnecting");
334
-            owner.handleNotification("stonedServer", owner.getAddress());
335
+            eventBus.publishAsync(new ServerStonedEvent(owner));
335 336
             owner.reconnect();
336 337
         }
337 338
     }

+ 1
- 1
src/com/dmdirc/events/ServerDisconnectedEvent.java Vedi File

@@ -27,7 +27,7 @@ import com.dmdirc.interfaces.Connection;
27 27
 /**
28 28
  * Fire when a server disconnects.
29 29
  */
30
-public class ServerDisconnectedEvent extends ServerEvent {
30
+public class ServerDisconnectedEvent extends ServerDisplayableEvent {
31 31
 
32 32
     public ServerDisconnectedEvent(final Connection connection) {
33 33
         super(connection);

+ 43
- 0
src/com/dmdirc/events/ServerReconnectScheduledEvent.java Vedi File

@@ -0,0 +1,43 @@
1
+/*
2
+ * Copyright (c) 2006-2015 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.interfaces.Connection;
26
+
27
+/**
28
+ * Event raised when a reconnection attempt has been scheduled.
29
+ */
30
+public class ServerReconnectScheduledEvent extends ServerDisplayableEvent {
31
+
32
+    private final int seconds;
33
+
34
+    public ServerReconnectScheduledEvent(final Connection connection, final int seconds) {
35
+        super(connection);
36
+        this.seconds = seconds;
37
+    }
38
+
39
+    public int getSeconds() {
40
+        return seconds;
41
+    }
42
+
43
+}

+ 36
- 0
src/com/dmdirc/events/ServerStonedEvent.java Vedi File

@@ -0,0 +1,36 @@
1
+/*
2
+ * Copyright (c) 2006-2015 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.interfaces.Connection;
26
+
27
+/**
28
+ * Event raised when a server appears to be 'stoned' (i.e., non-responsive).
29
+ */
30
+public class ServerStonedEvent extends ServerDisplayableEvent {
31
+
32
+    public ServerStonedEvent(final Connection connection) {
33
+        super(connection);
34
+    }
35
+
36
+}

Loading…
Annulla
Salva