Skip to content
This repository
Browse code

Merge pull request #2829 from alcoheca/shoddy_parenting

Shoddy parenting
  • Loading branch information...
commit ed580ff1349024a59bcc4ca7e7888c5d66351617 2 parents 25e3e3e + f062efd
Joakim Plate authored July 23, 2013

Showing 1 changed file with 25 additions and 14 deletions. Show diff stats Hide diff stats

  1. 39  xbmc/network/upnp/UPnPServer.cpp
39  xbmc/network/upnp/UPnPServer.cpp
@@ -299,7 +299,7 @@ CUPnPServer::Build(CFileItemPtr                  item,
299 299
                 }
300 300
             }
301 301
         } else if (file_path.StartsWith("library://") || file_path.StartsWith("videodb://")) {
302  
-            if (path == "library://video" ) {
  302
+            if (path == "library://video/" ) {
303 303
                 item->SetLabel("Video Library");
304 304
                 item->SetLabelPreformated(true);
305 305
             } else {
@@ -455,7 +455,7 @@ static NPT_String TranslateWMPObjectId(NPT_String id)
455 455
         id = "virtualpath://upnproot/";
456 456
     } else if (id == "15") {
457 457
         // Xbox 360 asking for videos
458  
-        id = "library://video";
  458
+        id = "library://video/";
459 459
     } else if (id == "16") {
460 460
         // Xbox 360 asking for photos
461 461
     } else if (id == "107") {
@@ -500,7 +500,6 @@ CUPnPServer::OnBrowseMetadata(PLT_ActionReference&          action,
500 500
     NPT_String                     didl;
501 501
     NPT_Reference<PLT_MediaObject> object;
502 502
     NPT_String                     id = TranslateWMPObjectId(object_id);
503  
-    vector<CStdString>             paths;
504 503
     CFileItemPtr                   item;
505 504
     NPT_Reference<CThumbLoader>    thumb_loader;
506 505
 
@@ -527,16 +526,28 @@ CUPnPServer::OnBrowseMetadata(PLT_ActionReference&          action,
527 526
         // determine if it's a container by calling CDirectory::Exists
528 527
         item.reset(new CFileItem((const char*)id, CDirectory::Exists((const char*)id)));
529 528
 
530  
-        // determine parent id for shared paths only
531  
-        // otherwise let db find out
  529
+        // attempt to determine the parent of this item
532 530
         CStdString parent;
533  
-        if (!URIUtils::GetParentPath((const char*)id, parent)) parent = "0";
534  
-
535  
-//#ifdef WMP_ID_MAPPING
536  
-//        if (!id.StartsWith("musicdb://") && !id.StartsWith("videodb://")) {
537  
-//            parent = "";
538  
-//        }
539  
-//#endif
  531
+        if (URIUtils::IsVideoDb((const char*)id) || URIUtils::IsMusicDb((const char*)id) || StringUtils::StartsWith((const char*)id, "library://video/")) {
  532
+            if (!URIUtils::GetParentPath((const char*)id, parent)) {
  533
+                parent = "0";
  534
+            }
  535
+        }
  536
+        else {
  537
+            // non-library objects - playlists / sources
  538
+            //
  539
+            // we could instead store the parents in a hash during every browse
  540
+            // or could handle this in URIUtils::GetParentPath() possibly,
  541
+            // however this is quicker to implement and subsequently purge when a
  542
+            // better solution presents itself
  543
+            CStdString child_id((const char*)id);
  544
+            if      (StringUtils::StartsWith(child_id, "special://musicplaylists/"))          parent = "musicdb://";
  545
+            else if (StringUtils::StartsWith(child_id, "special://videoplaylists/"))          parent = "library://video/";
  546
+            else if (StringUtils::StartsWith(child_id, "sources://video/"))                   parent = "library://video/";
  547
+            else if (StringUtils::StartsWith(child_id, "special://profile/playlists/music/")) parent = "special://musicplaylists/";
  548
+            else if (StringUtils::StartsWith(child_id, "special://profile/playlists/video/")) parent = "special://videoplaylists/";
  549
+            else parent = "sources://video/"; // this can only match video sources
  550
+        }
540 551
 
541 552
         if (item->IsVideoDb()) {
542 553
             thumb_loader = NPT_Reference<CThumbLoader>(new CVideoThumbLoader());
@@ -620,7 +631,7 @@ CUPnPServer::OnBrowseDirectChildren(PLT_ActionReference&          action,
620 631
             items.Add(item);
621 632
 
622 633
             // video library
623  
-            item.reset(new CFileItem("library://video", true));
  634
+            item.reset(new CFileItem("library://video/", true));
624 635
             item->SetLabel("Video Library");
625 636
             item->SetLabelPreformated(true);
626 637
             items.Add(item);
@@ -699,7 +710,7 @@ CUPnPServer::BuildResponse(PLT_ActionReference&          action,
699 710
     NPT_Reference<CThumbLoader> thumb_loader;
700 711
 
701 712
     if (URIUtils::IsVideoDb(items.GetPath()) ||
702  
-        StringUtils::StartsWith(items.GetPath(), "library://video") ||
  713
+        StringUtils::StartsWith(items.GetPath(), "library://video/") ||
703 714
         StringUtils::StartsWith(items.GetPath(), "special://profile/playlists/video/")) {
704 715
 
705 716
         thumb_loader = NPT_Reference<CThumbLoader>(new CVideoThumbLoader());

0 notes on commit ed580ff

Please sign in to comment.
Something went wrong with that request. Please try again.