summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatersocial.cpp
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2013-07-02 18:54:30 -0700
committerMerov Linden <merov@lindenlab.com>2013-07-02 18:54:30 -0700
commit2d94b69def305a5d7e92d433bde8ac43eae71337 (patch)
treead54c9259e229a0781245f07ed474a77296c43d7 /indra/newview/llfloatersocial.cpp
parent8c4a39b2025ef64f6218dc112e37f71c65aac446 (diff)
parentb070533bdaa78fb2d94ec49a2ea3d9a9ada3d437 (diff)
Pull merge from lindenlab/viewer-fbc
Diffstat (limited to 'indra/newview/llfloatersocial.cpp')
-rw-r--r--indra/newview/llfloatersocial.cpp86
1 files changed, 74 insertions, 12 deletions
diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp
index ddbaa2d704..684b177f24 100644
--- a/indra/newview/llfloatersocial.cpp
+++ b/indra/newview/llfloatersocial.cpp
@@ -88,7 +88,7 @@ void LLSocialStatusPanel::draw()
if (mMessageTextEditor && mPostStatusButton)
{
std::string message = mMessageTextEditor->getValue().asString();
- mPostStatusButton->setEnabled(!message.empty() && LLFacebookConnect::instance().isConnected());
+ mPostStatusButton->setEnabled(!message.empty());
}
LLPanel::draw();
@@ -101,8 +101,18 @@ void LLSocialStatusPanel::onSend()
std::string message = mMessageTextEditor->getValue().asString();
if (!message.empty())
{
- LLFacebookConnect::instance().updateStatus(message);
-
+ // Connect to Facebook if necessary and then post
+ if (LLFacebookConnect::instance().isConnected())
+ {
+ LLFacebookConnect::instance().updateStatus(message);
+ }
+ else
+ {
+ LLEventPumps::instance().obtain("FacebookConnectState").listen("LLSocialStatusPanel", boost::bind(&LLSocialStatusPanel::onConnectedToFacebook, this, _1, message));
+ LLFacebookConnect::instance().checkConnectionToFacebook(true);
+ }
+
+ // Close the floater once "Post" has been pushed
LLFloater* floater = getParentByType<LLFloater>();
if (floater)
{
@@ -112,6 +122,18 @@ void LLSocialStatusPanel::onSend()
}
}
+bool LLSocialStatusPanel::onConnectedToFacebook(const LLSD& data, const std::string& message)
+{
+ if (data.get("enum").asInteger() == LLFacebookConnect::FB_CONNECTED)
+ {
+ LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialStatusPanel");
+
+ LLFacebookConnect::instance().updateStatus(message);
+ }
+
+ return false;
+}
+
///////////////////////////
//LLSocialPhotoPanel///////
///////////////////////////
@@ -233,8 +255,6 @@ void LLSocialPhotoPanel::draw()
mThumbnailPlaceholder->draw();
gGL.popUIMatrix();
}
-
- mPostButton->setEnabled(LLFacebookConnect::instance().isConnected());
}
LLSnapshotLivePreview* LLSocialPhotoPanel::getPreviewView()
@@ -302,7 +322,18 @@ void LLSocialPhotoPanel::onSend()
}
LLSnapshotLivePreview* previewp = getPreviewView();
- LLFacebookConnect::instance().sharePhoto(previewp->getFormattedImage(), caption);
+
+ // Connect to Facebook if necessary and then post
+ if (LLFacebookConnect::instance().isConnected())
+ {
+ LLFacebookConnect::instance().sharePhoto(previewp->getFormattedImage(), caption);
+ }
+ else
+ {
+ LLEventPumps::instance().obtain("FacebookConnectState").listen("LLSocialPhotoPanel", boost::bind(&LLSocialPhotoPanel::onConnectedToFacebook, this, _1, previewp->getFormattedImage(), caption));
+ LLFacebookConnect::instance().checkConnectionToFacebook(true);
+ }
+
updateControls();
// Close the floater once "Post" has been pushed
@@ -313,6 +344,18 @@ void LLSocialPhotoPanel::onSend()
}
}
+bool LLSocialPhotoPanel::onConnectedToFacebook(const LLSD& data, LLPointer<LLImageFormatted> image, const std::string& caption)
+{
+ if (data.get("enum").asInteger() == LLFacebookConnect::FB_CONNECTED)
+ {
+ LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialPhotoPanel");
+
+ LLFacebookConnect::instance().sharePhoto(image, caption);
+ }
+
+ return false;
+}
+
void LLSocialPhotoPanel::updateControls()
{
LLSnapshotLivePreview* previewp = getPreviewView();
@@ -482,8 +525,7 @@ void LLSocialCheckinPanel::draw()
mMapCheckBox->setEnabled(true);
mMapCheckBox->set(mMapCheckBoxValue);
}
- mPostButton->setEnabled(LLFacebookConnect::instance().isConnected());
-
+
LLPanel::draw();
}
@@ -508,8 +550,16 @@ void LLSocialCheckinPanel::onSend()
// Get the caption
std::string caption = getChild<LLUICtrl>("place_caption")->getValue().asString();
- // Post all that to Facebook
- LLFacebookConnect::instance().postCheckin(slurl_string, region_name, description, map_url, caption);
+ // Connect to Facebook if necessary and then post
+ if (LLFacebookConnect::instance().isConnected())
+ {
+ LLFacebookConnect::instance().postCheckin(slurl_string, region_name, description, map_url, caption);
+ }
+ else
+ {
+ LLEventPumps::instance().obtain("FacebookConnectState").listen("LLSocialCheckinPanel", boost::bind(&LLSocialCheckinPanel::onConnectedToFacebook, this, _1, slurl_string, region_name, description, map_url, caption));
+ LLFacebookConnect::instance().checkConnectionToFacebook(true);
+ }
// Close the floater once "Post" has been pushed
LLFloater* floater = getParentByType<LLFloater>();
@@ -519,6 +569,18 @@ void LLSocialCheckinPanel::onSend()
}
}
+bool LLSocialCheckinPanel::onConnectedToFacebook(const LLSD& data, const std::string& location, const std::string& name, const std::string& description, const std::string& picture, const std::string& message)
+{
+ if (data.get("enum").asInteger() == LLFacebookConnect::FB_CONNECTED)
+ {
+ LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialCheckinPanel");
+
+ LLFacebookConnect::instance().postCheckin(location, name, description, picture, message);
+ }
+
+ return false;
+}
+
////////////////////////
//LLFloaterSocial///////
////////////////////////
@@ -539,8 +601,6 @@ void LLFloaterSocial::onCancel()
BOOL LLFloaterSocial::postBuild()
{
- // Initiate a connection to Facebook (getConnectionToFacebook() handles the already connected state)
- LLFacebookConnect::instance().getConnectionToFacebook(true);
// Keep tab of the Photo Panel
mSocialPhotoPanel = static_cast<LLSocialPhotoPanel*>(getChild<LLUICtrl>("panel_social_photo"));
// Connection status widgets
@@ -601,12 +661,14 @@ void LLFloaterSocial::draw()
case LLFacebookConnect::FB_NOT_CONNECTED:
break;
case LLFacebookConnect::FB_CONNECTION_IN_PROGRESS:
+ case LLFacebookConnect::FB_POSTING:
mStatusLoadingText->setVisible(true);
mStatusLoadingIndicator->setVisible(true);
break;
case LLFacebookConnect::FB_CONNECTED:
break;
case LLFacebookConnect::FB_CONNECTION_FAILED:
+ case LLFacebookConnect::FB_POST_FAILED:
mStatusErrorText->setVisible(true);
break;
}