Skip to content

Commit

Permalink
Merge pull request #1595 from koying/fixvideodbcopy
Browse files Browse the repository at this point in the history
FIX: Don't show the "Copy" option in the file manager for sources not supporting it (i.e. videodb)
  • Loading branch information
Arne Morten Kvarving committed Oct 12, 2012
2 parents 56b042b + 30faa11 commit 4de2170
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 21 deletions.
2 changes: 1 addition & 1 deletion xbmc/FileItem.cpp
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion xbmc/MediaSource.cpp
Expand Up @@ -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)
Expand Down
18 changes: 13 additions & 5 deletions xbmc/Util.cpp
Expand Up @@ -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))
Expand All @@ -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))
Expand Down
15 changes: 14 additions & 1 deletion xbmc/Util.h
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions xbmc/filesystem/MultiPathDirectory.cpp
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion xbmc/filesystem/MultiPathDirectory.h
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/MythDirectory.cpp
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/MythDirectory.h
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/PVRDirectory.cpp
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/PVRDirectory.h
Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions xbmc/video/VideoDatabase.cpp
Expand Up @@ -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))
{
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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))
{
Expand Down
2 changes: 1 addition & 1 deletion xbmc/video/windows/GUIWindowVideoBase.cpp
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions xbmc/video/windows/GUIWindowVideoNav.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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())))
{
Expand Down
2 changes: 2 additions & 0 deletions xbmc/windows/GUIWindowFileManager.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 4de2170

Please sign in to comment.