Преглед изворни кода

Use GroupChat in Connection.getChannel().

pull/298/head
Chris Smith пре 9 година
родитељ
комит
657817fd9b

+ 5
- 0
src/com/dmdirc/Channel.java Прегледај датотеку

570
                 .collect(Collectors.toList());
570
                 .collect(Collectors.toList());
571
     }
571
     }
572
 
572
 
573
+    @Override
574
+    public FrameContainer getWindowModel() {
575
+        return this;
576
+    }
577
+
573
 }
578
 }

+ 3
- 1
src/com/dmdirc/MessageEncoder.java Прегледај датотеку

24
 
24
 
25
 import com.dmdirc.events.UserErrorEvent;
25
 import com.dmdirc.events.UserErrorEvent;
26
 import com.dmdirc.interfaces.Connection;
26
 import com.dmdirc.interfaces.Connection;
27
+import com.dmdirc.interfaces.GroupChat;
27
 import com.dmdirc.logger.ErrorLevel;
28
 import com.dmdirc.logger.ErrorLevel;
28
 import com.dmdirc.parser.interfaces.Encoder;
29
 import com.dmdirc.parser.interfaces.Encoder;
29
 import com.dmdirc.parser.interfaces.Parser;
30
 import com.dmdirc.parser.interfaces.Parser;
65
 
66
 
66
         if (target != null && parser.isValidChannelName(target)) {
67
         if (target != null && parser.isValidChannelName(target)) {
67
             encoding = connection.getChannel(target)
68
             encoding = connection.getChannel(target)
68
-                    .map(Channel::getConfigManager)
69
+                    .map(GroupChat::getWindowModel)
70
+                    .map(FrameContainer::getConfigManager)
69
                     .map(cm -> cm.getOption("general", "encoding"))
71
                     .map(cm -> cm.getOption("general", "encoding"))
70
                     .orElse(encoding);
72
                     .orElse(encoding);
71
         }
73
         }

+ 5
- 4
src/com/dmdirc/Server.java Прегледај датотеку

34
 import com.dmdirc.events.ServerDisconnectedEvent;
34
 import com.dmdirc.events.ServerDisconnectedEvent;
35
 import com.dmdirc.events.ServerInviteExpiredEvent;
35
 import com.dmdirc.events.ServerInviteExpiredEvent;
36
 import com.dmdirc.interfaces.Connection;
36
 import com.dmdirc.interfaces.Connection;
37
+import com.dmdirc.interfaces.GroupChat;
37
 import com.dmdirc.interfaces.User;
38
 import com.dmdirc.interfaces.User;
38
 import com.dmdirc.interfaces.config.ConfigChangeListener;
39
 import com.dmdirc.interfaces.config.ConfigChangeListener;
39
 import com.dmdirc.interfaces.config.ConfigProvider;
40
 import com.dmdirc.interfaces.config.ConfigProvider;
483
     }
484
     }
484
 
485
 
485
     @Override
486
     @Override
486
-    public Optional<Channel> getChannel(final String channel) {
487
-        return channels.get(channel);
487
+    public Optional<GroupChat> getChannel(final String channel) {
488
+        return channels.get(channel).map(c -> (GroupChat) c);
488
     }
489
     }
489
 
490
 
490
     @Override
491
     @Override
590
 
591
 
591
         backgroundChannels.remove(chan.getName());
592
         backgroundChannels.remove(chan.getName());
592
 
593
 
593
-        final Optional<Channel> channel = getChannel(chan.getName());
594
+        final Optional<Channel> channel = channels.get(chan.getName());
594
         if (channel.isPresent()) {
595
         if (channel.isPresent()) {
595
             channel.get().setChannelInfo(chan);
596
             channel.get().setChannelInfo(chan);
596
             channel.get().selfJoin();
597
             channel.get().selfJoin();
723
                                 + request.getName();
724
                                 + request.getName();
724
                     }
725
                     }
725
 
726
 
