summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatersocial.cpp
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2013-07-03 19:31:34 -0700
committerMerov Linden <merov@lindenlab.com>2013-07-03 19:31:34 -0700
commit8494e04a759ef1d91d30663eb7da84ef271c65be (patch)
tree281f157e39bc37c1276c35d86809bec4f5f31d4e /indra/newview/llfloatersocial.cpp
parent6e8b353575f670e50267cb172860a3f8da1dbbd0 (diff)
parentf7a1f7b784fff0579e4d1fecd8265d0f960bd7f4 (diff)
Pull merge from lindenlab/viewer-fbc
Diffstat (limited to 'indra/newview/llfloatersocial.cpp')
-rw-r--r--indra/newview/llfloatersocial.cpp183
1 files changed, 128 insertions, 55 deletions
diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp
index fce9d1b28f..58a9edc524 100644
--- a/indra/newview/llfloatersocial.cpp
+++ b/indra/newview/llfloatersocial.cpp
@@ -96,37 +96,57 @@ void LLSocialStatusPanel::draw()
void LLSocialStatusPanel::onSend()
{
- if (mMessageTextEditor)
+ LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialStatusPanel"); // just in case it is already listening
+ LLEventPumps::instance().obtain("FacebookConnectState").listen("LLSocialStatusPanel", boost::bind(&LLSocialStatusPanel::onFacebookConnectStateChange, this, _1));
+
+ // Connect to Facebook if necessary and then post
+ if (LLFacebookConnect::instance().isConnected())
{
- std::string message = mMessageTextEditor->getValue().asString();
- if (!message.empty())
- {
- // 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);
- }
- }
+ sendStatus();
+ }
+ else
+ {
+ LLFacebookConnect::instance().checkConnectionToFacebook(true);
}
}
-bool LLSocialStatusPanel::onConnectedToFacebook(const LLSD& data, const std::string& message)
+bool LLSocialStatusPanel::onFacebookConnectStateChange(const LLSD& data)
{
- if (data.get("enum").asInteger() == LLFacebookConnect::FB_CONNECTED)
+ switch (data.get("enum").asInteger())
{
- LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialStatusPanel");
-
- LLFacebookConnect::instance().updateStatus(message);
+ case LLFacebookConnect::FB_CONNECTED:
+ sendStatus();
+ break;
+
+ case LLFacebookConnect::FB_POSTED:
+ LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialStatusPanel");
+ clearAndClose();
+ break;
}
return false;
}
+void LLSocialStatusPanel::sendStatus()
+{
+ std::string message = mMessageTextEditor->getValue().asString();
+ if (!message.empty())
+ {
+ LLFacebookConnect::instance().updateStatus(message);
+ }
+}
+
+void LLSocialStatusPanel::clearAndClose()
+{
+ mMessageTextEditor->setValue("");
+
+ LLFloater* floater = getParentByType<LLFloater>();
+ if (floater)
+ {
+ floater->closeFloater();
+ }
+}
+
///////////////////////////
//LLSocialPhotoPanel///////
///////////////////////////
@@ -258,9 +278,44 @@ void LLSocialPhotoPanel::onClickNewSnapshot()
void LLSocialPhotoPanel::onSend()
{
+ LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialPhotoPanel"); // just in case it is already listening
+ LLEventPumps::instance().obtain("FacebookConnectState").listen("LLSocialPhotoPanel", boost::bind(&LLSocialPhotoPanel::onFacebookConnectStateChange, this, _1));
+
+ // Connect to Facebook if necessary and then post
+ if (LLFacebookConnect::instance().isConnected())
+ {
+ sendPhoto();
+ }
+ else
+ {
+ LLFacebookConnect::instance().checkConnectionToFacebook(true);
+ }
+}
+
+bool LLSocialPhotoPanel::onFacebookConnectStateChange(const LLSD& data)
+{
+ switch (data.get("enum").asInteger())
+ {
+ case LLFacebookConnect::FB_CONNECTED:
+ sendPhoto();
+ break;
+
+ case LLFacebookConnect::FB_POSTED:
+ LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialPhotoPanel");
+ clearAndClose();
+ break;
+ }
+
+ return false;
+}
+
+void LLSocialPhotoPanel::sendPhoto()
+{
+ // Get the caption
std::string caption = mCaptionTextBox->getValue().asString();
- bool add_location = mLocationCheckbox->getValue().asBoolean();
+ // Add the location if required
+ bool add_location = mLocationCheckbox->getValue().asBoolean();
if (add_location)
{
LLSLURL slurl;
@@ -271,32 +326,24 @@ void LLSocialPhotoPanel::onSend()
caption = caption + " " + slurl.getSLURLString();
}
+ // Get the image
LLSnapshotLivePreview* previewp = getPreviewView();
- // 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);
- }
+ // Post to Facebook
+ LLFacebookConnect::instance().sharePhoto(previewp->getFormattedImage(), caption);
updateControls();
}
-bool LLSocialPhotoPanel::onConnectedToFacebook(const LLSD& data, LLPointer<LLImageFormatted> image, const std::string& caption)
+void LLSocialPhotoPanel::clearAndClose()
{
- if (data.get("enum").asInteger() == LLFacebookConnect::FB_CONNECTED)
+ mCaptionTextBox->setValue("");
+
+ LLFloater* floater = getParentByType<LLFloater>();
+ if (floater)
{
- LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialPhotoPanel");
-
- LLFacebookConnect::instance().sharePhoto(image, caption);
+ floater->closeFloater();
}
-
- return false;
}
void LLSocialPhotoPanel::updateControls()
@@ -474,6 +521,39 @@ void LLSocialCheckinPanel::draw()
void LLSocialCheckinPanel::onSend()
{
+ LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialCheckinPanel"); // just in case it is already listening
+ LLEventPumps::instance().obtain("FacebookConnectState").listen("LLSocialCheckinPanel", boost::bind(&LLSocialCheckinPanel::onFacebookConnectStateChange, this, _1));
+
+ // Connect to Facebook if necessary and then post
+ if (LLFacebookConnect::instance().isConnected())
+ {
+ sendCheckin();
+ }
+ else
+ {
+ LLFacebookConnect::instance().checkConnectionToFacebook(true);
+ }
+}
+
+bool LLSocialCheckinPanel::onFacebookConnectStateChange(const LLSD& data)
+{
+ switch (data.get("enum").asInteger())
+ {
+ case LLFacebookConnect::FB_CONNECTED:
+ sendCheckin();
+ break;
+
+ case LLFacebookConnect::FB_POSTED:
+ LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialCheckinPanel");
+ clearAndClose();
+ break;
+ }
+
+ return false;
+}
+
+void LLSocialCheckinPanel::sendCheckin()
+{
// Get the location SLURL
LLSLURL slurl;
LLAgentUI::buildSLURL(slurl);
@@ -493,28 +573,19 @@ void LLSocialCheckinPanel::onSend()
// Get the caption
std::string caption = getChild<LLUICtrl>("place_caption")->getValue().asString();
- // 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);
- }
+ // Post to Facebook
+ LLFacebookConnect::instance().postCheckin(slurl_string, region_name, description, map_url, caption);
}
-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)
+void LLSocialCheckinPanel::clearAndClose()
{
- if (data.get("enum").asInteger() == LLFacebookConnect::FB_CONNECTED)
+ getChild<LLUICtrl>("place_caption")->setValue("");
+
+ LLFloater* floater = getParentByType<LLFloater>();
+ if (floater)
{
- LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialCheckinPanel");
-
- LLFacebookConnect::instance().postCheckin(location, name, description, picture, message);
+ floater->closeFloater();
}
-
- return false;
}
////////////////////////
@@ -602,6 +673,8 @@ void LLFloaterSocial::draw()
mStatusLoadingIndicator->setVisible(true);
break;
case LLFacebookConnect::FB_CONNECTED:
+ break;
+ case LLFacebookConnect::FB_POSTED:
break;
case LLFacebookConnect::FB_CONNECTION_FAILED:
case LLFacebookConnect::FB_POST_FAILED: