banshee r4501 - in trunk/banshee: . data src/Backends/Banshee.Gnome/Banshee.GnomeBackend src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue src/Extensions/Banshee.Podcasting/Banshee.Podcasting src/Libraries/Migo/Migo.Syndication



Author: gburt
Date: Tue Sep  9 21:40:45 2008
New Revision: 4501
URL: http://svn.gnome.org/viewvc/banshee?rev=4501&view=rev

Log:
2008-09-09  Gabriel Burt  <gabriel burt gmail com>

	* src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs:
	Don't set the active source to the FSQ until it's done importing and
	actually imported something.  Prevents it from popping up when OPML files
	are passed in.

	* src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs:
	Fix copyright header, handle OPML files passed in on the command line (or
	by Firefox from the Miro Guide, say).

	* src/Backends/Banshee.Gnome/Banshee.GnomeBackend/DefaultApplicationHelper.cs:
	Refactor a bit.

	* src/Libraries/Migo/Migo.Syndication/OpmlParser.cs: Patch from Brandan
	Lloyd, cleaned up and modified slightly by me, for actually parsing feed
	URLs out of OPML files.

	* data/banshee-1.desktop.in.in:
	* data/mimetypes.txt: Add x-miro/x-democracy mimetypes.



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/data/banshee-1.desktop.in.in
   trunk/banshee/data/mimetypes.txt
   trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/DefaultApplicationHelper.cs
   trunk/banshee/src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs
   trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs
   trunk/banshee/src/Libraries/Migo/Migo.Syndication/OpmlParser.cs

Modified: trunk/banshee/data/banshee-1.desktop.in.in
==============================================================================
--- trunk/banshee/data/banshee-1.desktop.in.in	(original)
+++ trunk/banshee/data/banshee-1.desktop.in.in	Tue Sep  9 21:40:45 2008
@@ -13,4 +13,4 @@
 X-GNOME-Bugzilla-Product=banshee
 X-GNOME-Bugzilla-Component=General
 X-GNOME-Bugzilla-Version= VERSION@
-MimeType=application/musepack;application/ogg;application/ram;application/sdp;application/smil;application/vnd.rn-realmedia;application/x-ape;application/x-extension-m4a;application/x-extension-mp4;application/x-flac;application/x-flash-video;application/x-id3;application/x-matroska;application/x-musepack;application/x-netshow-channel;application/x-ogg;application/x-quicktime-media-link;application/x-quicktimeplayer;application/x-shorten;application/x-smil;application/x-troff-msvideo;application/xspf+xml;audio/3gpp;audio/AMR;audio/AMR-WB;audio/ac3;audio/ape;audio/avi;audio/basic;audio/flac;audio/midi;audio/mp;audio/mp3;audio/mp4;audio/mp4a-latm;audio/mpc;audio/mpeg;audio/mpeg3;audio/mpegurl;audio/musepack;audio/ogg;audio/vnd.rn-realaudio;audio/vorbis;audio/wav;audio/wave;audio/x-ape;audio/x-flac;audio/x-it;audio/x-m4a;audio/x-matroska;audio/x-mod;audio/x-mp;audio/x-mp3;audio/x-mpc;audio/x-mpeg;audio/x-mpeg-3;audio/x-mpegurl;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;audio/
 x-ms-wma;audio/x-musepack;audio/x-ogg;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;audio/x-pn-wav;audio/x-pn-windows-acm;audio/x-real-audio;audio/x-realaudio;audio/x-s3m;audio/x-sbc;audio/x-scpls;audio/x-speex;audio/x-tta;audio/x-vorbis;audio/x-vorbis+ogg;audio/x-wav;audio/x-wavpack;audio/x-xm;image/avi;image/vnd.rn-realpix;image/x-pict;misc/ultravox;text/google-video-pointer;text/x-google-video-pointer;video/3gpp;video/avi;video/dv;video/fli;video/flv;video/mp4;video/mp4v-es;video/mpeg;video/msvideo;video/quicktime;video/vivo;video/vnd.divx;video/vnd.rn-realvideo;video/vnd.vivo;video/x-anim;video/x-avi;video/x-flc;video/x-fli;video/x-flic;video/x-flv;video/x-m4v;video/x-matroska;video/x-mpeg;video/x-mpg;video/x-ms-asf;video/x-ms-wm;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvx;video/x-msvideo;video/x-nsv;video/x-ogm+ogg;video/x-theora+ogg;x-content/audio-cdda;x-content/audio-player;
