Przeglądaj źródła

Copy GroupChat methods into a GroupChatManager.

Will remove them from Connection shortly. Then the functionality
can be pulled out of Server into a sane, separate class.
pull/366/head
Chris Smith 9 lat temu
rodzic
commit
7d5e1d2908

+ 7
- 1
src/com/dmdirc/Server.java Wyświetl plik

@@ -33,6 +33,7 @@ import com.dmdirc.events.ServerDisconnectedEvent;
33 33
 import com.dmdirc.events.ServerInviteExpiredEvent;
34 34
 import com.dmdirc.interfaces.Connection;
35 35
 import com.dmdirc.interfaces.GroupChat;
36
+import com.dmdirc.interfaces.GroupChatManager;
36 37
 import com.dmdirc.interfaces.User;
37 38
 import com.dmdirc.interfaces.config.ConfigChangeListener;
38 39
 import com.dmdirc.interfaces.config.ConfigProvider;
@@ -99,7 +100,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
99 100
  * The Server class represents the client's view of a server. It maintains a list of all channels,
100 101
  * queries, etc, and handles parser callbacks pertaining to the server.
101 102
  */
102
-public class Server extends FrameContainer implements Connection {
103
+public class Server extends FrameContainer implements Connection, GroupChatManager {
103 104
 
104 105
     private static final Logger LOG = LoggerFactory.getLogger(Server.class);
105 106
     /** The name of the general domain. */
@@ -1243,6 +1244,11 @@ public class Server extends FrameContainer implements Connection {
1243 1244
         return getParser().map(p -> p.getMaxListModes(mode)).orElse(-1);
1244 1245
     }
1245 1246
 
1247
+    @Override
1248
+    public GroupChatManager getGroupChatManager() {
1249
+        return this;
1250
+    }
1251
+
1246 1252
     /**
1247 1253
      * Utility method to get a result from the parser while holding the {@link #parserLock}
1248 1254
      * read lock.

+ 7
- 0
src/com/dmdirc/interfaces/Connection.java Wyświetl plik

@@ -495,4 +495,11 @@ public interface Connection {
495 495
      */
496 496
     int getMaxListModes(final char mode);
497 497
 
498
+    /**
499
+     * Gets the manager that handles this connection's group chats.
500
+     *
501
+     * @return The group chat manager for this connection.
502
+     */
503
+    GroupChatManager getGroupChatManager();
504
+
498 505
 }

+ 90
- 0
src/com/dmdirc/interfaces/GroupChatManager.java Wyświetl plik

@@ -0,0 +1,90 @@
1
+/*
2
+ * Copyright (c) 2006-2015 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.interfaces;
24
+
25
+import com.dmdirc.parser.common.ChannelJoinRequest;
26
+
27
+import java.util.Collection;
28
+import java.util.Optional;
29
+
30
+/**
31
+ * Handles all {@link GroupChat}s on a {@link Connection}
32
+ */
33
+public interface GroupChatManager {
34
+
35
+    /**
36
+     * Retrieves the specified channel belonging to this server.
37
+     *
38
+     * @param channel The channel to be retrieved
39
+     *
40
+     * @return The appropriate channel object
41
+     */
42
+    Optional<GroupChat> getChannel(final String channel);
43
+
44
+    /**
45
+     * Retrieves the possible channel prefixes in use on this server.
46
+     *
47
+     * @return This server's possible channel prefixes
48
+     */
49
+    String getChannelPrefixes();
50
+
51
+    /**
52
+     * Gets a collection of all channels on this connection.
53
+     *
54
+     * @return collection of channels belonging to this connection
55
+     */
56
+    Collection<GroupChat> getChannels();
57
+
58
+    /**
59
+     * Determines if the specified channel name is valid. A channel name is valid if we already have
60
+     * an existing Channel with the same name, or we have a valid parser instance and the parser
61
+     * says it's valid.
62
+     *
63
+     * @param channelName The name of the channel to test
64
+     *
65
+     * @return True if the channel name is valid, false otherwise
66
+     */
67
+    boolean isValidChannelName(final String channelName);
68
+
69
+    /**
70
+     * Attempts to join the specified channels. If channels with the same name already exist, they
71
+     * are (re)joined and their windows activated.
72
+     *
73
+     * @param requests The channel join requests to process
74
+     *
75
+     * @since 0.6.4
76
+     */
77
+    void join(final ChannelJoinRequest... requests);
78
+
79
+    /**
80
+     * Attempts to join the specified channels. If channels with the same name already exist, they
81
+     * are (re)joined.
82
+     *
83
+     * @param focus    Whether or not to focus any new channels
84
+     * @param requests The channel join requests to process
85
+     *
86
+     * @since 0.6.4
87
+     */
88
+    void join(final boolean focus, final ChannelJoinRequest... requests);
89
+
90
+}

Ładowanie…
Anuluj
Zapisz