summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatersocial.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloatersocial.cpp')
-rw-r--r--indra/newview/llfloatersocial.cpp90
1 files changed, 86 insertions, 4 deletions
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();
}
////////////////////////