diff options
author | Cho <cho@lindenlab.com> | 2013-07-03 22:07:50 +0100 |
---|---|---|
committer | Cho <cho@lindenlab.com> | 2013-07-03 22:07:50 +0100 |
commit | 4ed5e21ae3fe069126bd43ae0785aa74ba3d0cf7 (patch) | |
tree | cd96b896c4acd13a31d4a1755185a54f077656e5 | |
parent | 55077fd1ae7a00b1a49993d124f2640b17d95bb8 (diff) |
made some slight reorganizations for ACME-662
-rw-r--r-- | indra/newview/llfloatersocial.cpp | 137 | ||||
-rw-r--r-- | indra/newview/llfloatersocial.h | 12 |
2 files changed, 86 insertions, 63 deletions
diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp index a0dbb7ea95..57b6cccd32 100644 --- a/indra/newview/llfloatersocial.cpp +++ b/indra/newview/llfloatersocial.cpp @@ -96,37 +96,39 @@ void LLSocialStatusPanel::draw() void LLSocialStatusPanel::onSend() { - if (mMessageTextEditor) + // 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 + { + LLEventPumps::instance().obtain("FacebookConnectState").listen("LLSocialStatusPanel", boost::bind(&LLSocialStatusPanel::onFacebookConnectStateChange, this, _1)); + 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) { LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialStatusPanel"); - LLFacebookConnect::instance().updateStatus(message); + sendStatus(); } return false; } +void LLSocialStatusPanel::sendStatus() +{ + std::string message = mMessageTextEditor->getValue().asString(); + if (!message.empty()) + { + LLFacebookConnect::instance().updateStatus(message); + } +} + /////////////////////////// //LLSocialPhotoPanel/////// /////////////////////////// @@ -301,47 +303,56 @@ void LLSocialPhotoPanel::onClickNewSnapshot() void LLSocialPhotoPanel::onSend() { - std::string caption = mCaptionTextBox->getValue().asString(); - bool add_location = mLocationCheckbox->getValue().asBoolean(); - - if (add_location) - { - LLSLURL slurl; - LLAgentUI::buildSLURL(slurl); - if (caption.empty()) - caption = slurl.getSLURLString(); - else - caption = caption + " " + slurl.getSLURLString(); - } - - LLSnapshotLivePreview* previewp = getPreviewView(); - // Connect to Facebook if necessary and then post if (LLFacebookConnect::instance().isConnected()) { - LLFacebookConnect::instance().sharePhoto(previewp->getFormattedImage(), caption); + sendPhoto(); } else { - LLEventPumps::instance().obtain("FacebookConnectState").listen("LLSocialPhotoPanel", boost::bind(&LLSocialPhotoPanel::onConnectedToFacebook, this, _1, previewp->getFormattedImage(), caption)); + LLEventPumps::instance().obtain("FacebookConnectState").listen("LLSocialPhotoPanel", boost::bind(&LLSocialPhotoPanel::onFacebookConnectStateChange, this, _1)); LLFacebookConnect::instance().checkConnectionToFacebook(true); } - - updateControls(); } -bool LLSocialPhotoPanel::onConnectedToFacebook(const LLSD& data, LLPointer<LLImageFormatted> image, const std::string& caption) +bool LLSocialPhotoPanel::onFacebookConnectStateChange(const LLSD& data) { if (data.get("enum").asInteger() == LLFacebookConnect::FB_CONNECTED) { LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialPhotoPanel"); - LLFacebookConnect::instance().sharePhoto(image, caption); + sendPhoto(); } return false; } +void LLSocialPhotoPanel::sendPhoto() +{ + // Get the caption + std::string caption = mCaptionTextBox->getValue().asString(); + + // Add the location if required + bool add_location = mLocationCheckbox->getValue().asBoolean(); + if (add_location) + { + LLSLURL slurl; + LLAgentUI::buildSLURL(slurl); + if (caption.empty()) + caption = slurl.getSLURLString(); + else + caption = caption + " " + slurl.getSLURLString(); + } + + // Get the image + LLSnapshotLivePreview* previewp = getPreviewView(); + + // Post to Facebook + LLFacebookConnect::instance().sharePhoto(previewp->getFormattedImage(), caption); + + updateControls(); +} + void LLSocialPhotoPanel::updateControls() { LLSnapshotLivePreview* previewp = getPreviewView(); @@ -517,6 +528,32 @@ void LLSocialCheckinPanel::draw() void LLSocialCheckinPanel::onSend() { + // Connect to Facebook if necessary and then post + if (LLFacebookConnect::instance().isConnected()) + { + sendCheckin(); + } + else + { + LLEventPumps::instance().obtain("FacebookConnectState").listen("LLSocialCheckinPanel", boost::bind(&LLSocialCheckinPanel::onFacebookConnectStateChange, this, _1)); + LLFacebookConnect::instance().checkConnectionToFacebook(true); + } +} + +bool LLSocialCheckinPanel::onFacebookConnectStateChange(const LLSD& data) +{ + if (data.get("enum").asInteger() == LLFacebookConnect::FB_CONNECTED) + { + LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialCheckinPanel"); + + sendCheckin(); + } + + return false; +} + +void LLSocialCheckinPanel::sendCheckin() +{ // Get the location SLURL LLSLURL slurl; LLAgentUI::buildSLURL(slurl); @@ -536,28 +573,8 @@ 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); - } -} - -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; + // Post to Facebook + LLFacebookConnect::instance().postCheckin(slurl_string, region_name, description, map_url, caption); } //////////////////////// diff --git a/indra/newview/llfloatersocial.h b/indra/newview/llfloatersocial.h index 07236c2838..e37facbbce 100644 --- a/indra/newview/llfloatersocial.h +++ b/indra/newview/llfloatersocial.h @@ -42,7 +42,9 @@ public: BOOL postBuild(); void draw(); void onSend(); - bool onConnectedToFacebook(const LLSD& data, const std::string& message); + bool onFacebookConnectStateChange(const LLSD& data); + + void sendStatus(); private: LLUICtrl* mMessageTextEditor; @@ -62,7 +64,9 @@ public: void onVisibilityChange(const LLSD& new_visibility); void onClickNewSnapshot(); void onSend(); - bool onConnectedToFacebook(const LLSD& data, LLPointer<LLImageFormatted> image, const std::string& caption); + bool onFacebookConnectStateChange(const LLSD& data); + + void sendPhoto(); void updateControls(); void updateResolution(BOOL do_update); @@ -94,7 +98,9 @@ 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); + bool onFacebookConnectStateChange(const LLSD& data); + + void sendCheckin(); private: std::string mMapUrl; |