Package org.osgi.service.upnp

Examples of org.osgi.service.upnp.UPnPDevice


      Mediator.getPropertiesViewer().showSubscriptionPanel(false);

    if ( node.category.equals(UPnPDeviceTreeNode.DEVICE)
      ||node.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE)){
      DeviceNode device = (DeviceNode) node.getUserObject();
      UPnPDevice upnpDevice = device.getDevice(Activator.context);
      makeProperties(upnpDevice);
    }
    else if (node.category.equals(UPnPDeviceTreeNode.SERVICE)){
      UPnPService service = (UPnPService) node.getUserObject();     
      makeProperties(service);
View Full Code Here


  * @param devUPnP the CyberLink device that where the new Service will be created
  * @param sr ServiceReference to OSGi Device that used as source of the information
  *              for the creation of the device
  */
  private static void addServices(String id,Device devUPnP, ServiceReference sr) {
    UPnPDevice devOSGi = (UPnPDevice) Activator.bc.getService(sr);

    if( devOSGi == null) {  //added by twa to prevent a null pointer exception
      Activator.logger.WARNING("UPnP Device that cotains serviceId="
          +id+" is deregistered from the framework while is exported");
      return;
    }

    UPnPService[] services =  devOSGi.getServices();
    if(services==null || services.length==0)
      return;
   
   
   
View Full Code Here

    } catch (InvalidSyntaxException e) {
      e.printStackTrace();
    }
    if (refs != null) {
      for (int i = 0; i < refs.length; i++) {
        UPnPDevice dev = (UPnPDevice) context.getService(refs[i]);
        Dictionary dic = dev.getDescriptions(null);
        if (((String) dic.get(UPnPDevice.UDN)).equals(udn)) {
          return;
        }
      }
    }
View Full Code Here

      e.printStackTrace();
    }
       
    if (refs != null) {
      for (int i = 0; i < refs.length; i++) {
        UPnPDevice dev = (UPnPDevice) context.getService(refs[i]);
        Dictionary dic = dev.getDescriptions(null);
        if (((String) dic.get(UPnPDevice.UDN)).equals(udn)) {
          return;
        }
      }
    }
