Пример #1
0
 public StationEditor(LastfmSource lastfm) : base(dialog_name, new Glade.XML(
                                                      System.Reflection.Assembly.GetExecutingAssembly(), dialog_resource, dialog_name, Banshee.ServiceStack.Application.InternalName))
 {
     this.lastfm = lastfm;
     Initialize();
     Dialog.Title = Catalog.GetString("New Station");
 }
Пример #2
0
        public StationSource(LastfmSource lastfm, string name, string type, string arg) : base(generic_name, name, 150)
        {
            this.lastfm = lastfm;
            Type        = StationType.FindByName(type);
            Arg         = arg;
            Station     = Type.GetStationFor(arg);

            Save();

            StationInitialize();
        }
Пример #3
0
        // For StationSources that already exist in the db
        protected StationSource(LastfmSource lastfm, int dbId, string name, string type, string arg, int playCount) : base(generic_name, name, 150, dbId.ToString())
        {
            this.lastfm = lastfm;
            dbid        = dbId;
            Type        = StationType.FindByName(type);
            Arg         = arg;
            PlayCount   = playCount;
            Station     = Type.GetStationFor(arg);

            StationInitialize();
        }
Пример #4
0
            public NumberedList(LastfmSource lastfm, string name) : base(name)
            {
                this.lastfm = lastfm;
                tile_view   = new NumberedTileView(1);
                PackStart(tile_view, true, true, 0);
                tile_view.Show();

                StyleSet += delegate {
                    tile_view.ModifyBg(StateType.Normal, Style.Base(StateType.Normal));
                    tile_view.ModifyFg(StateType.Normal, Style.Text(StateType.Normal));
                };
            }
Пример #5
0
 public static StationSource CreateFromUrl(LastfmSource lastfm, string url)
 {
     foreach (StationType type in StationType.Types)
     {
         string regex = Regex.Escape(type.GetStationFor("XXX")).Replace("XXX", "([^\\/]+)");
         Match  match = Regex.Match(url, regex);
         if (match.Groups.Count == 2 && match.Groups[0].Captures.Count > 0)
         {
             Log.DebugFormat("Creating last.fm station from url {0}", url);
             string        arg     = match.Groups[1].Captures[0].Value;
             StationSource station = new StationSource(lastfm, arg, type.Name, arg);
             lastfm.AddChildSource(station);
             station.NotifyUser();
         }
     }
     return(null);
 }
Пример #6
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();
 }
Пример #7
0
        public bool SetSource(ISource src)
        {
            lastfm = src as LastfmSource;
            if (lastfm == null)
            {
                return(false);
            }

            if (lastfm.Connection.Connected)
            {
                UpdateForUser(lastfm.Account.UserName);
            }
            else
            {
                lastfm.Connection.StateChanged += HandleConnectionStateChanged;
            }

            return(true);
        }
Пример #8
0
        public static List <StationSource> LoadAll(LastfmSource lastfm, string creator)
        {
            List <StationSource> stations = new List <StationSource> ();

            HyenaSqliteCommand command = new HyenaSqliteCommand(
                "SELECT StationID, Name, Type, Arg, PlayCount FROM LastfmStations WHERE Creator = ?",
                creator
                );

            using (IDataReader reader = ServiceManager.DbConnection.Query(command)) {
                while (reader.Read())
                {
                    try {
                        stations.Add(new StationSource(lastfm,
                                                       Convert.ToInt32(reader[0]),
                                                       reader[1] as string,
                                                       reader[2] as string,
                                                       reader[3] as string,
                                                       Convert.ToInt32(reader[4])
                                                       ));
                    } catch (Exception e) {
                        Log.Warning("Error Loading Last.fm Station", e.ToString(), false);
                    }
                }
            }

            // Create some default stations if the user has none
            if (stations.Count == 0)
            {
                stations.Add(new StationSource(lastfm, Catalog.GetString("Recommended"), "Recommended", creator));
                stations.Add(new StationSource(lastfm, Catalog.GetString("Personal"), "Personal", creator));
                stations.Add(new StationSource(lastfm, Catalog.GetString("Loved"), "Loved", creator));
                stations.Add(new StationSource(lastfm, Catalog.GetString("Banshee Group"), "Group", "Banshee"));
                stations.Add(new StationSource(lastfm, Catalog.GetString("Neighbors"), "Neighbor", creator));
                stations.Add(new StationSource(lastfm, Catalog.GetString("Creative Commons"), "Tag", "creative commons"));
            }

            return(stations);
        }
Пример #9
0
 public void SetStatus(string message, bool error, ConnectionState state)
 {
     base.SetStatus(message, error);
     LastfmSource.SetStatus(status_message, lastfm, error, state);
 }
Пример #10
0
 public override void SetStatus(string message, bool error)
 {
     base.SetStatus(message, error);
     LastfmSource.SetStatus(status_message, lastfm, error, ConnectionState.Connected);
 }
Пример #11
0
 public void ResetSource()
 {
     lastfm = null;
 }
