summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCho <cho@lindenlab.com>2013-07-03 01:16:41 +0100
committerCho <cho@lindenlab.com>2013-07-03 01:16:41 +0100
commiteef8579dd7f9af558041d4d3a4b4aeb39bf280a1 (patch)
tree82cfb462e06d86788902b7c96d491b622a5119dc
parent853ad9d70ddcf0cdd354672a5c7baa858de1bb22 (diff)
Moved auto-connect to happen when Post button is clicked for ACME-654 and ACME-652
-rw-r--r--indra/newview/llfloatersocial.cpp84
-rw-r--r--indra/newview/llfloatersocial.h60
2 files changed, 103 insertions, 41 deletions
diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp
index 50d641865b..061bcf246d 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///////
////////////////////////
@@ -536,8 +598,6 @@ void LLFloaterSocial::onCancel()
BOOL LLFloaterSocial::postBuild()
{
- // Initiate a connection to Facebook
- LLFacebookConnect::instance().checkConnectionToFacebook(true);
// Keep tab of the Photo Panel
mSocialPhotoPanel = static_cast<LLSocialPhotoPanel*>(getChild<LLUICtrl>("panel_social_photo"));
return LLFloater::postBuild();
diff --git a/indra/newview/llfloatersocial.h b/indra/newview/llfloatersocial.h
index 89b9e2016a..4970f95e89 100644
--- a/indra/newview/llfloatersocial.h
+++ b/indra/newview/llfloatersocial.h
@@ -41,6 +41,7 @@ public:
BOOL postBuild();
void draw();
void onSend();
+ bool onConnectedToFacebook(const LLSD& data, const std::string& message);
private:
LLUICtrl* mMessageTextEditor;
@@ -49,41 +50,40 @@ private:
class LLSocialPhotoPanel : public LLPanel
{
-
public:
- LLSocialPhotoPanel();
- ~LLSocialPhotoPanel();
+ LLSocialPhotoPanel();
+ ~LLSocialPhotoPanel();
- BOOL postBuild();
- void draw();
+ BOOL postBuild();
+ void draw();
- LLSnapshotLivePreview* getPreviewView();
- void onVisibilityChange(const LLSD& new_visibility);
- void onClickNewSnapshot();
- void onSend();
+ LLSnapshotLivePreview* getPreviewView();
+ void onVisibilityChange(const LLSD& new_visibility);
+ void onClickNewSnapshot();
+ void onSend();
+ bool onConnectedToFacebook(const LLSD& data, LLPointer<LLImageFormatted> image, const std::string& caption);
- void updateControls();
- void updateResolution(BOOL do_update);
- void checkAspectRatio(S32 index);
- void setNeedRefresh(bool need);
- LLUICtrl* getRefreshBtn();
+ void updateControls();
+ void updateResolution(BOOL do_update);
+ void checkAspectRatio(S32 index);
+ void setNeedRefresh(bool need);
+ LLUICtrl* getRefreshBtn();
private:
-
- LLHandle<LLView> mPreviewHandle;
-
- LLUICtrl * mSnapshotPanel;
- LLUICtrl * mResolutionComboBox;
- LLUICtrl * mRefreshBtn;
- LLUICtrl * mRefreshLabel;
- LLUICtrl * mSucceessLblPanel;
- LLUICtrl * mFailureLblPanel;
- LLUICtrl * mThumbnailPlaceholder;
- LLUICtrl * mCaptionTextBox;
- LLUICtrl * mLocationCheckbox;
- LLUICtrl * mPostButton;
-
- bool mNeedRefresh;
+ LLHandle<LLView> mPreviewHandle;
+
+ LLUICtrl * mSnapshotPanel;
+ LLUICtrl * mResolutionComboBox;
+ LLUICtrl * mRefreshBtn;
+ LLUICtrl * mRefreshLabel;
+ LLUICtrl * mSucceessLblPanel;
+ LLUICtrl * mFailureLblPanel;
+ LLUICtrl * mThumbnailPlaceholder;
+ LLUICtrl * mCaptionTextBox;
+ LLUICtrl * mLocationCheckbox;
+ LLUICtrl * mPostButton;
+
+ bool mNeedRefresh;
};
class LLSocialCheckinPanel : public LLPanel
@@ -93,6 +93,8 @@ public:
BOOL postBuild();
void draw();
void onSend();
+ bool onConnectedToFacebook(const LLSD& data, const std::string& location, const std::string& name, const std::string& description, const std::string& picture, const std::string& message);
+
private:
std::string mMapUrl;
LLPointer<LLViewerFetchedTexture> mMapTexture;