[banshee] [emusic] Disable by default, and cleanup some



commit d9a85f0e179fbd048f5795f6bbee367afe547424
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Fri Jan 8 16:38:47 2010 -0800

    [emusic] Disable by default, and cleanup some

 data/addin-xml-strings.cs                          |    5 ++
 .../Banshee.Emusic/Banshee.Emusic.addin.xml        |    4 +-
 .../Banshee.Emusic/Banshee.Emusic/EmusicImport.cs  |   10 ++--
 .../Banshee.Emusic/Banshee.Emusic/EmusicService.cs |   64 +++++++++++++-------
 4 files changed, 54 insertions(+), 29 deletions(-)
---
diff --git a/data/addin-xml-strings.cs b/data/addin-xml-strings.cs
index bf682c9..790cea2 100644
--- a/data/addin-xml-strings.cs
+++ b/data/addin-xml-strings.cs
@@ -93,6 +93,11 @@ internal static class AddinXmlStringCatalog
         Catalog.GetString (@"Browse and listen to music shared over your local network.");
         Catalog.GetString (@"Utilities");
 
+        // ../src/Extensions/Banshee.Emusic/Banshee.Emusic.addin.xml
+        Catalog.GetString (@"eMusic Import");
+        Catalog.GetString (@"Download and import music purchased from eMusic");
+        Catalog.GetString (@"Online Sources");
+
         // ../src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue.addin.xml
         Catalog.GetString (@"File System Preview Queue");
         Catalog.GetString (@"Preview files without importing to your library.");
diff --git a/src/Extensions/Banshee.Emusic/Banshee.Emusic.addin.xml b/src/Extensions/Banshee.Emusic/Banshee.Emusic.addin.xml
index 39b9d3c..81dfa55 100644
--- a/src/Extensions/Banshee.Emusic/Banshee.Emusic.addin.xml
+++ b/src/Extensions/Banshee.Emusic/Banshee.Emusic.addin.xml
@@ -5,11 +5,11 @@
     compatVersion="0.1"
     copyright="© 2009 Eitan Isaacson"
     name="eMusic Import"
-    category=""
+    category="Online Sources"
     description="Download and import music purchased from eMusic"
     author="Eitan Isaacson"
     url="http://banshee-project.org/";
-    defaultEnabled="true">
+    defaultEnabled="false">
 
   <Dependencies>
     <Addin id="Banshee.Services" version="1.0"/>
diff --git a/src/Extensions/Banshee.Emusic/Banshee.Emusic/EmusicImport.cs b/src/Extensions/Banshee.Emusic/Banshee.Emusic/EmusicImport.cs
index d1067e8..3f1cf60 100644
--- a/src/Extensions/Banshee.Emusic/Banshee.Emusic/EmusicImport.cs
+++ b/src/Extensions/Banshee.Emusic/Banshee.Emusic/EmusicImport.cs
@@ -57,16 +57,16 @@ namespace Banshee.Emusic
 
         public void Import ()
         {
-            
             var chooser = Banshee.Gui.Dialogs.FileChooserDialog.CreateForImport (Catalog.GetString ("Import eMusic Downloads to Library"), true);
-            Gtk.FileFilter ff = new Gtk.FileFilter();
+            Gtk.FileFilter ff = new Gtk.FileFilter ();
             ff.Name = Catalog.GetString ("eMusic Files");
-            ff.AddPattern("*.emx");
+            ff.AddPattern ("*.emx");
             chooser.AddFilter (ff);
 
-            if (chooser.Run () == (int)Gtk.ResponseType.Ok)
+            if (chooser.Run () == (int)Gtk.ResponseType.Ok) {
                 ServiceManager.Get<EmusicService> ().ImportEmx (chooser.Uris);
-            
+            }
+
             chooser.Destroy ();
         }
 
