Kaynağa Gözat

Use new InviteManager iface.

Delete the duplicated methods from Connection.
pull/403/head
Chris Smith 9 yıl önce
ebeveyn
işleme
020a9eed0f

+ 1
- 1
src/com/dmdirc/Channel.java Dosyayı Görüntüle

@@ -231,7 +231,7 @@ public class Channel extends MessageTarget implements GroupChat {
231 231
         checkWho();
232 232
         setIcon("channel");
233 233
 
234
-        connection.removeInvites(channelInfo.getName());
234
+        connection.getInviteManager().removeInvites(channelInfo.getName());
235 235
     }
236 236
 
237 237
     /**

+ 1
- 1
src/com/dmdirc/GroupChatManagerImpl.java Dosyayı Görüntüle

@@ -115,7 +115,7 @@ public class GroupChatManagerImpl implements GroupChatManager {
115 115
             final Collection<ChannelJoinRequest> pending = new ArrayList<>();
116 116
 
117 117
             for (ChannelJoinRequest request : requests) {
118
-                connection.removeInvites(request.getName());
118
+                connection.getInviteManager().removeInvites(request.getName());
119 119
 
120 120
                 final String name;
121 121
                 if (p.isValidChannelName(request.getName())) {

+ 8
- 8
src/com/dmdirc/Invite.java Dosyayı Görüntüle

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc;
24 24
 
25
-import com.dmdirc.interfaces.Connection;
25
+import com.dmdirc.interfaces.InviteManager;
26 26
 import com.dmdirc.interfaces.User;
27 27
 
28 28
 import java.util.Date;
@@ -32,8 +32,8 @@ import java.util.Date;
32 32
  */
