summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will@willthompson.co.uk>2011-03-12 17:55:54 +0000
committerWill Thompson <will@willthompson.co.uk>2011-03-20 23:52:04 +0000
commita4887dfde52ecec290d4cb5fbd7971268c5bc47a (patch)
treed2785791779d8a81ffab51197962b6e51384ea17
parent4a24f1956653c2b67fdee93411983c002643e5a4 (diff)
Add an eMusic web store pane.
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.
-rw-r--r--build/build.environment.mk2
-rw-r--r--configure.ac1
-rw-r--r--data/addin-xml-strings.cs5
-rw-r--r--src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store.addin.xml20
-rw-r--r--src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreSource.cs56
-rw-r--r--src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreView.cs112
-rw-r--r--src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreWebBrowserShell.cs53
-rw-r--r--src/Extensions/Banshee.Emusic.Store/Makefile.am17
-rw-r--r--src/Extensions/Makefile.am1
9 files changed, 267 insertions, 0 deletions
diff --git a/build/build.environment.mk b/build/build.environment.mk
index 87ebfea25..177764bcd 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 63fb0eaf2..a4d01f949 100644
--- a/configure.ac
+++ b/configure.ac
@@ -350,6 +350,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 1b9b8ddb8..c9d1db9c0 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 000000000..367bfe994
--- /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 000000000..d29e2a61d
--- /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 000000000..4212e93f3
--- /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 000000000..0d5c8e0c4
--- /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 000000000..17b8004ba
--- /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 d0c1509c0..b5621b104 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 \