org.fourthline.cling.model.profile.RemoteClientInfo Java Examples

The following examples show how to use org.fourthline.cling.model.profile.RemoteClientInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
public Document buildDOM(Device deviceModel, RemoteClientInfo info, Namespace namespace) throws DescriptorBindingException {

        try {
            log.fine("Generating DOM from device model: " + deviceModel);

            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);

            Document d = factory.newDocumentBuilder().newDocument();
            generateRoot(namespace, deviceModel, d, info);

            return d;

        } catch (Exception ex) {
            throw new DescriptorBindingException("Could not generate device descriptor: " + ex.getMessage(), ex);
        }
    }
 
Example #2
Source File: UDA10DeviceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
public Document buildDOM(Device deviceModel, RemoteClientInfo info, Namespace namespace) throws DescriptorBindingException {

        try {
            log.fine("Generating DOM from device model: " + deviceModel);

            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);

            Document d = factory.newDocumentBuilder().newDocument();
            generateRoot(namespace, deviceModel, d, info);

            return d;

        } catch (Exception ex) {
            throw new DescriptorBindingException("Could not generate device descriptor: " + ex.getMessage(), ex);
        }
    }
 
Example #3
Source File: SempDeviceDescriptorBinderImpl.java    From SmartApplianceEnabler with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void generateDevice(Namespace namespace, Device deviceModel, Document descriptor, Element rootElement,
        RemoteClientInfo info) {
    super.generateDevice(namespace, deviceModel, descriptor, rootElement, info);
    
    
    NodeList deviceElements = rootElement.getElementsByTagName(org.fourthline.cling.binding.xml.Descriptor.Device.ELEMENT.device.toString());
    if(deviceElements.getLength() > 0) {
        Element deviceElement = (Element) deviceElements.item(0);
        
        Element sempServiceElement = appendNewElementIfNotNull(
                descriptor, deviceElement, Semp.prefixed(ELEMENT.X_SEMPSERVICE),
                "", "urn:" + Semp.NAMESPACE + ":service-1-0"
        );
        
        appendNewElementIfNotNull(descriptor, sempServiceElement, Semp.prefixed(ELEMENT.server), sempServerUrl);
        appendNewElementIfNotNull(descriptor, sempServiceElement, Semp.prefixed(ELEMENT.basePath), "/semp");
        appendNewElementIfNotNull(descriptor, sempServiceElement, Semp.prefixed(ELEMENT.transport), "HTTP/Pull");
        appendNewElementIfNotNull(descriptor, sempServiceElement, Semp.prefixed(ELEMENT.exchangeFormat), "XML");
        appendNewElementIfNotNull(descriptor, sempServiceElement, Semp.prefixed(ELEMENT.wsVersion), Semp.XSD_VERSION);
    }
}
 
Example #4
Source File: LocalDevice.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
public DeviceDetails getDetails(RemoteClientInfo info) {
    if (getDeviceDetailsProvider() != null) {
        return getDeviceDetailsProvider().provide(info);
    }
    return this.getDetails();
}
 
Example #5
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public String generate(Device deviceModel, RemoteClientInfo info, Namespace namespace) throws DescriptorBindingException {
    try {
        log.fine("Generating XML descriptor from device model: " + deviceModel);

        return XMLUtil.documentToString(buildDOM(deviceModel, info, namespace));

    } catch (Exception ex) {
        throw new DescriptorBindingException("Could not build DOM: " + ex.getMessage(), ex);
    }
}
 
Example #6
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void generateRoot(Namespace namespace, Device deviceModel, Document descriptor, RemoteClientInfo info) {

        Element rootElement = descriptor.createElementNS(Descriptor.Device.NAMESPACE_URI, ELEMENT.root.toString());
        descriptor.appendChild(rootElement);

        generateSpecVersion(namespace, deviceModel, descriptor, rootElement);

        /* UDA 1.1 spec says: Don't use URLBase anymore
        if (deviceModel.getBaseURL() != null) {
            appendChildElementWithTextContent(descriptor, rootElement, "URLBase", deviceModel.getBaseURL());
        }
        */

        generateDevice(namespace, deviceModel, descriptor, rootElement, info);
    }
 