33 33
 public class Invite {
34 34
 
35
-    /** The connection this invite was on. */
36
-    private final Connection connection;
35
+    /** The manager associated with this invite. */
36
+    private final InviteManager inviteManager;
37 37
     /** The channel this invite is for. */
38 38
     private final String channel;
39 39
     /** The time this invite was created. */
@@ -44,12 +44,12 @@ public class Invite {
44 44
     /**
45 45
      * Creates a new instance of Invite.
46 46
      *
47
-     * @param connection The connection that this invite was received on
47
+     * @param inviteManager The manager that this invite is associated with.
48 48
      * @param channel    The channel that this invite is for
49 49
      * @param source     The source of this invite
50 50
      */
51
-    public Invite(final Connection connection, final String channel, final User source) {
52
-        this.connection = connection;
51
+    public Invite(final InviteManager inviteManager, final String channel, final User source) {
52
+        this.inviteManager = inviteManager;
53 53
         this.channel = channel;
54 54
         this.source = source;
55 55
         this.timestamp = new Date().getTime();
@@ -76,14 +76,14 @@ public class Invite {
76 76
      * Join the channel that belongs to this invite.
77 77
      */
78 78
     public void accept() {
79
-        connection.acceptInvites(this);
79
+        inviteManager.acceptInvites(this);
80 80
     }
81 81
 
82 82
     /**
83 83
      * Decline this invite removing it from the invite list.
84 84
      */
85 85
     public void decline() {
86
-        connection.removeInvite(this);
86
+        inviteManager.removeInvite(this);
87 87
     }
88 88
 
89 89
 }

+ 1
- 1
src/com/dmdirc/ServerEventHandler.java Dosyayı Görüntüle

@@ -500,7 +500,7 @@ public class ServerEventHandler extends EventHandler implements
500 500
             final String channel) {
501 501
         checkParser(parser);
502 502
 
503
-        owner.addInvite(new Invite(owner, channel, owner.getUser(userHost)));
503
+        owner.getInviteManager().addInvite(new Invite(owner, channel, owner.getUser(userHost)));
504 504
         final ServerInviteReceivedEvent event = new ServerInviteReceivedEvent(owner,
505 505
                 owner.getUser(userHost), channel);
506 506
         final String format = EventUtils.postDisplayable(eventBus, event, "inviteReceived");

+ 0
- 51
src/com/dmdirc/interfaces/Connection.java Dosyayı Görüntüle

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.interfaces;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Invite;
27 26
 import com.dmdirc.Query;
28 27
 import com.dmdirc.ServerState;
29 28
 import com.dmdirc.ServerStatus;
@@ -35,7 +34,6 @@ import com.dmdirc.parser.interfaces.Parser;
35 34
 import java.net.URI;
36 35
 import java.util.Collection;
37 36
 import java.util.Date;
38
-import java.util.List;
39 37
 import java.util.Optional;
40 38
 
41 39
 import javax.annotation.Nonnull;
@@ -45,29 +43,6 @@ import javax.annotation.Nonnull;
45 43
  */
46 44
 public interface Connection {
47 45
 
48
-    /**
49
-     * Attempts to accept the specified invites, and join the corresponding channels.
50
-     *
51
-     * @param invites The invites to process
52
-     *
53
-     * @since 0.6.4
54
-     */
55
-    void acceptInvites(final Invite... invites);
56
-
57
-    /**
58
-     * Attempts to accept all active invites for this server, and join the corresponding channels.
59
-     *
60
-     * @since 0.6.4
61
-     */
62
-    void acceptInvites();
63
-
64
-    /**
65
-     * Adds an invite to this server, and fires the appropriate listeners.
66
-     *
67
-     * @param invite The invite to be added
68
-     */
69
-    void addInvite(final Invite invite);
70
-
71 46
     /**
72 47
      * Passes the arguments to all frames for this server.
73 48
      *
@@ -146,13 +121,6 @@ public interface Connection {
146 121
      */
147 122
     IgnoreList getIgnoreList();
148 123
 
149
-    /**
150
-     * Returns the list of invites for this server.
151
-     *
152
-     * @return Invite list
153
-     */
154
-    List<Invite> getInvites();
155
-
156 124
     /**
157 125
      * Retrieves the name of this server's IRCd.
158 126
      *
@@ -309,25 +277,6 @@ public interface Connection {
309 277
      */
310 278
     void reconnect();
311 279
 
312
-    /**
313
-     * Removes an invite from this server, and fires the appropriate listeners.
314
-     *
315
-     * @param invite The invite to be removed
316
-     */
317
-    void removeInvite(final Invite invite);
318
-
319
-    /**
320
-     * Removes all invites for the specified channel.
321
-     *
322
-     * @param channel The channel to remove invites for
323
-     */
324
-    void removeInvites(final String channel);
325
-
326
-    /**
327
-     * Removes all invites for all channels.
328
-     */
329
-    void removeInvites();
330
-
331 280
     /**
332 281
      * Saves the contents of our ignore list to the network identity.
333 282
      */

+ 5
- 4
test/com/dmdirc/InviteTest.java Dosyayı Görüntüle

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc;
24 24
 
25
+import com.dmdirc.interfaces.InviteManager;
25 26
 import com.dmdirc.interfaces.User;
26 27
 
27 28
 import java.util.Date;
@@ -40,7 +41,7 @@ import static org.mockito.Mockito.verify;
40 41
 public class InviteTest {
41 42
 
42 43
     @Mock
43
-    private Server server;
44
+    private InviteManager inviteManager;
44 45
     @Mock
45 46
     private User user;
46 47
     private Invite invite;
@@ -48,7 +49,7 @@ public class InviteTest {
48 49
 
49 50
     @Before
50 51
     public void setUp() {
51
-        invite = new Invite(server, "#channel", user);
52
+        invite = new Invite(inviteManager, "#channel", user);
52 53
         ts = new Date().getTime();
53 54
     }
54 55
 
@@ -71,13 +72,13 @@ public class InviteTest {
71 72
     @Test
72 73
     public void testAccept() {
73 74
         invite.accept();
74
-        verify(server).acceptInvites(invite);
75
+        verify(inviteManager).acceptInvites(invite);
75 76
     }
76 77
 
77 78
     @Test
78 79
     public void testDecline() {
79 80
         invite.decline();
80
-        verify(server).removeInvite(invite);
81
+        verify(inviteManager).removeInvite(invite);
81 82
     }
82 83
 
83 84
 }

Loading…
İptal
Kaydet