Sfoglia il codice sorgente

Don't expose servers.

Change-Id: I5db4e866f20ca7e8d4c1ba596ef6248755f4d2ec
Depends-On: I58e485b06887b1215b4d4cba7f2244404a7b81aa
Reviewed-on: http://gerrit.dmdirc.com/3870
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
pull/1/head
Chris Smith 9 anni fa
parent
commit
54cee141ed

+ 9
- 8
src/com/dmdirc/ServerManager.java Vedi File

@@ -25,6 +25,7 @@ package com.dmdirc;
25 25
 import com.dmdirc.commandparser.parsers.ServerCommandParser;
26 26
 import com.dmdirc.events.UserErrorEvent;
27 27
 import com.dmdirc.interfaces.CommandController;
28
+import com.dmdirc.interfaces.Connection;
28 29
 import com.dmdirc.interfaces.ServerFactory;
29 30
 import com.dmdirc.interfaces.config.ConfigProvider;
30 31
 import com.dmdirc.interfaces.config.ConfigProviderMigrator;
@@ -146,8 +147,8 @@ public class ServerManager implements ServerFactory {
146 147
      *
147 148
      * @return A list of all servers
148 149
      */
149
-    public List<Server> getServers() {
150
-        return new ArrayList<>(servers);
150
+    public List<Connection> getServers() {
151
+        return new ArrayList<Connection>(servers);
151 152
     }
152 153
 
153 154
     /**
@@ -189,8 +190,8 @@ public class ServerManager implements ServerFactory {
189 190
      *
190 191
      * @return A list of servers connected to the network
191 192
      */
192
-    public List<Server> getServersByNetwork(final String network) {
193
-        final List<Server> res = new ArrayList<>();
193
+    public List<Connection> getServersByNetwork(final String network) {
194
+        final List<Connection> res = new ArrayList<>();
194 195
 
195 196
         for (Server server : servers) {
196 197
             if (server.isNetwork(network)) {
@@ -210,7 +211,7 @@ public class ServerManager implements ServerFactory {
210 211
      *
211 212
      * @since 0.6.3
212 213
      */
213
-    public Server connectToAddress(final URI uri) {
214
+    public Connection connectToAddress(final URI uri) {
214 215
         return connectToAddress(uri,
215 216
                 identityController.getProvidersByType("profile").get(0));
216 217
     }
@@ -257,11 +258,11 @@ public class ServerManager implements ServerFactory {
257 258
      * Connects the user to Quakenet if necessary and joins #DMDirc.
258 259
      */
259 260
     public void joinDevChat() {
260
-        final List<Server> qnetServers = getServersByNetwork("Quakenet");
261
+        final List<Connection> qnetServers = getServersByNetwork("Quakenet");
261 262
 
262
-        Server connectedServer = null;
263
+        Connection connectedServer = null;
263 264
 
264
-        for (Server server : qnetServers) {
265
+        for (Connection server : qnetServers) {
265 266
             if (server.getState() == ServerState.CONNECTED) {
266 267
                 connectedServer = server;
267 268
 

+ 4
- 3
src/com/dmdirc/commandparser/CommandManager.java Vedi File

@@ -23,12 +23,12 @@
23 23
 package com.dmdirc.commandparser;
24 24
 
25 25
 import com.dmdirc.Query;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.ServerManager;
28 27
 import com.dmdirc.commandparser.commands.Command;
29 28
 import com.dmdirc.commandparser.parsers.CommandParser;
30 29
 import com.dmdirc.config.ConfigBinding;
31 30
 import com.dmdirc.interfaces.CommandController;
31
+import com.dmdirc.interfaces.Connection;
32 32
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
33 33
 import com.dmdirc.ui.input.TabCompleter;
34 34
 import com.dmdirc.ui.input.TabCompletionType;
@@ -155,10 +155,11 @@ public class CommandManager implements CommandController {
155 155
         final String commandName = getCommandChar() + command.getName();
156 156
 
157 157
         // TODO: This logic is probably in two places. Abstract it.
158
-        for (Server server : serverManager.getServers()) {
158
+        for (Connection server : serverManager.getServers()) {
159 159
             if (command.getType() == CommandType.TYPE_SERVER
160 160
                     || command.getType() == CommandType.TYPE_GLOBAL) {
161
-                registerCommandName(server.getTabCompleter(), commandName, register);
161
+                registerCommandName(server.getWindowModel().getTabCompleter(),
162
+                        commandName, register);
162 163
             }
163 164
 
164 165
             if (command.getType() == CommandType.TYPE_CHANNEL

+ 4
- 3
src/com/dmdirc/commandparser/commands/global/AllServers.java Vedi File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.ServerManager;
28 27
 import com.dmdirc.commandparser.BaseCommandInfo;
29 28
 import com.dmdirc.commandparser.CommandArguments;
@@ -33,6 +32,7 @@ import com.dmdirc.commandparser.commands.Command;
33 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34 33
 import com.dmdirc.commandparser.commands.context.CommandContext;
35 34
 import com.dmdirc.interfaces.CommandController;
35
+import com.dmdirc.interfaces.Connection;
36 36
 import com.dmdirc.ui.input.AdditionalTabTargets;
37 37
 import com.dmdirc.ui.input.TabCompleterUtils;
38 38
 
@@ -68,8 +68,9 @@ public class AllServers extends Command implements IntelligentCommand {
68 68
             final CommandArguments args, final CommandContext context) {
69 69
         final String command = args.getArgumentsAsString();
70 70
 
71
-        for (Server target : serverManager.getServers()) {
72
-            target.getCommandParser().parseCommand(target, command);
71
+        for (Connection target : serverManager.getServers()) {
72
+            target.getWindowModel().getCommandParser()
73
+                    .parseCommand(target.getWindowModel(), command);
73 74
         }
74 75
     }
75 76
 

+ 2
- 2
test/com/dmdirc/ServerManagerTest.java Vedi File

@@ -206,8 +206,8 @@ public class ServerManagerTest {
206 206
 
207 207
     @Test
208 208
     public void testAddsNewServersToWindowManager() {
209
-        final Server newServer = serverManager.connectToAddress(URI.create("irc://fobar"));
210
-        verify(windowManager).addWindow(newServer);
209
+        serverManager.connectToAddress(URI.create("irc://fobar"));
210
+        verify(windowManager).addWindow(server);
211 211
     }
212 212
 
213 213
     @Test

Loading…
Annulla
Salva