Example #7
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void generateDeviceList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement, RemoteClientInfo info) {
    if (!deviceModel.hasEmbeddedDevices()) return;

    Element deviceListElement = appendNewElement(descriptor, deviceElement, ELEMENT.deviceList);

    for (Device device : deviceModel.getEmbeddedDevices()) {
        generateDevice(namespace, device, descriptor, deviceListElement, info);
    }
}
 
Example #8
Source File: RemoteActionInvocation.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public RemoteActionInvocation(Action action,
                              ActionArgumentValue[] input,
                              ActionArgumentValue[] output,
                              RemoteClientInfo remoteClientInfo) {
    super(action, input, output, null);
    this.remoteClientInfo = remoteClientInfo;
}
 
Example #9
Source File: LocalDevice.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
@Override
public DeviceDetails getDetails(RemoteClientInfo info) {
    if (getDeviceDetailsProvider() != null) {
        return getDeviceDetailsProvider().provide(info);
    }
    return this.getDetails();
}
 
Example #10
Source File: RemoteActionInvocation.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public RemoteActionInvocation(Action action,
                              ActionArgumentValue[] input,
                              ActionArgumentValue[] output,
                              RemoteClientInfo remoteClientInfo) {
    super(action, input, output, null);
    this.remoteClientInfo = remoteClientInfo;
}
 
Example #11
Source File: UDA10DeviceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected void generateDeviceList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement, RemoteClientInfo info) {
    if (!deviceModel.hasEmbeddedDevices()) return;

    Element deviceListElement = appendNewElement(descriptor, deviceElement, ELEMENT.deviceList);

    for (Device device : deviceModel.getEmbeddedDevices()) {
        generateDevice(namespace, device, descriptor, deviceListElement, info);
    }
}
 
Example #12
Source File: UDA10DeviceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected void generateRoot(Namespace namespace, Device deviceModel, Document descriptor, RemoteClientInfo info) {

        Element rootElement = descriptor.createElementNS(Descriptor.Device.NAMESPACE_URI, ELEMENT.root.toString());
        descriptor.appendChild(rootElement);

        generateSpecVersion(namespace, deviceModel, descriptor, rootElement);

        /* UDA 1.1 spec says: Don't use URLBase anymore
        if (deviceModel.getBaseURL() != null) {
            appendChildElementWithTextContent(descriptor, rootElement, "URLBase", deviceModel.getBaseURL());
        }
        */

        generateDevice(namespace, deviceModel, descriptor, rootElement, info);
    }
 
Example #13
Source File: UDA10DeviceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public String generate(Device deviceModel, RemoteClientInfo info, Namespace namespace) throws DescriptorBindingException {
    try {
        log.fine("Generating XML descriptor from device model: " + deviceModel);

        return XMLUtil.documentToString(buildDOM(deviceModel, info, namespace));

    } catch (Exception ex) {
        throw new DescriptorBindingException("Could not build DOM: " + ex.getMessage(), ex);
    }
}
 
Example #14
Source File: MethodActionExecutor.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected Object[] createInputArgumentValues(ActionInvocation<LocalService> actionInvocation, Method method) throws ActionException {

        LocalService service = actionInvocation.getAction().getService();

        List values = new ArrayList();
        int i = 0;
        for (ActionArgument<LocalService> argument : actionInvocation.getAction().getInputArguments()) {

            Class methodParameterType = method.getParameterTypes()[i];

            ActionArgumentValue<LocalService> inputValue = actionInvocation.getInput(argument);

            // If it's a primitive argument, we need a value
            if (methodParameterType.isPrimitive() && (inputValue == null || inputValue.toString().length() == 0))
                throw new ActionException(
                        ErrorCode.ARGUMENT_VALUE_INVALID,
                        "Primitive action method argument '" + argument.getName() + "' requires input value, can't be null or empty string"
                );

            // It's not primitive and we have no value, that's fine too
            if (inputValue == null) {
                values.add(i++, null);
                continue;
            }

            // If it's not null, maybe it was a string-convertible type, if so, try to instantiate it
            String inputCallValueString = inputValue.toString();
            // Empty string means null and we can't instantiate Enums!
            if (inputCallValueString.length() > 0 && service.isStringConvertibleType(methodParameterType) && !methodParameterType.isEnum()) {
                try {
                    Constructor<String> ctor = methodParameterType.getConstructor(String.class);
                    log.finer("Creating new input argument value instance with String.class constructor of type: " + methodParameterType);
                    Object o = ctor.newInstance(inputCallValueString);
                    values.add(i++, o);
                } catch (Exception ex) {
                    log.warning("Error preparing action method call: " + method);
                    log.warning("Can't convert input argument string to desired type of '" + argument.getName() + "': " + ex);
                    throw new ActionException(
                            ErrorCode.ARGUMENT_VALUE_INVALID, "Can't convert input argument string to desired type of '" + argument.getName() + "': " + ex
                    );
                }
            } else {
                // Or if it wasn't, just use the value without any conversion
                values.add(i++, inputValue.getValue());
            }
        }

        if (method.getParameterTypes().length > 0
            && RemoteClientInfo.class.isAssignableFrom(method.getParameterTypes()[method.getParameterTypes().length-1])) {
            if (actionInvocation instanceof RemoteActionInvocation &&
                ((RemoteActionInvocation)actionInvocation).getRemoteClientInfo() != null) {
                log.finer("Providing remote client info as last action method input argument: " + method);
                values.add(i, ((RemoteActionInvocation)actionInvocation).getRemoteClientInfo());
            } else {
                // Local call, no client info available
                values.add(i, null);
            }
        }

        return values.toArray(new Object[values.size()]);
    }
 
