[banshee] Add the Ubuntu One Music Store extension



commit 369038080017116f7db0d8abc332145a253fa8d9
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date:   Sat Dec 11 16:08:24 2010 +0100

    Add the Ubuntu One Music Store extension
    
    This extension integrates the Ubuntu One Music Store in Banshee. It was
    originally created by Jo Shields as part of the Banshee Community
    Extensions.
    
    It's disabled by default and can be enabled by passing
    --enable-ubuntuone to configure.
    
    It depends on ubuntuone-sharp, which provides a GTK+ widget embedding
    the store.
    
    The original source history is available in the Banshee Community
    Extension repository :
    http://gitorious.org/banshee-community-extensions

 Banshee.sln                                        |   13 ++
 build/build.environment.mk                         |    2 +
 build/m4/banshee/ubuntuonemusicstore.m4            |   20 +++
 configure.ac                                       |    5 +
 data/addin-xml-strings.cs                          |    5 +
 po/POTFILES.in                                     |    1 +
 .../Banshee.UbuntuOneMusicStore.addin.xml          |   23 ++++
 .../Banshee.UbuntuOneMusicStore.csproj             |   97 ++++++++++++++
 .../UbuntuOneMusicStoreSource.cs                   |  134 ++++++++++++++++++++
 .../Banshee.UbuntuOneMusicStore/Makefile.am        |   16 +++
 .../Resources/ubuntuone.png                        |  Bin 0 -> 1131 bytes
 src/Extensions/Makefile.am                         |    1 +
 12 files changed, 317 insertions(+), 0 deletions(-)
---
diff --git a/Banshee.sln b/Banshee.sln
index a1b9261..ff76e1d 100644
--- a/Banshee.sln
+++ b/Banshee.sln
@@ -142,6 +142,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Banshee.AmazonMp3.Store", "
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Banshee.SoundMenu", "src\Extensions\Banshee.SoundMenu\Banshee.SoundMenu.csproj", "{EE91126B-5500-4719-9FAA-36CBAC95DEE3}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Banshee.UbuntuOneMusicStore", "src\Extensions\Banshee.UbuntuOneMusicStore\Banshee.UbuntuOneMusicStore.csproj", "{3B855EBC-8E55-48DF-816B-B241BE45EBD8}"
+EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{4F47D6F1-4047-4A89-AE85-3AE5EF9F2961}"
 	ProjectSection(SolutionItems) = postProject
 	EndProjectSection
@@ -245,6 +247,16 @@ Global
 		{3B7DD288-5546-4907-B302-0CD0271D9713}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{3B7DD288-5546-4907-B302-0CD0271D9713}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{3B7DD288-5546-4907-B302-0CD0271D9713}.Windows|Any CPU.ActiveCfg = Windows|Any CPU
