celix_status_t deviceManager_driverRemoved(void * handle, service_reference_pt ref, void * service) { celix_status_t status = CELIX_SUCCESS; device_manager_pt manager = handle; logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove driver"); hashMap_remove(manager->drivers, ref); array_list_pt idleDevices = NULL; status = deviceManager_getIdleDevices(manager, &idleDevices); if (status == CELIX_SUCCESS) { int i; for (i = 0; i < arrayList_size(idleDevices); i++) { celix_status_t forStatus = CELIX_SUCCESS; service_reference_pt ref = arrayList_get(idleDevices, i); const char *bsn = NULL; bundle_pt bundle = NULL; forStatus = serviceReference_getBundle(ref, &bundle); if (forStatus == CELIX_SUCCESS) { module_pt module = NULL; forStatus = bundle_getCurrentModule(bundle, &module); if (forStatus == CELIX_SUCCESS) { forStatus = module_getSymbolicName(module, &bsn); if (forStatus == CELIX_SUCCESS) { logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: IDLE: %s", bsn); // #TODO attachDriver (idle device) // #TODO this can result in a loop? // Locate and install a driver // Let the match fail, the device is idle // The driver is removed, idle check is performed // Attach is tried again // .. loop .. void *device = hashMap_get(manager->devices, ref); forStatus = deviceManager_attachAlgorithm(manager, ref, device); } } } if (forStatus != CELIX_SUCCESS) { break; //Got error, stop loop and return status } } hash_map_iterator_pt iter = hashMapIterator_create(manager->drivers); while (hashMapIterator_hasNext(iter)) { hashMapIterator_nextValue(iter); // driver_attributes_pt da = hashMapIterator_nextValue(iter); // driverAttributes_tryUninstall(da); } hashMapIterator_destroy(iter); } if (idleDevices != NULL) { arrayList_destroy(idleDevices); } return status; }
celix_status_t deviceManager_deviceAdded(void * handle, service_reference_pt ref, void * service) { celix_status_t status = CELIX_SUCCESS; device_manager_pt manager = handle; logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add device"); status = deviceManager_attachAlgorithm(manager, ref, service); return status; }
celix_status_t deviceManager_deviceAdded(void * handle, service_reference_pt ref, void * service) { celix_status_t status = CELIX_SUCCESS; printf("DEVICE_MANAGER: Add device\n"); device_manager_pt manager = handle; status = deviceManager_attachAlgorithm(manager, ref, service); return status; }