Skip to content
This repository

FIX: Don't show the "Copy" option in the file manager for sources not supporting it (i.e. videodb) #1595

Merged
1 commit merged into from almost 2 years ago

1 participant

Chris Browet
Chris Browet
Collaborator

I made it generic in case there would be other sources not supporting "Copy" or other places where it would be needed

Deleted user

doxy the new functions please (yes, i know there are bad examples to follow ;))

not immediately obvious what output and input means in the context.

and cool.

Chris Browet
Collaborator

Would SupportsRead.. and SupportsWrite... be better?

Deleted user

yeah, that's better.

Deleted user

rebase please

Chris Browet
Collaborator

@cptspiff Done

Deleted user ghost merged commit 4de2170 into from
Deleted user ghost closed this
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Oct 12, 2012
Chris Browet koying FIX: Don't show the "Copy" option in the file manager for sources not…
… supporting it (i.e. videodb)
30faa11
This page is out of date. Refresh to see the latest.
2  xbmc/FileItem.cpp
@@ -1191,7 +1191,7 @@ bool CFileItem::IsReadOnly() const
1191 1191 {
1192 1192 if (IsParentFolder()) return true;
1193 1193 if (m_bIsShareOrDrive) return true;
1194   - return !CUtil::SupportsFileOperations(m_strPath);
  1194 + return !CUtil::SupportsWriteFileOperations(m_strPath);
1195 1195 }
1196 1196
1197 1197 void CFileItem::FillInDefaultIcon()
2  xbmc/MediaSource.cpp
@@ -30,7 +30,7 @@ using namespace XFILE;
30 30
31 31 bool CMediaSource::IsWritable() const
32 32 {
33   - return CUtil::SupportsFileOperations(strPath);
  33 + return CUtil::SupportsWriteFileOperations(strPath);
34 34 }
35 35
36 36 void CMediaSource::FromNameAndPaths(const CStdString &category, const CStdString &name, const vector<CStdString> &paths)
18 xbmc/Util.cpp
@@ -1702,7 +1702,7 @@ bool CUtil::MakeShortenPath(CStdString StrInput, CStdString& StrOutput, int iTex
1702 1702 return true;
1703 1703 }
1704 1704
1705   -bool CUtil::SupportsFileOperations(const CStdString& strPath)
  1705 +bool CUtil::SupportsWriteFileOperations(const CStdString& strPath)
1706 1706 {
1707 1707 // currently only hd, smb, nfs and afp support delete and rename
1708 1708 if (URIUtils::IsHD(strPath))
@@ -1710,7 +1710,7 @@ bool CUtil::SupportsFileOperations(const CStdString& strPath)
1710 1710 if (URIUtils::IsSmb(strPath))
1711 1711 return true;
1712 1712 if (CUtil::IsTVRecording(strPath))
1713   - return CPVRDirectory::SupportsFileOperations(strPath);
  1713 + return CPVRDirectory::SupportsWriteFileOperations(strPath);
1714 1714 if (URIUtils::IsNfs(strPath))
1715 1715 return true;
1716 1716 if (URIUtils::IsAfp(strPath))
@@ -1722,16 +1722,24 @@ bool CUtil::SupportsFileOperations(const CStdString& strPath)
1722 1722 * it hits the directory cache on the way through, which has the Live Channels and Guide
1723 1723 * items cached.
1724 1724 */
1725   - return CMythDirectory::SupportsFileOperations(strPath);
  1725 + return CMythDirectory::SupportsWriteFileOperations(strPath);
1726 1726 }
1727 1727 if (URIUtils::IsStack(strPath))
1728   - return SupportsFileOperations(CStackDirectory::GetFirstStackedFile(strPath));
  1728 + return SupportsWriteFileOperations(CStackDirectory::GetFirstStackedFile(strPath));
1729 1729 if (URIUtils::IsMultiPath(strPath))
1730   - return CMultiPathDirectory::SupportsFileOperations(strPath);
  1730 + return CMultiPathDirectory::SupportsWriteFileOperations(strPath);
1731 1731
1732 1732 return false;
1733 1733 }
1734 1734
  1735 +bool CUtil::SupportsReadFileOperations(const CStdString& strPath)
  1736 +{
  1737 + if (URIUtils::IsVideoDb(strPath))
  1738 + return false;
  1739 +
  1740 + return true;
  1741 +}
  1742 +
