[banshee] Emusic.Store: Add an eMusic web store source (bgo#623828)
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] Emusic.Store: Add an eMusic web store source (bgo#623828)
- Date: Fri, 8 Apr 2011 17:33:36 +0000 (UTC)
commit f9bab95a33a52b1326d25e8851b377d0c7da379e
Author: Will Thompson <will willthompson co uk>
Date: Sat Mar 12 17:55:54 2011 +0000
Emusic.Store: Add an eMusic web store source (bgo#623828)
This is basically copy-pasta from the Amazon store, and uses the
existing eMusic downloader plugin. It's lacking an icon, and doesn't
detect being logged in or out.
Signed-off-by: Gabriel Burt <gabriel burt gmail com>
build/build.environment.mk | 2 +
configure.ac | 1 +
data/addin-xml-strings.cs | 5 +
.../Banshee.Emusic.Store.addin.xml | 20 ++++
.../Banshee.Emusic.Store/StoreSource.cs | 56 ++++++++++
.../Banshee.Emusic.Store/StoreView.cs | 112 ++++++++++++++++++++
.../Banshee.Emusic.Store/StoreWebBrowserShell.cs | 53 +++++++++
src/Extensions/Banshee.Emusic.Store/Makefile.am | 17 +++
src/Extensions/Makefile.am | 1 +
9 files changed, 267 insertions(+), 0 deletions(-)
---
diff --git a/build/build.environment.mk b/build/build.environment.mk
index 87ebfea..177764b 100644
--- a/build/build.environment.mk
+++ b/build/build.environment.mk
@@ -132,7 +132,9 @@ REF_EXTENSION_BOOSCRIPT = $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_BOO)
REF_EXTENSION_BPM = $(LINK_BANSHEE_THICKCLIENT_DEPS)
REF_EXTENSION_COVERART = $(LINK_BANSHEE_THICKCLIENT_DEPS)
REF_EXTENSION_DAAP = $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_ICSHARP_ZIP_LIB) $(LINK_MONO_ZEROCONF)
+LINK_EXTENSION_EMUSIC = -r:$(DIR_BIN)/Banshee.Emusic.dll
REF_EXTENSION_EMUSIC = $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_MIGO_DEPS)
+REF_EXTENSION_EMUSIC_STORE = $(LINK_BANSHEE_WEBBROWSER_DEPS) $(LINK_EXTENSION_EMUSIC)
REF_EXTENSION_FILESYSTEMQUEUE = $(LINK_BANSHEE_THICKCLIENT_DEPS)
REF_EXTENSION_INTERNETRADIO = $(LINK_BANSHEE_THICKCLIENT_DEPS)
REF_EXTENSION_INTERNETARCHIVE = $(LINK_BANSHEE_THICKCLIENT_DEPS)
diff --git a/configure.ac b/configure.ac
index 9cf495c..d632736 100644
--- a/configure.ac
+++ b/configure.ac
@@ -358,6 +358,7 @@ src/Extensions/Banshee.Bpm/Makefile
src/Extensions/Banshee.CoverArt/Makefile
src/Extensions/Banshee.Daap/Makefile
src/Extensions/Banshee.Emusic/Makefile
+src/Extensions/Banshee.Emusic.Store/Makefile
src/Extensions/Banshee.FileSystemQueue/Makefile
src/Extensions/Banshee.InternetArchive/Makefile
src/Extensions/Banshee.Fixup/Makefile
diff --git a/data/addin-xml-strings.cs b/data/addin-xml-strings.cs
index 1b9b8dd..c9d1db9 100644
--- a/data/addin-xml-strings.cs
+++ b/data/addin-xml-strings.cs
@@ -69,6 +69,11 @@ internal static class AddinXmlStringCatalog
Catalog.GetString (@"Browse and listen to music shared over your local network.");
Catalog.GetString (@"Utilities");
+ // ../src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store.addin.xml
+ Catalog.GetString (@"eMusic Store");
+ Catalog.GetString (@"Browse, search, and purchase music and audiobooks from eMusic");
+ Catalog.GetString (@"Online Sources");
+
// ../src/Extensions/Banshee.Emusic/Banshee.Emusic.addin.xml
Catalog.GetString (@"eMusic Import");
Catalog.GetString (@"Download and import music purchased from eMusic.");
diff --git a/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store.addin.xml b/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store.addin.xml
new file mode 100644
index 0000000..367bfe9
--- /dev/null
+++ b/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store.addin.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Addin
+ id="Banshee.Emusic.Store"
+ version="1.0"
+ compatVersion="1.0"
+ copyright="Copyright 2010 Novell, Inc.; Copyright 2011 Will Thompson"
+ name="eMusic Store"
+ category="Online Sources"
+ description="Browse, search, and purchase music and audiobooks from eMusic"
+ author="Will Thompson"
+ url="http://banshee.fm/"
+ defaultEnabled="false">
+ <Dependencies>
+ <Addin id="Banshee.Services" version="1.0"/>
+ <Addin id="Banshee.Emusic" version="0.1"/>
+ </Dependencies>
+ <Extension path="/Banshee/SourceManager/Source">
+ <Source class="Banshee.Emusic.Store.StoreSource"/>
+ </Extension>
+</Addin>
diff --git a/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreSource.cs b/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreSource.cs
new file mode 100644
index 0000000..d29e2a6
--- /dev/null
+++ b/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreSource.cs
@@ -0,0 +1,56 @@
+//
+// StoreSource.cs
+//
+// Author:
+// Aaron Bockover <abockover novell com>
+// Will Thompson <will willthompson co uk>
+//
+// Copyright 2010 Novell, Inc.
+// Copyright 2011 Will Thompson
+//
+// 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 System;
+using Mono.Unix;
+
+using Hyena;
+
+using Banshee.WebSource;
+
+namespace Banshee.Emusic.Store
+{
+ public class StoreSource : Banshee.WebSource.WebSource, IDisposable
+ {
+ public StoreWebBrowserShell Shell { get; private set; }
+
+ public StoreSource () : base (Catalog.GetString ("eMusic"), 150, "emusic")
+ {
+ Properties.SetString ("Icon.Name", "emusic-store");
+ }
+
+ public void Dispose ()
+ {
+ }
+
+ protected override WebBrowserShell GetWidget ()
+ {
+ return (Shell = new StoreWebBrowserShell (new StoreView ()));
+ }
+ }
+}
diff --git a/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreView.cs b/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreView.cs
new file mode 100644
index 0000000..4212e93
--- /dev/null
+++ b/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreView.cs
@@ -0,0 +1,112 @@
+//
+// StoreView.cs
+//
+// Authors:
+// Aaron Bockover <abockover novell com>
+// Gabriel Burt <gburt novell com>
+// Will Thompson <will willthompson co uk>
+//
+// Copyright 2010 Novell, Inc.
+// Copyright 2011 Will Thompson
+//
+// 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 System;
+
+using Gtk;
+
+using Hyena;
+using Hyena.Downloader;
+
+using Banshee.Base;
+using Banshee.IO;
+using Banshee.WebBrowser;
+using Banshee.WebSource;
+using Banshee.Emusic;
+
+namespace Banshee.Emusic.Store
+{
+ public class StoreView : WebView
+ {
+ private static bool IsEmusicContentType (string contentType)
+ {
+ return contentType == "application/vnd.emusic-emusic_list";
+ }
+
+ public StoreView ()
+ {
+ CanSearch = true;
+ FullReload ();
+ }
+
+ protected override OssiferNavigationResponse OnMimeTypePolicyDecisionRequested (string mimetype)
+ {
+ // We only explicitly accept (render) text/html types, and only
+ // download what we can import or preview.
+ if (IsEmusicContentType (mimetype) || mimetype == "audio/x-mpegurl") {
+ return OssiferNavigationResponse.Download;
+ }
+
+ return base.OnMimeTypePolicyDecisionRequested (mimetype);
+ }
+
+ protected override string OnDownloadRequested (string mimetype, string uri, string suggestedFilename)
+ {
+ if (IsEmusicContentType (mimetype)) {
+ // BZZT BZZT! Secret "insecure temporary file" code detected.
+ var dest_uri_base = "file://" + Paths.Combine (Paths.TempDir, suggestedFilename);
+ var dest_uri = new SafeUri (dest_uri_base);
+ for (int i = 1; File.Exists (dest_uri);
+ dest_uri = new SafeUri (String.Format ("{0} ({1})", dest_uri_base, ++i)));
+ return dest_uri.AbsoluteUri;
+ } else if (mimetype == "audio/x-mpegurl") {
+ Banshee.Streaming.RadioTrackInfo.OpenPlay (uri);
+ // Banshee.ServiceStack.ServiceManager.PlaybackController.StopWhenFinished = true;
+ return null;
+ }
+
+ return null;
+ }
+
+ protected override void OnDownloadStatusChanged (OssiferDownloadStatus status, string mimetype, string destinationUri)
+ {
+ // FIXME: handle the error case
+ if (status != OssiferDownloadStatus.Finished) {
+ return;
+ }
+
+ if (IsEmusicContentType (mimetype)) {
+ Log.Debug ("OssiferWebView: downloaded purchase list", destinationUri);
+ Banshee.ServiceStack.ServiceManager.Get<EmusicService> ()
+ .ImportEmx (new SafeUri (destinationUri).LocalPath);
+ Reload ();
+ }
+ }
+
+ public override void GoHome ()
+ {
+ LoadUri ("http://integrated-services.banshee.fm/emusic/home/");
+ }
+
+ public override void GoSearch (string query)
+ {
+ LoadUri ("http://integrated-services.banshee.fm/emusic/search/" + System.Uri.EscapeDataString(query));
+ }
+ }
+}
diff --git a/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreWebBrowserShell.cs b/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreWebBrowserShell.cs
new file mode 100644
index 0000000..0d5c8e0
--- /dev/null
+++ b/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreWebBrowserShell.cs
@@ -0,0 +1,53 @@
+//
+// StoreWebBrowserShell.cs
+//
+// Authors:
+// Aaron Bockover <abockover novell com>
+// Gabriel Burt <gburt novell com>
+// Will Thompson <will willthompson co uk>
+//
+// Copyright 2010 Novell, Inc.
+// Copyright 2011 Will Thompson
+//
+// 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 System;
+
+using Gtk;
+using Mono.Unix;
+
+namespace Banshee.Emusic.Store
+{
+ public class StoreWebBrowserShell : Banshee.WebSource.WebBrowserShell
+ {
+ public StoreView StoreView { get; private set; }
+
+ public StoreWebBrowserShell (StoreView store_view) : base (Catalog.GetString ("eMusic"), store_view)
+ {
+ StoreView = store_view;
+
+ SearchEntry.EmptyMessage = String.Format (Catalog.GetString ("Search eMusic"));
+
+ // FIXME: add a â??sign outâ?? button, just as soon as someone figures
+ // out how to detect being signed in.
+
+ ShowAll ();
+ }
+ }
+}
diff --git a/src/Extensions/Banshee.Emusic.Store/Makefile.am b/src/Extensions/Banshee.Emusic.Store/Makefile.am
new file mode 100644
index 0000000..17b8004
--- /dev/null
+++ b/src/Extensions/Banshee.Emusic.Store/Makefile.am
@@ -0,0 +1,17 @@
+ASSEMBLY = Banshee.Emusic.Store
+TARGET = library
+LINK = $(REF_EXTENSION_EMUSIC_STORE)
+INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
+
+SOURCES = \
+ Banshee.Emusic.Store/StoreSource.cs \
+ Banshee.Emusic.Store/StoreView.cs \
+ Banshee.Emusic.Store/StoreWebBrowserShell.cs
+
+RESOURCES = Banshee.Emusic.Store.addin.xml
+
+if HAVE_LIBWEBKIT
+include $(top_srcdir)/build/build.mk
+else
+EXTRA_DIST = $(SOURCES) $(RESOURCES)
+endif
diff --git a/src/Extensions/Makefile.am b/src/Extensions/Makefile.am
index d0c1509..b5621b1 100644
--- a/src/Extensions/Makefile.am
+++ b/src/Extensions/Makefile.am
@@ -8,6 +8,7 @@ SUBDIRS = \
Banshee.CoverArt \
Banshee.Daap \
Banshee.Emusic \
+ Banshee.Emusic.Store \
Banshee.FileSystemQueue \
Banshee.InternetArchive \
Banshee.Fixup \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]