Пример #12
0
        public LastfmActions(LastfmSource lastfm) : base(ServiceManager.Get <InterfaceActionService> (), "Lastfm")
        {
            this.lastfm = lastfm;

            AddImportant(
                new ActionEntry(
                    "LastfmAddAction", Stock.Add,
                    Catalog.GetString("_Add Station..."),
                    null, Catalog.GetString("Add a new Last.fm radio station"), OnAddStation
                    )
                );

            Add(new ActionEntry [] {
                new ActionEntry(
                    "RefreshSourceAction", Stock.Refresh,
                    Catalog.GetString("Refresh"), null,
                    String.Empty, OnRefreshSource
                    ),

                new ActionEntry(
                    "LastfmConnectAction", null,
                    Catalog.GetString("Connect"),
                    null, String.Empty, OnConnect
                    )
            });

            // Translators: {0} is a type of Last.fm station, eg "Fans of" or "Similar to".
            string listen_to = Catalog.GetString("Listen to {0} Station");
            // Translators: {0} is a type of Last.fm station, eg "Fans of" or "Similar to".
            string listen_to_long = Catalog.GetString("Listen to the Last.fm {0} station for this artist");

            // Artist actions
            Add(new ActionEntry [] {
                new ActionEntry("LastfmArtistVisitLastfmAction", "audioscrobbler",
                                Catalog.GetString("View on Last.fm"), null,
                                Catalog.GetString("View this artist's Last.fm page"), OnArtistVisitLastfm),

                new ActionEntry("LastfmArtistVisitWikipediaAction", "",
                                Catalog.GetString("View Artist on Wikipedia"), null,
                                Catalog.GetString("Find this artist on Wikipedia"), OnArtistVisitWikipedia),

                /*new ActionEntry ("LastfmArtistVisitAmazonAction", "",
                 *  Catalog.GetString ("View Artist on Amazon"), null,
                 *  Catalog.GetString ("Find this artist on Amazon"), OnArtistVisitAmazon),*/

                new ActionEntry("LastfmArtistViewVideosAction", "",
                                Catalog.GetString("View Artist's Videos"), null,
                                Catalog.GetString("Find videos by this artist"), OnArtistViewVideos),

                new ActionEntry("LastfmArtistPlayFanRadioAction", StationType.Fan.IconName,
                                String.Format(listen_to, String.Format("'{0}'", Catalog.GetString("Fans of"))), null,
                                String.Format(listen_to_long, String.Format("'{0}'", Catalog.GetString("Fans of"))),
                                OnArtistPlayFanRadio),

                new ActionEntry("LastfmArtistPlaySimilarRadioAction", StationType.Similar.IconName,
                                String.Format(listen_to, String.Format("'{0}'", Catalog.GetString("Similar to"))), null,
                                String.Format(listen_to_long, String.Format("'{0}'", Catalog.GetString("Similar to"))),
                                OnArtistPlaySimilarRadio),

                new ActionEntry("LastfmArtistRecommendAction", "",
                                Catalog.GetString("Recommend to"), null,
                                Catalog.GetString("Recommend this artist to someone"), OnArtistRecommend)
            });

            // Album actions
            Add(new ActionEntry [] {
                new ActionEntry("LastfmAlbumVisitLastfmAction", "audioscrobbler.png",
                                Catalog.GetString("View on Last.fm"), null,
                                Catalog.GetString("View this album's Last.fm page"), OnAlbumVisitLastfm),

                /*new ActionEntry ("LastfmAlbumVisitAmazonAction", "",
                 *  Catalog.GetString ("View Album on Amazon"), null,
                 *  Catalog.GetString ("Find this album on Amazon"), OnAlbumVisitAmazon),*/

                new ActionEntry("LastfmAlbumRecommendAction", "",
                                Catalog.GetString("Recommend to"), null,
                                Catalog.GetString("Recommend this album to someone"), OnAlbumRecommend)
            });

            // Track actions
            Add(new ActionEntry [] {
                new ActionEntry(
                    "LastfmLoveAction", null,
                    Catalog.GetString("Love Track"), null,
                    Catalog.GetString("Mark current track as loved"), OnLoved),

                new ActionEntry(
                    "LastfmHateAction", null,
                    Catalog.GetString("Ban Track"), null,
                    Catalog.GetString("Mark current track as banned"), OnHated),

                new ActionEntry("LastfmTrackVisitLastfmAction", "audioscrobbler",
                                Catalog.GetString("View on Last.fm"), null,
                                Catalog.GetString("View this track's Last.fm page"), OnTrackVisitLastfm),

                new ActionEntry("LastfmTrackRecommendAction", "",
                                Catalog.GetString("Recommend to"), null,
                                Catalog.GetString("Recommend this track to someone"), OnTrackRecommend)
            });

            this["LastfmLoveAction"].IconName = "face-smile";
            this["LastfmHateAction"].IconName = "face-sad";

            this["LastfmLoveAction"].IsImportant = true;
            this["LastfmHateAction"].IsImportant = true;

            actions_id = Actions.UIManager.AddUiFromResource("GlobalUI.xml");
            Actions.AddActionGroup(this);

            lastfm.Connection.StateChanged += HandleConnectionStateChanged;
            Actions.SourceActions ["SourcePropertiesAction"].Activated += OnSourceProperties;
            ServiceManager.PlaybackController.SourceChanged            += OnPlaybackSourceChanged;
            ServiceManager.PlayerEngine.ConnectEvent(OnPlayerEvent,
                                                     PlayerEvent.StartOfStream |
                                                     PlayerEvent.EndOfStream);
            UpdateActions();
        }