summaryrefslogtreecommitdiff
path: root/indra/newview/llfavoritesbar.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2020-02-05 18:30:40 +0200
committerAndrey Lihatskiy <alihatskiy@productengine.com>2020-02-05 18:30:40 +0200
commitad63fa5ffad787402fc5b414fd8f2b85f9300411 (patch)
treebf6b24238b8f4f40ee3ea584a642e75cff6fca63 /indra/newview/llfavoritesbar.cpp
parent2c7a8a2485b98ff56e6fdc431bba5ccd226ae740 (diff)
parent2998552f3d7447da316afdd1713595528596a0c5 (diff)
Merge branch 'master' into DRTVWR-460
Diffstat (limited to 'indra/newview/llfavoritesbar.cpp')
-rw-r--r--indra/newview/llfavoritesbar.cpp70
1 files changed, 67 insertions, 3 deletions
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp
index 5b4b7789b4..17952349dc 100644
--- a/indra/newview/llfavoritesbar.cpp
+++ b/indra/newview/llfavoritesbar.cpp
@@ -1493,19 +1493,25 @@ void LLFavoritesOrderStorage::getSLURL(const LLUUID& asset_id)
}
// static
-std::string LLFavoritesOrderStorage::getStoredFavoritesFilename()
+std::string LLFavoritesOrderStorage::getStoredFavoritesFilename(const std::string &grid)
{
- std::string user_dir = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "");
+ std::string user_dir = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "");
return (user_dir.empty() ? ""
: gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,
"stored_favorites_"
- + LLGridManager::getInstance()->getGrid()
+ + grid
+ ".xml")
);
}
// static
+std::string LLFavoritesOrderStorage::getStoredFavoritesFilename()
+{
+ return getStoredFavoritesFilename(LLGridManager::getInstance()->getGrid());
+}
+
+// static
void LLFavoritesOrderStorage::destroyClass()
{
LLFavoritesOrderStorage::instance().cleanup();
@@ -1602,6 +1608,64 @@ void LLFavoritesOrderStorage::load()
}
}
+// static
+void LLFavoritesOrderStorage::removeFavoritesRecordOfUser(const std::string &user, const std::string &grid)
+{
+ std::string filename = getStoredFavoritesFilename(grid);
+ if (!filename.empty())
+ {
+ LLSD fav_llsd;
+ llifstream file;
+ file.open(filename.c_str());
+ if (file.is_open())
+ {
+ LLSDSerialize::fromXML(fav_llsd, file);
+ file.close();
+
+ // Note : use the "John Doe" and not the "john.doe" version of the name.
+ // See saveFavoritesSLURLs() here above for the reason why.
+ if (fav_llsd.has(user))
+ {
+ LLSD user_llsd = fav_llsd[user];
+
+ if ((user_llsd.beginArray() != user_llsd.endArray()) && user_llsd.beginArray()->has("id"))
+ {
+ for (LLSD::array_iterator iter = user_llsd.beginArray(); iter != user_llsd.endArray(); ++iter)
+ {
+ LLSD value;
+ value["id"] = iter->get("id").asUUID();
+ iter->assign(value);
+ }
+ fav_llsd[user] = user_llsd;
+ llofstream file;
+ file.open(filename.c_str());
+ if (file.is_open())
+ {
+ LLSDSerialize::toPrettyXML(fav_llsd, file);
+ file.close();
+ }
+ }
+ else
+ {
+ LL_INFOS("FavoritesBar") << "Removed favorites for " << user << LL_ENDL;
+ fav_llsd.erase(user);
+ }
+ }
+
+ llofstream out_file;
+ out_file.open(filename.c_str());
+ if (out_file.is_open())
+ {
+ LLSDSerialize::toPrettyXML(fav_llsd, out_file);
+ LL_INFOS("FavoritesBar") << "saved favorites to '" << filename << "' "
+ << LL_ENDL;
+ out_file.close();
+ }
+ }
+ }
+}
+
+// static
void LLFavoritesOrderStorage::removeFavoritesRecordOfUser()
{
std::string filename = getStoredFavoritesFilename();