From ef0b48ce5a918d30e4303c7b6eebec69c21ab8cf Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Fri, 1 Oct 2021 14:09:12 +0300
Subject: [PATCH] SL-16119 Viewer should now direct IM 2 Email setting to web

---
 indra/newview/llagent.cpp                     | 21 +++++++---------
 indra/newview/llagent.h                       |  6 ++---
 indra/newview/llfloaterpreference.cpp         | 23 ++++--------------
 indra/newview/llfloaterpreference.h           |  5 ++--
 indra/newview/llviewermessage.cpp             |  5 +---
 .../default/xui/en/floater_preferences.xml    |  6 -----
 .../default/xui/en/panel_preferences_chat.xml | 24 +++++++++++--------
 7 files changed, 33 insertions(+), 57 deletions(-)

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 1e7711e5770..50e0d1d9354 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -4636,23 +4636,19 @@ void LLAgent::requestAgentUserInfoCoro(std::string capurl)
         return;
     }
 
-    bool im_via_email;
-    bool is_verified_email;
     std::string email;
     std::string dir_visibility;
 
-    im_via_email = result["im_via_email"].asBoolean();
-    is_verified_email = result["is_verified"].asBoolean();
     email = result["email"].asString();
     dir_visibility = result["directory_visibility"].asString();
 
     // TODO: This should probably be changed.  I'm not entirely comfortable 
     // having LLAgent interact directly with the UI in this way.
-    LLFloaterPreference::updateUserInfo(dir_visibility, im_via_email, is_verified_email);
+    LLFloaterPreference::updateUserInfo(dir_visibility);
     LLFloaterSnapshot::setAgentEmail(email);
 }
 
-void LLAgent::sendAgentUpdateUserInfo(bool im_via_email, const std::string& directory_visibility)
+void LLAgent::sendAgentUpdateUserInfo(const std::string& directory_visibility)
 {
     std::string cap;
 
@@ -4665,16 +4661,16 @@ void LLAgent::sendAgentUpdateUserInfo(bool im_via_email, const std::string& dire
     if (!cap.empty())
     {
         LLCoros::instance().launch("updateAgentUserInfoCoro",
-            boost::bind(&LLAgent::updateAgentUserInfoCoro, this, cap, im_via_email, directory_visibility));
+            boost::bind(&LLAgent::updateAgentUserInfoCoro, this, cap, directory_visibility));
     }
     else
     {
-        sendAgentUpdateUserInfoMessage(im_via_email, directory_visibility);
+        sendAgentUpdateUserInfoMessage(directory_visibility);
     }
 }
 
 
-void LLAgent::updateAgentUserInfoCoro(std::string capurl, bool im_via_email, std::string directory_visibility)
+void LLAgent::updateAgentUserInfoCoro(std::string capurl, std::string directory_visibility)
 {
     LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
     LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
@@ -4685,8 +4681,8 @@ void LLAgent::updateAgentUserInfoCoro(std::string capurl, bool im_via_email, std
 
     httpOpts->setFollowRedirects(true);
     LLSD body(LLSDMap
-        ("dir_visibility",  LLSD::String(directory_visibility))
-        ("im_via_email",    LLSD::Boolean(im_via_email)));
+        ("dir_visibility",  LLSD::String(directory_visibility)));
+
 
     LLSD result = httpAdapter->postAndSuspend(httpRequest, capurl, body, httpOpts, httpHeaders);
 
@@ -4714,14 +4710,13 @@ void LLAgent::sendAgentUserInfoRequestMessage()
     sendReliableMessage();
 }
 
