Ver código fonte

Merge pull request #615 from csmith/tidying

Couple more deprecation fixes.
pull/616/head
Greg Holmes 8 anos atrás
pai
commit
145a660795

+ 3
- 1
res/com/dmdirc/ui/messages/format.yml Ver arquivo

@@ -205,6 +205,9 @@ CommandErrorEvent:
205 205
   colour: 7
206 206
 CommandOutputEvent:
207 207
   format: "{{message}}"
208
+UnknownCommandEvent:
209
+  format: "Unknown command {{command}}."
210
+  colour: 14
208 211
 
209 212
 ################## TODO ############################################################################
210 213
 #  selfCTCP=4->- [%1$s] %2$s
@@ -213,7 +216,6 @@ CommandOutputEvent:
213 216
 #  serverDisconnectInProgress=A disconnection attempt is in progress, please wait...
214 217
 #  serverConnectInProgress=A connection attempt is in progress, please wait...
215 218
 #  rawCommand=10>>> %1$s
216
-#  unknownCommand=14Unknown command %1$s.
217 219
 #  commandOutput=%1$s
218 220
 #  actionTooLong=Warning: action too long to be sent
219 221
 #  tabCompletion=14Multiple possibilities: %1$s

+ 1
- 0
src/com/dmdirc/GroupChatManagerImpl.java Ver arquivo

@@ -173,6 +173,7 @@ public class GroupChatManagerImpl implements GroupChatManager {
173 173
         channels.closeAll();
174 174
     }
175 175
 
176
+    @Deprecated
176 177
     public void addLineToAll(final String messageType, final Date date, final Object... args) {
177 178
         channels.addLineToAll(messageType, date, args);
178 179
     }

+ 3
- 1
src/com/dmdirc/commandparser/commands/channel/Mode.java Ver arquivo

@@ -32,6 +32,7 @@ import com.dmdirc.commandparser.commands.ExternalCommand;
32 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33 33
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
34 34
 import com.dmdirc.commandparser.commands.context.CommandContext;
35
+import com.dmdirc.events.ChannelModesDiscoveredEvent;
35 36
 import com.dmdirc.interfaces.CommandController;
36 37
 import com.dmdirc.interfaces.Connection;
37 38
 import com.dmdirc.interfaces.GroupChat;
@@ -70,7 +71,8 @@ public class Mode extends Command implements IntelligentCommand,
70 71
         final GroupChat channel = ((ChannelCommandContext) context).getGroupChat();
71 72
 
72 73
         if (args.getArguments().length == 0) {
73
-            sendLine(origin, args.isSilent(), "channelModeDiscovered", channel.getModes(), channel);
74
+            channel.getEventBus().publishAsync(new ChannelModesDiscoveredEvent(
75
+                    channel, channel.getModes()));
74 76
         } else {
75 77
             channel.getConnection().get().getParser().get().sendRawMessage("MODE "
76 78
                     + channel.getName() + ' ' + args.getArgumentsAsString());

+ 2
- 10
src/com/dmdirc/commandparser/parsers/CommandParser.java Ver arquivo

@@ -39,7 +39,6 @@ import com.dmdirc.interfaces.Connection;
39 39
 import com.dmdirc.interfaces.GroupChat;
40 40
 import com.dmdirc.interfaces.WindowModel;
41 41
 import com.dmdirc.interfaces.config.ReadOnlyConfigProvider;
42
-import com.dmdirc.util.EventUtils;
43 42
 import com.dmdirc.util.collections.RollingList;
44 43
 
45 44
 import java.io.Serializable;
@@ -335,15 +334,8 @@ public abstract class CommandParser implements Serializable {
335 334
      */
336 335
     protected void handleInvalidCommand(final WindowModel origin,
337 336
             final CommandArguments args) {
338
-        if (origin == null) {
339
-            eventBus.publish(new UnknownCommandEvent(null, args.getCommandName(), args.getArguments()));
340
-        } else {
341
-            final UnknownCommandEvent event = new UnknownCommandEvent(origin,
342
-                    args.getCommandName(), args.getArguments());
343
-            final String format = EventUtils.postDisplayable(eventBus, event, "unknownCommand");
344
-
345
-            origin.addLine(format, args.getCommandName());
346
-        }
337
+        eventBus.publishAsync(new UnknownCommandEvent(origin, args.getCommandName(),
338
+                args.getArguments()));
347 339
     }
348 340
 
349 341
     /**

+ 10
- 2
test/com/dmdirc/commandparser/commands/channel/ModeTest.java Ver arquivo

@@ -23,9 +23,11 @@
23 23
 package com.dmdirc.commandparser.commands.channel;
24 24
 
25 25
 import com.dmdirc.Channel;
26
+import com.dmdirc.DMDircMBassador;
26 27
 import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
28 29
 import com.dmdirc.config.InvalidIdentityFileException;
30
+import com.dmdirc.events.ChannelModesDiscoveredEvent;
29 31
 import com.dmdirc.interfaces.CommandController;
30 32
 import com.dmdirc.interfaces.Connection;
31 33
 import com.dmdirc.interfaces.WindowModel;
@@ -36,9 +38,12 @@ import java.util.Optional;
36 38
 import org.junit.Before;
37 39
 import org.junit.Test;
38 40
 import org.junit.runner.RunWith;
41
+import org.mockito.ArgumentCaptor;
42
+import org.mockito.Captor;
39 43
 import org.mockito.Mock;
40 44
 import org.mockito.runners.MockitoJUnitRunner;
41 45
 
46
+import static org.junit.Assert.assertEquals;
42 47
 import static org.mockito.Mockito.verify;
43 48
 import static org.mockito.Mockito.when;
44 49
 
@@ -46,10 +51,12 @@ import static org.mockito.Mockito.when;
46 51
 public class ModeTest {
47 52
 
48 53
     @Mock private WindowModel origin;
54
+    @Mock private DMDircMBassador eventbus;
49 55
     @Mock private CommandController controller;
50 56
     @Mock private Channel channel;
51 57
     @Mock private Connection connection;
52 58
     @Mock private Parser parser;
59
+    @Captor private ArgumentCaptor<ChannelModesDiscoveredEvent> modeDiscoveredCaptor;
53 60
     private Mode command;
54 61
 
55 62
     @Before
@@ -58,6 +65,7 @@ public class ModeTest {
58 65
         when(connection.getParser()).thenReturn(Optional.of(parser));
59 66
         when(channel.getModes()).thenReturn("my mode string!");
60 67
         when(channel.getName()).thenReturn("#chan");
68
+        when(channel.getEventBus()).thenReturn(eventbus);
61 69
 
62 70
         command = new Mode(controller);
63 71
     }
@@ -66,8 +74,8 @@ public class ModeTest {
66 74
     public void testWithoutArgs() {
67 75
         command.execute(origin, new CommandArguments(controller, "/mode"),
68 76
                 new ChannelCommandContext(null, Mode.INFO, channel));
69
-
70
-        verify(origin).addLine("channelModeDiscovered", "my mode string!", channel);
77
+        verify(eventbus).publishAsync(modeDiscoveredCaptor.capture());
78
+        assertEquals("my mode string!", modeDiscoveredCaptor.getValue().getModes());
71 79
     }
72 80
 
73 81
     @Test

Carregando…
Cancelar
Salvar