m_strLockCode = "0";
m_iBadPwdCount = 0;
m_iHasLock = 0;
+ m_allowSharing = true;
if (URIUtils::IsMultiPath(strPath))
m_iDriveType = SOURCE_TYPE_VPATH;
SOURCE_TYPE_VPATH = 5,
SOURCE_TYPE_REMOVABLE = 6
};
- CMediaSource() { m_iDriveType=SOURCE_TYPE_UNKNOWN; m_iLockMode=LOCK_MODE_EVERYONE; m_iBadPwdCount=0; m_iHasLock=0; m_ignore=false; };
+ CMediaSource() { m_iDriveType=SOURCE_TYPE_UNKNOWN; m_iLockMode=LOCK_MODE_EVERYONE; m_iBadPwdCount=0; m_iHasLock=0; m_ignore=false; m_allowSharing=true; };
virtual ~CMediaSource() {};
bool operator==(const CMediaSource &right) const;
std::vector<CStdString> vecPaths;
bool m_ignore; /// <Do not store in xml
+ bool m_allowSharing; /// <Allow browsing of source from UPnP / WebServer
};
/*!
#include "Util.h"
#include "URL.h"
#include "utils/URIUtils.h"
+#include "utils/FileUtils.h"
using namespace XFILE;
using namespace JSONRPC;
-static const unsigned int SourcesSize = 5;
-static CStdString SourceNames[] = { "programs", "files", "video", "music", "pictures" };
-
JSONRPC_STATUS CFileOperations::GetRootDirectory(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CStdString media = parameterObject["media"].asString();
CFileItemList items;
CStdString strPath = parameterObject["directory"].asString();
- // Check if this directory is part of a source and whether it's locked
- bool isSource;
- for (unsigned int index = 0; index < SourcesSize; index++)
- {
- VECSOURCES* sources = CMediaSourceSettings::Get().GetSources(SourceNames[index]);
- int sourceIndex = CUtil::GetMatchingSource(strPath, *sources, isSource);
- if (sourceIndex >= 0 && sourceIndex < (int)sources->size() && sources->at(sourceIndex).m_iHasLock == 2)
- return InvalidParams;
- }
+ if (!CFileUtils::RemoteAccessAllowed(strPath))
+ return InvalidParams;
CStdStringArray regexps;
CStdString extensions = "";
if (!CFile::Exists(file))
return InvalidParams;
+ if (!CFileUtils::RemoteAccessAllowed(file))
+ return InvalidParams;
+
CStdString path;
URIUtils::GetDirectory(file, path);
for (VECSOURCES::const_iterator source = sources->begin(); source != sources->end() && !accessible; source++)
{
- // don't allow access to locked sources
- if (source->m_iHasLock == 2)
+ // don't allow access to locked / disabled sharing sources
+ if (source->m_iHasLock == 2 || !source->m_allowSharing)
continue;
for (vector<CStdString>::const_iterator path = source->vecPaths.begin(); path != source->vecPaths.end(); path++)
#include "video/VideoDatabase.h"
#include "guilib/GUIWindowManager.h"
#include "xbmc/GUIUserMessages.h"
+#include "utils/FileUtils.h"
using namespace std;
using namespace ANNOUNCEMENT;
NPT_Result
ObjectIDValidate(const NPT_String& id)
{
- if(id.Find("..") != -1)
- return NPT_ERROR_NO_SUCH_FILE;
- if(id.StartsWith("virtualpath://upnproot/"))
- return NPT_SUCCESS;
- else if(id.StartsWith("musicdb://"))
- return NPT_SUCCESS;
- else if(id.StartsWith("videodb://"))
- return NPT_SUCCESS;
- else if(id.StartsWith("library://video"))
- return NPT_SUCCESS;
- else if(id.StartsWith("sources://video"))
- return NPT_SUCCESS;
- else if(id.StartsWith("special://musicplaylists"))
- return NPT_SUCCESS;
- else if(id.StartsWith("special://profile/playlists"))
- return NPT_SUCCESS;
- else if(id.StartsWith("special://videoplaylists"))
+ if (CFileUtils::RemoteAccessAllowed(id.GetChars()))
return NPT_SUCCESS;
return NPT_ERROR_NO_SUCH_FILE;
}
if (pThumbnailNode && pThumbnailNode->FirstChild())
share.m_strThumbnailImage = pThumbnailNode->FirstChild()->Value();
+ XMLUtils::GetBoolean(source, "allowsharing", share.m_allowSharing);
+
return true;
}
XMLUtils::SetString(&source, "lockcode", share.m_strLockCode);
XMLUtils::SetInt(&source, "badpwdcount", share.m_iBadPwdCount);
}
+
if (!share.m_strThumbnailImage.empty())
XMLUtils::SetPath(&source, "thumbnail", share.m_strThumbnailImage);
+ XMLUtils::SetBoolean(&source, "allowsharing", share.m_allowSharing);
+
sectionNode->InsertEndChild(source);
}
#include "URIUtils.h"
#include "filesystem/MultiPathDirectory.h"
#include <vector>
+#include "settings/MediaSourceSettings.h"
+#include "Util.h"
+#include "StringUtils.h"
+#include "URL.h"
using namespace XFILE;
using namespace std;
}
return false;
}
+
+bool CFileUtils::RemoteAccessAllowed(const CStdString &strPath)
+{
+ const unsigned int SourcesSize = 5;
+ CStdString SourceNames[] = { "programs", "files", "video", "music", "pictures" };
+
+ string realPath = URIUtils::GetRealPath(strPath);
+ // for rar:// and zip:// paths we need to extract the path to the archive
+ // instead of using the VFS path
+ while (URIUtils::IsInArchive(realPath))
+ realPath = CURL(realPath).GetHostName();
+
+ if (StringUtils::StartsWith(realPath, "virtualpath://upnproot/"))
+ return true;
+ else if (StringUtils::StartsWith(realPath, "musicdb://"))
+ return true;
+ else if (StringUtils::StartsWith(realPath, "videodb://"))
+ return true;
+ else if (StringUtils::StartsWith(realPath, "library://video"))
+ return true;
+ else if (StringUtils::StartsWith(realPath, "sources://video"))
+ return true;
+ else if (StringUtils::StartsWith(realPath, "special://musicplaylists"))
+ return true;
+ else if (StringUtils::StartsWith(realPath, "special://profile/playlists"))
+ return true;
+ else if (StringUtils::StartsWith(realPath, "special://videoplaylists"))
+ return true;
+
+ bool isSource;
+ for (unsigned int index = 0; index < SourcesSize; index++)
+ {
+ VECSOURCES* sources = CMediaSourceSettings::Get().GetSources(SourceNames[index]);
+ int sourceIndex = CUtil::GetMatchingSource(realPath, *sources, isSource);
+ if (sourceIndex >= 0 && sourceIndex < (int)sources->size() && sources->at(sourceIndex).m_iHasLock != 2 && sources->at(sourceIndex).m_allowSharing)
+ return true;
+ }
+ return false;
+}
\ No newline at end of file
static bool DeleteItem(const CFileItemPtr &item, bool force=false);
static bool DeleteItem(const CStdString &strPath, bool force=false);
static bool RenameFile(const CStdString &strFile);
+ static bool RemoteAccessAllowed(const CStdString &strPath);
};