bool CFavouritesDirectory::Save(const CFileItemList &items) { std::string favourites; CXBMCTinyXML doc; TiXmlElement xmlRootElement("favourites"); TiXmlNode *rootNode = doc.InsertEndChild(xmlRootElement); if (!rootNode) return false; for (int i = 0; i < items.Size(); i++) { const CFileItemPtr item = items[i]; TiXmlElement favNode("favourite"); favNode.SetAttribute("name", item->GetLabel().c_str()); if (item->HasArt("thumb")) favNode.SetAttribute("thumb", item->GetArt("thumb").c_str()); TiXmlText execute(item->GetPath()); favNode.InsertEndChild(execute); rootNode->InsertEndChild(favNode); } favourites = URIUtils::AddFileToFolder(CProfilesManager::GetInstance().GetProfileUserDataFolder(), "favourites.xml"); bool bRet = doc.SaveFile(favourites); if (bRet) ANNOUNCEMENT::CAnnouncementManager::GetInstance().Announce(ANNOUNCEMENT::GUI, "xbmc", "OnFavouritesUpdated"); return bRet; }
bool CFavourites::Save(const CFileItemList &items) { CStdString favourites; CXBMCTinyXML doc; TiXmlElement xmlRootElement("favourites"); TiXmlNode *rootNode = doc.InsertEndChild(xmlRootElement); if (!rootNode) return false; for (int i = 0; i < items.Size(); i++) { const CFileItemPtr item = items[i]; TiXmlElement favNode("favourite"); favNode.SetAttribute("name", item->GetLabel().c_str()); if (item->HasThumbnail()) favNode.SetAttribute("thumb", item->GetThumbnailImage().c_str()); TiXmlText execute(item->GetPath()); favNode.InsertEndChild(execute); rootNode->InsertEndChild(favNode); } URIUtils::AddFileToFolder(g_settings.GetProfileUserDataFolder(), "favourites.xml", favourites); return doc.SaveFile(favourites); }
bool CFavouritesService::Persist() { CXBMCTinyXML doc; TiXmlElement xmlRootElement("favourites"); TiXmlNode *rootNode = doc.InsertEndChild(xmlRootElement); if (!rootNode) return false; for (const auto& item : m_favourites) { TiXmlElement favNode("favourite"); favNode.SetAttribute("name", item->GetLabel().c_str()); if (item->HasArt("thumb")) favNode.SetAttribute("thumb", item->GetArt("thumb").c_str()); const CURL url(item->GetPath()); TiXmlText execute(CURL::Decode(url.GetHostName())); favNode.InsertEndChild(execute); rootNode->InsertEndChild(favNode); } auto path = URIUtils::AddFileToFolder(m_userDataFolder, "favourites.xml"); return doc.SaveFile(path); }