explicit merge of '59eae97dbb470d8c4a1e4dba3a9763e134bb0c53'

and 'aeec86a504a5fd67dff12d6775411a9c865d42ad'


Merge to aeec86a504a5fd67dff12d6775411a9c865d42ad
which is just before the 2009-08-11 whitespace cleanup at ef1c23821d433903124f7612cbc46ac096fc985b
This commit is contained in:
zzz
2012-05-25 19:36:22 +00:00
994 changed files with 128750 additions and 9391 deletions

View File

@@ -401,12 +401,22 @@ public class HTTPRequest extends HTTPPacket
InputStream in = null;
try {
if (postSocket == null){
// Thanks for Hao Hu
if (postSocket == null) {
// Mod for I2P
// We can't handle the default system soTimeout of 3 minutes or so
// as when the device goes away, this hangs the display of peers.jsp
// and who knows what else.
// Set the timeout to be nice and short, the device should be local and fast.
// Yeah, the UPnP standard is a minute or something, too bad.
// If he can't get back to us in a few seconds, forget it.
// And set the soTimeout to 1 second (for reads).
//postSocket = new Socket(host, port);
postSocket = new Socket();
postSocket.connect(new InetSocketAddress(host, port), HTTPServer.DEFAULT_TIMEOUT);
}
postSocket.setSoTimeout(1000);
SocketAddress sa = new InetSocketAddress(host, port);
postSocket.connect(sa, 3000);
}
out = postSocket.getOutputStream();
PrintStream pout = new PrintStream(out);
pout.print(getHeader());
@@ -522,6 +532,6 @@ public class HTTPRequest extends HTTPPacket
public void print()
{
System.out.println(toString());
Debug.message(toString());
}
}

View File

@@ -20,6 +20,7 @@
package org.cybergarage.http;
import java.io.InputStream;
import org.cybergarage.util.Debug;
public class HTTPResponse extends HTTPPacket
{
@@ -111,6 +112,6 @@ public class HTTPResponse extends HTTPPacket
public void print()
{
System.out.println(toString());
Debug.message(toString());
}
}

View File

@@ -147,6 +147,7 @@ public class HTTPServer implements Runnable
serverSock = new ServerSocket(bindPort, 0, bindAddr);
}
catch (IOException e) {
Debug.warning("HTTP server open failed " + addr + " " + port, e);
return false;
}
return true;

View File

@@ -401,7 +401,7 @@ public class Action
public void print()
{
System.out.println("Action : " + getName());
Debug.message("Action : " + getName());
ArgumentList argList = getArgumentList();
int nArgs = argList.size();
for (int n=0; n<nArgs; n++) {
@@ -409,7 +409,7 @@ public class Action
String name = arg.getName();
String value = arg.getValue();
String dir = arg.getDirection();
System.out.println(" [" + n + "] = " + dir + ", " + name + ", " + value);
Debug.message(" [" + n + "] = " + dir + ", " + name + ", " + value);
}
}

View File

