aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Morten Kvarving <spiff@xbmc.org>2012-10-12 02:33:59 -0700
committerArne Morten Kvarving <spiff@xbmc.org>2012-10-12 02:33:59 -0700
commit4de217033ee7c808f6e18b8f2a5d4be02722a305 (patch)
tree29abe863bf3efaa966735f29038e67e9850c48d7
parent56b042b637c4ac87da19ecd71e9be6058db2c6d6 (diff)
parent30faa1138bf86e718a92b002deaba66bdf667a21 (diff)
Merge pull request #1595 from koying/fixvideodbcopy
FIX: Don't show the "Copy" option in the file manager for sources not supporting it (i.e. videodb)
-rw-r--r--xbmc/FileItem.cpp2
-rw-r--r--xbmc/MediaSource.cpp2
-rw-r--r--xbmc/Util.cpp18
-rw-r--r--xbmc/Util.h15
-rw-r--r--xbmc/filesystem/MultiPathDirectory.cpp4
-rw-r--r--xbmc/filesystem/MultiPathDirectory.h2
-rw-r--r--xbmc/filesystem/MythDirectory.cpp2
-rw-r--r--xbmc/filesystem/MythDirectory.h2
-rw-r--r--xbmc/filesystem/PVRDirectory.cpp2
-rw-r--r--xbmc/filesystem/PVRDirectory.h2
-rw-r--r--xbmc/video/VideoDatabase.cpp6
-rw-r--r--xbmc/video/windows/GUIWindowVideoBase.cpp2
-rw-r--r--xbmc/video/windows/GUIWindowVideoNav.cpp4
-rw-r--r--xbmc/windows/GUIWindowFileManager.cpp2
14 files changed, 44 insertions, 21 deletions
diff --git a/xbmc/FileItem.cpp b/xbmc/FileItem.cpp
index dabe92369d..09be35c9d8 100644
--- a/xbmc/FileItem.cpp
+++ b/xbmc/FileItem.cpp
@@ -1191,7 +1191,7 @@ bool CFileItem::IsReadOnly() const
{
if (IsParentFolder()) return true;
if (m_bIsShareOrDrive) return true;
- return !CUtil::SupportsFileOperations(m_strPath);
+ return !CUtil::SupportsWriteFileOperations(m_strPath);
}
void CFileItem::FillInDefaultIcon()
diff --git a/xbmc/MediaSource.cpp b/xbmc/MediaSource.cpp
index c83d23d0f4..8b7db52315 100644
--- a/xbmc/MediaSource.cpp
+++ b/xbmc/MediaSource.cpp
@@ -30,7 +30,7 @@ using namespace XFILE;
bool CMediaSource::IsWritable() const
{
- return CUtil::SupportsFileOperations(strPath);
+ return CUtil::SupportsWriteFileOperations(strPath);
}
void CMediaSource::FromNameAndPaths(const CStdString &category, const CStdString &name, const vector<CStdString> &paths)
diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp
index 0b3fa8bd7f..60a6a2ae53 100644
--- a/xbmc/Util.cpp
+++ b/xbmc/Util.cpp
@@ -1702,7 +1702,7 @@ bool CUtil::MakeShortenPath(CStdString StrInput, CStdString& StrOutput, int iTex
return true;
}
-bool CUtil::SupportsFileOperations(const CStdString& strPath)
+bool CUtil::SupportsWriteFileOperations(const CStdString& strPath)
{
// currently only hd, smb, nfs and afp support delete and rename
if (URIUtils::IsHD(strPath))
@@ -1710,7 +1710,7 @@ bool CUtil::SupportsFileOperations(const CStdString& strPath)
if (URIUtils::IsSmb(strPath))
return true;
if (CUtil::IsTVRecording(strPath))
- return CPVRDirectory::SupportsFileOperations(strPath);
+ return CPVRDirectory::SupportsWriteFileOperations(strPath);
if (URIUtils::IsNfs(strPath))
return true;
if (URIUtils::IsAfp(strPath))
@@ -1722,16 +1722,24 @@ bool CUtil::SupportsFileOperations(const CStdString& strPath)
* it hits the directory cache on the way through, which has the Live Channels and Guide
* items cached.
*/
- return CMythDirectory::SupportsFileOperations(strPath);
+ return CMythDirectory::SupportsWriteFileOperations(strPath);
}
if (URIUtils::IsStack(strPath))
- return SupportsFileOperations(CStackDirectory::GetFirstStackedFile(strPath));
+ return SupportsWriteFileOperations(CStackDirectory::GetFirstStackedFile(strPath));
if (URIUtils::IsMultiPath(strPath))
- return CMultiPathDirectory::SupportsFileOperations(strPath);
+ return CMultiPathDirectory::SupportsWriteFileOperations(strPath);
return false;
}
+bool CUtil::SupportsReadFileOperations(const CStdString& strPath)
+{
+ if (URIUtils::IsVideoDb(strPath))
+ return false;
+
+ return true;
+}
+
CStdString CUtil::GetDefaultFolderThumb(const CStdString &folderThumb)
{
if (g_TextureManager.HasTexture(folderThumb))
diff --git a/xbmc/Util.h b/xbmc/Util.h
index 8c30abe858..db917f7e00 100644
--- a/xbmc/Util.h
+++ b/xbmc/Util.h
@@ -147,7 +147,20 @@ public:
static double AlbumRelevance(const CStdString& strAlbumTemp1, const CStdString& strAlbum1, const CStdString& strArtistTemp1, const CStdString& strArtist1);
static bool MakeShortenPath(CStdString StrInput, CStdString& StrOutput, int iTextMaxLength);
- static bool SupportsFileOperations(const CStdString& strPath);
+ /*! \brief Checks wether the supplied path supports Write file operations (e.g. Rename, Delete, ...)
+
+ \param strPath the path to be checked
+
+ \return true if Write file operations are supported, false otherwise
+ */
+ static bool SupportsWriteFileOperations(const CStdString& strPath);
+ /*! \brief Checks wether the supplied path supports Read file operations (e.g. Copy, ...)
+
+ \param strPath the path to be checked
+
+ \return true if Read file operations are supported, false otherwise
+ */
+ static bool SupportsReadFileOperations(const CStdString& strPath);
static CStdString GetDefaultFolderThumb(const CStdString &folderThumb);
#ifdef UNIT_TESTING
diff --git a/xbmc/filesystem/MultiPathDirectory.cpp b/xbmc/filesystem/MultiPathDirectory.cpp
index 9a9ae2ff8f..11a007b3b1 100644
--- a/xbmc/filesystem/MultiPathDirectory.cpp
+++ b/xbmc/filesystem/MultiPathDirectory.cpp
@@ -306,12 +306,12 @@ void CMultiPathDirectory::MergeItems(CFileItemList &items)
items.Size(), XbmcThreads::SystemClockMillis() - time);
}
-bool CMultiPathDirectory::SupportsFileOperations(const CStdString &strPath)
+bool CMultiPathDirectory::SupportsWriteFileOperations(const CStdString &strPath)
{
vector<CStdString> paths;
GetPaths(strPath, paths);
for (unsigned int i = 0; i < paths.size(); ++i)
- if (CUtil::SupportsFileOperations(paths[i]))
+ if (CUtil::SupportsWriteFileOperations(paths[i]))
return true;
return false;
}
diff --git a/xbmc/filesystem/MultiPathDirectory.h b/xbmc/filesystem/MultiPathDirectory.h
index 01f229282e..20b84e47ba 100644
--- a/xbmc/filesystem/MultiPathDirectory.h
+++ b/xbmc/filesystem/MultiPathDirectory.h
@@ -34,7 +34,7 @@ public:
virtual bool Remove(const char* strPath);
static CStdString GetFirstPath(const CStdString &strPath);
- static bool SupportsFileOperations(const CStdString &strPath);
+ static bool SupportsWriteFileOperations(const CStdString &strPath);
static bool GetPaths(const CStdString& strPath, std::vector<CStdString>& vecPaths);
static bool HasPath(const CStdString& strPath, const CStdString& strPathToFind);
static CStdString ConstructMultiPath(const std::vector<CStdString> &vecPaths);
diff --git a/xbmc/filesystem/MythDirectory.cpp b/xbmc/filesystem/MythDirectory.cpp
index 553db0196b..d0f986e04d 100644
--- a/xbmc/filesystem/MythDirectory.cpp
+++ b/xbmc/filesystem/MythDirectory.cpp
@@ -638,7 +638,7 @@ bool CMythDirectory::IsTvShow(const cmyth_proginfo_t program)
return !IsMovie(program);
}
-bool CMythDirectory::SupportsFileOperations(const CStdString& strPath)
+bool CMythDirectory::SupportsWriteFileOperations(const CStdString& strPath)
{
CURL url(strPath);
CStdString filename = url.GetFileName();
diff --git a/xbmc/filesystem/MythDirectory.h b/xbmc/filesystem/MythDirectory.h
index 3e70c0bb80..42833e1e3a 100644
--- a/xbmc/filesystem/MythDirectory.h
+++ b/xbmc/filesystem/MythDirectory.h
@@ -45,7 +45,7 @@ public:
virtual bool IsAllowed(const CStdString &strFile) const { return true; };
virtual DIR_CACHE_TYPE GetCacheType(const CStdString& strPath) const;
- static bool SupportsFileOperations(const CStdString& strPath);
+ static bool SupportsWriteFileOperations(const CStdString& strPath);
static bool IsLiveTV(const CStdString& strPath);
private:
diff --git a/xbmc/filesystem/PVRDirectory.cpp b/xbmc/filesystem/PVRDirectory.cpp
index 04609f1bdc..d979190f17 100644
--- a/xbmc/filesystem/PVRDirectory.cpp
+++ b/xbmc/filesystem/PVRDirectory.cpp
@@ -103,7 +103,7 @@ bool CPVRDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items
return false;
}
-bool CPVRDirectory::SupportsFileOperations(const CStdString& strPath)
+bool CPVRDirectory::SupportsWriteFileOperations(const CStdString& strPath)
{
CURL url(strPath);
CStdString filename = url.GetFileName();
diff --git a/xbmc/filesystem/PVRDirectory.h b/xbmc/filesystem/PVRDirectory.h
index df87c8fb4a..25fa93ab63 100644
--- a/xbmc/filesystem/PVRDirectory.h
+++ b/xbmc/filesystem/PVRDirectory.h
@@ -35,7 +35,7 @@ public:
virtual bool GetDirectory(const CStdString& strPath, CFileItemList &items);
virtual bool IsAllowed(const CStdString &strFile) const { return true; };
- static bool SupportsFileOperations(const CStdString& strPath);
+ static bool SupportsWriteFileOperations(const CStdString& strPath);
static bool IsLiveTV(const CStdString& strPath);
static bool HasRecordings();
diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp
index e0fa261617..8e149772ad 100644
--- a/xbmc/video/VideoDatabase.cpp
+++ b/xbmc/video/VideoDatabase.cpp
@@ -8158,7 +8158,7 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f
}
CFileItem item(movie.m_strFileNameAndPath,false);
- if (singleFiles && CUtil::SupportsFileOperations(movie.m_strFileNameAndPath))
+ if (singleFiles && CUtil::SupportsWriteFileOperations(movie.m_strFileNameAndPath))
{
if (!item.Exists(false))
{
@@ -8252,7 +8252,7 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f
}
CFileItem item(movie.m_strFileNameAndPath,false);
- if (CUtil::SupportsFileOperations(movie.m_strFileNameAndPath) && singleFiles)
+ if (CUtil::SupportsWriteFileOperations(movie.m_strFileNameAndPath) && singleFiles)
{
if (!item.Exists(false))
{
@@ -8349,7 +8349,7 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f
CFileItem item(tvshow.m_strPath, true);
- if (singleFiles && CUtil::SupportsFileOperations(tvshow.m_strPath))
+ if (singleFiles && CUtil::SupportsWriteFileOperations(tvshow.m_strPath))
{
if (!item.Exists(false))
{
diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp
index 7b3a72d608..ecc35f54e5 100644
--- a/xbmc/video/windows/GUIWindowVideoBase.cpp
+++ b/xbmc/video/windows/GUIWindowVideoBase.cpp
@@ -1595,7 +1595,7 @@ void CGUIWindowVideoBase::OnDeleteItem(CFileItemPtr item)
}
if (g_guiSettings.GetBool("filelists.allowfiledeletion") &&
- CUtil::SupportsFileOperations(item->GetPath()))
+ CUtil::SupportsWriteFileOperations(item->GetPath()))
CFileUtils::DeleteItem(item);
}
diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp
index 49115f9dfb..844396d1f3 100644
--- a/xbmc/video/windows/GUIWindowVideoNav.cpp
+++ b/xbmc/video/windows/GUIWindowVideoNav.cpp
@@ -742,7 +742,7 @@ void CGUIWindowVideoNav::OnDeleteItem(CFileItemPtr pItem)
pItem->m_bIsFolder=true;
if (g_guiSettings.GetBool("filelists.allowfiledeletion") &&
- CUtil::SupportsFileOperations(strDeletePath))
+ CUtil::SupportsWriteFileOperations(strDeletePath))
{
pItem->SetPath(strDeletePath);
CGUIWindowVideoBase::OnDeleteItem(pItem);
@@ -1040,7 +1040,7 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt
if (!m_vecItems->IsVideoDb() && !m_vecItems->IsVirtualDirectoryRoot())
{ // non-video db items, file operations are allowed
if ((g_guiSettings.GetBool("filelists.allowfiledeletion") &&
- CUtil::SupportsFileOperations(item->GetPath())) ||
+ CUtil::SupportsWriteFileOperations(item->GetPath())) ||
(inPlaylists && !URIUtils::GetFileName(item->GetPath()).Equals("PartyMode-Video.xsp")
&& (item->IsPlayList() || item->IsSmartPlayList())))
{
diff --git a/xbmc/windows/GUIWindowFileManager.cpp b/xbmc/windows/GUIWindowFileManager.cpp
index 2727053762..9dc40332bc 100644
--- a/xbmc/windows/GUIWindowFileManager.cpp
+++ b/xbmc/windows/GUIWindowFileManager.cpp
@@ -906,6 +906,8 @@ bool CGUIWindowFileManager::CanCopy(int iList)
// can't copy if the destination is not writeable, or if the source is a share!
// TODO: Perhaps if the source is removeable media (DVD/CD etc.) we could
// put ripping/backup in here.
+ if (!CUtil::SupportsReadFileOperations(m_Directory[iList]->GetPath())) return false;
+ if (m_Directory[iList]->IsVirtualDirectoryRoot()) return false;
if (m_Directory[1 - iList]->IsVirtualDirectoryRoot()) return false;
if (m_Directory[iList]->IsVirtualDirectoryRoot()) return false;
if (m_Directory[1 -iList]->IsReadOnly()) return false;