private void MapSource(DapSource source, bool active) { lock (sync) { sources [source.Device.Uuid] = source; source.RequestUnmap += OnRequestUnmap; } ThreadAssist.ProxyToMain(() => { ServiceManager.SourceManager.AddSource(source); source.NotifyUser(); if (active) { ServiceManager.SourceManager.SetActiveSource(source); } // If there are any queued device commands, see if they are to be // handled by this new DAP (e.g. --device-activate=file:///media/disk) try { if (unhandled_device_commands != null) { foreach (DeviceCommand command in unhandled_device_commands) { if (source.CanHandleDeviceCommand(command)) { HandleDeviceCommand(source, command.Action); unhandled_device_commands.Remove(command); if (unhandled_device_commands.Count == 0) { unhandled_device_commands = null; } break; } } } } catch (Exception e) { Log.Error(e); } }); }
public void Run() { DapSource source = null; lock (service.sync) { try { if (service.sources.ContainsKey(device.Uuid)) { return; } if (device is ICdromDevice || device is IDiscVolume) { return; } if (device is IVolume && (device as IVolume).ShouldIgnore) { return; } if (device.MediaCapabilities == null && !(device is IBlockDevice) && !(device is IVolume)) { return; } source = service.FindDeviceSource(device); if (source != null) { Log.DebugFormat("Found DAP support ({0}) for device {1} and Uuid {2}", source.GetType().FullName, source.Name, device.Uuid); service.sources.Add(device.Uuid, source); } } catch (Exception e) { Log.Exception(e); } } if (source != null) { ThreadAssist.ProxyToMain(delegate { ServiceManager.SourceManager.AddSource(source); source.NotifyUser(); // If there are any queued device commands, see if they are to be // handled by this new DAP (e.g. --device-activate=file:///media/disk) try { if (service.unhandled_device_commands != null) { foreach (DeviceCommand command in service.unhandled_device_commands) { if (source.CanHandleDeviceCommand(command)) { service.HandleDeviceCommand(source, command.Action); service.unhandled_device_commands.Remove(command); if (service.unhandled_device_commands.Count == 0) { service.unhandled_device_commands = null; } break; } } } } catch (Exception e) { Log.Exception(e); } }); } }
private void MapSource(DapSource source, bool active) { lock (sync) { sources [source.Device.Uuid] = source; source.RequestUnmap += OnRequestUnmap; } ThreadAssist.ProxyToMain (() => { ServiceManager.SourceManager.AddSource (source); source.NotifyUser (); if (active) { ServiceManager.SourceManager.SetActiveSource (source); } // If there are any queued device commands, see if they are to be // handled by this new DAP (e.g. --device-activate=file:///media/disk) try { if (unhandled_device_commands != null) { foreach (DeviceCommand command in unhandled_device_commands) { if (source.CanHandleDeviceCommand (command)) { HandleDeviceCommand (source, command.Action); unhandled_device_commands.Remove (command); if (unhandled_device_commands.Count == 0) { unhandled_device_commands = null; } break; } } } } catch (Exception e) { Log.Error (e); } }); }