Przeglądaj źródła

Replace Server with Connection in some more places

Also allow subclasses in ActionComponentChains.

Change-Id: I90ae66664119d1306313166af920bb892a0ec69a
Reviewed-on: http://gerrit.dmdirc.com/2936
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
tags/0.8rc1
Chris Smith 10 lat temu
rodzic
commit
5356cb2b75

+ 2
- 1
src/com/dmdirc/ChannelEventHandler.java Wyświetl plik

@@ -24,6 +24,7 @@ package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.CoreActionType;
27
+import com.dmdirc.interfaces.Connection;
27 28
 import com.dmdirc.parser.common.AwayState;
28 29
 import com.dmdirc.parser.common.CallbackManager;
29 30
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
@@ -66,7 +67,7 @@ public class ChannelEventHandler extends EventHandler implements
66 67
 
67 68
     /** {@inheritDoc} */
68 69
     @Override
69
-    protected Server getServer() {
70
+    protected Connection getConnection() {
70 71
         return owner.getServer();
71 72
     }
72 73
 

+ 10
- 9
src/com/dmdirc/EventHandler.java Wyświetl plik

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc;
24 24
 
25
+import com.dmdirc.interfaces.Connection;
25 26
 import com.dmdirc.logger.ErrorLevel;
26 27
 import com.dmdirc.logger.Logger;
27 28
 import com.dmdirc.parser.common.CallbackManager;
@@ -39,7 +40,7 @@ public abstract class EventHandler implements CallbackInterface {
39 40
      * owner's parser.
40 41
      */
41 42
     public void registerCallbacks() {
42
-        final CallbackManager cbm = getServer().getParser().getCallbackManager();
43
+        final CallbackManager cbm = getConnection().getParser().getCallbackManager();
43 44
 
44 45
         try {
45 46
             for (Class<?> iface : this.getClass().getInterfaces()) {
@@ -57,8 +58,8 @@ public abstract class EventHandler implements CallbackInterface {
57 58
      * Unregisters all callbacks that have been registered by this event handler.
58 59
      */
59 60
     public void unregisterCallbacks() {
60
-        if (getServer().getParser() != null) {
61
-            getServer().getParser().getCallbackManager().delAllCallback(this);
61
+        if (getConnection().getParser() != null) {
62
+            getConnection().getParser().getCallbackManager().delAllCallback(this);
62 63
         }
63 64
     }
64 65
 
@@ -74,12 +75,12 @@ public abstract class EventHandler implements CallbackInterface {
74 75
             final CallbackManager cbm, final Class<T> type);
75 76
 
76 77
     /**
77
-     * Retrieves the server belonging to this EventHandler's owner.
78
+     * Retrieves the connection that this event handler is for.
78 79
      *
79 80
      * @since 0.6.3m1
80
-     * @return This EventHandler's expected server
81
+     * @return This EventHandler's expected connection.
81 82
      */
82
-    protected abstract Server getServer();
83
+    protected abstract Connection getConnection();
83 84
 
84 85
     /**
85 86
      * Checks that the specified parser is the same as the one the server is
@@ -89,11 +90,11 @@ public abstract class EventHandler implements CallbackInterface {
89 90
      * @param parser The parser to check
90 91
      */
91 92
     protected void checkParser(final Parser parser) {
92
-        if (parser != getServer().getParser()) {
93
+        if (parser != getConnection().getParser()) {
93 94
             parser.disconnect("Shouldn't be in use");
94 95
             throw new IllegalArgumentException("Event called from a parser that's not in use (#"
95
-                    + getServer().getStatus().getParserID(parser)
96
-                    + ").\n\n " + getServer().getStatus().getTransitionHistory());
96
+                    + getConnection().getStatus().getParserID(parser)
97
+                    + ").\n\n " + getConnection().getStatus().getTransitionHistory());
97 98
         }
98 99
     }
99 100
 

+ 10
- 8
src/com/dmdirc/Invite.java Wyświetl plik

@@ -22,6 +22,8 @@
22 22
 
23 23
 package com.dmdirc;
24 24
 
25
+import com.dmdirc.interfaces.Connection;
26
+
25 27
 import java.util.Date;
26 28
 
27 29
 import lombok.Getter;
@@ -32,8 +34,8 @@ import lombok.Getter;
32 34
 @SuppressWarnings("PMD.UnusedPrivateField")
33 35
 public class Invite {
34 36
 
35
-    /** The server this invite was on. */
36
-    private final Server server;
37
+    /** The connection this invite was on. */
38
+    private final Connection connection;
37 39
 
38 40
     /** The channel this invite is for. */
39 41
     @Getter
@@ -49,12 +51,12 @@ public class Invite {
49 51
     /**
50 52
      * Creates a new instance of Invite.
51 53
      *
52
-     * @param server The server that this invite was received for
54
+     * @param connection The connection that this invite was received on
53 55
      * @param channel The channel that this invite is for
54 56
      * @param source The source of this invite
55 57
      */
56
-    public Invite(final Server server, final String channel, final String source) {
57
-        this.server = server;
58
+    public Invite(final Connection connection, final String channel, final String source) {
59
+        this.connection = connection;
58 60
         this.channel = channel;
59 61
         this.source = source;
60 62
         this.timestamp = new Date().getTime();
@@ -67,20 +69,20 @@ public class Invite {
67 69
      * @see Server#parseHostmask(java.lang.String)
68 70
      */
69 71
     public String[] getSource() {
70
-        return server.parseHostmask(source);
72
+        return connection.parseHostmask(source);
71 73
     }
72 74
 
73 75
     /**
74 76
      * Join the channel that belongs to this invite.
75 77
      */
76 78
     public void accept() {
77
-        server.acceptInvites(this);
79
+        connection.acceptInvites(this);
78 80
     }
79 81
 
80 82
     /**
81 83
      * Decline this invite removing it from the invite list.
82 84
      */
83 85
     public void decline() {
84
-        server.removeInvite(this);
86
+        connection.removeInvite(this);
85 87
     }
86 88
 }

+ 2
- 1
src/com/dmdirc/ServerEventHandler.java Wyświetl plik

@@ -24,6 +24,7 @@ package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.CoreActionType;
27
+import com.dmdirc.interfaces.Connection;
27 28
 import com.dmdirc.logger.ErrorLevel;
28 29
 import com.dmdirc.logger.Logger;
29 30
 import com.dmdirc.parser.common.AwayState;
@@ -76,7 +77,7 @@ public class ServerEventHandler extends EventHandler implements
76 77
 
77 78
     /** {@inheritDoc} */
78 79
     @Override
79
-    protected Server getServer() {
80
+    protected Connection getConnection() {
80 81
         return owner;
81 82
     }
82 83
 

+ 1
- 1
src/com/dmdirc/actions/ActionComponentChain.java Wyświetl plik

@@ -59,7 +59,7 @@ public class ActionComponentChain implements ActionComponent {
59 59
             if (component == null) {
60 60
                 throw new IllegalArgumentException("Component " + componentName
61 61
                         + " not found");
62
-            } else if (component.appliesTo() == current) {
62
+            } else if (component.appliesTo().isAssignableFrom(current)) {
63 63
                 components.add(component);
64 64
                 current = component.getType();
65 65
             } else {

+ 16
- 16
src/com/dmdirc/actions/CoreActionComponent.java Wyświetl plik

@@ -25,7 +25,7 @@ package com.dmdirc.actions;
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.Query;
28
-import com.dmdirc.Server;
28
+import com.dmdirc.interfaces.Connection;
29 29
 import com.dmdirc.interfaces.actions.ActionComponent;
30 30
 import com.dmdirc.interfaces.config.ConfigProvider;
31 31
 import com.dmdirc.interfaces.ui.Window;
@@ -52,10 +52,10 @@ public enum CoreActionComponent implements ActionComponent {
52 52
     SERVER_NAME {
53 53
         /** {@inheritDoc} */
54 54
         @Override
55
-        public Object get(final Object arg) { return ((Server) arg).getAddress(); }
55
+        public Object get(final Object arg) { return ((Connection) arg).getAddress(); }
56 56
         /** {@inheritDoc} */
57 57
         @Override
58
-        public Class<?> appliesTo() { return Server.class; }
58
+        public Class<?> appliesTo() { return Connection.class; }
59 59
         /** {@inheritDoc} */
60 60
         @Override
61 61
         public Class<?> getType() { return String.class; }
@@ -69,10 +69,10 @@ public enum CoreActionComponent implements ActionComponent {
69 69
         /** {@inheritDoc} */
70 70
         @Override
71 71
         @ComponentOptions(requireConnected = true)
72
-        public Object get(final Object arg) { return ((Server) arg).getNetwork(); }
72
+        public Object get(final Object arg) { return ((Connection) arg).getNetwork(); }
73 73
         /** {@inheritDoc} */
74 74
         @Override
75
-        public Class<?> appliesTo() { return Server.class; }
75
+        public Class<?> appliesTo() { return Connection.class; }
76 76
         /** {@inheritDoc} */
77 77
         @Override
78 78
         public Class<?> getType() { return String.class; }
@@ -89,10 +89,10 @@ public enum CoreActionComponent implements ActionComponent {
89 89
     SERVER_PROTOCOL {
90 90
         /** {@inheritDoc} */
91 91
         @Override
92
-        public Object get(final Object arg) { return ((Server) arg).getProtocol(); }
92
+        public Object get(final Object arg) { return ((Connection) arg).getProtocol(); }
93 93
         /** {@inheritDoc} */
94 94
         @Override
95
-        public Class<?> appliesTo() { return Server.class; }
95
+        public Class<?> appliesTo() { return Connection.class; }
96 96
         /** {@inheritDoc} */
97 97
         @Override
98 98
         public Class<?> getType() { return String.class; }
@@ -105,10 +105,10 @@ public enum CoreActionComponent implements ActionComponent {
105 105
     SERVER_MYAWAYREASON {
106 106
         /** {@inheritDoc} */
107 107
         @Override
108
-        public Object get(final Object arg) { return ((Server) arg).getAwayMessage(); }
108
+        public Object get(final Object arg) { return ((Connection) arg).getAwayMessage(); }
109 109
         /** {@inheritDoc} */
110 110
         @Override
111
-        public Class<?> appliesTo() { return Server.class; }
111
+        public Class<?> appliesTo() { return Connection.class; }
112 112
         /** {@inheritDoc} */
113 113
         @Override
114 114
         public Class<?> getType() { return String.class; }
@@ -122,10 +122,10 @@ public enum CoreActionComponent implements ActionComponent {
122 122
         /** {@inheritDoc} */
123 123
         @Override
124 124
         @ComponentOptions(requireConnected = true)
125
-        public Object get(final Object arg) { return ((Server) arg).getParser().getChannelUserModes(); }
125
+        public Object get(final Object arg) { return ((Connection) arg).getParser().getChannelUserModes(); }
126 126
         /** {@inheritDoc} */
127 127
         @Override
128
-        public Class<?> appliesTo() { return Server.class; }
128
+        public Class<?> appliesTo() { return Connection.class; }
129 129
         /** {@inheritDoc} */
130 130
         @Override
131 131
         public Class<?> getType() { return String.class; }
@@ -140,7 +140,7 @@ public enum CoreActionComponent implements ActionComponent {
140 140
         @Override
141 141
         @ComponentOptions(requireConnected = true)
142 142
         public Object get(final Object arg) {
143
-            final Server server = (Server) arg;
143
+            final Connection server = (Connection) arg;
144 144
 
145 145
             if (server == null || server.getParser() == null) {
146 146
                 Logger.appError(ErrorLevel.LOW, "SERVER_MYNICKNAME.get() called with null element",
@@ -157,7 +157,7 @@ public enum CoreActionComponent implements ActionComponent {
157 157
         }
158 158
         /** {@inheritDoc} */
159 159
         @Override
160
-        public Class<?> appliesTo() { return Server.class; }
160
+        public Class<?> appliesTo() { return Connection.class; }
161 161
         /** {@inheritDoc} */
162 162
         @Override
163 163
         public Class<?> getType() { return String.class; }
@@ -170,10 +170,10 @@ public enum CoreActionComponent implements ActionComponent {
170 170
     SERVER_PROFILE {
171 171
         /** {@inheritDoc} */
172 172
         @Override
173
-        public Object get(final Object arg) { return ((Server) arg).getProfile(); }
173
+        public Object get(final Object arg) { return ((Connection) arg).getProfile(); }
174 174
         /** {@inheritDoc} */
175 175
         @Override
176
-        public Class<?> appliesTo() { return Server.class; }
176
+        public Class<?> appliesTo() { return Connection.class; }
177 177
         /** {@inheritDoc} */
178 178
         @Override
179 179
         public Class<?> getType() { return ConfigProvider.class; }
@@ -555,7 +555,7 @@ public enum CoreActionComponent implements ActionComponent {
555 555
         public Class<?> appliesTo() { return Window.class; }
556 556
         /** {@inheritDoc} */
557 557
         @Override
558
-        public Class<?> getType() { return Server.class; }
558
+        public Class<?> getType() { return Connection.class; }
559 559
         /** {@inheritDoc} */
560 560
         @Override
561 561
         public String getName() { return "server"; }

+ 10
- 10
src/com/dmdirc/actions/metatypes/ServerEvents.java Wyświetl plik

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.actions.metatypes;
24 24
 
25
-import com.dmdirc.Server;
25
+import com.dmdirc.interfaces.Connection;
26 26
 import com.dmdirc.interfaces.actions.ActionMetaType;
27 27
 import com.dmdirc.parser.interfaces.ClientInfo;
28 28
 
@@ -32,23 +32,23 @@ import com.dmdirc.parser.interfaces.ClientInfo;
32 32
 public enum ServerEvents implements ActionMetaType {
33 33
 
34 34
     /** Server ping event type. */
35
-    SERVER_PING(new String[]{"server", "ping"}, Server.class, Long.class),
35
+    SERVER_PING(new String[]{"server", "ping"}, Connection.class, Long.class),
36 36
     /** Server numeric event type. */
37
-    SERVER_NUMERIC(new String[]{"server", "numeric", "arguments"}, Server.class, Integer.class, String[].class),
37
+    SERVER_NUMERIC(new String[]{"server", "numeric", "arguments"}, Connection.class, Integer.class, String[].class),
38 38
     /** Server event with argument. */
39
-    SERVER_EVENT_WITH_ARG(new String[]{"server", "message"}, Server.class, String.class),
39
+    SERVER_EVENT_WITH_ARG(new String[]{"server", "message"}, Connection.class, String.class),
40 40
     /** Server nick change. */
41
-    SERVER_NICKCHANGE(new String[]{"server", "old nickname", "new nickname"}, Server.class, String.class, String.class),
41
+    SERVER_NICKCHANGE(new String[]{"server", "old nickname", "new nickname"}, Connection.class, String.class, String.class),
42 42
     /** Server event, with source and argument. */
43
-    SERVER_SOURCED_EVENT_WITH_ARG(new String[]{"server", "user", "message"}, Server.class, ClientInfo.class, String.class),
43
+    SERVER_SOURCED_EVENT_WITH_ARG(new String[]{"server", "user", "message"}, Connection.class, ClientInfo.class, String.class),
44 44
     /** Server CTCP event. */
45
-    SERVER_CTCP_EVENT(new String[]{"server", "user", "type", "content"}, Server.class, ClientInfo.class, String.class, String.class),
45
+    SERVER_CTCP_EVENT(new String[]{"server", "user", "type", "content"}, Connection.class, ClientInfo.class, String.class, String.class),
46 46
     /** Server event with argument. */
47
-    SERVER_UNKNOWN_EVENT(new String[]{"server", "source", "target", "message"}, Server.class, String.class, String.class, String.class),
47
+    SERVER_UNKNOWN_EVENT(new String[]{"server", "source", "target", "message"}, Connection.class, String.class, String.class, String.class),
48 48
     /** Server invite event. */
49
-    SERVER_INVITE(new String[]{"server", "source", "channel"}, Server.class, ClientInfo.class, String.class),
49
+    SERVER_INVITE(new String[]{"server", "source", "channel"}, Connection.class, ClientInfo.class, String.class),
50 50
     /** Server event type. */
51
-    SERVER_EVENT(new String[]{"server"}, Server.class);
51
+    SERVER_EVENT(new String[]{"server"}, Connection.class);
52 52
 
53 53
     /** The names of the arguments for this meta type. */
54 54
     private String[] argNames;

+ 2
- 2
src/com/dmdirc/actions/wrappers/PerformWrapper.java Wyświetl plik

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.actions.wrappers;
24 24
 
25
-import com.dmdirc.Server;
26 25
 import com.dmdirc.actions.Action;
27 26
 import com.dmdirc.actions.ActionComponentChain;
28 27
 import com.dmdirc.actions.ActionCondition;
@@ -33,6 +32,7 @@ import com.dmdirc.actions.ConditionTree;
33 32
 import com.dmdirc.actions.CoreActionComparison;
34 33
 import com.dmdirc.actions.CoreActionComponent;
35 34
 import com.dmdirc.actions.CoreActionType;
35
+import com.dmdirc.interfaces.Connection;
36 36
 import com.dmdirc.interfaces.actions.ActionComponent;
37 37
 import com.dmdirc.interfaces.actions.ActionType;
38 38
 import com.dmdirc.logger.ErrorLevel;
@@ -230,7 +230,7 @@ public class PerformWrapper extends ActionGroup {
230 230
 
231 231
         if (profile != null) {
232 232
             conditions.add(new ActionCondition(0,
233
-                    new ActionComponentChain(Server.class, PP_COMP_NAME, ActionManager.getActionManager()),
233
+                    new ActionComponentChain(Connection.class, PP_COMP_NAME, ActionManager.getActionManager()),
234 234
                     CoreActionComparison.STRING_EQUALS, profile));
235 235
         }
236 236
 

+ 8
- 8
src/com/dmdirc/lists/GroupListManager.java Wyświetl plik

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.lists;
24 24
 
25
-import com.dmdirc.Server;
25
+import com.dmdirc.interfaces.Connection;
26 26
 import com.dmdirc.parser.common.ChannelJoinRequest;
27 27
 import com.dmdirc.parser.interfaces.Parser;
28 28
 import com.dmdirc.parser.interfaces.callbacks.GroupListEndListener;
@@ -48,8 +48,8 @@ public class GroupListManager implements GroupListStartListener,
48 48
     /** List of registered listeners. */
49 49
     private final ListenerList listenerList = new ListenerList();
50 50
 
51
-    /** The server to request group information from. */
52
-    private final Server server;
51
+    /** The connection to request group information from. */
52
+    private final Connection connection;
53 53
 
54 54
     /** The cached groups. */
55 55
     @Getter
@@ -65,10 +65,10 @@ public class GroupListManager implements GroupListStartListener,
65 65
     public void startSearch(final String searchTerm) {
66 66
         groups.clear();
67 67
 
68
-        server.getParser().getCallbackManager().addCallback(GroupListStartListener.class, this);
69
-        server.getParser().getCallbackManager().addCallback(GroupListEntryListener.class, this);
70
-        server.getParser().getCallbackManager().addCallback(GroupListEndListener.class, this);
71
-        server.getParser().requestGroupList(searchTerm);
68
+        connection.getParser().getCallbackManager().addCallback(GroupListStartListener.class, this);
69
+        connection.getParser().getCallbackManager().addCallback(GroupListEntryListener.class, this);
70
+        connection.getParser().getCallbackManager().addCallback(GroupListEndListener.class, this);
71
+        connection.getParser().requestGroupList(searchTerm);
72 72
     }
73 73
 
74 74
     /** {@inheritDoc} */
@@ -97,7 +97,7 @@ public class GroupListManager implements GroupListStartListener,
97 97
      * @param entry Group list entry to join
98 98
      */
99 99
     public void joinGroupListEntry(final GroupListEntry entry) {
100
-        server.join(new ChannelJoinRequest(entry.getName()));
100
+        connection.join(new ChannelJoinRequest(entry.getName()));
101 101
     }
102 102
 
103 103
     /**

Ładowanie…
Anuluj
Zapisz