-void LLAgent::sendAgentUpdateUserInfoMessage(bool im_via_email, const std::string& directory_visibility)
+void LLAgent::sendAgentUpdateUserInfoMessage(const std::string& directory_visibility)
 {
     gMessageSystem->newMessageFast(_PREHASH_UpdateUserInfo);
     gMessageSystem->nextBlockFast(_PREHASH_AgentData);
     gMessageSystem->addUUIDFast(_PREHASH_AgentID, getID());
     gMessageSystem->addUUIDFast(_PREHASH_SessionID, getSessionID());
     gMessageSystem->nextBlockFast(_PREHASH_UserData);
-    gMessageSystem->addBOOLFast(_PREHASH_IMViaEMail, im_via_email);
     gMessageSystem->addString("DirectoryVisibility", directory_visibility);
     gAgent.sendReliableMessage();
 
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index 134540c6b3d..498bea3c070 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -928,14 +928,14 @@ class LLAgent : public LLOldEvents::LLObservable
 	void 			sendAgentUserInfoRequest();
 
 // IM to Email and Online visibility
-	void			sendAgentUpdateUserInfo(bool im_to_email, const std::string& directory_visibility);
+	void			sendAgentUpdateUserInfo(const std::string& directory_visibility);
 
 private:
     void            requestAgentUserInfoCoro(std::string capurl);
-    void            updateAgentUserInfoCoro(std::string capurl, bool im_via_email, std::string directory_visibility);
+    void            updateAgentUserInfoCoro(std::string capurl, std::string directory_visibility);
     // DEPRECATED: may be removed when User Info cap propagates 
     void 			sendAgentUserInfoRequestMessage();
-    void            sendAgentUpdateUserInfoMessage(bool im_via_email, const std::string& directory_visibility);
+    void            sendAgentUpdateUserInfoMessage(const std::string& directory_visibility);
 
 	//--------------------------------------------------------------------
 	// Receive
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 82f01fb7476..da01457126f 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -261,7 +261,6 @@ std::string LLFloaterPreference::sSkin = "";
 LLFloaterPreference::LLFloaterPreference(const LLSD& key)
 	: LLFloater(key),
 	mGotPersonalInfo(false),
-	mOriginalIMViaEmail(false),
 	mLanguageChanged(false),
 	mAvatarDataInitialized(false),
 	mSearchDataDirty(true)
@@ -557,11 +556,9 @@ void LLFloaterPreference::apply()
 	
 	if (mGotPersonalInfo)
 	{ 
-		bool new_im_via_email = getChild<LLUICtrl>("send_im_to_email")->getValue().asBoolean();
 		bool new_hide_online = getChild<LLUICtrl>("online_visibility")->getValue().asBoolean();		
 	
-		if ((new_im_via_email != mOriginalIMViaEmail)
-			||(new_hide_online != mOriginalHideOnlineStatus))
+		if (new_hide_online != mOriginalHideOnlineStatus)
 		{
 			// This hack is because we are representing several different 	 
 			// possible strings with a single checkbox. Since most users 	 
@@ -575,7 +572,7 @@ void LLFloaterPreference::apply()
 			 //Update showonline value, otherwise multiple applys won't work
 				mOriginalHideOnlineStatus = new_hide_online;
 			}
-			gAgent.sendAgentUpdateUserInfo(new_im_via_email,mDirectoryVisibility);
+			gAgent.sendAgentUpdateUserInfo(mDirectoryVisibility);
 		}
 	}
 
@@ -980,12 +977,12 @@ void LLFloaterPreference::onBtnCancel(const LLSD& userdata)
 }
 
 // static 
-void LLFloaterPreference::updateUserInfo(const std::string& visibility, bool im_via_email, bool is_verified_email)
+void LLFloaterPreference::updateUserInfo(const std::string& visibility)
 {
 	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
 	if (instance)
 	{
-        instance->setPersonalInfo(visibility, im_via_email, is_verified_email);
+        instance->setPersonalInfo(visibility);
 	}
 }
 
@@ -1694,10 +1691,9 @@ bool LLFloaterPreference::moveTranscriptsAndLog()
 	return true;
 }
 
