use of org.cybergarage.upnp.ServiceStateTable in project felix by apache.
the class MyCtrlPoint method searchForListener.
public void searchForListener(Device device) {
Activator.logger.DEBUG("[Importer] searching for UPnPEventListener");
ServiceReference[] listeners = null;
try {
listeners = context.getServiceReferences(UPnPEventListener.class.getName(), null);
} catch (InvalidSyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (listeners != null) {
String deviceID = device.getUDN();
String serviceID;
String deviceType = device.getDeviceType();
String serviceType;
Hashtable hash = new Hashtable();
hash.put(UPnPDevice.ID, deviceID);
hash.put(UPnPDevice.TYPE, deviceType);
ServiceList services = device.getServiceList();
Vector eventedSers = new Vector();
for (int i = 0; i < services.size(); i++) {
Service service = (Service) services.elementAt(i);
ServiceStateTable vars = service.getServiceStateTable();
for (int j = 0; j < vars.size(); j++) {
StateVariable var = (StateVariable) vars.elementAt(j);
if (var.isSendEvents()) {
eventedSers.add(service);
break;
}
}
}
for (int i = 0; i < listeners.length; i++) {
UPnPEventListener listener = (UPnPEventListener) context.getService(listeners[i]);
Filter filter = (Filter) listeners[i].getProperty(UPnPEventListener.UPNP_FILTER);
if (filter == null) {
for (int j = 0; j < eventedSers.size(); j++) {
Service ser = (Service) eventedSers.elementAt(j);
subQueue.enqueue(new FirstMessage(ser, listener));
}
} else {
for (int j = 0; j < eventedSers.size(); j++) {
Service ser = (Service) eventedSers.elementAt(j);
serviceID = ser.getServiceID();
serviceType = ser.getServiceType();
hash.put(UPnPService.ID, serviceID);
hash.put(UPnPService.TYPE, serviceType);
boolean bool = filter.match(hash);
if (bool) {
subQueue.enqueue(new FirstMessage(ser, listener));
}
}
}
}
}
}
use of org.cybergarage.upnp.ServiceStateTable in project i2p.i2p by i2p.
the class UPnP method listStateTable.
/**
* debug only
*/
private static void listStateTable(Service serv, StringBuilder sb) {
ServiceStateTable table;
try {
table = serv.getServiceStateTable();
} catch (RuntimeException e) {
// getSCPDNode() returns null,
// NPE at org.cybergarage.upnp.Service.getServiceStateTable(Service.java:526)
sb.append(" : no state");
return;
}
sb.append("<ul><small>");
for (int i = 0; i < table.size(); i++) {
StateVariable current = table.getStateVariable(i);
sb.append("<li>").append(DataHelper.escapeHTML(current.getName())).append(" : \"").append(DataHelper.escapeHTML(current.getValue())).append("\"</li>");
}
sb.append("</small></ul>");
}
Aggregations