banshee r4366 - in trunk/banshee: . src/Libraries/Migo/Migo.DownloadCore src/Libraries/Migo/Migo.Syndication
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4366 - in trunk/banshee: . src/Libraries/Migo/Migo.DownloadCore src/Libraries/Migo/Migo.Syndication
- Date: Wed, 13 Aug 2008 15:21:59 +0000 (UTC)
Author: gburt
Date: Wed Aug 13 15:21:59 2008
New Revision: 4366
URL: http://svn.gnome.org/viewvc/banshee?rev=4366&view=rev
Log:
2008-08-13 Gabriel Burt <gabriel burt gmail com>
Patch from Alan McGovern laying the groundwork for torrent support in Migo.
* src/Libraries/Migo/Migo.DownloadCore/DownloadManager.cs: Add support for
other types of DownloadTasks.
* src/Libraries/Migo/Migo.Syndication/FeedEnclosure.cs: Strip the trailing
.torrent extension for the file name.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Libraries/Migo/Migo.DownloadCore/DownloadManager.cs
trunk/banshee/src/Libraries/Migo/Migo.Syndication/FeedEnclosure.cs
Modified: trunk/banshee/src/Libraries/Migo/Migo.DownloadCore/DownloadManager.cs
==============================================================================
--- trunk/banshee/src/Libraries/Migo/Migo.DownloadCore/DownloadManager.cs (original)
+++ trunk/banshee/src/Libraries/Migo/Migo.DownloadCore/DownloadManager.cs Wed Aug 13 15:21:59 2008
@@ -44,6 +44,20 @@
{
public class DownloadManager : IDisposable
{
+ private static Dictionary<string, Type> downloader_types;
+
+ static DownloadManager () {
+ downloader_types = new Dictionary<string,Type> (StringComparer.OrdinalIgnoreCase);
+ }
+
+ public static void Register (string fileType, Type type)
+ {
+ lock (downloader_types) {
+ downloader_types.Add (fileType, type);
+ }
+ }
+
+
private bool disposed;
private string tmpDir;
@@ -124,12 +138,17 @@
.Replace ("-", String.Empty)
.ToLower ();
- HttpFileDownloadTask task = new HttpFileDownloadTask (
- url, tmpDir + urlHash + Path.DirectorySeparatorChar +
- System.Web.HttpUtility.UrlDecode (fileName),
- userState
- );
+ string remoteUri = url;
+ string localPath = tmpDir + urlHash + Path.DirectorySeparatorChar + System.Web.HttpUtility.UrlDecode (fileName);
+ HttpFileDownloadTask task = null;
+ string [] parts = fileName.Split ('.');
+ if (parts.Length > 0 && downloader_types.ContainsKey (parts[parts.Length - 1])) {
+ task = (HttpFileDownloadTask) Activator.CreateInstance (downloader_types[parts[parts.Length - 1]], remoteUri, localPath, userState);
+ } else {
+ task = new HttpFileDownloadTask (url , localPath, userState );
+ }
+
return task;
}
Modified: trunk/banshee/src/Libraries/Migo/Migo.Syndication/FeedEnclosure.cs
==============================================================================
--- trunk/banshee/src/Libraries/Migo/Migo.Syndication/FeedEnclosure.cs (original)
+++ trunk/banshee/src/Libraries/Migo/Migo.Syndication/FeedEnclosure.cs Wed Aug 13 15:21:59 2008
@@ -153,6 +153,9 @@
public void SetFileImpl (string url, string path, string mimeType, string filename)
{
+ if (filename.EndsWith (".torrent", StringComparison.OrdinalIgnoreCase)) {
+ filename = filename.Substring(0, filename.Length - 8);
+ }
string tmpLocalPath;
string fullPath = path;
string localEnclosurePath = Item.Feed.LocalEnclosurePath;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]