ClientPutComplexDir
ClientPutDiskDir
-ConfigData (since 1027)
FCPPluginMessage (since 1075)
FCPPluginReply (since 1075)
-GetConfig (since 1027)
GetFailed
GetPluginInfo (since 1075)
GetRequestStatus
--- /dev/null
+/*
+ * jSite2 - ConfigData.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;
+
+/**
+ * A “ConfigData” message contains various aspects of the node’s configuration.
+ *
+ * @see GetConfig
+ * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
+ * @version $Id$
+ */
+public class ConfigData extends BaseMessage {
+
+ /**
+ * Creates a new “ConfigData” message that wraps the received message.
+ *
+ * @param receivedMessage
+ * The received message
+ */
+ ConfigData(FcpMessage receivedMessage) {
+ super(receivedMessage);
+ }
+
+ /**
+ * Returns the current value of the given option.
+ *
+ * @param option
+ * The name of the option
+ * @return The current value of the option
+ */
+ public String getCurrent(String option) {
+ return getField("current." + option);
+ }
+
+ /**
+ * Returns the short description of the given option.
+ *
+ * @param option
+ * The name of the option
+ * @return The short description of the option
+ */
+ public String getShortDescription(String option) {
+ return getField("shortDescription." + option);
+ }
+
+ /**
+ * Returns the long description of the given option.
+ *
+ * @param option
+ * The name of the option
+ * @return The long description of the option
+ */
+ public String getLongDescription(String option) {
+ return getField("longDescription." + option);
+ }
+
+ /**
+ * Returns the data type of the given option.
+ *
+ * @param option
+ * The name of the option
+ * @return The data type of the option
+ */
+ public String getDataType(String option) {
+ return getField("dataType." + option);
+ }
+
+ /**
+ * Returns the default value of the given option.
+ *
+ * @param option
+ * The name of the option
+ * @return The default value of the option
+ */
+ public String getDefault(String option) {
+ return getField("default." + option);
+ }
+
+ /**
+ * Returns the sort order of the given option.
+ *
+ * @param option
+ * The name of the option
+ * @return The sort order of the option, or <code>-1</code> if the sort
+ * order could not be parsed
+ */
+ public int getSortOrder(String option) {
+ return FcpUtils.safeParseInt(getField("sortOrder." + option));
+ }
+
+ /**
+ * Returns the expert flag of the given option.
+ *
+ * @param option
+ * The name of the option
+ * @return The expert flag of the option
+ */
+ public boolean getExpertFlag(String option) {
+ return Boolean.valueOf(getField("expertFlag." + option));
+ }
+
+ /**
+ * Returns the force-write flag of the given option
+ *
+ * @param option
+ * The name of the option
+ * @return The force-write flag of the given option
+ */
+ public boolean getForceWriteFlag(String option) {
+ return Boolean.valueOf(getField("forceWriteFlag." + option));
+ }
+
+}
}
/**
+ * @see FcpListener#receivedConfigData(FcpConnection, ConfigData)
+ */
+ public void receivedConfigData(FcpConnection fcpConnection, ConfigData configData) {
+ /* empty. */
+ }
+
+ /**
* @see FcpListener#receivedProtocolError(FcpConnection, ProtocolError)
*/
public void receivedProtocolError(FcpConnection fcpConnection, ProtocolError protocolError) {
}
/**
+ * Notifies all listeners that a “ConfigData” message was received.
+ *
+ * @param configData
+ * The “ConfigData” message
+ */
+ private void fireReceivedConfigData(ConfigData configData) {
+ for (FcpListener fcpListener: fcpListeners) {
+ fcpListener.receivedConfigData(this, configData);
+ }
+ }
+
+ /**
* Notifies all listeners that a “ProtocolError” message was received.
*
* @param protocolError
fireReceivedTestDDAReply(new TestDDAReply(fcpMessage));
} else if ("TestDDAComplete".equals(messageName)) {
fireReceivedTestDDAComplete(new TestDDAComplete(fcpMessage));
+ } else if ("ConfigData".equals(messageName)) {
+ fireReceivedConfigData(new ConfigData(fcpMessage));
} else if ("NodeHello".equals(messageName)) {
fireReceivedNodeHello(new NodeHello(fcpMessage));
} else if ("CloseConnectionDuplicateClientName".equals(messageName)) {
public void receivedUnknownNodeIdentifier(FcpConnection fcpConnection, UnknownNodeIdentifier unknownNodeIdentifier);
/**
+ * Notifies a listener that a “ConfigData” message was received.
+ *
+ * @param fcpConnection
+ * The connection that received the message
+ * @param configData
+ * The “ConfigData” message
+ */
+ public void receivedConfigData(FcpConnection fcpConnection, ConfigData configData);
+
+ /**
* Notifies a listener that a “ProtocolError” was received.
*
* @param fcpConnection
--- /dev/null
+/*
+ * jSite2 - GetConfig.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 “GetConfig” command tells the node to send its configuration to the
+ * client.
+ *
+ * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
+ * @version $Id$
+ */
+public class GetConfig extends FcpMessage {
+
+ /**
+ * Creates a new “GetConfig” command.
+ */
+ public GetConfig() {
+ super("GetConfig");
+ }
+
+ /**
+ * Sets whether the {@link ConfigData} result message shall include the
+ * current values.
+ *
+ * @param withCurrent
+ * <code>true</code> to include current values in the result,
+ * <code>false</code> otherwise
+ */
+ public void setWithCurrent(boolean withCurrent) {
+ setField("WithCurrent", String.valueOf(withCurrent));
+ }
+
+ /**
+ * Sets whether the {@link ConfigData} result message shall include the
+ * short descriptions.
+ *
+ * @param withShortDescription
+ * <code>true</code> to include the short descriptions in the
+ * result, <code>false</code> otherwise
+ */
+ public void setWithShortDescription(boolean withShortDescription) {
+ setField("WithShortDescription", String.valueOf(withShortDescription));
+ }
+
+ /**
+ * Sets whether the {@link ConfigData} result message shall include the long
+ * descriptions.
+ *
+ * @param withLongDescription
+ * <code>true</code> to include the long descriptions in the
+ * result, <code>false</code> otherwise
+ */
+ public void setWithLongDescription(boolean withLongDescription) {
+ setField("WithLongDescription", String.valueOf(withLongDescription));
+ }
+
+ /**
+ * Sets whether the {@link ConfigData} result message shall include the data
+ * types.
+ *
+ * @param withDataTypes
+ * <code>true</code> to include the data types in the result,
+ * <code>false</code> otherwise
+ */
+ public void setWithDataTypes(boolean withDataTypes) {
+ setField("WithDataTypes", String.valueOf(withDataTypes));
+ }
+
+ /**
+ * Sets whether the {@link ConfigData} result message shall include the
+ * defaults.
+ *
+ * @param setWithDefaults
+ * <code>true</code> to include the defaults in the result,
+ * <code>false</code> otherwise
+ */
+ public void setWithDefaults(boolean setWithDefaults) {
+ setField("WithDefaults", String.valueOf(setWithDefaults));
+ }
+
+ /**
+ * Sets whether the {@ConfigData} result message shall include the sort
+ * order.
+ *
+ * @param withSortOrder
+ * <code>true</code> to include the sort order in the result,
+ * <code>false</code> otherwise
+ */
+ public void setWithSortOrder(boolean withSortOrder) {
+ setField("WithSortOrder", String.valueOf(withSortOrder));
+ }
+
+ /**
+ * Sets whether the {@link ConfigData} result message shall include the
+ * expert flag.
+ *
+ * @param withExpertFlag
+ * <code>true</code> to include the expert flag in the result,
+ * <code>false</code> otherwise
+ */
+ public void setWithExpertFlag(boolean withExpertFlag) {
+ setField("WithExpertFlag", String.valueOf(withExpertFlag));
+ }
+
+ /**
+ * Sets whether the {@link ConfigData} result message shall include the
+ * force-write flag.
+ *
+ * @param withForceWriteFlag
+ * <code>true</code> to include the force-write flag in the
+ * result, <code>false</code> otherwise
+ */
+ public void setWithForceWriteFlag(boolean withForceWriteFlag) {
+ setField("WithForceWriteFlag", String.valueOf(withForceWriteFlag));
+ }
+
+}