public LastfmPreferences (LastfmSource source)
        {
            var service = ServiceManager.Get<PreferenceService> ();
            if (service == null) {
                return;
            }

            this.source = source;

            service.InstallWidgetAdapters += OnPreferencesServiceInstallWidgetAdapters;
            source_page = new Banshee.Preferences.SourcePage (source) {
                (account_section = new Section ("lastfm-account", Catalog.GetString ("Account"), 20) {
                    (username_preference = new SchemaPreference<string> (LastfmSource.LastUserSchema,
                        Catalog.GetString ("_Username")) {
                        ShowLabel = false
                    }),
                    new VoidPreference ("lastfm-signup")
                }),
                (prefs_section = new Section ("lastfm-settings", Catalog.GetString ("Preferences"), 30))
            };

            scrobbler = ServiceManager.Get<Banshee.Lastfm.Audioscrobbler.AudioscrobblerService> ();
            if (scrobbler != null) {
                reporting_preference = new Preference<bool> ("enable-song-reporting",
                    Catalog.GetString ("_Enable Song Reporting"), null, scrobbler.Enabled);
                reporting_preference.ValueChanged += root => scrobbler.Enabled = reporting_preference.Value;
                prefs_section.Add (reporting_preference);
            }
        }
示例#2
0
        public LastfmPreferences(LastfmSource source)
        {
            var service = ServiceManager.Get <PreferenceService> ();

            if (service == null)
            {
                return;
            }

            this.source = source;

            service.InstallWidgetAdapters += OnPreferencesServiceInstallWidgetAdapters;
            source_page = new Banshee.Preferences.SourcePage(source)
            {
                (account_section = new Section("lastfm-account", Catalog.GetString("Account"), 20)
                {
                    (username_preference = new SchemaPreference <string> (LastfmSource.LastUserSchema,
                                                                          Catalog.GetString("_Username"))
                    {
                        ShowLabel = false
                    }),
                    new VoidPreference("lastfm-signup")
                }),
                (prefs_section = new Section("lastfm-settings", Catalog.GetString("Preferences"), 30))
            };

            scrobbler = ServiceManager.Get <Banshee.Lastfm.Audioscrobbler.AudioscrobblerService> ();
            if (scrobbler != null)
            {
                reporting_preference = new Preference <bool> ("enable-song-reporting",
                                                              Catalog.GetString("_Enable Song Reporting"), null, scrobbler.Enabled);
                reporting_preference.ValueChanged += root => scrobbler.Enabled = reporting_preference.Value;
                prefs_section.Add(reporting_preference);
            }
        }
示例#3
0
 public StationEditor(LastfmSource lastfm, StationSource source)
 {
     this.lastfm = lastfm;
     this.source = source;
     Initialize ();
     Title = Catalog.GetString ("Edit Station");
     Arg = source.Arg;
 }
            public NumberedList(LastfmSource lastfm, string name) : base(name)
            {
                this.lastfm = lastfm;
                artwork_manager.AddCachedSize(40);
                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 NumberedList(LastfmSource lastfm, string name) : base(name)
            {
                this.lastfm = lastfm;
                artwork_manager.AddCachedSize(40);
                tile_view = new NumberedTileView(1);
                PackStart(tile_view, true, true, 0);
                tile_view.Show();

                StyleUpdated += delegate {
                    tile_view.OverrideBackgroundColor(StateFlags.Normal, StyleContext.GetBackgroundColor(StateFlags.Normal));
                    tile_view.OverrideColor(StateFlags.Normal, StyleContext.GetColor(StateFlags.Normal));
                };
            }
        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;
        }
示例#7
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;
 }
示例#8
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();
 }
        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);
        }
 public void ResetSource()
 {
     lastfm = null;
 }
示例#11
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.ToInt64 (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 ("Mix"), "Mix", 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;
        }
示例#12
0
        // For StationSources that already exist in the db
        protected StationSource(LastfmSource lastfm, long 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 ();
        }
示例#13
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 ();
        }
示例#14
0
 public StationEditor(LastfmSource lastfm)
 {
     this.lastfm = lastfm;
     Initialize ();
     Title = Catalog.GetString ("New Station");
 }
示例#15
0
        public LastfmActions (LastfmSource lastfm) : base (ServiceManager.Get<InterfaceActionService> (), "Lastfm")
        {
            this.lastfm = lastfm;

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

            // 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 ("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 ("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)
            });

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

            lastfm.Connection.StateChanged += HandleConnectionStateChanged;
            ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent,
                PlayerEvent.StartOfStream |
                PlayerEvent.EndOfStream);
            UpdateActions ();
        }
        public LastfmStreamingActions (LastfmSource lastfm) : base (ServiceManager.Get<InterfaceActionService> (), "LastfmStreaming")
        {
            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
                )
            });

            // 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 ("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)
            });

            // 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)
            });

            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 ();
        }
示例#17
0
            public NumberedList(LastfmSource lastfm, string name)
                : base(name)
            {
                this.lastfm = lastfm;
                artwork_manager.AddCachedSize(40);
                tile_view = new NumberedTileView (1);
                PackStart (tile_view, true, true, 0);
                tile_view.Show ();

                StyleUpdated += delegate {
                    tile_view.OverrideBackgroundColor (StateFlags.Normal, StyleContext.GetBackgroundColor (StateFlags.Normal));
                    tile_view.OverrideColor (StateFlags.Normal, StyleContext.GetColor (StateFlags.Normal));
                };
            }
            public NumberedList (LastfmSource lastfm, string name) : base (name)
            {
                this.lastfm = lastfm;
                artwork_manager.AddCachedSize(40);
                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));
                };
            }
示例#19
0
        public LastfmActions(LastfmSource lastfm) : base(ServiceManager.Get <InterfaceActionService> (), "Lastfm")
        {
            this.lastfm = lastfm;

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

            // 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("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("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)
            });

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

            lastfm.Connection.StateChanged += HandleConnectionStateChanged;
            ServiceManager.PlayerEngine.ConnectEvent(OnPlayerEvent,
                                                     PlayerEvent.StartOfStream |
                                                     PlayerEvent.EndOfStream);
            UpdateActions();
        }
 public void ResetSource ()
 {
     lastfm = null;
 }
示例#21
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 ();
 }