Beispiel #1
0
        public void PushMessage(SourceMessage message)
        {
            lock (this) {
                messages.Insert(0, message);
                message.Updated += HandleMessageUpdated;
            }

            OnMessageNotify();
        }
Beispiel #2
0
 public void RemoveMessage(SourceMessage message)
 {
     lock (this) {
         if (messages.Remove(message))
         {
             message.Updated -= HandleMessageUpdated;
             OnMessageNotify();
         }
     }
 }
 public void Dispose()
 {
     if (teaser != null) {
         var podcast_src = ServiceManager.SourceManager.Sources.FirstOrDefault (s => s.UniqueId == "PodcastSource-PodcastLibrary");
         if (podcast_src != null) {
             podcast_src.RemoveMessage (teaser);
         }
         teaser = null;
     }
 }
Beispiel #4
0
 public virtual void HideStatus()
 {
     lock (this) {
         if (status_message != null)
         {
             RemoveMessage(status_message);
             status_message = null;
         }
     }
 }
Beispiel #5
0
        protected void ClearMessages()
        {
            lock (this) {
                if (messages.Count > 0)
                {
                    foreach (SourceMessage message in messages)
                    {
                        message.Updated -= HandleMessageUpdated;
                    }
                    messages.Clear();
                    OnMessageNotify();
                }

                status_message = null;
            }
        }
Beispiel #6
0
        protected SourceMessage PopMessage()
        {
            try {
                lock (this) {
                    if (messages.Count > 0)
                    {
                        SourceMessage message = messages[0];
                        message.Updated -= HandleMessageUpdated;
                        messages.RemoveAt(0);
                        return(message);
                    }

                    return(null);
                }
            } finally {
                OnMessageNotify();
            }
        }
Beispiel #7
0
        private void TestMessages()
        {
            int           count     = 0;
            SourceMessage message_3 = null;

            Application.RunTimeout(5000, delegate {
                if (count++ > 5)
                {
                    if (count == 7)
                    {
                        RemoveMessage(message_3);
                    }
                    PopMessage();
                    return(true);
                }
                else if (count > 10)
                {
                    return(false);
                }

                SourceMessage message = new SourceMessage(this);
                message.FreezeNotify();
                message.Text       = String.Format("Testing message {0}", count);
                message.IsSpinning = count % 2 == 0;
                message.CanClose   = count % 2 == 1;
                if (count % 3 == 0)
                {
                    for (int i = 2; i < count; i++)
                    {
                        message.AddAction(new MessageAction(String.Format("Button {0}", i)));
                    }
                }

                message.ThawNotify();
                PushMessage(message);

                if (count == 3)
                {
                    message_3 = message;
                }

                return(true);
            });
        }
Beispiel #8
0
        public virtual void SetStatus(string message, bool can_close, bool is_spinning, string icon_name)
        {
            lock (this) {
                if (status_message == null)
                {
                    status_message = new SourceMessage(this);
                    PushMessage(status_message);
                }

                string status_name = String.Format("<i>{0}</i>", GLib.Markup.EscapeText(Name));

                status_message.FreezeNotify();
                status_message.Text       = String.Format(GLib.Markup.EscapeText(message), status_name);
                status_message.CanClose   = can_close;
                status_message.IsSpinning = is_spinning;
                status_message.SetIconName(icon_name);
                status_message.IsHidden = false;
                status_message.ClearActions();
            }

            status_message.ThawNotify();
        }
Beispiel #9
0
 private void DestroyQueryMessage ()
 {
     if (query_message != null) {
         RemoveMessage (query_message);
         query_message = null;
     }
 }
Beispiel #10
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 track information...");
            query_message.ThawNotify ();

            PushMessage (query_message);
        }
Beispiel #11
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 ();
 }
Beispiel #12
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;
        }
Beispiel #13
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;
        }
Beispiel #14
0
		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 ();
		}
        private bool MaybeShowTeaserInPodcasts()
        {
            var manager = ServiceManager.SourceManager;
            var podcast_src = manager.Sources.FirstOrDefault (s => s.UniqueId == "PodcastSource-PodcastLibrary");

            if (podcast_src != null) {
                var show = CreateSchema<bool> ("show_miro_guide_teaser_in_podcasts", true, null, null);
                if (show.Get ()) {
                    var msg = new SourceMessage (podcast_src) {
                        CanClose = true,
                        Text = Catalog.GetString ("Discover interesting podcasts in the Miro Guide podcast directory!")
                    };
                    msg.SetIconName ("miro-guide-source");
                    msg.AddAction (new MessageAction (Catalog.GetString ("Open Miro Guide"),
                        delegate { manager.SetActiveSource (this); }
                    ));
                    msg.Updated += delegate {
                        if (msg.IsHidden) {
                            show.Set (false);
                        }
                    };

                    teaser = msg;
                    podcast_src.PushMessage (msg);
                }
                return true;
            }

            return false;
        }
Beispiel #16
0
 public virtual void SetStatus(SourceMessage status_message, string preferences_page_id)
 {
 }