aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Morten Kvarving <spiff@kodi.tv>2024-02-11 00:59:50 +0100
committerArne Morten Kvarving <spiff@kodi.tv>2024-05-05 21:44:02 +0200
commit2cc38c11e5526ab483bdd42afce2633afb6df6e5 (patch)
tree500017aa94ad18f14689348c96657db2ee313fbe
parent94facd42ad002375667e4c6f0787fac7869437ec (diff)
downloadxbmc-2cc38c11e5526ab483bdd42afce2633afb6df6e5.tar.xz
move CFileItem::IsRemote to NetworkFileItemClassify
-rw-r--r--xbmc/FileItem.cpp41
-rw-r--r--xbmc/FileItem.h1
-rw-r--r--xbmc/FileItemList.cpp3
-rw-r--r--xbmc/cdrip/CDDARipJob.cpp6
-rw-r--r--xbmc/cores/VideoPlayer/VideoPlayer.cpp5
-rw-r--r--xbmc/cores/playercorefactory/PlayerSelectionRule.cpp2
-rw-r--r--xbmc/filesystem/SourcesDirectory.cpp3
-rw-r--r--xbmc/network/NetworkFileItemClassify.cpp5
-rw-r--r--xbmc/network/NetworkFileItemClassify.h3
-rw-r--r--xbmc/network/test/TestNetworkFileItemClassify.cpp33
10 files changed, 73 insertions, 29 deletions
diff --git a/xbmc/FileItem.cpp b/xbmc/FileItem.cpp
index 03115ac8ef..6798314241 100644
--- a/xbmc/FileItem.cpp
+++ b/xbmc/FileItem.cpp
@@ -68,7 +68,6 @@
#include <memory>
using namespace KODI;
-using namespace KODI::VIDEO;
using namespace XFILE;
using namespace PLAYLIST;
using namespace MUSIC_INFO;
@@ -847,7 +846,7 @@ bool CFileItem::Exists(bool bUseCache /* = true */) const
IsVirtualDirectoryRoot() || IsPlugin() || IsPVR())
return true;
- if (IsVideoDb(*this) && HasVideoInfoTag())
+ if (VIDEO::IsVideoDb(*this) && HasVideoInfoTag())
{
CFileItem dbItem(m_bIsFolder ? GetVideoInfoTag()->m_strPath : GetVideoInfoTag()->m_strFileNameAndPath, m_bIsFolder);
return dbItem.Exists();
@@ -1054,10 +1053,10 @@ bool CFileItem::IsDiscImage() const
bool CFileItem::IsOpticalMediaFile() const
{
- if (IsDVDFile(*this, false, true))
+ if (VIDEO::IsDVDFile(*this, false, true))
return true;
- return IsBDFile(*this);
+ return VIDEO::IsBDFile(*this);
}
bool CFileItem::IsRAR() const
@@ -1139,7 +1138,7 @@ bool CFileItem::IsBluray() const
CFileItem item = CFileItem(VIDEO::UTILS::GetOpticalMediaPath(*this), false);
- return IsBDFile(item);
+ return VIDEO::IsBDFile(item);
}
bool CFileItem::IsDVD() const
@@ -1167,11 +1166,6 @@ bool CFileItem::IsISO9660() const
return URIUtils::IsISO9660(m_strPath);
}
-bool CFileItem::IsRemote() const
-{
- return URIUtils::IsRemote(m_strPath);
-}
-
bool CFileItem::IsSmb() const
{
return URIUtils::IsSmb(m_strPath);
@@ -1280,7 +1274,7 @@ void CFileItem::FillInDefaultIcon()
// audio
SetArt("icon", "DefaultAudio.png");
}
- else if (IsVideo(*this))
+ else if (VIDEO::IsVideo(*this))
{
// video
SetArt("icon", "DefaultVideo.png");
@@ -1474,7 +1468,7 @@ bool CFileItem::IsSamePath(const CFileItem *item) const
if (item->HasProperty("item_start") || HasProperty("item_start"))
return (item->GetProperty("item_start") == GetProperty("item_start"));
// See if we have associated a bluray playlist
- if (IsBlurayPlaylist(*this) || IsBlurayPlaylist(*item))
+ if (VIDEO::IsBlurayPlaylist(*this) || VIDEO::IsBlurayPlaylist(*item))
return (GetDynPath() == item->GetDynPath());
return true;
}
@@ -1507,7 +1501,7 @@ bool CFileItem::IsSamePath(const CFileItem *item) const
dbItem.SetProperty("item_start", GetProperty("item_start"));
return dbItem.IsSamePath(item);
}
- if (IsVideoDb(*this) && HasVideoInfoTag())
+ if (VIDEO::IsVideoDb(*this) && HasVideoInfoTag())
{
CFileItem dbItem(GetVideoInfoTag()->m_strFileNameAndPath, false);
if (HasProperty("item_start"))
@@ -1521,7 +1515,7 @@ bool CFileItem::IsSamePath(const CFileItem *item) const
dbItem.SetProperty("item_start", item->GetProperty("item_start"));
return IsSamePath(&dbItem);
}
- if (IsVideoDb(*item) && item->HasVideoInfoTag())
+ if (VIDEO::IsVideoDb(*item) && item->HasVideoInfoTag())
{
CFileItem dbItem(item->GetVideoInfoTag()->m_strFileNameAndPath, false);
if (item->HasProperty("item_start"))
@@ -1672,7 +1666,7 @@ void CFileItem::MergeInfo(const CFileItem& item)
SetLabel2(item.GetLabel2());
if (!item.GetArt().empty())
{
- if (IsVideo(item))
+ if (VIDEO::IsVideo(item))
AppendArt(item.GetArt());
else
SetArt(item.GetArt());
@@ -1877,7 +1871,7 @@ void CFileItem::SetDynPath(const std::string &path)
std::string CFileItem::GetBlurayPath() const
{
- if (IsBlurayPlaylist(*this))
+ if (VIDEO::IsBlurayPlaylist(*this))
{
CURL url(GetDynPath());
CURL url2(url.GetHostName()); // strip bluray://
@@ -2011,7 +2005,10 @@ std::string CFileItem::GetUserMusicThumb(bool alwaysCheckRemote /* = false */, b
}
// if a folder, check for folder.jpg
- if (m_bIsFolder && !IsFileFolder() && (!IsRemote() || alwaysCheckRemote || CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_MUSICFILES_FINDREMOTETHUMBS)))
+ if (m_bIsFolder && !IsFileFolder() &&
+ (!NETWORK::IsRemote(*this) || alwaysCheckRemote ||
+ CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(
+ CSettings::SETTING_MUSICFILES_FINDREMOTETHUMBS)))
{
std::vector<CVariant> thumbs = CServiceBroker::GetSettingsComponent()->GetSettings()->GetList(
CSettings::SETTING_MUSICLIBRARY_MUSICTHUMBS);
@@ -2308,7 +2305,7 @@ std::string CFileItem::GetBaseMoviePath(bool bUseFolderNames) const
std::string CFileItem::GetLocalFanart() const
{
- if (IsVideoDb(*this))
+ if (VIDEO::IsVideoDb(*this))
{
if (!HasVideoInfoTag())
return ""; // nothing can be done
@@ -2390,7 +2387,7 @@ std::string CFileItem::GetLocalMetadataPath() const
return m_strPath;
std::string parent{};
- if (IsBlurayPlaylist(*this))
+ if (VIDEO::IsBlurayPlaylist(*this))
parent = URIUtils::GetParentPath(GetBlurayPath());
else
parent = URIUtils::GetParentPath(m_strPath);
@@ -2482,7 +2479,7 @@ bool CFileItem::LoadGameTag()
bool CFileItem::LoadDetails()
{
- if (IsVideoDb(*this))
+ if (VIDEO::IsVideoDb(*this))
{
if (HasVideoInfoTag())
return true;
@@ -2542,7 +2539,7 @@ bool CFileItem::LoadDetails()
return false;
}
- if (!IsPlayList() && IsVideo(*this))
+ if (!IsPlayList() && VIDEO::IsVideo(*this))
{
if (HasVideoInfoTag())
return true;
@@ -2574,7 +2571,7 @@ bool CFileItem::LoadDetails()
if (playlist->Load(GetPath()) && playlist->size() == 1)
{
const auto item{(*playlist)[0]};
- if (IsVideo(*item))
+ if (VIDEO::IsVideo(*item))
{
CVideoDatabase db;
if (!db.Open())
diff --git a/xbmc/FileItem.h b/xbmc/FileItem.h
index 99791f5238..365d5adea0 100644
--- a/xbmc/FileItem.h
+++ b/xbmc/FileItem.h
@@ -195,7 +195,6 @@ public:
bool IsOnLAN() const;
bool IsHD() const;
bool IsNfs() const;
- bool IsRemote() const;
bool IsSmb() const;
bool IsURL() const;
bool IsStack() const;
diff --git a/xbmc/FileItemList.cpp b/xbmc/FileItemList.cpp
index de52c4d9b8..e14b9a6c61 100644
--- a/xbmc/FileItemList.cpp
+++ b/xbmc/FileItemList.cpp
@@ -17,6 +17,7 @@
#include "filesystem/StackDirectory.h"
#include "filesystem/VideoDatabaseDirectory.h"
#include "music/MusicFileItemClassify.h"
+#include "network/NetworkFileItemClassify.h"
#include "settings/AdvancedSettings.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
@@ -758,7 +759,7 @@ void CFileItemList::StackFolders()
// only check known fast sources?
// NOTES:
// 1. rars and zips may be on slow sources? is this supposed to be allowed?
- if (!item->IsRemote() || item->IsSmb() || item->IsNfs() ||
+ if (!NETWORK::IsRemote(*item) || item->IsSmb() || item->IsNfs() ||
URIUtils::IsInRAR(item->GetPath()) || URIUtils::IsInZIP(item->GetPath()) ||
URIUtils::IsOnLAN(item->GetPath()))
{
diff --git a/xbmc/cdrip/CDDARipJob.cpp b/xbmc/cdrip/CDDARipJob.cpp
index 61726a5c42..3063a91e65 100644
--- a/xbmc/cdrip/CDDARipJob.cpp
+++ b/xbmc/cdrip/CDDARipJob.cpp
@@ -22,6 +22,7 @@
#include "guilib/GUIComponent.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/LocalizeStrings.h"
+#include "network/NetworkFileItemClassify.h"
#include "settings/AdvancedSettings.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
@@ -37,6 +38,7 @@
using namespace ADDON;
using namespace MUSIC_INFO;
using namespace XFILE;
+using namespace KODI;
using namespace KODI::CDRIP;
CCDDARipJob::CCDDARipJob(const std::string& input,
@@ -66,7 +68,7 @@ bool CCDDARipJob::DoWork()
// if we are ripping to a samba share, rip it to hd first and then copy it to the share
CFileItem file(m_output, false);
- if (file.IsRemote())
+ if (NETWORK::IsRemote(file))
m_output = SetupTempFile();
if (m_output.empty())
@@ -115,7 +117,7 @@ bool CCDDARipJob::DoWork()
encoder.reset();
reader.Close();
- if (file.IsRemote() && !cancelled && result == 2)
+ if (NETWORK::IsRemote(file) && !cancelled && result == 2)
{
// copy the ripped track to the share
if (!CFile::Copy(m_output, file.GetPath()))
diff --git a/xbmc/cores/VideoPlayer/VideoPlayer.cpp b/xbmc/cores/VideoPlayer/VideoPlayer.cpp
index b43fe8c622..78e9cc3cdc 100644
--- a/xbmc/cores/VideoPlayer/VideoPlayer.cpp
+++ b/xbmc/cores/VideoPlayer/VideoPlayer.cpp
@@ -17,6 +17,7 @@
#include "DVDDemuxers/DVDFactoryDemuxer.h"
#include "DVDInputStreams/DVDFactoryInputStream.h"
#include "DVDInputStreams/DVDInputStream.h"
+#include "network/NetworkFileItemClassify.h"
#if defined(HAVE_LIBBLURAY)
#include "DVDInputStreams/DVDInputStreamBluray.h"
#endif
@@ -46,6 +47,7 @@
#include "input/actions/Action.h"
#include "input/actions/ActionIDs.h"
#include "messaging/ApplicationMessenger.h"
+#include "network/NetworkFileItemClassify.h"
#include "settings/AdvancedSettings.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
@@ -68,6 +70,7 @@
#include <mutex>
#include <utility>
+using namespace KODI;
using namespace std::chrono_literals;
//------------------------------------------------------------------------------
@@ -999,7 +1002,7 @@ void CVideoPlayer::OpenDefaultStreams(bool reset)
CloseStream(m_CurrentAudioID3, false);
// disable demux streams
- if (m_item.IsRemote() && m_pDemuxer)
+ if (NETWORK::IsRemote(m_item) && m_pDemuxer)
{
for (auto &stream : m_SelectionStreams.m_Streams)
{
diff --git a/xbmc/cores/playercorefactory/PlayerSelectionRule.cpp b/xbmc/cores/playercorefactory/PlayerSelectionRule.cpp
index 6f78649d42..3bee50aa06 100644
--- a/xbmc/cores/playercorefactory/PlayerSelectionRule.cpp
+++ b/xbmc/cores/playercorefactory/PlayerSelectionRule.cpp
@@ -126,7 +126,7 @@ void CPlayerSelectionRule::GetPlayers(const CFileItem& item, std::vector<std::st
return;
if (m_tInternetStream >= 0 && (m_tInternetStream > 0) != NETWORK::IsInternetStream(item))
return;
- if (m_tRemote >= 0 && (m_tRemote > 0) != item.IsRemote())
+ if (m_tRemote >= 0 && (m_tRemote > 0) != NETWORK::IsRemote(item))
return;
if (m_tBD >= 0 && (m_tBD > 0) != (VIDEO::IsBDFile(item) && item.IsOnDVD()))
diff --git a/xbmc/filesystem/SourcesDirectory.cpp b/xbmc/filesystem/SourcesDirectory.cpp
index 4f95b39b21..166861e323 100644
--- a/xbmc/filesystem/SourcesDirectory.cpp
+++ b/xbmc/filesystem/SourcesDirectory.cpp
@@ -16,6 +16,7 @@
#include "guilib/TextureManager.h"
#include "media/MediaLockState.h"
#include "music/MusicFileItemClassify.h"
+#include "network/NetworkFileItemClassify.h"
#include "profiles/ProfileManager.h"
#include "settings/MediaSourceSettings.h"
#include "storage/MediaManager.h"
@@ -75,7 +76,7 @@ bool CSourcesDirectory::GetDirectory(const VECSOURCES &sources, CFileItemList &i
else if (VIDEO::IsVideoDb(*pItem) || MUSIC::IsMusicDb(*pItem) || pItem->IsPlugin() ||
pItem->IsPath("musicsearch://"))
strIcon = "DefaultFolder.png";
- else if (pItem->IsRemote())
+ else if (NETWORK::IsRemote(*pItem))
strIcon = "DefaultNetwork.png";
else if (pItem->IsISO9660())
strIcon = "DefaultDVDRom.png";
diff --git a/xbmc/network/NetworkFileItemClassify.cpp b/xbmc/network/NetworkFileItemClassify.cpp
index c806d07b56..ed4bd77be6 100644
--- a/xbmc/network/NetworkFileItemClassify.cpp
+++ b/xbmc/network/NetworkFileItemClassify.cpp
@@ -25,6 +25,11 @@ bool IsInternetStream(const CFileItem& item, const bool bStrictCheck /* = false
return URIUtils::IsInternetStream(item.GetPath(), bStrictCheck);
}
+bool IsRemote(const CFileItem& item)
+{
+ return URIUtils::IsRemote(item.GetPath());
+}
+
bool IsStreamedFilesystem(const CFileItem& item)
{
if (!item.GetDynPath().empty())
diff --git a/xbmc/network/NetworkFileItemClassify.h b/xbmc/network/NetworkFileItemClassify.h
index 8f8b1d2444..5a96a98253 100644
--- a/xbmc/network/NetworkFileItemClassify.h
+++ b/xbmc/network/NetworkFileItemClassify.h
@@ -16,6 +16,9 @@ namespace KODI::NETWORK
//! \brief Check whether an item is a an internet stream.
bool IsInternetStream(const CFileItem& item, const bool bStrictCheck = false);
+//! \brief Check whether an item is on a remote location.
+bool IsRemote(const CFileItem& item);
+
//! \brief Check whether an item is on a streamed filesystem.
bool IsStreamedFilesystem(const CFileItem& item);
} // namespace KODI::NETWORK
diff --git a/xbmc/network/test/TestNetworkFileItemClassify.cpp b/xbmc/network/test/TestNetworkFileItemClassify.cpp
index 0d195c887d..13dbd44c72 100644
--- a/xbmc/network/test/TestNetworkFileItemClassify.cpp
+++ b/xbmc/network/test/TestNetworkFileItemClassify.cpp
@@ -7,6 +7,7 @@
*/
#include "FileItem.h"
+#include "URL.h"
#include "filesystem/StackDirectory.h"
#include "network/NetworkFileItemClassify.h"
@@ -191,6 +192,38 @@ TEST(TestNetworkWorkFileItemClassify, InternetStreamStacks)
EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, true), true));
}
+class RemoteTest : public testing::WithParamInterface<SimpleDefinition>, public testing::Test
+{
+};
+
+TEST_P(RemoteTest, IsRemote)
+{
+ EXPECT_EQ(NETWORK::IsRemote(GetParam().item), GetParam().result);
+}
+
+const auto remote_tests = std::array{
+ SimpleDefinition{"cdda://1", false, false},
+ SimpleDefinition{"cdda://1", true, false},
+ SimpleDefinition{"iso9660://some.file", false, false},
+ SimpleDefinition{"cdda://some.file", true, false},
+ SimpleDefinition{"special://home/foo.xml", false, false},
+ SimpleDefinition{"special://home", true, false},
+ SimpleDefinition{"zip://" + CURL::Encode("/home/foo/bar.zip"), true, false},
+ SimpleDefinition{"zip://" + CURL::Encode("https://some.where/yo.zip"), true, true},
+ SimpleDefinition{"addons://plugins", true, false},
+ SimpleDefinition{"sources://music", true, false},
+ SimpleDefinition{"videodb://1/2", true, false},
+ SimpleDefinition{"musicdb://1/2", true, false},
+ SimpleDefinition{"library://movies/titles", true, false},
+ SimpleDefinition{"plugin://plugin.video.yo", true, false},
+ SimpleDefinition{"androidapp://cool.app", true, false},
+ SimpleDefinition{"/home/foo/bar", true, false},
+ SimpleDefinition{"https://127.0.0.1/bar", true, false},
+ SimpleDefinition{"https://some.where/bar", true, true},
+};
+
+INSTANTIATE_TEST_SUITE_P(TestNetworkFileItemClassify, RemoteTest, testing::ValuesIn(remote_tests));
+
class StreamedFilesystemTest : public testing::WithParamInterface<SimpleDefinition>,
public testing::Test
{