Example #15
Source File: RemoteActionInvocation.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public RemoteClientInfo getRemoteClientInfo() {
    return remoteClientInfo;
}
 
Example #16
Source File: Device.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public DeviceDetails getDetails(RemoteClientInfo info) {
    return this.getDetails();
}
 
Example #17
Source File: RemoteActionInvocation.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public RemoteActionInvocation(Action action,
                              RemoteClientInfo remoteClientInfo) {
    super(action);
    this.remoteClientInfo = remoteClientInfo;
}
 
Example #18
Source File: AnnotationActionBinder.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected List<ActionArgument> createInputArguments() throws LocalServiceBindingException {

        List<ActionArgument> list = new ArrayList();

        // Input arguments are always method parameters
        int annotatedParams = 0;
        Annotation[][] params = getMethod().getParameterAnnotations();
        for (int i = 0; i < params.length; i++) {
            Annotation[] param = params[i];
            for (Annotation paramAnnotation : param) {
                if (paramAnnotation instanceof UpnpInputArgument) {
                    UpnpInputArgument inputArgumentAnnotation = (UpnpInputArgument) paramAnnotation;
                    annotatedParams++;

                    String argumentName =
                            inputArgumentAnnotation.name();

                    StateVariable stateVariable =
                            findRelatedStateVariable(
                                    inputArgumentAnnotation.stateVariable(),
                                    argumentName,
                                    getMethod().getName()
                            );

                    if (stateVariable == null) {
                        throw new LocalServiceBindingException(
                                "Could not detected related state variable of argument: " + argumentName
                        );
                    }

                    validateType(stateVariable, getMethod().getParameterTypes()[i]);

                    ActionArgument inputArgument = new ActionArgument(
                            argumentName,
                            inputArgumentAnnotation.aliases(),
                            stateVariable.getName(),
                            ActionArgument.Direction.IN
                    );

                    list.add(inputArgument);
                }
            }
        }
        // A method can't have any parameters that are not annotated with @UpnpInputArgument - we wouldn't know what
        // value to pass when we invoke it later on... unless the last parameter is of type RemoteClientInfo
        if (annotatedParams < getMethod().getParameterTypes().length
            && !RemoteClientInfo.class.isAssignableFrom(method.getParameterTypes()[method.getParameterTypes().length-1])) {
            throw new LocalServiceBindingException("Method has parameters that are not input arguments: " + getMethod().getName());
        }

        return list;
    }
 
