[banshee] Add support for handling u1ms:// links



commit 92ff207f0bd9c60332228f8abb25347c98e22af2
Author: Rodney Dawes <dobey gnome org>
Date:   Mon Feb 28 13:11:29 2011 -0500

    Add support for handling u1ms:// links

 data/desktop-files/banshee-1.desktop.mime          |    1 +
 .../Banshee.UbuntuOneMusicStore.addin.xml          |    2 +-
 .../UbuntuOneMusicStoreSource.cs                   |   26 ++++++++++++++++++++
 3 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/data/desktop-files/banshee-1.desktop.mime b/data/desktop-files/banshee-1.desktop.mime
index 0f26d00..653c099 100644
--- a/data/desktop-files/banshee-1.desktop.mime
+++ b/data/desktop-files/banshee-1.desktop.mime
@@ -135,3 +135,4 @@ video/x-ogm+ogg
 video/x-theora
 video/x-theora+ogg
 x-scheme-handler/lastfm
+x-scheme-handler/u1ms
diff --git a/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore.addin.xml b/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore.addin.xml
index 89bd3f5..be1eb26 100644
--- a/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore.addin.xml
+++ b/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore.addin.xml
@@ -9,7 +9,7 @@
     description="This extension grants access to the Ubuntu One Music Store, powered by 7digital."
     author="Jo Shields"
     url="http://one.ubuntu.com/";
-    defaultEnabled="false">
+    defaultEnabled="true">
 
   <Dependencies>
     <Addin id="Banshee.Services" version="1.0"/>
diff --git a/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore/UbuntuOneMusicStoreSource.cs b/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore/UbuntuOneMusicStoreSource.cs
index 260c384..4a9a4c6 100644
--- a/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore/UbuntuOneMusicStoreSource.cs
+++ b/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore/UbuntuOneMusicStoreSource.cs
@@ -3,8 +3,10 @@
 //
 // Authors:
 //   Jo Shields <directhex apebox org>
+//   Rodney Dawes <rodney dawes canonical com>
 //
 // Copyright (C) 2010 Jo Shields
+// Copyright (C) 2011 Canonical, Ltd.
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -28,6 +30,7 @@
 
 using Mono.Unix;
 using Gdk;
+using System;
 
 using Hyena;
 
@@ -51,6 +54,28 @@ namespace Banshee.UbuntuOneMusicStore
             sort_order, "ubuntu-one-music-store")
         {
             Properties.SetString ("Icon.Name", "ubuntuone");
+
+            // So we can handle u1ms:// URIs
+            ServiceManager.Get<DBusCommandService> ().ArgumentPushed += OnCommandLineArgument;
+        }
+
+        ~UbuntuOneMusicStoreSource ()
+        {
+            ServiceManager.Get<DBusCommandService> ().ArgumentPushed -= OnCommandLineArgument;
+        }
+
+        private void OnCommandLineArgument (string uri, object value, bool isFile)
+        {
+            if (!isFile || String.IsNullOrEmpty (uri)) {
+                return;
+            }
+
+            Log.Debug ("U1MS: URI requested: ", uri);
+            // Handle u1ms:// URIs
+            if (uri.StartsWith ("u1ms://")) {
+                string http_url = uri.Replace ("u1ms://", "http://";);
+                custom_view.Store.LoadStoreLink (http_url);
+            }
         }
 
         // A count of 0 will be hidden in the source TreeView
@@ -127,6 +152,7 @@ namespace Banshee.UbuntuOneMusicStore
             public void ResetSource () { }
             public Gtk.Widget Widget { get { return store; } }
             public ISource Source { get { return null; } }
+            public UbuntuOne.U1MusicStore Store { get { return store; } }
         }
     }
 }



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