OpenNapPreferences.java
| Index Score | ||
|---|---|---|
![]() |
![]() |
org.xnap.plugin.opennap.util |
![]() |
![]() |
XNap 3 |
View: Reasons, Metrics, Source Code
These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.
/*
* XNap - A P2P framework and client.
*
* See the file AUTHORS for copyright information.
*
* 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.
*
* 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 org.xnap.plugin.opennap.util;
import org.xnap.plugin.opennap.OpenNapPlugin;
import org.xnap.util.AbstractPluginPreferences;
import org.xnap.util.FileHelper;
import org.xnap.util.Preferences;
import org.xnap.util.prefs.IntValidator;
import org.xnap.util.prefs.PortRangeValidator;
/**
* Provides the preferences for the {@link OpenNapPlugin}. This class should
* only be instanziated once. Use {@link OpenNapPlugin.getPreferences()} to
* access that instance.
*
* <p>If you hack around, make sure all pathes are returned with a trailing
* file separator and all values are initialized to something other than
* null.
*
* <p>Most important, keep all preferences sorted alphabetically everywhere.
*/
public class OpenNapPreferences extends AbstractPluginPreferences {
//--- Constant(s) ---
public static final int VERSION = 9;
//--- Data field(s) ---
//--- Constructor(s) ---
public OpenNapPreferences()
{
super("plugin.nap", VERSION);
String defaultClientInfo
= "XNap " + OpenNapPlugin.getInstance().getInfo().getVersion();
setDefault("autoFetchNapigator", "true");
setDefault("autoFetchNapigatorInterval", "24");
setDefault("autoLoadNapigator", "true");
setDefault("autoResumeDownloads", "false");
setDefault("autoResumeConnectedCount", "5");
setDefault("autoSaveNapigator", "true");
setDefault("clientInfo", defaultClientInfo);
setDefault("customizeClientInfo", "false");
setDefault("fakeNetworks", "n/a");
setDefault("filterNetworks", "OpenNapster");
setDefault("firewalled", "false");
setDefault("hotlistUsers", "");
setDefault("limitSearchResultsPerServer", "false");
setDefault("limitSearchServers", "false");
setDefault("limitSharesPerServer", "false");
setDefault("localPort", "6600-6700", new PortRangeValidator());
setDefault("maxAutoconnectServers", "10");
setDefault("maxLoginsPerNetwork", "1");
setDefault("maxPacketsPerTick", "50");
setDefault("maxSearchResultsPerServer", "200",
new IntValidator(0, Integer.MAX_VALUE));
setDefault("maxSearchServers", "5");
setDefault("maxSharesPerServer", "500");
setDefault("multiSourceDownloading", "false");
setDefault("napigatorFile", FileHelper.getHomeDir()
+ "napigator_hosts");
setDefault("napigatorURL",
"http://www.gotnap.com/servers.txt\n"
+ "http://naplist.com/servers.txt\n"
+ "#http://www.napigator.com/servers.php?version=112&client=napigator\n");
setDefault("removeFailedServers", "false");
setDefault("seenStartupWizard", "false");
setDefault("sendWholeRepository", "false");
setDefault("serverFile", FileHelper.getHomeDir() + "hosts");
setDefault("serverTableColumns",
"name;status;localPort;version;files;size;users");
setDefault("startupDialogShow", "false");
setDefault("useAutoconnector", "true");
setDefault("useUTF8Encoding", "true");
setDefault("tickLength", "100");
setDefault("whoisQueryOnTransfer", "false");
setDefault("whoisTableColumns",
"user;server;fileCount;linkSpeed;level;status;downloads;uploads;client;lastSeen;online");
if (!getCustomizeClientInfo()) {
setClientInfo(defaultClientInfo);
}
}
//--- Method(s) ---
public void convert(int oldVersion)
{
if (oldVersion <= 0) {
set("userTableColumns", "0;2;3;4;5;6;7;8");
set("serverTableColumns", "0;1;4;5;6;7");
}
if (oldVersion <= 1) {
removeProperty("xnap.plugin.nap.userTableColumns");
renameProperty("xnap.serverTableColumns",
"xnap.plugin.nap.serverTableColumns");
renameProperty("xnap.serverTableColumnWidth",
"xnap.plugin.nap.serverTableColumnWidth");
renameProperty("xnap.serverTableMaintainSortOrder",
"xnap.plugin.nap.serverTableMaintainSortOrder");
renameProperty("xnap.serverTableSortedColumn",
"xnap.plugin.nap.serverTableSortedColumn");
}
if (oldVersion <= 2) {
// deprecated, makes no sense
// just make sure nobody unchecked this by accident
//setUseSinglePort(true);
}
if (oldVersion <= 3) {
removeProperty("hotlistDividerLocation");
removeProperty("hotlistTableColumns");
// LinkedList l
// = StringHelper.toList(get("bannedUsers"), ARRAY_SEPARATOR);
// for (Iterator i = l.iterator(); i.hasNext();) {
// GlobalUser u = new GlobalUser(i.next().toString(), false);
// u.setMaxUploads(0);
// u.setCategory(XNap.tr("Banned"));
// UserManager.getInstance().add(u);
// }
// removeProperty("bannedUsers");
// QuotedStringTokenizer t
// = new QuotedStringTokenizer(get("hotlistUsers"));
// while (t.hasMoreTokens()) {
// GlobalUser u = new GlobalUser(t.nextToken(), false);
// UserManager.getInstance().add(u);
// }
// UserManager.getInstance().write();
// removeProperty("hotlistUsers");
}
if (oldVersion <= 4) {
removeProperty("useSinglePort");
}
Preferences prefs = Preferences.getInstance();
if (oldVersion == 5) {
prefs.setMinimumShares(getInt("minimumShares"));
prefs.setMinimumSharesMessage(get("minimumSharesMessage"));
prefs.setSendMinimumSharesMessage
(getBoolean("sendMinimumSharesMessage"));
prefs.setUseMinimumShares(getBoolean("useMinimumShares"));
}
if (oldVersion <= 6) {
setFirewalled(prefs.getBoolean("firewalled"));
set("serverTableColumns",
"name;status;localPort;version;files;size;users");
set("whoisTableColumns",
"user;server;fileCount;linkSpeed;level;status;downloads;uploads;client;lastSeen;online");
}
if (oldVersion <= 7) {
renameProperty("xnap.plugin.nap.autoFetchNaptigator",
"xnap.plugin.nap.autoFetchNapigator");
renameProperty("xnap.plugin.nap.autoLoadNaptigator",
"xnap.plugin.nap.autoLoadNapigator");
renameProperty("xnap.plugin.nap.autoSaveNaptigator",
"xnap.plugin.nap.autoSaveNapigator");
}
if (oldVersion <= 8) {
if (getNapigatorURL().equals("http://www.napigator.com/servers.php?version=112&client=napigator")) {
setNapigatorURL("http://www.gotnap.com/servers.txt\n"
+ "http://naplist.com/servers.txt\n"
+ "#http://www.napigator.com/servers.php?version=112&client=napigator\n");
}
}
}
public boolean getAutoFetchNapigator() {
return getBoolean("autoFetchNaptigator");
}
public void setAutoFetchNapigator(boolean newValue) {
set("autoFetchNaptigator", newValue);
}
public int getAutoFetchNapigatorInterval() {
return getInt("autoFetchNapigatorInterval");
}
public void setAutoFetchNapigatorInterval(int newValue) {
set("autoFetchNapigatorInterval", newValue);
}
public boolean getAutoLoadNapigator() {
return getBoolean("autoLoadNapigator");
}
public void setAutoLoadNapigator(boolean newValue) {
set("autoLoadNapigator", newValue);
}
public boolean getAutoResumeDownloads() {
return getBoolean("autoResumeDownloads");
}
public void setAutoResumeDownloads(boolean newValue) {
set("autoResumeDownloads", newValue);
}
public int getAutoResumeConnectedCount() {
return getInt("autoResumeConnectedCount");
}
public void setAutoResumeConnectedCount(int newValue) {
set("autoResumeConnectedCount", newValue);
}
public boolean getAutoSaveNapigator() {
return getBoolean("autoSaveNapigator");
}
public void setAutoSaveNapigator(boolean newValue) {
set("autoSaveNapigator", newValue);
}
public String getClientInfo() {
return get("clientInfo");
}
public void setClientInfo(String newValue) {
if (newValue.equals("")) {
return;
}
set("clientInfo", newValue);
}
public boolean getCustomizeClientInfo() {
return getBoolean("customizeClientInfo");
}
public void setCustomizeClientInfo(boolean newValue) {
set("customizeClientInfo", newValue);
}
public String getFakeNetworks() {
return get("fakeNetworks");
}
public String getFilterNetworks() {
return get("filterNetworks");
}
public boolean getFirewalled() {
return getBoolean("firewalled");
}
public void setFirewalled(boolean newValue) {
set("firewalled", newValue);
}
public boolean getLimitSearchServers() {
return getBoolean("limitSearchServers");
}
public void setLimitSearchServers(boolean newValue) {
set("limitSearchServers", newValue);
}
public boolean getLimitSearchResultsPerServer() {
return getBoolean("limitSearchResultsPerServer");
}
public void setLimitSearchResultsPerServer(boolean newValue) {
set("limitSearchResultsPerServer", newValue);
}
public boolean getLimitSharesPerServer() {
return getBoolean("limitSharesPerServer");
}
public void setLimitSharesPerServer(boolean newValue) {
set("limitSharesPerServer", newValue);
}
public String getLocalPortRange() {
return get("localPort");
}
public void setLocalPortRange(String newValue) {
set("localPort", newValue);
}
public int getMaxAutoconnectServers() {
return getInt("maxAutoconnectServers");
}
public void setMaxAutoconnectServers(int newValue) {
if (newValue < 0) {
return;
}
set("maxAutoconnectServers", newValue);
}
public int getMaxLoginsPerNetwork() {
return getInt("maxLoginsPerNetwork");
}
public int getMaxPacketsPerTick() {
return getInt("maxPacketsPerTick");
}
public int getMaxSearchResultsPerServer() {
return getInt("maxSearchResultsPerServer");
}
public void setMaxSearchResultsPerServer(int newValue) {
set("maxSearchResultsPerServer", newValue);
}
public int getMaxSearchServers() {
return getInt("maxSearchServers");
}
public void setMaxSearchServers(int newValue) {
if (newValue < 1) {
return;
}
set("maxSearchServers", newValue);
}
public int getMaxSharesPerServer() {
return getInt("maxSharesPerServer");
}
public void setMaxSharesPerServer(int newValue) {
set("maxSharesPerServer", newValue);
}
public boolean getMultiSourceDownloading() {
return getBoolean("multiSourceDownloading");
}
public void setMultiSourceDownloading(boolean newValue) {
set("multiSourceDownloading", newValue);
}
public String getNapigatorFile() {
return get("napigatorFile");
}
public String getNapigatorURL() {
return get("napigatorURL");
}
public void setNapigatorURL(String url) {
set("napigatorURL", url);
}
public boolean getRemoveFailedServers() {
return getBoolean("removeFailedServers");
}
public void setRemoveFailedServers(boolean newValue) {
set("removeFailedServers", newValue);
}
public boolean getSendWholeRepository() {
return getBoolean("sendWholeRepository");
}
public void setSendWholeRepository(boolean newValue) {
set("sendWholeRepository", newValue);
}
public String getServerFile() {
return get("serverFile");
}
public boolean getUseAutoconnector() {
return getBoolean("useAutoconnector");
}
public void setUseAutoconnector(boolean newValue) {
set("useAutoconnector", newValue);
}
public boolean getUseUTF8Encoding() {
return getBoolean("useUTF8Encoding");
}
public void setUseUTF8Encoding(boolean newValue) {
set("useUTF8Encoding", newValue);
}
public boolean getSeenStartupWizard() {
return getBoolean("seenStartupWizard");
}
public void setSeenStartupWizard(boolean newValue) {
set("seenStartupWizard", newValue);
}
public long getTickLength() {
return getLong("tickLength");
}
public boolean getWhoisQueryOnTransfer() {
return getBoolean("whoisQueryOnTransfer");
}
public void setWhoisQueryOnTransfer(boolean newValue) {
set("whoisQueryOnTransfer", newValue);
}
}
The table below shows all metrics for OpenNapPreferences.java.




