From 84f06e40e1e12723228e31d1a329c899cec99751 Mon Sep 17 00:00:00 2001
From: Leyla Farazha <leyla@lindenlab.com>
Date: Wed, 13 Oct 2010 14:36:01 -0700
Subject: [PATCH] DN-165 User cannot reset name to default if they are
 throttled because they receive the Sorry you cannot change your display name
 until [time] message. They cannot access the change display name dialog to
 hit reset when throttled.

---
 indra/newview/llfloaterdisplayname.cpp        | 57 +++++++++++++++++--
 indra/newview/llpanelme.cpp                   | 12 ----
 .../default/xui/en/floater_display_name.xml   | 34 ++++++++---
 .../skins/default/xui/en/notifications.xml    | 10 +---
 4 files changed, 79 insertions(+), 34 deletions(-)

diff --git a/indra/newview/llfloaterdisplayname.cpp b/indra/newview/llfloaterdisplayname.cpp
index 11ac3d8fdf2..ac8f1079280 100644
--- a/indra/newview/llfloaterdisplayname.cpp
+++ b/indra/newview/llfloaterdisplayname.cpp
@@ -67,6 +67,37 @@ void LLFloaterDisplayName::onOpen(const LLSD& key)
 {
 	getChild<LLUICtrl>("display_name_editor")->clear();
 	getChild<LLUICtrl>("display_name_confirm")->clear();
+
+	LLAvatarName av_name;
+	LLAvatarNameCache::get(gAgent.getID(), &av_name);
+
+	F64 now_secs = LLDate::now().secondsSinceEpoch();
+
+	if (now_secs < av_name.mNextUpdate)
+	{
+		// ...can't update until some time in the future
+		F64 next_update_local_secs =
+			av_name.mNextUpdate - LLStringOps::getLocalTimeOffset();
+		LLDate next_update_local(next_update_local_secs);
+		// display as "July 18 12:17 PM"
+		std::string next_update_string =
+		next_update_local.toHTTPDateString("%B %d %I:%M %p");
+		getChild<LLUICtrl>("lockout_text")->setTextArg("[TIME]", next_update_string);
+		getChild<LLUICtrl>("lockout_text")->setVisible(true);
+		getChild<LLUICtrl>("save_btn")->setEnabled(false);
+		getChild<LLUICtrl>("display_name_editor")->setEnabled(false);
+		getChild<LLUICtrl>("display_name_confirm")->setEnabled(false);
+		getChild<LLUICtrl>("cancel_btn")->setFocus(TRUE);
+		
+	}
+	else
+	{
+		getChild<LLUICtrl>("lockout_text")->setVisible(false);
+		getChild<LLUICtrl>("save_btn")->setEnabled(true);
+		getChild<LLUICtrl>("display_name_editor")->setEnabled(true);
+		getChild<LLUICtrl>("display_name_confirm")->setEnabled(true);
+
+	}
 }
 
 BOOL LLFloaterDisplayName::postBuild()
@@ -133,9 +164,16 @@ void LLFloaterDisplayName::onCancel()
 
 void LLFloaterDisplayName::onReset()
 {
-	LLViewerDisplayName::set("",
-		boost::bind(&LLFloaterDisplayName::onCacheSetName, this, _1, _2, _3));
-
+	if (LLAvatarNameCache::useDisplayNames())
+	{
+		LLViewerDisplayName::set("",
+			boost::bind(&LLFloaterDisplayName::onCacheSetName, this, _1, _2, _3));
+	}	
+	else
+	{
+		LLNotificationsUtil::add("SetDisplayNameFailedGeneric");
+	}
+	
 	setVisible(false);
 }
 
@@ -160,9 +198,16 @@ void LLFloaterDisplayName::onSave()
 		LLNotificationsUtil::add("SetDisplayNameFailedLength", args);
 		return;
 	}
-
-	LLViewerDisplayName::set(display_name_utf8,
-		boost::bind(&LLFloaterDisplayName::onCacheSetName, this, _1, _2, _3));	
+	
+	if (LLAvatarNameCache::useDisplayNames())
+	{
+		LLViewerDisplayName::set(display_name_utf8,
+			boost::bind(&LLFloaterDisplayName::onCacheSetName, this, _1, _2, _3));	
+	}
+	else
+	{
+		LLNotificationsUtil::add("SetDisplayNameFailedGeneric");
+	}
 
 	setVisible(false);
 }
