CURL::Encode usage refactoring
authorKarlson2k <k2k@narod.ru>
Wed, 15 Jan 2014 06:21:37 +0000 (10:21 +0400)
committerKarlson2k <k2k@narod.ru>
Wed, 15 Jan 2014 07:10:57 +0000 (11:10 +0400)
12 files changed:
xbmc/filesystem/CurlFile.cpp
xbmc/filesystem/MultiPathDirectory.cpp
xbmc/filesystem/SMBDirectory.cpp
xbmc/filesystem/SmbFile.cpp
xbmc/filesystem/ZeroconfDirectory.cpp
xbmc/music/windows/GUIWindowMusicNav.cpp
xbmc/network/AirPlayServer.cpp
xbmc/network/WebServer.cpp
xbmc/network/upnp/UPnP.cpp
xbmc/utils/ScraperParser.cpp
xbmc/utils/ScraperUrl.cpp
xbmc/utils/URIUtils.cpp

index 6d1b25a..9e3d598 100644 (file)
@@ -674,7 +674,7 @@ void CCurlFile::ParseAndCorrectUrl(CURL &url2)
     /* url encoded. if handed from ftpdirectory */
     /* it won't be so let's handle that case    */
 
-    CStdString partial, filename(url2.GetFileName());
+    CStdString filename(url2.GetFileName());
     std::vector<std::string> array;
 
     // if server sent us the filename in non-utf8, we need send back with same encoding.
@@ -689,9 +689,7 @@ void CCurlFile::ParseAndCorrectUrl(CURL &url2)
       if(it != array.begin())
         filename += "/";
 
-      partial = *it;
-      partial = CURL::Encode(partial);
-      filename += partial;
+      filename += CURL::Encode(*it);
     }
 
     /* make sure we keep slashes */
