Procházet zdrojové kódy

Add some more events, remove some unused methods.

pull/612/head
Chris Smith před 8 roky
rodič
revize
dfb63e9836

+ 5
- 2
res/com/dmdirc/ui/messages/format.yml Zobrazit soubor

@@ -8,6 +8,8 @@ ServerCtcpEvent:
8 8
 ServerCtcpReplyEvent:
9 9
   format: "-!- CTCP {{type}} reply from {{user.nickname}}: {{content}}."
10 10
   colour: 4
11
+ServerConnectingEvent:
12
+  format: "Connecting to {{uri.host}}:{{uri.port}}..."
11 13
 ServerDisconnectedEvent:
12 14
   format: "-!- You have been disconnected from the server."
13 15
   colour: 2
@@ -50,6 +52,9 @@ ServerNickChangeEvent:
50 52
 ServerErrorEvent:
51 53
   format: "ERROR: {{reason}}"
52 54
   colour: 4
55
+ServerUnknownProtocolEvent:
56
+  format: "Unknown protocol '{{protocol}}'. Unable to connect."
57
+  colour: 4
53 58
 
54 59
 ################## Server messaging events #########################################################
55 60
 
@@ -205,7 +210,6 @@ CommandOutputEvent:
205 210
 #  selfCTCP=4->- [%1$s] %2$s
206 211
 #  selfNotice=5>%1$s> %2$s
207 212
 #  selfMessage=>[%1$s]> %2$s
208
-#  serverConnecting=Connecting to %1$s:%2$s...
209 213
 #  serverDisconnectInProgress=A disconnection attempt is in progress, please wait...
210 214
 #  serverConnectInProgress=A connection attempt is in progress, please wait...
211 215
 #  rawCommand=10>>> %1$s
@@ -213,7 +217,6 @@ CommandOutputEvent:
213 217
 #  commandOutput=%1$s
214 218
 #  actionTooLong=Warning: action too long to be sent
215 219
 #  tabCompletion=14Multiple possibilities: %1$s
216
-#  serverUnknownProtocol=4Unknown protocol '%1$s'. Unable to connect.
217 220
 #  commandUsage=7Usage: %1$s%2$s %3$s
218 221
 #  numeric_006=%4$s
219 222
 #  numeric_007=%4$s

+ 0
- 18
src/com/dmdirc/FrameContainer.java Zobrazit soubor

@@ -319,24 +319,6 @@ public abstract class FrameContainer implements WindowModel {
319 319
         addLine(type, new Date(), args);
320 320
     }
321 321
 
322
-    @Override
323
-    public void addLine(final StringBuffer type, final Date timestamp, final Object... args) {
324
-        if (type != null) {
325
-            addLine(type.toString(), timestamp, args);
326
-        }
327
-    }
328
-
329
-    @Override
330
-    public void addLine(final StringBuffer type, final Object... args) {
331
-        addLine(type, new Date(), args);
332
-    }
333
-
334
-    @Override
335
-    @Deprecated
336
-    public void addLine(final String line, final boolean timestamp) {
337
-        addLine(line, new Date());
338
-    }
339
-
340 322
     @Override
