Search in sources :

Example 16 with Node

use of org.cybergarage.xml.Node in project i2p.i2p by i2p.

the class Device method setNMPRMode.

// //////////////////////////////////////////////
// NMPR
// //////////////////////////////////////////////
public void setNMPRMode(boolean flag) {
    Node devNode = getDeviceNode();
    if (devNode == null)
        return;
    if (flag == true) {
        devNode.setNode(UPnP.INMPR03, UPnP.INMPR03_VERSION);
        devNode.removeNode(Device.URLBASE_NAME);
    } else {
        devNode.removeNode(UPnP.INMPR03);
    }
}
Also used : Node(org.cybergarage.xml.Node)

Example 17 with Node

use of org.cybergarage.xml.Node in project i2p.i2p by i2p.

the class Service method addAction.

public void addAction(Action a) {
    Iterator<Argument> i = a.getArgumentList().iterator();
    while (i.hasNext()) {
        Argument arg = i.next();
        arg.setService(this);
    }
    Node scdpNode = getSCPDNode();
    Node actionListNode = scdpNode.getNode(ActionList.ELEM_NAME);
    if (actionListNode == null) {
        actionListNode = new Node(ActionList.ELEM_NAME);
        scdpNode.addNode(actionListNode);
    }
    actionListNode.addNode(a.getActionNode());
}
Also used : Node(org.cybergarage.xml.Node)

Example 18 with Node

use of org.cybergarage.xml.Node in project i2p.i2p by i2p.

the class Service method getSCPDData.

public byte[] getSCPDData() {
    Node scpdNode = getSCPDNode();
    if (scpdNode == null)
        return new byte[0];
    // Thanks for Mikael Hakman (04/25/05)
    String desc = new String();
    desc += UPnP.XML_DECLARATION;
    desc += "\n";
    desc += scpdNode.toString();
    return desc.getBytes();
}
Also used : Node(org.cybergarage.xml.Node)

Example 19 with Node

use of org.cybergarage.xml.Node in project i2p.i2p by i2p.

the class Service method getSCPDNode.

private Node getSCPDNode() {
    ServiceData data = getServiceData();
    Node scpdNode = data.getSCPDNode();
    if (scpdNode != null)
        return scpdNode;
    // Thanks for Jaap (Sep 18, 2010)
    Device rootDev = getRootDevice();
    if (rootDev == null)
        return null;
    String scpdURLStr = getSCPDURL();
    try {
        URL scpdUrl = new URL(rootDev.getAbsoluteURL(scpdURLStr));
        scpdNode = getSCPDNode(scpdUrl);
        if (scpdNode != null) {
            data.setSCPDNode(scpdNode);
            return scpdNode;
        }
    } catch (Exception e) {
        // I2P
        Debug.warning(e);
    }
    return null;
}
Also used : Node(org.cybergarage.xml.Node) ServiceData(org.cybergarage.upnp.xml.ServiceData) URL(java.net.URL) ParserException(org.cybergarage.xml.ParserException) InvalidDescriptionException(org.cybergarage.upnp.device.InvalidDescriptionException)

Example 20 with Node

use of org.cybergarage.xml.Node in project i2p.i2p by i2p.

the class Service method getActionList.

// //////////////////////////////////////////////
// actionList
// //////////////////////////////////////////////
public ActionList getActionList() {
    ActionList actionList = new ActionList();
    Node scdpNode = getSCPDNode();
    if (scdpNode == null)
        return actionList;
    Node actionListNode = scdpNode.getNode(ActionList.ELEM_NAME);
    if (actionListNode == null)
        return actionList;
    int nNode = actionListNode.getNNodes();
    for (int n = 0; n < nNode; n++) {
        Node node = actionListNode.getNode(n);
        if (Action.isActionNode(node) == false)
            continue;
        Action action = new Action(serviceNode, node);
        actionList.add(action);
    }
    return actionList;
}
Also used : Node(org.cybergarage.xml.Node)

Aggregations

Node (org.cybergarage.xml.Node)58 ParserException (org.cybergarage.xml.ParserException)7 ArrayList (java.util.ArrayList)5 ServiceData (org.cybergarage.upnp.xml.ServiceData)5 Parser (org.cybergarage.xml.Parser)5 IOException (java.io.IOException)4 File (java.io.File)3 Device (org.cybergarage.upnp.Device)3 DeviceData (org.cybergarage.upnp.xml.DeviceData)3 UPnPDevice (org.osgi.service.upnp.UPnPDevice)3 URL (java.net.URL)2 Log (net.i2p.util.Log)2 InvalidDescriptionException (org.cybergarage.upnp.device.InvalidDescriptionException)2 NamedNodeMap (org.w3c.dom.NamedNodeMap)2 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1