|
@@ -29,11 +29,11 @@ import com.dmdirc.commandparser.CommandType;
|
29
|
29
|
import com.dmdirc.commandparser.parsers.CommandParser;
|
30
|
30
|
import com.dmdirc.config.ConfigManager;
|
31
|
31
|
import com.dmdirc.config.Identity;
|
32
|
|
-import com.dmdirc.config.IdentityManager;
|
33
|
32
|
import com.dmdirc.interfaces.AwayStateListener;
|
34
|
33
|
import com.dmdirc.interfaces.CommandController;
|
35
|
34
|
import com.dmdirc.interfaces.ConfigChangeListener;
|
36
|
35
|
import com.dmdirc.interfaces.Connection;
|
|
36
|
+import com.dmdirc.interfaces.IdentityFactory;
|
37
|
37
|
import com.dmdirc.interfaces.InviteListener;
|
38
|
38
|
import com.dmdirc.logger.ErrorLevel;
|
39
|
39
|
import com.dmdirc.logger.Logger;
|
|
@@ -109,10 +109,10 @@ public class Server extends WritableFrameContainer
|
109
|
109
|
// <editor-fold defaultstate="collapsed" desc="Instance">
|
110
|
110
|
|
111
|
111
|
/** Open channels that currently exist on the server. */
|
112
|
|
- private final Map<String, Channel> channels = new ConcurrentSkipListMap<String, Channel>();
|
|
112
|
+ private final Map<String, Channel> channels = new ConcurrentSkipListMap<>();
|
113
|
113
|
|
114
|
114
|
/** Open query windows on the server. */
|
115
|
|
- private final Map<String, Query> queries = new ConcurrentSkipListMap<String, Query>();
|
|
115
|
+ private final Map<String, Query> queries = new ConcurrentSkipListMap<>();
|
116
|
116
|
|
117
|
117
|
/** The Parser instance handling this server. */
|
118
|
118
|
private Parser parser;
|
|
@@ -163,10 +163,10 @@ public class Server extends WritableFrameContainer
|
163
|
163
|
private final ServerEventHandler eventHandler = new ServerEventHandler(this);
|
164
|
164
|
|
165
|
165
|
/** A list of outstanding invites. */
|
166
|
|
- private final List<Invite> invites = new ArrayList<Invite>();
|
|
166
|
+ private final List<Invite> invites = new ArrayList<>();
|
167
|
167
|
|
168
|
168
|
/** A set of channels we want to join without focusing. */
|
169
|
|
- private final Set<String> backgroundChannels = new HashSet<String>();
|
|
169
|
+ private final Set<String> backgroundChannels = new HashSet<>();
|
170
|
170
|
|
171
|
171
|
/** Our ignore list. */
|
172
|
172
|
private final IgnoreList ignoreList = new IgnoreList();
|
|
@@ -183,6 +183,9 @@ public class Server extends WritableFrameContainer
|
183
|
183
|
/** ServerManager that created us. */
|
184
|
184
|
private final ServerManager manager;
|
185
|
185
|
|
|
186
|
+ /** Factory to use to create new identities. */
|
|
187
|
+ private final IdentityFactory identityFactory;
|
|
188
|
+
|
186
|
189
|
// </editor-fold>
|
187
|
190
|
|
188
|
191
|
// </editor-fold>
|
|
@@ -201,6 +204,7 @@ public class Server extends WritableFrameContainer
|
201
|
204
|
* @param windowManager The window manager to register this server with.
|
202
|
205
|
* @param aliasWrapper The actions wrapper to retrieve aliases from.
|
203
|
206
|
* @param commandController The controller to use to retrieve commands.
|
|
207
|
+ * @param identityFactory The factory to use to create identities.
|
204
|
208
|
* @param uri The address of the server to connect to
|
205
|
209
|
* @param profile The profile to use
|
206
|
210
|
*/
|
|
@@ -212,6 +216,7 @@ public class Server extends WritableFrameContainer
|
212
|
216
|
final WindowManager windowManager,
|
213
|
217
|
final AliasWrapper aliasWrapper,
|
214
|
218
|
final CommandController commandController,
|
|
219
|
+ final IdentityFactory identityFactory,
|
215
|
220
|
final URI uri,
|
216
|
221
|
final Identity profile) {
|
217
|
222
|
super("server-disconnected",
|
|
@@ -225,6 +230,7 @@ public class Server extends WritableFrameContainer
|
225
|
230
|
|
226
|
231
|
this.manager = manager;
|
227
|
232
|
this.parserFactory = parserFactory;
|
|
233
|
+ this.identityFactory = identityFactory;
|
228
|
234
|
setConnectionDetails(uri, profile);
|
229
|
235
|
|
230
|
236
|
manager.registerServer(this);
|
|
@@ -517,7 +523,7 @@ public class Server extends WritableFrameContainer
|
517
|
523
|
/** {@inheritDoc} */
|
518
|
524
|
@Override
|
519
|
525
|
public List<String> getChannels() {
|
520
|
|
- return new ArrayList<String>(channels.keySet());
|
|
526
|
+ return new ArrayList<>(channels.keySet());
|
521
|
527
|
}
|
522
|
528
|
|
523
|
529
|
/** {@inheritDoc} */
|
|
@@ -651,7 +657,7 @@ public class Server extends WritableFrameContainer
|
651
|
657
|
* Closes all open channel windows associated with this server.
|
652
|
658
|
*/
|
653
|
659
|
private void closeChannels() {
|
654
|
|
- for (Channel channel : new ArrayList<Channel>(channels.values())) {
|
|
660
|
+ for (Channel channel : new ArrayList<>(channels.values())) {
|
655
|
661
|
channel.close();
|
656
|
662
|
}
|
657
|
663
|
}
|
|
@@ -669,7 +675,7 @@ public class Server extends WritableFrameContainer
|
669
|
675
|
* Closes all open query windows associated with this server.
|
670
|
676
|
*/
|
671
|
677
|
private void closeQueries() {
|
672
|
|
- for (Query query : new ArrayList<Query>(queries.values())) {
|
|
678
|
+ for (Query query : new ArrayList<>(queries.values())) {
|
673
|
679
|
query.close();
|
674
|
680
|
}
|
675
|
681
|
}
|
|
@@ -858,7 +864,7 @@ public class Server extends WritableFrameContainer
|
858
|
864
|
public void join(final boolean focus, final ChannelJoinRequest ... requests) {
|
859
|
865
|
synchronized (myStateLock) {
|
860
|
866
|
if (myState.getState() == ServerState.CONNECTED) {
|
861
|
|
- final List<ChannelJoinRequest> pending = new ArrayList<ChannelJoinRequest>();
|
|
867
|
+ final List<ChannelJoinRequest> pending = new ArrayList<>();
|
862
|
868
|
|
863
|
869
|
for (ChannelJoinRequest request : requests) {
|
864
|
870
|
removeInvites(request.getName());
|
|
@@ -1453,7 +1459,7 @@ public class Server extends WritableFrameContainer
|
1453
|
1459
|
|
1454
|
1460
|
converter = parser.getStringConverter();
|
1455
|
1461
|
|
1456
|
|
- final List<ChannelJoinRequest> requests = new ArrayList<ChannelJoinRequest>();
|
|
1462
|
+ final List<ChannelJoinRequest> requests = new ArrayList<>();
|
1457
|
1463
|
if (getConfigManager().getOptionBool(DOMAIN_GENERAL, "rejoinchannels")) {
|
1458
|
1464
|
for (Channel chan : channels.values()) {
|
1459
|
1465
|
requests.add(new ChannelJoinRequest(chan.getName()));
|
|
@@ -1547,13 +1553,13 @@ public class Server extends WritableFrameContainer
|
1547
|
1553
|
/** {@inheritDoc} */
|
1548
|
1554
|
@Override
|
1549
|
1555
|
public Identity getServerIdentity() {
|
1550
|
|
- return IdentityManager.getIdentityManager().createServerConfig(parser.getServerName());
|
|
1556
|
+ return identityFactory.createServerConfig(parser.getServerName());
|
1551
|
1557
|
}
|
1552
|
1558
|
|
1553
|
1559
|
/** {@inheritDoc} */
|
1554
|
1560
|
@Override
|
1555
|
1561
|
public Identity getNetworkIdentity() {
|
1556
|
|
- return IdentityManager.getIdentityManager().createNetworkConfig(getNetwork());
|
|
1562
|
+ return identityFactory.createNetworkConfig(getNetwork());
|
1557
|
1563
|
}
|
1558
|
1564
|
|
1559
|
1565
|
// </editor-fold>
|
|
@@ -1580,7 +1586,7 @@ public class Server extends WritableFrameContainer
|
1580
|
1586
|
@Override
|
1581
|
1587
|
public void addInvite(final Invite invite) {
|
1582
|
1588
|
synchronized (invites) {
|
1583
|
|
- for (Invite oldInvite : new ArrayList<Invite>(invites)) {
|
|
1589
|
+ for (Invite oldInvite : new ArrayList<>(invites)) {
|
1584
|
1590
|
if (oldInvite.getChannel().equals(invite.getChannel())) {
|
1585
|
1591
|
removeInvite(oldInvite);
|
1586
|
1592
|
}
|
|
@@ -1619,7 +1625,7 @@ public class Server extends WritableFrameContainer
|
1619
|
1625
|
/** {@inheritDoc} */
|
1620
|
1626
|
@Override
|
1621
|
1627
|
public void removeInvites(final String channel) {
|
1622
|
|
- for (Invite invite : new ArrayList<Invite>(invites)) {
|
|
1628
|
+ for (Invite invite : new ArrayList<>(invites)) {
|
1623
|
1629
|
if (invite.getChannel().equals(channel)) {
|
1624
|
1630
|
removeInvite(invite);
|
1625
|
1631
|
}
|
|
@@ -1629,7 +1635,7 @@ public class Server extends WritableFrameContainer
|
1629
|
1635
|
/** {@inheritDoc} */
|
1630
|
1636
|
@Override
|
1631
|
1637
|
public void removeInvites() {
|
1632
|
|
- for (Invite invite : new ArrayList<Invite>(invites)) {
|
|
1638
|
+ for (Invite invite : new ArrayList<>(invites)) {
|
1633
|
1639
|
removeInvite(invite);
|
1634
|
1640
|
}
|
1635
|
1641
|
}
|