private void UpdateUI() { bool have_user = Account.UserName != null; bool have_session_key = Account.SessionKey != null; if (have_session_key) { LastSessionKeySchema.Set(Account.SessionKey); LastIsSubscriberSchema.Set(Account.Subscriber); } if (have_user) { SetUserName(Account.UserName); } else { ClearChildSources(); } if (Connection.Connected) { HideStatus(); } else { SetStatus(RadioConnection.MessageFor(Connection.State), Connection.State != ConnectionState.Connecting, Connection.State); } OnUpdated(); }
public LastfmSource() : base(lastfm, lastfm, 210, lastfm) { account = LastfmCore.Account; // We don't automatically connect to Last.fm, but load the last Last.fm // account information if (account.UserName != null) { account.UserName = LastUserSchema.Get(); account.SessionKey = LastSessionKeySchema.Get(); account.Subscriber = LastIsSubscriberSchema.Get(); } if (LastfmCore.UserAgent == null) { LastfmCore.UserAgent = Banshee.Web.Browser.UserAgent; } Browser.Open = Banshee.Web.Browser.Open; connection = LastfmCore.Radio; Network network = ServiceManager.Get <Network> (); connection.UpdateNetworkState(network.Connected); network.StateChanged += HandleNetworkStateChanged; Connection.StateChanged += HandleConnectionStateChanged; UpdateUI(); Properties.SetString("GtkActionPath", "/LastfmSourcePopup"); Properties.SetString("Icon.Name", "lastfm-audioscrobbler"); Properties.Set <LastfmColumnController> ("TrackView.ColumnController", new LastfmColumnController()); // Initialize DataCore's UserAgent and CachePath DataCore.UserAgent = Banshee.Web.Browser.UserAgent; DataCore.CachePath = System.IO.Path.Combine(Hyena.Paths.ExtensionCacheRoot, "lastfm"); // FIXME this is temporary until we split the GUI part from the non-GUI part Properties.Set <ISourceContents> ("Nereid.SourceContents", new LazyLoadSourceContents <LastfmSourceContents> ()); Properties.Set <bool> ("Nereid.SourceContents.HeaderVisible", false); actions = new LastfmActions(this); preferences = new LastfmPreferences(this); ServiceManager.SourceManager.AddSource(this); if (FirstRunSchema.Get()) { var streaming_addin = AddinManager.Registry.GetAddins() .Single(a => a.LocalId.Equals("Banshee.LastfmStreaming")); if (streaming_addin != null) { streaming_addin.Enabled = Account.Subscriber; } FirstRunSchema.Set(false); } }
public LastfmSource() : base(lastfm, lastfm, 210, lastfm) { account = LastfmCore.Account; // We don't automatically connect to Last.fm, but load the last Last.fm // username we used so we can load the user's stations. if (account.UserName != null) { account.UserName = LastUserSchema.Get(); account.SessionKey = LastSessionKeySchema.Get(); account.Subscriber = LastIsSubscriberSchema.Get(); } if (LastfmCore.UserAgent == null) { LastfmCore.UserAgent = Banshee.Web.Browser.UserAgent; } Browser.Open = Banshee.Web.Browser.Open; connection = LastfmCore.Radio; Network network = ServiceManager.Get <Network> (); connection.UpdateNetworkState(network.Connected); network.StateChanged += delegate(object o, NetworkStateChangedArgs args) { connection.UpdateNetworkState(args.Connected); }; Connection.StateChanged += HandleConnectionStateChanged; UpdateUI(); Properties.SetString("ActiveSourceUIResource", "ActiveSourceUI.xml"); Properties.Set <bool> ("ActiveSourceUIResourcePropagate", true); Properties.SetString("GtkActionPath", "/LastfmSourcePopup"); Properties.SetString("Icon.Name", "lastfm-audioscrobbler"); Properties.SetString("SortChildrenActionLabel", Catalog.GetString("Sort Stations by")); Properties.Set <LastfmColumnController> ("TrackView.ColumnController", new LastfmColumnController()); // FIXME this is temporary until we split the GUI part from the non-GUI part Properties.Set <ISourceContents> ("Nereid.SourceContents", new LastfmSourceContents()); Properties.Set <bool> ("Nereid.SourceContents.HeaderVisible", false); actions = new LastfmActions(this); InstallPreferences(); ServiceManager.SourceManager.AddSource(this); ServiceManager.Get <DBusCommandService> ().ArgumentPushed += OnCommandLineArgument; }