}
}//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;
for (int k = 0; k < stateVars.length; k++) {
hasEventedVars = stateVars[k].sendsEvents();
if (hasEventedVars) {
break;
}
}
if (hasEventedVars) {
newServices
.add(((UPnPServiceImpl) services[j])
.getCyberService());
}//hasEventedvars
}//for services
}//services !=null
context.ungetService(devicesRefs[i]);
}//for devicesRefs
subQueue
.enqueue(new ListenerModified(newServices, listener));
}//devicesRefs !=null
}
} else if (event.getType() == ServiceEvent.UNREGISTERING) {