diff options
author | Cho <cho@lindenlab.com> | 2013-07-02 01:21:38 +0100 |
---|---|---|
committer | Cho <cho@lindenlab.com> | 2013-07-02 01:21:38 +0100 |
commit | 1449e645c61f3b31568e38e3c4daf531189323c6 (patch) | |
tree | f6f2d2e3b0a4509fee357541e6183b335f664564 | |
parent | fa1e0e486a2c32911e6bfe9d72264c3d9ebe1d9f (diff) |
added callback to LLFacebookConnect upon connect for ACME-659
-rw-r--r-- | indra/newview/llfacebookconnect.cpp | 35 | ||||
-rw-r--r-- | indra/newview/llfacebookconnect.h | 9 | ||||
-rwxr-xr-x | indra/newview/llpanelpeople.cpp | 2 |
3 files changed, 35 insertions, 11 deletions
diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 24100a9a55..5d6c496275 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -88,10 +88,16 @@ class LLFacebookConnectResponder : public LLHTTPClient::Responder { LOG_CLASS(LLFacebookConnectResponder); public: + LLFacebookConnectResponder() { LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); } + + LLFacebookConnectResponder(LLFacebookConnect::connect_callback_t cb) : mConnectCallback(cb) + { + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); + } virtual void completed(U32 status, const std::string& reason, const LLSD& content) { @@ -101,6 +107,11 @@ public: // Grab some graph data now that we are connected LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED); + + if (mConnectCallback) + { + mConnectCallback(); + } } else { @@ -117,6 +128,8 @@ public: } } +private: + LLFacebookConnect::connect_callback_t mConnectCallback; }; /////////////////////////////////////////////////////////////////////////////// @@ -195,14 +208,23 @@ public: LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); } + LLFacebookConnectedResponder(bool auto_connect, LLFacebookConnect::connect_callback_t cb) : mAutoConnect(auto_connect), mConnectCallback(cb) + { + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); + } + virtual void completed(U32 status, const std::string& reason, const LLSD& content) { if (isGoodStatus(status)) { LL_DEBUGS("FacebookConnect") << "Connect successful. content: " << content << LL_ENDL; - // Grab some graph data if already connected LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED); + + if (mConnectCallback) + { + mConnectCallback(); + } } else { @@ -228,6 +250,7 @@ public: private: bool mAutoConnect; + LLFacebookConnect::connect_callback_t mConnectCallback; }; /////////////////////////////////////////////////////////////////////////////// @@ -283,13 +306,13 @@ std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) return url; } -void LLFacebookConnect::connectToFacebook(const std::string& auth_code) +void LLFacebookConnect::connectToFacebook(const std::string& auth_code, connect_callback_t cb) { LLSD body; if (!auth_code.empty()) body["code"] = auth_code; - LLHTTPClient::put(getFacebookConnectURL("/connection"), body, new LLFacebookConnectResponder()); + LLHTTPClient::put(getFacebookConnectURL("/connection"), body, new LLFacebookConnectResponder(cb)); } void LLFacebookConnect::disconnectFromFacebook() @@ -297,13 +320,13 @@ void LLFacebookConnect::disconnectFromFacebook() LLHTTPClient::del(getFacebookConnectURL("/connection"), new LLFacebookDisconnectResponder()); } -void LLFacebookConnect::getConnectionToFacebook(bool auto_connect) +void LLFacebookConnect::getConnectionToFacebook(bool auto_connect, connect_callback_t cb) { if ((mConnectionState == FB_NOT_CONNECTED) || (mConnectionState == FB_CONNECTION_FAILED)) { - const bool follow_redirects=false; + const bool follow_redirects = false; const F32 timeout=HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(auto_connect), + LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(auto_connect, cb), LLSD(), timeout, follow_redirects); } } diff --git a/indra/newview/llfacebookconnect.h b/indra/newview/llfacebookconnect.h index c54da8e3f3..abd6fb385d 100644 --- a/indra/newview/llfacebookconnect.h +++ b/indra/newview/llfacebookconnect.h @@ -48,13 +48,14 @@ public: FB_CONNECTED = 2, FB_CONNECTION_FAILED = 3 }; - + + typedef boost::function<void()> connect_callback_t; typedef boost::function<void(bool ok)> share_callback_t; typedef boost::function<void()> content_updated_callback_t; - void connectToFacebook(const std::string& auth_code = ""); // Initiate the complete FB connection. Please use getConnectionToFacebook() in normal use. - void disconnectFromFacebook(); // Disconnect from the FBC service. - void getConnectionToFacebook(bool auto_connect = false); // Check if an access token is available on the FBC service. If not, call connectToFacebook(). + void connectToFacebook(const std::string& auth_code = "", connect_callback_t cb = connect_callback_t()); // Initiate the complete FB connection. Please use getConnectionToFacebook() in normal use. + void disconnectFromFacebook(); // Disconnect from the FBC service. + void getConnectionToFacebook(bool auto_connect = false, connect_callback_t cb = connect_callback_t()); // Check if an access token is available on the FBC service. If not, call connectToFacebook(). void loadFacebookFriends(); void postCheckin(const std::string& location, const std::string& name, const std::string& description, const std::string& picture, const std::string& message); diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index 457ccb8285..6568b7054e 100755 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -863,7 +863,7 @@ void LLPanelPeople::updateFacebookList(bool visible) if (mTryToConnectToFbc) { // try to reconnect to facebook! - LLFacebookConnect::instance().getConnectionToFacebook(); + LLFacebookConnect::instance().getConnectionToFacebook(false, boost::bind(&LLFacebookConnect::loadFacebookFriends, &LLFacebookConnect::instance())); // don't try again mTryToConnectToFbc = false; |