Backed out changeset 81af786a3574 (Temporary favorites fix) for merge
parent
20ed11968d
commit
f7966ea93d
|
|
@ -385,9 +385,11 @@ LLFavoritesBarCtrl::LLFavoritesBarCtrl(const LLFavoritesBarCtrl::Params& p)
|
|||
mShowDragMarker(FALSE),
|
||||
mLandingTab(NULL),
|
||||
mLastTab(NULL),
|
||||
mTabsHighlightEnabled(TRUE)
|
||||
, mUpdateDropDownItems(true)
|
||||
, mRestoreOverflowMenu(false)
|
||||
mTabsHighlightEnabled(TRUE),
|
||||
mUpdateDropDownItems(true),
|
||||
mRestoreOverflowMenu(false),
|
||||
mGetPrevItems(true),
|
||||
mItemsChangedTimer()
|
||||
{
|
||||
// Register callback for menus with current registrar (will be parent panel's registrar)
|
||||
LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Favorites.DoToSelected",
|
||||
|
|
@ -680,6 +682,15 @@ void LLFavoritesBarCtrl::changed(U32 mask)
|
|||
LLFavoritesOrderStorage::instance().getSLURL((*i)->getAssetUUID());
|
||||
}
|
||||
updateButtons();
|
||||
if (!mItemsChangedTimer.getStarted())
|
||||
{
|
||||
mItemsChangedTimer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
mItemsChangedTimer.reset();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -714,6 +725,21 @@ void LLFavoritesBarCtrl::draw()
|
|||
// Once drawn, mark this false so we won't draw it again (unless we hit the favorite bar again)
|
||||
mShowDragMarker = FALSE;
|
||||
}
|
||||
if (mItemsChangedTimer.getStarted())
|
||||
{
|
||||
if (mItemsChangedTimer.getElapsedTimeF32() > 1.f)
|
||||
{
|
||||
LLFavoritesOrderStorage::instance().saveFavoritesRecord();
|
||||
mItemsChangedTimer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
if(!mItemsChangedTimer.getStarted() && LLFavoritesOrderStorage::instance().mUpdateRequired)
|
||||
{
|
||||
LLFavoritesOrderStorage::instance().mUpdateRequired = false;
|
||||
mItemsChangedTimer.start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const LLButton::Params& LLFavoritesBarCtrl::getButtonParams()
|
||||
|
|
@ -744,6 +770,12 @@ void LLFavoritesBarCtrl::updateButtons()
|
|||
return;
|
||||
}
|
||||
|
||||
if(mGetPrevItems)
|
||||
{
|
||||
LLFavoritesOrderStorage::instance().mPrevFavorites = mItems;
|
||||
mGetPrevItems = false;
|
||||
}
|
||||
|
||||
const LLButton::Params& button_params = getButtonParams();
|
||||
|
||||
if(mItems.empty())
|
||||
|
|
@ -883,6 +915,7 @@ void LLFavoritesBarCtrl::updateButtons()
|
|||
{
|
||||
mUpdateDropDownItems = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LLButton* LLFavoritesBarCtrl::createButton(const LLPointer<LLViewerInventoryItem> item, const LLButton::Params& button_params, S32 x_offset)
|
||||
|
|
@ -954,9 +987,11 @@ BOOL LLFavoritesBarCtrl::postBuild()
|
|||
|
||||
BOOL LLFavoritesBarCtrl::collectFavoriteItems(LLInventoryModel::item_array_t &items)
|
||||
{
|
||||
|
||||
if (mFavoriteFolderId.isNull())
|
||||
return FALSE;
|
||||
|
||||
|
||||
LLInventoryModel::cat_array_t cats;
|
||||
|
||||
LLIsType is_type(LLAssetType::AT_LANDMARK);
|
||||
|
|
@ -1466,6 +1501,7 @@ void LLFavoritesBarCtrl::insertItem(LLInventoryModel::item_array_t& items, const
|
|||
|
||||
const std::string LLFavoritesOrderStorage::SORTING_DATA_FILE_NAME = "landmarks_sorting.xml";
|
||||
const S32 LLFavoritesOrderStorage::NO_INDEX = -1;
|
||||
bool LLFavoritesOrderStorage::mSaveOnExit = false;
|
||||
|
||||
void LLFavoritesOrderStorage::setSortIndex(const LLViewerInventoryItem* inv_item, S32 sort_index)
|
||||
{
|
||||
|
|
@ -1502,19 +1538,23 @@ void LLFavoritesOrderStorage::getSLURL(const LLUUID& asset_id)
|
|||
LL_DEBUGS("FavoritesBar") << "landmark for " << asset_id << " already loaded" << LL_ENDL;
|
||||
onLandmarkLoaded(asset_id, lm);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// static
|
||||
std::string LLFavoritesOrderStorage::getStoredFavoritesFilename()
|
||||
{
|
||||
std::string user_dir = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "");
|
||||
// <FS:Ansariel> Favorites are stored in username.grid folder
|
||||
//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()
|
||||
+ ".xml")
|
||||
);
|
||||
// return (user_dir.empty() ? ""
|
||||
// : gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,
|
||||
// "stored_favorites_"
|
||||
// + LLGridManager::getInstance()->getGrid()
|
||||
// + ".xml")
|
||||
// );
|
||||
return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "stored_favorites.xml");
|
||||
// <FS:Ansariel>
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
@ -1536,15 +1576,19 @@ void LLFavoritesOrderStorage::destroyClass()
|
|||
// LLFile::copy(old_filename,new_filename);
|
||||
// LLFile::remove(old_filename);
|
||||
//}
|
||||
llifstream file;
|
||||
// </FS:Ansariel>
|
||||
|
||||
if (gSavedPerAccountSettings.getBOOL("ShowFavoritesOnLogin"))
|
||||
std::string filename = getSavedOrderFileName();
|
||||
file.open(filename.c_str());
|
||||
if (file.is_open())
|
||||
{
|
||||
LLFavoritesOrderStorage::instance().saveFavoritesSLURLs();
|
||||
}
|
||||
else
|
||||
{
|
||||
LLFavoritesOrderStorage::instance().removeFavoritesRecordOfUser();
|
||||
file.close();
|
||||
LLFile::remove(filename);
|
||||
if(mSaveOnExit)
|
||||
{
|
||||
LLFavoritesOrderStorage::instance().saveFavoritesRecord(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1559,124 +1603,66 @@ std::string LLFavoritesOrderStorage::getSavedOrderFileName()
|
|||
|
||||
void LLFavoritesOrderStorage::load()
|
||||
{
|
||||
// load per-resident sorting information
|
||||
std::string filename = getSavedOrderFileName();
|
||||
|
||||
LLSD settings_llsd;
|
||||
llifstream file;
|
||||
file.open(filename.c_str());
|
||||
if (file.is_open())
|
||||
{
|
||||
LLSDSerialize::fromXML(settings_llsd, file);
|
||||
LL_INFOS("FavoritesBar") << "loaded favorites order from '" << filename << "' "
|
||||
<< (settings_llsd.isMap() ? "" : "un") << "successfully"
|
||||
<< LL_ENDL;
|
||||
file.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_WARNS("FavoritesBar") << "unable to open favorites order file at '" << filename << "'" << LL_ENDL;
|
||||
}
|
||||
LL_INFOS("FavoritesBar") << "loaded favorites order from '" << filename << "' "
|
||||
<< (settings_llsd.isMap() ? "" : "un") << "successfully"
|
||||
<< LL_ENDL;
|
||||
file.close();
|
||||
mSaveOnExit = true;
|
||||
|
||||
for (LLSD::map_const_iterator iter = settings_llsd.beginMap();
|
||||
iter != settings_llsd.endMap(); ++iter)
|
||||
for (LLSD::map_const_iterator iter = settings_llsd.beginMap();
|
||||
iter != settings_llsd.endMap(); ++iter)
|
||||
{
|
||||
mSortIndexes.insert(std::make_pair(LLUUID(iter->first), (S32)iter->second.asInteger()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mSortIndexes.insert(std::make_pair(LLUUID(iter->first), (S32)iter->second.asInteger()));
|
||||
filename = getStoredFavoritesFilename();
|
||||
if (!filename.empty())
|
||||
{
|
||||
llifstream in_file;
|
||||
in_file.open(filename.c_str());
|
||||
LLSD fav_llsd;
|
||||
LLSD user_llsd;
|
||||
if (in_file.is_open())
|
||||
{
|
||||
LLSDSerialize::fromXML(fav_llsd, in_file);
|
||||
LL_INFOS("FavoritesBar") << "loaded favorites from '" << filename << "' "
|
||||
<< (fav_llsd.isMap() ? "" : "un") << "successfully"
|
||||
<< LL_ENDL;
|
||||
in_file.close();
|
||||
// <FS:Ansariel> FIRE-10122 - User@grid stored_favorites.xml
|
||||
//user_llsd = fav_llsd[gAgentUsername];
|
||||
user_llsd = fav_llsd[gAgentUsername + " @ " + LLGridManager::getInstance()->getGridLabel()];
|
||||
// </FS:Ansariel>
|
||||
|
||||
S32 index = 0;
|
||||
for (LLSD::array_iterator iter = user_llsd.beginArray();
|
||||
iter != user_llsd.endArray(); ++iter)
|
||||
{
|
||||
mSortIndexes.insert(std::make_pair(iter->get("id").asUUID(), index));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
LL_WARNS("FavoritesBar") << "unable to open favorites from '" << filename << "'" << LL_ENDL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LLFavoritesOrderStorage::saveFavoritesSLURLs()
|
||||
{
|
||||
// Do not change the file if we are not logged in yet.
|
||||
if (!LLLoginInstance::getInstance()->authSuccess())
|
||||
{
|
||||
LL_WARNS("FavoritesBar") << "Cannot save favorites: not logged in" << LL_ENDL;
|
||||
return;
|
||||
}
|
||||
|
||||
// <FS:Ansariel> Favorites are stored in username.grid folder
|
||||
// std::string filename = getStoredFavoritesFilename();
|
||||
std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "stored_favorites.xml");
|
||||
// </FS:Ansariel>
|
||||
if (!filename.empty())
|
||||
{
|
||||
llifstream in_file;
|
||||
in_file.open(filename.c_str());
|
||||
LLSD fav_llsd;
|
||||
if (in_file.is_open())
|
||||
{
|
||||
LLSDSerialize::fromXML(fav_llsd, in_file);
|
||||
LL_INFOS("FavoritesBar") << "loaded favorites from '" << filename << "' "
|
||||
<< (fav_llsd.isMap() ? "" : "un") << "successfully"
|
||||
<< LL_ENDL;
|
||||
in_file.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_WARNS("FavoritesBar") << "unable to open favorites from '" << filename << "'" << LL_ENDL;
|
||||
}
|
||||
|
||||
const LLUUID fav_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
|
||||
LLInventoryModel::cat_array_t cats;
|
||||
LLInventoryModel::item_array_t items;
|
||||
gInventory.collectDescendents(fav_id, cats, items, LLInventoryModel::EXCLUDE_TRASH);
|
||||
|
||||
LLSD user_llsd;
|
||||
for (LLInventoryModel::item_array_t::iterator it = items.begin(); it != items.end(); it++)
|
||||
{
|
||||
LLSD value;
|
||||
value["name"] = (*it)->getName();
|
||||
value["asset_id"] = (*it)->getAssetUUID();
|
||||
|
||||
slurls_map_t::iterator slurl_iter = mSLURLs.find(value["asset_id"]);
|
||||
if (slurl_iter != mSLURLs.end())
|
||||
{
|
||||
LL_DEBUGS("FavoritesBar") << "Saving favorite: idx=" << LLFavoritesOrderStorage::instance().getSortIndex((*it)->getUUID()) << ", SLURL=" << slurl_iter->second << ", value=" << value << LL_ENDL;
|
||||
value["slurl"] = slurl_iter->second;
|
||||
user_llsd[LLFavoritesOrderStorage::instance().getSortIndex((*it)->getUUID())] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_WARNS("FavoritesBar") << "Not saving favorite " << value["name"] << ": no matching SLURL" << LL_ENDL;
|
||||
}
|
||||
}
|
||||
|
||||
LLAvatarName av_name;
|
||||
LLAvatarNameCache::get( gAgentID, &av_name );
|
||||
// Note : use the "John Doe" and not the "john.doe" version of the name
|
||||
// as we'll compare it with the stored credentials in the login panel.
|
||||
// <FS:CR> FIRE-10122 - User@grid stored_favorites.xml
|
||||
//fav_llsd[av_name.getUserName()] = user_llsd;
|
||||
std::string name = av_name.getUserName() + " @ " + LLGridManager::getInstance()->getGridLabel();
|
||||
LL_DEBUGS("Favorites") << "Saved favorites for " << name << LL_ENDL;
|
||||
fav_llsd[name] = user_llsd;
|
||||
// </FS:CR>
|
||||
|
||||
llofstream file;
|
||||
file.open(filename.c_str());
|
||||
if ( file.is_open() )
|
||||
{
|
||||
LLSDSerialize::toPrettyXML(fav_llsd, file);
|
||||
LL_INFOS("FavoritesBar") << "saved favorites for '" << av_name.getUserName()
|
||||
<< "' to '" << filename << "' "
|
||||
<< LL_ENDL;
|
||||
file.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_WARNS("FavoritesBar") << "unable to open favorites storage for '" << av_name.getUserName()
|
||||
<< "' at '" << filename << "' "
|
||||
<< LL_ENDL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LLFavoritesOrderStorage::removeFavoritesRecordOfUser()
|
||||
{
|
||||
// <FS:Ansariel> Favorites are stored in username.grid folder
|
||||
// std::string filename = getStoredFavoritesFilename();
|
||||
std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "stored_favorites.xml");
|
||||
// </FS:Ansariel>
|
||||
std::string filename = getStoredFavoritesFilename();
|
||||
if (!filename.empty())
|
||||
{
|
||||
LLSD fav_llsd;
|
||||
|
|
@ -1691,19 +1677,46 @@ void LLFavoritesOrderStorage::removeFavoritesRecordOfUser()
|
|||
LLAvatarNameCache::get( gAgentID, &av_name );
|
||||
// Note : use the "John Doe" and not the "john.doe" version of the name.
|
||||
// See saveFavoritesSLURLs() here above for the reason why.
|
||||
// <FS:CR> FIRE-10122 - User@grid stored_favorites.xml
|
||||
// if (fav_llsd.has(av_name.getUserName()))
|
||||
// <FS:CR> FIRE-10122 - User@grid stored_favorites.xml
|
||||
//if (fav_llsd.has(av_name.getUserName()))
|
||||
//{
|
||||
// LL_INFOS("FavoritesBar") << "Removed favorites for " << av_name.getUserName() << LL_ENDL;
|
||||
// fav_llsd.erase(av_name.getUserName());
|
||||
//}
|
||||
std::string name = av_name.getUserName() + " @ " + LLGridManager::getInstance()->getGridLabel();
|
||||
LL_DEBUGS("Favorites") << "Removed favorites for " << name << LL_ENDL;
|
||||
if (fav_llsd.has(name))
|
||||
{
|
||||
fav_llsd.erase(name);
|
||||
}
|
||||
// </FS:CR>
|
||||
// LLSD user_llsd = fav_llsd[av_name.getUserName()];
|
||||
std::string name = av_name.getUserName() + " @ " + LLGridManager::getInstance()->getGridLabel();
|
||||
if (fav_llsd.has(name))
|
||||
{
|
||||
LLSD user_llsd = fav_llsd[name];
|
||||
// </FS:CR>
|
||||
|
||||
if (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);
|
||||
}
|
||||
// <FS:CR> FIRE-10122 - User@grid stored_favorites.xml
|
||||
//fav_llsd[av_name.getUserName()] = user_llsd;
|
||||
fav_llsd[name] = user_llsd;
|
||||
// </FS:CR> FIRE-10122
|
||||
llofstream file;
|
||||
file.open(filename.c_str());
|
||||
if ( file.is_open() )
|
||||
{
|
||||
LLSDSerialize::toPrettyXML(fav_llsd, file);
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// <FS:CR> FIRE-10122 - User@grid stored_favorites.xml
|
||||
//LL_INFOS("FavoritesBar") << "Removed favorites for " << av_name.getUserName() << LL_ENDL;
|
||||
//fav_llsd.erase(av_name.getUserName());
|
||||
LL_INFOS("FavoritesBar") << "Removed favorites for " << name << LL_ENDL;
|
||||
fav_llsd.erase(name);
|
||||
// </FS:CR> FIRE-10122
|
||||
}
|
||||
}
|
||||
|
||||
llofstream out_file;
|
||||
out_file.open(filename.c_str());
|
||||
|
|
@ -1723,20 +1736,20 @@ void LLFavoritesOrderStorage::onLandmarkLoaded(const LLUUID& asset_id, LLLandmar
|
|||
if (landmark)
|
||||
{
|
||||
LL_DEBUGS("FavoritesBar") << "landmark for " << asset_id << " loaded" << LL_ENDL;
|
||||
LLVector3d pos_global;
|
||||
if (!landmark->getGlobalPos(pos_global))
|
||||
{
|
||||
// If global position was unknown on first getGlobalPos() call
|
||||
// it should be set for the subsequent calls.
|
||||
landmark->getGlobalPos(pos_global);
|
||||
}
|
||||
LLVector3d pos_global;
|
||||
if (!landmark->getGlobalPos(pos_global))
|
||||
{
|
||||
// If global position was unknown on first getGlobalPos() call
|
||||
// it should be set for the subsequent calls.
|
||||
landmark->getGlobalPos(pos_global);
|
||||
}
|
||||
|
||||
if (!pos_global.isExactlyZero())
|
||||
{
|
||||
LL_DEBUGS("FavoritesBar") << "requesting slurl for landmark " << asset_id << LL_ENDL;
|
||||
LLLandmarkActions::getSLURLfromPosGlobal(pos_global,
|
||||
if (!pos_global.isExactlyZero())
|
||||
{
|
||||
LL_DEBUGS("FavoritesBar") << "requesting slurl for landmark " << asset_id << LL_ENDL;
|
||||
LLLandmarkActions::getSLURLfromPosGlobal(pos_global,
|
||||
boost::bind(&LLFavoritesOrderStorage::storeFavoriteSLURL, this, asset_id, _1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1746,41 +1759,6 @@ void LLFavoritesOrderStorage::storeFavoriteSLURL(const LLUUID& asset_id, std::st
|
|||
mSLURLs[asset_id] = slurl;
|
||||
}
|
||||
|
||||
void LLFavoritesOrderStorage::save()
|
||||
{
|
||||
if (mIsDirty)
|
||||
{
|
||||
// something changed, so save it
|
||||
std::string filename = LLFavoritesOrderStorage::getInstance()->getSavedOrderFileName();
|
||||
if (!filename.empty())
|
||||
{
|
||||
LLSD settings_llsd;
|
||||
|
||||
for(sort_index_map_t::const_iterator iter = mSortIndexes.begin(); iter != mSortIndexes.end(); ++iter)
|
||||
{
|
||||
settings_llsd[iter->first.asString()] = iter->second;
|
||||
}
|
||||
|
||||
llofstream file;
|
||||
file.open(filename.c_str());
|
||||
if ( file.is_open() )
|
||||
{
|
||||
LLSDSerialize::toPrettyXML(settings_llsd, file);
|
||||
LL_INFOS("FavoritesBar") << "saved favorites order to '" << filename << "' " << LL_ENDL;
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_WARNS("FavoritesBar") << "failed to open favorites order file '" << filename << "' " << LL_ENDL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_DEBUGS("FavoritesBar") << "no user directory available to store favorites order file" << LL_ENDL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LLFavoritesOrderStorage::cleanup()
|
||||
{
|
||||
// nothing to clean
|
||||
|
|
@ -1795,7 +1773,7 @@ void LLFavoritesOrderStorage::cleanup()
|
|||
|
||||
sort_index_map_t aTempMap;
|
||||
//copy unremoved values from mSortIndexes to aTempMap
|
||||
std::remove_copy_if(mSortIndexes.begin(), mSortIndexes.end(),
|
||||
std::remove_copy_if(mSortIndexes.begin(), mSortIndexes.end(),
|
||||
inserter(aTempMap, aTempMap.begin()),
|
||||
is_not_in_fav);
|
||||
|
||||
|
|
@ -1827,8 +1805,8 @@ void LLFavoritesOrderStorage::saveOrder()
|
|||
|
||||
void LLFavoritesOrderStorage::saveItemsOrder( const LLInventoryModel::item_array_t& items )
|
||||
{
|
||||
int sortField = 0;
|
||||
|
||||
int sortField = 0;
|
||||
// current order is saved by setting incremental values (1, 2, 3, ...) for the sort field
|
||||
for (LLInventoryModel::item_array_t::const_iterator i = items.begin(); i != items.end(); ++i)
|
||||
{
|
||||
|
|
@ -1868,6 +1846,115 @@ void LLFavoritesOrderStorage::rearrangeFavoriteLandmarks(const LLUUID& source_it
|
|||
saveItemsOrder(items);
|
||||
}
|
||||
|
||||
BOOL LLFavoritesOrderStorage::saveFavoritesRecord(bool pref_changed)
|
||||
{
|
||||
|
||||
LLUUID favorite_folder= gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
|
||||
if (favorite_folder.isNull())
|
||||
return FALSE;
|
||||
|
||||
LLInventoryModel::item_array_t items;
|
||||
LLInventoryModel::cat_array_t cats;
|
||||
|
||||
LLIsType is_type(LLAssetType::AT_LANDMARK);
|
||||
gInventory.collectDescendentsIf(favorite_folder, cats, items, LLInventoryModel::EXCLUDE_TRASH, is_type);
|
||||
|
||||
std::sort(items.begin(), items.end(), LLFavoritesSort());
|
||||
|
||||
if((items != mPrevFavorites) || pref_changed)
|
||||
{
|
||||
std::string filename = getStoredFavoritesFilename();
|
||||
if (!filename.empty())
|
||||
{
|
||||
llifstream in_file;
|
||||
in_file.open(filename.c_str());
|
||||
LLSD fav_llsd;
|
||||
if (in_file.is_open())
|
||||
{
|
||||
LLSDSerialize::fromXML(fav_llsd, in_file);
|
||||
in_file.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_WARNS("FavoritesBar") << "unable to open favorites from '" << filename << "'" << LL_ENDL;
|
||||
}
|
||||
|
||||
LLSD user_llsd;
|
||||
S32 fav_iter = 0;
|
||||
for (LLInventoryModel::item_array_t::iterator it = items.begin(); it != items.end(); it++)
|
||||
{
|
||||
LLSD value;
|
||||
if (gSavedPerAccountSettings.getBOOL("ShowFavoritesOnLogin"))
|
||||
{
|
||||
value["name"] = (*it)->getName();
|
||||
value["asset_id"] = (*it)->getAssetUUID();
|
||||
value["id"] = (*it)->getUUID();
|
||||
slurls_map_t::iterator slurl_iter = mSLURLs.find(value["asset_id"]);
|
||||
if (slurl_iter != mSLURLs.end())
|
||||
{
|
||||
value["slurl"] = slurl_iter->second;
|
||||
user_llsd[fav_iter] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
getSLURL((*it)->getAssetUUID());
|
||||
mUpdateRequired = true;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value["id"] = (*it)->getUUID();
|
||||
user_llsd[fav_iter] = value;
|
||||
}
|
||||
|
||||
fav_iter ++;
|
||||
}
|
||||
|
||||
LLAvatarName av_name;
|
||||
LLAvatarNameCache::get( gAgentID, &av_name );
|
||||
// Note : use the "John Doe" and not the "john.doe" version of the name
|
||||
// as we'll compare it with the stored credentials in the login panel.
|
||||
// <FS:CR> FIRE-10122 - User@grid stored_favorites.xml
|
||||
//fav_llsd[av_name.getUserName()] = user_llsd;
|
||||
std::string name = av_name.getUserName() + " @ " + LLGridManager::getInstance()->getGridLabel();
|
||||
LL_DEBUGS("Favorites") << "Saved favorites for " << name << LL_ENDL;
|
||||
fav_llsd[name] = user_llsd;
|
||||
// </FS:CR>
|
||||
llofstream file;
|
||||
file.open(filename.c_str());
|
||||
if ( file.is_open() )
|
||||
{
|
||||
LLSDSerialize::toPrettyXML(fav_llsd, file);
|
||||
file.close();
|
||||
mSaveOnExit = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_WARNS("FavoritesBar") << "unable to open favorites storage for '" << av_name.getUserName()
|
||||
<< "' at '" << filename << "' " << LL_ENDL;
|
||||
}
|
||||
}
|
||||
|
||||
mPrevFavorites = items;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
void LLFavoritesOrderStorage::showFavoritesOnLoginChanged(BOOL show)
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
saveFavoritesRecord(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
removeFavoritesRecordOfUser();
|
||||
}
|
||||
}
|
||||
|
||||
void AddFavoriteLandmarkCallback::fire(const LLUUID& inv_item_id)
|
||||
{
|
||||
if (mTargetLandmarkId.isNull()) return;
|
||||
|
|
|
|||
|
|
@ -108,8 +108,10 @@ protected:
|
|||
bool mUpdateDropDownItems;
|
||||
bool mRestoreOverflowMenu;
|
||||
|
||||
LLUUID mSelectedItemID;
|
||||
bool mGetPrevItems;
|
||||
|
||||
LLUUID mSelectedItemID;
|
||||
LLFrameTimer mItemsChangedTimer;
|
||||
LLUIImage* mImageDragIndication;
|
||||
|
||||
private:
|
||||
|
|
@ -211,12 +213,23 @@ public:
|
|||
* @see cleanup()
|
||||
*/
|
||||
static void destroyClass();
|
||||
static std::string getStoredFavoritesFilename();
|
||||
static std::string getSavedOrderFileName();
|
||||
|
||||
BOOL saveFavoritesRecord(bool pref_changed = false);
|
||||
void showFavoritesOnLoginChanged(BOOL show);
|
||||
|
||||
LLInventoryModel::item_array_t mPrevFavorites;
|
||||
|
||||
|
||||
const static S32 NO_INDEX;
|
||||
static bool mSaveOnExit;
|
||||
bool mUpdateRequired;
|
||||
|
||||
private:
|
||||
friend class LLSingleton<LLFavoritesOrderStorage>;
|
||||
LLFavoritesOrderStorage() : mIsDirty(false) { load(); }
|
||||
~LLFavoritesOrderStorage() { save(); }
|
||||
LLFavoritesOrderStorage() : mIsDirty(false), mUpdateRequired(false){ load(); }
|
||||
~LLFavoritesOrderStorage() {}
|
||||
|
||||
/**
|
||||
* Removes sort indexes for items which are not in Favorites bar for now.
|
||||
|
|
@ -224,13 +237,8 @@ private:
|
|||
void cleanup();
|
||||
|
||||
const static std::string SORTING_DATA_FILE_NAME;
|
||||
std::string getSavedOrderFileName();
|
||||
static std::string getStoredFavoritesFilename();
|
||||
|
||||
void load();
|
||||
void save();
|
||||
|
||||
void saveFavoritesSLURLs();
|
||||
void load();
|
||||
|
||||
// Remove record of current user's favorites from file on disk.
|
||||
void removeFavoritesRecordOfUser();
|
||||
|
|
|
|||
|
|
@ -3016,8 +3016,7 @@ void LLPanelPreference::handleFavoritesOnLoginChanged(LLUICtrl* checkbox, const
|
|||
{
|
||||
if (checkbox)
|
||||
{
|
||||
// <FS:Ansariel> FIRE-17114 / BUG-10506 / MAINT-5760: Commented out because LLFavoritesBar files have been reverted temporarily
|
||||
//LLFavoritesOrderStorage::instance().showFavoritesOnLoginChanged(checkbox->getValue().asBoolean());
|
||||
LLFavoritesOrderStorage::instance().showFavoritesOnLoginChanged(checkbox->getValue().asBoolean());
|
||||
if(checkbox->getValue())
|
||||
{
|
||||
LLNotificationsUtil::add("FavoritesOnLogin");
|
||||
|
|
|
|||
Loading…
Reference in New Issue