[banshee: 22/27] [lastfm] Auto-disable the streaming extension on first start



commit 0f1ac9349968e9ba5e49488ce688db86af4c38af
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date:   Sat May 22 15:44:26 2010 +0200

    [lastfm] Auto-disable the streaming extension on first start
    
    Add a configuration entry to detect if it's the first run after the
    Last.fm split. If yes, automatically enable the streaming extension if
    the user is a subscriber, disable it if not.

 .../Banshee.Lastfm/Banshee.Lastfm/LastfmSource.cs  |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm/LastfmSource.cs b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm/LastfmSource.cs
index cc22759..6bfa98c 100644
--- a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm/LastfmSource.cs
+++ b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm/LastfmSource.cs
@@ -29,7 +29,9 @@
 using System;
 using System.IO;
 using System.Collections;
+using System.Linq;
 using Mono.Unix;
+using Mono.Addins;
 
 using Lastfm;
 using Lastfm.Gui;
@@ -112,6 +114,14 @@ namespace Banshee.Lastfm
             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 void Dispose ()
@@ -263,5 +273,9 @@ namespace Banshee.Lastfm
         public static readonly SchemaEntry<bool> ExpandedSchema = new SchemaEntry<bool> (
             "plugins.lastfm", "expanded", false, "Last.fm expanded", "Last.fm expanded"
         );
+
+        public static readonly SchemaEntry<bool> FirstRunSchema = new SchemaEntry<bool> (
+            "plugins.lastfm", "first_run", true, "First run", "First run of the Last.fm extension"
+        );
     }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]