1735 1743 CStdString CUtil::GetDefaultFolderThumb(const CStdString &folderThumb)
1736 1744 {
1737 1745 if (g_TextureManager.HasTexture(folderThumb))
15 xbmc/Util.h
@@ -147,7 +147,20 @@ class CUtil
147 147
148 148 static double AlbumRelevance(const CStdString& strAlbumTemp1, const CStdString& strAlbum1, const CStdString& strArtistTemp1, const CStdString& strArtist1);
149 149 static bool MakeShortenPath(CStdString StrInput, CStdString& StrOutput, int iTextMaxLength);
150   - static bool SupportsFileOperations(const CStdString& strPath);
  150 + /*! \brief Checks wether the supplied path supports Write file operations (e.g. Rename, Delete, ...)
  151 +
  152 + \param strPath the path to be checked
  153 +
  154 + \return true if Write file operations are supported, false otherwise
  155 + */
  156 + static bool SupportsWriteFileOperations(const CStdString& strPath);
  157 + /*! \brief Checks wether the supplied path supports Read file operations (e.g. Copy, ...)
  158 +
  159 + \param strPath the path to be checked
  160 +
  161 + \return true if Read file operations are supported, false otherwise
  162 + */
  163 + static bool SupportsReadFileOperations(const CStdString& strPath);
151 164 static CStdString GetDefaultFolderThumb(const CStdString &folderThumb);
152 165
153 166 #ifdef UNIT_TESTING
4 xbmc/filesystem/MultiPathDirectory.cpp
@@ -306,12 +306,12 @@ void CMultiPathDirectory::MergeItems(CFileItemList &items)
306 306 items.Size(), XbmcThreads::SystemClockMillis() - time);
307 307 }
308 308
309   -bool CMultiPathDirectory::SupportsFileOperations(const CStdString &strPath)
  309 +bool CMultiPathDirectory::SupportsWriteFileOperations(const CStdString &strPath)
310 310 {
311 311 vector<CStdString> paths;
312 312 GetPaths(strPath, paths);
313 313 for (unsigned int i = 0; i < paths.size(); ++i)
314   - if (CUtil::SupportsFileOperations(paths[i]))
  314 + if (CUtil::SupportsWriteFileOperations(paths[i]))
315 315 return true;
316 316 return false;
317 317 }
2  xbmc/filesystem/MultiPathDirectory.h
@@ -34,7 +34,7 @@ class CMultiPathDirectory :
34 34 virtual bool Remove(const char* strPath);
35 35
36 36 static CStdString GetFirstPath(const CStdString &strPath);
37   - static bool SupportsFileOperations(const CStdString &strPath);
  37 + static bool SupportsWriteFileOperations(const CStdString &strPath);
38 38 static bool GetPaths(const CStdString& strPath, std::vector<CStdString>& vecPaths);
39 39 static bool HasPath(const CStdString& strPath, const CStdString& strPathToFind);
40 40 static CStdString ConstructMultiPath(const std::vector<CStdString> &vecPaths);
2  xbmc/filesystem/MythDirectory.cpp
@@ -638,7 +638,7 @@ bool CMythDirectory::IsTvShow(const cmyth_proginfo_t program)
638 638 return !IsMovie(program);
639 639 }
640 640
641   -bool CMythDirectory::SupportsFileOperations(const CStdString& strPath)
  641 +bool CMythDirectory::SupportsWriteFileOperations(const CStdString& strPath)
642 642 {
643 643 CURL url(strPath);
644 644 CStdString filename = url.GetFileName();
2  xbmc/filesystem/MythDirectory.h
@@ -45,7 +45,7 @@ class CMythDirectory
45 45 virtual bool IsAllowed(const CStdString &strFile) const { return true; };
46 46 virtual DIR_CACHE_TYPE GetCacheType(const CStdString& strPath) const;
47 47
48   - static bool SupportsFileOperations(const CStdString& strPath);
  48 + static bool SupportsWriteFileOperations(const CStdString& strPath);
49 49 static bool IsLiveTV(const CStdString& strPath);
50 50
51 51 private:
2  xbmc/filesystem/PVRDirectory.cpp
@@ -103,7 +103,7 @@ bool CPVRDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items
103 103 return false;
104 104 }
105 105
106   -bool CPVRDirectory::SupportsFileOperations(const CStdString& strPath)
  106 +bool CPVRDirectory::SupportsWriteFileOperations(const CStdString& strPath)
