From 66522bb6bdff50f5f6838c1410e2cc4ab45a0a62 Mon Sep 17 00:00:00 2001
From: Gilbert Gonzales <gilbert@lindenlab.com>
Date: Tue, 23 Jul 2013 13:31:41 -0700
Subject: ACME-677 Make the 'Connect...', 'Disconnect' and 'Use another
 account...' buttons disabled upon clicking

---
 indra/newview/llfacebookconnect.cpp            | 12 +++++++++++-
 indra/newview/llfacebookconnect.h              |  5 +++--
 indra/newview/llfloatersocial.cpp              | 23 +++++++++++++++++++++++
 indra/newview/llfloatersocial.h                |  1 +
 indra/newview/skins/default/xui/en/strings.xml |  1 +
 5 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp
index 0d6806d252..cccfb6f2b8 100644
--- a/indra/newview/llfacebookconnect.cpp
+++ b/indra/newview/llfacebookconnect.cpp
@@ -181,7 +181,12 @@ class LLFacebookDisconnectResponder : public LLHTTPClient::Responder
 {
 	LOG_CLASS(LLFacebookDisconnectResponder);
 public:
-    
+ 
+	LLFacebookDisconnectResponder()
+	{
+		LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_DISCONNECTING);
+	}
+
 	virtual void completed(U32 status, const std::string& reason, const LLSD& content)
 	{
 		if (isGoodStatus(status))
@@ -252,6 +257,11 @@ class LLFacebookDisconnectThenConnectResponder : public LLHTTPClient::Responder
 	LOG_CLASS(LLFacebookDisconnectThenConnectResponder);
 public:
 
+	LLFacebookDisconnectThenConnectResponder()
+	{
+		LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_DISCONNECTING);
+	}
+
 	virtual void completed(U32 status, const std::string& reason, const LLSD& content)
 	{
 		if (isGoodStatus(status))
diff --git a/indra/newview/llfacebookconnect.h b/indra/newview/llfacebookconnect.h
index b59c7090f6..f74b9f7d41 100644
--- a/indra/newview/llfacebookconnect.h
+++ b/indra/newview/llfacebookconnect.h
@@ -51,7 +51,8 @@ public:
 		FB_CONNECTION_FAILED = 3,
 		FB_POSTING = 4,
 		FB_POSTED = 5,
-		FB_POST_FAILED = 6
+		FB_POST_FAILED = 6,
+		FB_DISCONNECTING = 7
 	};
 	
 	void connectToFacebook(const std::string& auth_code = "", const std::string& auth_state = "");	// Initiate the complete FB connection. Please use checkConnectionToFacebook() in normal use.
@@ -73,7 +74,7 @@ public:
     const LLSD& getContent() const;
     
     void setConnectionState(EConnectionState connection_state);
-	bool isConnected() { return ((mConnectionState == FB_CONNECTED) || (mConnectionState == FB_POSTING) || (mConnectionState == FB_POSTED)); }
+	bool isConnected() { return ((mConnectionState == FB_CONNECTED) || (mConnectionState == FB_DISCONNECTING) || (mConnectionState == FB_POSTING) || (mConnectionState == FB_POSTED)); }
 	bool isTransactionOngoing() { return ((mConnectionState == FB_CONNECTION_IN_PROGRESS) || (mConnectionState == FB_POSTING)); }
     EConnectionState getConnectionState() { return mConnectionState; }
     S32  generation() { return mGeneration; }
diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp
index 2eb112d328..3c8d4d6fb9 100644
--- a/indra/newview/llfloatersocial.cpp
+++ b/indra/newview/llfloatersocial.cpp
@@ -641,6 +641,22 @@ BOOL LLSocialAccountPanel::postBuild()
 	return LLPanel::postBuild();
 }
 
+void LLSocialAccountPanel::draw()
+{
+	LLFacebookConnect::EConnectionState connection_state = LLFacebookConnect::instance().getConnectionState();
+
+	//Disable the 'disconnect' button and the 'use another account' button when disconnecting in progress
+	bool disconnecting = connection_state == LLFacebookConnect::FB_DISCONNECTING;
+	mDisconnectButton->setEnabled(!disconnecting);
+	mUseAnotherAccountButton->setEnabled(!disconnecting);
+
+	//Disable the 'connect' button when a connection is in progress
+	bool connecting = connection_state == LLFacebookConnect::FB_CONNECTION_IN_PROGRESS;
+	mConnectButton->setEnabled(!connecting);
+
+	LLPanel::draw();
+}
+
 void LLSocialAccountPanel::onVisibilityChange(const LLSD& new_visibility)
 {
 	bool visible = new_visibility.asBoolean();
@@ -862,6 +878,13 @@ void LLFloaterSocial::draw()
             status_text = LLTrans::getString("SocialFacebookErrorPosting");
             mStatusErrorText->setValue(status_text);
             break;
+		case LLFacebookConnect::FB_DISCONNECTING:
+			// Disconnecting loading indicator
+			mStatusLoadingText->setVisible(true);
+			status_text = LLTrans::getString("SocialFacebookDisconnecting");
+			mStatusLoadingText->setValue(status_text);
+			mStatusLoadingIndicator->setVisible(true);
+			break;
         }
     }
 	LLFloater::draw();
diff --git a/indra/newview/llfloatersocial.h b/indra/newview/llfloatersocial.h
index f947207fbe..13c29e7028 100644
--- a/indra/newview/llfloatersocial.h
+++ b/indra/newview/llfloatersocial.h
@@ -120,6 +120,7 @@ class LLSocialAccountPanel : public LLPanel
 public:
 	LLSocialAccountPanel();
 	BOOL postBuild();
+	void draw();
 
 private:
 	void onVisibilityChange(const LLSD& new_visibility);
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index 5067922b88..02b64ef7e3 100755
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -153,6 +153,7 @@ Please try logging in again in a minute.</string>
 	<string name="SocialFacebookPosting">Posting...</string>
 	<string name="SocialFacebookErrorConnecting">Problem connecting to Facebook</string>
 	<string name="SocialFacebookErrorPosting">Problem posting to Facebook</string>
+	<string name="SocialFacebookDisconnecting">Disconnecting from Facebook...</string>
     
 	<!-- Tooltip -->
 	<string name="TooltipPerson">Person</string><!-- Object under mouse pointer is an avatar -->
-- 
cgit v1.2.3