+MimeType=application/musepack;application/ogg;application/ram;application/sdp;application/smil;application/vnd.rn-realmedia;application/x-ape;application/x-democracy;application/x-extension-m4a;application/x-extension-mp4;application/x-flac;application/x-flash-video;application/x-id3;application/x-matroska;application/x-miro;application/x-musepack;application/x-netshow-channel;application/x-ogg;application/x-quicktime-media-link;application/x-quicktimeplayer;application/x-shorten;application/x-smil;application/x-troff-msvideo;application/xspf+xml;audio/3gpp;audio/AMR;audio/AMR-WB;audio/ac3;audio/ape;audio/avi;audio/basic;audio/flac;audio/midi;audio/mp;audio/mp3;audio/mp4;audio/mp4a-latm;audio/mpc;audio/mpeg;audio/mpeg3;audio/mpegurl;audio/musepack;audio/ogg;audio/vnd.rn-realaudio;audio/vorbis;audio/wav;audio/wave;audio/x-ape;audio/x-flac;audio/x-it;audio/x-m4a;audio/x-matroska;audio/x-mod;audio/x-mp;audio/x-mp3;audio/x-mpc;audio/x-mpeg;audio/x-mpeg-3;audio/x-mpegurl;audio/x-
 ms-asf;audio/x-ms-asx;audio/x-ms-wax;audio/x-ms-wma;audio/x-musepack;audio/x-ogg;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;audio/x-pn-wav;audio/x-pn-windows-acm;audio/x-real-audio;audio/x-realaudio;audio/x-s3m;audio/x-sbc;audio/x-scpls;audio/x-speex;audio/x-tta;audio/x-vorbis;audio/x-vorbis+ogg;audio/x-wav;audio/x-wavpack;audio/x-xm;image/avi;image/vnd.rn-realpix;image/x-pict;misc/ultravox;text/google-video-pointer;text/x-google-video-pointer;video/3gpp;video/avi;video/dv;video/fli;video/flv;video/mp4;video/mp4v-es;video/mpeg;video/msvideo;video/ogg;video/quicktime;video/vivo;video/vnd.divx;video/vnd.rn-realvideo;video/vnd.vivo;video/x-anim;video/x-avi;video/x-flc;video/x-fli;video/x-flic;video/x-flv;video/x-m4v;video/x-matroska;video/x-mpeg;video/x-mpg;video/x-ms-asf;video/x-ms-wm;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvx;video/x-msvideo;video/x-nsv;video/x-ogm+ogg;video/x-theora;video/x-theora+ogg;x-content/audio-cdda;x-content/audio
 -player;

Modified: trunk/banshee/data/mimetypes.txt
==============================================================================
--- trunk/banshee/data/mimetypes.txt	(original)
+++ trunk/banshee/data/mimetypes.txt	Tue Sep  9 21:40:45 2008
@@ -1,4 +1,5 @@
 # Note: run perl mimetypes.pl to resort this list, remove duplicates, and generate a ; separated list suitable for the .desktop file
+#application/x-bittorrent
 #x-content/audio-dvd
 #x-content/video-blueray
 #x-content/video-dvd
@@ -12,12 +13,14 @@
 application/smil
 application/vnd.rn-realmedia
 application/x-ape
+application/x-democracy
 application/x-extension-m4a
 application/x-extension-mp4
 application/x-flac
 application/x-flash-video
 application/x-id3
 application/x-matroska