+		{3B855EBC-8E55-48DF-816B-B241BE45EBD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{3B855EBC-8E55-48DF-816B-B241BE45EBD8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{3B855EBC-8E55-48DF-816B-B241BE45EBD8}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{3B855EBC-8E55-48DF-816B-B241BE45EBD8}.Debug|x86.Build.0 = Debug|Any CPU
+		{3B855EBC-8E55-48DF-816B-B241BE45EBD8}.Release|Any CPU.ActiveCfg = Debug|Any CPU
+		{3B855EBC-8E55-48DF-816B-B241BE45EBD8}.Release|Any CPU.Build.0 = Debug|Any CPU
+		{3B855EBC-8E55-48DF-816B-B241BE45EBD8}.Release|x86.ActiveCfg = Debug|Any CPU
+		{3B855EBC-8E55-48DF-816B-B241BE45EBD8}.Release|x86.Build.0 = Debug|Any CPU
+		{3B855EBC-8E55-48DF-816B-B241BE45EBD8}.Windows|Any CPU.ActiveCfg = Windows|Any CPU
+		{3B855EBC-8E55-48DF-816B-B241BE45EBD8}.Windows|Any CPU.Build.0 = Windows|Any CPU
 		{46AD1892-C5D3-4696-BA40-FBF7F4CE2B39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{46AD1892-C5D3-4696-BA40-FBF7F4CE2B39}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{46AD1892-C5D3-4696-BA40-FBF7F4CE2B39}.Windows|Any CPU.ActiveCfg = Windows|Any CPU
@@ -528,6 +540,7 @@ Global
 		{930ADBFD-07F1-4044-A1C5-8B28BD23DB5C} = {4DD1DE63-F20B-4FC3-8FDA-F0BDF4183722}
 		{AF8A9C6D-2188-413D-8EB8-C5E242BD68AC} = {4DD1DE63-F20B-4FC3-8FDA-F0BDF4183722}
 		{EE91126B-5500-4719-9FAA-36CBAC95DEE3} = {4DD1DE63-F20B-4FC3-8FDA-F0BDF4183722}
+		{3B855EBC-8E55-48DF-816B-B241BE45EBD8} = {4DD1DE63-F20B-4FC3-8FDA-F0BDF4183722}
 		{95374549-9553-4C1E-9D89-667755F90E12} = {4F47D6F1-4047-4A89-AE85-3AE5EF9F2961}
 		{95374549-9553-4C1E-9D89-667755F90E13} = {4F47D6F1-4047-4A89-AE85-3AE5EF9F2961}
 		{C856EFD8-E812-4E61-8B76-E3583D94C233} = {4F47D6F1-4047-4A89-AE85-3AE5EF9F2961}
diff --git a/build/build.environment.mk b/build/build.environment.mk
index 137a8c6..5dd05ae 100644
--- a/build/build.environment.mk
+++ b/build/build.environment.mk
@@ -29,6 +29,7 @@ LINK_MONOTORRENT_DBUS = $(MONOTORRENT_DBUS_LIBS)
 LINK_MONO_ADDINS_DEPS = $(MONO_ADDINS_LIBS)
 LINK_MONO_ADDINS_SETUP_DEPS = $(MONO_ADDINS_SETUP_LIBS)
 LINK_INDICATESHARP = $(INDICATESHARP_LIBS)
+LINK_UBUNTUONESHARP = $(UBUNTUONESHARP_LIBS)
 
 DIR_BIN = $(top_builddir)/bin
 
@@ -161,6 +162,7 @@ REF_EXTENSION_PODCASTING = $(LINK_MIGO_DEPS) $(LINK_BANSHEE_THICKCLIENT_DEPS)
 REF_EXTENSION_AUDIOBOOK = $(LINK_BANSHEE_THICKCLIENT_DEPS)
 REF_EXTENSION_SAMPLE = $(LINK_BANSHEE_THICKCLIENT_DEPS)
 REF_EXTENSION_REMOTE_AUDIO = $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_MONO_ZEROCONF)
+REF_EXTENSION_UBUNTUONEMUSICSTORE= $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_UBUNTUONESHARP)
 REF_EXTENSION_WIKIPEDIA= $(LINK_BANSHEE_WEBBROWSER_DEPS)
 
 # Backends
diff --git a/build/m4/banshee/ubuntuonemusicstore.m4 b/build/m4/banshee/ubuntuonemusicstore.m4
new file mode 100644
index 0000000..2ff4a67
--- /dev/null
+++ b/build/m4/banshee/ubuntuonemusicstore.m4
@@ -0,0 +1,20 @@
+AC_DEFUN([BANSHEE_CHECK_UBUNTUONE],
+[
+	AC_ARG_ENABLE([ubuntuone],
+		AS_HELP_STRING([--enable-ubuntuone], [Enable Ubuntu One Music Store support]),
+		enable_ubuntuone=$enableval, enable_ubuntuone=no
+	)
+
+	if test "x$enable_ubuntuone" = "xyes"; then
+		has_ubuntuonesharp=no
+		PKG_CHECK_MODULES(UBUNTUONESHARP,
+			[ubuntuone-sharp-1.0],
+			has_ubuntuonesharp=yes, has_ubuntuonesharp=no)
+		if test "x$has_ubuntuonesharp" = "xno"; then
+			AC_MSG_ERROR([ubuntuone-sharp was not found. Please install ubuntuone-sharp, or disable Ubuntu One support by passing --disable-ubuntuone])
+		fi
+	fi
+
+	AM_CONDITIONAL(ENABLE_UBUNTUONE, test "x$enable_ubuntuone" = "xyes")
+])
+
diff --git a/configure.ac b/configure.ac
index 0fd6ba0..1cd941a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -178,6 +178,9 @@ BANSHEE_CHECK_MEEGO
 dnl Sound menu integration (optional)
 BANSHEE_CHECK_SOUNDMENU
 
+dnl Ubuntu One Music Store (optional)
+BANSHEE_CHECK_UBUNTUONE
+
 dnl Gapless, if we have a new-enough playbin2
 ENABLE_GAPLESS="no"
 AC_ARG_ENABLE(gapless-playback,
@@ -365,6 +368,7 @@ src/Extensions/Banshee.SqlDebugConsole/Makefile
 src/Extensions/Banshee.Sample/Makefile
 src/Extensions/Banshee.Torrent/Makefile
 src/Extensions/Banshee.RemoteAudio/Makefile
+src/Extensions/Banshee.UbuntuOneMusicStore/Makefile
 src/Extensions/Banshee.Wikipedia/Makefile
 src/Extensions/Banshee.YouTube/Makefile
 
@@ -418,6 +422,7 @@ ${PACKAGE}-${VERSION}
     Gapless playback:  ${ENABLE_GAPLESS} (gstreamer-plugins-base > 0.10.25.2)
     YouTube extension: ${enable_youtube} (gdata-sharp >= 1.4)
     Sound menu:        ${enable_soundmenu} (indicate-sharp >= 0.4.1)
+    Ubuntu One Store:  ${enable_ubuntuone} (ubuntuone-sharp)
 
   Build/Development:
     Unit Tests:        ${do_tests} (nunit >= ${NUNIT_REQUIRED})
diff --git a/data/addin-xml-strings.cs b/data/addin-xml-strings.cs
index 8246b86..4fde14f 100644
--- a/data/addin-xml-strings.cs
+++ b/data/addin-xml-strings.cs
@@ -218,6 +218,11 @@ internal static class AddinXmlStringCatalog
         Catalog.GetString (@"Support downloading BitTorrent files from podcasts.");
         Catalog.GetString (@"Utilities");
 
+        // ../src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore.addin.xml
+        Catalog.GetString (@"Ubuntu One Music Store");
+        Catalog.GetString (@"This extension grants access to the Ubuntu One Music Store, powered by 7digital.");
+        Catalog.GetString (@"Online Sources");
+
         // ../src/Extensions/Banshee.Wikipedia/Banshee.Wikipedia.addin.xml
         Catalog.GetString (@"Wikipedia");
         Catalog.GetString (@"View artist information from Wikipedia in the context pane.");
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5b04eff..5ada56e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -298,6 +298,7 @@ src/Extensions/Banshee.Sample/Banshee.Sample/SampleSource.cs
 src/Extensions/Banshee.SoundMenu/Banshee.SoundMenu/SoundMenuService.cs
 src/Extensions/Banshee.SqlDebugConsole/Banshee.SqlDebugConsole/SqlActions.cs
 src/Extensions/Banshee.Torrent/Banshee.Torrent.addin.xml
+src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore/UbuntuOneMusicStoreSource.cs
 src/Extensions/Banshee.Wikipedia/Banshee.Wikipedia.addin.xml
 src/Extensions/Banshee.Wikipedia/Banshee.Wikipedia/ContextPage.cs
 src/Extensions/Banshee.Wikipedia/Banshee.Wikipedia/WikipediaView.cs
diff --git a/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore.addin.xml b/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore.addin.xml
new file mode 100644
index 0000000..89bd3f5
--- /dev/null
+++ b/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore.addin.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Addin 
+    id="Banshee.UbuntuOneMusicStore"
+    version="1.0"
+    compatVersion="1.0"
+    copyright="Copyright 2010 Jo Shields. Licensed under the MIT X11 license."
+    name="Ubuntu One Music Store"
+    category="Online Sources"
+    description="This extension grants access to the Ubuntu One Music Store, powered by 7digital."
+    author="Jo Shields"
+    url="http://one.ubuntu.com/";
+    defaultEnabled="false">
+
+  <Dependencies>
+    <Addin id="Banshee.Services" version="1.0"/>
+    <Addin id="Banshee.ThickClient" version="1.0"/>
+  </Dependencies>
+
+  <Extension path="/Banshee/SourceManager/Source">
+    <Source class="Banshee.UbuntuOneMusicStore.UbuntuOneMusicStoreSource"/>
+  </Extension>
+
+</Addin>
diff --git a/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore.csproj b/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore.csproj
new file mode 100644
index 0000000..420e027
--- /dev/null
+++ b/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore.csproj
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"; ToolsVersion="3.5">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.50727</ProductVersion>
+    <ProjectGuid>{3B855EBC-8E55-48DF-816B-B241BE45EBD8}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <UseParentDirectoryAsNamespace>true</UseParentDirectoryAsNamespace>
+    <AssemblyName>Banshee.UbuntuOneMusicStore</AssemblyName>
+    <SchemaVersion>2.0</SchemaVersion>
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <Optimize>true</Optimize>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
+    <RootNamespace>Banshee.UbuntuOneMusicStore</RootNamespace>
+    <AssemblyOriginatorKeyFile>.</AssemblyOriginatorKeyFile>
+    <ReleaseVersion>1.3</ReleaseVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <OutputPath>..\..\..\bin</OutputPath>
+    <WarningLevel>4</WarningLevel>
+    <Optimize>false</Optimize>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Windows|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <OutputPath>..\..\..\bin</OutputPath>
+    <PlatformTarget>x86</PlatformTarget>
+    <WarningLevel>4</WarningLevel>
+    <Optimize>false</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+      <Package>gtk-sharp-2.0</Package>
+    </Reference>
+    <Reference Include="Mono.Posix" />
+    <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+      <Package>gtk-sharp-2.0</Package>
+    </Reference>
+    <Reference Include="ubuntuone-sharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
+      <Package>ubuntuone-sharp-1.0</Package>
+    </Reference>
+    <Reference Include="Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
+      <Package>mono-addins</Package>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Resources\ubuntuone.png">
+      <LogicalName>ubuntuone.png</LogicalName>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Banshee.UbuntuOneMusicStore.addin.xml">
+      <LogicalName>Banshee.UbuntuOneMusicStore.addin.xml</LogicalName>
+    </EmbeddedResource>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Banshee.UbuntuOneMusicStore\UbuntuOneMusicStoreSource.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ProjectExtensions>
+    <MonoDevelop>
+      <Properties>
+        <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="true" RelativeMakefileName="Makefile.am">
+          <BuildFilesVar Sync="true" Name="SOURCES" />
+          <DeployFilesVar />
+          <ResourcesVar Sync="true" Name="RESOURCES" />
+          <OthersVar />
+          <GacRefVar />
+          <AsmRefVar />
+          <ProjectRefVar />
+        </MonoDevelop.Autotools.MakefileInfo>
+      </Properties>
+    </MonoDevelop>
+  </ProjectExtensions>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Core\Banshee.Core\Banshee.Core.csproj">
+      <Project>{2ADB831A-A050-47D0-B6B9-9C19D60233BB}</Project>
+      <Name>Banshee.Core</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Core\Banshee.Services\Banshee.Services.csproj">
+      <Project>{B28354F0-BA87-44E8-989F-B864A3C7C09F}</Project>
+      <Name>Banshee.Services</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Core\Banshee.ThickClient\Banshee.ThickClient.csproj">
+      <Project>{AC839523-7BDF-4AB6-8115-E17921B96EC6}</Project>
+      <Name>Banshee.ThickClient</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Hyena\Hyena\Hyena.csproj">
+      <Project>{95374549-9553-4C1E-9D89-667755F90E12}</Project>
+      <Name>Hyena</Name>
+    </ProjectReference>
+  </ItemGroup>
+</Project>
diff --git a/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore/UbuntuOneMusicStoreSource.cs b/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore/UbuntuOneMusicStoreSource.cs
new file mode 100644
index 0000000..f975e70
--- /dev/null
+++ b/src/Extensions/Banshee.UbuntuOneMusicStore/Banshee.UbuntuOneMusicStore/UbuntuOneMusicStoreSource.cs
@@ -0,0 +1,134 @@
+//
+// UbuntuOneMusicStoreSource.cs
+//
+// Authors:
+//   Jo Shields <directhex apebox org>
+//
+// Copyright (C) 2010 Jo Shields
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using Mono.Unix;
+using Gdk;
+
+using Hyena;
+
+using Banshee.Collection;
+using Banshee.Gui;
+using Banshee.ServiceStack;
+using Banshee.Sources;
+using Banshee.Sources.Gui;
+
+namespace Banshee.UbuntuOneMusicStore
+{
+    public class UbuntuOneMusicStoreSource : Source
+    {
+        // In the sources TreeView, sets the order value for this source, small on top
+        const int sort_order = 190;
+        CustomView custom_view;
+
+        public UbuntuOneMusicStoreSource () : base (
+            Catalog.GetString ("Ubuntu One Music Store"),
+            Catalog.GetString ("Ubuntu One Music Store"),
+            sort_order, "ubuntu-one-music-store")
+        {
+            Pixbuf icon = new Pixbuf (System.Reflection.Assembly.GetExecutingAssembly ()
+                                      .GetManifestResourceStream ("ubuntuone.png"));
+            Properties.Set<Pixbuf> ("Icon.Pixbuf_22", icon.ScaleSimple (22, 22, InterpType.Bilinear));
+        }
+
+        // A count of 0 will be hidden in the source TreeView
+        public override int Count {
+            get { return 0; }
+        }
+
+        // Defer any UI creation until it's actually needed.
+        public override void Activate ()
+        {
+            if (custom_view == null) {
+                Properties.Set<ISourceContents> ("Nereid.SourceContents", custom_view = new CustomView ());
+            }
+
+            base.Activate ();
+            Log.Debug ("U1MS: Initialized");
+        }
+
+        public class StoreWrapper: UbuntuOne.U1MusicStore, IDisableKeybindings
+        {
+            string U1LibraryLocation = System.IO.Path.Combine (System.IO.Path.Combine (System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal), ".ubuntuone"), "Purchased from Ubuntu One");
+
+            public StoreWrapper (): base ()
+            {
+                this.PreviewMp3 += PlayMP3Preview;
+                this.DownloadFinished += AddDownloadToLibrary;
+                this.PlayLibrary += PlayU1MSLibrary;
+                this.UrlLoaded += U1MSUrlLoaded;
+            }
+
+            private void PlayMP3Preview (object Sender, UbuntuOne.PreviewMp3Args a)
+            {
+                Log.Debug ("U1MS: Playing preview: ", a.Url );
+                TrackInfo PreviewTrack = new TrackInfo ();
+                PreviewTrack.TrackTitle = a.Title;
+                PreviewTrack.ArtistName = Catalog.GetString ("Track Preview");
+                PreviewTrack.AlbumTitle = Catalog.GetString ("Ubuntu One Music Store");
+                PreviewTrack.Uri = new SafeUri (a.Url);
+                ServiceManager.PlayerEngine.OpenPlay (PreviewTrack);
+                ServiceManager.PlaybackController.StopWhenFinished = true;
+            }
+
+            private void AddDownloadToLibrary (object Sender, UbuntuOne.DownloadFinishedArgs a)
+            {
+                Log.Debug ("U1MS: Track downloaded: ", a.Path);
+                ServiceManager.Get<Banshee.Library.LibraryImportManager> ().ImportTrack (new SafeUri (a.Path));
+                ServiceManager.Get<Banshee.Library.LibraryImportManager> ().NotifyAllSources ();
+            }
+
+            private void PlayU1MSLibrary (object Sender, UbuntuOne.PlayLibraryArgs a)
+            {
+                Log.Debug ("U1MS: Playing from library: ", a.Path);
+                Log.Debug ("U1MS: U1 library location: ", U1LibraryLocation);
+                int track_id = Banshee.Collection.Database.DatabaseTrackInfo.GetTrackIdForUri (System.IO.Path.Combine (U1LibraryLocation, a.Path));
+                if (track_id > 0)
+                {
+                    var track = Banshee.Collection.Database.DatabaseTrackInfo.Provider.FetchSingle (track_id);
+                    ServiceManager.PlaybackController.NextSource = ServiceManager.SourceManager.MusicLibrary;
+                    ServiceManager.PlayerEngine.OpenPlay (track);
+                }
+            }
+
+            private void U1MSUrlLoaded (object Sender, UbuntuOne.UrlLoadedArgs a)
+            {
+                Log.Debug ("U1MS: Url Loaded: ", a.Url);
+            }
+        }
+
+        private class CustomView : ISourceContents
+        {
+            StoreWrapper store = new StoreWrapper ();
+
+            public bool SetSource (ISource source) { return true; }
+            public void ResetSource () { }
+            public Gtk.Widget Widget { get { return store; } }
+            public ISource Source { get { return null; } }
+        }
+    }
+}
diff --git a/src/Extensions/Banshee.UbuntuOneMusicStore/Makefile.am b/src/Extensions/Banshee.UbuntuOneMusicStore/Makefile.am
new file mode 100644
index 0000000..a00b36a
--- /dev/null
+++ b/src/Extensions/Banshee.UbuntuOneMusicStore/Makefile.am
@@ -0,0 +1,16 @@
+ASSEMBLY = Banshee.UbuntuOneMusicStore
+TARGET = library
+LINK = $(REF_EXTENSION_UBUNTUONEMUSICSTORE)
+INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
+
+SOURCES = Banshee.UbuntuOneMusicStore/UbuntuOneMusicStoreSource.cs
+
+RESOURCES =  \
+	Banshee.UbuntuOneMusicStore.addin.xml \
+	Resources/ubuntuone.png
+
+if ENABLE_UBUNTUONE
+include $(top_srcdir)/build/build.mk
+else
+EXTRA_DIST = $(SOURCES) $(RESOURCES)
+endif
diff --git a/src/Extensions/Banshee.UbuntuOneMusicStore/Resources/ubuntuone.png b/src/Extensions/Banshee.UbuntuOneMusicStore/Resources/ubuntuone.png
new file mode 100644
index 0000000..dca1f8d
Binary files /dev/null and b/src/Extensions/Banshee.UbuntuOneMusicStore/Resources/ubuntuone.png differ
diff --git a/src/Extensions/Makefile.am b/src/Extensions/Makefile.am
index 5a270a5..d0c1509 100644
--- a/src/Extensions/Makefile.am
+++ b/src/Extensions/Makefile.am
@@ -30,6 +30,7 @@ SUBDIRS = \
 	Banshee.SqlDebugConsole \
 	Banshee.Torrent \
 	Banshee.RemoteAudio \
+	Banshee.UbuntuOneMusicStore \
 	Banshee.Wikipedia \
 	Banshee.YouTube
 



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