Example #19
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected void generateDevice(Namespace namespace, Device deviceModel, Document descriptor, Element rootElement, RemoteClientInfo info) {

        Element deviceElement = appendNewElement(descriptor, rootElement, ELEMENT.device);

        appendNewElementIfNotNull(descriptor, deviceElement, ELEMENT.deviceType, deviceModel.getType());

        DeviceDetails deviceModelDetails = deviceModel.getDetails(info);
        appendNewElementIfNotNull(
                descriptor, deviceElement, ELEMENT.friendlyName,
                deviceModelDetails.getFriendlyName()
        );
        if (deviceModelDetails.getManufacturerDetails() != null) {
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.manufacturer,
                    deviceModelDetails.getManufacturerDetails().getManufacturer()
            );
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.manufacturerURL,
                    deviceModelDetails.getManufacturerDetails().getManufacturerURI()
            );
        }
        if (deviceModelDetails.getModelDetails() != null) {
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.modelDescription,
                    deviceModelDetails.getModelDetails().getModelDescription()
            );
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.modelName,
                    deviceModelDetails.getModelDetails().getModelName()
            );
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.modelNumber,
                    deviceModelDetails.getModelDetails().getModelNumber()
            );
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.modelURL,
                    deviceModelDetails.getModelDetails().getModelURI()
            );
        }
        appendNewElementIfNotNull(
                descriptor, deviceElement, ELEMENT.serialNumber,
                deviceModelDetails.getSerialNumber()
        );
        appendNewElementIfNotNull(descriptor, deviceElement, ELEMENT.UDN, deviceModel.getIdentity().getUdn());
        appendNewElementIfNotNull(
                descriptor, deviceElement, ELEMENT.presentationURL,
                deviceModelDetails.getPresentationURI()
        );
        appendNewElementIfNotNull(
                descriptor, deviceElement, ELEMENT.UPC,
                deviceModelDetails.getUpc()
        );

        if (deviceModelDetails.getDlnaDocs() != null) {
            for (DLNADoc dlnaDoc : deviceModelDetails.getDlnaDocs()) {
                appendNewElementIfNotNull(
                        descriptor, deviceElement, Descriptor.Device.DLNA_PREFIX + ":" + ELEMENT.X_DLNADOC,
                        dlnaDoc, Descriptor.Device.DLNA_NAMESPACE_URI
                );
            }
        }
        appendNewElementIfNotNull(
                descriptor, deviceElement, Descriptor.Device.DLNA_PREFIX + ":" + ELEMENT.X_DLNACAP,
                deviceModelDetails.getDlnaCaps(), Descriptor.Device.DLNA_NAMESPACE_URI
        );
        
        appendNewElementIfNotNull(
                descriptor, deviceElement, Descriptor.Device.SEC_PREFIX + ":" + ELEMENT.ProductCap,
                deviceModelDetails.getSecProductCaps(), Descriptor.Device.SEC_NAMESPACE_URI
        );
        
        appendNewElementIfNotNull(
                descriptor, deviceElement, Descriptor.Device.SEC_PREFIX + ":" + ELEMENT.X_ProductCap,
                deviceModelDetails.getSecProductCaps(), Descriptor.Device.SEC_NAMESPACE_URI
        );

        generateIconList(namespace, deviceModel, descriptor, deviceElement);
        generateServiceList(namespace, deviceModel, descriptor, deviceElement);
        generateDeviceList(namespace, deviceModel, descriptor, deviceElement, info);
    }
 
Example #20
Source File: RemoteActionInvocation.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public RemoteActionInvocation(ActionException failure,
                        RemoteClientInfo remoteClientInfo) {
    super(failure);
    this.remoteClientInfo = remoteClientInfo;
}
 
Example #21
Source File: ReceivingSync.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
protected ReceivingSync(UpnpService upnpService, IN inputMessage) {
    super(upnpService, inputMessage);
    this.remoteClientInfo = new RemoteClientInfo(inputMessage);
}
 
Example #22
Source File: ReceivingSync.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public RemoteClientInfo getRemoteClientInfo() {
    return remoteClientInfo;
}
 
Example #23
Source File: ReceivingSync.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected ReceivingSync(UpnpService upnpService, IN inputMessage) {
    super(upnpService, inputMessage);
    this.remoteClientInfo = new RemoteClientInfo(inputMessage);
}
 
Example #24
Source File: RemoteActionInvocation.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public RemoteClientInfo getRemoteClientInfo() {
    return remoteClientInfo;
}
 
Example #25
Source File: RemoteActionInvocation.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public RemoteActionInvocation(ActionException failure,
                        RemoteClientInfo remoteClientInfo) {
    super(failure);
    this.remoteClientInfo = remoteClientInfo;
}
 
