Преглед изворни кода

Core support for accepting multiple invites

Fixes issue 4175

Change-Id: Ie63e84f626a248f85af36185c3a4a72d9f117e74
Reviewed-on: http://gerrit.dmdirc.com/1274
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.4rc1
Greg Holmes пре 14 година
родитељ
комит
587bf6cc27
2 измењених фајлова са 37 додато и 3 уклоњено
  1. 8
    3
      src/com/dmdirc/Invite.java
  2. 29
    0
      src/com/dmdirc/Server.java

+ 8
- 3
src/com/dmdirc/Invite.java Прегледај датотеку

@@ -98,9 +98,14 @@ public class Invite {
98 98
      * Join the channel that belongs to this invite.
99 99
      */
100 100
     public void accept() {
101
-        server.join(new ChannelJoinRequest(channel));
102
-        
101
+        server.acceptInvites(this);
102
+    }
103
+
104
+
105
+    /**
106
+     * Decline this invite removing it from the invite list.
107
+     */
108
+    public void decline() {
103 109
         server.removeInvite(this);
104 110
     }
105
-    
106 111
 }

+ 29
- 0
src/com/dmdirc/Server.java Прегледај датотеку

@@ -1724,6 +1724,35 @@ public class Server extends WritableFrameContainer<ServerWindow> implements Conf
1724 1724
         }
1725 1725
     }
1726 1726
 
1727
+    /**
1728
+     * Attempts to accept the specified invites, and join the corresponding
1729
+     * channels.
1730
+     *
1731
+     * @param invites The invites to process
1732
+     * @since 0.6.4
1733
+     */
1734
+    public void acceptInvites(final Invite ... invites) {
1735
+        final ChannelJoinRequest[] requests = new ChannelJoinRequest[invites.length];
1736
+
1737
+        for (int i = 0; i < invites.length; i++) {
1738
+            requests[i] = new ChannelJoinRequest(invites[i].getChannel());
1739
+        }
1740
+
1741
+        join(requests);
1742
+    }
1743
+
1744
+    /**
1745
+     * Attempts to accept all active invites for this server, and join the
1746
+     * corresponding channels.
1747
+     *
1748
+     * @since 0.6.4
1749
+     */
1750
+    public void acceptInvites() {
1751
+        synchronized (invites) {
1752
+            acceptInvites(invites.toArray(new Invite[invites.size()]));
1753
+        }
1754
+    }
1755
+
1727 1756
     /**
1728 1757
      * Removes all invites for the specified channel.
1729 1758
      *

Loading…
Откажи
Сачувај