Преглед на файлове

Couple more deprecation fixes.

pull/615/head
Chris Smith преди 8 години
родител
ревизия
e1e78e2437

+ 3
- 1
res/com/dmdirc/ui/messages/format.yml Целия файл

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

+ 1
- 0
src/com/dmdirc/GroupChatManagerImpl.java Целия файл

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

+ 3
- 1
src/com/dmdirc/commandparser/commands/channel/Mode.java Целия файл

32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
33
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
33
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
34
 import com.dmdirc.commandparser.commands.context.CommandContext;
34
 import com.dmdirc.commandparser.commands.context.CommandContext;
35
+import com.dmdirc.events.ChannelModesDiscoveredEvent;
35
 import com.dmdirc.interfaces.CommandController;
36
 import com.dmdirc.interfaces.CommandController;
36
 import com.dmdirc.interfaces.Connection;
37
 import com.dmdirc.interfaces.Connection;
37
 import com.dmdirc.interfaces.GroupChat;
38
 import com.dmdirc.interfaces.GroupChat;
70
         final GroupChat channel = ((ChannelCommandContext) context).getGroupChat();
71
         final GroupChat channel = ((ChannelCommandContext) context).getGroupChat();
71
 
72
 
72
         if (args.getArguments().length == 0) {
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
         } else {
76
         } else {
75
             channel.getConnection().get().getParser().get().sendRawMessage("MODE "
77
             channel.getConnection().get().getParser().get().sendRawMessage("MODE "
76
                     + channel.getName() + ' ' + args.getArgumentsAsString());
78
                     + channel.getName() + ' ' + args.getArgumentsAsString());

+ 2
- 10
src/com/dmdirc/commandparser/parsers/CommandParser.java Целия файл

39
 import com.dmdirc.interfaces.GroupChat;
39
 import com.dmdirc.interfaces.GroupChat;
40
 import com.dmdirc.interfaces.WindowModel;
40
 import com.dmdirc.interfaces.WindowModel;
41
 import com.dmdirc.interfaces.config.ReadOnlyConfigProvider;
41
 import com.dmdirc.interfaces.config.ReadOnlyConfigProvider;
42
-import com.dmdirc.util.EventUtils;
43
 import com.dmdirc.util.collections.RollingList;
42
 import com.dmdirc.util.collections.RollingList;
44
 
43
 
45
 import java.io.Serializable;
44
 import java.io.Serializable;
335
      */
334
      */
336
     protected void handleInvalidCommand(final WindowModel origin,
335
     protected void handleInvalidCommand(final WindowModel origin,
337
             final CommandArguments args) {
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 Целия файл

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

Loading…
Отказ
Запис