Commit e13c46f3 authored by Nicholas Little's avatar Nicholas Little Committed by Andrés G. Aragoneses

Dap: refactor DapService, extract method

Signed-off-by: default avatarAndrés G. Aragoneses <knocte@gmail.com>
parent 3e748631
......@@ -221,32 +221,37 @@ namespace Banshee.Dap
}
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;
}
service.MapSource (source);
}
}
}
private void MapSource (DapSource source)
{
ThreadAssist.ProxyToMain (() => {
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 (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);
}
});
}
} catch (Exception e) {
Log.Error (e);
}
}
});
}
internal void UnmapDevice (string uuid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment