Ejemplo n.º 1
0
        public bool Unmap()
        {
            StopPlayingDisc();

            foreach (TrackInfo track in DiscModel)
            {
                track.CanPlay = false;
            }

            OnUpdated();

            SourceMessage eject_message = new SourceMessage(this);

            eject_message.FreezeNotify();
            eject_message.IsSpinning = true;
            eject_message.CanClose   = false;
            // Translators: {0} is the type of disc, "Audio CD" or "DVD"
            eject_message.Text = String.Format(Catalog.GetString("Ejecting {0}..."), GenericName.ToLower());
            eject_message.ThawNotify();
            PushMessage(eject_message);

            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    DiscModel.Volume.Unmount();
                    DiscModel.Volume.Eject();

                    ThreadAssist.ProxyToMain(delegate {
                        Service.UnmapDiscVolume(DiscModel.Volume.Uuid);
                        Dispose();
                    });
                } catch (Exception e) {
                    ThreadAssist.ProxyToMain(delegate {
                        ClearMessages();
                        eject_message.IsSpinning = false;
                        eject_message.SetIconName("dialog-error");
                        // Translators: {0} is the type of disc, "Audio CD" or "DVD". {1} is the error message.
                        eject_message.Text = String.Format(Catalog.GetString("Could not eject {0}: {1}"), GenericName.ToLower(), e.Message);
                        PushMessage(eject_message);

                        foreach (TrackInfo track in Model)
                        {
                            track.CanPlay = true;
                        }
                        OnUpdated();
                    });

                    Log.Exception(e);
                }
            });

            return(true);
        }
Ejemplo n.º 2
0
        public bool Unmap()
        {
            StopPlayingDisc();

            foreach (TrackInfo track in disc_model)
            {
                track.CanPlay = false;
            }

            OnUpdated();

            SourceMessage eject_message = new SourceMessage(this);

            eject_message.FreezeNotify();
            eject_message.IsSpinning = true;
            eject_message.CanClose   = false;
            eject_message.Text       = Catalog.GetString("Ejecting audio CD...");
            eject_message.ThawNotify();
            PushMessage(eject_message);

            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    disc_model.Volume.Unmount();
                    disc_model.Volume.Eject();

                    ThreadAssist.ProxyToMain(delegate {
                        service.UnmapDiscVolume(disc_model.Volume.Uuid);
                        Dispose();
                    });
                } catch (Exception e) {
                    ThreadAssist.ProxyToMain(delegate {
                        ClearMessages();
                        eject_message.IsSpinning = false;
                        eject_message.SetIconName("dialog-error");
                        eject_message.Text = String.Format(Catalog.GetString("Could not eject audio CD: {0}"), e.Message);
                        PushMessage(eject_message);

                        foreach (TrackInfo track in disc_model)
                        {
                            track.CanPlay = true;
                        }
                        OnUpdated();
                    });

                    Log.Exception(e);
                }
            });

            return(true);
        }
Ejemplo n.º 3
0
        private void OnMetadataQueryStarted(object o, EventArgs args)
        {
            if (query_message != null)
            {
                DestroyQueryMessage();
            }

            query_message = new SourceMessage(this);
            query_message.FreezeNotify();
            query_message.CanClose   = false;
            query_message.IsSpinning = true;
            query_message.Text       = Catalog.GetString("Searching for CD metadata...");
            query_message.ThawNotify();

            PushMessage(query_message);
        }
Ejemplo n.º 4
0
 internal static void SetStatus(SourceMessage status_message, LastfmSource lastfm, bool error, ConnectionState state)
 {
     status_message.FreezeNotify();
     if (error)
     {
         if (state == ConnectionState.NoAccount || state == ConnectionState.InvalidAccount || state == ConnectionState.NotAuthorized)
         {
             status_message.AddAction(new MessageAction(Catalog.GetString("Account Settings"),
                                                        delegate { lastfm.Actions.ShowLoginDialog(); }));
         }
         if (state == ConnectionState.NoAccount || state == ConnectionState.InvalidAccount)
         {
             status_message.AddAction(new MessageAction(Catalog.GetString("Join Last.fm"),
                                                        delegate { lastfm.Account.SignUp(); }));
         }
     }
     status_message.ThawNotify();
 }
Ejemplo n.º 5
0
        private void OnMetadataQueryFinished(object o, EventArgs args)
        {
            if (disc_model.Title != Name)
            {
                Name = disc_model.Title;
                OnUpdated();
            }

            if (disc_model.MetadataQuerySuccess)
            {
                DestroyQueryMessage();
                if (DiscIsPlaying)
                {
                    ServiceManager.PlayerEngine.TrackInfoUpdated();
                }

                if (AudioCdService.AutoRip.Get())
                {
                    BeginAutoRip();
                }

                return;
            }

            if (query_message == null)
            {
                return;
            }

            query_message.FreezeNotify();
            query_message.IsSpinning = false;
            query_message.SetIconName("dialog-error");
            query_message.Text     = Catalog.GetString("Could not fetch metadata for CD.");
            query_message.CanClose = true;
            query_message.ThawNotify();
        }
        private void ShowResponseMessage()
        {
            getting_response = true;

            if (response_message == null)
            {
                response_message            = new SourceMessage(this);
                response_message.CanClose   = false;
                response_message.IsSpinning = false;
                response_message.SetIconName(null);
                response_message.IsHidden = false;
            }

            PushMessage(response_message);
            response_message.FreezeNotify();
            response_message.ClearActions();

            string status_name = String.Format("<i>{0}</i>", GLib.Markup.EscapeText(Name));
            string message     = String.Format(AddinManager.CurrentLocalizer.GetString("{0} is requesting to browse your library"), Contact.Name);

            response_message.Text = String.Format(GLib.Markup.EscapeText(message), status_name);

            response_message.AddAction(new MessageAction(AddinManager.CurrentLocalizer.GetString("Accept"),
                                                         delegate {
                tube_manager.AcceptBrowseRequest();
                ResetResponseMessage();
            }));
            response_message.AddAction(new MessageAction(AddinManager.CurrentLocalizer.GetString("Reject"),
                                                         delegate {
                tube_manager.RejectBrowseRequest();
                ResetResponseMessage();
            }));

            response_message.ThawNotify();
            TelepathyNotification.Create().Show(Contact.Name,
                                                AddinManager.CurrentLocalizer.GetString("is requesting to browse your Banshee library"));

            // show notify bubble every 30 seconds
            System.Timers.Timer notify_timer = new System.Timers.Timer(30000);
            notify_timer.Elapsed += (o, a) => {
                if (!getting_response)
                {
                    notify_timer.Stop();
                }
                else
                {
                    TelepathyNotification.Create().Show(Contact.Name,
                                                        AddinManager.CurrentLocalizer.GetString("is requesting to browse your Banshee library"));
                }
            };
            notify_timer.AutoReset = true;
            notify_timer.Start();

            // pulse source every 5 seconds
            NotifyUser();
            System.Timers.Timer timer = new System.Timers.Timer(5000);
            timer.Elapsed += (o, a) => {
                if (!getting_response)
                {
                    timer.Stop();
                    notify_timer.Stop();
                }
                else
                {
                    NotifyUser();
                }
            };
            timer.AutoReset = true;
            timer.Start();
        }