Example #26
Source File: RemoteActionInvocation.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public RemoteActionInvocation(Action action,
                              RemoteClientInfo remoteClientInfo) {
    super(action);
    this.remoteClientInfo = remoteClientInfo;
}
 
Example #27
Source File: MethodActionExecutor.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
protected Object[] createInputArgumentValues(ActionInvocation<LocalService> actionInvocation, Method method) throws ActionException {

        LocalService service = actionInvocation.getAction().getService();

        List values = new ArrayList();
        int i = 0;
        for (ActionArgument<LocalService> argument : actionInvocation.getAction().getInputArguments()) {

            Class methodParameterType = method.getParameterTypes()[i];

            ActionArgumentValue<LocalService> inputValue = actionInvocation.getInput(argument);

            // If it's a primitive argument, we need a value
            if (methodParameterType.isPrimitive() && (inputValue == null || inputValue.toString().length() == 0))
                throw new ActionException(
                        ErrorCode.ARGUMENT_VALUE_INVALID,
                        "Primitive action method argument '" + argument.getName() + "' requires input value, can't be null or empty string"
                );

            // It's not primitive and we have no value, that's fine too
            if (inputValue == null) {
                values.add(i++, null);
                continue;
            }

            // If it's not null, maybe it was a string-convertible type, if so, try to instantiate it
            String inputCallValueString = inputValue.toString();
            // Empty string means null and we can't instantiate Enums!
            if (inputCallValueString.length() > 0 && service.isStringConvertibleType(methodParameterType) && !methodParameterType.isEnum()) {
                try {
                    Constructor<String> ctor = methodParameterType.getConstructor(String.class);
                    log.finer("Creating new input argument value instance with String.class constructor of type: " + methodParameterType);
                    Object o = ctor.newInstance(inputCallValueString);
                    values.add(i++, o);
                } catch (Exception ex) {
                    log.warning("Error preparing action method call: " + method);
                    log.warning("Can't convert input argument string to desired type of '" + argument.getName() + "': " + ex);
                    throw new ActionException(
                            ErrorCode.ARGUMENT_VALUE_INVALID, "Can't convert input argument string to desired type of '" + argument.getName() + "': " + ex
                    );
                }
            } else {
                // Or if it wasn't, just use the value without any conversion
                values.add(i++, inputValue.getValue());
            }
        }

        if (method.getParameterTypes().length > 0
            && RemoteClientInfo.class.isAssignableFrom(method.getParameterTypes()[method.getParameterTypes().length-1])) {
            if (actionInvocation instanceof RemoteActionInvocation &&
                ((RemoteActionInvocation)actionInvocation).getRemoteClientInfo() != null) {
                log.finer("Providing remote client info as last action method input argument: " + method);
                values.add(i, ((RemoteActionInvocation)actionInvocation).getRemoteClientInfo());
            } else {
                // Local call, no client info available
                values.add(i, null);
            }
        }

        return values.toArray(new Object[values.size()]);
    }
 
Example #28
Source File: Device.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public DeviceDetails getDetails(RemoteClientInfo info) {
    return this.getDetails();
}
 
Example #29
Source File: AnnotationActionBinder.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
protected List<ActionArgument> createInputArguments() throws LocalServiceBindingException {

        List<ActionArgument> list = new ArrayList();

        // Input arguments are always method parameters
        int annotatedParams = 0;
        Annotation[][] params = getMethod().getParameterAnnotations();
        for (int i = 0; i < params.length; i++) {
            Annotation[] param = params[i];
            for (Annotation paramAnnotation : param) {
                if (paramAnnotation instanceof UpnpInputArgument) {
                    UpnpInputArgument inputArgumentAnnotation = (UpnpInputArgument) paramAnnotation;
                    annotatedParams++;

                    String argumentName =
                            inputArgumentAnnotation.name();

                    StateVariable stateVariable =
                            findRelatedStateVariable(
                                    inputArgumentAnnotation.stateVariable(),
                                    argumentName,
                                    getMethod().getName()
                            );

                    if (stateVariable == null) {
                        throw new LocalServiceBindingException(
                                "Could not detected related state variable of argument: " + argumentName
                        );
                    }

                    validateType(stateVariable, getMethod().getParameterTypes()[i]);

                    ActionArgument inputArgument = new ActionArgument(
                            argumentName,
                            inputArgumentAnnotation.aliases(),
                            stateVariable.getName(),
                            ActionArgument.Direction.IN
                    );

                    list.add(inputArgument);
                }
            }
        }
        // A method can't have any parameters that are not annotated with @UpnpInputArgument - we wouldn't know what
        // value to pass when we invoke it later on... unless the last parameter is of type RemoteClientInfo
        if (annotatedParams < getMethod().getParameterTypes().length
            && !RemoteClientInfo.class.isAssignableFrom(method.getParameterTypes()[method.getParameterTypes().length-1])) {
            throw new LocalServiceBindingException("Method has parameters that are not input arguments: " + getMethod().getName());
        }

        return list;
    }
 
