We will need this once Reverse DCC is implemented.
dccSendInformation.get().filename,
dccSendInformation.get().internetAddress,
dccSendInformation.get().port,
- dccSendInformation.get().size));
+ dccSendInformation.get().size,
+ dccSendInformation.get().token));
} else {
logger.warn(format("Received malformed DCC SEND: “%s”", message));
}
if (!internetAddress.isPresent() || !port.isPresent()) {
return absent();
}
- return of(new DccSendInformation(messageWords[2], internetAddress.get(), port.get(), fileSize));
+ String token = null;
+ if (messageWords.length > 6) {
+ token = messageWords[6];
+ }
+ return of(new DccSendInformation(messageWords[2], internetAddress.get(), port.get(), fileSize, token));
}
private static class DccSendInformation {
private final InetAddress internetAddress;
private final int port;
private final long size;
+ private final String token;
- private DccSendInformation(String filename,
- InetAddress internetAddress, int port, long size) {
+ private DccSendInformation(String filename, InetAddress internetAddress, int port, long size, String token) {
this.filename = filename;
this.internetAddress = internetAddress;
this.port = port;
this.size = size;
+ this.token = token;
}
}
/** The filesize. */
private final long filesize;
- /**
- * Creates a new DCC SEND received event.
- *
- * @param connection
- * The connetion the event occured on
- * @param source
- * The source offering the file
- * @param filename
- * The name of the file being offered
- * @param inetAddress
- * The IP address of the source
- * @param port
- * The port number of the source
- * @param filesize
- * The size of the file being offered ({@code -1} for unknown size)
- */
- public DccSendReceived(Connection connection, Source source, String filename, InetAddress inetAddress, int port, long filesize) {
+ private final String token;
+
+ public DccSendReceived(Connection connection, Source source, String filename, InetAddress inetAddress, int port, long filesize, String token) {
super(connection);
this.source = source;
this.filename = filename;
this.inetAddress = inetAddress;
this.port = port;
this.filesize = filesize;
+ this.token = token;
}
//
return port;
}
+ public String token() {
+ return token;
+ }
+
}
import static net.pterodactylus.irc.Source.parseSource;
import static net.pterodactylus.irc.connection.Replies.createReply;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentCaptor.forClass;
import static org.mockito.Matchers.anyObject;
}
@Test
+ public void dccCommandWithTokenIsRecognizedCorrectly() {
+ handler.handleReply(createReply(parseSource("User!user@host"), "PRIVMSG", "\u0001DCC SEND filename 1234 0 12345 T123\u0001"));
+ ArgumentCaptor<DccSendReceived> dccSendReceivedCaptor = forClass(DccSendReceived.class);
+ verify(eventBus).post(dccSendReceivedCaptor.capture());
+ assertThat(dccSendReceivedCaptor.getAllValues(), hasSize(1));
+ DccSendReceived dccSendReceived = dccSendReceivedCaptor.getValue();
+ assertThat(dccSendReceived.token(), equalTo("T123"));
+ }
+
+ @Test
public void dccAcceptCommandIsRecognized() {
handler.handleReply(createReply(parseSource("User!user@host"),
"NOTICE",