diff options
author | Gilbert Gonzales <gilbert@lindenlab.com> | 2013-07-19 16:36:55 -0700 |
---|---|---|
committer | Gilbert Gonzales <gilbert@lindenlab.com> | 2013-07-19 16:36:55 -0700 |
commit | c3c61018cd2d6547c4976c04edc4d3212cf3fb31 (patch) | |
tree | f27f917caecfedd35da60b9b855af6551ac80e56 /indra | |
parent | 03563fcaa17c0af776c49baaa59421921603cddd (diff) |
ACME-732 Create the viewer side info route responder
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llfacebookconnect.cpp | 50 | ||||
-rw-r--r-- | indra/newview/llfacebookconnect.h | 5 | ||||
-rw-r--r-- | indra/newview/llfloatersocial.cpp | 24 | ||||
-rw-r--r-- | indra/newview/llfloatersocial.h | 1 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_social_account.xml | 6 |
5 files changed, 81 insertions, 5 deletions
diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index ac92fc6ed5..51abbdf82f 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -44,6 +44,7 @@ #include "llfloaterreg.h" boost::scoped_ptr<LLEventPump> LLFacebookConnect::sStateWatcher(new LLEventStream("FacebookConnectState")); +boost::scoped_ptr<LLEventPump> LLFacebookConnect::sInfoWatcher(new LLEventStream("FacebookConnectInfo")); boost::scoped_ptr<LLEventPump> LLFacebookConnect::sContentWatcher(new LLEventStream("FacebookConnectContent")); // Local functions @@ -246,6 +247,36 @@ private: /////////////////////////////////////////////////////////////////////////////// // +class LLFacebookInfoResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLFacebookInfoResponder); +public: + + virtual void completed(U32 status, const std::string& reason, const LLSD& info) + { + if (isGoodStatus(status)) + { + llinfos << "Facebook: Info received" << llendl; + LL_DEBUGS("FacebookConnect") << "Getting Facebook info successful. info: " << info << LL_ENDL; + LLFacebookConnect::instance().storeInfo(info); + } + else + { + log_facebook_connect_error("Info", status, reason, info.get("error_code"), info.get("error_description")); + } + } + + void completedHeader(U32 status, const std::string& reason, const LLSD& content) + { + if (status == 302) + { + LLFacebookConnect::instance().openFacebookWeb(content["location"]); + } + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// class LLFacebookFriendsResponder : public LLHTTPClient::Responder { LOG_CLASS(LLFacebookFriendsResponder); @@ -329,6 +360,14 @@ void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect) } } +void LLFacebookConnect::loadFacebookInfo() +{ + const bool follow_redirects = false; + const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; + LLHTTPClient::get(getFacebookConnectURL("/info"), new LLFacebookInfoResponder(), + LLSD(), timeout, follow_redirects); +} + void LLFacebookConnect::loadFacebookFriends() { const bool follow_redirects = false; @@ -427,6 +466,17 @@ void LLFacebookConnect::updateStatus(const std::string& message) LLHTTPClient::post(getFacebookConnectURL("/share/wall"), body, new LLFacebookShareResponder()); } +void LLFacebookConnect::storeInfo(const LLSD& info) +{ + mInfo = info; + sInfoWatcher->post(info); +} + +const LLSD& LLFacebookConnect::getInfo() const +{ + return mInfo; +} + void LLFacebookConnect::storeContent(const LLSD& content) { mGeneration++; diff --git a/indra/newview/llfacebookconnect.h b/indra/newview/llfacebookconnect.h index 77b1896c6e..1dbc35c27f 100644 --- a/indra/newview/llfacebookconnect.h +++ b/indra/newview/llfacebookconnect.h @@ -58,12 +58,15 @@ public: 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 loadFacebookInfo(); void loadFacebookFriends(); void postCheckin(const std::string& location, const std::string& name, const std::string& description, const std::string& picture, const std::string& message); void sharePhoto(const std::string& image_url, const std::string& caption); void sharePhoto(LLPointer<LLImageFormatted> image, const std::string& caption); void updateStatus(const std::string& message); + void storeInfo(const LLSD& info); + const LLSD& getInfo() const; void clearContent(); void storeContent(const LLSD& content); const LLSD& getContent() const; @@ -84,10 +87,12 @@ private: std::string getFacebookConnectURL(const std::string& route = ""); EConnectionState mConnectionState; + LLSD mInfo; LLSD mContent; S32 mGeneration; static boost::scoped_ptr<LLEventPump> sStateWatcher; + static boost::scoped_ptr<LLEventPump> sInfoWatcher; static boost::scoped_ptr<LLEventPump> sContentWatcher; }; diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp index e61d86c474..d734518cbb 100644 --- a/indra/newview/llfloatersocial.cpp +++ b/indra/newview/llfloatersocial.cpp @@ -650,6 +650,11 @@ void LLSocialAccountPanel::onVisibilityChange(const LLSD& new_visibility) LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialAccountPanel"); LLEventPumps::instance().obtain("FacebookConnectState").listen("LLSocialAccountPanel", boost::bind(&LLSocialAccountPanel::onFacebookConnectStateChange, this, _1)); + LLFacebookConnect::instance().loadFacebookInfo(); + + LLEventPumps::instance().obtain("FacebookConnectInfo").stopListening("LLSocialAccountPanel"); + LLEventPumps::instance().obtain("FacebookConnectInfo").listen("LLSocialAccountPanel", boost::bind(&LLSocialAccountPanel::onFacebookConnectInfoChange, this)); + if(LLFacebookConnect::instance().isConnected()) { showConnectedLayout(); @@ -663,6 +668,7 @@ void LLSocialAccountPanel::onVisibilityChange(const LLSD& new_visibility) else { LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialAccountPanel"); + LLEventPumps::instance().obtain("FacebookConnectInfo").stopListening("LLSocialAccountPanel"); } } @@ -687,6 +693,21 @@ bool LLSocialAccountPanel::onFacebookConnectStateChange(const LLSD& data) return false; } +bool LLSocialAccountPanel::onFacebookConnectInfoChange() +{ + LLSD info = LLFacebookConnect::instance().getInfo(); + std::string clickable_name; + + if(info.has("link") && info.has("name")) + { + clickable_name = "[" + info["link"].asString() + " " + info["name"].asString() + "]"; + } + + mAccountNameLabel->setText(clickable_name); + + return false; +} + void LLSocialAccountPanel::showConnectButton() { if(!mConnectButton->getVisible()) @@ -726,8 +747,9 @@ void LLSocialAccountPanel::showDisconnectedLayout() void LLSocialAccountPanel::showConnectedLayout() { + LLFacebookConnect::instance().loadFacebookInfo(); + mAccountCaptionLabel->setText(getString("facebook_connected")); - mAccountNameLabel->setText(std::string("[secondlife:/// Philippe Bossut]")); hideConnectButton(); } diff --git a/indra/newview/llfloatersocial.h b/indra/newview/llfloatersocial.h index e49445a39f..f947207fbe 100644 --- a/indra/newview/llfloatersocial.h +++ b/indra/newview/llfloatersocial.h @@ -124,6 +124,7 @@ public: private: void onVisibilityChange(const LLSD& new_visibility); bool onFacebookConnectStateChange(const LLSD& data); + bool onFacebookConnectInfoChange(); void onConnect(); void onUseAnotherAccount(); void onDisconnect(); diff --git a/indra/newview/skins/default/xui/en/panel_social_account.xml b/indra/newview/skins/default/xui/en/panel_social_account.xml index 470e0848d2..8706aac5ce 100644 --- a/indra/newview/skins/default/xui/en/panel_social_account.xml +++ b/indra/newview/skins/default/xui/en/panel_social_account.xml @@ -30,10 +30,8 @@ height="16" left="9" name="account_name_label" - type="string"> - [secondlife:/// Philippe Bossut] - </text> - + parse_urls="true" + type="string"/> <panel layout="topleft" name="panel_buttons" |