From fa9e057bae22e239c85f4f9236915e93efacb6e6 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 25 Jun 2014 22:52:53 +0200 Subject: [PATCH] [stdstring] get rid of CStdString in network/upnp/ --- xbmc/network/upnp/UPnP.cpp | 10 ++-- xbmc/network/upnp/UPnP.h | 4 +- xbmc/network/upnp/UPnPInternal.cpp | 14 +++--- xbmc/network/upnp/UPnPInternal.h | 4 +- xbmc/network/upnp/UPnPPlayer.h | 1 + xbmc/network/upnp/UPnPRenderer.cpp | 10 ++-- xbmc/network/upnp/UPnPServer.cpp | 73 +++++++++++++++--------------- 7 files changed, 58 insertions(+), 58 deletions(-) diff --git a/xbmc/network/upnp/UPnP.cpp b/xbmc/network/upnp/UPnP.cpp index 4c34e6050f2c3..ec187e7c82f1c 100644 --- a/xbmc/network/upnp/UPnP.cpp +++ b/xbmc/network/upnp/UPnP.cpp @@ -208,7 +208,7 @@ class CMediaBrowser : public PLT_SyncMediaBrowser, { NPT_String path = "upnp://"+device->GetUUID()+"/"; if (!NPT_StringsEqual(item_id, "0")) { - CStdString id(CURL::Encode(item_id)); + std::string id(CURL::Encode(item_id)); URIUtils::AddSlashAtEnd(id); path += id.c_str(); } @@ -584,7 +584,7 @@ CUPnP::CreateServer(int port /* = 0 */) // trying to set optional upnp values for XP UPnP UI Icons to detect us // but it doesn't work anyways as it requires multicast for XP to detect us device->m_PresentationURL = - NPT_HttpUrl(m_IP, + NPT_HttpUrl(m_IP.c_str(), CSettings::Get().GetInt("services.webserverport"), "/").ToString(); @@ -608,7 +608,7 @@ CUPnP::StartServer() if (!m_ServerHolder->m_Device.IsNull()) return false; // load upnpserver.xml - CStdString filename = URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), "upnpserver.xml"); + std::string filename = URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), "upnpserver.xml"); CUPnPSettings::Get().Load(filename); // create the server with a XBox compatible friendlyname and UUID from upnpserver.xml if found @@ -667,7 +667,7 @@ CUPnP::CreateRenderer(int port /* = 0 */) port); device->m_PresentationURL = - NPT_HttpUrl(m_IP, + NPT_HttpUrl(m_IP.c_str(), CSettings::Get().GetInt("services.webserverport"), "/").ToString(); device->m_ModelName = "Kodi"; @@ -687,7 +687,7 @@ bool CUPnP::StartRenderer() { if (!m_RendererHolder->m_Device.IsNull()) return false; - CStdString filename = URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), "upnpserver.xml"); + std::string filename = URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), "upnpserver.xml"); CUPnPSettings::Get().Load(filename); m_RendererHolder->m_Device = CreateRenderer(CUPnPSettings::Get().GetRendererPort()); diff --git a/xbmc/network/upnp/UPnP.h b/xbmc/network/upnp/UPnP.h index 96194e6ac8511..56c91b0a7bdee 100644 --- a/xbmc/network/upnp/UPnP.h +++ b/xbmc/network/upnp/UPnP.h @@ -23,7 +23,7 @@ */ #pragma once -#include "utils/StdString.h" +#include class NPT_LogHandler; class PLT_UPnP; @@ -88,7 +88,7 @@ class CUPnP PLT_MediaController* m_MediaController; private: - CStdString m_IP; + std::string m_IP; PLT_UPnP* m_UPnP; NPT_LogHandler* m_LogHandler; CDeviceHostReferenceHolder* m_ServerHolder; diff --git a/xbmc/network/upnp/UPnPInternal.cpp b/xbmc/network/upnp/UPnPInternal.cpp index ac83c8ca747a9..2b1d6b16d6aaa 100644 --- a/xbmc/network/upnp/UPnPInternal.cpp +++ b/xbmc/network/upnp/UPnPInternal.cpp @@ -113,7 +113,7 @@ NPT_String GetMimeType(const CFileItem& item, const PLT_HttpRequestContext* context /* = NULL */) { - CStdString path = item.GetPath(); + std::string path = item.GetPath(); if (item.HasVideoInfoTag() && !item.GetVideoInfoTag()->GetPath().empty()) { path = item.GetVideoInfoTag()->GetPath(); } else if (item.HasMusicInfoTag() && !item.GetMusicInfoTag()->GetURL().empty()) { @@ -567,9 +567,9 @@ BuildObject(CFileItem& item, // set a title for the object if (object->m_Title.IsEmpty()) { if (!item.GetLabel().empty()) { - CStdString title = item.GetLabel(); + std::string title = item.GetLabel(); if (item.IsPlayList() || !item.m_bIsFolder) URIUtils::RemoveExtension(title); - object->m_Title = title; + object->m_Title = title.c_str(); } } @@ -616,15 +616,15 @@ BuildObject(CFileItem& item, /*---------------------------------------------------------------------- | CUPnPServer::CorrectAllItemsSortHack +---------------------------------------------------------------------*/ -const CStdString& -CorrectAllItemsSortHack(const CStdString &item) +const std::string& +CorrectAllItemsSortHack(const std::string &item) { // This is required as in order for the "* All Albums" etc. items to sort // correctly, they must have fake artist/album etc. information generated. // This looks nasty if we attempt to render it to the GUI, thus this (further) // workaround if ((item.size() == 1 && item[0] == 0x01) || (item.size() > 1 && ((unsigned char) item[1]) == 0xff)) - return StringUtils::EmptyString; + return StringUtils::Empty; return item; } @@ -984,7 +984,7 @@ bool GetResource(const PLT_MediaObject* entry, CFileItem& item) { if(info.Match(PLT_ProtocolInfo("*", "*", allowed[type], "*"))) { - CStdString prop = StringUtils::Format("subtitle:%d", ++subs); + std::string prop = StringUtils::Format("subtitle:%d", ++subs); item.SetProperty(prop, (const char*)res.m_Uri); break; } diff --git a/xbmc/network/upnp/UPnPInternal.h b/xbmc/network/upnp/UPnPInternal.h index f0bbf991a5dbe..a76f904d74849 100644 --- a/xbmc/network/upnp/UPnPInternal.h +++ b/xbmc/network/upnp/UPnPInternal.h @@ -23,8 +23,8 @@ #include #include "system.h" -#include "utils/StdString.h" #include "FileItem.h" +#include class CUPnPServer; class CFileItem; @@ -82,7 +82,7 @@ namespace UPNP const NPT_String GetProtocolInfo(const CFileItem& item, const char* protocol, const PLT_HttpRequestContext* context = NULL); - const CStdString& CorrectAllItemsSortHack(const CStdString &item); + const std::string& CorrectAllItemsSortHack(const std::string &item); NPT_Result PopulateTagFromObject(MUSIC_INFO::CMusicInfoTag& tag, PLT_MediaObject& object, diff --git a/xbmc/network/upnp/UPnPPlayer.h b/xbmc/network/upnp/UPnPPlayer.h index 7e20b86c4c2c7..c10b5d5dff9ae 100644 --- a/xbmc/network/upnp/UPnPPlayer.h +++ b/xbmc/network/upnp/UPnPPlayer.h @@ -20,6 +20,7 @@ */ #include "cores/IPlayer.h" +#include class PLT_MediaController; class CGUIDialogBusy; diff --git a/xbmc/network/upnp/UPnPRenderer.cpp b/xbmc/network/upnp/UPnPRenderer.cpp index 7aeb034ead991..39552bdc26820 100644 --- a/xbmc/network/upnp/UPnPRenderer.cpp +++ b/xbmc/network/upnp/UPnPRenderer.cpp @@ -214,7 +214,7 @@ CUPnPRenderer::ProcessHttpGetRequest(NPT_HttpRequest& request, } // open the file - CStdString path (CURL::Decode((const char*) filepath)); + std::string path (CURL::Decode((const char*) filepath)); NPT_File file(path.c_str()); NPT_Result result = file.Open(NPT_FILE_OPEN_MODE_READ); if (NPT_FAILED(result)) { @@ -277,7 +277,7 @@ CUPnPRenderer::Announce(AnnouncementFlag flag, const char *sender, const char *m if (NPT_FAILED(FindServiceByType("urn:schemas-upnp-org:service:RenderingControl:1", rct))) return; - CStdString buffer; + std::string buffer; buffer = StringUtils::Format("%" PRId64, data["volume"].asInteger()); rct->SetStateVariable("Volume", buffer.c_str()); @@ -314,7 +314,7 @@ CUPnPRenderer::UpdateState() avt->SetStateVariable("NumberOfTracks", "1"); avt->SetStateVariable("CurrentTrack", "1"); - CStdString buffer = g_infoManager.GetCurrentPlayTime(TIME_FORMAT_HH_MM_SS); + std::string buffer = g_infoManager.GetCurrentPlayTime(TIME_FORMAT_HH_MM_SS); avt->SetStateVariable("RelativeTimePosition", buffer.c_str()); avt->SetStateVariable("AbsoluteTimePosition", buffer.c_str()); @@ -337,7 +337,7 @@ CUPnPRenderer::UpdateState() CGUIWindowSlideShow *slideshow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW); if (slideshow) { - CStdString index; + std::string index; index = StringUtils::Format("%d", slideshow->NumSlides()); avt->SetStateVariable("NumberOfTracks", index.c_str()); index = StringUtils::Format("%d", slideshow->CurrentSlide()); @@ -403,7 +403,7 @@ CUPnPRenderer::GetMetadata(NPT_String& meta) PLT_MediaObject* object = BuildObject(item, file_path, false, thumb_loader); if (object) { // fetch the item's artwork - CStdString thumb; + std::string thumb; if (object->m_ObjectClass.type == "object.item.audioItem.musicTrack") thumb = g_infoManager.GetImage(MUSICPLAYER_COVER, -1); else diff --git a/xbmc/network/upnp/UPnPServer.cpp b/xbmc/network/upnp/UPnPServer.cpp index 20e3bf5ab2ccc..60c4a9e7c90b9 100644 --- a/xbmc/network/upnp/UPnPServer.cpp +++ b/xbmc/network/upnp/UPnPServer.cpp @@ -230,10 +230,10 @@ NPT_String CUPnPServer::BuildSafeResourceUri(const NPT_HttpUrl &rooturi, const char* file_path) { CURL url(file_path); - CStdString md5; + std::string md5; // determine the filename to provide context to md5'd urls - CStdString filename; + std::string filename; if (url.IsProtocol("image")) filename = URIUtils::GetFileName(url.GetHostName()); else @@ -323,7 +323,7 @@ CUPnPServer::Build(CFileItemPtr item, if (item->GetLabel().empty()) { /* if no label try to grab it from node type */ - CStdString label; + std::string label; if (CMusicDatabaseDirectory::GetLabel((const char*)path, label)) { item->SetLabel(label); item->SetLabelPreformated(true); @@ -367,7 +367,7 @@ CUPnPServer::Build(CFileItemPtr item, // try to grab it from the folder if (item->GetLabel().empty()) { - CStdString label; + std::string label; if (CVideoDatabaseDirectory::GetLabel((const char*)path, label)) { item->SetLabel(label); item->SetLabelPreformated(true); @@ -559,7 +559,7 @@ CUPnPServer::OnBrowseMetadata(PLT_ActionReference& action, item.reset(new CFileItem((const char*)id, CDirectory::Exists((const char*)id))); // attempt to determine the parent of this item - CStdString parent; + std::string parent; if (URIUtils::IsVideoDb((const char*)id) || URIUtils::IsMusicDb((const char*)id) || StringUtils::StartsWithNoCase((const char*)id, "library://video/")) { if (!URIUtils::GetParentPath((const char*)id, parent)) { parent = "0"; @@ -572,7 +572,7 @@ CUPnPServer::OnBrowseMetadata(PLT_ActionReference& action, // or could handle this in URIUtils::GetParentPath() possibly, // however this is quicker to implement and subsequently purge when a // better solution presents itself - CStdString child_id((const char*)id); + std::string child_id((const char*)id); if (StringUtils::StartsWithNoCase(child_id, "special://musicplaylists/")) parent = "musicdb://"; else if (StringUtils::StartsWithNoCase(child_id, "special://videoplaylists/")) parent = "library://video/"; else if (StringUtils::StartsWithNoCase(child_id, "sources://video/")) parent = "library://video/"; @@ -640,7 +640,7 @@ CUPnPServer::OnBrowseDirectChildren(PLT_ActionReference& action, return NPT_FAILURE; } - items.SetPath(CStdString(parent_id)); + items.SetPath(std::string(parent_id)); // guard against loading while saving to the same cache file // as CArchive currently performs no locking itself @@ -894,8 +894,7 @@ CUPnPServer::OnSearchContainer(PLT_ActionReference& action, if (genre.GetLength() > 0) { // all tracks by genre filtered by artist and/or album - CStdString strPath; - strPath = StringUtils::Format("musicdb://genres/%i/%i/%i/", + std::string strPath = StringUtils::Format("musicdb://genres/%i/%i/%i/", database.GetGenreByName((const char*)genre), database.GetArtistByName((const char*)artist), // will return -1 if no artist database.GetAlbumByName((const char*)album)); // will return -1 if no album @@ -903,15 +902,14 @@ CUPnPServer::OnSearchContainer(PLT_ActionReference& action, return OnBrowseDirectChildren(action, strPath.c_str(), filter, starting_index, requested_count, sort_criteria, context); } else if (artist.GetLength() > 0) { // all tracks by artist name filtered by album if passed - CStdString strPath; - strPath = StringUtils::Format("musicdb://artists/%i/%i/", + std::string strPath = StringUtils::Format("musicdb://artists/%i/%i/", database.GetArtistByName((const char*)artist), database.GetAlbumByName((const char*)album)); // will return -1 if no album return OnBrowseDirectChildren(action, strPath.c_str(), filter, starting_index, requested_count, sort_criteria, context); } else if (album.GetLength() > 0) { // all tracks by album name - CStdString strPath = StringUtils::Format("musicdb://albums/%i/", + std::string strPath = StringUtils::Format("musicdb://albums/%i/", database.GetAlbumByName((const char*)album)); return OnBrowseDirectChildren(action, strPath.c_str(), filter, starting_index, requested_count, sort_criteria, context); @@ -934,12 +932,12 @@ CUPnPServer::OnSearchContainer(PLT_ActionReference& action, database.Open(); if (genre.GetLength() > 0) { - CStdString strPath = StringUtils::Format("musicdb://genres/%i/%i/", + std::string strPath = StringUtils::Format("musicdb://genres/%i/%i/", database.GetGenreByName((const char*)genre), database.GetArtistByName((const char*)artist)); // no artist should return -1 return OnBrowseDirectChildren(action, strPath.c_str(), filter, starting_index, requested_count, sort_criteria, context); } else if (artist.GetLength() > 0) { - CStdString strPath = StringUtils::Format("musicdb://artists/%i/", + std::string strPath = StringUtils::Format("musicdb://artists/%i/", database.GetArtistByName((const char*)artist)); return OnBrowseDirectChildren(action, strPath.c_str(), filter, starting_index, requested_count, sort_criteria, context); } @@ -952,7 +950,7 @@ CUPnPServer::OnSearchContainer(PLT_ActionReference& action, if (genre.GetLength() > 0) { CMusicDatabase database; database.Open(); - CStdString strPath = StringUtils::Format("musicdb://genres/%i/", database.GetGenreByName((const char*)genre)); + std::string strPath = StringUtils::Format("musicdb://genres/%i/", database.GetGenreByName((const char*)genre)); return OnBrowseDirectChildren(action, strPath.c_str(), filter, starting_index, requested_count, sort_criteria, context); } return OnBrowseDirectChildren(action, "musicdb://artists/", filter, starting_index, requested_count, sort_criteria, context); @@ -1009,7 +1007,7 @@ CUPnPServer::OnUpdateObject(PLT_ActionReference& action, NPT_Map& new_vals, const PLT_HttpRequestContext& context) { - CStdString path(CURL::Decode(object_id)); + std::string path(CURL::Decode(object_id)); CFileItem updated; updated.SetPath(path); CLog::Log(LOGINFO, "UPnP: OnUpdateObject: %s from %s", path.c_str(), @@ -1047,7 +1045,7 @@ CUPnPServer::OnUpdateObject(PLT_ActionReference& action, goto failure; } - CStdString file_path; + std::string file_path; db.GetFilePathById(id, file_path, content_type); CVideoInfoTag tag; db.LoadVideoInfo(file_path, tag); @@ -1174,7 +1172,7 @@ CUPnPServer::ServeFile(const NPT_HttpRequest& request, NPT_List::Iterator url = files.GetFirstItem(); for (;url;url++) { - output += "#EXTINF:-1," + URIUtils::GetFileName((const char*)*url); + output += ("#EXTINF:-1," + URIUtils::GetFileName((const char*)*url)).c_str(); output += "\r\n"; output += BuildSafeResourceUri( rooturi, @@ -1190,7 +1188,7 @@ CUPnPServer::ServeFile(const NPT_HttpRequest& request, if(URIUtils::IsURL((const char*)file_path)) { - CStdString disp = "inline; filename=\"" + URIUtils::GetFileName((const char*)file_path) + "\""; + std::string disp = "inline; filename=\"" + URIUtils::GetFileName((const char*)file_path) + "\""; response.GetHeaders().SetHeader("Content-Disposition", disp.c_str()); } @@ -1212,7 +1210,7 @@ CUPnPServer::ServeFile(const NPT_HttpRequest& request, bool CUPnPServer::SortItems(CFileItemList& items, const char* sort_criteria) { - CStdString criteria(sort_criteria); + std::string criteria(sort_criteria); if (criteria.empty()) { return false; } @@ -1223,47 +1221,48 @@ CUPnPServer::SortItems(CFileItemList& items, const char* sort_criteria) SortDescription sorting; /* Platinum guarantees 1st char is - or + */ sorting.sortOrder = StringUtils::StartsWith(*itr, "+") ? SortOrderAscending : SortOrderDescending; - CStdString method = itr->substr(1); + std::string method = itr->substr(1); /* resource specific */ - if (method.Equals("res@duration")) + if (StringUtils::EqualsNoCase(method, "res@duration")) sorting.sortBy = SortByTime; - else if (method.Equals("res@size")) + else if (StringUtils::EqualsNoCase(method, "res@size")) sorting.sortBy = SortBySize; - else if (method.Equals("res@bitrate")) + else if (StringUtils::EqualsNoCase(method, "res@bitrate")) sorting.sortBy = SortByBitrate; /* dc: */ - else if (method.Equals("dc:date")) + else if (StringUtils::EqualsNoCase(method, "dc:date")) sorting.sortBy = SortByDate; - else if (method.Equals("dc:title")) + else if (StringUtils::EqualsNoCase(method, "dc:title")) { sorting.sortBy = SortByTitle; sorting.sortAttributes = SortAttributeIgnoreArticle; } /* upnp: */ - else if (method.Equals("upnp:album")) + else if (StringUtils::EqualsNoCase(method, "upnp:album")) sorting.sortBy = SortByAlbum; - else if (method.Equals("upnp:artist") || method.Equals("upnp:albumArtist")) + else if (StringUtils::EqualsNoCase(method, "upnp:artist") || + StringUtils::EqualsNoCase(method, "upnp:albumArtist")) sorting.sortBy = SortByArtist; - else if (method.Equals("upnp:episodeNumber")) + else if (StringUtils::EqualsNoCase(method, "upnp:episodeNumber")) sorting.sortBy = SortByEpisodeNumber; - else if (method.Equals("upnp:episodeCount")) + else if (StringUtils::EqualsNoCase(method, "upnp:episodeCount")) sorting.sortBy = SortByNumberOfEpisodes; - else if (method.Equals("upnp:episodeSeason")) + else if (StringUtils::EqualsNoCase(method, "upnp:episodeSeason")) sorting.sortBy = SortBySeason; - else if (method.Equals("upnp:genre")) + else if (StringUtils::EqualsNoCase(method, "upnp:genre")) sorting.sortBy = SortByGenre; - else if (method.Equals("upnp:originalTrackNumber")) + else if (StringUtils::EqualsNoCase(method, "upnp:originalTrackNumber")) sorting.sortBy = SortByTrackNumber; - else if(method.Equals("upnp:rating")) + else if(StringUtils::EqualsNoCase(method, "upnp:rating")) sorting.sortBy = SortByMPAA; - else if (method.Equals("xbmc:rating")) + else if (StringUtils::EqualsNoCase(method, "xbmc:rating")) sorting.sortBy = SortByRating; - else if (method.Equals("xbmc:dateadded")) + else if (StringUtils::EqualsNoCase(method, "xbmc:dateadded")) sorting.sortBy = SortByDateAdded; - else if (method.Equals("xbmc:votes")) + else if (StringUtils::EqualsNoCase(method, "xbmc:votes")) sorting.sortBy = SortByVotes; else { CLog::Log(LOGINFO, "UPnP: unsupported sort criteria '%s' passed", method.c_str());