From 837f6c7cbefa7ac1c64c9506d2fabd640ae652ec Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Wed, 27 Jan 2010 17:29:44 +0200 Subject: Work on major bug EXT-3985 ([BSI] Landmarks created in Viewer 2.0 show up with 1@ in Viewer 1.23.x) -- Implemented storage to save favorite landmarks order in local file. -- Previously implemented solution to store sort index in Landmark's name replaced with using the storage. For now all landmarks are shown as is (with sort LM prefix if it exists). -- Some deprecated methods are marked to be removed later -- Reverted fixes for: EXT-4306, EXT-1237, EXT-1615 as not necessary, these bugs should be verified again. --HG-- branch : product-engine --- indra/newview/llpanelgroupnotices.cpp | 2 +- indra/newview/llpanellandmarkinfo.cpp | 1 - indra/newview/lltoastgroupnotifypanel.cpp | 12 +-- indra/newview/llviewerinventory.cpp | 142 +++++++++++++++++++++++------- indra/newview/llviewerinventory.h | 1 - indra/newview/llviewermessage.cpp | 30 ------- 6 files changed, 114 insertions(+), 74 deletions(-) diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp index 45fc3d4688..6210973dae 100644 --- a/indra/newview/llpanelgroupnotices.cpp +++ b/indra/newview/llpanelgroupnotices.cpp @@ -614,7 +614,7 @@ void LLPanelGroupNotices::showNotice(const std::string& subject, mViewInventoryIcon->setVisible(TRUE); std::stringstream ss; - ss << " " << LLViewerInventoryItem::getDisplayName(inventory_name); + ss << " " << inventory_name; mViewInventoryName->setText(ss.str()); mBtnOpenAttachment->setEnabled(TRUE); diff --git a/indra/newview/llpanellandmarkinfo.cpp b/indra/newview/llpanellandmarkinfo.cpp index c792fd4fe3..c75fc39089 100644 --- a/indra/newview/llpanellandmarkinfo.cpp +++ b/indra/newview/llpanellandmarkinfo.cpp @@ -367,7 +367,6 @@ void LLPanelLandmarkInfo::createLandmark(const LLUUID& folder_id) } LLStringUtil::replaceChar(desc, '\n', ' '); - LLViewerInventoryItem::insertDefaultSortField(name); // If no folder chosen use the "Landmarks" folder. LLLandmarkActions::createLandmarkHere(name, desc, diff --git a/indra/newview/lltoastgroupnotifypanel.cpp b/indra/newview/lltoastgroupnotifypanel.cpp index e49044cdca..add61c00cf 100644 --- a/indra/newview/lltoastgroupnotifypanel.cpp +++ b/indra/newview/lltoastgroupnotifypanel.cpp @@ -127,17 +127,7 @@ LLToastGroupNotifyPanel::LLToastGroupNotifyPanel(LLNotificationPtr& notification pAttachLink->setVisible(hasInventory); pAttachIcon->setVisible(hasInventory); if (hasInventory) { - std::string dis_name; - std::string inv_name = payload["inventory_name"]; - - if (LLViewerInventoryItem::extractSortFieldAndDisplayName(inv_name, NULL, &dis_name)) - { - pAttachLink->setValue(dis_name); - } - else - { - pAttachLink->setValue(inv_name); - } + pAttachLink->setValue(payload["inventory_name"]); mInventoryOffer = new LLOfferInfo(payload["inventory_offer"]); childSetActionTextbox("attachment", boost::bind( diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index b330c1ba83..f7529dd553 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -34,6 +34,7 @@ #include "llviewerinventory.h" #include "llnotificationsutil.h" +#include "llsdserialize.h" #include "message.h" #include "indra_constants.h" @@ -1174,17 +1175,125 @@ const std::string& LLViewerInventoryItem::getName() const return getDisplayName(); } +/** + * Class to store sorting order of favorites landmarks in a local file. EXT-3985. + * It replaced previously implemented solution to store sort index in landmark's name as a "@" prefix. + */ +class LLFavoritesOrderStorage : public LLSingleton +{ +public: + /** + * Sets sort index for specified with LLUUID favorite landmark + */ + void setSortIndex(const LLUUID& inv_item_id, S32 sort_index); + + /** + * Gets sort index for specified with LLUUID favorite landmark + */ + S32 getSortIndex(const LLUUID& inv_item_id); + void removeSortIndex(const LLUUID& inv_item_id); + + const static S32 NO_INDEX; +private: + friend class LLSingleton; + LLFavoritesOrderStorage() { load(); } + ~LLFavoritesOrderStorage() { save(); } + + const static std::string SORTING_DATA_FILE_NAME; + + void load(); + void save(); + + typedef std::map sort_index_map_t; + sort_index_map_t mSortIndexes; +}; + +const std::string LLFavoritesOrderStorage::SORTING_DATA_FILE_NAME = "landmarks_sorting.xml"; +const S32 LLFavoritesOrderStorage::NO_INDEX = -1; + +void LLFavoritesOrderStorage::setSortIndex(const LLUUID& inv_item_id, S32 sort_index) +{ + mSortIndexes[inv_item_id] = sort_index; +} + +S32 LLFavoritesOrderStorage::getSortIndex(const LLUUID& inv_item_id) +{ + sort_index_map_t::const_iterator it = mSortIndexes.find(inv_item_id); + if (it != mSortIndexes.end()) + { + return it->second; + } + return NO_INDEX; +} + +void LLFavoritesOrderStorage::removeSortIndex(const LLUUID& inv_item_id) +{ + mSortIndexes.erase(inv_item_id); +} + +void LLFavoritesOrderStorage::load() +{ + // load per-resident sorting information + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, SORTING_DATA_FILE_NAME); + + LLSD settings_llsd; + llifstream file; + file.open(filename); + if (file.is_open()) + { + LLSDSerialize::fromXML(settings_llsd, file); + } + + 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())); + } +} + +void LLFavoritesOrderStorage::save() +{ + // If we quit from the login screen we will not have an SL account + // name. Don't try to save, otherwise we'll dump a file in + // C:\Program Files\SecondLife\ or similar. JC + std::string user_dir = gDirUtilp->getLindenUserDir(); + if (!user_dir.empty()) + { + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, SORTING_DATA_FILE_NAME); + 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); + LLSDSerialize::toPrettyXML(settings_llsd, file); + } +} + + + +// *TODO: mantipov: REMOVE, EXT-3985 const std::string& LLViewerInventoryItem::getDisplayName() const { + return LLInventoryItem::getName(); +/* std::string result; BOOL hasSortField = extractSortFieldAndDisplayName(0, &result); + mDisplayName = LLInventoryItem::getName(); + return mDisplayName = hasSortField ? result : LLInventoryItem::getName(); +*/ } +// *TODO: mantipov: REMOVE, EXT-3985 // static std::string LLViewerInventoryItem::getDisplayName(const std::string& name) { + llassert(false); std::string result; BOOL hasSortField = extractSortFieldAndDisplayName(name, 0, &result); @@ -1193,34 +1302,12 @@ std::string LLViewerInventoryItem::getDisplayName(const std::string& name) S32 LLViewerInventoryItem::getSortField() const { - S32 result; - BOOL hasSortField = extractSortFieldAndDisplayName(&result, 0); - - return hasSortField ? result : -1; + return LLFavoritesOrderStorage::instance().getSortIndex(mUUID); } void LLViewerInventoryItem::setSortField(S32 sortField) { - using std::string; - - std::stringstream ss; - ss << sortField; - - string newSortField = ss.str(); - - const char separator = getSeparator(); - const string::size_type separatorPos = mName.find(separator, 0); - - if (separatorPos < string::npos) - { - // the name of the LLViewerInventoryItem already consists of sort field and display name. - mName = newSortField + separator + mName.substr(separatorPos + 1, string::npos); - } - else - { - // there is no sort field in the name of LLViewerInventoryItem, we should add it - mName = newSortField + separator + mName; - } + LLFavoritesOrderStorage::instance().setSortIndex(mUUID, sortField); } void LLViewerInventoryItem::rename(const std::string& n) @@ -1334,6 +1421,7 @@ U32 LLViewerInventoryItem::getCRC32() const return LLInventoryItem::getCRC32(); } +// *TODO: mantipov: REMOVE, EXT-3985 BOOL LLViewerInventoryItem::extractSortFieldAndDisplayName(const std::string& name, S32* sortField, std::string* displayName) { using std::string; @@ -1369,12 +1457,6 @@ BOOL LLViewerInventoryItem::extractSortFieldAndDisplayName(const std::string& na return result; } -void LLViewerInventoryItem::insertDefaultSortField(std::string& name) -{ - name.insert(0, std::string("1") + getSeparator()); -} - - // This returns true if the item that this item points to // doesn't exist in memory (i.e. LLInventoryModel). The baseitem // might still be in the database but just not loaded yet. diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h index 7f3f019b07..cf104503a8 100644 --- a/indra/newview/llviewerinventory.h +++ b/indra/newview/llviewerinventory.h @@ -82,7 +82,6 @@ public: virtual U32 getCRC32() const; // really more of a checksum. static BOOL extractSortFieldAndDisplayName(const std::string& name, S32* sortField, std::string* displayName); - static void insertDefaultSortField(std::string& name); // construct a complete viewer inventory item LLViewerInventoryItem(const LLUUID& uuid, const LLUUID& parent_uuid, diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index d6ce356c4b..96dd063a7c 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -1434,31 +1434,6 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const return false; } -std::string get_display_name(const std::string& name) -{ - // We receive landmark name as \'@name\' where is a number - // LLViewerInventoryItem::getDisplayName will remove \'@ though we need the \' - // Lets save all chars preceding @ and insert them back after @ was removed - - std::string saved; - - if(std::string::npos != name.find(LLViewerInventoryItem::getSeparator())) - { - int n = 0; - while(!isdigit(name[n]) && LLViewerInventoryItem::getSeparator() != name[n]) - { - ++n; - } - saved = name.substr(0, n); - } - - std::string d_name = LLViewerInventoryItem::getDisplayName(name); - d_name.insert(0, saved); - LLStringUtil::trim(d_name); - - return d_name; -} - void inventory_offer_handler(LLOfferInfo* info) { //Until throttling is implmented, busy mode should reject inventory instead of silently @@ -1496,11 +1471,6 @@ void inventory_offer_handler(LLOfferInfo* info) LLStringUtil::truncate(msg, indx); } - if(LLAssetType::AT_LANDMARK == info->mType) - { - msg = get_display_name(msg); - } - LLSD args; args["[OBJECTNAME]"] = msg; -- cgit v1.2.3 From b3763f1ec1e20226bf489042346c5827d187ba42 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Wed, 27 Jan 2010 18:40:19 +0200 Subject: Cleaned up including of the "llviewerinventory.h" --HG-- branch : product-engine --- indra/newview/llappearancemgr.h | 2 +- indra/newview/llfloaterbulkpermission.cpp | 1 + indra/newview/llfloaterbulkpermission.h | 2 -- indra/newview/llfolderviewitem.cpp | 1 - indra/newview/llinventoryfilter.cpp | 1 - indra/newview/llinventoryfunctions.cpp | 1 - indra/newview/llpanelcontents.cpp | 2 +- indra/newview/llpanelteleporthistory.cpp | 1 - indra/newview/llsidepanelinventorysubpanel.cpp | 1 - indra/newview/llwearablelist.cpp | 1 - 10 files changed, 3 insertions(+), 10 deletions(-) diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index dd50b482cf..38d1e01d08 100644 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -35,11 +35,11 @@ #include "llsingleton.h" #include "llinventorymodel.h" -#include "llviewerinventory.h" #include "llcallbacklist.h" class LLWearable; class LLWearableHoldingPattern; +class LLInventoryCallback; class LLAppearanceManager: public LLSingleton { diff --git a/indra/newview/llfloaterbulkpermission.cpp b/indra/newview/llfloaterbulkpermission.cpp index 5c3a54e34b..b2f700069f 100644 --- a/indra/newview/llfloaterbulkpermission.cpp +++ b/indra/newview/llfloaterbulkpermission.cpp @@ -43,6 +43,7 @@ #include "llviewerregion.h" #include "lscript_rt_interface.h" #include "llviewercontrol.h" +#include "llviewerinventory.h" #include "llviewerobject.h" #include "llviewerregion.h" #include "llresmgr.h" diff --git a/indra/newview/llfloaterbulkpermission.h b/indra/newview/llfloaterbulkpermission.h index 31f4f5c3e1..bffcff7059 100644 --- a/indra/newview/llfloaterbulkpermission.h +++ b/indra/newview/llfloaterbulkpermission.h @@ -44,8 +44,6 @@ #include "llfloater.h" #include "llscrolllistctrl.h" -#include "llviewerinventory.h" - class LLFloaterBulkPermission : public LLFloater, public LLVOInventoryListener { friend class LLFloaterReg; diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 4b48626b22..b05eb84e52 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -40,7 +40,6 @@ #include "llinventoryfilter.h" #include "llpanel.h" #include "llviewercontrol.h" // gSavedSettings -#include "llviewerinventory.h" #include "llviewerwindow.h" // Argh, only for setCursor() // linden library includes diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index b4dcb566e4..cd20d64ca8 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -39,7 +39,6 @@ #include "llfolderviewitem.h" #include "llinventorymodel.h" // gInventory.backgroundFetchActive() #include "llviewercontrol.h" -#include "llviewerinventory.h" #include "llfolderview.h" // linden library includes diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 2885ba13fa..33623539e9 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -76,7 +76,6 @@ #include "lltabcontainer.h" #include "lltooldraganddrop.h" #include "lluictrlfactory.h" -#include "llviewerinventory.h" #include "llviewermessage.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" diff --git a/indra/newview/llpanelcontents.cpp b/indra/newview/llpanelcontents.cpp index 9d591ef43d..2a7d097f94 100644 --- a/indra/newview/llpanelcontents.cpp +++ b/indra/newview/llpanelcontents.cpp @@ -50,7 +50,6 @@ // project includes #include "llagent.h" -#include "llfloaterbulkpermission.h" #include "llpanelobjectinventory.h" #include "llpreviewscript.h" #include "llresmgr.h" @@ -60,6 +59,7 @@ #include "lltoolmgr.h" #include "lltrans.h" #include "llviewerassettype.h" +#include "llviewerinventory.h" #include "llviewerobject.h" #include "llviewerregion.h" #include "llviewerwindow.h" diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp index 1b8fb49641..954f3995c1 100644 --- a/indra/newview/llpanelteleporthistory.cpp +++ b/indra/newview/llpanelteleporthistory.cpp @@ -46,7 +46,6 @@ #include "llnotificationsutil.h" #include "lltextbox.h" #include "llviewermenu.h" -#include "llviewerinventory.h" #include "lllandmarkactions.h" #include "llclipboard.h" diff --git a/indra/newview/llsidepanelinventorysubpanel.cpp b/indra/newview/llsidepanelinventorysubpanel.cpp index 56e342c3ce..f51462dcce 100644 --- a/indra/newview/llsidepanelinventorysubpanel.cpp +++ b/indra/newview/llsidepanelinventorysubpanel.cpp @@ -44,7 +44,6 @@ #include "lllineeditor.h" #include "llradiogroup.h" #include "llviewercontrol.h" -#include "llviewerinventory.h" #include "llviewerobjectlist.h" diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp index 5636256856..d6a9837b86 100644 --- a/indra/newview/llwearablelist.cpp +++ b/indra/newview/llwearablelist.cpp @@ -38,7 +38,6 @@ #include "llassetstorage.h" #include "llagent.h" #include "llvoavatar.h" -#include "llviewerinventory.h" #include "llviewerstats.h" #include "llnotificationsutil.h" #include "llinventorymodel.h" -- cgit v1.2.3 From b80cd227042f8e461fa0a2f9a5ae3b448842b863 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Thu, 28 Jan 2010 09:50:06 +0200 Subject: Work on major bug EXT-3985 ([BSI] Landmarks created in Viewer 2.0 show up with 1@ in Viewer 1.23.x) -- removed using of the LM Prefix while renaming Inventori item --HG-- branch : product-engine --- indra/newview/llviewerinventory.cpp | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index f7529dd553..a3cbd80c84 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1310,27 +1310,10 @@ void LLViewerInventoryItem::setSortField(S32 sortField) LLFavoritesOrderStorage::instance().setSortIndex(mUUID, sortField); } +// *TODO: mantipov: REMOVE, EXT-3985 void LLViewerInventoryItem::rename(const std::string& n) { - using std::string; - - string new_name(n); - LLStringUtil::replaceNonstandardASCII(new_name, ' '); - LLStringUtil::replaceChar(new_name, '|', ' '); - LLStringUtil::trim(new_name); - LLStringUtil::truncate(new_name, DB_INV_ITEM_NAME_STR_LEN); - - const char separator = getSeparator(); - const string::size_type separatorPos = mName.find(separator, 0); - - if (separatorPos < string::npos) - { - mName.replace(separatorPos + 1, string::npos, new_name); - } - else - { - mName = new_name; - } + LLInventoryItem::rename(n); } const LLPermissions& LLViewerInventoryItem::getPermissions() const -- cgit v1.2.3 From a08f098847cda964bfba5476fd213e05bdf67dd0 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Fri, 29 Jan 2010 10:11:53 +0200 Subject: Work on major bug EXT-3985 ([BSI] Landmarks created in Viewer 2.0 show up with 1@ in Viewer 1.23.x) -- implemented patch to remove LM prefixes from landmarks' names *NOTE: It will be unnecessary after the first successful session in viewer 2.0. Can be removed before public release. Implementation details: At the first run with this patch it patches all cached landmarks: removes LM sort prefixes and updates them on the viewer and server sides. Also it calls fetching agent's inventory to process not yet loaded landmarks too. If fetching is successfully done it will store special per-agent empty file-marker in the user temporary folder (where cached inventory is loaded) while caching agent's inventory. After that in will not affect the viewer until cached marker is removed. --HG-- branch : product-engine --- indra/newview/llinventorymodel.cpp | 134 +++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 961f7adc0a..9e96bbc55f 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -142,6 +142,105 @@ bool LLCanCache::operator()(LLInventoryCategory* cat, LLInventoryItem* item) return rv; } +/* +This namespace contains a functionality to remove LM prefixes were used to store sort order of +Favorite Landmarks in landmarks' names. +Once being in Favorites folder LM inventory Item has such prefix. +Due to another solution is implemented in EXT-3985 these prefixes should be removed. + +*NOTE: It will be unnecessary after the first successful session in viewer 2.0. +Can be removed before public release. + +Implementation details: +At the first run with this patch it patches all cached landmarks: removes LM sort prefixes and +updates them on the viewer and server sides. +Also it calls fetching agent's inventory to process not yet loaded landmarks too. +If fetching is successfully done it will store special per-agent empty file-marker +in the user temporary folder (where cached inventory is loaded) while caching agent's inventory. +After that in will not affect the viewer until cached marker is removed. +*/ +namespace LMSortPrefix +{ + bool cleanup_done = false; + const std::string getMarkerPath() + { + std::string path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, gAgentID.asString())); + std::string marker_filename = llformat("%s-lm_prefix_marker", path.c_str()); + + return marker_filename; + } + bool wasClean() + { + static bool was_clean = false; + static bool already_init = false; + if (already_init) return was_clean; + + already_init = true; + std::string path_to_marker = getMarkerPath(); + was_clean = LLFile::isfile(path_to_marker); + + return was_clean; + } + + void setLandmarksWereCleaned() + { + if (cleanup_done) + { + std::string path_to_marker = getMarkerPath(); + LLFILE* file = LLFile::fopen(path_to_marker, "w"); + if(!file) + { + llwarns << "unable to save marker that LM prefixes were removed: " << path_to_marker << llendl; + return; + } + + fclose(file); + } + } + + void removePrefix(LLPointer inv_item) + { + if (wasClean()) + { + LL_INFOS_ONCE("") << "Inventory was cleaned for this avatar. Patch can be removed." << LL_ENDL; + return; + } + + if (LLInventoryType::IT_LANDMARK != inv_item->getInventoryType()) return; + + std::string old_name = inv_item->getName(); + + S32 sort_field = -1; + std::string display_name; + BOOL exists = LLViewerInventoryItem::extractSortFieldAndDisplayName(old_name, &sort_field, &display_name); + if (exists && sort_field != -1) + { + llinfos << "Removing Landmark sort field and separator for: " << old_name << " | " << inv_item->getUUID() << llendl; + LLUUID parent_uuid = inv_item->getParentUUID(); + if (gInventory.getCategory(parent_uuid)) + { + llinfos << "parent folder is: " << gInventory.getCategory(parent_uuid)->getName() << llendl; + } + + + // mark item completed to avoid error while copying and updating server + inv_item->setComplete(TRUE); + LLPointer new_item = new LLViewerInventoryItem(inv_item); + new_item->rename(display_name); + gInventory.updateItem(new_item); + new_item->updateServer(FALSE); + + gInventory.notifyObservers(); + } + } + + void completeCleanup() + { + // background fetch is completed. can save marker + cleanup_done = true; + } +} + ///---------------------------------------------------------------------------- /// Class LLInventoryModel ///---------------------------------------------------------------------------- @@ -1736,6 +1835,8 @@ void LLInventoryModel::stopBackgroundFetch() gIdleCallbacks.deleteFunction(&LLInventoryModel::backgroundFetch, NULL); sBulkFetchCount=0; sMinTimeBetweenFetches=0.0f; + + LMSortPrefix::completeCleanup(); } } @@ -1882,6 +1983,13 @@ void LLInventoryModel::cache( const LLUUID& parent_folder_id, const LLUUID& agent_id) { + if (getRootFolderID() == parent_folder_id) + { + // *TODO: mantipov: can be removed before public release, EXT-3985 + //save marker to avoid fetching inventory on future sessions + LMSortPrefix::setLandmarksWereCleaned(); + } + lldebugs << "Caching " << parent_folder_id << " for " << agent_id << llendl; LLViewerInventoryCategory* root_cat = getCategory(parent_folder_id); @@ -2692,6 +2800,28 @@ void LLInventoryModel::buildParentChildMap() // The inv tree is built. mIsAgentInvUsable = true; + {// *TODO: mantipov: can be removed before public release, EXT-3985 + /* + *HACK: mantipov: to cleanup landmarks were marked with sort index prefix in name. + Is necessary to be called once per account after EXT-3985 is implemented. + So, let fetch agent's inventory, processing will be done in processInventoryDescendents() + Should be removed before public release. + */ + if (!LMSortPrefix::wasClean()) + { + cat_array_t cats; + item_array_t items; + collectDescendents(agent_inv_root_id, cats, items, INCLUDE_TRASH); + + for (item_array_t::const_iterator it= items.begin(); it != items.end(); ++it) + { + LMSortPrefix::removePrefix(*it); + } + + gInventory.startBackgroundFetch(agent_inv_root_id); + } + } + llinfos << "Inventory initialized, notifying observers" << llendl; addChangedMask(LLInventoryObserver::ALL, LLUUID::null); notifyObservers(); @@ -3457,6 +3587,10 @@ void LLInventoryModel::processInventoryDescendents(LLMessageSystem* msg,void**) continue; } gInventory.updateItem(titem); + + {// *TODO: mantipov: can be removed before public release, EXT-3985 + LMSortPrefix::removePrefix(titem); + } } // set version and descendentcount according to message. -- cgit v1.2.3 From 72b2cf291d67ae7a271b5745e50290d174a088b6 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Fri, 29 Jan 2010 12:25:38 +0200 Subject: Work on major bug EXT-3985 ([BSI] Landmarks created in Viewer 2.0 show up with 1@ in Viewer 1.23.x) -- implemented cleanning of stored sort indexes to remove ones for landmarks not in Favorites while disconnecting viewer --HG-- branch : product-engine --- indra/newview/llviewerinventory.cpp | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index a3cbd80c84..1b141532ef 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1178,8 +1178,10 @@ const std::string& LLViewerInventoryItem::getName() const /** * Class to store sorting order of favorites landmarks in a local file. EXT-3985. * It replaced previously implemented solution to store sort index in landmark's name as a "@" prefix. + * Data are stored in user home directory. */ class LLFavoritesOrderStorage : public LLSingleton + , public LLDestroyClass { public: /** @@ -1193,12 +1195,27 @@ public: S32 getSortIndex(const LLUUID& inv_item_id); void removeSortIndex(const LLUUID& inv_item_id); + /** + * Implementation of LLDestroyClass. Calls cleanup() instance method. + * + * It is important this callback is called before gInventory is cleaned. + * For now it is called from LLAppViewer::cleanup() -> LLAppViewer::disconnectViewer(), + * Inventory is cleaned later from LLAppViewer::cleanup() after LLAppViewer::disconnectViewer() is called. + * @see cleanup() + */ + static void destroyClass(); + const static S32 NO_INDEX; private: friend class LLSingleton; LLFavoritesOrderStorage() { load(); } ~LLFavoritesOrderStorage() { save(); } + /** + * Removes sort indexes for items which are not in Favorites bar for now. + */ + void cleanup(); + const static std::string SORTING_DATA_FILE_NAME; void load(); @@ -1206,6 +1223,32 @@ private: typedef std::map sort_index_map_t; sort_index_map_t mSortIndexes; + + struct IsNotInFavorites + { + IsNotInFavorites(const LLInventoryModel::item_array_t& items) + : mFavoriteItems(items) + { + + } + + /** + * Returns true if specified item is not found among inventory items + */ + bool operator()(const sort_index_map_t::value_type& id_index_pair) const + { + LLPointer item = gInventory.getItem(id_index_pair.first); + if (item.isNull()) return true; + + LLInventoryModel::item_array_t::const_iterator found_it = + std::find(mFavoriteItems.begin(), mFavoriteItems.end(), item); + + return found_it == mFavoriteItems.end(); + } + private: + LLInventoryModel::item_array_t mFavoriteItems; + }; + }; const std::string LLFavoritesOrderStorage::SORTING_DATA_FILE_NAME = "landmarks_sorting.xml"; @@ -1231,6 +1274,12 @@ void LLFavoritesOrderStorage::removeSortIndex(const LLUUID& inv_item_id) mSortIndexes.erase(inv_item_id); } +// static +void LLFavoritesOrderStorage::destroyClass() +{ + LLFavoritesOrderStorage::instance().cleanup(); +} + void LLFavoritesOrderStorage::load() { // load per-resident sorting information @@ -1273,6 +1322,24 @@ void LLFavoritesOrderStorage::save() } } +void LLFavoritesOrderStorage::cleanup() +{ + 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); + + IsNotInFavorites is_not_in_fav(items); + + sort_index_map_t aTempMap; + //copy unremoved values from mSortIndexes to aTempMap + std::remove_copy_if(mSortIndexes.begin(), mSortIndexes.end(), + inserter(aTempMap, aTempMap.begin()), + is_not_in_fav); + + //Swap the contents of mSortIndexes and aTempMap + mSortIndexes.swap(aTempMap); +} // *TODO: mantipov: REMOVE, EXT-3985 -- cgit v1.2.3 From 4666636cdc67beb3cbb1c81107ce1f1f368385e1 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Fri, 29 Jan 2010 12:34:23 +0200 Subject: Work on major bug EXT-3985 ([BSI] Landmarks created in Viewer 2.0 show up with 1@ in Viewer 1.23.x) -- improvements: for now sort indexes are cleaned & saved only if something was changed amont them. --HG-- branch : product-engine --- indra/newview/llviewerinventory.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 1b141532ef..bcfb8ecbbd 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1208,7 +1208,7 @@ public: const static S32 NO_INDEX; private: friend class LLSingleton; - LLFavoritesOrderStorage() { load(); } + LLFavoritesOrderStorage() : mIsDirty(false) { load(); } ~LLFavoritesOrderStorage() { save(); } /** @@ -1224,6 +1224,8 @@ private: typedef std::map sort_index_map_t; sort_index_map_t mSortIndexes; + bool mIsDirty; + struct IsNotInFavorites { IsNotInFavorites(const LLInventoryModel::item_array_t& items) @@ -1257,6 +1259,7 @@ const S32 LLFavoritesOrderStorage::NO_INDEX = -1; void LLFavoritesOrderStorage::setSortIndex(const LLUUID& inv_item_id, S32 sort_index) { mSortIndexes[inv_item_id] = sort_index; + mIsDirty = true; } S32 LLFavoritesOrderStorage::getSortIndex(const LLUUID& inv_item_id) @@ -1272,6 +1275,7 @@ S32 LLFavoritesOrderStorage::getSortIndex(const LLUUID& inv_item_id) void LLFavoritesOrderStorage::removeSortIndex(const LLUUID& inv_item_id) { mSortIndexes.erase(inv_item_id); + mIsDirty = true; } // static @@ -1302,6 +1306,9 @@ void LLFavoritesOrderStorage::load() void LLFavoritesOrderStorage::save() { + // nothing to save if clean + if (!mIsDirty) return; + // If we quit from the login screen we will not have an SL account // name. Don't try to save, otherwise we'll dump a file in // C:\Program Files\SecondLife\ or similar. JC @@ -1324,6 +1331,9 @@ void LLFavoritesOrderStorage::save() void LLFavoritesOrderStorage::cleanup() { + // nothing to clean + if (!mIsDirty) return; + const LLUUID fav_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE); LLInventoryModel::cat_array_t cats; LLInventoryModel::item_array_t items; -- cgit v1.2.3 From 8a7ca61479813f55481f1040f75cd6fc63e713d2 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Fri, 29 Jan 2010 13:05:11 +0200 Subject: Work on major bug EXT-3985 ([BSI] Landmarks created in Viewer 2.0 show up with 1@ in Viewer 1.23.x) -- cleanup: removed deprecated code added for previous sollution to support custom sorting of favorite landmarks. For now previous implementation is removed, bug is FIXED. --HG-- branch : product-engine --- indra/newview/llfavoritesbar.cpp | 4 +-- indra/newview/llinventorybridge.cpp | 2 +- indra/newview/llviewerinventory.cpp | 50 ++++++++----------------------------- indra/newview/llviewerinventory.h | 4 --- 4 files changed, 13 insertions(+), 47 deletions(-) diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index 0e42ff09d8..57e6619470 100644 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -685,7 +685,7 @@ void LLFavoritesBarCtrl::updateButtons() { // an child's order and mItems should be same if (button->getLandmarkId() != item->getUUID() // sort order has been changed - || button->getLabelSelected() != item->getDisplayName() // favorite's name has been changed + || button->getLabelSelected() != item->getName() // favorite's name has been changed || button->getRect().mRight < rightest_point) // favbar's width has been changed { break; @@ -780,7 +780,7 @@ LLButton* LLFavoritesBarCtrl::createButton(const LLPointergetWidth(item->getDisplayName()) + 20; + int requred_width = mFont->getWidth(item->getName()) + 20; int width = requred_width > def_button_width? def_button_width : requred_width; LLFavoriteLandmarkButton* fav_btn = NULL; diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 6c9c7d15be..e04d3ec5a0 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -5079,7 +5079,7 @@ void LLLandmarkBridgeAction::doIt() payload["asset_id"] = item->getAssetUUID(); LLSD args; - args["LOCATION"] = item->getDisplayName(); + args["LOCATION"] = item->getName(); LLNotificationsUtil::add("TeleportFromLandmark", args, payload); } diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index bcfb8ecbbd..3001992630 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1172,7 +1172,7 @@ const std::string& LLViewerInventoryItem::getName() const return linked_category->getName(); } - return getDisplayName(); + return LLInventoryItem::getName(); } /** @@ -1340,42 +1340,17 @@ void LLFavoritesOrderStorage::cleanup() gInventory.collectDescendents(fav_id, cats, items, LLInventoryModel::EXCLUDE_TRASH); IsNotInFavorites is_not_in_fav(items); - - sort_index_map_t aTempMap; - //copy unremoved values from mSortIndexes to aTempMap - std::remove_copy_if(mSortIndexes.begin(), mSortIndexes.end(), - inserter(aTempMap, aTempMap.begin()), - is_not_in_fav); - - //Swap the contents of mSortIndexes and aTempMap - mSortIndexes.swap(aTempMap); -} + sort_index_map_t aTempMap; + //copy unremoved values from mSortIndexes to aTempMap + std::remove_copy_if(mSortIndexes.begin(), mSortIndexes.end(), + inserter(aTempMap, aTempMap.begin()), + is_not_in_fav); -// *TODO: mantipov: REMOVE, EXT-3985 -const std::string& LLViewerInventoryItem::getDisplayName() const -{ - return LLInventoryItem::getName(); -/* - std::string result; - BOOL hasSortField = extractSortFieldAndDisplayName(0, &result); - - mDisplayName = LLInventoryItem::getName(); - - return mDisplayName = hasSortField ? result : LLInventoryItem::getName(); -*/ + //Swap the contents of mSortIndexes and aTempMap + mSortIndexes.swap(aTempMap); } -// *TODO: mantipov: REMOVE, EXT-3985 -// static -std::string LLViewerInventoryItem::getDisplayName(const std::string& name) -{ - llassert(false); - std::string result; - BOOL hasSortField = extractSortFieldAndDisplayName(name, 0, &result); - - return hasSortField ? result : name; -} S32 LLViewerInventoryItem::getSortField() const { @@ -1387,12 +1362,6 @@ void LLViewerInventoryItem::setSortField(S32 sortField) LLFavoritesOrderStorage::instance().setSortIndex(mUUID, sortField); } -// *TODO: mantipov: REMOVE, EXT-3985 -void LLViewerInventoryItem::rename(const std::string& n) -{ - LLInventoryItem::rename(n); -} - const LLPermissions& LLViewerInventoryItem::getPermissions() const { // Use the actual permissions of the symlink, not its parent. @@ -1481,7 +1450,8 @@ U32 LLViewerInventoryItem::getCRC32() const return LLInventoryItem::getCRC32(); } -// *TODO: mantipov: REMOVE, EXT-3985 +// *TODO: mantipov: should be removed with LMSortPrefix patch in llinventorymodel.cpp, EXT-3985 +static char getSeparator() { return '@'; } BOOL LLViewerInventoryItem::extractSortFieldAndDisplayName(const std::string& name, S32* sortField, std::string* displayName) { using std::string; diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h index cf104503a8..c24f76c87a 100644 --- a/indra/newview/llviewerinventory.h +++ b/indra/newview/llviewerinventory.h @@ -64,12 +64,8 @@ public: virtual LLAssetType::EType getType() const; virtual const LLUUID& getAssetUUID() const; virtual const std::string& getName() const; - virtual const std::string& getDisplayName() const; - static std::string getDisplayName(const std::string& name); - static char getSeparator() { return '@'; } virtual S32 getSortField() const; virtual void setSortField(S32 sortField); - virtual void rename(const std::string& new_name); virtual const LLPermissions& getPermissions() const; virtual const LLUUID& getCreatorUUID() const; virtual const std::string& getDescription() const; -- cgit v1.2.3