Skip to content
This repository
Browse code

jsonrpc: ensure that "label" always contains at least the filename of…

… a playing item
  • Loading branch information...
commit db911a5f88ef054840b3dc3b98bf342845361506 1 parent 80bb9b9
Sascha Montellese authored July 15, 2013
54  xbmc/interfaces/json-rpc/AudioLibrary.cpp
@@ -555,35 +555,39 @@ JSONRPC_STATUS CAudioLibrary::Clean(const CStdString &method, ITransportLayer *t
555 555
 bool CAudioLibrary::FillFileItem(const CStdString &strFilename, CFileItemPtr &item, const CVariant &parameterObject /* = CVariant(CVariant::VariantTypeArray) */)
556 556
 {
557 557
   CMusicDatabase musicdatabase;
558  
-  if (strFilename.empty() || !musicdatabase.Open())
  558
+  if (strFilename.empty())
559 559
     return false;
560 560
 
561  
-  if (CDirectory::Exists(strFilename))
  561
+  bool filled = false;
  562
+  if (musicdatabase.Open())
562 563
   {
563  
-    CAlbum album;
564  
-    int albumid = musicdatabase.GetAlbumIdByPath(strFilename);
565  
-    if (!musicdatabase.GetAlbumInfo(albumid, album, NULL))
566  
-      return false;
567  
-
568  
-    item->SetFromAlbum(album);
569  
-
570  
-    CFileItemList items;
571  
-    items.Add(item);
572  
-    if (GetAdditionalAlbumDetails(parameterObject, items, musicdatabase) != OK)
573  
-      return false;
574  
-  }
575  
-  else
576  
-  {
577  
-    CSong song;
578  
-    if (!musicdatabase.GetSongByFileName(strFilename, song))
579  
-      return false;
  564
+    if (CDirectory::Exists(strFilename))
  565
+    {
  566
+      CAlbum album;
  567
+      int albumid = musicdatabase.GetAlbumIdByPath(strFilename);
  568
+      if (musicdatabase.GetAlbumInfo(albumid, album, NULL))
  569
+      {
  570
+        item->SetFromAlbum(album);
580 571
 
581  
-    item->SetFromSong(song);
  572
+        CFileItemList items;
  573
+        items.Add(item);
  574
+        if (GetAdditionalAlbumDetails(parameterObject, items, musicdatabase) == OK)
  575
+          filled = true;
  576
+      }
  577
+    }
  578
+    else
  579
+    {
  580
+      CSong song;
  581
+      if (musicdatabase.GetSongByFileName(strFilename, song))
  582
+      {
  583
+        item->SetFromSong(song);
582 584
 
583  
-    CFileItemList items;
584  
-    items.Add(item);
585  
-    if (GetAdditionalSongDetails(parameterObject, items, musicdatabase) != OK)
586  
-      return false;
  585
+        CFileItemList items;
  586
+        items.Add(item);
  587
+        if (GetAdditionalSongDetails(parameterObject, items, musicdatabase) == OK)
  588
+          filled = true;
  589
+      }
  590
+    }
587 591
   }
588 592
 
589 593
   if (item->GetLabel().empty())
@@ -593,7 +597,7 @@ bool CAudioLibrary::FillFileItem(const CStdString &strFilename, CFileItemPtr &it
593 597
       item->SetLabel(URIUtils::GetFileName(strFilename));
594 598
   }
595 599
 
596  
-  return true;
  600
+  return filled;
597 601
 }
598 602
 
599 603
 bool CAudioLibrary::FillFileItemList(const CVariant &parameterObject, CFileItemList &list)
6  xbmc/interfaces/json-rpc/FileItemHandler.cpp
@@ -389,8 +389,12 @@ bool CFileItemHandler::FillFileItemList(const CVariant &parameterObject, CFileIt
389 389
         picture.Load(item->GetPath());
390 390
         *item->GetPictureInfoTag() = picture;
391 391
       }
392  
-      if (item->GetLabel().IsEmpty())
  392
+      if (item->GetLabel().empty())
  393
+      {
393 394
         item->SetLabel(CUtil::GetTitleFromPath(file, false));
  395
+        if (item->GetLabel().empty())
  396
+          item->SetLabel(URIUtils::GetFileName(file));
  397
+      }
394 398
       list.Add(item);
395 399
     }
