Browse files

FIX: Don't show the "Copy" option in the file manager for sources not…

… supporting it (i.e. videodb)
  • Loading branch information...
1 parent 56b042b commit 30faa1138bf86e718a92b002deaba66bdf667a21 @koying koying committed Oct 10, 2012
View
2 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()
View
2 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)
View
18 xbmc/Util.cpp
@@ -1702,15 +1702,15 @@ 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))
return true;
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))
View
15 xbmc/Util.h
@@ -147,7 +147,20 @@ class CUtil
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
View
4 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;
}
View
2 xbmc/filesystem/MultiPathDirectory.h
@@ -34,7 +34,7 @@ class CMultiPathDirectory :
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);
View
2 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();
View
2 xbmc/filesystem/MythDirectory.h
@@ -45,7 +45,7 @@ class CMythDirectory
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:
View
2 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();
View
2 xbmc/filesystem/PVRDirectory.h
@@ -35,7 +35,7 @@ class CPVRDirectory
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();
View
6 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))
{
View
2 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);
}
View
4 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())))
{
View
2 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;

0 comments on commit 30faa11

Please sign in to comment.