[banshee: 42/57] Added code to possibly support path traversal quirks on missbehaving upnp servers in recursive brows



commit ba9b280e8315f48468e89305210bc95136fdbcb7
Author: Tobias Arrskog <topfs2 xbmc org>
Date:   Fri Jul 15 16:01:56 2011 +0200

    Added code to possibly support path traversal quirks on missbehaving upnp servers in recursive browse

 .../Banshee.UPnPClient/UPnPServerSource.cs         |   33 ++++++++++++++++++--
 1 files changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPServerSource.cs b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPServerSource.cs
index 7ca0f41..803da75 100644
--- a/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPServerSource.cs
+++ b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPServerSource.cs
@@ -75,7 +75,7 @@ namespace Banshee.UPnPClient
             AddChildSource (video_source);
 
             ThreadAssist.Spawn (delegate {
-                Parse (contentDirectory);
+                Parse (device, contentDirectory);
             });
             
         }
@@ -100,7 +100,14 @@ namespace Banshee.UPnPClient
             }
         }
 
-        void Parse (ContentDirectoryController contentDirectory)
+        List<string[]> FindBrowseQuirks (Device device)
+        {
+            List<string[]> core = new List<string[]>();
+            core.Add(new string[0]);
+            return core;
+        }
+
+        void Parse (Device device, ContentDirectoryController contentDirectory)
         {
             RemoteContentDirectory remoteContentDirectory = new RemoteContentDirectory (contentDirectory);
             DateTime begin = DateTime.Now;
@@ -142,7 +149,9 @@ namespace Banshee.UPnPClient
                     List<MusicTrack> musicTracks = new List<MusicTrack>();
                     List<VideoItem> videoTracks = new List<VideoItem>();
 
-                    ParseContainer (remoteContentDirectory, root, 0, musicTracks, videoTracks);
+                    foreach (var hierarchy in FindBrowseQuirks(device)) {
+                        TraverseContainer(remoteContentDirectory, root, hierarchy, 0, musicTracks, videoTracks);
+                    }
 
                     if (musicTracks.Count > 0)
                         music_source.AddTracks (musicTracks);
@@ -156,6 +165,24 @@ namespace Banshee.UPnPClient
             Hyena.Log.Debug ("Found all items on the service, took " + (DateTime.Now - begin).ToString());
         }
 
+        void TraverseContainer (RemoteContentDirectory remoteContentDirectory, Container container, string[] hierarchy, int position, List<MusicTrack> musicTracks, List<VideoItem> videoTracks)
+        {
+            if (hierarchy != null && hierarchy.Length > position) {
+                HandleResults<Mono.Upnp.Dcp.MediaServer1.ContentDirectory1.Object> (
+                                           remoteContentDirectory.GetChildren<Mono.Upnp.Dcp.MediaServer1.ContentDirectory1.Object>(container),
+                                           remoteContentDirectory,
+                                           chunk => {
+                                                        foreach (var upnp_object in chunk) {
+                                                            if (upnp_object is Container && upnp_object.Title == hierarchy[position]) {
+                                                                TraverseContainer (remoteContentDirectory, upnp_object as Container, hierarchy, position + 1, musicTracks, videoTracks);
+                                                            }
+                                                        }
+                                                    });
+            } else {
+                ParseContainer (remoteContentDirectory, container, 0, musicTracks, videoTracks);
+            }
+        }
+
         void ParseContainer (RemoteContentDirectory remoteContentDirectory, Container container, int depth, List<MusicTrack> musicTracks, List<VideoItem> videoTracks)
         {
             if (depth > 10 || (container.ChildCount != null && container.ChildCount == 0))



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