[banshee: 41/57] We only need to fallback to recursive browse on invalid cast exception in search (tells us server ha
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee: 41/57] We only need to fallback to recursive browse on invalid cast exception in search (tells us server ha
- Date: Mon, 13 Feb 2012 20:31:16 +0000 (UTC)
commit 45e0cdb5b6de96ab374a722fa602a174d3f47d48
Author: Tobias Arrskog <topfs2 xbmc org>
Date: Fri Jul 15 14:27:20 2011 +0200
We only need to fallback to recursive browse on invalid cast exception in search (tells us server has wrong implementation on search). All other exceptions should break search/recursive browse
.../Banshee.UPnPClient/UPnPServerSource.cs | 63 ++++++++++----------
1 files changed, 32 insertions(+), 31 deletions(-)
---
diff --git a/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPServerSource.cs b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPServerSource.cs
index 032c4d3..7ca0f41 100644
--- a/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPServerSource.cs
+++ b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPServerSource.cs
@@ -107,36 +107,37 @@ namespace Banshee.UPnPClient
Container root = remoteContentDirectory.GetRootObject();
bool recursiveBrowse = !contentDirectory.CanSearch;
- if (!recursiveBrowse) {
- try {
- Hyena.Log.Debug ("Searchable, lets search");
-
- HandleResults<MusicTrack> (remoteContentDirectory.Search<MusicTrack>(root, visitor => visitor.VisitDerivedFrom("upnp:class", "object.item.audioItem.musicTrack"), new ResultsSettings()),
- remoteContentDirectory,
- chunk => {
- List<MusicTrack> musicTracks = new List<MusicTrack>();
- foreach (var item in chunk)
- musicTracks.Add(item as MusicTrack);
-
- music_source.AddTracks (musicTracks);
- });
-
- HandleResults<VideoItem> (remoteContentDirectory.Search<VideoItem>(root, visitor => visitor.VisitDerivedFrom("upnp:class", "object.item.videoItem"), new ResultsSettings()),
- remoteContentDirectory,
- chunk => {
- List<VideoItem> videoTracks = new List<VideoItem>();
- foreach (var item in chunk)
- videoTracks.Add(item as VideoItem);
-
- video_source.AddTracks (videoTracks);
- });
- } catch (Exception exception) {
- Hyena.Log.Exception (exception);
- recursiveBrowse = true;
+ try {
+ if (!recursiveBrowse) {
+ try {
+ Hyena.Log.Debug ("Searchable, lets search");
+
+ HandleResults<MusicTrack> (remoteContentDirectory.Search<MusicTrack>(root, visitor => visitor.VisitDerivedFrom("upnp:class", "object.item.audioItem.musicTrack"), new ResultsSettings()),
+ remoteContentDirectory,
+ chunk => {
+ List<MusicTrack> musicTracks = new List<MusicTrack>();
+ foreach (var item in chunk)
+ musicTracks.Add(item as MusicTrack);
+
+ music_source.AddTracks (musicTracks);
+ });
+
+ HandleResults<VideoItem> (remoteContentDirectory.Search<VideoItem>(root, visitor => visitor.VisitDerivedFrom("upnp:class", "object.item.videoItem"), new ResultsSettings()),
+ remoteContentDirectory,
+ chunk => {
+ List<VideoItem> videoTracks = new List<VideoItem>();
+ foreach (var item in chunk)
+ videoTracks.Add(item as VideoItem);
+
+ video_source.AddTracks (videoTracks);
+ });
+ } catch (System.InvalidCastException exception) {
+ Hyena.Log.Exception (exception);
+ recursiveBrowse = true;
+ }
}
- }
- if (recursiveBrowse) {
- try {
+
+ if (recursiveBrowse) {
Hyena.Log.Debug ("Not searchable, lets recursive browse");
List<MusicTrack> musicTracks = new List<MusicTrack>();
List<VideoItem> videoTracks = new List<VideoItem>();
@@ -147,9 +148,9 @@ namespace Banshee.UPnPClient
music_source.AddTracks (musicTracks);
if (videoTracks.Count > 0)
video_source.AddTracks (videoTracks);
- } catch (Exception exception) {
- Hyena.Log.Exception (exception);
}
+ } catch (Exception exception) {
+ Hyena.Log.Exception (exception);
}
Hyena.Log.Debug ("Found all items on the service, took " + (DateTime.Now - begin).ToString());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]