summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorMike Antipov <mantipov@productengine.com>2010-01-27 17:29:44 +0200
committerMike Antipov <mantipov@productengine.com>2010-01-27 17:29:44 +0200
commit837f6c7cbefa7ac1c64c9506d2fabd640ae652ec (patch)
treeeb07d97e1e0ccf5bba6913aa11878e9b74d7c5bf /indra
parentb23a5dda5a730b1d0196d171dc5005e03b2328d4 (diff)
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
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llpanelgroupnotices.cpp2
-rw-r--r--indra/newview/llpanellandmarkinfo.cpp1
-rw-r--r--indra/newview/lltoastgroupnotifypanel.cpp12
-rw-r--r--indra/newview/llviewerinventory.cpp142
-rw-r--r--indra/newview/llviewerinventory.h1
-rw-r--r--indra/newview/llviewermessage.cpp30
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 "<N>@" prefix.
+ */
+class LLFavoritesOrderStorage : public LLSingleton<LLFavoritesOrderStorage>
+{
+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>;
+ LLFavoritesOrderStorage() { load(); }
+ ~LLFavoritesOrderStorage() { save(); }
+
+ const static std::string SORTING_DATA_FILE_NAME;
+
+ void load();
+ void save();
+
+ typedef std::map<LLUUID, S32> 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 \'<n>@name\' where <n> is a number
- // LLViewerInventoryItem::getDisplayName will remove \'<n>@ though we need the \'
- // Lets save all chars preceding @ and insert them back after <n>@ 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;