Browse Source

Replace loads of servers with connections.

Change-Id: Ia569d12d8d53797ef7378ceab2ba1f5bda3affdc
Depends-On: I11efabb2757d8e62127b6487cbeb62d240cbd891
Reviewed-on: http://gerrit.dmdirc.com/3873
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
pull/1/head
Chris Smith 9 years ago
parent
commit
38b5e683a5

+ 12
- 12
src/com/dmdirc/commandparser/commands/context/ServerCommandContext.java View File

@@ -23,39 +23,39 @@
23 23
 package com.dmdirc.commandparser.commands.context;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.commandparser.CommandInfo;
27
+import com.dmdirc.interfaces.Connection;
28 28
 
29 29
 /**
30
- * A command context for server commands.
30
+ * A command context for connection commands.
31 31
  *
32 32
  * @since 0.6.4
33 33
  */
34 34
 public class ServerCommandContext extends CommandContext {
35 35
 
36
-    /** The server the command was executed for. */
37
-    private final Server server;
36
+    /** The connection the command was executed for. */
37
+    private final Connection connection;
38 38
 
39 39
     /**
40
-     * Creates a new server command context.
40
+     * Creates a new connection command context.
41 41
      *
42 42
      * @param source      The source of the command
43 43
      * @param commandInfo The command info object which associated the command with the input
44
-     * @param server      The server associated with the command
44
+     * @param connection      The connection associated with the command
45 45
      */
46 46
     public ServerCommandContext(final FrameContainer source, final CommandInfo commandInfo,
47
-            final Server server) {
47
+            final Connection connection) {
48 48
         super(source, commandInfo);
49
-        this.server = server;
49
+        this.connection = connection;
50 50
     }
51 51
 
52 52
     /**
53
-     * Retrieves the server associated with this context.
53
+     * Retrieves the connection associated with this context.
54 54
      *
55
-     * @return This context's server
55
+     * @return This context's connection
56 56
      */
57
-    public Server getServer() {
58
-        return server;
57
+    public Connection getConnection() {
58
+        return connection;
59 59
     }
60 60
 
61 61
 }

+ 2
- 2
src/com/dmdirc/commandparser/commands/server/AllChannels.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.commandparser.BaseCommandInfo;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29 28
 import com.dmdirc.commandparser.CommandInfo;
@@ -33,6 +32,7 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
33 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
34 33
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
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
 
@@ -62,7 +62,7 @@ public class AllChannels extends Command implements IntelligentCommand {
62 62
     @Override
63 63
     public void execute(@Nonnull final FrameContainer origin,
64 64
             final CommandArguments args, final CommandContext context) {
65
-        final Server server = ((ServerCommandContext) context).getServer();
65
+        final Connection server = ((ServerCommandContext) context).getConnection();
66 66
         final String command = args.getArgumentsAsString();
67 67
 
68 68
         for (String channel : server.getChannels()) {

+ 4
- 4
src/com/dmdirc/commandparser/commands/server/Away.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.commandparser.BaseCommandInfo;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29 28
 import com.dmdirc.commandparser.CommandInfo;
@@ -33,6 +32,7 @@ import com.dmdirc.commandparser.commands.CommandOptions;
33 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
34 33
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
35 34
 import com.dmdirc.interfaces.CommandController;
35
+import com.dmdirc.interfaces.Connection;
36 36
 
37 37
 import javax.annotation.Nonnull;
38 38
 import javax.inject.Inject;
@@ -60,13 +60,13 @@ public class Away extends Command {
60 60
     @Override
61 61
     public void execute(@Nonnull final FrameContainer origin,
62 62
             final CommandArguments args, final CommandContext context) {
63
-        final Server server = ((ServerCommandContext) context).getServer();
63
+        final Connection connection = ((ServerCommandContext) context).getConnection();
64 64
         final String line = args.getArgumentsAsString();
65 65
 
66 66
         if (line.isEmpty()) {
67
-            server.getParser().getLocalClient().setBack();
67
+            connection.getParser().getLocalClient().setBack();
68 68
         } else {
69
-            server.getParser().getLocalClient().setAway(line);
69
+            connection.getParser().getLocalClient().setAway(line);
70 70
         }
71 71
     }
72 72
 

+ 3
- 3
src/com/dmdirc/commandparser/commands/server/Back.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.commandparser.BaseCommandInfo;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29 28
 import com.dmdirc.commandparser.CommandInfo;
@@ -34,6 +33,7 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
34 33
 import com.dmdirc.commandparser.commands.context.CommandContext;
35 34
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
36 35
 import com.dmdirc.interfaces.CommandController;
36
+import com.dmdirc.interfaces.Connection;
37 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
38 38
 
39 39
 import javax.annotation.Nonnull;
@@ -62,8 +62,8 @@ public class Back extends Command implements IntelligentCommand {
62 62
     @Override
63 63
     public void execute(@Nonnull final FrameContainer origin,
64 64
             final CommandArguments args, final CommandContext context) {
65
-        final Server server = ((ServerCommandContext) context).getServer();
66
-        server.getParser().getLocalClient().setBack();
65
+        final Connection connection = ((ServerCommandContext) context).getConnection();
66
+        connection.getParser().getLocalClient().setBack();
67 67
     }
68 68
 
69 69
     @Override

+ 3
- 3
src/com/dmdirc/commandparser/commands/server/ChangeServer.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.commandparser.BaseCommandInfo;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29 28
 import com.dmdirc.commandparser.CommandInfo;
@@ -32,6 +31,7 @@ import com.dmdirc.commandparser.commands.Command;
32 31
 import com.dmdirc.commandparser.commands.context.CommandContext;
33 32
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
34 33
 import com.dmdirc.interfaces.CommandController;
34
+import com.dmdirc.interfaces.Connection;
35 35
 import com.dmdirc.util.InvalidURIException;
36 36
 import com.dmdirc.util.URIParser;
37 37
 
@@ -74,9 +74,9 @@ public class ChangeServer extends Command {
74 74
         }
75 75
 
76 76
         try {
77
-            final Server server = ((ServerCommandContext) context).getServer();
77
+            final Connection connection = ((ServerCommandContext) context).getConnection();
78 78
             final URI address = uriParser.parseFromText(args.getArgumentsAsString());
79
-            server.connect(address, server.getProfile());
79
+            connection.connect(address, connection.getProfile());
80 80
         } catch (InvalidURIException ex) {
81 81
             origin.addLine(FORMAT_ERROR, "Invalid URI: " + ex.getMessage()
82 82
                     + (ex.getCause() == null ? "" : ": " + ex.getCause().getMessage()));

+ 3
- 3
src/com/dmdirc/commandparser/commands/server/Ctcp.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.commandparser.BaseCommandInfo;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29 28
 import com.dmdirc.commandparser.CommandInfo;
@@ -34,6 +33,7 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
34 33
 import com.dmdirc.commandparser.commands.context.CommandContext;
35 34
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
36 35
 import com.dmdirc.interfaces.CommandController;
36
+import com.dmdirc.interfaces.Connection;
37 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
38 38
 import com.dmdirc.ui.input.TabCompletionType;
39 39
 
@@ -64,11 +64,11 @@ public class Ctcp extends Command implements IntelligentCommand {
64 64
     @Override
65 65
     public void execute(@Nonnull final FrameContainer origin,
66 66
             final CommandArguments args, final CommandContext context) {
67
-        final Server server = ((ServerCommandContext) context).getServer();
67
+        final Connection connection = ((ServerCommandContext) context).getConnection();
68 68
         if (args.getArguments().length < 2) {
69 69
             showUsage(origin, args.isSilent(), "ctcp", "<target> <type> [arguments]");
70 70
         } else {
71
-            server.getParser().sendCTCP(args.getArguments()[0],
71
+            connection.getParser().sendCTCP(args.getArguments()[0],
72 72
                     args.getArguments()[1], args.getArgumentsAsString(2));
73 73
             sendLine(origin, args.isSilent(), "selfCTCP", args.getArguments()[0],
74 74
                     args.getArgumentsAsString(1));

+ 3
- 3
src/com/dmdirc/commandparser/commands/server/Disconnect.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.commandparser.BaseCommandInfo;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29 28
 import com.dmdirc.commandparser.CommandInfo;
@@ -32,6 +31,7 @@ import com.dmdirc.commandparser.commands.Command;
32 31
 import com.dmdirc.commandparser.commands.context.CommandContext;
33 32
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
34 33
 import com.dmdirc.interfaces.CommandController;
34
+import com.dmdirc.interfaces.Connection;
35 35
 
36 36
 import javax.annotation.Nonnull;
37 37
 import javax.inject.Inject;
@@ -59,7 +59,7 @@ public class Disconnect extends Command {
59 59
     @Override
60 60
     public void execute(@Nonnull final FrameContainer origin,
61 61
             final CommandArguments args, final CommandContext context) {
62
-        final Server server = ((ServerCommandContext) context).getServer();
62
+        final Connection connection = ((ServerCommandContext) context).getConnection();
63 63
         final String line;
64 64
 
65 65
         if (args.getArguments().length == 0) {
@@ -68,7 +68,7 @@ public class Disconnect extends Command {
68 68
             line = args.getArgumentsAsString();
69 69
         }
70 70
 
71
-        server.disconnect(line);
71
+        connection.disconnect(line);
72 72
     }
73 73
 
74 74
 }

+ 21
- 21
src/com/dmdirc/commandparser/commands/server/Ignore.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.commandparser.BaseCommandInfo;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29 28
 import com.dmdirc.commandparser.CommandInfo;
@@ -33,6 +32,7 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
33 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
34 33
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
35 34
 import com.dmdirc.interfaces.CommandController;
35
+import com.dmdirc.interfaces.Connection;
36 36
 import com.dmdirc.parser.common.IgnoreList;
37 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
38 38
 import com.dmdirc.ui.input.TabCompletionType;
@@ -67,22 +67,22 @@ public class Ignore extends Command implements IntelligentCommand {
67 67
     @Override
68 68
     public void execute(@Nonnull final FrameContainer origin,
69 69
             final CommandArguments args, final CommandContext context) {
70
-        final Server server = ((ServerCommandContext) context).getServer();
70
+        final Connection connection = ((ServerCommandContext) context).getConnection();
71 71
 
72 72
         if (args.getArguments().length == 0) {
73
-            executeView(origin, server, args.isSilent(), args, false);
73
+            executeView(origin, connection, args.isSilent(), args, false);
74 74
         } else if ("--remove".equalsIgnoreCase(args.getArguments()[0])) {
75
-            executeRemove(origin, server, args.isSilent(), args);
75
+            executeRemove(origin, connection, args.isSilent(), args);
76 76
         } else if ("--regex".equalsIgnoreCase(args.getArguments()[0])) {
77
-            executeRegex(origin, server, args.isSilent(), args);
77
+            executeRegex(origin, connection, args.isSilent(), args);
78 78
         } else {
79
-            executeAdd(origin, server, args.isSilent(), args);
79
+            executeAdd(origin, connection, args.isSilent(), args);
80 80
         }
81 81
     }
82 82
 
83
-    protected void executeView(final FrameContainer origin, final Server server,
83
+    protected void executeView(final FrameContainer origin, final Connection connection,
84 84
             final boolean isSilent, final CommandArguments args, final boolean forceRegex) {
85
-        final IgnoreList ignoreList = server.getIgnoreList();
85
+        final IgnoreList ignoreList = connection.getIgnoreList();
86 86
 
87 87
         if (ignoreList.count() == 0) {
88 88
             sendLine(origin, args.isSilent(), FORMAT_ERROR,
@@ -108,24 +108,24 @@ public class Ignore extends Command implements IntelligentCommand {
108 108
         }
109 109
     }
110 110
 
111
-    protected void executeAdd(final FrameContainer origin, final Server server,
111
+    protected void executeAdd(final FrameContainer origin, final Connection connection,
112 112
             final boolean isSilent, final CommandArguments args) {
113
-        final IgnoreList ignoreList = server.getIgnoreList();
113
+        final IgnoreList ignoreList = connection.getIgnoreList();
114 114
         final String target = args.getArgumentsAsString();
115 115
 
116 116
         ignoreList.addSimple(target);
117
-        server.saveIgnoreList();
117
+        connection.saveIgnoreList();
118 118
         sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Added " + target + " to the ignore list.");
119 119
     }
120 120
 
121
-    protected void executeRegex(final FrameContainer origin, final Server server,
121
+    protected void executeRegex(final FrameContainer origin, final Connection connection,
122 122
             final boolean isSilent, final CommandArguments args) {
123 123
         if (args.getArguments().length == 1) {
124
-            executeView(origin, server, args.isSilent(), args, true);
124
+            executeView(origin, connection, args.isSilent(), args, true);
125 125
             return;
126 126
         }
127 127
 
128
-        final IgnoreList ignoreList = server.getIgnoreList();
128
+        final IgnoreList ignoreList = connection.getIgnoreList();
129 129
         final String target = args.getArgumentsAsString(1);
130 130
 
131 131
         try {
@@ -138,23 +138,23 @@ public class Ignore extends Command implements IntelligentCommand {
138 138
         }
139 139
 
140 140
         ignoreList.add(target);
141
-        server.saveIgnoreList();
141
+        connection.saveIgnoreList();
142 142
         sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Added " + target + " to the ignore list.");
143 143
     }
144 144
 
145
-    protected void executeRemove(final FrameContainer origin, final Server server,
145
+    protected void executeRemove(final FrameContainer origin, final Connection connection,
146 146
             final boolean isSilent, final CommandArguments args) {
147 147
         if (args.getArguments().length == 1) {
148 148
             showUsage(origin, args.isSilent(), "ignore", "--remove <host>");
149 149
             return;
150 150
         }
151 151
 
152
-        final IgnoreList ignoreList = server.getIgnoreList();
152
+        final IgnoreList ignoreList = connection.getIgnoreList();
153 153
         final String host = args.getArgumentsAsString(1);
154 154
 
155 155
         if (ignoreList.canConvert() && ignoreList.getSimpleList().contains(host)) {
156 156
             ignoreList.remove(ignoreList.getSimpleList().indexOf(host));
157
-            server.saveIgnoreList();
157
+            connection.saveIgnoreList();
158 158
             sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Removed " + host
159 159
                     + " from the ignore list.");
160 160
             return;
@@ -162,7 +162,7 @@ public class Ignore extends Command implements IntelligentCommand {
162 162
 
163 163
         if (ignoreList.getRegexList().contains(host)) {
164 164
             ignoreList.remove(ignoreList.getRegexList().indexOf(host));
165
-            server.saveIgnoreList();
165
+            connection.saveIgnoreList();
166 166
             sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Removed " + host
167 167
                     + " from the ignore list.");
168 168
             return;
@@ -183,7 +183,7 @@ public class Ignore extends Command implements IntelligentCommand {
183 183
             targets.add("--remove");
184 184
             targets.include(TabCompletionType.CHANNEL_NICK);
185 185
             targets.include(TabCompletionType.QUERY_NICK);
186
-        } else if (arg == 1 && context.getPreviousArgs().get(0).equals("--remove")) {
186
+        } else if (arg == 1 && "--remove".equals(context.getPreviousArgs().get(0))) {
187 187
             final IgnoreList ignoreList = context.getWindow().getConnection()
188 188
                     .getIgnoreList();
189 189
             if (ignoreList.canConvert()) {
@@ -195,7 +195,7 @@ public class Ignore extends Command implements IntelligentCommand {
195 195
                 targets.add(entry);
196 196
             }
197 197
 
198
-        } else if (arg == 1 && context.getPreviousArgs().get(0).equals("--regex")) {
198
+        } else if (arg == 1 && "--regex".equals(context.getPreviousArgs().get(0))) {
199 199
             targets.include(TabCompletionType.CHANNEL_NICK);
200 200
             targets.include(TabCompletionType.QUERY_NICK);
201 201
         }

+ 2
- 3
src/com/dmdirc/commandparser/commands/server/JoinChannelCommand.java View File

@@ -24,7 +24,6 @@ package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.DMDircMBassador;
26 26
 import com.dmdirc.FrameContainer;
27
-import com.dmdirc.Server;
28 27
 import com.dmdirc.commandparser.BaseCommandInfo;
29 28
 import com.dmdirc.commandparser.CommandArguments;
30 29
 import com.dmdirc.commandparser.CommandInfo;
@@ -82,7 +81,7 @@ public class JoinChannelCommand extends Command implements IntelligentCommand {
82 81
     @Override
83 82
     public void execute(@Nonnull final FrameContainer origin,
84 83
             final CommandArguments args, final CommandContext context) {
85
-        final Server server = ((ServerCommandContext) context).getServer();
84
+        final Connection connection = ((ServerCommandContext) context).getConnection();
86 85
         if (args.getArguments().length == 0) {
87 86
             showUsage(origin, args.isSilent(), "join", "join <channel [key]>[,channel [key]...]");
88 87
             return;
@@ -101,7 +100,7 @@ public class JoinChannelCommand extends Command implements IntelligentCommand {
101 100
             }
102 101
         }
103 102
 
104
-        server.join(!args.isSilent(), channels.toArray(new ChannelJoinRequest[channels.size()]));
103
+        connection.join(!args.isSilent(), channels.toArray(new ChannelJoinRequest[channels.size()]));
105 104
     }
106 105
 
107 106
     @Handler

+ 9
- 9
src/com/dmdirc/commandparser/commands/server/Message.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.commandparser.BaseCommandInfo;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29 28
 import com.dmdirc.commandparser.CommandInfo;
@@ -35,6 +34,7 @@ import com.dmdirc.commandparser.commands.WrappableCommand;
35 34
 import com.dmdirc.commandparser.commands.context.CommandContext;
36 35
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
37 36
 import com.dmdirc.interfaces.CommandController;
37
+import com.dmdirc.interfaces.Connection;
38 38
 import com.dmdirc.parser.interfaces.Parser;
39 39
 import com.dmdirc.ui.input.AdditionalTabTargets;
40 40
 import com.dmdirc.ui.input.TabCompletionType;
@@ -67,7 +67,7 @@ public class Message extends Command implements IntelligentCommand,
67 67
     @Override
68 68
     public void execute(@Nonnull final FrameContainer origin,
69 69
             final CommandArguments args, final CommandContext context) {
70
-        final Server server = ((ServerCommandContext) context).getServer();
70
+        final Connection connection = ((ServerCommandContext) context).getConnection();
71 71
         if (args.getArguments().length < 2) {
72 72
             showUsage(origin, args.isSilent(), "msg", "<target> <message>");
73 73
         } else {
@@ -77,12 +77,12 @@ public class Message extends Command implements IntelligentCommand,
77 77
 
78 78
             // If this is a known server or channel, and this is not a silent
79 79
             // invocation, use sendLine, else send it raw to the parser.
80
-            if (!args.isSilent() && server.hasChannel(target)) {
81
-                server.getChannel(target).sendLine(message);
82
-            } else if (!args.isSilent() && server.hasQuery(target)) {
83
-                server.getQuery(target).sendLine(message, target);
80
+            if (!args.isSilent() && connection.hasChannel(target)) {
81
+                connection.getChannel(target).sendLine(message);
82
+            } else if (!args.isSilent() && connection.hasQuery(target)) {
83
+                connection.getQuery(target).sendLine(message, target);
84 84
             } else {
85
-                final Parser parser = server.getParser();
85
+                final Parser parser = connection.getParser();
86 86
 
87 87
                 if (parser == null) {
88 88
                     // This can happen if the server gets disconnected after
@@ -116,8 +116,8 @@ public class Message extends Command implements IntelligentCommand,
116 116
     public int getLineCount(final FrameContainer origin, final CommandArguments arguments) {
117 117
         if (arguments.getArguments().length >= 2) {
118 118
             final String target = arguments.getArguments()[0];
119
-            return ((Server) origin.getConnection()).getNumLines("PRIVMSG "
120
-                    + target + " :" + arguments.getArgumentsAsString(1));
119
+            return origin.getConnection().getWindowModel().getNumLines(
120
+                    "PRIVMSG " + target + " :" + arguments.getArgumentsAsString(1));
121 121
         } else {
122 122
             return 1;
123 123
         }

+ 3
- 3
src/com/dmdirc/commandparser/commands/server/Nick.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.commandparser.BaseCommandInfo;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29 28
 import com.dmdirc.commandparser.CommandInfo;
@@ -34,6 +33,7 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
34 33
 import com.dmdirc.commandparser.commands.context.CommandContext;
35 34
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
36 35
 import com.dmdirc.interfaces.CommandController;
36
+import com.dmdirc.interfaces.Connection;
37 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
38 38
 import com.dmdirc.ui.input.TabCompletionType;
39 39
 
@@ -64,13 +64,13 @@ public class Nick extends Command implements IntelligentCommand {
64 64
     @Override
65 65
     public void execute(@Nonnull final FrameContainer origin,
66 66
             final CommandArguments args, final CommandContext context) {
67
-        final Server server = ((ServerCommandContext) context).getServer();
67
+        final Connection connection = ((ServerCommandContext) context).getConnection();
68 68
         if (args.getArguments().length == 0) {
69 69
             showUsage(origin, args.isSilent(), "nick", "<new nickname>");
70 70
             return;
71 71
         }
72 72
 
73
-        server.getParser().getLocalClient().setNickname(args.getArguments()[0]);
73
+        connection.getParser().getLocalClient().setNickname(args.getArguments()[0]);
74 74
     }
75 75
 
76 76
     @Override

+ 3
- 3
src/com/dmdirc/commandparser/commands/server/Notice.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.commandparser.BaseCommandInfo;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29 28
 import com.dmdirc.commandparser.CommandInfo;
@@ -34,6 +33,7 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
34 33
 import com.dmdirc.commandparser.commands.context.CommandContext;
35 34
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
36 35
 import com.dmdirc.interfaces.CommandController;
36
+import com.dmdirc.interfaces.Connection;
37 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
38 38
 import com.dmdirc.ui.input.TabCompletionType;
39 39
 
@@ -64,11 +64,11 @@ public class Notice extends Command implements IntelligentCommand {
64 64
     @Override
65 65
     public void execute(@Nonnull final FrameContainer origin,
66 66
             final CommandArguments args, final CommandContext context) {
67
-        final Server server = ((ServerCommandContext) context).getServer();
67
+        final Connection connection = ((ServerCommandContext) context).getConnection();
68 68
         if (args.getArguments().length < 2) {
69 69
             showUsage(origin, args.isSilent(), "notice", "<target> <message>");
70 70
         } else {
71
-            server.getParser().sendNotice(args.getArguments()[0],
71
+            connection.getParser().sendNotice(args.getArguments()[0],
72 72
                     args.getArgumentsAsString(1));
73 73
             sendLine(origin, args.isSilent(), "selfNotice", args.getArguments()[0],
74 74
                     args.getArgumentsAsString(1));

+ 5
- 5
src/com/dmdirc/commandparser/commands/server/OpenQuery.java View File

@@ -24,7 +24,6 @@ package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Query;
27
-import com.dmdirc.Server;
28 27
 import com.dmdirc.commandparser.BaseCommandInfo;
29 28
 import com.dmdirc.commandparser.CommandArguments;
30 29
 import com.dmdirc.commandparser.CommandInfo;
@@ -35,6 +34,7 @@ import com.dmdirc.commandparser.commands.WrappableCommand;
35 34
 import com.dmdirc.commandparser.commands.context.CommandContext;
36 35
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
37 36
 import com.dmdirc.interfaces.CommandController;
37
+import com.dmdirc.interfaces.Connection;
38 38
 import com.dmdirc.ui.input.AdditionalTabTargets;
39 39
 import com.dmdirc.ui.input.TabCompletionType;
40 40
 import com.dmdirc.ui.messages.Styliser;
@@ -71,8 +71,8 @@ public class OpenQuery extends Command implements IntelligentCommand,
71 71
             return;
72 72
         }
73 73
 
74
-        final Server server = ((ServerCommandContext) context).getServer();
75
-        if (server.getParser().isValidChannelName(args.getArguments()[0])) {
74
+        final Connection connection = ((ServerCommandContext) context).getConnection();
75
+        if (connection.getParser().isValidChannelName(args.getArguments()[0])) {
76 76
             sendLine(origin, args.isSilent(), FORMAT_ERROR, "You can't open a query "
77 77
                     + "with a channel; maybe you meant " + Styliser.CODE_FIXED
78 78
                     + Styliser.CODE_BOLD
@@ -83,7 +83,7 @@ public class OpenQuery extends Command implements IntelligentCommand,
83 83
             return;
84 84
         }
85 85
 
86
-        final Query query = server.getQuery(args.getArguments()[0], !args.isSilent());
86
+        final Query query = connection.getQuery(args.getArguments()[0], !args.isSilent());
87 87
 
88 88
         if (args.getArguments().length > 1) {
89 89
             query.sendLine(args.getArgumentsAsString(1), args.getArguments()[0]);
@@ -113,7 +113,7 @@ public class OpenQuery extends Command implements IntelligentCommand,
113 113
     public int getLineCount(final FrameContainer origin, final CommandArguments arguments) {
114 114
         if (arguments.getArguments().length >= 2) {
115 115
             final String target = arguments.getArguments()[0];
116
-            return ((Server) origin.getConnection()).getNumLines("PRIVMSG "
116
+            return ((Connection) origin.getConnection()).getWindowModel().getNumLines("PRIVMSG "
117 117
                     + target + " :" + arguments.getArgumentsAsString(1));
118 118
         } else {
119 119
             return 1;

+ 3
- 3
src/com/dmdirc/commandparser/commands/server/Raw.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.commandparser.BaseCommandInfo;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29 28
 import com.dmdirc.commandparser.CommandInfo;
@@ -33,6 +32,7 @@ import com.dmdirc.commandparser.commands.CommandOptions;
33 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
34 33
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
35 34
 import com.dmdirc.interfaces.CommandController;
35
+import com.dmdirc.interfaces.Connection;
36 36
 
37 37
 import javax.annotation.Nonnull;
38 38
 import javax.inject.Inject;
@@ -61,10 +61,10 @@ public class Raw extends Command {
61 61
     @Override
62 62
     public void execute(@Nonnull final FrameContainer origin,
63 63
             final CommandArguments args, final CommandContext context) {
64
-        final Server server = ((ServerCommandContext) context).getServer();
64
+        final Connection connection = ((ServerCommandContext) context).getConnection();
65 65
         final String line = args.getArgumentsAsString();
66 66
 
67
-        server.getParser().sendRawMessage(line);
67
+        connection.getParser().sendRawMessage(line);
68 68
         sendLine(origin, args.isSilent(), "rawCommand", line);
69 69
     }
70 70
 

+ 4
- 3
src/com/dmdirc/commandparser/commands/server/RawServerCommand.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.commandparser.CommandArguments;
28 27
 import com.dmdirc.commandparser.CommandInfo;
29 28
 import com.dmdirc.commandparser.CommandType;
@@ -32,6 +31,7 @@ import com.dmdirc.commandparser.commands.CommandOptions;
32 31
 import com.dmdirc.commandparser.commands.context.CommandContext;
33 32
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
34 33
 import com.dmdirc.interfaces.CommandController;
34
+import com.dmdirc.interfaces.Connection;
35 35
 
36 36
 import javax.annotation.Nonnull;
37 37
 
@@ -58,8 +58,9 @@ public class RawServerCommand extends Command implements CommandInfo {
58 58
     @Override
59 59
     public void execute(@Nonnull final FrameContainer origin,
60 60
             final CommandArguments args, final CommandContext context) {
61
-        final Server server = ((ServerCommandContext) context).getServer();
62
-        server.getParser().sendRawMessage(myName.toUpperCase() + " " + args.getArgumentsAsString());
61
+        final Connection connection = ((ServerCommandContext) context).getConnection();
62
+        connection.getParser().sendRawMessage(myName.toUpperCase() + ' '
63
+                + args.getArgumentsAsString());
63 64
     }
64 65
 
65 66
     @Override

+ 3
- 3
src/com/dmdirc/commandparser/commands/server/Reconnect.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.commandparser.BaseCommandInfo;
28 27
 import com.dmdirc.commandparser.CommandArguments;
29 28
 import com.dmdirc.commandparser.CommandInfo;
@@ -32,6 +31,7 @@ import com.dmdirc.commandparser.commands.Command;
32 31
 import com.dmdirc.commandparser.commands.context.CommandContext;
33 32
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
34 33
 import com.dmdirc.interfaces.CommandController;
34
+import com.dmdirc.interfaces.Connection;
35 35
 
36 36
 import javax.annotation.Nonnull;
37 37
 import javax.inject.Inject;
@@ -59,7 +59,7 @@ public class Reconnect extends Command {
59 59
     @Override
60 60
     public void execute(@Nonnull final FrameContainer origin,
61 61
             final CommandArguments args, final CommandContext context) {
62
-        final Server server = ((ServerCommandContext) context).getServer();
62
+        final Connection connection = ((ServerCommandContext) context).getConnection();
63 63
         final String line;
64 64
 
65 65
         if (args.getArguments().length == 0) {
@@ -68,7 +68,7 @@ public class Reconnect extends Command {
68 68
             line = args.getArgumentsAsString();
69 69
         }
70 70
 
71
-        server.reconnect(line);
71
+        connection.reconnect(line);
72 72
     }
73 73
 
74 74
 }

+ 5
- 5
src/com/dmdirc/commandparser/commands/server/Umode.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27 26
 import com.dmdirc.ServerState;
28 27
 import com.dmdirc.commandparser.BaseCommandInfo;
29 28
 import com.dmdirc.commandparser.CommandArguments;
@@ -34,6 +33,7 @@ import com.dmdirc.commandparser.commands.CommandOptions;
34 33
 import com.dmdirc.commandparser.commands.context.CommandContext;
35 34
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
36 35
 import com.dmdirc.interfaces.CommandController;
36
+import com.dmdirc.interfaces.Connection;
37 37
 
38 38
 import javax.annotation.Nonnull;
39 39
 import javax.inject.Inject;
@@ -62,14 +62,14 @@ public class Umode extends Command {
62 62
     @Override
63 63
     public void execute(@Nonnull final FrameContainer origin,
64 64
             final CommandArguments args, final CommandContext context) {
65
-        final Server server = ((ServerCommandContext) context).getServer();
66
-        if (server.getState() != ServerState.CONNECTED) {
65
+        final Connection connection = ((ServerCommandContext) context).getConnection();
66
+        if (connection.getState() != ServerState.CONNECTED) {
67 67
             sendLine(origin, args.isSilent(), FORMAT_ERROR, "Not connected");
68 68
             return;
69 69
         }
70 70
 
71
-        server.getParser().sendRawMessage("MODE "
72
-                + server.getParser().getLocalClient().getNickname()
71
+        connection.getParser().sendRawMessage("MODE "
72
+                + connection.getParser().getLocalClient().getNickname()
73 73
                 + " " + args.getArgumentsAsString());
74 74
     }
75 75
 

+ 2
- 1
src/com/dmdirc/interfaces/Connection.java View File

@@ -33,6 +33,7 @@ import com.dmdirc.parser.common.ChannelJoinRequest;
33 33
 import com.dmdirc.parser.common.IgnoreList;
34 34
 import com.dmdirc.parser.interfaces.ChannelInfo;
35 35
 import com.dmdirc.parser.interfaces.Parser;
36
+import com.dmdirc.parser.interfaces.ProtocolDescription;
36 37
 import com.dmdirc.tls.CertificateProblemListener;
37 38
 
38 39
 import java.net.URI;
@@ -409,7 +410,7 @@ public interface Connection {
409 410
      * Parses the specified hostmask in a manner prescribed by the protocol currently used by this
410 411
      * server.
411 412
      *
412
-     * @see com.dmdirc.parser.interfaces.ProtocolDescription#parseHostmask(java.lang.String)
413
+     * @see ProtocolDescription#parseHostmask(String)
413 414
      * @param hostmask The hostmask to be parsed
414 415
      *
415 416
      * @return An array containing the nickname, username and hostname

+ 9
- 8
test/com/dmdirc/commandparser/commands/global/NewServerTest.java View File

@@ -22,10 +22,10 @@
22 22
 package com.dmdirc.commandparser.commands.global;
23 23
 
24 24
 import com.dmdirc.FrameContainer;
25
-import com.dmdirc.Server;
26 25
 import com.dmdirc.commandparser.CommandArguments;
27 26
 import com.dmdirc.commandparser.commands.context.CommandContext;
28 27
 import com.dmdirc.interfaces.CommandController;
28
+import com.dmdirc.interfaces.Connection;
29 29
 import com.dmdirc.interfaces.ConnectionFactory;
30 30
 import com.dmdirc.interfaces.config.ConfigProvider;
31 31
 import com.dmdirc.interfaces.config.IdentityController;
@@ -34,7 +34,7 @@ import com.dmdirc.util.URIParser;
34 34
 
35 35
 import java.net.URI;
36 36
 import java.net.URISyntaxException;
37
-import java.util.Arrays;
37
+import java.util.Collections;
38 38
 
39 39
 import org.junit.Before;
40 40
 import org.junit.Test;
@@ -58,13 +58,14 @@ public class NewServerTest {
58 58
     @Mock private FrameContainer container;
59 59
     @Mock private PluginManager pluginManager;
60 60
     @Mock private ConnectionFactory factory;
61
-    @Mock private Server server;
61
+    @Mock private Connection connection;
62 62
     private NewServer command;
63 63
 
64 64
     @Before
65 65
     public void setup() {
66
-        when(factory.createServer(any(URI.class), any(ConfigProvider.class))).thenReturn(server);
67
-        when(identityController.getProvidersByType("profile")).thenReturn(Arrays.asList(new ConfigProvider[] { identity }));
66
+        when(factory.createServer(any(URI.class), any(ConfigProvider.class))).thenReturn(connection);
67
+        when(identityController.getProvidersByType("profile")).thenReturn(
68
+                Collections.singletonList(identity));
68 69
         command = new NewServer(controller, factory, pluginManager, identityController, new URIParser());
69 70
     }
70 71
 
@@ -74,7 +75,7 @@ public class NewServerTest {
74 75
                 new CommandContext(null, NewServer.INFO));
75 76
 
76 77
         verify(factory).createServer(eq(new URI("irc://irc.foo.com")), any(ConfigProvider.class));
77
-        verify(server).connect();
78
+        verify(connection).connect();
78 79
     }
79 80
 
80 81
     @Test
@@ -83,7 +84,7 @@ public class NewServerTest {
83 84
                 new CommandContext(null, NewServer.INFO));
84 85
 
85 86
         verify(factory).createServer(eq(new URI("irc://irc.foo.com:1234")), any(ConfigProvider.class));
86
-        verify(server).connect();
87
+        verify(connection).connect();
87 88
     }
88 89
 
89 90
     @Test
@@ -92,7 +93,7 @@ public class NewServerTest {
92 93
                 new CommandContext(null, NewServer.INFO));
93 94
 
94 95
         verify(factory).createServer(eq(new URI("otheruri://foo.com:123/blah")), any(ConfigProvider.class));
95
-        verify(server).connect();
96
+        verify(connection).connect();
96 97
     }
97 98
 
98 99
     @Test

Loading…
Cancel
Save