From 882b2508db4519b328016802ab72093df7911e68 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Mon, 22 Jul 2013 18:49:22 -0700 Subject: ACME-729 Implement the 'Use another account...' button --- indra/newview/llfacebookconnect.cpp | 34 ++++++++++++++++++++++++++++++++++ indra/newview/llfacebookconnect.h | 1 + indra/newview/llfloatersocial.cpp | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 7c1e7b3b16..0d6806d252 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -245,6 +245,35 @@ private: bool mAutoConnect; }; +/////////////////////////////////////////////////////////////////////////////// +// +class LLFacebookDisconnectThenConnectResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLFacebookDisconnectThenConnectResponder); +public: + + virtual void completed(U32 status, const std::string& reason, const LLSD& content) + { + if (isGoodStatus(status)) + { + LL_DEBUGS("FacebookConnect") << "Disconnect successful. content: " << content << LL_ENDL; + + // Clear all facebook stuff + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED); + LLFacebookConnect::instance().clearContent(); + + LLViewerMedia::clearAllCookies(); + + //Now attempt to reconnect + LLFacebookConnect::instance().checkConnectionToFacebook(true); + } + else + { + log_facebook_connect_error("Disconnect", status, reason, content.get("error_code"), content.get("error_description")); + } + } +}; + /////////////////////////////////////////////////////////////////////////////// // class LLFacebookInfoResponder : public LLHTTPClient::Responder @@ -363,6 +392,11 @@ void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect) } } +void LLFacebookConnect::disconnectThenConnectToFacebook() +{ + LLHTTPClient::del(getFacebookConnectURL("/connection"), new LLFacebookDisconnectThenConnectResponder()); +} + void LLFacebookConnect::loadFacebookInfo() { const bool follow_redirects = false; diff --git a/indra/newview/llfacebookconnect.h b/indra/newview/llfacebookconnect.h index 1dbc35c27f..b59c7090f6 100644 --- a/indra/newview/llfacebookconnect.h +++ b/indra/newview/llfacebookconnect.h @@ -57,6 +57,7 @@ public: void connectToFacebook(const std::string& auth_code = "", const std::string& auth_state = ""); // Initiate the complete FB connection. Please use checkConnectionToFacebook() in normal use. void disconnectFromFacebook(); // Disconnect from the FBC service. void checkConnectionToFacebook(bool auto_connect = false); // Check if an access token is available on the FBC service. If not, call connectToFacebook(). + void disconnectThenConnectToFacebook(); // Disconnects and then connects (for switching FB accounts) void loadFacebookInfo(); void loadFacebookFriends(); diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp index e93a560f8f..f0bd1bb71a 100644 --- a/indra/newview/llfloatersocial.cpp +++ b/indra/newview/llfloatersocial.cpp @@ -750,7 +750,7 @@ void LLSocialAccountPanel::onConnect() void LLSocialAccountPanel::onUseAnotherAccount() { - + LLFacebookConnect::instance().disconnectThenConnectToFacebook(); } void LLSocialAccountPanel::onDisconnect() -- cgit v1.2.3