示例#1
0
// If serial is 0, any Phantom device will suffice
Phantom* Phantom::findPhantom(unsigned int serial)
{
  // TODO Cache the Phantom devices and recreate list upon bus resets (much more efficient, assuming that it does not take too much resources to create the list...)

  FirewireDevice *dev;
  DeviceIterator *i = DeviceIterator::createInstance();

  for (dev = i->next(); dev; dev = i->next())
  {
    if (dev->isSensableDevice())
    {
      uint32_t device_serial = readDeviceSerial(dev);
      if (serial != 0 && serial != device_serial)
      {
        delete dev;
        continue;
      }

      //We have found a Phantom device
      delete i;
      return new Phantom(dev);
    }

    delete dev;
  }
  delete i;

  // We failed to find a(n unused) Phantom device...
  return 0;
}
示例#2
0
Service ControlPoint::getWanIpConnectionService(Device& igd)
{
   /* Note:
    *
    * An InternetGatewayDevice has a WANDevice in it. Inside the WANDevice
    * there is a WANConnectionDevice. The WANConnectionDevice may have a
    * WANIPConnectionServices which provides port mapping services.
    */

   // get the wan device
   Device wd(NULL);
   {
      igd["devices"]->setType(Array);
      DeviceIterator di = igd["devices"].getIterator();
      while(wd.isNull() && di->hasNext())
      {
         Device& next = di->next();
         if(strcmp(next["deviceType"]->getString(), UPNP_DEVICE_TYPE_WAN) == 0)
         {
            // found wan device
            wd = next;

            MO_CAT_DEBUG(MO_UPNP_CAT,
               "Found device '" UPNP_DEVICE_TYPE_WAN "'");
         }
      }
   }

   // get the wan connection device
   Device wcd(NULL);
   if(!wd.isNull())
   {
      wd["devices"]->setType(Array);
      DeviceIterator di = wd["devices"].getIterator();
      while(wcd.isNull() && di->hasNext())
      {
         Device& next = di->next();
         if(strcmp(
            next["deviceType"]->getString(),
            UPNP_DEVICE_TYPE_WAN_CONNECTION) == 0)
         {
            // found wan connection device
            wcd = next;

            MO_CAT_DEBUG(MO_UPNP_CAT,
               "Found device '" UPNP_DEVICE_TYPE_WAN_CONNECTION "'");
         }
      }
   }

   // get the wan ip connection service
   Service wipcs(NULL);
   if(!wcd.isNull())
   {
      wcd["services"]->setType(Array);
      ServiceIterator si = wcd["services"].getIterator();
      while(wipcs.isNull() && si->hasNext())
      {
         Service& next = si->next();
         if(strcmp(
            next["serviceType"]->getString(),
            UPNP_SERVICE_TYPE_WAN_IP_CONNECTION) == 0)
         {
            // found wan ip connection service
            wipcs = next;

            MO_CAT_DEBUG(MO_UPNP_CAT,
               "Found service '" UPNP_SERVICE_TYPE_WAN_IP_CONNECTION "'");
         }
      }
   }

   return wipcs;
}