HandleDeviceCommand() private method

private HandleDeviceCommand ( Banshee.Dap.DapSource source, DeviceCommandAction action ) : void
source Banshee.Dap.DapSource
action DeviceCommandAction
return void
コード例 #1
0
            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);
                        }
                    });
                }
            }