public PodcastGroupSource(DapSource parent) : base(parent, Catalog.GetString("Podcasts")) { Properties.Remove("Icon.Name"); Properties.SetStringList("Icon.Name", "podcast"); ConditionSql = String.Format("(CoreTracks.Attributes & {0}) != 0", (int)TrackMediaAttributes.Podcast); AutoHide = true; }
public MusicGroupSource(DapSource parent) : base(parent, Catalog.GetString ("Music")) { Properties.Remove ("Icon.Name"); Properties.SetStringList ("Icon.Name", Banshee.ServiceStack.ServiceManager.SourceManager.MusicLibrary.Properties.GetStringList ("Icon.Name")); ConditionSql = Banshee.ServiceStack.ServiceManager.SourceManager.MusicLibrary.AttributesCondition; }
private void Unmap(string uuid) { DapSource source = null; lock (sync) { if (sources == null) { // DapService already disposed... return; } if (sources.ContainsKey(uuid)) { Log.DebugFormat("Unmapping DAP source ({0})", uuid); source = sources[uuid]; sources.Remove(uuid); } } if (source != null) { source.Dispose(); ThreadAssist.ProxyToMain(delegate { try { ServiceManager.SourceManager.RemoveSource(source); } catch (Exception e) { Log.Exception(e); } }); } }
public VideoGroupSource(DapSource parent) : base(parent, Catalog.GetString("Videos")) { Properties.Remove("Icon.Name"); Properties.SetStringList("Icon.Name", Banshee.ServiceStack.ServiceManager.SourceManager.VideoLibrary.Properties.GetStringList("Icon.Name")); ConditionSql = Banshee.ServiceStack.ServiceManager.SourceManager.VideoLibrary.AttributesCondition; AutoHide = true; }
private void Unmap(string uuid) { DapSource source = null; lock (sync) { if (sources == null) { Log.WarningFormat("Dap.DapService: already Disposed, can't unmap {0}", uuid); return; } if (sources.ContainsKey(uuid)) { Log.DebugFormat("Unmapping DAP source ({0})", uuid); source = sources[uuid]; sources.Remove(uuid); } } if (source != null) { source.RequestUnmap -= OnRequestUnmap; source.Dispose(); ThreadAssist.ProxyToMain(delegate { try { ServiceManager.SourceManager.RemoveSource(source); } catch (Exception e) { Log.Error(e); } }); } }
internal void UnmapDevice(string uuid) { DapSource source = null; lock (sync) { if (sources.ContainsKey(uuid)) { Log.DebugFormat("Unmapping DAP source ({0})", uuid); source = sources[uuid]; sources.Remove(uuid); } } if (source != null) { try { source.Dispose(); ThreadAssist.ProxyToMain(delegate { ServiceManager.SourceManager.RemoveSource(source); }); } catch (Exception e) { Log.Exception(e); } } }
private void HandleDeviceCommand(DapSource source, DeviceCommandAction action) { if ((action & DeviceCommandAction.Activate) != 0) { ServiceManager.SourceManager.SetActiveSource(source); } }
private DapSource FindDeviceSource(IDevice device) { foreach (TypeExtensionNode node in supported_dap_types) { try { DapSource source = (DapSource)node.CreateInstance(); source.DeviceInitialize(device, false); source.LoadDeviceContents(); source.AddinId = node.Addin.Id; return(source); } catch (InvalidDeviceStateException) { Log.WarningFormat( "Dap.DapService: invalid state, mapping potential source for {0}", device.Name ); DapSource source = new PotentialSource(this, node, device); return(source); } catch (InvalidDeviceException) { } catch (InvalidCastException e) { Log.Warning("Extension is not a DapSource as required", e); } catch (Exception e) { Log.Error(e); } } return(null); }
public VideoGroupSource(DapSource parent) : base(parent, Catalog.GetString ("Videos")) { Properties.Remove ("Icon.Name"); Properties.SetStringList ("Icon.Name", Banshee.ServiceStack.ServiceManager.SourceManager.VideoLibrary.Properties.GetStringList ("Icon.Name")); ConditionSql = Banshee.ServiceStack.ServiceManager.SourceManager.VideoLibrary.AttributesCondition; AutoHide = true; }
public DapSync(DapSource dapSource) { dap = dapSource; sync_limiter = new RateLimiter (RateLimitedSync); BuildPreferences (); BuildSyncLists (); UpdateSensitivities (); }
public DapContent (DapSource source) : base (source) { dap = source; BuildWidgets (); BuildActions (); dap.Properties.PropertyChanged += OnPropertyChanged; }
public DapSync(DapSource dapSource) { dap = dapSource; sync_limiter = new RateLimiter(RateLimitedSync); BuildPreferences(); BuildSyncLists(); UpdateSensitivities(); }
public PodcastGroupSource(DapSource parent) : base(parent, Catalog.GetString ("Podcasts")) { Properties.Remove ("Icon.Name"); Properties.SetStringList ("Icon.Name", "podcast"); ConditionSql = String.Format ("(CoreTracks.Attributes & {0}) != 0", (int)TrackMediaAttributes.Podcast); AutoHide = true; }
private void OnSourceRemoved(SourceEventArgs args) { DapSource dap_source = args.Source as DapSource; if (dap_source != null) { UnmapDevice(dap_source.Device.Uuid); } }
private void OnRequestUnmap(object sender, EventArgs e) { DapSource source = sender as DapSource; if (source != null) { Log.DebugFormat("DapService: unmap request from {0}", source.Device.Uuid); UnmapDevice(source.Device.Uuid); } }
private void OnActiveSourceChanged (EventArgs args) { if (previous_dap != null) { previous_dap.Sync.Updated -= OnSyncUpdated; } previous_dap = ActiveSource as DapSource; if (previous_dap != null) { previous_dap.Sync.Updated += OnSyncUpdated; } }
private bool TryDeviceInitialize (bool force, out DapSource source) { lock (lock_object) { source = null; if (initialized) { return false; } SetStatus ( Catalog.GetString ("Trying to claim your device..."), false, true, "dialog-information" ); Log.Debug ("PotentialSource: Creating Instance"); try { DapSource src = (DapSource) Claimant.CreateInstance (); Log.Debug ("PotentialSource: Initializing Device"); src.DeviceInitialize (Device, force); Log.Debug ("PotentialSource: Loading Contents"); src.LoadDeviceContents (); Log.DebugFormat ("PotentialSource: Success, new Source {0}", src.Name); src.AddinId = Claimant.Addin.Id; source = src; initialized = true; } catch (InvalidDeviceStateException e) { Log.Warning (e); } catch (InvalidDeviceException e) { Log.Warning (e); } catch (Exception e) { Log.Error (e); } bool success = (source != null); SetStatus ( success ? Catalog.GetString ("Connection successful. Please wait...") : Catalog.GetString ("Connection failed"), !success, success, success ? "dialog-information" : "dialog-warning" ); return success; } }
public MediaGroupSource (DapSource parent, string name) : base (name, parent) { this.parent = parent; Properties.Set<Gtk.Widget> ("Nereid.SourceContents.FooterWidget", parent.Properties.Get<Gtk.Widget> ("Nereid.SourceContents.FooterWidget")); if (this is IPurchasedMusicSource) { PurchasedMusicActions.Create (); Properties.Set<Assembly> ("ActiveSourceUIResource.Assembly", Assembly.GetExecutingAssembly ()); Properties.SetString ("ActiveSourceUIResource", "PurchasedMusicSourceUI.xml"); } }
public MediaGroupSource(DapSource parent, string name) : base(name, parent) { this.parent = parent; Properties.Set <Gtk.Widget> ("Nereid.SourceContents.FooterWidget", parent.Properties.Get <Gtk.Widget> ("Nereid.SourceContents.FooterWidget")); if (this is IPurchasedMusicSource) { PurchasedMusicActions.Create(); Properties.Set <Assembly> ("ActiveSourceUIResource.Assembly", Assembly.GetExecutingAssembly()); Properties.SetString("ActiveSourceUIResource", "PurchasedMusicSourceUI.xml"); } }
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.Error(e); } } if (source != null) { service.MapSource(source, false); } }
internal void SwapSource(DapSource oldSource, DapSource newSource, bool makeActive) { if (oldSource.Device.Uuid != newSource.Device.Uuid) { Log.ErrorFormat( "Dap.DapService: swap ignored from {0} to {1}.", oldSource.Device.Uuid, newSource.Device.Uuid ); return; } Log.DebugFormat( "Dap.DapService: Swapping {0} with UUID {1} for {2}", oldSource.GetType().Name, oldSource.Device.Uuid, newSource.GetType().Name ); Unmap(oldSource.Device.Uuid); MapSource(newSource, makeActive); }
private DapSource FindDeviceSource(IDevice device) { foreach (TypeExtensionNode node in supported_dap_types) { try { DapSource source = (DapSource)node.CreateInstance(); source.DeviceInitialize(device); source.LoadDeviceContents(); source.AddinId = node.Addin.Id; return(source); } catch (InvalidDeviceException) { } catch (InvalidCastException e) { Log.Exception("Extension is not a DapSource as required", e); } catch (Exception e) { Log.Exception(e); } } return(null); }
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 MusicGroupSource(DapSource parent) : base(parent, Catalog.GetString("Music")) { Properties.Remove("Icon.Name"); Properties.SetStringList("Icon.Name", Banshee.ServiceStack.ServiceManager.SourceManager.MusicLibrary.Properties.GetStringList("Icon.Name")); ConditionSql = Banshee.ServiceStack.ServiceManager.SourceManager.MusicLibrary.AttributesCondition; }
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); } }); } }
public DapPropertiesDialog(DapSource source) : base(// Translators: {0} is the name assigned to a Digital Audio Player by its owner String.Format(Catalog.GetString("{0} Properties"), source.Name), null, DialogFlags.Modal, Stock.Close, ResponseType.Close) { this.source = source; HBox iconbox = new HBox(); iconbox.Spacing = 10; //Image icon = new Image (source.Properties.Get<string> ("Icon.Names")[0], IconSize.Dialog); //icon.Yalign = 0.0f; //icon.Pixbuf = device.GetIcon(48); //iconbox.PackStart(icon, false, false, 0); VBox box = new VBox(); box.Spacing = 10; PropertyTable table = new PropertyTable(); table.ColumnSpacing = 10; table.RowSpacing = 5; if(!source.IsReadOnly && source.CanRename) { nameEntry = table.AddEntry(Catalog.GetString("Device name"), source.Name); nameEntry.Changed += OnEntryChanged; } else { table.AddLabel(Catalog.GetString("Device name"), source.Name); } /*if(device.ShowOwner) { if(!device.IsReadOnly && device.CanSetOwner) { ownerEntry = table.AddEntry(Catalog.GetString("Owner name"), device.Owner); ownerEntry.Changed += OnEntryChanged; } else { table.AddLabel(Catalog.GetString("Owner name"), device.Owner); } }*/ if(!source.IsReadOnly) { try { VBox profile_description_box = new VBox(); ProfileComboBoxConfigurable profile_box = new ProfileComboBoxConfigurable(ServiceManager.MediaProfileManager, source.UniqueId, profile_description_box); profile_box.Combo.MimeTypeFilter = source.AcceptableMimeTypes; table.AddWidget(Catalog.GetString("Encode to"), profile_box); table.AddWidget(null, profile_description_box); profile_description_box.Show(); table.AddSeparator(); } catch(Exception e) { Console.WriteLine(e); } } table.AddWidget(Catalog.GetString("Capacity used"), UsedProgressBar); box.PackStart(table, true, true, 0); PropertyTable extTable = new PropertyTable(); extTable.ColumnSpacing = 10; extTable.RowSpacing = 5; foreach(DapSource.DapProperty property in source.DapProperties) { extTable.AddLabel(property.Name, property.Value); } Expander expander = new Expander(Catalog.GetString("Advanced details")); expander.Add(extTable); box.PackStart(expander, false, false, 0); BorderWidth = 10; Resizable = false; iconbox.PackStart(box, true, true, 0); iconbox.ShowAll(); ContentArea.Add(iconbox); }
public DapPropertiesDialog(DapSource source) : base( // Translators: {0} is the name assigned to a Digital Audio Player by its owner String.Format(Catalog.GetString("{0} Properties"), source.Name), null, DialogFlags.Modal, Stock.Close, ResponseType.Close) { this.source = source; HBox iconbox = new HBox(); iconbox.Spacing = 10; //Image icon = new Image (source.Properties.Get<string> ("Icon.Names")[0], IconSize.Dialog); //icon.Yalign = 0.0f; //icon.Pixbuf = device.GetIcon(48); //iconbox.PackStart(icon, false, false, 0); VBox box = new VBox(); box.Spacing = 10; PropertyTable table = new PropertyTable(); table.ColumnSpacing = 10; table.RowSpacing = 5; if (!source.IsReadOnly && source.CanRename) { nameEntry = table.AddEntry(Catalog.GetString("Device name"), source.Name); nameEntry.Changed += OnEntryChanged; } else { table.AddLabel(Catalog.GetString("Device name"), source.Name); } /*if(device.ShowOwner) { * if(!device.IsReadOnly && device.CanSetOwner) { * ownerEntry = table.AddEntry(Catalog.GetString("Owner name"), device.Owner); * ownerEntry.Changed += OnEntryChanged; * } else { * table.AddLabel(Catalog.GetString("Owner name"), device.Owner); * } * }*/ if (!source.IsReadOnly) { try { VBox profile_description_box = new VBox(); ProfileComboBoxConfigurable profile_box = new ProfileComboBoxConfigurable(ServiceManager.MediaProfileManager, source.UniqueId, profile_description_box); profile_box.Combo.MimeTypeFilter = source.AcceptableMimeTypes; table.AddWidget(Catalog.GetString("Encode to"), profile_box); table.AddWidget(null, profile_description_box); profile_description_box.Show(); table.AddSeparator(); } catch (Exception e) { Console.WriteLine(e); } } table.AddWidget(Catalog.GetString("Capacity used"), UsedProgressBar); box.PackStart(table, true, true, 0); PropertyTable extTable = new PropertyTable(); extTable.ColumnSpacing = 10; extTable.RowSpacing = 5; foreach (DapSource.DapProperty property in source.DapProperties) { extTable.AddLabel(property.Name, property.Value); } Expander expander = new Expander(Catalog.GetString("Advanced details")); expander.Add(extTable); box.PackStart(expander, false, false, 0); BorderWidth = 10; Resizable = false; iconbox.PackStart(box, true, true, 0); iconbox.ShowAll(); ContentArea.Add(iconbox); }
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 InactiveDapContent(DapSource dapSource) : base(dapSource) { dapSource.Properties.PropertyChanged += OnPropertyChanged; BuildWidgets (); }
internal void SwapSource(DapSource oldSource, DapSource newSource, bool makeActive) { if (oldSource.Device.Uuid != newSource.Device.Uuid) { Log.ErrorFormat ( "Dap.DapService: swap ignored from {0} to {1}.", oldSource.Device.Uuid, newSource.Device.Uuid ); return; } Log.DebugFormat ( "Dap.DapService: Swapping {0} with UUID {1} for {2}", oldSource.GetType ().Name, oldSource.Device.Uuid, newSource.GetType ().Name ); Unmap (oldSource.Device.Uuid); MapSource (newSource, makeActive); }
private void HandleDeviceCommand (DapSource source, DeviceCommandAction action) { if ((action & DeviceCommandAction.Activate) != 0) { ServiceManager.SourceManager.SetActiveSource (source); } }
private bool TryDeviceInitialize(bool force, out DapSource source) { lock (lock_object) { source = null; if (initialized) { return false; } SetStatus ( Catalog.GetString ("Trying to claim your device..."), false, true, "dialog-information" ); Log.Debug ("PotentialSource: Creating Instance"); try { DapSource src = (DapSource) Claimant.CreateInstance (); Log.Debug ("PotentialSource: Initializing Device"); src.DeviceInitialize (Device, force); Log.Debug ("PotentialSource: Loading Contents"); src.LoadDeviceContents (); Log.DebugFormat ("PotentialSource: Success, new Source {0}", src.Name); src.AddinId = Claimant.Addin.Id; source = src; initialized = true; } catch (InvalidDeviceStateException e) { Log.Warning (e); } catch (InvalidDeviceException e) { Log.Warning (e); } catch (Exception e) { Log.Error (e); } bool success = (source != null); SetStatus ( success ? Catalog.GetString ("Connection successful. Please wait...") : Catalog.GetString ("Connection failed"), !success, success, success ? "dialog-information" : "dialog-warning" ); return success; } }