107 107 {
108 108 CURL url(strPath);
109 109 CStdString filename = url.GetFileName();
2  xbmc/filesystem/PVRDirectory.h
@@ -35,7 +35,7 @@ class CPVRDirectory
35 35 virtual bool GetDirectory(const CStdString& strPath, CFileItemList &items);
36 36 virtual bool IsAllowed(const CStdString &strFile) const { return true; };
37 37
38   - static bool SupportsFileOperations(const CStdString& strPath);
  38 + static bool SupportsWriteFileOperations(const CStdString& strPath);
39 39 static bool IsLiveTV(const CStdString& strPath);
40 40 static bool HasRecordings();
41 41
6 xbmc/video/VideoDatabase.cpp
@@ -8158,7 +8158,7 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f
8158 8158 }
8159 8159
8160 8160 CFileItem item(movie.m_strFileNameAndPath,false);
8161   - if (singleFiles && CUtil::SupportsFileOperations(movie.m_strFileNameAndPath))
  8161 + if (singleFiles && CUtil::SupportsWriteFileOperations(movie.m_strFileNameAndPath))
8162 8162 {
8163 8163 if (!item.Exists(false))
8164 8164 {
@@ -8252,7 +8252,7 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f
8252 8252 }
8253 8253
8254 8254 CFileItem item(movie.m_strFileNameAndPath,false);
8255   - if (CUtil::SupportsFileOperations(movie.m_strFileNameAndPath) && singleFiles)
  8255 + if (CUtil::SupportsWriteFileOperations(movie.m_strFileNameAndPath) && singleFiles)
8256 8256 {
8257 8257 if (!item.Exists(false))
8258 8258 {
@@ -8349,7 +8349,7 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f
8349 8349
8350 8350
8351 8351 CFileItem item(tvshow.m_strPath, true);
8352   - if (singleFiles && CUtil::SupportsFileOperations(tvshow.m_strPath))
  8352 + if (singleFiles && CUtil::SupportsWriteFileOperations(tvshow.m_strPath))
8353 8353 {
8354 8354 if (!item.Exists(false))
8355 8355 {
2  xbmc/video/windows/GUIWindowVideoBase.cpp
@@ -1595,7 +1595,7 @@ void CGUIWindowVideoBase::OnDeleteItem(CFileItemPtr item)
1595 1595 }
1596 1596
1597 1597 if (g_guiSettings.GetBool("filelists.allowfiledeletion") &&
1598   - CUtil::SupportsFileOperations(item->GetPath()))
  1598 + CUtil::SupportsWriteFileOperations(item->GetPath()))
1599 1599 CFileUtils::DeleteItem(item);
1600 1600 }
1601 1601
4 xbmc/video/windows/GUIWindowVideoNav.cpp
@@ -742,7 +742,7 @@ void CGUIWindowVideoNav::OnDeleteItem(CFileItemPtr pItem)
742 742 pItem->m_bIsFolder=true;
743 743
744 744 if (g_guiSettings.GetBool("filelists.allowfiledeletion") &&
745   - CUtil::SupportsFileOperations(strDeletePath))
  745 + CUtil::SupportsWriteFileOperations(strDeletePath))
746 746 {
747 747 pItem->SetPath(strDeletePath);
748 748 CGUIWindowVideoBase::OnDeleteItem(pItem);
@@ -1040,7 +1040,7 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt
1040 1040 if (!m_vecItems->IsVideoDb() && !m_vecItems->IsVirtualDirectoryRoot())
1041 1041 { // non-video db items, file operations are allowed
1042 1042 if ((g_guiSettings.GetBool("filelists.allowfiledeletion") &&
1043   - CUtil::SupportsFileOperations(item->GetPath())) ||
  1043 + CUtil::SupportsWriteFileOperations(item->GetPath())) ||
1044 1044 (inPlaylists && !URIUtils::GetFileName(item->GetPath()).Equals("PartyMode-Video.xsp")
1045 1045 && (item->IsPlayList() || item->IsSmartPlayList())))
1046 1046 {
2  xbmc/windows/GUIWindowFileManager.cpp
@@ -906,6 +906,8 @@ bool CGUIWindowFileManager::CanCopy(int iList)
906 906 // can't copy if the destination is not writeable, or if the source is a share!
907 907 // TODO: Perhaps if the source is removeable media (DVD/CD etc.) we could
908 908 // put ripping/backup in here.
  909 + if (!CUtil::SupportsReadFileOperations(m_Directory[iList]->GetPath())) return false;
  910 + if (m_Directory[iList]->IsVirtualDirectoryRoot()) return false;
909 911 if (m_Directory[1 - iList]->IsVirtualDirectoryRoot()) return false;
910 912 if (m_Directory[iList]->IsVirtualDirectoryRoot()) return false;
911 913 if (m_Directory[1 -iList]->IsReadOnly()) return false;

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.