[banshee] [AmazonMp3] Use new DownloadManagerJob class
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [AmazonMp3] Use new DownloadManagerJob class
- Date: Thu, 2 Sep 2010 17:43:04 +0000 (UTC)
commit 6edbd3ccefdc508050b35c4ab8ae7b67e6d26978
Author: Gabriel Burt <gabriel burt gmail com>
Date: Thu Sep 2 12:42:21 2010 -0500
[AmazonMp3] Use new DownloadManagerJob class
po/POTFILES.in | 19 ++++++-
po/POTFILES.skip | 17 -----
.../Banshee.AmazonMp3/Banshee.AmazonMp3.csproj | 2 +-
...DownloadManager.cs => AmazonDownloadManager.cs} | 64 ++++----------------
src/Extensions/Banshee.AmazonMp3/Makefile.am | 4 +-
src/Hyena | 2 +-
6 files changed, 33 insertions(+), 75 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a0706bb..57fed0d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -179,9 +179,9 @@ src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/WebOSDevice.cs
src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp.addin.xml
src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
+src/Extensions/Banshee.AmazonMp3/Banshee.AmazonMp3/AmazonDownloadManager.cs
src/Extensions/Banshee.AmazonMp3/Banshee.AmazonMp3/AmazonMp3DownloaderService.cs
src/Extensions/Banshee.AmazonMp3/Banshee.AmazonMp3/ImportSource.cs
-src/Extensions/Banshee.AmazonMp3/Banshee.AmazonMp3/UserJobDownloadManager.cs
src/Extensions/Banshee.AmazonMp3.Store/Banshee.AmazonMp3.Store/StoreSource.cs
src/Extensions/Banshee.AmazonMp3.Store/Banshee.AmazonMp3.Store/StoreSourcePreferences.cs
src/Extensions/Banshee.AmazonMp3.Store/Banshee.AmazonMp3.Store/StoreWebBrowserShell.cs
@@ -303,6 +303,23 @@ src/Extensions/Banshee.Wikipedia/Banshee.Wikipedia/WikipediaView.cs
src/Extensions/Banshee.YouTube/Banshee.YouTube/ContextPage.cs
src/Extensions/Banshee.YouTube/Banshee.YouTube.Gui/VideoStreamTile.cs
src/Extensions/Banshee.YouTube/Banshee.YouTube/YouTubePane.cs
+src/Hyena/Hyena.Gui/Hyena.Data.Gui/Accessibility/ColumnHeaderCellTextAccessible.cs
+src/Hyena/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs
+src/Hyena/Hyena.Gui/Hyena.Gui.Dialogs/ExceptionDialog.cs
+src/Hyena/Hyena.Gui/Hyena.Gui.Dialogs/VersionInformationDialog.cs
+src/Hyena/Hyena.Gui/Hyena.Query.Gui/FileSizeQueryValueEntry.cs
+src/Hyena/Hyena.Gui/Hyena.Query.Gui/QueryBox.cs
+src/Hyena/Hyena.Gui/Hyena.Query.Gui/QueryLimitBox.cs
+src/Hyena/Hyena.Gui/Hyena.Query.Gui/RelativeTimeSpanQueryValueEntry.cs
+src/Hyena/Hyena.Gui/Hyena.Query.Gui/TimeSpanQueryValueEntry.cs
+src/Hyena/Hyena.Gui/Hyena.Widgets/RatingMenuItem.cs
+src/Hyena/Hyena/Hyena.Downloader/DownloadManagerJob.cs
+src/Hyena/Hyena/Hyena.Query/DateQueryValue.cs
+src/Hyena/Hyena/Hyena.Query/EnumQueryValue.cs
+src/Hyena/Hyena/Hyena.Query/IntegerQueryValue.cs
+src/Hyena/Hyena/Hyena.Query/NullQueryValue.cs
+src/Hyena/Hyena/Hyena.Query/RelativeTimeSpanQueryValue.cs
+src/Hyena/Hyena/Hyena.Query/StringQueryValue.cs
src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginDialog.cs
src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginForm.cs
src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 15939ac..56dca0e 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -1,19 +1,2 @@
data/audio-profiles/aac.xml.in
src/Hyena/Mono.Data.Sqlite/Mono.Data.Sqlite/SR.Designer.cs
-src/Hyena/Hyena.Gui/Hyena.Data.Gui/Accessibility/ColumnHeaderCellTextAccessible.cs
-src/Hyena/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs
-src/Hyena/Hyena.Gui/Hyena.Gui.Dialogs/ExceptionDialog.cs
-src/Hyena/Hyena.Gui/Hyena.Gui.Dialogs/VersionInformationDialog.cs
-src/Hyena/Hyena.Gui/Hyena.Query.Gui/FileSizeQueryValueEntry.cs
-src/Hyena/Hyena.Gui/Hyena.Query.Gui/QueryBox.cs
-src/Hyena/Hyena.Gui/Hyena.Query.Gui/QueryLimitBox.cs
-src/Hyena/Hyena.Gui/Hyena.Query.Gui/RelativeTimeSpanQueryValueEntry.cs
-src/Hyena/Hyena.Gui/Hyena.Query.Gui/TimeSpanQueryValueEntry.cs
-src/Hyena/Hyena.Gui/Hyena.Widgets/RatingMenuItem.cs
-src/Hyena/Hyena/Hyena.Query/DateQueryValue.cs
-src/Hyena/Hyena/Hyena.Query/EnumQueryValue.cs
-src/Hyena/Hyena/Hyena.Query/IntegerQueryValue.cs
-src/Hyena/Hyena/Hyena.Query/NullQueryValue.cs
-src/Hyena/Hyena/Hyena.Query/RelativeTimeSpanQueryValue.cs
-src/Hyena/Hyena/Hyena.Query/StringQueryValue.cs
-src/Hyena/Mono.Data.Sqlite/Mono.Data.Sqlite/SR.Designer.cs
diff --git a/src/Extensions/Banshee.AmazonMp3/Banshee.AmazonMp3.csproj b/src/Extensions/Banshee.AmazonMp3/Banshee.AmazonMp3.csproj
index 7dd383a..64b4c2f 100644
--- a/src/Extensions/Banshee.AmazonMp3/Banshee.AmazonMp3.csproj
+++ b/src/Extensions/Banshee.AmazonMp3/Banshee.AmazonMp3.csproj
@@ -63,12 +63,12 @@
<Folder Include="Banshee.AmazonMp3\" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Banshee.AmazonMp3\AmazonDownloadManager.cs" />
<Compile Include="Banshee.AmazonMp3\AmazonMp3DownloaderService.cs" />
<Compile Include="Banshee.AmazonMp3\AmzMp3Downloader.cs" />
<Compile Include="Banshee.AmazonMp3\AmzXspfPlaylist.cs" />
<Compile Include="Banshee.AmazonMp3\ConsoleTool.cs" />
<Compile Include="Banshee.AmazonMp3\ImportSource.cs" />
- <Compile Include="Banshee.AmazonMp3\UserJobDownloadManager.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
diff --git a/src/Extensions/Banshee.AmazonMp3/Banshee.AmazonMp3/UserJobDownloadManager.cs b/src/Extensions/Banshee.AmazonMp3/Banshee.AmazonMp3/AmazonDownloadManager.cs
similarity index 75%
rename from src/Extensions/Banshee.AmazonMp3/Banshee.AmazonMp3/UserJobDownloadManager.cs
rename to src/Extensions/Banshee.AmazonMp3/Banshee.AmazonMp3/AmazonDownloadManager.cs
index b1dfaf0..35f6bf2 100644
--- a/src/Extensions/Banshee.AmazonMp3/Banshee.AmazonMp3/UserJobDownloadManager.cs
+++ b/src/Extensions/Banshee.AmazonMp3/Banshee.AmazonMp3/AmazonDownloadManager.cs
@@ -1,5 +1,5 @@
//
-// UserJobDownloadManager.cs
+// AmazonDownloadManager.cs
//
// Author:
// Aaron Bockover <abockover novell com>
@@ -41,21 +41,18 @@ using Banshee.Base;
namespace Banshee.AmazonMp3
{
- public class UserJobDownloadManager : DownloadManager
+ public class AmazonDownloadManager : DownloadManager
{
- private UserJob user_job;
- private int total_count;
- private int finished_count;
+ private DownloadManagerJob job;
private LibraryImportManager import_manager;
private int mp3_count;
private List<TrackInfo> mp3_imported_tracks = new List<TrackInfo> ();
private Queue<AmzMp3Downloader> non_mp3_queue = new Queue<AmzMp3Downloader> ();
- public UserJobDownloadManager (string path)
+ public AmazonDownloadManager (string path)
{
var playlist = new AmzXspfPlaylist (path);
- total_count = playlist.DownloadableTrackCount;
foreach (var track in playlist.DownloadableTracks) {
var downloader = new AmzMp3Downloader (track);
if (downloader.FileExtension == "mp3") {
@@ -64,9 +61,13 @@ namespace Banshee.AmazonMp3
QueueDownloader (downloader);
}
- user_job = new UserJob (Catalog.GetString ("Amazon MP3 Purchases"),
- Catalog.GetString ("Contacting..."), "amazon-mp3-source");
- user_job.Register ();
+ job = new DownloadManagerJob (this) {
+ Title = Catalog.GetString ("Amazon MP3 Purchases"),
+ Status = Catalog.GetString ("Contacting..."),
+ IconNames = new string [] { "amazon-mp3-source" }
+ };
+
+ ServiceManager.Get<JobScheduler> ().Add (job);
import_manager = new LibraryImportManager (true) {
KeepUserJobHidden = true
@@ -155,41 +156,6 @@ namespace Banshee.AmazonMp3
Log.InformationFormat ("Starting to download \"{0}\" by {1}", track.Title, track.Creator);
}
- protected override void OnDownloaderProgress (HttpDownloader downloader)
- {
- lock (SyncRoot) {
- double weight = 1.0 / total_count;
- double progress = finished_count * weight;
- double speed = 0;
- int count = 0;
- foreach (var active_downloader in ActiveDownloaders) {
- progress += weight * active_downloader.State.PercentComplete;
- speed = active_downloader.State.TransferRate;
- count++;
- }
- user_job.Progress = progress;
-
- var human_speed = new Hyena.Query.FileSizeQueryValue ((long)Math.Round (speed)).ToUserQuery ();
- if (PendingDownloadCount == 0) {
- user_job.Status = String.Format (
- Catalog.GetPluralString (
- "{0} download at {1}/s",
- "{0} downloads at {1}/s",
- count),
- count, human_speed
- );
- } else {
- user_job.Status = String.Format (
- Catalog.GetPluralString (
- "{0} download at {1}/s ({2} pending)",
- "{0} downloads at {1}/s ({2} pending)",
- count),
- count, human_speed, PendingDownloadCount
- );
- }
- }
- }
-
protected override void OnDownloaderFinished (HttpDownloader downloader)
{
base.OnDownloaderFinished (downloader);
@@ -211,14 +177,6 @@ namespace Banshee.AmazonMp3
}
Log.InformationFormat ("Finished downloading \"{0}\" by {1}", track.Title, track.Creator);
-
- lock (SyncRoot) {
- finished_count++;
-
- if (TotalDownloadCount <= 0) {
- user_job.Finish ();
- }
- }
}
}
}
diff --git a/src/Extensions/Banshee.AmazonMp3/Makefile.am b/src/Extensions/Banshee.AmazonMp3/Makefile.am
index 16b6c08..66851e5 100644
--- a/src/Extensions/Banshee.AmazonMp3/Makefile.am
+++ b/src/Extensions/Banshee.AmazonMp3/Makefile.am
@@ -4,12 +4,12 @@ LINK = $(REF_EXTENSION_AMAZONMP3)
INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
SOURCES = \
+ Banshee.AmazonMp3/AmazonDownloadManager.cs \
Banshee.AmazonMp3/AmazonMp3DownloaderService.cs \
Banshee.AmazonMp3/AmzMp3Downloader.cs \
Banshee.AmazonMp3/AmzXspfPlaylist.cs \
Banshee.AmazonMp3/ConsoleTool.cs \
- Banshee.AmazonMp3/ImportSource.cs \
- Banshee.AmazonMp3/UserJobDownloadManager.cs
+ Banshee.AmazonMp3/ImportSource.cs
RESOURCES = Banshee.AmazonMp3.addin.xml
diff --git a/src/Hyena b/src/Hyena
index 9dd0936..8da3085 160000
--- a/src/Hyena
+++ b/src/Hyena
@@ -1 +1 @@
-Subproject commit 9dd093655d8084bf1fed69fd4e057b8407108cd1
+Subproject commit 8da3085bee4a5e6f395bf3f6bc51814691fd7806
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]