diff --git a/src/Extensions/Banshee.Emusic/Banshee.Emusic/EmusicService.cs b/src/Extensions/Banshee.Emusic/Banshee.Emusic/EmusicService.cs
index 3453237..4eadb70 100644
--- a/src/Extensions/Banshee.Emusic/Banshee.Emusic/EmusicService.cs
+++ b/src/Extensions/Banshee.Emusic/Banshee.Emusic/EmusicService.cs
@@ -1,3 +1,31 @@
+//
+// EmusicService.cs
+//
+// Author:
+//   Eitan Isaacson <eitan monotonous org>
+//
+// Copyright (C) 2009 Eitan Isaacson
+//
+// 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 System.IO;
 using System.Xml;
@@ -27,12 +55,10 @@ namespace Banshee.Emusic
 
         public EmusicService ()
         {
-            Log.DebugFormat ("{0} constructed.", this.ToString());
         }
 
         public void Initialize ()
         {
-            Log.DebugFormat ("{0} initialized.", this.ToString());
             tasks = new Dictionary<string, HttpFileDownloadTask> ();
 
             import_manager = ServiceManager.Get<LibraryImportManager> ();
@@ -51,7 +77,6 @@ namespace Banshee.Emusic
 
         public void Dispose ()
         {
-            Log.DebugFormat ("{0} disposed.", this.ToString());
             download_manager.Dispose ();
             download_manager_iface.Dispose ();
             download_manager = null;
@@ -68,27 +93,22 @@ namespace Banshee.Emusic
                 ImportEmx (argument);
         }
 
-        public void ImportEmx (string uri)
-        {
-            ImportEmx (new string [] {uri});
-        }
-
-        public void ImportEmx (string[] uris)
+        public void ImportEmx (params string[] uris)
         {
-            foreach (string uri in uris)
-            {
-                using (var xml_reader = new XmlTextReader (uri))
-                {
-                    while (xml_reader.Read())
-                    {
+            foreach (string uri in uris) {
+                using (var xml_reader = new XmlTextReader (uri)) {
+                    while (xml_reader.Read()) {
                         if (xml_reader.NodeType == XmlNodeType.Element &&
                             xml_reader.Name == "TRACKURL")
                         {
                             xml_reader.Read();
                             Hyena.Log.DebugFormat ("Downloading: {0}", xml_reader.Value);
                             HttpFileDownloadTask task = download_manager.CreateDownloadTask (xml_reader.Value);
-                            if (File.Exists (task.LocalPath))
+
+                            if (File.Exists (task.LocalPath)) {
                                 File.Delete (task.LocalPath); // FIXME: We go into a download loop if we don't.
+                            }
+
                             task.Completed += OnDownloadCompleted;
                             download_manager.QueueDownload (task);
                             tasks.Add (task.LocalPath, task);
@@ -102,15 +122,16 @@ namespace Banshee.Emusic
         {
             HttpFileDownloadTask task = sender as HttpFileDownloadTask;
 
-            if (task.Status != TaskStatus.Succeeded)
-            {
+            if (task.Status != TaskStatus.Succeeded) {
                 task.Completed -= OnDownloadCompleted;
 
-                if (File.Exists (task.LocalPath))
+                if (File.Exists (task.LocalPath)) {
                     File.Delete (task.LocalPath);
+                }
 
-                if (Directory.Exists (Path.GetDirectoryName (task.LocalPath)))
+                if (Directory.Exists (Path.GetDirectoryName (task.LocalPath))) {
                     Directory.Delete (Path.GetDirectoryName (task.LocalPath));
+                }
 
                 tasks.Remove (task.LocalPath);
 
@@ -123,8 +144,7 @@ namespace Banshee.Emusic
 
         void HandleImportResult(object o, DatabaseImportResultArgs args)
         {
-            if (tasks.ContainsKey (args.Path))
-            {
+            if (tasks.ContainsKey (args.Path)) {
                 HttpFileDownloadTask task = tasks[args.Path];
                 task.Completed -= OnDownloadCompleted;
                 File.Delete (args.Path);



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