341 323
     public void addLine(final String line, final Date timestamp) {
342 324
         for (final String myLine : line.split("\n")) {

+ 4
- 5
src/com/dmdirc/Server.java Zobrazit soubor

@@ -29,6 +29,7 @@ import com.dmdirc.events.ServerConnectedEvent;
29 29
 import com.dmdirc.events.ServerConnectingEvent;
30 30
 import com.dmdirc.events.ServerDisconnectedEvent;
31 31
 import com.dmdirc.events.ServerReconnectScheduledEvent;
32
+import com.dmdirc.events.ServerUnknownProtocolEvent;
32 33
 import com.dmdirc.interfaces.Connection;
33 34
 import com.dmdirc.interfaces.GroupChatManager;
34 35
 import com.dmdirc.interfaces.InviteManager;
@@ -69,7 +70,6 @@ import java.util.Arrays;
69 70
 import java.util.Collection;
70 71
 import java.util.Collections;
71 72
 import java.util.Date;
72
-import java.util.List;
73 73
 import java.util.Map;
74 74
 import java.util.Optional;
75 75
 import java.util.concurrent.ConcurrentSkipListMap;
@@ -322,7 +322,8 @@ public class Server extends FrameContainer implements Connection {
322 322
                 parser = Optional.ofNullable(buildParser());
323 323
 
324 324
                 if (!parser.isPresent()) {
325
-                    addLine("serverUnknownProtocol", address.getScheme());
325
+                    getEventBus().publishAsync(
326
+                            new ServerUnknownProtocolEvent(this, address.getScheme()));
326 327
                     return;
327 328
                 }
328 329
 
@@ -332,8 +333,6 @@ public class Server extends FrameContainer implements Connection {
332 333
                 parserLock.writeLock().unlock();
333 334
             }
334 335
 
335
-            addLine("serverConnecting", connectAddress.getHost(), connectAddress.getPort());
336
-
337 336
             myState.transition(ServerState.CONNECTING);
338 337
 
339 338
             doCallbacks();
@@ -348,7 +347,7 @@ public class Server extends FrameContainer implements Connection {
348 347
             }
349 348
         }
350 349
 
351
-        getEventBus().publish(new ServerConnectingEvent(this));
350
+        getEventBus().publish(new ServerConnectingEvent(this, address));
352 351
     }
353 352
 
354 353
     @Override

+ 13
- 3
src/com/dmdirc/events/ServerConnectingEvent.java Zobrazit soubor

@@ -24,17 +24,27 @@ package com.dmdirc.events;
24 24
 
25 25
 import com.dmdirc.interfaces.Connection;
26 26
 
27
+import java.net.URI;
28
+
27 29
 /**
28 30
  * Fire when a server is connecting.
29 31
  */
30
-public class ServerConnectingEvent extends ServerEvent {
32
+public class ServerConnectingEvent extends ServerDisplayableEvent {
33
+
34
+    private final URI uri;
31 35
 
32
-    public ServerConnectingEvent(final Connection connection) {
36
+    public ServerConnectingEvent(final Connection connection, final URI uri) {
33 37
         super(connection);
38
+        this.uri = uri;
34 39
     }
35 40
 
36
-    public ServerConnectingEvent(final long timestamp, final Connection connection) {
41
+    public ServerConnectingEvent(final long timestamp, final Connection connection, final URI uri) {
37 42
         super(timestamp, connection);
43
+        this.uri = uri;
44
+    }
45
+
46
+    public URI getUri() {
47
+        return uri;
38 48
     }
39 49
 
40 50
 }

+ 48
- 0
src/com/dmdirc/events/ServerUnknownProtocolEvent.java Zobrazit soubor

@@ -0,0 +1,48 @@
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
+ * Raised when a server attempts to connect to an unknown protocol.
29
+ */
30
+public class ServerUnknownProtocolEvent extends ServerDisplayableEvent {
31
+
32
+    private final String protocol;
33
+
34
+    public ServerUnknownProtocolEvent(final long timestamp, final Connection connection, final String protocol) {
35
+        super(timestamp, connection);
36
+        this.protocol = protocol;
37
+    }
38
+
39
+    public ServerUnknownProtocolEvent(final Connection connection, final String protocol) {
40
+        super(connection);
41
+        this.protocol = protocol;
42
+    }
43
+
44
+    public String getProtocol() {
45
+        return protocol;
46
+    }
47
+
48
+}

+ 0
- 31
src/com/dmdirc/interfaces/WindowModel.java Zobrazit soubor

@@ -161,37 +161,6 @@ public interface WindowModel {
161 161
      */
162 162
     void addLine(String type, Object... args);
163 163
 
164
-    /**
165
-     * Adds a line to this container's window. If the window is null for some reason, the line is
166
-     * silently discarded.
167
-     *
168
-     * @param type      The message type to use
169
-     * @param timestamp The timestamp to use for this line
170
-     * @param args      The message's arguments
171
-     *
172
-     * @since 0.6.4
173
-     */
174
-    void addLine(StringBuffer type, Date timestamp, Object... args);
175
-
176
-    /**
177
-     * Adds a line to this container's window. If the window is null for some reason, the line is
178
-     * silently discarded.
179
-     *
180
-     * @param type The message type to use
181
-     * @param args The message's arguments
182
-     */
183
-    void addLine(StringBuffer type, Object... args);
184
-
185
-    /**
186
-     * Adds the specified raw line to the window, without using a formatter.
187
-     *
188
-     * @param line      The line to be added
189
-     * @param timestamp Whether or not to display the timestamp for this line
190
-     * @deprecated Timestamps are always displayed.
191
-     */
192
-    @Deprecated
193
-    void addLine(String line, boolean timestamp);
194
-
195 164
     /**
196 165
      * Adds the specified raw line to the window, without using a formatter, and using the specified
197 166
      * timestamp. If the timestamp is <code>null</code>, no timestamp is added.

Načítá se…
Zrušit
Uložit