+application/x-miro
 application/x-musepack
 application/x-netshow-channel
 application/x-ogg
@@ -101,6 +104,7 @@
 video/mp4v-es
 video/mpeg
 video/msvideo
+video/ogg
 video/quicktime
 video/vivo
 video/vnd.divx
@@ -124,8 +128,7 @@
 video/x-msvideo
 video/x-nsv
 video/x-ogm+ogg
-video/x-theora+ogg
 video/x-theora
-video/ogg
+video/x-theora+ogg
 x-content/audio-cdda
 x-content/audio-player

Modified: trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/DefaultApplicationHelper.cs
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/DefaultApplicationHelper.cs	(original)
+++ trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/DefaultApplicationHelper.cs	Tue Sep  9 21:40:45 2008
@@ -72,10 +72,18 @@
             //Add ("/desktop/gnome/volume_manager", "autoplay_vcd_command", "{0} --device=%d");
             
             foreach (string uri_scheme in uri_schemes) {
-                Add (String.Format ("/desktop/gnome/url-handlers/{0}", uri_scheme), "command", "{0} \"%s\"");
-                Add (String.Format ("/desktop/gnome/url-handlers/{0}", uri_scheme), "enabled", true);
-                Add (String.Format ("/desktop/gnome/url-handlers/{0}", uri_scheme), "needs_terminal", false);
+                string ns = String.Format ("/desktop/gnome/url-handlers/{0}", uri_scheme);
+                Add (ns, "command", "{0} \"%s\"");
+                Add (ns, "enabled", true);
+                Add (ns, "needs_terminal", false);
             }
+
+            // TODO set us as handler in Firefox?
+            // browser.audioFeeds.handler.default = client
+            // browser.audioFeeds.handlers.application = /usr/local/bin/banshee-1
+            //
+            // browser.videoFeeds.handler.default = client
+            // browser.videoFeeds.handlers.application = /usr/local/bin/banshee-1
         }
 
         public bool IsDefault {

Modified: trunk/banshee/src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs	Tue Sep  9 21:40:45 2008
@@ -106,8 +106,6 @@
             }
         }
         
-        uint source_activate_id = 0;
-        
         public void Enqueue (string path)
         {
             lock (this) {
@@ -129,17 +127,17 @@
                             }
                         });
                     };
+
+                    importer.Finished += delegate {
+                        if (visible) {
+                            Banshee.Base.ThreadAssist.ProxyToMain (delegate {
+                                ServiceManager.SourceManager.SetActiveSource (this);
+                            });
+                        }
+                    };
                 }
             
                 importer.Enqueue (path);
-                
-                if (source_activate_id == 0) {
-                    source_activate_id = GLib.Timeout.Add (500, delegate {
-                        ServiceManager.SourceManager.SetActiveSource (this);
-                        source_activate_id = 0;
-                        return false;
-                    });
-                }
             }
         }
         

Modified: trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs	Tue Sep  9 21:40:45 2008
@@ -1,30 +1,32 @@
-/***************************************************************************
- *  PodcastService.cs
- *
- *  Copyright (C) 2008 Michael C. Urbanski
- *  Written by Mike Urbanski <michael c urbanski gmail com>
- ****************************************************************************/
-
-/*  THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: 
- *
- *  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.
- */
+//
+// PodcastService.cs
+//
+// Authors:
+//   Mike Urbanski <michael c urbanski gmail com>
+//   Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2008 Michael C. Urbanski
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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;
@@ -252,8 +254,17 @@
                 return;
             }
             