index 09240b8..ebd90b6 100644 (file)
@@ -222,11 +222,9 @@ CStdString CMultiPathDirectory::ConstructMultiPath(const CFileItemList& items, c
 
 void CMultiPathDirectory::AddToMultiPath(CStdString& strMultiPath, const CStdString& strPath)
 {
-  CStdString strPath1 = strPath;
   URIUtils::AddSlashAtEnd(strMultiPath);
   //CLog::Log(LOGDEBUG, "-- adding path: %s", strPath.c_str());
-  strPath1 = CURL::Encode(strPath1);
-  strMultiPath += strPath1;
+  strMultiPath += CURL::Encode(strPath);
   strMultiPath += "/";
 }
 
index 4311b60..9b2318c 100644 (file)
@@ -416,8 +416,7 @@ void CSMBDirectory::UnMountShare(const CStdString &strType, const CStdString &st
 
 CStdString CSMBDirectory::GetMountPoint(const CStdString &strType, const CStdString &strName)
 {
-  CStdString strPath = strType + strName;
-  strPath = CURL::Encode(strPath);
+  CStdString strPath(CURL::Encode(strType + strName));
 
 #if defined(TARGET_DARWIN)
   CStdString str = getenv("HOME");
index 34e0991..f523e06 100644 (file)
@@ -244,9 +244,7 @@ CStdString CSMB::URLEncode(const CURL &url)
 
 CStdString CSMB::URLEncode(const CStdString &value)
 {
-  CStdString encoded(value);
-  encoded = CURL::Encode(encoded);
-  return encoded;
+  return CURL::Encode(value);
 }
 
 /* This is called from CApplication::ProcessSlow() and is used to tell if smbclient have been idle for too long */
index 6b7f615..bbdefc6 100644 (file)
@@ -186,8 +186,7 @@ bool CZeroconfDirectory::GetDirectory(const CStdString& strPath, CFileItemList &
         CFileItemPtr item(new CFileItem("", true));
         CURL url;
         url.SetProtocol("zeroconf");
-        CStdString service_path = CZeroconfBrowser::ZeroconfService::toPath(*it);
-        service_path = CURL::Encode(service_path);
+        CStdString service_path(CURL::Encode(CZeroconfBrowser::ZeroconfService::toPath(*it)));
         url.SetFileName(service_path);
         item->SetPath(url.Get());
 
index 522e85c..74c7e34 100644 (file)
@@ -766,8 +766,7 @@ void CGUIWindowMusicNav::DisplayEmptyDatabaseMessage(bool bDisplay)
 
 void CGUIWindowMusicNav::OnSearchUpdate()
 {
-  CStdString search(GetProperty("search").asString());
-  search = CURL::Encode(search);
+  CStdString search(CURL::Encode(GetProperty("search").asString()));
   if (!search.empty())
   {
     CStdString path = "musicsearch://" + search + "/";
index 1e73405..7db6754 100644 (file)
@@ -862,8 +862,7 @@ int CAirPlayServer::CTCPClient::ProcessRequest( CStdString& responseHeader,
 
     if (status != AIRPLAY_STATUS_NEED_AUTH)
     {
-      CStdString userAgent="AppleCoreMedia/1.0.0.8F455 (AppleTV; U; CPU OS 4_3 like Mac OS X; de_de)";
-      userAgent = CURL::Encode(userAgent);
+      CStdString userAgent(CURL::Encode("AppleCoreMedia/1.0.0.8F455 (AppleTV; U; CPU OS 4_3 like Mac OS X; de_de)"));
       location += "|User-Agent=" + userAgent;
 
       CFileItem fileToPlay(location, false);
index 604066a..208d17c 100644 (file)
@@ -853,8 +853,7 @@ bool CWebServer::PrepareDownload(const char *path, CVariant &details, std::strin
       url = "image/";
     else
       url = "vfs/";
-    strPath = CURL::Encode(strPath);
-    url += strPath;
+    url += CURL::Encode(strPath);
     details["path"] = url;
     return true;
   }
index 7745c6d..e9ce9e9 100644 (file)
@@ -183,8 +183,7 @@ public:
     {
         NPT_String path = "upnp://"+device->GetUUID()+"/";
         if (!NPT_StringsEqual(item_id, "0")) {
-            CStdString id = item_id;
-            id = CURL::Encode(id);
+            CStdString id(CURL::Encode(item_id));
             URIUtils::AddSlashAtEnd(id);
             path += id.c_str();
         }
index c4f2ae2..13c56ca 100644 (file)
@@ -528,8 +528,7 @@ void CScraperParser::Clean(CStdString& strDirty)
     size_t i2;
     if ((i2 = strDirty.find("!!!ENCODE!!!",i+12)) != std::string::npos)
     {
-      strBuffer = strDirty.substr(i+12,i2-i-12);
-      strBuffer = CURL::Encode(strBuffer);
+      strBuffer = CURL::Encode(strDirty.substr(i + 12, i2 - i - 12));
       strDirty.replace(i, i2-i+12, strBuffer);
       i += strBuffer.size();
     }
index 1f9cff7..8e7b42e 100644 (file)
@@ -346,9 +346,8 @@ CStdString CScraperUrl::GetThumbURL(const CScraperUrl::SUrlEntry &entry)
 {
   if (entry.m_spoof.empty())
     return entry.m_url;
-  CStdString spoof = entry.m_spoof;
-  spoof = CURL::Encode(spoof);
-  return entry.m_url + "|Referer=" + spoof;
+  
+  return entry.m_url + "|Referer=" + CStdString(CURL::Encode(entry.m_spoof));
 }
 
 void CScraperUrl::GetThumbURLs(std::vector<CStdString> &thumbs, const std::string &type, int season) const
index 68be135..95b8091 100644 (file)
@@ -1113,24 +1113,17 @@ void URIUtils::CreateArchivePath(CStdString& strUrlPath,
                                  const CStdString& strFilePathInArchive,
                                  const CStdString& strPwd)
 {
-  CStdString strBuffer;
-
   strUrlPath = strType+"://";
 
   if( !strPwd.empty() )
   {
-    strBuffer = strPwd;
-    strBuffer = CURL::Encode(strBuffer);
-    strUrlPath += strBuffer;
+    strUrlPath += CURL::Encode(strPwd);
     strUrlPath += "@";
   }
 
-  strBuffer = strArchivePath;
-  strBuffer = CURL::Encode(strBuffer);
-
-  strUrlPath += strBuffer;
+  strUrlPath += CURL::Encode(strArchivePath);
 
-  strBuffer = strFilePathInArchive;
+  CStdString strBuffer(strFilePathInArchive);
   StringUtils::Replace(strBuffer, '\\', '/');
   StringUtils::TrimLeft(strBuffer, "/");