Example #30
Source File: UDA10DeviceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
protected void generateDevice(Namespace namespace, Device deviceModel, Document descriptor, Element rootElement, RemoteClientInfo info) {

        Element deviceElement = appendNewElement(descriptor, rootElement, ELEMENT.device);

        appendNewElementIfNotNull(descriptor, deviceElement, ELEMENT.deviceType, deviceModel.getType());

        DeviceDetails deviceModelDetails = deviceModel.getDetails(info);
        appendNewElementIfNotNull(
                descriptor, deviceElement, ELEMENT.friendlyName,
                deviceModelDetails.getFriendlyName()
        );
        if (deviceModelDetails.getManufacturerDetails() != null) {
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.manufacturer,
                    deviceModelDetails.getManufacturerDetails().getManufacturer()
            );
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.manufacturerURL,
                    deviceModelDetails.getManufacturerDetails().getManufacturerURI()
            );
        }
        if (deviceModelDetails.getModelDetails() != null) {
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.modelDescription,
                    deviceModelDetails.getModelDetails().getModelDescription()
            );
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.modelName,
                    deviceModelDetails.getModelDetails().getModelName()
            );
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.modelNumber,
                    deviceModelDetails.getModelDetails().getModelNumber()
            );
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.modelURL,
                    deviceModelDetails.getModelDetails().getModelURI()
            );
        }
        appendNewElementIfNotNull(
                descriptor, deviceElement, ELEMENT.serialNumber,
                deviceModelDetails.getSerialNumber()
        );
        appendNewElementIfNotNull(descriptor, deviceElement, ELEMENT.UDN, deviceModel.getIdentity().getUdn());
        appendNewElementIfNotNull(
                descriptor, deviceElement, ELEMENT.presentationURL,
                deviceModelDetails.getPresentationURI()
        );
        appendNewElementIfNotNull(
                descriptor, deviceElement, ELEMENT.UPC,
                deviceModelDetails.getUpc()
        );

        if (deviceModelDetails.getDlnaDocs() != null) {
            for (DLNADoc dlnaDoc : deviceModelDetails.getDlnaDocs()) {
                appendNewElementIfNotNull(
                        descriptor, deviceElement, Descriptor.Device.DLNA_PREFIX + ":" + ELEMENT.X_DLNADOC,
                        dlnaDoc, Descriptor.Device.DLNA_NAMESPACE_URI
                );
            }
        }
        appendNewElementIfNotNull(
                descriptor, deviceElement, Descriptor.Device.DLNA_PREFIX + ":" + ELEMENT.X_DLNACAP,
                deviceModelDetails.getDlnaCaps(), Descriptor.Device.DLNA_NAMESPACE_URI
        );
        
        appendNewElementIfNotNull(
                descriptor, deviceElement, Descriptor.Device.SEC_PREFIX + ":" + ELEMENT.ProductCap,
                deviceModelDetails.getSecProductCaps(), Descriptor.Device.SEC_NAMESPACE_URI
        );
        
        appendNewElementIfNotNull(
                descriptor, deviceElement, Descriptor.Device.SEC_PREFIX + ":" + ELEMENT.X_ProductCap,
                deviceModelDetails.getSecProductCaps(), Descriptor.Device.SEC_NAMESPACE_URI
        );

        generateIconList(namespace, deviceModel, descriptor, deviceElement);
        generateServiceList(namespace, deviceModel, descriptor, deviceElement);
        generateDeviceList(namespace, deviceModel, descriptor, deviceElement, info);
    }