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; }
void IExtensionService.Initialize() { account = LastfmCore.Account; if (account.UserName == null) { account.UserName = LastUserSchema.Get(); account.SessionKey = LastSessionKeySchema.Get(); account.ScrobbleUrl = LastScrobbleUrlSchema.Get(); } if (LastfmCore.UserAgent == null) { LastfmCore.UserAgent = Banshee.Web.Browser.UserAgent; } Browser.Open = Banshee.Web.Browser.Open; queue = new Queue(); LastfmCore.AudioscrobblerQueue = queue; connection = LastfmCore.Audioscrobbler; // Initialize with a reasonable value in case we miss the first StartOfStream event song_start_time = DateTime.Now; Network network = ServiceManager.Get <Network> (); connection.UpdateNetworkState(network.Connected); network.StateChanged += HandleNetworkStateChanged; // Update the Visit action menu item if we update our account info LastfmCore.Account.Updated += delegate(object o, EventArgs args) { actions["AudioscrobblerVisitAction"].Sensitive = String.IsNullOrEmpty(LastfmCore.Account.UserName); }; ServiceManager.PlayerEngine.ConnectEvent(OnPlayerEvent, PlayerEvent.StartOfStream | PlayerEvent.EndOfStream | PlayerEvent.Seek | PlayerEvent.Iterate); if (DeviceEnabled) { SubscribeForDeviceEvents(); } action_service = ServiceManager.Get <InterfaceActionService> (); InterfaceInitialize(); }
void IExtensionService.Initialize() { account = LastfmCore.Account; if (account.UserName == null) { account.UserName = LastUserSchema.Get(); account.SessionKey = LastSessionKeySchema.Get(); account.ScrobbleUrl = LastScrobbleUrlSchema.Get(); } if (LastfmCore.UserAgent == null) { LastfmCore.UserAgent = Banshee.Web.Browser.UserAgent; } Browser.Open = Banshee.Web.Browser.Open; queue = new Queue(); LastfmCore.AudioscrobblerQueue = queue; connection = LastfmCore.Audioscrobbler; Network network = ServiceManager.Get <Network> (); connection.UpdateNetworkState(network.Connected); network.StateChanged += delegate(object o, NetworkStateChangedArgs args) { connection.UpdateNetworkState(args.Connected); }; // Update the Visit action menu item if we update our account info LastfmCore.Account.Updated += delegate(object o, EventArgs args) { actions["AudioscrobblerVisitAction"].Sensitive = String.IsNullOrEmpty(LastfmCore.Account.UserName); }; ServiceManager.PlayerEngine.ConnectEvent(OnPlayerEvent, PlayerEvent.StartOfStream | PlayerEvent.EndOfStream | PlayerEvent.Seek | PlayerEvent.Iterate); action_service = ServiceManager.Get <InterfaceActionService> ("InterfaceActionService"); InterfaceInitialize(); }
private void OnPreferencesServiceInstallWidgetAdapters(object sender, EventArgs args) { if (pref_section == null) { return; } var user_entry = new Gtk.Entry(user_pref.Value ?? ""); user_entry.Changed += (o, a) => { user_pref.Value = user_entry.Text; }; var auth_button = new Gtk.Button(Authorized ? Catalog.GetString("Authorized!") : Catalog.GetString("Authorize...")); user_pref.ValueChanged += (s) => { auth_button.Sensitive = NeedAuth; }; auth_button.Sensitive = NeedAuth; auth_button.TooltipText = Catalog.GetString("Open Last.fm in a browser, giving you the option to authorize Banshee to work with your account"); auth_button.Clicked += delegate { account.SessionKey = null; account.RequestAuthorization(); }; var signup_button = new Gtk.LinkButton(account.SignUpUrl, Catalog.GetString("Sign up for Last.fm")); signup_button.Xalign = 0f; var refresh_button = new Gtk.Button(new Gtk.Image(Gtk.Stock.Refresh, Gtk.IconSize.Button)); user_pref.ValueChanged += (s) => { refresh_button.Sensitive = NeedAuth; }; refresh_button.Sensitive = NeedAuth; refresh_button.TooltipText = Catalog.GetString("Check if Banshee has been authorized"); refresh_button.Clicked += delegate { if (String.IsNullOrEmpty(account.UserName) || account.SessionKey == null) { account.UserName = LastUserSchema.Get(); account.FetchSessionKey(); account.Save(); LastSessionKeySchema.Set(account.SessionKey); } auth_button.Sensitive = refresh_button.Sensitive = NeedAuth; auth_button.Label = Authorized ? Catalog.GetString("Authorized!") : Catalog.GetString("Authorize..."); }; var auth_box = new Gtk.HBox() { Spacing = 6 }; auth_box.PackStart(user_entry, true, true, 0); auth_box.PackStart(auth_button, false, false, 0); auth_box.PackStart(refresh_button, false, false, 0); auth_box.ShowAll(); signup_button.Visible = String.IsNullOrEmpty(user_pref.Value); var button_box = new Gtk.HBox() { Spacing = 6 }; button_box.PackStart(new Badge(account) { Visible = true }, false, false, 0); button_box.PackStart(signup_button, true, true, 0); user_pref.DisplayWidget = auth_box; pref_section["lastfm-signup"].DisplayWidget = button_box; }