View Full Code Here

                       *
                       * only if there is a compatibile device
                       */
          Dictionary dic = new Hashtable();
          for (int i = 0; i < devicesRefs.length; i++) {
            UPnPDevice device = (UPnPDevice) context.getService(devicesRefs[i]);
            dic.put(UPnPDevice.ID, device.getDescriptions(null).get(UPnPDevice.UDN));
            dic.put(UPnPDevice.TYPE, device.getDescriptions(null).get(UPnPDevice.TYPE));
            UPnPService[] services = device.getServices();
            if (services != null) {
              for (int j = 0; j < services.length; j++) {
                dic.put(UPnPService.ID, services[j].getId());
                dic.put(UPnPService.TYPE, services[j].getType());
                //TODO add method boolean serviceEvented() so we can remove the below cycle
                UPnPStateVariable[] stateVars = services[j].getStateVariables();
                boolean hasEventedVars = false;
                for (int k = 0; k < stateVars.length && ! hasEventedVars; k++) {
                  hasEventedVars = stateVars[k].sendsEvents();
                  if (hasEventedVars) {
                    if(filter.match(dic)){
                      UPnPEventListener listener =
                                            (UPnPEventListener) context.getService(serRef);
                      FirstMessage msg = new FirstMessage(
                          ((UPnPServiceImpl) services[j]).getCyberService(),
                          listener);
                      subQueue.enqueue(msg);                     
                    }
                  }
                }
              }
            }
                        context.ungetService(devicesRefs[i]);
          }
        }
      } else {/* obj==null (interested in all devices) */
        try {
          String newfilter = "(!" + EXPORT_FLTR+ ")";
          devicesRefs = context.getServiceReferences(UPnPDevice.class.getName(), newfilter);
        } catch (InvalidSyntaxException e) {
          e.printStackTrace();
        }
        if (devicesRefs != null) {/*
                       *
                       * only if there is a device
                       */

          for (int i = 0; i < devicesRefs.length; i++) {
            UPnPDevice device = (UPnPDevice) context
                .getService(devicesRefs[i]);
            UPnPService[] services = device.getServices();
            if (services != null) {
              for (int j = 0; j < services.length; j++) {
                UPnPStateVariable[] stateVars = services[j]
                    .getStateVariables();
                boolean bool = false;               
                for (int k = 0; k < stateVars.length; k++) {
                  bool = stateVars[k].sendsEvents();
                  if (bool) {
                    break;
                  }
                }
                if (bool) {
                  UPnPEventListener listener =
                                        (UPnPEventListener) context.getService(serRef);
                  FirstMessage msg = new FirstMessage(
                      ((UPnPServiceImpl) services[j]).getCyberService(),
                      listener);
                  subQueue.enqueue(msg);
                }
              }
            }
                        context.ungetService(devicesRefs[i]);
          }
        }
      }

    } else if (event.getType() == ServiceEvent.MODIFIED) {
      Vector newServices = new Vector();
      ServiceReference serRef = event.getServiceReference();
      Filter filter = (Filter) serRef.getProperty(UPnPEventListener.UPNP_FILTER);
      UPnPEventListener listener = (UPnPEventListener) context.getService(serRef);
      ServiceReference[] devicesRefs = null;

      if (filter != null) {
        try {
          String filtra = filter.toString();
                    String newfilter = "(&" + filtra + "(!" + EXPORT_FLTR + ")" + ")";
          devicesRefs = context.getServiceReferences(UPnPDevice.class.getName(), newfilter);
        } catch (InvalidSyntaxException e) {
          e.printStackTrace();
        }
        if (devicesRefs != null) {/*
                       *
                       * only if there is a compatibile device
                       */
          Dictionary dic = new Hashtable();
          /*
           * look for the service that match
           */
          for (int i = 0; i < devicesRefs.length; i++) {
            UPnPDevice device = (UPnPDevice) context
                .getService(devicesRefs[i]);
            dic.put(UPnPDevice.ID, device.getDescriptions(null)
                .get(UPnPDevice.UDN));
            dic.put(UPnPDevice.TYPE, device.getDescriptions(null)
                .get(UPnPDevice.TYPE));
            UPnPService[] services = device.getServices();

            if (services != null) {
              for (int j = 0; j < services.length; j++) {
                dic.put(UPnPService.ID, services[j].getId());
                dic.put(UPnPService.TYPE, services[j].getType());

                UPnPStateVariable[] stateVars = services[j]
                    .getStateVariables();
                boolean hasEventedVars = false;
                for (int k = 0; k < stateVars.length; k++) {
                  hasEventedVars = stateVars[k].sendsEvents();
                  if (hasEventedVars) {
                    break;
                  }
                }
                if (!hasEventedVars) {
                  continue;
                }

                boolean bool = filter.match(dic);
                if (bool) {
                  newServices
                      .add(((UPnPServiceImpl) services[j])
                          .getCyberService());
                }
              }//for services
            }//services ==null
            context.ungetService(devicesRefs[i]);
          }//for devicesRefs
          ListenerModified msg = new ListenerModified(newServices,
              listener);
          subQueue.enqueue(msg);
        }//devicesrefs !=null
      } else {//interrested in all devices
        try {

          String newfilter = "(!(" + UPnPDevice.UPNP_EXPORT + "=*"
              + ")" + ")";
          devicesRefs = context.getServiceReferences(UPnPDevice.class
              .getName(), newfilter);
        } catch (InvalidSyntaxException e) {
          e.printStackTrace();
        }
        if (devicesRefs != null) {/*
                       * only if there is a device
                       */

          for (int i = 0; i < devicesRefs.length; i++) {
            UPnPDevice device = (UPnPDevice) context
                .getService(devicesRefs[i]);
            UPnPService[] services = device.getServices();
            if (services != null) {
              for (int j = 0; j < services.length; j++) {
                UPnPStateVariable[] stateVars = services[j]
                    .getStateVariables();
                boolean hasEventedVars = false;
View Full Code Here

  public Service serviceFromSid(String sid) {
    Enumeration e = devices.elements();
    Service cyberService = null;
    while (e.hasMoreElements()) {
      OSGiDeviceInfo deviceinfo = (OSGiDeviceInfo) e.nextElement();
      UPnPDevice device = deviceinfo.getOSGiDevice();
      UPnPService[] services = (UPnPService[]) device.getServices();
      UPnPServiceImpl[] servicesImpl = new UPnPServiceImpl[services.length];
      for (int i = 0; i < servicesImpl.length; i++) {
        servicesImpl[i] = (UPnPServiceImpl) services[i];
      }
      for (int i = 0; i < servicesImpl.length; i++) {
View Full Code Here

            pw.print(key);
            pw.print(" = "); //$NON-NLS-1$
            pw.println(val);
        }

        UPnPDevice dev = (UPnPDevice) tracker.getService(ref);
        if (null == dev)
            return;

        UPnPService services[] = dev.getServices();
        if (null != services && services.length > 0)
        {
            pw.println("  Services:");
            for (int i = 0; i < services.length; i++)
            {
View Full Code Here

        throws ServletException
    {
        final String deviceUdn = require("udn", request); //$NON-NLS-1$
        final String serviceUrn = require("urn", request); //$NON-NLS-1$

        final UPnPDevice device = getDevice(deviceUdn);
        return getService(device, serviceUrn);
    }
View Full Code Here

        return getService(device, serviceUrn);
    }

    private final JSONObject deviceTreeToJSON(ServiceReference ref) throws JSONException
    {
        final UPnPDevice device = (UPnPDevice) tracker.getService(ref);
        if (null == device)
        {
            return null; // the device is dynamically removed
        }
View Full Code Here

            if (icons.containsKey(udn))
            {
                continue;
            }

            final UPnPDevice device = (UPnPDevice) bc.getService(ref);
            UPnPIcon icon = null;
            try
            { // Fix for FELIX-4012
                UPnPIcon[] _icons = device == null ? null : device.getIcons(null);
                icon = _icons != null && _icons.length > 0 ? _icons[0] : null;
            }
            catch (IllegalStateException e)
            { // since OSGi r4.3 ignore it
            }
View Full Code Here

TOP

Related Classes of org.osgi.service.upnp.UPnPDevice

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.