From b2e2282e988ab8c7d989d8554a41fda8b8c6e691 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Thu, 18 Jul 2013 16:13:14 -0700 Subject: ACME-727 Display 'Not connected to Facebook' when the user does not have a FB token --- indra/newview/llfloatersocial.cpp | 60 ++++++++++++++++++++-- indra/newview/llfloatersocial.h | 2 + .../skins/default/xui/en/panel_social_account.xml | 15 ++++-- 3 files changed, 70 insertions(+), 7 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp index 66624f6355..d64e4273f4 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,9 +638,61 @@ BOOL LLSocialAccountPanel::postBuild() mUseAnotherAccountButton = getChild("use_another_account_btn"); mDisconnectButton = getChild("disconnect_btn"); + 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)); + + if(LLFacebookConnect::instance().isConnected()) + { hideConnectButton(); + mAccountCaptionLabel->setText(getString("facebook_connected")); + mAccountNameLabel->setText(std::string("[secondlife:/// Philippe Bossut]")); - return LLPanel::postBuild(); + } + else + { + mAccountCaptionLabel->setText(getString("facebook_disconnected")); + mAccountNameLabel->setText(std::string("")); + LLFacebookConnect::instance().checkConnectionToFacebook(); + } + } + else + { + LLEventPumps::instance().obtain("FacebookConnectState").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: + mAccountCaptionLabel->setText(getString("facebook_connected")); + mAccountNameLabel->setText(std::string("[secondlife:/// Philippe Bossut]")); + hideConnectButton(); + break; + case LLFacebookConnect::FB_NOT_CONNECTED: + case LLFacebookConnect::FB_CONNECTION_IN_PROGRESS: + case LLFacebookConnect::FB_CONNECTION_FAILED: + mAccountCaptionLabel->setText(getString("facebook_disconnected")); + mAccountNameLabel->setText(std::string("")); + showConnectButton(); + break; + } + + return false; } void LLSocialAccountPanel::showConnectButton() @@ -673,7 +727,7 @@ void LLSocialAccountPanel::hideConnectButton() void LLSocialAccountPanel::onConnect() { - hideConnectButton(); + LLFacebookConnect::instance().checkConnectionToFacebook(true); } void LLSocialAccountPanel::onUseAnotherAccount() @@ -683,7 +737,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..48245e34ea 100644 --- a/indra/newview/llfloatersocial.h +++ b/indra/newview/llfloatersocial.h @@ -122,6 +122,8 @@ public: BOOL postBuild(); private: + void onVisibilityChange(const LLSD& new_visibility); + bool onFacebookConnectStateChange(const LLSD& data); 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 838a9ba064..470e0848d2 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"> - + + - You are connected to Facebook as: + Not connected to Facebook. + width="210" + visible="false"> @@ -64,7 +70,8 @@ height="23" label="Disconnect" name="disconnect_btn" - width="210"> + width="210" + visible="false"> -- cgit v1.2.3 From 03563fcaa17c0af776c49baaa59421921603cddd Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Thu, 18 Jul 2013 16:23:11 -0700 Subject: ACME-728: When the 'Disconnect' button is clicked the fbc-service disconnect route should be called --- indra/newview/llfloatersocial.cpp | 30 ++++++++++++++++++------------ indra/newview/llfloatersocial.h | 2 ++ 2 files changed, 20 insertions(+), 12 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp index d64e4273f4..e61d86c474 100644 --- a/indra/newview/llfloatersocial.cpp +++ b/indra/newview/llfloatersocial.cpp @@ -652,15 +652,11 @@ void LLSocialAccountPanel::onVisibilityChange(const LLSD& new_visibility) if(LLFacebookConnect::instance().isConnected()) { - hideConnectButton(); - mAccountCaptionLabel->setText(getString("facebook_connected")); - mAccountNameLabel->setText(std::string("[secondlife:/// Philippe Bossut]")); - + showConnectedLayout(); } else { - mAccountCaptionLabel->setText(getString("facebook_disconnected")); - mAccountNameLabel->setText(std::string("")); + showDisconnectedLayout(); LLFacebookConnect::instance().checkConnectionToFacebook(); } } @@ -679,16 +675,12 @@ bool LLSocialAccountPanel::onFacebookConnectStateChange(const LLSD& data) case LLFacebookConnect::FB_POSTING: case LLFacebookConnect::FB_POSTED: case LLFacebookConnect::FB_POST_FAILED: - mAccountCaptionLabel->setText(getString("facebook_connected")); - mAccountNameLabel->setText(std::string("[secondlife:/// Philippe Bossut]")); - hideConnectButton(); + showConnectedLayout(); break; case LLFacebookConnect::FB_NOT_CONNECTED: case LLFacebookConnect::FB_CONNECTION_IN_PROGRESS: case LLFacebookConnect::FB_CONNECTION_FAILED: - mAccountCaptionLabel->setText(getString("facebook_disconnected")); - mAccountNameLabel->setText(std::string("")); - showConnectButton(); + showDisconnectedLayout(); break; } @@ -725,6 +717,20 @@ void LLSocialAccountPanel::hideConnectButton() } } +void LLSocialAccountPanel::showDisconnectedLayout() +{ + mAccountCaptionLabel->setText(getString("facebook_disconnected")); + mAccountNameLabel->setText(std::string("")); + showConnectButton(); +} + +void LLSocialAccountPanel::showConnectedLayout() +{ + mAccountCaptionLabel->setText(getString("facebook_connected")); + mAccountNameLabel->setText(std::string("[secondlife:/// Philippe Bossut]")); + hideConnectButton(); +} + void LLSocialAccountPanel::onConnect() { LLFacebookConnect::instance().checkConnectionToFacebook(true); diff --git a/indra/newview/llfloatersocial.h b/indra/newview/llfloatersocial.h index 48245e34ea..e49445a39f 100644 --- a/indra/newview/llfloatersocial.h +++ b/indra/newview/llfloatersocial.h @@ -130,6 +130,8 @@ private: void showConnectButton(); void hideConnectButton(); + void showDisconnectedLayout(); + void showConnectedLayout(); LLTextBox * mAccountCaptionLabel; LLTextBox * mAccountNameLabel; -- cgit v1.2.3 From c3c61018cd2d6547c4976c04edc4d3212cf3fb31 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Fri, 19 Jul 2013 16:36:55 -0700 Subject: ACME-732 Create the viewer side info route responder --- indra/newview/llfacebookconnect.cpp | 50 ++++++++++++++++++++++ indra/newview/llfacebookconnect.h | 5 +++ indra/newview/llfloatersocial.cpp | 24 ++++++++++- indra/newview/llfloatersocial.h | 1 + .../skins/default/xui/en/panel_social_account.xml | 6 +-- 5 files changed, 81 insertions(+), 5 deletions(-) (limited to 'indra') 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 LLFacebookConnect::sStateWatcher(new LLEventStream("FacebookConnectState")); +boost::scoped_ptr LLFacebookConnect::sInfoWatcher(new LLEventStream("FacebookConnectInfo")); boost::scoped_ptr LLFacebookConnect::sContentWatcher(new LLEventStream("FacebookConnectContent")); // Local functions @@ -244,6 +245,36 @@ private: bool mAutoConnect; }; +/////////////////////////////////////////////////////////////////////////////// +// +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 @@ -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 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 sStateWatcher; + static boost::scoped_ptr sInfoWatcher; static boost::scoped_ptr 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] - - + parse_urls="true" + type="string"/>