Przeglądaj źródła

Merge pull request #704 from csmith/master

Replace Query with PrivateChat in Connection.
pull/705/head
Greg Holmes 7 lat temu
rodzic
commit
604d669b90

+ 5
- 4
src/main/java/com/dmdirc/Server.java Wyświetl plik

@@ -33,6 +33,7 @@ import com.dmdirc.events.ServerUnknownProtocolEvent;
33 33
 import com.dmdirc.interfaces.Connection;
34 34
 import com.dmdirc.interfaces.GroupChatManager;
35 35
 import com.dmdirc.interfaces.InviteManager;
36
+import com.dmdirc.interfaces.PrivateChat;
36 37
 import com.dmdirc.interfaces.User;
37 38
 import com.dmdirc.interfaces.WindowModel;
38 39
 import com.dmdirc.interfaces.config.ConfigChangeListener;
@@ -441,12 +442,12 @@ public class Server implements Connection {
441 442
     }
442 443
 
443 444
     @Override
444
-    public Query getQuery(final String host) {
445
+    public PrivateChat getQuery(final String host) {
445 446
         return getQuery(host, false);
446 447
     }
447 448
 
448 449
     @Override
449
-    public Query getQuery(final String host, final boolean focus) {
450
+    public PrivateChat getQuery(final String host, final boolean focus) {
450 451
         synchronized (myStateLock) {
451 452
             if (myState.getState() == ServerState.CLOSING) {
452 453
                 // Can't open queries while the server is closing
@@ -490,12 +491,12 @@ public class Server implements Connection {
490 491
     }
491 492
 
492 493
     @Override
493
-    public Collection<Query> getQueries() {
494
+    public Collection<PrivateChat> getQueries() {
494 495
         return Collections.unmodifiableCollection(queries.values());
495 496
     }
496 497
 
497 498
     @Override
498
-    public void delQuery(final Query query) {
499
+    public void delQuery(final PrivateChat query) {
499 500
         windowModel.getInputModel().get().getTabCompleter().removeEntry(
500 501
                 TabCompletionType.QUERY_NICK, query.getNickname());
501 502
         queries.remove(converter.toLowerCase(query.getNickname()));

+ 8
- 4
src/main/java/com/dmdirc/ServerEventHandler.java Wyświetl plik

@@ -142,14 +142,14 @@ public class ServerEventHandler extends EventHandler {
142 142
     @Handler
143 143
     public void onPrivateMessage(final PrivateMessageEvent event) {
144 144
         if (!owner.hasQuery(event.getHost())) {
145
-            owner.getQuery(event.getHost()).onPrivateMessage(event);
145
+            ((Query) owner.getQuery(event.getHost())).onPrivateMessage(event);
146 146
         }
147 147
     }
148 148
 
149 149
     @Handler
150 150
     public void onPrivateAction(final PrivateActionEvent event) {
151 151
         if (!owner.hasQuery(event.getHost())) {
152
-            owner.getQuery(event.getHost()).onPrivateAction(event);
152
+            ((Query) owner.getQuery(event.getHost())).onPrivateAction(event);
153 153
         }
154 154
     }
155 155
 
@@ -341,7 +341,9 @@ public class ServerEventHandler extends EventHandler {
341 341
         if (event.getParser().getLocalClient().equals(event.getParser().getClient(event.getHost()))) {
342 342
             // Local client
343 343
             eventBus.publishAsync(
344
-                    new QuerySelfMessageEvent(owner.getQuery(event.getTarget()), owner.getLocalUser().get(),
344
+                    new QuerySelfMessageEvent(
345
+                            (Query) owner.getQuery(event.getTarget()),
346
+                            owner.getLocalUser().get(),
345 347
                             event.getMessage()));
346 348
         } else {
347 349
             eventBus.publishAsync(new ServerUnknownMessageEvent(
@@ -354,7 +356,9 @@ public class ServerEventHandler extends EventHandler {
354 356
         if (event.getParser().getLocalClient().equals(event.getParser().getClient(event.getHost()))) {
355 357
             // Local client
356 358
             eventBus.publishAsync(
357
-                    new QuerySelfActionEvent(owner.getQuery(event.getTarget()), owner.getLocalUser().get(),
359
+                    new QuerySelfActionEvent(
360
+                            (Query) owner.getQuery(event.getTarget()),
361
+                            owner.getLocalUser().get(),
358 362
                             event.getMessage()));
359 363
         } else {
360 364
             eventBus.publishAsync(new ServerUnknownActionEvent(

+ 6
- 4
src/main/java/com/dmdirc/commandparser/CommandManager.java Wyświetl plik

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser;
24 24
 
25 25
 import com.dmdirc.GlobalWindow;
26
-import com.dmdirc.Query;
27 26
 import com.dmdirc.commandparser.commands.Command;
28 27
 import com.dmdirc.commandparser.parsers.CommandParser;
29 28
 import com.dmdirc.config.ConfigBinding;
@@ -31,6 +30,7 @@ import com.dmdirc.interfaces.CommandController;
31 30
 import com.dmdirc.interfaces.Connection;
32 31
 import com.dmdirc.interfaces.ConnectionManager;
33 32
 import com.dmdirc.interfaces.GroupChat;
33
+import com.dmdirc.interfaces.PrivateChat;
34 34
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
35 35
 import com.dmdirc.ui.input.TabCompleter;
36 36
 import com.dmdirc.ui.input.TabCompletionType;
@@ -197,10 +197,12 @@ public class CommandManager implements CommandController {
197 197
 
198 198
             if (command.getType() == CommandType.TYPE_QUERY
199 199
                     || command.getType() == CommandType.TYPE_CHAT) {
200
-                for (Query query : server.getQueries()) {
201
-                    registerCommandName(query.getInputModel().get().getTabCompleter(),
200
+                for (PrivateChat query : server.getQueries()) {
201
+                    registerCommandName(
202
+                            query.getWindowModel().getInputModel().get().getTabCompleter(),
202 203
                             plainCommandName, register);
203
-                    registerCommandName(query.getInputModel().get().getTabCompleter(),
204
+                    registerCommandName(
205
+                            query.getWindowModel().getInputModel().get().getTabCompleter(),
204 206
                             silencedCommandName, register);
205 207
                 }
206 208
             }

+ 2
- 2
src/main/java/com/dmdirc/commandparser/commands/server/OpenQuery.java Wyświetl plik

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25
-import com.dmdirc.Query;
26 25
 import com.dmdirc.commandparser.BaseCommandInfo;
27 26
 import com.dmdirc.commandparser.CommandArguments;
28 27
 import com.dmdirc.commandparser.CommandInfo;
@@ -35,6 +34,7 @@ import com.dmdirc.commandparser.commands.context.CommandContext;
35 34
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
36 35
 import com.dmdirc.interfaces.CommandController;
37 36
 import com.dmdirc.interfaces.Connection;
37
+import com.dmdirc.interfaces.PrivateChat;
38 38
 import com.dmdirc.interfaces.WindowModel;
39 39
 import com.dmdirc.ui.input.AdditionalTabTargets;
40 40
 import com.dmdirc.ui.input.TabCompletionType;
@@ -85,7 +85,7 @@ public class OpenQuery extends Command implements IntelligentCommand,
85 85
             return;
86 86
         }
87 87
 
88
-        final Query query = connection.getQuery(args.getArguments()[0], !args.isSilent());
88
+        final PrivateChat query = connection.getQuery(args.getArguments()[0], !args.isSilent());
89 89
 
90 90
         if (args.getArguments().length > 1) {
91 91
             query.sendLine(args.getArgumentsAsString(1), args.getArguments()[0]);

+ 4
- 5
src/main/java/com/dmdirc/interfaces/Connection.java Wyświetl plik

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.interfaces;
24 24
 
25
-import com.dmdirc.Query;
26 25
 import com.dmdirc.ServerState;
27 26
 import com.dmdirc.ServerStatus;
28 27
 import com.dmdirc.config.profiles.Profile;
@@ -75,7 +74,7 @@ public interface Connection {
75 74
      *
76 75
      * @param query The query that should be removed.
77 76
      */
78
-    void delQuery(final Query query);
77
+    void delQuery(final PrivateChat query);
79 78
 
80 79
     /**
81 80
      * Disconnects from the server with the default quit message.
@@ -167,7 +166,7 @@ public interface Connection {
167 166
      *
168 167
      * @return list of queries belonging to this server
169 168
      */
170
-    Collection<Query> getQueries();
169
+    Collection<PrivateChat> getQueries();
171 170
 
172 171
     /**
173 172
      * Retrieves the specified query belonging to this server. If the query does not yet exist, it
@@ -177,7 +176,7 @@ public interface Connection {
177 176
      *
178 177
      * @return The appropriate query object
179 178
      */
180
-    Query getQuery(final String host);
179
+    PrivateChat getQuery(final String host);
181 180
 
182 181
     /**
183 182
      * Retrieves the specified query belonging to this server. If the query does not yet exist, it
@@ -188,7 +187,7 @@ public interface Connection {
188 187
      *
189 188
      * @return The appropriate query object
190 189
      */
191
-    Query getQuery(final String host, final boolean focus);
190
+    PrivateChat getQuery(final String host, final boolean focus);
192 191
 
193 192
     /**
194 193
      * Retrieves the identity for this server.

Ładowanie…
Anuluj
Zapisz