diff --git a/indra/newview/llpanelme.cpp b/indra/newview/llpanelme.cpp
index f587923269c..a9f7b6c62cf 100644
--- a/indra/newview/llpanelme.cpp
+++ b/indra/newview/llpanelme.cpp
@@ -394,18 +394,6 @@ void LLPanelMyProfileEdit::onAvatarNameCache(const LLUUID& agent_id, const LLAva
 			LLNotificationsUtil::add("SetDisplayNameBlocked");
 			return;
 		}
-	
-		// ...can't update until some time in the future
-		F64 next_update_local_secs =
-			av_name.mNextUpdate - LLStringOps::getLocalTimeOffset();
-		LLDate next_update_local(next_update_local_secs);
-		// display as "July 18 12:17 PM"
-		std::string next_update_string =
-		next_update_local.toHTTPDateString("%B %d %I:%M %p");
-		LLSD args;
-		args["TIME"] = next_update_string;
-		LLNotificationsUtil::add("SetDisplayNameFailedLockout", args);
-		return;
 	}
 	
 	LLFloaterReg::showInstance("display_name");
diff --git a/indra/newview/skins/default/xui/en/floater_display_name.xml b/indra/newview/skins/default/xui/en/floater_display_name.xml
index ecf2e524aa0..7a3fb9334aa 100644
--- a/indra/newview/skins/default/xui/en/floater_display_name.xml
+++ b/indra/newview/skins/default/xui/en/floater_display_name.xml
@@ -3,12 +3,13 @@
  legacy_header_height="18"
  can_minimize="false"
  can_close="false" 
- height="280"
+ height="300"
  layout="topleft"
  name="Display Name"
  help_topic="display_name"
  save_rect="false"
- width="440">
+ title="CHANGE DISPLAY NAME" 
+ width="445">
     <text
      type="string"
      length="1"
@@ -20,17 +21,34 @@
      name="info_text"
      top="40"
      use_ellipses="true"
-     width="400"
+     width="380"
      wrap="true">
       The name you give your avatar is called your Display Name. You can change it once a week.
     </text>
+	<text
+     type="string"
+     length="1"
+     follows="left|top"
+     font="SansSerif"
+     height="25"
+     layout="topleft"
+     left="25"
+	 text_color="EmphasisColor" 
+     name="lockout_text"
+     top="80"
+     use_ellipses="true"
+	 visible="false" 
+     width="410"
+     wrap="true">
+		You cannot change your Display Name until: [TIME].
+	</text>
     <text
-      top_pad="15"
+      top_pad="10"
       width="150"
       height="20"
       font="SansSerif"
       name="set_name_label">
-      New display name:
+      New Display Name:
     </text>
     <line_editor
       width="330"
@@ -39,9 +57,9 @@
       height="20"
       top_pad="5"
       left="50" />
-    <text
+	<text
        top_pad="15"
-       left="25" 
+       left="25"
        width="300"
        height="20"
       font="SansSerif"
@@ -62,6 +80,7 @@
      font="SansSerif"
      left="35"
      name="save_btn"
+     tool_tip="Save your new Display Name" 
      top_pad="40"
      width="120" />
     <button
@@ -71,6 +90,7 @@
      font="SansSerif"
      left_pad="5"
      name="reset_btn"
+     tool_tip="Make Display Name the same as Username"
      width="120" />
     <button
      height="23"
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index 4e25efe5559..7e9cc6772d9 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -3193,14 +3193,6 @@ Hi [DISPLAY_NAME]!
 Just like in real life, it takes a while for everyone to learn about a new name.  Please allow several days for [http://wiki.secondlife.com/wiki/Setting_your_display_name your name to update] in objects, scripts, search, etc.
   </notification>
 
-  <notification
-   icon="alertmodal.tga"
-   name="SetDisplayNameFailedLockout"
-   type="alert">
-Sorry, you cannot [http://wiki.secondlife.com/wiki/Setting_your_display_name change your display name] until:
-[TIME]
-  </notification>
-
   <notification
  icon="alertmodal.tga"
  name="SetDisplayNameBlocked"
@@ -3231,7 +3223,7 @@ Please try a shorter name.
     The display names you entered do not match. Please re-enter.
   </notification>
 
-  <!-- *NOTE: This should never happen, users should see SetDisplayNameFailedLockout above -->
+  <!-- *NOTE: This should never happen -->
   <notification
    icon="alertmodal.tga"
    name="AgentDisplayNameUpdateThresholdExceeded"
-- 
GitLab