-void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im_via_email, bool is_verified_email)
+void LLFloaterPreference::setPersonalInfo(const std::string& visibility)
 {
 	mGotPersonalInfo = true;
-	mOriginalIMViaEmail = im_via_email;
 	mDirectoryVisibility = visibility;
 	
 	if (visibility == VISIBILITY_DEFAULT)
@@ -1719,16 +1715,7 @@ void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im
 	getChildView("friends_online_notify_checkbox")->setEnabled(TRUE);
 	getChild<LLUICtrl>("online_visibility")->setValue(mOriginalHideOnlineStatus); 	 
 	getChild<LLUICtrl>("online_visibility")->setLabelArg("[DIR_VIS]", mDirectoryVisibility);
-	getChildView("send_im_to_email")->setEnabled(is_verified_email);
 
-    std::string tooltip;
-    if (!is_verified_email)
-        tooltip = getString("email_unverified_tooltip");
-
-    getChildView("send_im_to_email")->setToolTip(tooltip);
-
-    // *TODO: Show or hide verify email text here based on is_verified_email
-    getChild<LLUICtrl>("send_im_to_email")->setValue(im_via_email);
 	getChildView("favorites_on_login_check")->setEnabled(TRUE);
 	getChildView("log_path_button")->setEnabled(TRUE);
 	getChildView("chat_font_size")->setEnabled(TRUE);
diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index 4c8568c385f..5ef2ca68d36 100644
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -88,7 +88,7 @@ class LLFloaterPreference : public LLFloater, public LLAvatarPropertiesObserver,
 	/*virtual*/ void changed(const LLUUID& session_id, U32 mask) {};
 
 	// static data update, called from message handler
-	static void updateUserInfo(const std::string& visibility, bool im_via_email, bool is_verified_email);
+	static void updateUserInfo(const std::string& visibility);
 
 	// refresh all the graphics preferences menus
 	static void refreshEnabledGraphics();
@@ -160,7 +160,7 @@ class LLFloaterPreference : public LLFloater, public LLAvatarPropertiesObserver,
 	void changeLogPath(const std::vector<std::string>& filenames, std::string proposed_name);
 	bool moveTranscriptsAndLog();
 	void enableHistory();
-	void setPersonalInfo(const std::string& visibility, bool im_via_email, bool is_verified_email);
+	void setPersonalInfo(const std::string& visibility);
 	void refreshEnabledState();
 	void onCommitWindowedMode();
 	void refresh();	// Refresh enable/disable
@@ -206,7 +206,6 @@ class LLFloaterPreference : public LLFloater, public LLAvatarPropertiesObserver,
 	static std::string sSkin;
 	notifications_map mNotificationOptions;
 	bool mGotPersonalInfo;
-	bool mOriginalIMViaEmail;
 	bool mLanguageChanged;
 	bool mAvatarDataInitialized;
 	std::string mPriorInstantMessageLogPath;
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 0c55e3276b6..14442c97050 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -6430,15 +6430,12 @@ void process_user_info_reply(LLMessageSystem* msg, void**)
 				<< "wrong agent id." << LL_ENDL;
 	}
 	
-	BOOL im_via_email;
-	msg->getBOOLFast(_PREHASH_UserData, _PREHASH_IMViaEMail, im_via_email);
 	std::string email;
 	msg->getStringFast(_PREHASH_UserData, _PREHASH_EMail, email);
 	std::string dir_visibility;
 	msg->getString( "UserData", "DirectoryVisibility", dir_visibility);
 
-    // For Message based user info information the is_verified is assumed to be false.
-	LLFloaterPreference::updateUserInfo(dir_visibility, im_via_email, false);   
+	LLFloaterPreference::updateUserInfo(dir_visibility);   
 	LLFloaterSnapshot::setAgentEmail(email);
 }
 
diff --git a/indra/newview/skins/default/xui/en/floater_preferences.xml b/indra/newview/skins/default/xui/en/floater_preferences.xml
index ee730dcb013..c4adf0409d6 100644
--- a/indra/newview/skins/default/xui/en/floater_preferences.xml
+++ b/indra/newview/skins/default/xui/en/floater_preferences.xml
@@ -11,12 +11,6 @@
  single_instance="true"
  title="PREFERENCES"
  width="658">
-    <floater.string
-     name="email_unverified_tooltip">
-        Please verify your email to enable IM to Email by visiting
-https://accounts.secondlife.com/change_email/
-    </floater.string>
- 
    <button
      follows="right|bottom"
      height="23"
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml
index c023cb036ee..fee745aca32 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml
@@ -41,16 +41,6 @@
         width="330">
     </check_box>
 
-    <check_box
-        enabled="false"
-        height="16"
-        label="Email me IMs when I'm offline"
-        layout="topleft"
-        name="send_im_to_email"
-        top_pad="6"
-        width="330">
-    </check_box>
-
     <check_box
         enabled="false"
         height="16"
@@ -61,6 +51,20 @@
         width="350">     
     </check_box>
 
+    <text
+       font="SansSerifSmall"
+       height="16"
+       layout="topleft"
+       length="1"       
+       name="email_settings"
+       skip_link_underline="true"
+       top_pad="6"
+       left_delta="2"
+       type="string"
+       width="350">
+      [https://accounts.secondlife.com/change_email Open email notification settings]
+    </text>
+
     <text
         layout="topleft"
         left="345"
-- 
GitLab