396 400
   }
12  xbmc/interfaces/json-rpc/PlayerOperations.cpp
@@ -123,7 +123,12 @@ JSONRPC_STATUS CPlayerOperations::GetItem(const CStdString &method, ITransportLa
123 123
         {
124 124
           const CVideoInfoTag *currentVideoTag = g_infoManager.GetCurrentMovieTag();
125 125
           if (currentVideoTag != NULL)
126  
-            fileItem = CFileItemPtr(new CFileItem(*currentVideoTag));
  126
+          {
  127
+            CStdString originalLabel = fileItem->GetLabel();
  128
+            fileItem->SetFromVideoInfoTag(*currentVideoTag);
  129
+            if (fileItem->GetLabel().empty())
  130
+              fileItem->SetLabel(originalLabel);
  131
+          }
127 132
           fileItem->SetPath(g_application.CurrentFileItem().GetPath());
128 133
         }
129 134
       }
@@ -133,7 +138,12 @@ JSONRPC_STATUS CPlayerOperations::GetItem(const CStdString &method, ITransportLa
133 138
         {
134 139
           const MUSIC_INFO::CMusicInfoTag *currentMusicTag = g_infoManager.GetCurrentSongTag();
135 140
           if (currentMusicTag != NULL)
  141
+          {
  142
+            CStdString originalLabel = fileItem->GetLabel();
136 143
             fileItem = CFileItemPtr(new CFileItem(*currentMusicTag));
  144
+            if (fileItem->GetLabel().empty())
  145
+              fileItem->SetLabel(originalLabel);
  146
+          }
137 147
           fileItem->SetPath(g_application.CurrentFileItem().GetPath());
138 148
         }
139 149
       }
21  xbmc/interfaces/json-rpc/VideoLibrary.cpp
@@ -691,21 +691,28 @@ JSONRPC_STATUS CVideoLibrary::Clean(const CStdString &method, ITransportLayer *t
691 691
 bool CVideoLibrary::FillFileItem(const CStdString &strFilename, CFileItemPtr &item, const CVariant &parameterObject /* = CVariant(CVariant::VariantTypeArray) */)
692 692
 {
693 693
   CVideoDatabase videodatabase;
694  
-  if (strFilename.empty() || !videodatabase.Open())
695  
-    return false;
696  
-
697  
-  CVideoInfoTag details;
698  
-  if (!videodatabase.LoadVideoInfo(strFilename, details))
  694
+  if (strFilename.empty())
699 695
     return false;
  696
+  
  697
+  bool filled = false;
  698
+  if (videodatabase.Open())
  699
+  {
  700
+    CVideoInfoTag details;
  701
+    if (videodatabase.LoadVideoInfo(strFilename, details))
  702
+    {
  703
+      item->SetFromVideoInfoTag(details);
  704
+      filled = true;
  705
+    }
  706
+  }
700 707
 
701  
-  item->SetFromVideoInfoTag(details);
702 708
   if (item->GetLabel().empty())
703 709
   {
704 710
     item->SetLabel(CUtil::GetTitleFromPath(strFilename, false));
705 711
     if (item->GetLabel().empty())
706 712
       item->SetLabel(URIUtils::GetFileName(strFilename));
707 713
   }
708  
-  return true;
  714
+
  715
+  return filled;
709 716
 }
710 717
 
711 718
 bool CVideoLibrary::FillFileItemList(const CVariant &parameterObject, CFileItemList &list)

0 notes on commit db911a5

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