Commits

Anonymous committed b7544ff

STORM-34 ADDITIONAL_FIX Made saving favorites in file per-account preference instead of per-machine.

- Made changes in code of floater preferences and panel login that were required because of turning the setting per-account.

- Added new method to LLFloaterPreference that looks for current user's record in saved favorites file and removes it.

Comments (0)

Files changed (7)

indra/newview/app_settings/settings.xml

       <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>

indra/newview/app_settings/settings_per_account.xml

         <key>Value</key>
             <integer>0</integer>
         </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>
     <!-- End of back compatibility settings -->
     </map>
 </llsd>

indra/newview/llfloaterpreference.cpp

 #include "llteleporthistorystorage.h"
 
 #include "lllogininstance.h"        // to check if logged in yet
+#include "llsdserialize.h"
 
 const F32 MAX_USER_FAR_CLIP = 512.f;
 const F32 MIN_USER_FAR_CLIP = 64.f;
 	mGotPersonalInfo(false),
 	mOriginalIMViaEmail(false),
 	mLanguageChanged(false),
-	mDoubleClickActionDirty(false)
+	mDoubleClickActionDirty(false),
+	mFavoritesRecordMayExist(false)
 {
 	//Build Floater is now Called from 	LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
 	
 	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()
 		mDoubleClickActionDirty = false;
 	}
 
-	if (mFavoritesFileMayExist && !gSavedSettings.getBOOL("ShowFavoritesOnLogin"))
+	if (mFavoritesRecordMayExist && !gSavedPerAccountSettings.getBOOL("ShowFavoritesOnLogin"))
 	{
-		mFavoritesFileMayExist = false;
-		std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "stored_favorites.xml");
-		LLFile::remove(filename);
+		removeFavoritesRecordOfUser();		
 	}
 }
 
+void LLFloaterPreference::removeFavoritesRecordOfUser()
+{
+	mFavoritesRecordMayExist = false;
+	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;
+	LLSDSerialize::fromXML(fav_llsd, file);
+	
+	LLAvatarName av_name;
+	LLAvatarNameCache::get( gAgentID, &av_name );
+	if (fav_llsd.has(av_name.getLegacyName()))
+	{
+		fav_llsd.erase(av_name.getLegacyName());
+	}
+	
+	llofstream out_file;
+	out_file.open(filename);
+	LLSDSerialize::toPrettyXML(fav_llsd, out_file);
+
+}
+
 void LLFloaterPreference::cancel()
 {
 	LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
 		getChildView("maturity_desired_combobox")->setVisible( false);
 	}
 
+	if (LLStartUp::getStartupState() == STATE_STARTED)
+	{
+		mFavoritesRecordMayExist = gSavedPerAccountSettings.getBOOL("ShowFavoritesOnLogin");
+	}
+
 	// Forget previous language changes.
 	mLanguageChanged = false;
 
 	
 //	getChild<LLUICtrl>("busy_response")->setValue(gSavedSettings.getString("BusyModeResponse2"));
 	
+	getChildView("favorites_on_login_check")->setEnabled(TRUE);
 	getChildView("log_nearby_chat")->setEnabled(TRUE);
 	getChildView("log_instant_messages")->setEnabled(TRUE);
 	getChildView("show_timestamps_check_im")->setEnabled(TRUE);

indra/newview/llfloaterpreference.h

 	
 	void buildPopupLists();
 	static void refreshSkin(void* data);
+	// Remove record of current user's favorites from file on disk.
+	void removeFavoritesRecordOfUser();
 private:
 	static std::string sSkin;
 	// set true if state of double-click action checkbox or radio-group was changed by user
 	bool mLanguageChanged;
 	
 	bool mOriginalHideOnlineStatus;
-	bool mFavoritesFileMayExist;
+	// Record of current user's favorites may be stored in file on disk.
+	bool mFavoritesRecordMayExist;
 	std::string mDirectoryVisibility;
 };
 

indra/newview/llpanellogin.cpp

 
 	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"))
-	{
-	    addUsersWithFavoritesToUsername();
-		getChild<LLComboBox>("username_combo")->setTextChangedCallback(boost::bind(&LLPanelLogin::addFavoritesToStartLocation, this));
-	}
+	// Show last logged in user favorites in "Start at" combo.
+	addUsersWithFavoritesToUsername();
+	getChild<LLComboBox>("username_combo")->setTextChangedCallback(boost::bind(&LLPanelLogin::addFavoritesToStartLocation, this));
 
 	updateLocationCombo(false);
 
 	{
 	  sInstance->getChild<LLComboBox>("username_combo")->setLabel(std::string());	
 	}
-	if (gSavedSettings.getBOOL("ShowFavoritesOnLogin"))
-	{
-		sInstance->addFavoritesToStartLocation();
-	}
+	sInstance->addFavoritesToStartLocation();
 	// if the password exists in the credential, set the password field with
 	// a filler to get some stars
 	LLSD authenticator = credential->getAuthenticator();

indra/newview/llviewerinventory.cpp

 void LLFavoritesOrderStorage::destroyClass()
 {
 	LLFavoritesOrderStorage::instance().cleanup();
-	if (gSavedSettings.getBOOL("ShowFavoritesOnLogin"))
+	if (gSavedPerAccountSettings.getBOOL("ShowFavoritesOnLogin"))
 	{
 		LLFavoritesOrderStorage::instance().saveFavoritesSLURLs();
 	}

indra/newview/skins/default/xui/en/panel_preferences_privacy.xml

      width="350" />
     <check_box
      control_name="ShowFavoritesOnLogin"
+     enabled="false" 
      height="16"
      label="Show my Favorite Landmarks at Login (via &apos;Start At&apos; drop-down menu)"
      layout="topleft"