726
-                    if (getChannel(name).map(Channel::isOnChannel).orElse(false)) {
727
+                    if (getChannel(name).map(GroupChat::isOnChannel).orElse(false)) {
727
                         if (!focus) {
728
                         if (!focus) {
728
                             backgroundChannels.add(name);
729
                             backgroundChannels.add(name);
729
                         }
730
                         }

+ 2
- 2
src/com/dmdirc/commandparser/commands/server/Message.java Прегледај датотеку

22
 
22
 
23
 package com.dmdirc.commandparser.commands.server;
23
 package com.dmdirc.commandparser.commands.server;
24
 
24
 
25
-import com.dmdirc.Channel;
26
 import com.dmdirc.FrameContainer;
25
 import com.dmdirc.FrameContainer;
27
 import com.dmdirc.commandparser.BaseCommandInfo;
26
 import com.dmdirc.commandparser.BaseCommandInfo;
28
 import com.dmdirc.commandparser.CommandArguments;
27
 import com.dmdirc.commandparser.CommandArguments;
36
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
35
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
37
 import com.dmdirc.interfaces.CommandController;
36
 import com.dmdirc.interfaces.CommandController;
38
 import com.dmdirc.interfaces.Connection;
37
 import com.dmdirc.interfaces.Connection;
38
+import com.dmdirc.interfaces.GroupChat;
39
 import com.dmdirc.parser.interfaces.Parser;
39
 import com.dmdirc.parser.interfaces.Parser;
40
 import com.dmdirc.ui.input.AdditionalTabTargets;
40
 import com.dmdirc.ui.input.AdditionalTabTargets;
41
 import com.dmdirc.ui.input.TabCompletionType;
41
 import com.dmdirc.ui.input.TabCompletionType;
80
 
80
 
81
             // If this is a known server or channel, and this is not a silent
81
             // If this is a known server or channel, and this is not a silent
82
             // invocation, use sendLine, else send it raw to the parser.
82
             // invocation, use sendLine, else send it raw to the parser.
83
-            final Optional<Channel> channel = connection.getChannel(target);
83
+            final Optional<GroupChat> channel = connection.getChannel(target);
84
             if (!args.isSilent() && channel.isPresent()) {
84
             if (!args.isSilent() && channel.isPresent()) {
85
                 channel.get().sendLine(message);
85
                 channel.get().sendLine(message);
86
             } else if (!args.isSilent() && connection.hasQuery(target)) {
86
             } else if (!args.isSilent() && connection.hasQuery(target)) {

+ 4
- 3
src/com/dmdirc/commandparser/parsers/CommandParser.java Прегледај датотеку

22
 
22
 
23
 package com.dmdirc.commandparser.parsers;
23
 package com.dmdirc.commandparser.parsers;
24
 
24
 
25
-import com.dmdirc.Channel;
26
 import com.dmdirc.DMDircMBassador;
25
 import com.dmdirc.DMDircMBassador;
27
 import com.dmdirc.FrameContainer;
26
 import com.dmdirc.FrameContainer;
28
 import com.dmdirc.commandparser.CommandArguments;
27
 import com.dmdirc.commandparser.CommandArguments;
37
 import com.dmdirc.events.UnknownCommandEvent;
36
 import com.dmdirc.events.UnknownCommandEvent;
38
 import com.dmdirc.interfaces.CommandController;
37
 import com.dmdirc.interfaces.CommandController;
39
 import com.dmdirc.interfaces.Connection;
38
 import com.dmdirc.interfaces.Connection;
39
+import com.dmdirc.interfaces.GroupChat;
40
 import com.dmdirc.interfaces.config.ReadOnlyConfigProvider;
40
 import com.dmdirc.interfaces.config.ReadOnlyConfigProvider;
41
 import com.dmdirc.util.EventUtils;
41
 import com.dmdirc.util.EventUtils;
42
 import com.dmdirc.util.collections.RollingList;
42
 import com.dmdirc.util.collections.RollingList;
208
                         + args.getCommandName()
208
                         + args.getCommandName()
209
                         + (cargs.length > 1 ? ' ' + args.getArgumentsAsString(1) : "");
209
                         + (cargs.length > 1 ? ' ' + args.getArgumentsAsString(1) : "");
210
 
210
 
211
-                final Optional<Channel> channel = server.getChannel(channelName);
211
+                final Optional<GroupChat> channel = server.getChannel(channelName);
212
                 if (channel.isPresent()) {
212
                 if (channel.isPresent()) {
213
-                    channel.get().getCommandParser().parseCommand(origin, newCommandString, false);
213
+                    channel.get().getWindowModel().getCommandParser()
214
+                            .parseCommand(origin, newCommandString, false);
214
                 } else {
215
                 } else {
215
                     final Map.Entry<CommandInfo, Command> actCommand = commandManager.getCommand(
216
                     final Map.Entry<CommandInfo, Command> actCommand = commandManager.getCommand(
216
                             CommandType.TYPE_CHANNEL, command);
217
                             CommandType.TYPE_CHANNEL, command);

+ 7
- 7
src/com/dmdirc/interfaces/Connection.java Прегледај датотеку

155
      *
155
      *
156
      * @return The appropriate channel object
156
      * @return The appropriate channel object
157
      */
157
      */
158
-    Optional<Channel> getChannel(final String channel);
158
+    Optional<GroupChat> getChannel(final String channel);
159
 
159
 
160
     /**
160
     /**
161
      * Retrieves the possible channel prefixes in use on this server.
161
      * Retrieves the possible channel prefixes in use on this server.
437
     void updateTitle();
437
     void updateTitle();
438
 
438
 
439
     /**
439
     /**
440
-     * Gets the core model for the input/output window for this connection.
440
+     * Sends a raw line to the underlying connection.
441
      *
441
      *
442
-     * @return A model for windows based on this connection.
442
+     * @param line The line to be sent
443
      */
443
      */
444
-    FrameContainer getWindowModel();
444
+    void sendLine(String line);
445
 
445
 
446
     /**
446
     /**
447
-     * Sends a raw line to the underlying connection.
447
+     * Gets the core model for the input/output window for this connection.
448
      *
448
      *
449
-     * @param line The line to be sent
449
+     * @return A model for windows based on this connection.
450
      */
450
      */
451
-    void sendLine(String line);
451
+    FrameContainer getWindowModel();
452
 
452
 
453
 }
453
 }

+ 8
- 0
src/com/dmdirc/interfaces/GroupChat.java Прегледај датотеку

23
 package com.dmdirc.interfaces;
23
 package com.dmdirc.interfaces;
24
 
24
 
25
 import com.dmdirc.DMDircMBassador;
25
 import com.dmdirc.DMDircMBassador;
26
+import com.dmdirc.FrameContainer;
26
 import com.dmdirc.Topic;
27
 import com.dmdirc.Topic;
27
 
28
 
28
 import java.util.Collection;
29
 import java.util.Collection;
117
      */
118
      */
118
     Collection<GroupChatUser> getUsers();
119
     Collection<GroupChatUser> getUsers();
119
 
120
 
121
+    /**
122
+     * Gets the core model for the input/output window for this connection.
123
+     *
124
+     * @return A model for windows based on this connection.
125
+     */
126
+    FrameContainer getWindowModel();
127
+
120
 }
128
 }

+ 1
- 0
test/com/dmdirc/commandparser/parsers/CommandParserTest.java Прегледај датотеку

86
         channelCommandParser = new TestCommandParser(configProvider, commandController, eventBus);
86
         channelCommandParser = new TestCommandParser(configProvider, commandController, eventBus);
87
         channelCommandParser.registerCommand(channelCommand, channelCommandInfo);
87
         channelCommandParser.registerCommand(channelCommand, channelCommandInfo);
88
 
88
 
89
+        when(channel.getWindowModel()).thenReturn(channel);
89
         when(channel.getCommandParser()).thenReturn(channelCommandParser);
90
         when(channel.getCommandParser()).thenReturn(channelCommandParser);
90
     }
91
     }
91
 
92
 

Loading…
Откажи
Сачувај