diff options
author | Merov Linden <merov@lindenlab.com> | 2013-07-19 17:55:44 -0700 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2013-07-19 17:55:44 -0700 |
commit | ae4c17dee1cfc6a11ea165c5bd140d75203cfe69 (patch) | |
tree | 6bc814651ec67ea42b8bcf3e0d2bd5f776b1bd96 /indra | |
parent | 652ec2feeeb39c5c7ec9553563e3fdc29c66780d (diff) | |
parent | c3c61018cd2d6547c4976c04edc4d3212cf3fb31 (diff) |
Pull merge from lindenlab/viewer-fbc
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 | 90 | ||||
-rw-r--r-- | indra/newview/llfloatersocial.h | 5 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_social_account.xml | 21 |
5 files changed, 159 insertions, 12 deletions
diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index eb9b93161c..f0b735c5ca 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); @@ -333,6 +364,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; @@ -431,6 +470,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 66624f6355..d734518cbb 100644 --- a/indra/newview/llfloatersocial.cpp +++ b/indra/newview/llfloatersocial.cpp @@ -625,6 +625,8 @@ mDisconnectButton(NULL) mCommitCallbackRegistrar.add("SocialSharing.Connect", boost::bind(&LLSocialAccountPanel::onConnect, this)); mCommitCallbackRegistrar.add("SocialSharing.UseAnotherAccount", boost::bind(&LLSocialAccountPanel::onUseAnotherAccount, this)); mCommitCallbackRegistrar.add("SocialSharing.Disconnect", boost::bind(&LLSocialAccountPanel::onDisconnect, this)); + + setVisibleCallback(boost::bind(&LLSocialAccountPanel::onVisibilityChange, this, _2)); } BOOL LLSocialAccountPanel::postBuild() @@ -636,11 +638,76 @@ BOOL LLSocialAccountPanel::postBuild() mUseAnotherAccountButton = getChild<LLUICtrl>("use_another_account_btn"); mDisconnectButton = getChild<LLUICtrl>("disconnect_btn"); - hideConnectButton(); - return LLPanel::postBuild(); } +void LLSocialAccountPanel::onVisibilityChange(const LLSD& new_visibility) +{ + bool visible = new_visibility.asBoolean(); + + if(visible) + { + 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(); + } + else + { + showDisconnectedLayout(); + LLFacebookConnect::instance().checkConnectionToFacebook(); + } + } + else + { + LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialAccountPanel"); + LLEventPumps::instance().obtain("FacebookConnectInfo").stopListening("LLSocialAccountPanel"); + } +} + +bool LLSocialAccountPanel::onFacebookConnectStateChange(const LLSD& data) +{ + + switch (data.get("enum").asInteger()) + { + case LLFacebookConnect::FB_CONNECTED: + case LLFacebookConnect::FB_POSTING: + case LLFacebookConnect::FB_POSTED: + case LLFacebookConnect::FB_POST_FAILED: + showConnectedLayout(); + break; + case LLFacebookConnect::FB_NOT_CONNECTED: + case LLFacebookConnect::FB_CONNECTION_IN_PROGRESS: + case LLFacebookConnect::FB_CONNECTION_FAILED: + showDisconnectedLayout(); + break; + } + + 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()) @@ -671,11 +738,26 @@ void LLSocialAccountPanel::hideConnectButton() } } -void LLSocialAccountPanel::onConnect() +void LLSocialAccountPanel::showDisconnectedLayout() +{ + mAccountCaptionLabel->setText(getString("facebook_disconnected")); + mAccountNameLabel->setText(std::string("")); + showConnectButton(); +} + +void LLSocialAccountPanel::showConnectedLayout() { + LLFacebookConnect::instance().loadFacebookInfo(); + + mAccountCaptionLabel->setText(getString("facebook_connected")); hideConnectButton(); } +void LLSocialAccountPanel::onConnect() +{ + LLFacebookConnect::instance().checkConnectionToFacebook(true); +} + void LLSocialAccountPanel::onUseAnotherAccount() { @@ -683,7 +765,7 @@ void LLSocialAccountPanel::onUseAnotherAccount() void LLSocialAccountPanel::onDisconnect() { - showConnectButton(); + LLFacebookConnect::instance().disconnectFromFacebook(); } //////////////////////// diff --git a/indra/newview/llfloatersocial.h b/indra/newview/llfloatersocial.h index cdd8a71b79..f947207fbe 100644 --- a/indra/newview/llfloatersocial.h +++ b/indra/newview/llfloatersocial.h @@ -122,12 +122,17 @@ public: BOOL postBuild(); private: + void onVisibilityChange(const LLSD& new_visibility); + bool onFacebookConnectStateChange(const LLSD& data); + bool onFacebookConnectInfoChange(); void onConnect(); void onUseAnotherAccount(); void onDisconnect(); void showConnectButton(); void hideConnectButton(); + void showDisconnectedLayout(); + void showConnectedLayout(); LLTextBox * mAccountCaptionLabel; LLTextBox * mAccountNameLabel; 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 838a9ba064..8706aac5ce 100644 --- a/indra/newview/skins/default/xui/en/panel_social_account.xml +++ b/indra/newview/skins/default/xui/en/panel_social_account.xml @@ -3,7 +3,12 @@ width="304" layout="topleft" name="panel_social_account"> - + <string + name="facebook_connected" + value="You are connected to Facebook as:" /> + <string + name="facebook_disconnected" + value="Not connected to Facebook" /> <text layout="topleft" length="1" @@ -14,7 +19,7 @@ name="account_caption_label" top="21" type="string"> - You are connected to Facebook as: + Not connected to Facebook. </text> <text layout="topleft" @@ -25,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" @@ -53,7 +56,8 @@ height="23" label="Use another account..." name="use_another_account_btn" - width="210"> + width="210" + visible="false"> <commit_callback function="SocialSharing.UseAnotherAccount"/> </button> @@ -64,7 +68,8 @@ height="23" label="Disconnect" name="disconnect_btn" - width="210"> + width="210" + visible="false"> <commit_callback function="SocialSharing.Disconnect"/> </button> </panel> |