}
/**
+ * {@inheritDoc}
+ *
+ * @see net.pterodactylus.util.fcp.FcpListener#receivedTestDDAReply(net.pterodactylus.util.fcp.FcpConnection,
+ * net.pterodactylus.util.fcp.TestDDAReply)
+ */
+ public void receivedTestDDAReply(FcpConnection fcpConnection, TestDDAReply testDDAReply) {
+ /* empty. */
+ }
+
+ /**
* @see net.pterodactylus.util.fcp.FcpListener#receivedMessage(net.pterodactylus.util.fcp.FcpConnection,
* net.pterodactylus.util.fcp.FcpMessage)
*/
}
/**
+ * Notifies all listeners that a “TestDDAReply” message was received.
+ *
+ * @param testDDAReply
+ * The “TestDDAReply” message
+ */
+ private void fireReceivedTestDDAReply(TestDDAReply testDDAReply) {
+ for (FcpListener fcpListener: fcpListeners) {
+ fcpListener.receivedTestDDAReply(this, testDDAReply);
+ }
+ }
+
+ /**
* Notifies all registered listeners that a message has been received.
*
* @see FcpListener#receivedMessage(FcpConnection, FcpMessage)
fireReceivedPeerRemoved(new PeerRemoved(fcpMessage));
} else if ("NodeData".equals(messageName)) {
fireReceivedNodeData(new NodeData(fcpMessage));
+ } else if ("TestDDAReply".equals(messageName)) {
+ fireReceivedTestDDAReply(new TestDDAReply(fcpMessage));
} else if ("NodeHello".equals(messageName)) {
fireReceivedNodeHello(new NodeHello(fcpMessage));
} else if ("CloseConnectionDuplicateClientName".equals(messageName)) {
public void receivedNodeData(FcpConnection fcpConnection, NodeData nodeData);
/**
+ * Notifies a listener that a “TestDDAReply” message was received.
+ *
+ * @param fcpConnection
+ * The connection that received the message
+ * @param testDDAReply
+ * The “TestDDAReply” message
+ */
+ public void receivedTestDDAReply(FcpConnection fcpConnection, TestDDAReply testDDAReply);
+
+ /**
* Notifies a listener that a message has been received. This method is only
* called if {@link FcpConnection#handleMessage(FcpMessage)} does not
* recognize the message. Should that ever happen, please file a bug report!
--- /dev/null
+/*
+ * jSite2 - TestDDAReply.java -
+ * Copyright © 2008 David Roden
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package net.pterodactylus.util.fcp;
+
+/**
+ * The “TestDDAReply” is sent as a response to {@link TestDDARequest}. If you
+ * specified that you wanted to read files from that directory
+ * {@link #getReadFilename()} will give you a filename. Similarly, if you
+ * specified that you want to write in the directory {@link #getWriteFilename()}
+ * will give you a filename to write {@link #getContentToWrite()} to.
+ *
+ * @author David Roden <droden@gmail.com>
+ * @version $Id$
+ */
+public class TestDDAReply extends BaseMessage {
+
+ /**
+ * Creates a “TestDDAReply” message that wraps the received message.
+ *
+ * @param receivedMessage
+ * The received message
+ */
+ public TestDDAReply(FcpMessage receivedMessage) {
+ super(receivedMessage);
+ }
+
+ /**
+ * Returns the directory the TestDDRequest was made for.
+ *
+ * @return The directory to test
+ */
+ public String getDirectory() {
+ return getField("Directory");
+ }
+
+ /**
+ * Returns the filename you have to read to proof your ability to read that
+ * specific directory.
+ *
+ * @return The name of the file to read
+ */
+ public String getReadFilename() {
+ return getField("ReadFilename");
+ }
+
+ /**
+ * Returns the filename you have to write to to proof your ability to write
+ * to that specific directory.
+ *
+ * @return The name of the file write to
+ */
+ public String getWriteFilename() {
+ return getField("WriteFilename");
+ }
+
+ /**
+ * If you requested a test for writing permissions you have to write the
+ * return value of this method to the file given by
+ * {@link #getWriteFilename()}.
+ *
+ * @return The content to write to the file
+ */
+ public String getContentToWrite() {
+ return getField("ContentToWrite");
+ }
+
+}
--- /dev/null
+/*
+ * jSite2 - TestDDARequest.java -
+ * Copyright © 2008 David Roden
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package net.pterodactylus.util.fcp;
+
+/**
+ * The “TestDDARequest” initiates a DDA test sequence.
+ *
+ * @author David Roden <droden@gmail.com>
+ * @version $Id$
+ */
+public class TestDDARequest extends FcpMessage {
+
+ /**
+ * Creates a new “TestDDARequest” command that initiates a DDA test.
+ *
+ * @param directory
+ * The directory you want to access files in
+ * @param wantReadDirectory
+ * <code>true</code> if you want to read files from the
+ * directory
+ * @param wantWriteDirectory
+ * <code>true</code> if you want to write files to the
+ * directory
+ */
+ public TestDDARequest(String directory, boolean wantReadDirectory, boolean wantWriteDirectory) {
+ super("TestDDARequest");
+ setField("Directory", directory);
+ setField("WantReadDirectory", String.valueOf(wantReadDirectory));
+ setField("WantWriteDirectory", String.valueOf(wantWriteDirectory));
+ }
+
+}