diff options
author | Andrew Productengine <adyukov@productengine.com> | 2010-12-06 18:05:44 +0200 |
---|---|---|
committer | Andrew Productengine <adyukov@productengine.com> | 2010-12-06 18:05:44 +0200 |
commit | d6f8efae246db921b8d52fc1f86bbf667931dd93 (patch) | |
tree | 463d81d77d942faa47b0b09dd3377e0ff8a79a3c /indra/newview | |
parent | 45c7663cef287665945a148cce5751f253ee3a0f (diff) |
STORM-34 FIXED Saving of user's favorites into file and showing them in "Start at" combobox on login screen was implemented.
Implementation details:
- File is saved on exit from viewer and not immediately on changes as was written in spec. It is done to make this file consistent with favorites order: order of favorites is saved on exit,
so if favorites info is saved in other moment earlier, crashing viewer or other unexpected way of finishing its work (i.e. via Windows task bar) would cause inconsistence between favorites order
saved per account and one from this new file.
- File is saved in user_settings\stored_favorites.xml.
- If you uncheck the option in Preferences and press OK, the file gets immediately deleted (according to spec).
Issues that require further changes:
- Currently only favorites of last logged in user are shown in login screen. Showing favorites of multiple users will be implemented later when design for it is approved by Esbee.
- Preference is now global for all users, because design states it may be changed before login, and we don't have account info at the moment. But it doesn't seem to be a good idea, so changes in design are needed.
- Currently the way of retrieving SLURLs needs optimization in a separate ticket.
More detailed design approved by Esbee is needed to develop it further, perhaps in new tickets.
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/app_settings/settings.xml | 11 | ||||
-rw-r--r-- | indra/newview/llfavoritesbar.cpp | 10 | ||||
-rw-r--r-- | indra/newview/llfloaterpreference.cpp | 21 | ||||
-rw-r--r-- | indra/newview/llfloaterpreference.h | 3 | ||||
-rw-r--r-- | indra/newview/llpanellogin.cpp | 36 | ||||
-rw-r--r-- | indra/newview/llpanellogin.h | 2 | ||||
-rw-r--r-- | indra/newview/llviewerinventory.cpp | 102 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/notifications.xml | 10 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_preferences_privacy.xml | 13 |
9 files changed, 205 insertions, 3 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 402a0e85c4..871053782b 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -12332,5 +12332,16 @@ <key>Value</key> <string>name</string> </map> + <key>ShowFavoritesOnLogin</key> + <map> + <key>Comment</key> + <string>Determines whether favorites of last logged in user will be saved on exit from viewer and shown on login screen</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> </map> </llsd> diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index a1ba370c26..4f87221065 100644 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -606,6 +606,16 @@ void LLFavoritesBarCtrl::changed(U32 mask) } else { + LLInventoryModel::item_array_t items; + LLInventoryModel::cat_array_t cats; + LLIsType is_type(LLAssetType::AT_LANDMARK); + gInventory.collectDescendentsIf(mFavoriteFolderId, cats, items, LLInventoryModel::EXCLUDE_TRASH, is_type); + + S32 sortField = 0; + for (LLInventoryModel::item_array_t::iterator i = items.begin(); i != items.end(); ++i) + { + (*i)->setSortField(++sortField); + } updateButtons(); } } diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 6a7b5171b5..6500aefb10 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -330,6 +330,8 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) gSavedSettings.getControl("NameTagShowUsernames")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2)); gSavedSettings.getControl("NameTagShowFriends")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2)); gSavedSettings.getControl("UseDisplayNames")->getCommitSignal()->connect(boost::bind(&handleDisplayNamesOptionChanged, _2)); + + mFavoritesFileMayExist = gSavedSettings.getBOOL("ShowFavoritesOnLogin"); } BOOL LLFloaterPreference::postBuild() @@ -489,6 +491,13 @@ void LLFloaterPreference::apply() updateDoubleClickSettings(); mDoubleClickActionDirty = false; } + + if (mFavoritesFileMayExist && !gSavedSettings.getBOOL("ShowFavoritesOnLogin")) + { + mFavoritesFileMayExist = false; + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "stored_favorites.xml"); + LLFile::remove(filename); + } } void LLFloaterPreference::cancel() @@ -1491,6 +1500,10 @@ BOOL LLPanelPreference::postBuild() { getChild<LLCheckBoxCtrl>("voice_call_friends_only_check")->setCommitCallback(boost::bind(&showFriendsOnlyWarning, _1, _2)); } + if (hasChild("favorites_on_login_check")) + { + getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setCommitCallback(boost::bind(&showFavoritesOnLoginWarning, _1, _2)); + } // Panel Advanced if (hasChild("modifier_combo")) @@ -1558,6 +1571,14 @@ void LLPanelPreference::showFriendsOnlyWarning(LLUICtrl* checkbox, const LLSD& v } } +void LLPanelPreference::showFavoritesOnLoginWarning(LLUICtrl* checkbox, const LLSD& value) +{ + if (checkbox && checkbox->getValue()) + { + LLNotificationsUtil::add("FavoritesOnLogin"); + } +} + void LLPanelPreference::cancel() { for (control_values_map_t::iterator iter = mSavedValues.begin(); diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index bb871e7e25..c95a2472a7 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -162,6 +162,7 @@ private: bool mLanguageChanged; bool mOriginalHideOnlineStatus; + bool mFavoritesFileMayExist; std::string mDirectoryVisibility; }; @@ -183,6 +184,8 @@ public: private: //for "Only friends and groups can call or IM me" static void showFriendsOnlyWarning(LLUICtrl*, const LLSD&); + //for "Show my Favorite Landmarks at Login" + static void showFavoritesOnLoginWarning(LLUICtrl* checkbox, const LLSD& value); typedef std::map<LLControlVariable*, LLSD> control_values_map_t; control_values_map_t mSavedValues; diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index cf567fb208..16ea303c77 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -262,11 +262,45 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, gResponsePtr = LLIamHereLogin::build( this ); LLHTTPClient::head( LLGridManager::getInstance()->getLoginPage(), gResponsePtr ); - + + // Show last logged in user favorites in "Start at" combo if corresponding option is enabled. + if (gSavedSettings.getBOOL("ShowFavoritesOnLogin")) + { + addFavoritesToStartLocation(); + } + updateLocationCombo(false); } +void LLPanelLogin::addFavoritesToStartLocation() +{ + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "stored_favorites.xml"); + LLSD fav_llsd; + llifstream file; + file.open(filename); + if (!file.is_open()) return; + LLComboBox* combo = getChild<LLComboBox>("start_location_combo"); + combo->addSeparator(); + LLSDSerialize::fromXML(fav_llsd, file); + for (LLSD::map_const_iterator iter = fav_llsd.beginMap(); + iter != fav_llsd.endMap(); ++iter) + { + LLSD user_llsd = iter->second; + for (LLSD::array_const_iterator iter1 = user_llsd.beginArray(); + iter1 != user_llsd.endArray(); ++iter1) + { + std::string label = (*iter1)["name"].asString(); + std::string value = (*iter1)["slurl"].asString(); + if(label != "" && value != "") + { + combo->add(label, value); + } + } + + } +} + // force the size to be correct (XML doesn't seem to be sufficient to do this) // (with some padding so the other login screen doesn't show through) void LLPanelLogin::reshapeBrowser() diff --git a/indra/newview/llpanellogin.h b/indra/newview/llpanellogin.h index 83e76a308b..8a8888a053 100644 --- a/indra/newview/llpanellogin.h +++ b/indra/newview/llpanellogin.h @@ -85,6 +85,8 @@ public: private: friend class LLPanelLoginListener; void reshapeBrowser(); + // adds favorites of last logged in user from file to "Start at" combobox. + void addFavoritesToStartLocation(); static void onClickConnect(void*); static void onClickNewAccount(void*); // static bool newAccountAlertCallback(const LLSD& notification, const LLSD& response); diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 7dbaa4cf92..941e81d36f 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -48,6 +48,7 @@ #include "llinventorybridge.h" #include "llinventorypanel.h" #include "llfloaterinventory.h" +#include "lllandmarkactions.h" #include "llviewerassettype.h" #include "llviewerregion.h" @@ -59,6 +60,8 @@ #include "llcommandhandler.h" #include "llviewermessage.h" #include "llsidepanelappearance.h" +#include "llavatarnamecache.h" +#include "lllogininstance.h" ///---------------------------------------------------------------------------- /// Helper class to store special inventory item names and their localized values. @@ -1414,6 +1417,8 @@ public: S32 getSortIndex(const LLUUID& inv_item_id); void removeSortIndex(const LLUUID& inv_item_id); + void getSLURL(const LLUUID& asset_id); + /** * Implementation of LLDestroyClass. Calls cleanup() instance method. * @@ -1440,9 +1445,17 @@ private: void load(); void save(); + void saveFavoritesSLURLs(); + + void onLandmarkLoaded(const LLUUID& asset_id, LLLandmark* landmark); + void storeFavoriteSLURL(const LLUUID& asset_id, std::string& slurl); + typedef std::map<LLUUID, S32> sort_index_map_t; sort_index_map_t mSortIndexes; + typedef std::map<LLUUID, std::string> slurls_map_t; + slurls_map_t mSLURLs; + bool mIsDirty; struct IsNotInFavorites @@ -1497,10 +1510,27 @@ void LLFavoritesOrderStorage::removeSortIndex(const LLUUID& inv_item_id) mIsDirty = true; } +void LLFavoritesOrderStorage::getSLURL(const LLUUID& asset_id) +{ + slurls_map_t::iterator slurl_iter = mSLURLs.find(asset_id); + if (slurl_iter != mSLURLs.end()) return; // SLURL for current landmark is already cached + + LLLandmark* lm = gLandmarkList.getAsset(asset_id, + boost::bind(&LLFavoritesOrderStorage::onLandmarkLoaded, this, asset_id, _1)); + if (lm) + { + onLandmarkLoaded(asset_id, lm); + } +} + // static void LLFavoritesOrderStorage::destroyClass() { LLFavoritesOrderStorage::instance().cleanup(); + if (gSavedSettings.getBOOL("ShowFavoritesOnLogin")) + { + LLFavoritesOrderStorage::instance().saveFavoritesSLURLs(); + } } void LLFavoritesOrderStorage::load() @@ -1523,6 +1553,77 @@ void LLFavoritesOrderStorage::load() } } +void LLFavoritesOrderStorage::saveFavoritesSLURLs() +{ + // Do not change the file if we are not logged in yet. + if (!LLLoginInstance::getInstance()->authSuccess()) return; + + std::string user_dir = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, ""); + if (user_dir.empty()) return; + + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "stored_favorites.xml"); + + 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()) + { + value["slurl"] = slurl_iter->second; + } + else + { + llwarns << "Fetching SLURLs for \"Favorites\" is not complete!" << llendl; + return; + } + + user_llsd[(*it)->getSortField()] = value; + } + + LLSD fav_llsd; + // this level in LLSD is not needed now and is just a stub, but will be needed later when implementing save of multiple users favorites in one file. + LLAvatarName av_name; + LLAvatarNameCache::get( gAgentID, &av_name ); + fav_llsd[av_name.getLegacyName()] = user_llsd; + + llofstream file; + file.open(filename); + LLSDSerialize::toPrettyXML(fav_llsd, file); +} + +void LLFavoritesOrderStorage::onLandmarkLoaded(const LLUUID& asset_id, LLLandmark* landmark) +{ + if (!landmark) return; + + 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()) + { + LLLandmarkActions::getSLURLfromPosGlobal(pos_global, + boost::bind(&LLFavoritesOrderStorage::storeFavoriteSLURL, this, asset_id, _1)); + } +} + +void LLFavoritesOrderStorage::storeFavoriteSLURL(const LLUUID& asset_id, std::string& slurl) +{ + mSLURLs[asset_id] = slurl; +} + void LLFavoritesOrderStorage::save() { // nothing to save if clean @@ -1579,6 +1680,7 @@ S32 LLViewerInventoryItem::getSortField() const void LLViewerInventoryItem::setSortField(S32 sortField) { LLFavoritesOrderStorage::instance().setSortIndex(mUUID, sortField); + LLFavoritesOrderStorage::instance().getSLURL(mAssetUUID); } const LLPermissions& LLViewerInventoryItem::getPermissions() const diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 60b876d163..34ccecce09 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -253,6 +253,16 @@ Save all changes to clothing/body parts? <notification icon="alertmodal.tga" + name="FavoritesOnLogin" + type="alertmodal"> + Note: When you turn on this option, anyone who uses this computer can see your list of favorite locations. + <usetemplate + name="okbutton" + yestext="OK"/> + </notification> + + <notification + icon="alertmodal.tga" name="GrantModifyRights" type="alertmodal"> Granting modify rights to another Resident allows them to change, delete or take ANY objects you may have in-world. Be VERY careful when handing out this permission. diff --git a/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml b/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml index 626122c0b0..85d3859f63 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml @@ -69,6 +69,15 @@ name="auto_disengage_mic_check" top_pad="10" width="350" /> + <check_box + control_name="ShowFavoritesOnLogin" + height="16" + label="Show my Favorite Landmarks at Login (via 'Start At' drop-down menu)" + layout="topleft" + left="30" + name="favorites_on_login_check" + top_pad="10" + width="350" /> <text type="string" length="1" @@ -78,7 +87,7 @@ left="30" mouse_opaque="false" name="Logs:" - top_pad="30" + top_pad="20" width="350"> Chat Logs: </text> @@ -170,7 +179,7 @@ layout="topleft" left="30" name="block_list" - top_pad="35" + top_pad="28" width="145"> <!--<button.commit_callback function="SideTray.ShowPanel"--> |