[CURL] make the CStdString constructor explicit, to ensure we capture function conver...
authorJonathan Marshall <jmarshall@xbmc.org>
Sat, 7 Jun 2014 09:15:31 +0000 (21:15 +1200)
committerJonathan Marshall <jmarshall@never.you.mind>
Tue, 10 Jun 2014 03:11:01 +0000 (15:11 +1200)
xbmc/Application.cpp
xbmc/URL.h
xbmc/filesystem/CurlFile.cpp
xbmc/filesystem/File.cpp
xbmc/filesystem/MythDirectory.cpp
xbmc/filesystem/ShoutcastFile.cpp
xbmc/filesystem/UPnPFile.cpp
xbmc/network/AirTunesServer.cpp
xbmc/network/WakeOnAccess.cpp
xbmc/network/httprequesthandler/HTTPImageHandler.cpp

index 1eb1bd8..4c56c1c 100644 (file)
@@ -3895,7 +3895,7 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart)
   if (URIUtils::IsUPnP(item.GetPath()))
   {
     CFileItem item_new(item);
-    if (XFILE::CUPnPDirectory::GetResource(item.GetPath(), item_new))
+    if (XFILE::CUPnPDirectory::GetResource(item.GetURL(), item_new))
       return PlayFile(item_new, false);
     return PLAYBACK_FAIL;
   }
@@ -4840,7 +4840,7 @@ bool CApplication::OnMessage(CGUIMessage& message)
 #ifdef HAS_UPNP
       if (URIUtils::IsUPnP(file.GetPath()))
       {
-        if (!XFILE::CUPnPDirectory::GetResource(file.GetPath(), file))
+        if (!XFILE::CUPnPDirectory::GetResource(file.GetURL(), file))
           return true;
       }
 #endif