-            // Handle podcast URIs
-            if (uri.Contains ("xml") || uri.Contains ("rss") || uri.Contains ("feed") || uri.StartsWith ("itpc")) {
+            // Handle OPML files
+            if (uri.Contains ("opml") || uri.EndsWith (".miro") || uri.EndsWith (".democracy")) {
+                try {
+                    OpmlParser opml_parser = new OpmlParser (uri, true);
+                    foreach (string feed in opml_parser.Feeds) {
+                        ServiceManager.Get<DBusCommandService> ().PushFile (feed);
+                    }
+                } catch (Exception e) {
+                    Log.Exception (e);
+                }
+            } else if (uri.Contains ("xml") || uri.Contains ("rss") || uri.Contains ("feed") || uri.StartsWith ("itpc")) {
                 if (uri.StartsWith ("feed://") || uri.StartsWith ("itpc://")) {
                     uri = String.Format ("http://{0}";, uri.Substring (7));
                 }

Modified: trunk/banshee/src/Libraries/Migo/Migo.Syndication/OpmlParser.cs
==============================================================================
--- trunk/banshee/src/Libraries/Migo/Migo.Syndication/OpmlParser.cs	(original)
+++ trunk/banshee/src/Libraries/Migo/Migo.Syndication/OpmlParser.cs	Tue Sep  9 21:40:45 2008
@@ -3,8 +3,10 @@
 //
 // Authors:
 //   Gabriel Burt <gburt novell com>
+//   Brandan Lloyd
 //
 // Copyright (C) 2008 Novell, Inc.
+// Copyright (C) 2008 Brandan Lloyd
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -35,139 +37,54 @@
     public class OpmlParser
     {
         private XmlDocument doc;
-        //private XmlNamespaceManager ns_mgr;
-        
-        public OpmlParser (string url, string xml)
+        private System.Collections.Generic.List<string> feeds = null;
+
+        public OpmlParser (string xml, bool fromFile)
         {
             doc = new XmlDocument ();
             try {
-                doc.LoadXml (xml);
-                //ns_mgr = XmlUtils.GetNamespaceManager (doc);
+                if (fromFile) {
+                    doc.Load (xml);
+                } else {
+                    doc.LoadXml (xml);
+                }
             } catch (XmlException) {
-                throw new FormatException ("Invalid xml document.");                                  
+                throw new FormatException ("Invalid xml document.");
             }
             VerifyOpml ();
         }
-        
-        public OpmlParser (string url, XmlDocument doc)
-        {
-            this.doc = doc;
-            //ns_mgr = XmlUtils.GetNamespaceManager (doc);
-            VerifyOpml ();
-        }
-    
-        /*public Feed CreateFeed ()
-        {
-            return UpdateFeed (new Feed ());
-        }
-        
-        public Feed UpdateFeed (Feed feed)
-        {
-            try {
-                feed.Title            = XmlUtils.GetXmlNodeText (doc, "/rss/channel/title");
-                feed.Description      = XmlUtils.GetXmlNodeText (doc, "/rss/channel/description");
-                feed.Copyright        = XmlUtils.GetXmlNodeText (doc, "/rss/channel/copyright");
-                feed.ImageUrl         = XmlUtils.GetXmlNodeText (doc, "/rss/channel/itunes:image/@href", ns_mgr);
-                if (String.IsNullOrEmpty (feed.ImageUrl)) {
-                    feed.ImageUrl = XmlUtils.GetXmlNodeText (doc, "/rss/channel/image/url");
+
+        public IEnumerable<string> Feeds {
+            get {
+                if (null == feeds) {
+                    feeds = new List<string> ();
+                    GetFeeds (doc.SelectSingleNode ("/opml/body"));
                 }
-                feed.Interval         = XmlUtils.GetInt64 (doc, "/rss/channel/interval"); 
-                feed.Language         = XmlUtils.GetXmlNodeText (doc, "/rss/channel/language");
-                feed.LastBuildDate    = XmlUtils.GetRfc822DateTime (doc, "/rss/channel/lastBuildDate");
-                feed.Link             = XmlUtils.GetXmlNodeText (doc, "/rss/channel/link"); 
-                feed.PubDate          = XmlUtils.GetRfc822DateTime (doc, "/rss/channel/pubDate");
-                feed.Ttl              = XmlUtils.GetInt64 (doc, "/rss/channel/ttl");
-                feed.Keywords         = XmlUtils.GetXmlNodeText (doc, "/rss/channel/itunes:keywords", ns_mgr);
-                feed.Category         = XmlUtils.GetXmlNodeText (doc, "/rss/channel/itunes:category/@text", ns_mgr);
-                
-                return feed;
-            } catch (Exception e) {
-                 Hyena.Log.Exception (e);
+                return feeds;
             }
-             
-            return null;
         }
-        
-        public IEnumerable<FeedItem> GetFeedItems (Feed feed)
+
+        private void GetFeeds (XmlNode baseNode)
         {
-            XmlNodeList nodes = null;
-            try {
-                nodes = doc.SelectNodes ("//item");
-            } catch (Exception e) {
-                Hyena.Log.Exception (e);
-            }
-            
-            if (nodes != null) {
-                foreach (XmlNode node in nodes) {
-                    FeedItem item = null;
-                    
-                    try {
-                        item = ParseItem (node);
-                    } catch (Exception e) {
-                        Hyena.Log.Exception (e);
-                    }
-                    
-                    if (item != null) {
-                        item.Feed = feed;
-                        yield return item;
-                    }
+            XmlNodeList nodes = baseNode.SelectNodes ("./outline");
+            foreach (XmlNode node in nodes) {
+                if (node.Attributes["xmlUrl"] != null) {
+                    feeds.Add (node.Attributes["xmlUrl"].Value);
                 }
+
+                // Parse outline nodes recursively.
+                GetFeeds (node);
             }
         }
-        
-        public FeedItem ParseItem (XmlNode node)
-        {
-            try {
-                FeedItem item = new FeedItem ();
-                item.Description = XmlUtils.GetXmlNodeText (node, "description");                        
-                item.Title = XmlUtils.GetXmlNodeText (node, "title");                        
-            
-                if (String.IsNullOrEmpty (item.Description) && String.IsNullOrEmpty (item.Title)) {
-                    throw new FormatException ("node:  Either 'title' or 'description' node must exist.");
-                }
-                
-                item.Author            = XmlUtils.GetXmlNodeText (node, "author");
-                item.Comments          = XmlUtils.GetXmlNodeText (node, "comments");
-                item.Guid              = XmlUtils.GetXmlNodeText (node, "guid");
-                item.Link              = XmlUtils.GetXmlNodeText (node, "link");
-                item.Modified          = XmlUtils.GetRfc822DateTime (node, "dcterms:modified");
-                item.PubDate           = XmlUtils.GetRfc822DateTime (node, "pubDate");
-                
-                item.Enclosure = ParseEnclosure (node);
-                
-                return item;
-             } catch (Exception e) {
-                 Hyena.Log.Exception (e);
-             }
-             
-             return null;
-        }
-        
-        public FeedEnclosure ParseEnclosure (XmlNode node)
-        {
-            try {
-                FeedEnclosure enclosure = new FeedEnclosure ();
-                enclosure.Url = XmlUtils.GetXmlNodeText (node, "enclosure/@url");
-                enclosure.FileSize = Math.Max (0, XmlUtils.GetInt64 (node, "enclosure/@length"));
-                enclosure.MimeType = XmlUtils.GetXmlNodeText (node, "enclosure/@type");
-                enclosure.Duration = XmlUtils.GetItunesDuration (node, ns_mgr);
-                enclosure.Keywords = XmlUtils.GetXmlNodeText (node, "itunes:keywords", ns_mgr);
-                return enclosure;
-             } catch (Exception e) {
-                 Hyena.Log.Exception (e);
-             }
-             
-             return null;
-        }*/
-        
+
         private void VerifyOpml ()
-        {            
+        {
             if (doc.SelectSingleNode ("/opml") == null)
                 throw new FormatException ("Invalid OPML document.");
-                
+
             if (doc.SelectSingleNode ("/opml/head") == null)
                 throw new FormatException ("Invalid OPML document.");
-                
+
             if (doc.SelectSingleNode ("/opml/body") == null)
                 throw new FormatException ("Invalid OPML document.");
         }



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