org.cybergarage.upnp.Device类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中org.cybergarage.upnp.Device类的一些代码示例,展示了Device类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Device类的具体详情如下:
包路径:org.cybergarage.upnp.Device
类名称:Device

Device介绍

暂无

代码示例

代码示例来源:origin: i2p/i2p.i2p

public boolean isDevice(String name) {
  if (name == null)
    return false;
  if (name.endsWith(getUDN()) == true)
    return true;
  if (name.equals(getFriendlyName()) == true)
    return true;
  if (name.endsWith(getDeviceType()) == true)
    return true;
  return false;
}

代码示例来源:origin: i2p/i2p.i2p

for (Device current : _router.getDeviceList()) {
  String type = current.getDeviceType();
  if (!(WAN_DEVICE.equals(type) || WAN_DEVICE_2.equals(type)))
    continue;
  DeviceList l = current.getDeviceList();
  for (int i=0;i<current.getDeviceList().size();i++) {
    Device current2 = l.getDevice(i);
    type = current2.getDeviceType();
    if (!(WANCON_DEVICE.equals(type) || WANCON_DEVICE_2.equals(type)))
      continue;
    _service = current2.getService(WAN_IP_CONNECTION_2);
    if (_service == null) {
      _service = current2.getService(WAN_IP_CONNECTION);
      if (_service == null) {
        _service = current2.getService(WAN_PPP_CONNECTION);
        if (_service == null) {
          if (_log.shouldWarn())
            _log.warn(_router.getFriendlyName() + " doesn't have any recognized connection type; we won't be able to use it!");
      Service svc2 = current2.getService(WAN_IPV6_CONNECTION);
      if (svc2 != null)
        _log.warn(_router.getFriendlyName() + " supports WANIPv6Connection, but we don't");

代码示例来源:origin: i2p/i2p.i2p

public String getAbsoluteURL(String urlString) {
  String baseURLStr = null;
  String locationURLStr = null;
  Device rootDev = getRootDevice();
  if (rootDev != null) {
    baseURLStr = rootDev.getURLBase();
    locationURLStr = rootDev.getLocation();
  }
  return getAbsoluteURL(urlString, baseURLStr, locationURLStr);
}

代码示例来源:origin: i2p/i2p.i2p

private String getNotifyDeviceNT() {
  if (isRootDevice() == false)
    return getUDN();
  return UPNP_ROOTDEVICE;
}

代码示例来源:origin: i2p/i2p.i2p

private String getNotifyDeviceTypeUSN() {
  return getUDN() + "::" + getDeviceType();
}

代码示例来源:origin: i2p/i2p.i2p

public void announce(String bindAddr) {
  String devLocation = getLocationURL(bindAddr);
  ssdpReq.setLeaseTime(getLeaseTime());
  ssdpReq.setLocation(devLocation);
  ssdpReq.setNTS(NTS.ALIVE);
  ssdpReq.setBootId(getBootId());
  if (isRootDevice() == true) {
    String devNT = getNotifyDeviceNT();
    String devUSN = getNotifyDeviceUSN();
    ssdpReq.setNT(devNT);
    ssdpReq.setUSN(devUSN);
    ssdpSock.post(ssdpReq);
    String devUDN = getUDN();
    ssdpReq.setNT(devUDN);
    ssdpReq.setUSN(devUDN);
  String devNT = getNotifyDeviceTypeNT();
  String devUSN = getNotifyDeviceTypeUSN();
  ssdpReq.setNT(devNT);
  ssdpReq.setUSN(devUSN);
  ServiceList serviceList = getServiceList();
  int serviceCnt = serviceList.size();
  for (int n = 0; n < serviceCnt; n++) {
  DeviceList childDeviceList = getDeviceList();
  int childDeviceCnt = childDeviceList.size();

代码示例来源:origin: i2p/i2p.i2p

boolean isRootDevice = isRootDevice();
String devUSN = getUDN();
if (isRootDevice == true)
  devUSN += "::" + USN.ROOTDEVICE;
  String devNT = getNotifyDeviceNT();
  int repeatCnt = (isRootDevice == true) ? 3 : 2;
  for (int n = 0; n < repeatCnt; n++)
    postSearchResponse(ssdpPacket, devNT, devUSN);
} else if (ST.isRootDevice(ssdpST) == true) {
  if (isRootDevice == true)
    postSearchResponse(ssdpPacket, ST.ROOT_DEVICE, devUSN);
} else if (ST.isUUIDDevice(ssdpST) == true) {
  String devUDN = getUDN();
  if (ssdpST.equals(devUDN) == true)
    postSearchResponse(ssdpPacket, devUDN, devUSN);
} else if (ST.isURNDevice(ssdpST) == true) {
  String devType = getDeviceType();
  if (ssdpST.equals(devType) == true) {
    devUSN = getUDN() + "::" + devType;
    postSearchResponse(ssdpPacket, devType, devUSN);
ServiceList serviceList = getServiceList();
int serviceCnt = serviceList.size();
for (int n = 0; n < serviceCnt; n++) {
DeviceList childDeviceList = getDeviceList();

代码示例来源:origin: i2p/i2p.i2p

String udn = dev.getUDN();
if (udn == null)
  udn = "???";
    String name = dev.getFriendlyName();
if (name == null)
  name = "???";
String type = dev.getDeviceType();
boolean isIGD = (ROUTER_DEVICE.equals(type) || ROUTER_DEVICE_2.equals(type)) && dev.isRootDevice();
name += isIGD ? " IGD" : (' ' + type);
String ip = getIP(dev);
    _log.warn("UP&P non-IGD device found, ignoring " + name + ' ' + dev.getDeviceType());
  synchronized (lock) {
    _otherUDNs.put(udn, name);
SSDPPacket pkt = dev.getSSDPPacket();
if (!ignore && pkt != null) {
  String pktIP = pkt.getRemoteAddress();
  _log.warn("UP&P IGD found : " + name + " UDN: " + udn + " lease time: " + dev.getLeaseTime());

代码示例来源:origin: com.github.kmbulebu.nicknack/wemo-provider

@Override
public void deviceRemoved(Device dev) {
  if (isWemoSwitch(dev)) {
    urnToDeviceMap.remove(dev.getUDN());
    final Service basicEventService = dev.getService("urn:Belkin:service:basicevent:1");
    if (basicEventService != null && basicEventService.getSID() != null) {
      sidToDeviceMap.remove(basicEventService.getSID());
    }
    if (LOG.isInfoEnabled()) {
      LOG.info("Removed Wemo Device: " + dev.getFriendlyName() + " (" + dev.getUDN() + ')');
    }
  }
}

代码示例来源:origin: i2p/i2p.i2p

public boolean start() {
  stop(true);
  int bindPort = getHTTPPort();
  HTTPServerList httpServerList = getHTTPServerList();
  while (httpServerList.open(bindPort) == false) {
    retryCnt++;
    if (UPnP.SERVER_RETRY_COUNT < retryCnt)
      return false;
    setHTTPPort(bindPort + 1);
    bindPort = getHTTPPort();
  SSDPSearchSocketList ssdpSearchSockList = getSSDPSearchSocketList();
  if (ssdpSearchSockList.open() == false)
    return false;
  updateBootId();
  updateConfigId();
  announce();
  setAdvertiser(adv);
  adv.start();

代码示例来源:origin: i2p/i2p.i2p

String udn = dev.getUDN();
if (_log.shouldLog(Log.WARN))
  _log.warn("UP&P device removed : " + dev.getFriendlyName() + " UDN: " + udn);
ForwardPortCallback fpc = null;
Map<ForwardPort, ForwardPortStatus> removeMap = null;
  String type = dev.getDeviceType();
    if ((ROUTER_DEVICE.equals(type) || ROUTER_DEVICE_2.equals(type)) &&
    dev.isRootDevice() &&
    stringEquals(_router.getFriendlyName(), dev.getFriendlyName()) &&
    stringEquals(_router.getUDN(), udn)) {
    if (_log.shouldLog(Log.WARN))
      _log.warn("UP&P IGD device removed : " + dev.getFriendlyName());

代码示例来源:origin: i2p/i2p.i2p

public Action getAction(String name) {
  ServiceList serviceList = getServiceList();
  int serviceCnt = serviceList.size();
  for (int n = 0; n < serviceCnt; n++) {
    Service service = serviceList.getService(n);
    ActionList actionList = service.getActionList();
    int actionCnt = actionList.size();
    for (int i = 0; i < actionCnt; i++) {
      Action action = (Action) actionList.getAction(i);
      String actionName = action.getName();
      if (actionName == null)
        continue;
      if (actionName.equals(name) == true)
        return action;
    }
  }
  DeviceList devList = getDeviceList();
  int devCnt = devList.size();
  for (int n = 0; n < devCnt; n++) {
    Device dev = devList.getDevice(n);
    Action action = dev.getAction(name);
    if (action != null)
      return action;
  }
  return null;
}

代码示例来源:origin: i2p/i2p.i2p

public boolean postSearchResponse(SSDPPacket ssdpPacket, String st,
    String usn) {
  String localAddr = ssdpPacket.getLocalAddress();
  Device rootDev = getRootDevice();
  String rootDevLocation = rootDev.getLocationURL(localAddr);
  SSDPSearchResponse ssdpRes = new SSDPSearchResponse();
  ssdpRes.setLeaseTime(getLeaseTime());
  ssdpRes.setDate(cal);
  ssdpRes.setST(st);
  ssdpRes.setUSN(usn);
  ssdpRes.setLocation(rootDevLocation);
  ssdpRes.setBootId(getBootId());
  // Thanks for Brent Hills (10/20/04)
  ssdpRes.setMYNAME(getFriendlyName());
  int mx = ssdpPacket.getMX();
  TimerUtil.waitRandom(mx * 1000);
  String remoteAddr = ssdpPacket.getRemoteAddress();
  int remotePort = ssdpPacket.getRemotePort();
  SSDPSearchResponseSocket ssdpResSock = new SSDPSearchResponseSocket();
  if (Debug.isOn() == true)
    ssdpRes.print();
  int ssdpCount = getSSDPAnnounceCount();
  for (int i = 0; i < ssdpCount; i++)
    ssdpResSock.post(remoteAddr, remotePort, ssdpRes);
  return true;
}

代码示例来源:origin: i2p/i2p.i2p

public void print()
  {
    DeviceList devList = getDeviceList();
    int devCnt = devList.size();
    Debug.message("Device Num = " + devCnt);
    for (int n=0; n<devCnt; n++) {
      Device dev = devList.getDevice(n);
      Debug.message("[" + n + "] " + dev.getFriendlyName() + ", " + dev.getLeaseTime() + ", " + dev.getElapsedTime());
    }        
  }
}

代码示例来源:origin: i2p/i2p.i2p

private void listSubDev(String prefix, Device dev, StringBuilder sb){
      if (prefix == null)
    sb.append("<p>").append(_t("Found Device")).append(": ");
  else
    sb.append("<li>").append(_t("Subdevice")).append(": ");
  sb.append(DataHelper.escapeHTML(dev.getFriendlyName()));
      if (prefix == null) {
    String ip = getIP(dev);
    if (ip != null)
      sb.append("<br>IP: ").append(ip);
    String udn = dev.getUDN();
    if (udn != null)
      sb.append("<br>UDN: ").append(DataHelper.escapeHTML(udn));
  }
  sb.append("</p>");
  listSubServices(dev, sb);
  
  DeviceList dl = dev.getDeviceList();
  if (dl.isEmpty())
    return;
  sb.append("<ul>\n");
  for(int j=0; j<dl.size(); j++) {
    Device subDev = dl.getDevice(j);
    if(subDev == null) continue;
    listSubDev(dev.getFriendlyName(), subDev, sb);
  }
  sb.append("</ul>\n");
}

代码示例来源:origin: cybergarage/cybergarage-upnp

void set(Device dev)
  {
    if (dev.isRootDevice() == true) {
      addRow("Location", dev.getLocation());
      addRow("URLBase", dev.getURLBase());
      addRow("LeaseTime", Long.toString(dev.getLeaseTime()));
    }

    set(dev.getDeviceNode());
  }
}

代码示例来源:origin: apache/felix

Device d = edi.getDevice();
if(d!=null) {
  Activator.logger.INFO("[Exporter] removing device:" +d.getFriendlyName());
  d.stop();
  exportedDevices.remove(d.getUDN());

代码示例来源:origin: cybergarage/cybergarage-upnp

public Service getDeviceService(String deviceType, String serviceType)
{
  Device dev = ctrlPoint.getDevice(deviceType);
  if (dev == null)
    return null;
  Service service = dev.getService(serviceType);
  if (service == null)
    return null;
  return service;
}

代码示例来源:origin: i2p/i2p.i2p

private void updateConfigId(Device dev) {
  int configId = 0;
  DeviceList cdevList = dev.getDeviceList();
  int cdevCnt = cdevList.size();
  for (int n = 0; n < cdevCnt; n++) {
    Device cdev = cdevList.getDevice(n);
    updateConfigId(cdev);
    configId += cdev.getConfigId();
    configId &= UPnP.CONFIGID_UPNP_ORG_MAX;
  }
  ServiceList serviceList = dev.getServiceList();
  int serviceCnt = serviceList.size();
  for (int n = 0; n < serviceCnt; n++) {
    Service service = serviceList.getService(n);
    service.updateConfigId();
    configId += service.getConfigId();
    configId &= UPnP.CONFIGID_UPNP_ORG_MAX;
  }
  Node devNode = getDeviceNode();
  if (devNode == null)
    return;
  String devDescXml = devNode.toString();
  configId += UPnP.caluculateConfigId(devDescXml);
  configId &= UPnP.CONFIGID_UPNP_ORG_MAX;
  devNode.setAttribute(CONFIG_ID, configId);
}

代码示例来源:origin: i2p/i2p.i2p

public Service getService(String name) {
  ServiceList serviceList = getServiceList();
  int serviceCnt = serviceList.size();
  for (int n = 0; n < serviceCnt; n++) {
    Service service = serviceList.getService(n);
    if (service.isService(name) == true)
      return service;
  }
  DeviceList devList = getDeviceList();
  int devCnt = devList.size();
  for (int n = 0; n < devCnt; n++) {
    Device dev = devList.getDevice(n);
    Service service = dev.getService(name);
    if (service != null)
      return service;
  }
  return null;
}

相关文章

Device类方法