index 193b0f8..ea151c1 100644 (file)
 class CURL
 {
 public:
-  CURL(const CStdString& strURL);
+  explicit CURL(const CStdString& strURL);
   CURL();
   virtual ~CURL(void);
 
+  // explicit equals operator for std::string comparison
+  bool operator==(const std::string &url) const { return Get() == url; }
+
   void Reset();
   void Parse(const CStdString& strURL);
   void SetFileName(const CStdString& strFileName);
index 2ca558d..9e4b859 100644 (file)
@@ -816,7 +816,8 @@ bool CCurlFile::Get(const CStdString& strURL, CStdString& strHTML)
 
 bool CCurlFile::Service(const CStdString& strURL, CStdString& strHTML)
 {
-  if (Open(strURL))
+  const CURL pathToUrl(strURL);
+  if (Open(pathToUrl))
   {
     if (ReadData(strHTML))
     {
@@ -875,8 +876,8 @@ bool CCurlFile::Download(const CStdString& strURL, const CStdString& strFileName
 // Detect whether we are "online" or not! Very simple and dirty!
 bool CCurlFile::IsInternet()
 {
-  CStdString strURL = "http://www.google.com";
-  bool found = Exists(strURL);
+  CURL url("http://www.google.com");
+  bool found = Exists(url);
   Close();
 
   return found;
index b38e7cd..f122900 100644 (file)
@@ -394,7 +394,7 @@ bool CFile::OpenForWrite(const CStdString& strFileName, bool bOverWrite)
 
 bool CFile::Exists(const CStdString& strFileName, bool bUseCache /* = true */)
 {
-  CURL url = URIUtils::SubstitutePath(strFileName);
+  CURL url(URIUtils::SubstitutePath(strFileName));
   
   try
   {
@@ -482,12 +482,10 @@ int CFile::Stat(const CStdString& strFileName, struct __stat64* buffer)
   if (!buffer)
     return -1;
 
-  CURL url;
-  
+  CURL url(URIUtils::SubstitutePath(strFileName));
+
   try
   {
-    url = URIUtils::SubstitutePath(strFileName);
-    
     auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
     if (!pFile.get())
       return -1;
index 792cd3d..6c40732 100644 (file)
@@ -469,7 +469,7 @@ bool CMythDirectory::GetChannels(const CStdString& base, CFileItemList &items)
 
 bool CMythDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
 {
-  m_session = CMythSession::AquireSession(strPath);
+  m_session = CMythSession::AquireSession(CURL(strPath));
   if (!m_session)
     return false;
 
index d6dafc6..e150c5c 100644 (file)
@@ -72,7 +72,7 @@ bool CShoutcastFile::Open(const CURL& url)
   url2.SetProtocolOptions(url2.GetProtocolOptions()+"&noshout=true&Icy-MetaData=1");
   url2.SetProtocol("http");
 
-  bool result = m_file.Open(url2.Get());
+  bool result = m_file.Open(url2);
   if (result)
   {
     m_tag.SetTitle(m_file.GetHttpHeader().GetValue("icy-name"));
index 879377c..87ec0d3 100644 (file)
@@ -38,7 +38,7 @@ CUPnPFile::~CUPnPFile()
 bool CUPnPFile::Open(const CURL& url)
 {
   CFileItem item_new;
-  if (CUPnPDirectory::GetResource(url.Get(), item_new))
+  if (CUPnPDirectory::GetResource(url, item_new))
   {
     //CLog::Log(LOGDEBUG,"FileUPnP - file redirect to %s.", item_new.GetPath().c_str());
     IFile *pNewImp = CFileFactory::CreateLoader(item_new.GetPath());    
@@ -55,7 +55,7 @@ bool CUPnPFile::Open(const CURL& url)
 int CUPnPFile::Stat(const CURL& url, struct __stat64* buffer)
 {
   CFileItem item_new;
-  if (CUPnPDirectory::GetResource(url.Get(), item_new))
+  if (CUPnPDirectory::GetResource(url, item_new))
   {
     //CLog::Log(LOGDEBUG,"FileUPnP - file redirect to %s.", item_new.GetPath().c_str());
     IFile *pNewImp = CFileFactory::CreateLoader(item_new.GetPath());
@@ -72,7 +72,7 @@ int CUPnPFile::Stat(const CURL& url, struct __stat64* buffer)
 bool CUPnPFile::Exists(const CURL& url)
 {
   CFileItem item_new;
-  if (CUPnPDirectory::GetResource(url.Get(), item_new))
+  if (CUPnPDirectory::GetResource(url, item_new))
   {
     //CLog::Log(LOGDEBUG,"FileUPnP - file redirect to %s.", item_new.GetPath().c_str());
     IFile *pNewImp = CFileFactory::CreateLoader(item_new.GetPath());
index 107c7d9..0843fef 100644 (file)
@@ -206,7 +206,8 @@ char *session="XBMC-AirTunes";
 void* CAirTunesServer::AudioOutputFunctions::audio_init(void *cls, int bits, int channels, int samplerate)
 {
   XFILE::CPipeFile *pipe=(XFILE::CPipeFile *)cls;
-  pipe->OpenForWrite(XFILE::PipesManager::GetInstance().GetUniquePipeName());
+  const CURL pathToUrl(XFILE::PipesManager::GetInstance().GetUniquePipeName());
+  pipe->OpenForWrite(pathToUrl);
   pipe->SetOpenThreashold(300);
 
   Demux_BXA_FmtHeader header;
index 8031e2a..3361bd8 100644 (file)
@@ -509,7 +509,7 @@ static void AddHostsFromMediaSource(const CMediaSource& source, std::vector<std:
 {
   for (CStdStringArray::const_iterator it = source.vecPaths.begin() ; it != source.vecPaths.end(); it++)
   {
-    CURL url = *it;
+    CURL url(*it);
 
     AddHost (url.GetHostName(), hosts);
   }
@@ -549,7 +549,7 @@ void CWakeOnAccess::QueueMACDiscoveryForAllRemotes()
   // add from path substitutions ..
   for (CAdvancedSettings::StringMapping::iterator i = g_advancedSettings.m_pathSubstitutions.begin(); i != g_advancedSettings.m_pathSubstitutions.end(); ++i)
   {
-    CURL url = i->second;
+    CURL url(i->second);
 
     AddHost (url.GetHostName(), hosts);
   }
index 856c858..9affa06 100644 (file)
@@ -37,7 +37,8 @@ int CHTTPImageHandler::HandleHTTPRequest(const HTTPRequest &request)
     m_path = request.url.substr(7);
 
     XFILE::CImageFile imageFile;
-    if (imageFile.Exists(m_path))
+    const CURL pathToUrl(m_path);
+    if (imageFile.Exists(pathToUrl))
     {
       m_responseCode = MHD_HTTP_OK;
       m_responseType = HTTPFileDownload;