public ControlPointAdapter getControlPointAdapter(Service service) { // TODO: Just take the first, we really should provide a drop-down menu for (ControlPointAdapter controlPointAdapter : controlPointLoader) { if (controlPointAdapter.getServiceType().implementsVersion(service.getServiceType())) { return controlPointAdapter; } } return null; }
protected List<RemoteService> filterExclusiveServices(RemoteService[] services) { ServiceType[] exclusiveTypes = getUpnpService().getConfiguration().getExclusiveServiceTypes(); if (exclusiveTypes == null || exclusiveTypes.length == 0) return Arrays.asList(services); List<RemoteService> exclusiveServices = new ArrayList<>(); for (RemoteService discoveredService : services) { for (ServiceType exclusiveType : exclusiveTypes) { if (discoveredService.getServiceType().implementsVersion(exclusiveType)) { log.fine("Including exclusive service: " + discoveredService); exclusiveServices.add(discoveredService); } else { log.fine("Excluding unwanted service: " + exclusiveType); } } } return exclusiveServices; }
public void onUseServiceRequest(@Observes UseService request) { for (ServiceType supportedServiceType : getSupportedServiceTypes()) { if (request.service.getServiceType().implementsVersion(supportedServiceType)) { onUseServiceRequest(request.service); break; } } }
private boolean isMatch(Service s, ServiceType serviceType, ServiceId serviceId) { boolean matchesType = serviceType == null || s.getServiceType().implementsVersion(serviceType); boolean matchesId = serviceId == null || s.getServiceId().equals(serviceId); return matchesType && matchesId; }
protected boolean isSupportedServiceAdvertisement(IncomingDatagramMessage message) { ServiceType[] exclusiveServiceTypes = getUpnpService().getConfiguration().getExclusiveServiceTypes(); if (exclusiveServiceTypes == null) return false; // Discovery is disabled if (exclusiveServiceTypes.length == 0) return true; // Any advertisement is fine String usnHeader = message.getHeaders().getFirstHeader(UpnpHeader.Type.USN.getHttpName()); if (usnHeader == null) return false; // Not a service advertisement, drop it try { NamedServiceType nst = NamedServiceType.valueOf(usnHeader); for (ServiceType exclusiveServiceType : exclusiveServiceTypes) { if (nst.getServiceType().implementsVersion(exclusiveServiceType)) return true; } } catch (InvalidValueException ex) { log.finest("Not a named service type header value: " + usnHeader); } log.fine("Service advertisement not supported, dropping it: " + usnHeader); return false; }
public IncomingActionRequestMessage(StreamRequestMessage source, LocalService service) throws ActionException { super(source); SoapActionHeader soapActionHeader = getHeaders().getFirstHeader(UpnpHeader.Type.SOAPACTION, SoapActionHeader.class); if (soapActionHeader == null) { throw new ActionException(ErrorCode.INVALID_ACTION, "Missing SOAP action header"); } SoapActionType actionType = soapActionHeader.getValue(); this.action = service.getAction(actionType.getActionName()); if (this.action == null) { throw new ActionException(ErrorCode.INVALID_ACTION, "Service doesn't implement action: " + actionType.getActionName()); } if (!QueryStateVariableAction.ACTION_NAME.equals(actionType.getActionName())) { if (!service.getServiceType().implementsVersion(actionType.getServiceType())) { throw new ActionException(ErrorCode.INVALID_ACTION, "Service doesn't support the requested service version"); } } this.actionNamespace = actionType.getTypeString(); }
protected List<RemoteService> filterExclusiveServices(RemoteService[] services) { ServiceType[] exclusiveTypes = getUpnpService().getConfiguration().getExclusiveServiceTypes(); if (exclusiveTypes == null || exclusiveTypes.length == 0) return Arrays.asList(services); List<RemoteService> exclusiveServices = new ArrayList(); for (RemoteService discoveredService : services) { for (ServiceType exclusiveType : exclusiveTypes) { if (discoveredService.getServiceType().implementsVersion(exclusiveType)) { log.fine("Including exclusive service: " + discoveredService); exclusiveServices.add(discoveredService); } else { log.fine("Excluding unwanted service: " + exclusiveType); } } } return exclusiveServices; }
private boolean isMatch(Service s, ServiceType serviceType, ServiceId serviceId) { boolean matchesType = serviceType == null || s.getServiceType().implementsVersion(serviceType); boolean matchesId = serviceId == null || s.getServiceId().equals(serviceId); return matchesType && matchesId; }
protected boolean isSupportedServiceAdvertisement(IncomingDatagramMessage message) { ServiceType[] exclusiveServiceTypes = getUpnpService().getConfiguration().getExclusiveServiceTypes(); if (exclusiveServiceTypes == null) return false; // Discovery is disabled if (exclusiveServiceTypes.length == 0) return true; // Any advertisement is fine String usnHeader = message.getHeaders().getFirstHeader(UpnpHeader.Type.USN.getHttpName()); if (usnHeader == null) return false; // Not a service advertisement, drop it try { NamedServiceType nst = NamedServiceType.valueOf(usnHeader); for (ServiceType exclusiveServiceType : exclusiveServiceTypes) { if (nst.getServiceType().implementsVersion(exclusiveServiceType)) return true; } } catch (InvalidValueException ex) { log.finest("Not a named service type header value: " + usnHeader); } log.fine("Service advertisement not supported, dropping it: " + usnHeader); return false; }
public IncomingActionRequestMessage(StreamRequestMessage source, LocalService service) throws ActionException { super(source); SoapActionHeader soapActionHeader = getHeaders().getFirstHeader(UpnpHeader.Type.SOAPACTION, SoapActionHeader.class); if (soapActionHeader == null) { throw new ActionException(ErrorCode.INVALID_ACTION, "Missing SOAP action header"); } SoapActionType actionType = soapActionHeader.getValue(); this.action = service.getAction(actionType.getActionName()); if (this.action == null) { throw new ActionException(ErrorCode.INVALID_ACTION, "Service doesn't implement action: " + actionType.getActionName()); } if (!QueryStateVariableAction.ACTION_NAME.equals(actionType.getActionName())) { if (!service.getServiceType().implementsVersion(actionType.getServiceType())) { throw new ActionException(ErrorCode.INVALID_ACTION, "Service doesn't support the requested service version"); } } this.actionNamespace = actionType.getTypeString(); }
protected List<RemoteService> filterExclusiveServices(RemoteService[] services) { ServiceType[] exclusiveTypes = getUpnpService().getConfiguration().getExclusiveServiceTypes(); if (exclusiveTypes == null || exclusiveTypes.length == 0) return Arrays.asList(services); List<RemoteService> exclusiveServices = new ArrayList<>(); for (RemoteService discoveredService : services) { for (ServiceType exclusiveType : exclusiveTypes) { if (discoveredService.getServiceType().implementsVersion(exclusiveType)) { log.fine("Including exclusive service: " + discoveredService); exclusiveServices.add(discoveredService); } else { log.fine("Excluding unwanted service: " + exclusiveType); } } } return exclusiveServices; }
private boolean isMatch(Service s, ServiceType serviceType, ServiceId serviceId) { boolean matchesType = serviceType == null || s.getServiceType().implementsVersion(serviceType); boolean matchesId = serviceId == null || s.getServiceId().equals(serviceId); return matchesType && matchesId; }
protected boolean isSupportedServiceAdvertisement(IncomingDatagramMessage message) { ServiceType[] exclusiveServiceTypes = getUpnpService().getConfiguration().getExclusiveServiceTypes(); if (exclusiveServiceTypes == null) return false; // Discovery is disabled if (exclusiveServiceTypes.length == 0) return true; // Any advertisement is fine String usnHeader = message.getHeaders().getFirstHeader(UpnpHeader.Type.USN.getHttpName()); if (usnHeader == null) return false; // Not a service advertisement, drop it try { NamedServiceType nst = NamedServiceType.valueOf(usnHeader); for (ServiceType exclusiveServiceType : exclusiveServiceTypes) { if (nst.getServiceType().implementsVersion(exclusiveServiceType)) return true; } } catch (InvalidValueException ex) { log.finest("Not a named service type header value: " + usnHeader); } log.fine("Service advertisement not supported, dropping it: " + usnHeader); return false; }
public IncomingActionRequestMessage(StreamRequestMessage source, LocalService service) throws ActionException { super(source); SoapActionHeader soapActionHeader = getHeaders().getFirstHeader(UpnpHeader.Type.SOAPACTION, SoapActionHeader.class); if (soapActionHeader == null) { throw new ActionException(ErrorCode.INVALID_ACTION, "Missing SOAP action header"); } SoapActionType actionType = soapActionHeader.getValue(); this.action = service.getAction(actionType.getActionName()); if (this.action == null) { throw new ActionException(ErrorCode.INVALID_ACTION, "Service doesn't implement action: " + actionType.getActionName()); } if (!QueryStateVariableAction.ACTION_NAME.equals(actionType.getActionName())) { if (!service.getServiceType().implementsVersion(actionType.getServiceType())) { throw new ActionException(ErrorCode.INVALID_ACTION, "Service doesn't support the requested service version"); } } this.actionNamespace = actionType.getTypeString(); }