@@ -293,18 +293,25 @@ public class ControlPoint implements HTTPRequestListener
for (int n=0; n<nRoots; n++) {
Node rootNode = devNodeList.getNode(n);
Device dev = getDevice(rootNode);
if (dev == null)
continue;
devList.add(dev);
}
return devList;
}
public Device getDevice(String name)
{
int nRoots = devNodeList.size();
for (int n=0; n<nRoots; n++) {
Node rootNode = devNodeList.getNode(n);
if (dev == null)
continue;
devList.add(dev);
}
return devList;
}
public Device getDevice(String name)
{
int nRoots = devNodeList.size();
for (int n=0; n<nRoots; n++) {
// AIOOB was thrown from here, maybe would be better to
// copy the list before traversal?
Node rootNode;
try {
rootNode = devNodeList.getNode(n);
} catch (ArrayIndexOutOfBoundsException aioob) {
break;
}
Device dev = getDevice(rootNode);
if (dev == null)
continue;
@@ -825,9 +832,13 @@ public class ControlPoint implements HTTPRequestListener
HTTPServerList httpServerList = getHTTPServerList();
while (httpServerList.open(bindPort) == false) {
retryCnt++;
if (UPnP.SERVER_RETRY_COUNT < retryCnt)
if (UPnP.SERVER_RETRY_COUNT < retryCnt) {
Debug.warning("Failed to open HTTP event listener port " + bindPort);
// I2P do we really need this, or can we just break ?
return false;
setHTTPPort(bindPort + 1);
}
// I2P go down not up so we don't run into other I2P things
setHTTPPort(bindPort - 1);
bindPort = getHTTPPort();
}
httpServerList.addRequestListener(this);
@@ -838,8 +849,10 @@ public class ControlPoint implements HTTPRequestListener
////////////////////////////////////////
SSDPNotifySocketList ssdpNotifySocketList = getSSDPNotifySocketList();
if (ssdpNotifySocketList.open() == false)
if (ssdpNotifySocketList.open() == false) {
Debug.warning("Failed to open SSDP notify port 1900");
return false;
}
ssdpNotifySocketList.setControlPoint(this);
ssdpNotifySocketList.start();
@@ -852,9 +865,12 @@ public class ControlPoint implements HTTPRequestListener
SSDPSearchResponseSocketList ssdpSearchResponseSocketList = getSSDPSearchResponseSocketList();
while (ssdpSearchResponseSocketList.open(ssdpPort) == false) {
retryCnt++;
if (UPnP.SERVER_RETRY_COUNT < retryCnt)
if (UPnP.SERVER_RETRY_COUNT < retryCnt) {
Debug.warning("Failed to open SSDP search response port " + ssdpPort);
return false;
setSSDPPort(ssdpPort + 1);
}
// I2P go down not up so we don't run into other I2P things
setSSDPPort(ssdpPort - 1);
ssdpPort = getSSDPPort();
}
ssdpSearchResponseSocketList.setControlPoint(this);

View File

@@ -47,7 +47,8 @@ public class UPnP
public final static String NAME = "CyberLinkJava";
public final static String VERSION = "1.8";
public final static int SERVER_RETRY_COUNT = 100;
// I2P was 100
public final static int SERVER_RETRY_COUNT = 4;
public final static int DEFAULT_EXPIRED_DEVICE_EXTRA_TIME = 60;
public final static String getServerName()

View File

@@ -51,6 +51,7 @@ public class Disposer extends ThreadCore
public void run()
{
Thread.currentThread().setName("UPnP-Disposer");
ControlPoint ctrlp = getControlPoint();
long monitorInterval = ctrlp.getExpiredDeviceMonitoringInterval() * 1000;

View File

@@ -188,6 +188,10 @@ public class NotifyRequest extends SOAPRequest
public PropertyList getPropertyList() {
PropertyList properties = new PropertyList();
Node varSetNode = getEnvelopeNode();
// I2P change: ParserException caught in getRootNode() causes
// getEnvelopeNode() to return null
if (varSetNode == null)
return properties;
for (int i = 0; i<varSetNode.getNNodes(); i++){
Node propNode = varSetNode.getNode(i);
if (propNode == null)
@@ -198,4 +202,4 @@ public class NotifyRequest extends SOAPRequest
return properties;
}
}
}

View File

@@ -130,7 +130,8 @@ public class SSDPNotifySocket extends HTTPMUSocket implements Runnable
InetAddress maddr = getMulticastInetAddress();
InetAddress pmaddr = packet.getHostInetAddress();
if (maddr.equals(pmaddr) == false) {
Debug.warning("Invalidate Multicast Recieved from IP " + maddr + " on " + pmaddr);
// I2P
//Debug.warning("Invalidate Multicast Recieved : " + maddr + "," + pmaddr);
continue;
}
//TODO Must be performed on a different Thread in order to prevent UDP packet losses.

View File

@@ -1,81 +1,65 @@
/******************************************************************
*
* CyberUtil for Java
*
* Copyright (C) Satoshi Konno 2002
*
* File: Debug.java
*
* Revision;
*
* 11/18/02
* - first revision.
*
******************************************************************/
package org.cybergarage.util;
import java.io.PrintStream;
public final class Debug{
public static Debug debug = new Debug();
private PrintStream out = System.out;
public Debug(){
}
public synchronized PrintStream getOut() {
return out;
}
public synchronized void setOut(PrintStream out) {
this.out = out;
}
public static boolean enabled = false;
public static Debug getDebug(){
return Debug.debug;
}
public static final void on() {
enabled = true;
}
public static final void off() {
enabled = false;
}
public static boolean isOn() {
return enabled;
}
public static final void message(String s) {
if (enabled == true)
Debug.debug.getOut().println("CyberGarage message : " + s);
}
public static final void message(String m1, String m2) {
if (enabled == true)
Debug.debug.getOut().println("CyberGarage message : ");
Debug.debug.getOut().println(m1);
Debug.debug.getOut().println(m2);
}
public static final void warning(String s) {
Debug.debug.getOut().println("CyberGarage warning : " + s);
}
public static final void warning(String m, Exception e) {
if(e.getMessage()==null){
Debug.debug.getOut().println("CyberGarage warning : " + m + " START");
e.printStackTrace(Debug.debug.getOut());
Debug.debug.getOut().println("CyberGarage warning : " + m + " END");
}else{
Debug.debug.getOut().println("CyberGarage warning : " + m + " (" + e.getMessage() + ")");
e.printStackTrace(Debug.debug.getOut());
}
}
public static final void warning(Exception e) {
warning(e.getMessage());
e.printStackTrace(Debug.debug.getOut());
}
}
/******************************************************************
*
* CyberUtil for Java
*
* Copyright (C) Satoshi Konno 2002
*
* File: Debug.java
*
* Revision;
*
* 11/18/02
* - first revision.
*
******************************************************************/
package org.cybergarage.util;
import net.i2p.I2PAppContext;
import net.i2p.util.Log;
public final class Debug
{
private static Log _log;
/** I2P this is all static so have the UPnPManager call this */
public static void initialize(I2PAppContext ctx) {
_log = ctx.logManager().getLog(Debug.class);
// org.cybergarage.util.Debug=DEBUG at startup
enabled = _log.shouldLog(Log.DEBUG);
}
public static boolean enabled = false;
public static final void on() {
enabled = true;
}
public static final void off() {
enabled = false;
}
public static boolean isOn() {
return enabled;
}
public static final void message(String s) {
if (_log != null)
_log.debug(s);
}
public static final void message(String m1, String m2) {
if (_log != null) {
_log.debug(m1);
_log.debug(m2);
}
}
public static final void warning(String s) {
if (_log != null)
_log.error(s);
}
public static final void warning(String m, Exception e) {
if (_log != null)
_log.error(m, e);
}
public static final void warning(Exception e) {
if (_log != null)
_log.error("", e);
}
}

View File

@@ -1,57 +0,0 @@
* import java.io.IOException;
* import java.io.StringReader;
* import plugins.JabberLinker.org.xmlpull.v1.<a href="XmlPullParserException.html">XmlPullParserException.html</a>;
* import plugins.JabberLinker.org.xmlpull.v1.<a href="XmlPullParserFactory.html">XmlPullParserFactory</a>;
* import plugins.JabberLinker.org.xmlpull.v1.XmlPullParser;
//import plugins.UPnP.org.cybergarage.util.*;
import java.io.*;
import java.io.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.net.*;
import java.net.*;
import java.util.*;
import java.util.*;
import java.util.Calendar;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.TimeZone;
import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.xml.sax.InputSource;
import plugins.UPnP.org.cybergarage.http.*;
import plugins.UPnP.org.cybergarage.http.*;
import plugins.UPnP.org.cybergarage.net.*;
import plugins.UPnP.org.cybergarage.net.*;
import plugins.UPnP.org.cybergarage.soap.*;
import plugins.UPnP.org.cybergarage.soap.*;
import plugins.UPnP.org.cybergarage.upnp.*;
import plugins.UPnP.org.cybergarage.upnp.*;
import plugins.UPnP.org.cybergarage.upnp.Device;
import plugins.UPnP.org.cybergarage.upnp.control.*;
import plugins.UPnP.org.cybergarage.upnp.control.*;
import plugins.UPnP.org.cybergarage.upnp.device.*;
import plugins.UPnP.org.cybergarage.upnp.device.*;
import plugins.UPnP.org.cybergarage.upnp.event.*;
import plugins.UPnP.org.cybergarage.upnp.event.*;
import plugins.UPnP.org.cybergarage.upnp.ssdp.*;
import plugins.UPnP.org.cybergarage.upnp.ssdp.*;
import plugins.UPnP.org.cybergarage.upnp.xml.*;
import plugins.UPnP.org.cybergarage.upnp.xml.*;
import plugins.UPnP.org.cybergarage.util.*;
import plugins.UPnP.org.cybergarage.util.*;
import plugins.UPnP.org.cybergarage.xml.*;
import plugins.UPnP.org.cybergarage.xml.*;
import plugins.UPnP.org.cybergarage.xml.Node;
import plugins.UPnP.org.cybergarage.xml.Parser;
import plugins.UPnP.org.cybergarage.xml.ParserException;
import plugins.UPnP.org.cybergarage.xml.parser.*;

View File

@@ -815,7 +815,7 @@ public interface XmlPullParser {
* <a href="http://www.w3.org/TR/REC-xml-names/#ns-using">Namespaces in XML</a>
* specification to "http://www.w3.org/XML/1998/namespace".
*
* @param zero based index of attribute
* @param index zero based index of attribute
* @return attribute namespace,
* empty string ("") is returned if namesapces processing is not enabled or
* namespaces processing is enabled but attribute has no namespace (it has no prefix).
@@ -828,7 +828,7 @@ public interface XmlPullParser {
* Throws an IndexOutOfBoundsException if the index is out of range
* or current event type is not START_TAG.
*
* @param zero based index of attribute
* @param index zero based index of attribute
* @return attribute name (null is never returned)
*/
String getAttributeName (int index);
@@ -840,7 +840,7 @@ public interface XmlPullParser {
* Throws an IndexOutOfBoundsException if the index is out of range
* or current event type is not START_TAG.
*
* @param zero based index of attribute
* @param index zero based index of attribute
* @return attribute prefix or null if namespaces processing is not enabled.
*/
String getAttributePrefix(int index);
@@ -849,7 +849,7 @@ public interface XmlPullParser {
* Returns the type of the specified attribute
* If parser is non-validating it MUST return CDATA.
*
* @param zero based index of attribute
* @param index zero based index of attribute
* @return attribute type (null is never returned)
*/
String getAttributeType(int index);
@@ -859,7 +859,7 @@ public interface XmlPullParser {
* If parser is non-validating it MUST always return false.
* This information is part of XML infoset:
*
* @param zero based index of attribute
* @param index zero based index of attribute
* @return false if attribute was in input
*/
boolean isAttributeDefault(int index);
@@ -876,7 +876,7 @@ public interface XmlPullParser {
*
* @see #defineEntityReplacementText
*
* @param zero based index of attribute
* @param index zero based index of attribute
* @return value of attribute (null is never returned)
*/
String getAttributeValue(int index);