Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
        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);
                    }
                });
            }
        }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
        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);
                    }
                });
            }
        }
Esempio n. 6
0
        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);
                }
            }
        }
Esempio n. 7
0
 private void HandleDeviceCommand(DapSource source, DeviceCommandAction action)
 {
     if ((action & DeviceCommandAction.Activate) != 0)
     {
         ServiceManager.SourceManager.SetActiveSource(source);
     }
 }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
 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;
 }
Esempio n. 10
0
 public DapSync(DapSource dapSource)
 {
     dap = dapSource;
     sync_limiter = new RateLimiter (RateLimitedSync);
     BuildPreferences ();
     BuildSyncLists ();
     UpdateSensitivities ();
 }
Esempio n. 11
0
        public DapContent (DapSource source) : base (source)
        {
            dap = source;

            BuildWidgets ();
            BuildActions ();
            dap.Properties.PropertyChanged += OnPropertyChanged;
        }
Esempio n. 12
0
 public DapSync(DapSource dapSource)
 {
     dap          = dapSource;
     sync_limiter = new RateLimiter(RateLimitedSync);
     BuildPreferences();
     BuildSyncLists();
     UpdateSensitivities();
 }
Esempio n. 13
0
 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;
 }
Esempio n. 14
0
        private void OnSourceRemoved(SourceEventArgs args)
        {
            DapSource dap_source = args.Source as DapSource;

            if (dap_source != null)
            {
                UnmapDevice(dap_source.Device.Uuid);
            }
        }
Esempio n. 15
0
        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);
            }
        }
Esempio n. 16
0
        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;
            }
        }
Esempio n. 17
0
        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");
            }
        }
Esempio n. 19
0
        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");
            }
        }
Esempio n. 20
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.Error(e);
                    }
                }

                if (source != null)
                {
                    service.MapSource(source, false);
                }
            }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
        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);
                }
            });
        }
Esempio n. 24
0
 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;
 }
Esempio n. 25
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);
                        }
                    });
                }
            }
Esempio n. 26
0
        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);
        }
Esempio n. 27
0
        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);
        }
Esempio n. 28
0
        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);
                }
            });
        }
Esempio n. 29
0
 public InactiveDapContent(DapSource dapSource)
     : base(dapSource)
 {
     dapSource.Properties.PropertyChanged += OnPropertyChanged;
     BuildWidgets ();
 }
Esempio n. 30
0
        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);
        }
Esempio n. 31
0
 private void HandleDeviceCommand (DapSource source, DeviceCommandAction action)
 {
     if ((action & DeviceCommandAction.Activate) != 0) {
         ServiceManager.SourceManager.SetActiveSource (source);
     }
 }
Esempio n. 32
0
        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;
            }
        }