[banshee/stable-2.2] u1ms: Ensure u1ms URIs passed at startup get loaded by the store



commit 1346fcaf02c16b554edf67459d8eb6d1cd6bf1f7
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date:   Tue Nov 1 18:56:26 2011 +0100

    u1ms: Ensure u1ms URIs passed at startup get loaded by the store
    
    This is a combination of two patches by Alex Launi and Rodney Dawes that
    were already applied on git master. Fixes bgo#660818.

 .../UbuntuOneMusicStoreSource.cs                   |   28 ++++++++++++++++---
 1 files changed, 23 insertions(+), 5 deletions(-)
---
diff --git a/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore/UbuntuOneMusicStoreSource.cs b/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore/UbuntuOneMusicStoreSource.cs
index e06ea9c..6cedff0 100644
--- a/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore/UbuntuOneMusicStoreSource.cs
+++ b/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore/UbuntuOneMusicStoreSource.cs
@@ -61,6 +61,14 @@ namespace Banshee.UbuntuOneMusicStore
 
             // So we can handle u1ms:// URIs
             ServiceManager.Get<DBusCommandService> ().ArgumentPushed += OnCommandLineArgument;
+
+            // make sure that the u1ms uri gets handled on banshee startup
+            foreach (string uri in ApplicationContext.CommandLine.Files) {
+                if (IsU1msUri (uri)) {
+                    LoadU1msUri (uri);
+                    break;
+                }
+            }
         }
 
         ~UbuntuOneMusicStoreSource ()
@@ -68,24 +76,34 @@ namespace Banshee.UbuntuOneMusicStore
             ServiceManager.Get<DBusCommandService> ().ArgumentPushed -= OnCommandLineArgument;
         }
 
+        // A count of 0 will be hidden in the source TreeView
+        public override int Count {
+            get { return 0; }
+        }
+
         private void OnCommandLineArgument (string uri, object value, bool isFile)
         {
             if (!isFile || String.IsNullOrEmpty (uri)) {
                 return;
             }
 
+            LoadU1msUri (uri);
+        }
+
+        private void LoadU1msUri (string uri)
+        {
             Log.Debug ("U1MS: URI requested: ", uri);
             // Handle u1ms:// URIs
-            if (uri.StartsWith ("u1ms://")) {
+            if (IsU1msUri (uri)) {
                 string http_url = uri.Replace ("u1ms://", "http://";);
                 custom_view.Store.LoadStoreLink (http_url);
                 ServiceManager.SourceManager.SetActiveSource (this);
             }
         }
 
-        // A count of 0 will be hidden in the source TreeView
-        public override int Count {
-            get { return 0; }
+        private bool IsU1msUri (string uri)
+        {
+            return uri.StartsWith ("u1ms://");
         }
 
         public class StoreWrapper: UbuntuOne.U1MusicStore, IDisableKeybindings
@@ -140,7 +158,7 @@ namespace Banshee.UbuntuOneMusicStore
 
         private class CustomView : ISourceContents
         {
-            StoreWrapper store = new StoreWrapper ();
+            internal StoreWrapper store = new StoreWrapper ();
 
             public bool SetSource (ISource source) { return true; }
             public void ResetSource () { }



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