diff --git a/.classpath b/.classpath
index 6612902157..566b917553 100644
--- a/.classpath
+++ b/.classpath
@@ -9,7 +9,11 @@
-
+
+
+
+
+
diff --git a/ressourcen/code-ressourcen/miglayout-3.7.3.1-javadoc.jar b/ressourcen/code-ressourcen/miglayout-3.7.3.1-javadoc.jar
new file mode 100644
index 0000000000..41db6b14a1
Binary files /dev/null and b/ressourcen/code-ressourcen/miglayout-3.7.3.1-javadoc.jar differ
diff --git a/ressourcen/code-ressourcen/miglayout-3.7.3.1-sources.jar b/ressourcen/code-ressourcen/miglayout-3.7.3.1-sources.jar
new file mode 100644
index 0000000000..f5b97a56bb
Binary files /dev/null and b/ressourcen/code-ressourcen/miglayout-3.7.3.1-sources.jar differ
diff --git a/ressourcen/libs/miglayout.jar b/ressourcen/libs/miglayout.jar
index e1175963e3..73d30eb9e2 100644
Binary files a/ressourcen/libs/miglayout.jar and b/ressourcen/libs/miglayout.jar differ
diff --git a/src/jd/gui/swing/jdgui/views/settings/panels/reconnect/MethodSelection.java b/src/jd/gui/swing/jdgui/views/settings/panels/reconnect/MethodSelection.java
index 0e1be8225f..b2f9ce4685 100644
--- a/src/jd/gui/swing/jdgui/views/settings/panels/reconnect/MethodSelection.java
+++ b/src/jd/gui/swing/jdgui/views/settings/panels/reconnect/MethodSelection.java
@@ -20,6 +20,7 @@ import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
@@ -294,7 +295,7 @@ public class MethodSelection extends ConfigPanel implements ActionListener {
};
cp.initPanel();
+ cp.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0));
return cp;
}
-
}
diff --git a/src/jd/gui/swing/jdgui/views/settings/panels/reconnect/SubPanelCLRReconnect.java b/src/jd/gui/swing/jdgui/views/settings/panels/reconnect/SubPanelCLRReconnect.java
index 2a32ae3d1a..ab1565197b 100644
--- a/src/jd/gui/swing/jdgui/views/settings/panels/reconnect/SubPanelCLRReconnect.java
+++ b/src/jd/gui/swing/jdgui/views/settings/panels/reconnect/SubPanelCLRReconnect.java
@@ -20,8 +20,6 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
import jd.config.ConfigContainer;
import jd.config.ConfigEntry;
@@ -42,8 +40,6 @@ public class SubPanelCLRReconnect extends ConfigPanel implements ActionListener
private GUIConfigEntry ip;
- private GUIConfigEntry script;
-
public SubPanelCLRReconnect(Configuration configuration) {
super();
this.configuration = configuration;
@@ -59,35 +55,19 @@ public class SubPanelCLRReconnect extends ConfigPanel implements ActionListener
@Override
public void initPanel() {
-
- JPanel buttons = new JPanel();
- buttons.setLayout(new MigLayout("ins 0, wrap 3"));
-
- // JDUtilities.addToGridBag(panel, btnSelectRouter, 0, 0, 1, 1, 0, 1,
- // insets, GridBagConstraints.NONE, GridBagConstraints.WEST);
-
btnFindIP = new JButton(JDL.L("gui.config.liveHeader.btnfindip", "Fetch Router IP"));
btnFindIP.addActionListener(this);
- buttons.add(btnFindIP, "width 160!");
- panel.add(buttons, "spanx,gapleft 0,gaptop 10");
+ panel.setLayout(new MigLayout("ins 5, wrap 2", "[fill]10[grow,fill]"));
+ panel.add(btnFindIP, "wrap");
+
addGUIConfigEntry(new GUIConfigEntry(new ConfigEntry(ConfigContainer.TYPE_TEXTFIELD, configuration, Configuration.PARAM_HTTPSEND_USER, JDL.L("gui.config.liveheader.user", "Login User (->%%%user%%%)"))));
addGUIConfigEntry(new GUIConfigEntry(new ConfigEntry(ConfigContainer.TYPE_PASSWORDFIELD, configuration, Configuration.PARAM_HTTPSEND_PASS, JDL.L("gui.config.liveheader.password", "Login Password (->%%%pass%%%)"))));
addGUIConfigEntry(ip = new GUIConfigEntry(new ConfigEntry(ConfigContainer.TYPE_TEXTFIELD, configuration, Configuration.PARAM_HTTPSEND_IP, JDL.L("gui.config.liveheader.routerip", "RouterIP (->%%%routerip%%%)"))));
+ addGUIConfigEntry(new GUIConfigEntry(new ConfigEntry(ConfigContainer.TYPE_TEXTAREA, configuration, Configuration.PARAM_HTTPSEND_REQUESTS_CLR, null)));
- panel.add(new JScrollPane((script = new GUIConfigEntry(new ConfigEntry(ConfigContainer.TYPE_TEXTAREA, configuration, Configuration.PARAM_HTTPSEND_REQUESTS_CLR, JDL.L("gui.config.liveheader.script", "HTTP Script")))).getInput()[0]), "gaptop 10,spanx,gapright 20,pushy, growy");
-
- script.setData(configuration.getStringProperty(Configuration.PARAM_HTTPSEND_REQUESTS_CLR));
- // routerScript = new GUIConfigEntry();
- // this.entries.add(routerScript);
-
- add(panel);
- // add(routerScript);
- }
-
- @Override
- public void saveSpecial() {
- configuration.setProperty(Configuration.PARAM_HTTPSEND_REQUESTS_CLR, script.getText());
+ this.setBorder(null);
+ this.add(panel);
}
}
diff --git a/src/jd/gui/swing/jdgui/views/settings/panels/reconnect/SubPanelLiveHeaderReconnect.java b/src/jd/gui/swing/jdgui/views/settings/panels/reconnect/SubPanelLiveHeaderReconnect.java
index 5f4c6d1aaf..c1fc3d55d2 100644
--- a/src/jd/gui/swing/jdgui/views/settings/panels/reconnect/SubPanelLiveHeaderReconnect.java
+++ b/src/jd/gui/swing/jdgui/views/settings/panels/reconnect/SubPanelLiveHeaderReconnect.java
@@ -20,7 +20,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
-import javax.swing.JScrollPane;
+import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
@@ -34,7 +34,6 @@ import jd.gui.swing.dialog.ImportRouterDialog;
import jd.gui.swing.jdgui.views.settings.ConfigPanel;
import jd.gui.swing.jdgui.views.settings.GUIConfigEntry;
import jd.router.FindRouterIP;
-import jd.router.GetRouterInfo;
import jd.router.reconnectrecorder.Gui;
import jd.utils.locale.JDL;
import net.miginfocom.swing.MigLayout;
@@ -45,8 +44,6 @@ public class SubPanelLiveHeaderReconnect extends ConfigPanel implements ActionLi
private Configuration configuration;
- private JButton btnAutoConfig;
-
private JButton btnFindIP;
private JButton btnSelectRouter;
@@ -128,60 +125,36 @@ public class SubPanelLiveHeaderReconnect extends ConfigPanel implements ActionLi
if (pw == null || pw.matches("[\\s]*")) {
pass.setData(data[5]);
}
-
}
- } else if (e.getSource() == btnAutoConfig) {
- GetRouterInfo.autoConfig(pass, user, ip, script);
}
-
}
@Override
public void initPanel() {
+ JPanel buttons = new JPanel(new MigLayout("ins 0"));
- this.setLayout(new MigLayout("ins 0 20 0 20, wrap 2", "[grow 20,fill][grow,fill]", "[]5[]5[]"));
btnSelectRouter = new JButton(JDL.L("gui.config.liveheader.selectrouter", "Select Router"));
btnSelectRouter.addActionListener(this);
- add(btnSelectRouter, "gaptop 10");
- add(panel, "spany 3,gapbottom 20");
+ buttons.add(btnSelectRouter, "sizegroup btns");
btnFindIP = new JButton(JDL.L("gui.config.liveheader.btnfindip", "Fetch Router IP"));
btnFindIP.addActionListener(this);
- add(btnFindIP);
- // JDUtilities.addToGridBag(panel, btnFindIP, 1, 0, 1, 1, 0, 1, insets,
- // GridBagConstraints.NONE, GridBagConstraints.WEST);
+ buttons.add(btnFindIP, "sizegroup btns");
- btnAutoConfig = new JButton(JDL.L("gui.config.liveheader.autoconfig", "Config router automatically"));
- btnAutoConfig.addActionListener(this);
-
- // add(btnAutoConfig,"aligny top");
- // JDUtilities.addToGridBag(panel, btnAutoConfig, 2, 0,
- // GridBagConstraints.REMAINDER, 1, 0, 1, insets,
- // GridBagConstraints.NONE, GridBagConstraints.WEST);
btnRouterRecorder = new JButton(JDL.L("gui.config.liveheader.recorder", "Create Reconnect Script"));
btnRouterRecorder.addActionListener(this);
- add(btnRouterRecorder, "aligny top");
- panel.setLayout(new MigLayout("ins 10 10 10 0,wrap 2", "[fill,grow 10]10[fill,grow]"));
- user = new GUIConfigEntry(new ConfigEntry(ConfigContainer.TYPE_TEXTFIELD, configuration, Configuration.PARAM_HTTPSEND_USER, JDL.L("gui.config.httpliveheader.user", "User")));
- addGUIConfigEntry(user);
- pass = new GUIConfigEntry(new ConfigEntry(ConfigContainer.TYPE_PASSWORDFIELD, configuration, Configuration.PARAM_HTTPSEND_PASS, JDL.L("gui.config.httpliveheader.password", "Password")));
- addGUIConfigEntry(pass);
- ip = new GUIConfigEntry(new ConfigEntry(ConfigContainer.TYPE_TEXTFIELD, configuration, Configuration.PARAM_HTTPSEND_IP, JDL.L("gui.config.httpliveheader.routerip", "Router's ip")));
- addGUIConfigEntry(ip);
+ buttons.add(btnRouterRecorder, "sizegroup btns");
- add(new JScrollPane((script = new GUIConfigEntry(new ConfigEntry(ConfigContainer.TYPE_TEXTAREA, configuration, Configuration.PARAM_HTTPSEND_REQUESTS, JDL.L("gui.config.httpliveheader.script", "Reconnection Script")))).getInput()[0]), "gaptop 10,spanx,gapright 20,pushy, growy");
+ panel.setLayout(new MigLayout("ins 5, wrap 2", "[fill]10[grow,fill]"));
+ panel.add(buttons, "spanx");
- script.setData(configuration.getStringProperty(Configuration.PARAM_HTTPSEND_REQUESTS));
- // sp.setBorder(null);
- // routerScript = new GUIConfigEntry();
- // this.entries.add(routerScript);
+ addGUIConfigEntry(user = new GUIConfigEntry(new ConfigEntry(ConfigContainer.TYPE_TEXTFIELD, configuration, Configuration.PARAM_HTTPSEND_USER, JDL.L("gui.config.httpliveheader.user", "User"))));
+ addGUIConfigEntry(pass = new GUIConfigEntry(new ConfigEntry(ConfigContainer.TYPE_PASSWORDFIELD, configuration, Configuration.PARAM_HTTPSEND_PASS, JDL.L("gui.config.httpliveheader.password", "Password"))));
+ addGUIConfigEntry(ip = new GUIConfigEntry(new ConfigEntry(ConfigContainer.TYPE_TEXTFIELD, configuration, Configuration.PARAM_HTTPSEND_IP, JDL.L("gui.config.httpliveheader.routerip", "Router's ip"))));
+ addGUIConfigEntry(script = new GUIConfigEntry(new ConfigEntry(ConfigContainer.TYPE_TEXTAREA, configuration, Configuration.PARAM_HTTPSEND_REQUESTS, null)));
- // add(routerScript);
- }
-
- @Override
- public void saveSpecial() {
- configuration.setProperty(Configuration.PARAM_HTTPSEND_REQUESTS, script.getText());
+ this.setBorder(null);
+ this.add(panel);
}
}
\ No newline at end of file
diff --git a/src/jd/router/FindRouterIP.java b/src/jd/router/FindRouterIP.java
index b34ae4f683..c17562282c 100644
--- a/src/jd/router/FindRouterIP.java
+++ b/src/jd/router/FindRouterIP.java
@@ -25,6 +25,7 @@ import jd.nrouter.RouterUtils;
import jd.utils.locale.JDL;
public class FindRouterIP {
+
public static String findIP(GUIConfigEntry ip) {
final ProgressController progress = new ProgressController(JDL.L("gui.config.routeripfinder.featchIP", "Search for routers hostname..."), 100, null);
@@ -49,9 +50,8 @@ public class FindRouterIP {
}
public FindRouterIP(final GUIConfigEntry ip) {
-
new Thread() {
- // @Override
+ @Override
public void run() {
findIP(ip);
}
diff --git a/src/jd/router/GetMacAdress.java b/src/jd/router/GetMacAdress.java
deleted file mode 100644
index d3c4813c6c..0000000000
--- a/src/jd/router/GetMacAdress.java
+++ /dev/null
@@ -1,111 +0,0 @@
-// jDownloader - Downloadmanager
-// Copyright (C) 2009 JD-Team support@jdownloader.org
-//
-// 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 3 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, see .
-
-package jd.router;
-
-import java.net.InetAddress;
-
-import jd.controlling.JDLogger;
-import jd.nutils.OSDetector;
-import jd.parser.Regex;
-import jd.utils.JDUtilities;
-import jd.utils.StringUtil;
-
-public final class GetMacAdress {
- /**
- * Don't let anyone instantiate this class.
- */
- private GetMacAdress() {
- }
-
- public static String getMacAddress() throws Exception {
- try {
- return GetMacAdress.getMacAddress(RouterInfoCollector.getRouterIP());
- } catch (Exception e) {
- JDLogger.exception(e);
- }
- return null;
- }
-
- public static String getMacAddress(final InetAddress hostAddress) throws Exception {
- final String resultLine = callArpTool(hostAddress.getHostAddress());
- String rd = new Regex(resultLine, "..?[:\\-]..?[:\\-]..?[:\\-]..?[:\\-]..?[:\\-]..?").getMatch(-1).replaceAll("-", ":");
- if (rd == null) return null;
- rd = rd.replaceAll("\\s", "0");
- final String[] d = rd.split("[:\\-]");
- final StringBuilder ret = new StringBuilder(18);
- for (final String string : d) {
- if (string.length() < 2) {
- ret.append('0');
- }
- ret.append(string);
- ret.append(':');
- }
- return ret.toString().substring(0, 17);
- }
-
- private static String callArpTool(final String ipAddress) throws Exception {
- if (OSDetector.isWindows()) return callArpToolWindows(ipAddress);
- return callArpToolDefault(ipAddress);
- }
-
- private static String callArpToolWindows(final String ipAddress) throws Exception {
- final ProcessBuilder pb = new ProcessBuilder(new String[] { "ping", ipAddress });
- pb.start();
- final String[] parts = JDUtilities.runCommand("arp", new String[] { "-a" }, null, 10).split(StringUtil.LINE_SEPARATOR);
- pb.directory();
- for (final String part : parts) {
- if (part.indexOf(ipAddress) > -1) { return part; }
- }
- return null;
- }
-
- private static String callArpToolDefault(final String ipAddress) throws Exception {
- String out = null;
- final InetAddress hostAddress = InetAddress.getByName(ipAddress);
- ProcessBuilder pb = null;
- try {
- pb = new ProcessBuilder(new String[] { "ping", ipAddress });
- pb.start();
- out = JDUtilities.runCommand("arp", new String[] { ipAddress }, null, 10);
- pb.directory();
- if (!out.matches("(?is).*((" + hostAddress.getHostName() + "|" + hostAddress.getHostAddress() + ").*..?[:\\-]..?[:\\-]..?[:\\-]..?[:\\-]..?[:\\-]..?|.*..?[:\\-]..?[:\\-]..?[:\\-]..?[:\\-]..?[:\\-]..?.*(" + hostAddress.getHostName() + "|" + hostAddress.getHostAddress() + ")).*")) out = null;
- } catch (Exception e) {
- if (pb != null) pb.directory();
- }
- if (out == null || out.trim().length() == 0) {
- try {
- pb = new ProcessBuilder(new String[] { "ping", ipAddress });
- pb.start();
- out = JDUtilities.runCommand("ip", new String[] { "neigh", "show" }, null, 10);
- pb.directory();
- if (out != null) {
- if (!out.matches("(?is).*((" + hostAddress.getHostName() + "|" + hostAddress.getHostAddress() + ").*..?[:\\-]..?[:\\-]..?[:\\-]..?[:\\-]..?[:\\-]..?|.*..?[:\\-]..?[:\\-]..?[:\\-]..?[:\\-]..?[:\\-]..?.*(" + hostAddress.getHostName() + "|" + hostAddress.getHostAddress() + ")).*")) {
- out = null;
- } else {
- out = new Regex(out, "(" + hostAddress.getHostName() + "|" + hostAddress.getHostAddress() + ")[^\r\n]*").getMatch(-1);
- }
- }
- } catch (Exception e) {
- if (pb != null) {
- pb.directory();
- }
- }
- }
- return out;
- }
-
-}
diff --git a/src/jd/router/GetRouterInfo.java b/src/jd/router/GetRouterInfo.java
deleted file mode 100644
index fcfe6462ae..0000000000
--- a/src/jd/router/GetRouterInfo.java
+++ /dev/null
@@ -1,399 +0,0 @@
-// jDownloader - Downloadmanager
-// Copyright (C) 2008 JD-Team support@jdownloader.org
-//
-// 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 3 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, see .
-
-package jd.router;
-
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-
-import javax.swing.JTextField;
-
-import jd.config.Configuration;
-import jd.controlling.JDLogger;
-import jd.controlling.reconnect.ReconnectMethod;
-import jd.controlling.reconnect.Reconnecter;
-import jd.gui.UserIO;
-import jd.gui.swing.GuiRunnable;
-import jd.gui.swing.dialog.ProgressDialog;
-import jd.gui.swing.jdgui.views.settings.GUIConfigEntry;
-import jd.gui.userio.DummyFrame;
-import jd.http.Browser;
-import jd.nutils.JDFlags;
-import jd.nutils.Threader;
-import jd.nutils.Threader.WorkerListener;
-import jd.nutils.jobber.JDRunnable;
-import jd.utils.JDUtilities;
-import jd.utils.locale.JDL;
-
-public class GetRouterInfo {
-
- private Threader threader = null;
- private Threader th2 = null;
- private boolean cancel = false;
-
- public void cancel() {
- cancel = true;
- if (threader != null) {
- try {
- threader.interrupt();
- } catch (Exception e) {
- }
- } else if (th2 != null) {
- try {
- th2.interrupt();
- } catch (Exception e) {
- }
- }
-
- }
-
- private Logger logger = JDLogger.getLogger();
-
- public String username = null;
-
- public String password = null;
-
- private ProgressDialog progressBar;
-
- public GetRouterInfo(ProgressDialog progress) {
- progressBar = progress;
- if (progressBar != null) {
- progressBar.setMaximum(100);
- }
- }
-
- public static LinkedHashMap sortByIntegrety(Map map) {
- LinkedList> list = new LinkedList>(map.entrySet());
- Collections.sort(list, new Comparator>() {
- public int compare(Entry o1, Entry o2) {
- if (o1.getValue().equals((o2).getValue())) {
- return o2.getKey().compareTo(o1.getKey());
- } else
- return o1.getValue().compareTo(o2.getValue());
- }
- });
- LinkedHashMap result = new LinkedHashMap();
- for (Entry entry : list) {
- result.put(entry.getKey(), entry.getValue());
- }
- return result;
- }
-
- private RInfo checkRouters(HashMap routers) {
- int retries = JDUtilities.getConfiguration().getIntegerProperty(ReconnectMethod.PARAM_RETRIES, 5);
- int wipchange = JDUtilities.getConfiguration().getIntegerProperty(ReconnectMethod.PARAM_WAITFORIPCHANGE, 20);
- JDUtilities.getConfiguration().setProperty(ReconnectMethod.PARAM_RETRIES, 0);
- JDUtilities.getConfiguration().setProperty(ReconnectMethod.PARAM_WAITFORIPCHANGE, 10);
- JDUtilities.getConfiguration().setProperty(Configuration.PARAM_HTTPSEND_USER, username);
- JDUtilities.getConfiguration().setProperty(Configuration.PARAM_HTTPSEND_PASS, password);
- int size = routers.size();
- int i = 0;
- for (Entry info2 : routers.entrySet()) {
- if (cancel) return null;
- if (info2.getKey().getReconnectMethode() != null) {
- JDUtilities.getConfiguration().setProperty(ReconnectMethod.PARAM_RECONNECT_TYPE, ReconnectMethod.LIVEHEADER);
- JDUtilities.getConfiguration().setProperty(Configuration.PARAM_HTTPSEND_REQUESTS, info2.getKey().getReconnectMethode());
- } else if (info2.getKey().getReconnectMethodeClr() != null) {
- JDUtilities.getConfiguration().setProperty(ReconnectMethod.PARAM_RECONNECT_TYPE, ReconnectMethod.CLR);
- JDUtilities.getConfiguration().setProperty(Configuration.PARAM_HTTPSEND_REQUESTS_CLR, info2.getKey().getReconnectMethodeClr());
- } else
- continue;
- setProgressText(JDL.L("gui.config.routeripfinder.status.testingrouter", "Testing router") + " " + info2.getKey().getRouterName() + " ...");
- setProgress(i++ * 100 / size);
-
- JDUtilities.getConfiguration().save();
- if (Reconnecter.waitForNewIP(1, true)) {
- JDUtilities.getConfiguration().setProperty(ReconnectMethod.PARAM_RETRIES, retries);
- JDUtilities.getConfiguration().setProperty(ReconnectMethod.PARAM_WAITFORIPCHANGE, wipchange);
- JDUtilities.getConfiguration().save();
- setProgress(100);
- return info2.getKey();
- }
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public RInfo getRouterData() {
-
- setProgressText(JDL.L("gui.config.routeripfinder.status.collectingrouterinfo", "Collecting router information..."));
-
- final RInfo infos = RouterInfoCollector.getRInfo(RouterInfoCollector.RInfo_ROUTERSEARCH);
- infos.setReconnectMethode(null);
- infos.setReconnectMethodeClr(null);
- th2 = new Threader();
- final class isalvs {
- boolean isAlv = true;
- ArrayList meths = null;
- HashMap SCPDs = null;
- }
- final isalvs isalv = new isalvs();
- final JDRunnable jupnp = new JDRunnable() {
-
- public void go() throws Exception {
-
- try {
- UPnPInfo upnp = new UPnPInfo(InetAddress.getByName(infos.getRouterHost()));
- if (upnp.met != null && upnp.met.size() != 0) {
- isalv.SCPDs = upnp.SCPDs;
- isalv.meths = upnp.met;
-
- }
- } catch (Exception e) {
- }
- isalv.isAlv = false;
- }
-
- };
-
- th2.getBroadcaster().addListener(new WorkerListener() {
-
- public void onThreadException(Threader th, JDRunnable job, Throwable e) {
- }
-
- public void onThreadFinished(Threader th, JDRunnable runnable) {
- if (runnable == jupnp) {
- isalv.isAlv = false;
- th2.notify();
- }
- }
-
- public void onThreadStarts(Threader threader, JDRunnable runnable) {
- }
-
- });
- th2.add(jupnp);
- th2.add(new JDRunnable() {
-
- public void go() throws Exception {
- try {
-
- LinkedHashMap routers = new LinkedHashMap();
- int upnp = 0;
- Browser br = new Browser();
- LinkedHashMap he = new LinkedHashMap();
- if (infos.getRouterHost() != null) he.put("RouterHost", infos.getRouterHost());
- if (infos.getRouterHost() != null) he.put("RouterMAC", infos.getRouterMAC());
- if (infos.getPageHeader() != null) he.put("PageHeader", SQLRouterData.replaceTimeStamps(infos.getPageHeader()));
- if (infos.getRouterErrorPage() != null) he.put("RouterErrorPage", SQLRouterData.replaceTimeStamps(infos.getRouterErrorPage()));
- he.put("HTMLTagCount", "" + infos.countHtmlTags());
- ArrayList ra;
- try {
- setProgressText(JDL.L("gui.config.routeripfinder.status.downloadlingsimilarmethods", "Downloading similar router methods..."));
- String st = br.postPage("http://service.jdownloader.org/routerdb/getRouters.php", he);
- ra = (ArrayList) JDUtilities.xmlStringToObjekt(st);
- } catch (Exception e) {
- return;
- }
- setProgressText(JDL.L("gui.config.routeripfinder.status.sortingmethods", "Sorting router methods..."));
- for (RInfo info : ra) {
- if (info.isHaveUpnpReconnect()) upnp++;
-
- if (info.getReconnectMethodeClr() != null) {
- Integer b = info.compare(infos);
- info.setIntegrety(200);
- routers.put(info, b);
- } else if (info.getReconnectMethode() != null) {
- Integer b = info.compare(infos);
- if (info.getIntegrety() > 3) {
- routers.put(info, b);
- }
- }
- }
-
- routers = sortByIntegrety(routers);
- HashMap methodes = new HashMap();
- Iterator> inter = routers.entrySet().iterator();
- while (inter.hasNext()) {
- Map.Entry entry = inter.next();
- RInfo meth = methodes.get(entry.getKey().getReconnectMethode());
- if (meth != null) {
- meth.setIntegrety(meth.getIntegrety() + entry.getKey().getIntegrety());
- inter.remove();
- } else
- methodes.put(entry.getKey().getReconnectMethode(), entry.getKey());
- }
- routers = sortByIntegrety(routers);
- if (upnp > 0) {
- while (isalv.isAlv) {
- try {
- wait();
- } catch (Exception e) {
- }
-
- }
- if (isalv.meths == null) {
-
- UserIO.setCountdownTime(600);
- int ret = UserIO.getInstance().requestConfirmDialog(0, null, JDL.LF("gui.config.liveheader.warning.upnpinactive", "Please activate UPnP support in your router's network configuration.
Go to Router
Wiki article: Upnp in Router
Click OK when you activate UPnP support in router or Cancel to skip.", infos.getRouterHost()), UserIO.getInstance().getIcon(UserIO.ICON_WARNING), null, null);
- UserIO.setCountdownTime(-1);
- if (JDFlags.hasAllFlags(ret, UserIO.RETURN_OK)) {
- try {
- setProgressText(JDL.L("gui.config.routeripfinder.status.testingupnp", "Testing UPnP..."));
- for (int i = 0; i < 30 && !cancel; i++) {
- setProgress(i++ * 100 / 30);
- UPnPInfo upnpd = new UPnPInfo(InetAddress.getByName(infos.getRouterHost()), 10000);
- if (upnpd.met != null) {
- infos.setUPnPSCPDs(upnpd.SCPDs);
- if (upnpd.met != null && upnpd.met.size() != 0) {
-
- isalv.SCPDs = upnpd.SCPDs;
- isalv.meths = upnpd.met;
- }
- break;
- }
- }
- } catch (Exception e) {
- }
- }
- }
- }
- JDUtilities.getConfiguration().setProperty(Configuration.PARAM_HTTPSEND_IP, infos.getRouterHost());
- RInfo router = null;
- if (isalv.meths != null) {
- HashMap upnprouters = new HashMap();
- for (String info : isalv.meths) {
- RInfo tempinfo = new RInfo();
- tempinfo.setRouterHost(infos.getRouterHost());
- tempinfo.setRouterIP(infos.getRouterIP());
- tempinfo.setUPnPSCPDs(isalv.SCPDs);
- tempinfo.setReconnectMethode(info);
- tempinfo.setRouterName("UPNP:" + tempinfo.getRouterName());
- upnprouters.put(tempinfo, 1);
- }
- router = checkRouters(upnprouters);
-
- }
- if (router == null) {
- router = checkRouters(routers);
- }
- setProgress(100);
- if (router != null) {
- infos.setRouterName(router.getRouterName());
- infos.setReconnectMethode(router.getReconnectMethode());
- infos.setReconnectMethodeClr(router.getReconnectMethodeClr());
- }
- } catch (Exception e) {
- JDLogger.exception(e);
- }
- setProgress(100);
- }
- });
- th2.startAndWait();
- if (infos.getReconnectMethode() != null || infos.getReconnectMethodeClr() != null)
- return infos;
- else
- return null;
- }
-
- private void setProgress(final int val) {
- new GuiRunnable