summaryrefslogtreecommitdiff
path: root/indra/newview
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
parent6e8b353575f670e50267cb172860a3f8da1dbbd0 (diff)
parentf7a1f7b784fff0579e4d1fecd8265d0f960bd7f4 (diff)
Pull merge from lindenlab/viewer-fbc
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llfacebookconnect.cpp40
-rw-r--r--indra/newview/llfacebookconnect.h19
-rw-r--r--indra/newview/llfloatersocial.cpp183
-rw-r--r--indra/newview/llfloatersocial.h15
-rwxr-xr-xindra/newview/llpanelpeople.cpp10
-rwxr-xr-xindra/newview/llpanelpeople.h2
6 files changed, 162 insertions, 107 deletions
diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp
index 30fb63084b..30ebedca25 100644
--- a/indra/newview/llfacebookconnect.cpp
+++ b/indra/newview/llfacebookconnect.cpp
@@ -41,6 +41,7 @@
#include "llevents.h"
boost::scoped_ptr<LLEventPump> LLFacebookConnect::sStateWatcher(new LLEventStream("FacebookConnectState"));
+boost::scoped_ptr<LLEventPump> LLFacebookConnect::sContentWatcher(new LLEventStream("FacebookConnectContent"));
// Local functions
void log_facebook_connect_error(const std::string& request, U32 status, const std::string& reason, const std::string& code, const std::string& description)
@@ -133,11 +134,6 @@ public:
LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POSTING);
}
- LLFacebookShareResponder(LLFacebookConnect::share_callback_t cb) : mShareCallback(cb)
- {
- LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POSTING);
- }
-
virtual void completed(U32 status, const std::string& reason, const LLSD& content)
{
if (isGoodStatus(status))
@@ -145,18 +141,17 @@ public:
toast_user_for_success();
LL_DEBUGS("FacebookConnect") << "Post successful. content: " << content << LL_ENDL;
- LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED);
+ LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POSTED);
+ }
+ else if (status == 404)
+ {
+ LLFacebookConnect::instance().connectToFacebook();
}
else
{
LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POST_FAILED);
log_facebook_connect_error("Share", status, reason, content.get("error_code"), content.get("error_description"));
}
-
- if (mShareCallback)
- {
- mShareCallback(isGoodStatus(status));
- }
}
void completedHeader(U32 status, const std::string& reason, const LLSD& content)
@@ -166,9 +161,6 @@ public:
LLFacebookConnect::instance().openFacebookWeb(content["location"]);
}
}
-
-private:
- LLFacebookConnect::share_callback_t mShareCallback;
};
///////////////////////////////////////////////////////////////////////////////
@@ -342,7 +334,7 @@ void LLFacebookConnect::postCheckin(const std::string& location, const std::stri
body["message"] = message;
// Note: we can use that route for different publish action. We should be able to use the same responder.
- LLHTTPClient::post(getFacebookConnectURL("/share/checkin"), body, new LLFacebookShareResponder(mPostCheckinCallback));
+ LLHTTPClient::post(getFacebookConnectURL("/share/checkin"), body, new LLFacebookShareResponder());
}
void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::string& caption)
@@ -405,7 +397,7 @@ void LLFacebookConnect::sharePhoto(LLPointer<LLImageFormatted> image, const std:
memcpy(data, body.str().data(), size);
// Note: we can use that route for different publish action. We should be able to use the same responder.
- LLHTTPClient::postRaw(getFacebookConnectURL("/share/photo"), data, size, new LLFacebookShareResponder(mSharePhotoCallback), headers);
+ LLHTTPClient::postRaw(getFacebookConnectURL("/share/photo"), data, size, new LLFacebookShareResponder(), headers);
}
void LLFacebookConnect::updateStatus(const std::string& message)
@@ -414,7 +406,7 @@ void LLFacebookConnect::updateStatus(const std::string& message)
body["message"] = message;
// Note: we can use that route for different publish action. We should be able to use the same responder.
- LLHTTPClient::post(getFacebookConnectURL("/share/wall"), body, new LLFacebookShareResponder(mUpdateStatusCallback));
+ LLHTTPClient::post(getFacebookConnectURL("/share/wall"), body, new LLFacebookShareResponder());
}
void LLFacebookConnect::storeContent(const LLSD& content)
@@ -422,10 +414,7 @@ void LLFacebookConnect::storeContent(const LLSD& content)
mGeneration++;
mContent = content;
- if(mContentUpdatedCallback)
- {
- mContentUpdatedCallback();
- }
+ sContentWatcher->post(content);
}
const LLSD& LLFacebookConnect::getContent() const
@@ -450,12 +439,3 @@ void LLFacebookConnect::setConnectionState(LLFacebookConnect::EConnectionState c
mConnectionState = connection_state;
}
-
-
-
-
-
-
-
-
-
diff --git a/indra/newview/llfacebookconnect.h b/indra/newview/llfacebookconnect.h
index ddff87385e..7b6eb3644f 100644
--- a/indra/newview/llfacebookconnect.h
+++ b/indra/newview/llfacebookconnect.h
@@ -50,12 +50,10 @@ public:
FB_CONNECTED = 2,
FB_CONNECTION_FAILED = 3,
FB_POSTING = 4,
- FB_POST_FAILED = 5
+ FB_POSTED = 5,
+ FB_POST_FAILED = 6
};
- typedef boost::function<void(bool ok)> share_callback_t;
- typedef boost::function<void()> content_updated_callback_t;
-
void connectToFacebook(const std::string& auth_code = ""); // Initiate the complete FB connection. Please use checkConnectionToFacebook() in normal use.
void disconnectFromFacebook(); // Disconnect from the FBC service.
void checkConnectionToFacebook(bool auto_connect = false); // Check if an access token is available on the FBC service. If not, call connectToFacebook().
@@ -66,17 +64,12 @@ public:
void sharePhoto(LLPointer<LLImageFormatted> image, const std::string& caption);
void updateStatus(const std::string& message);
- void setPostCheckinCallback(share_callback_t cb) { mPostCheckinCallback = cb; }
- void setSharePhotoCallback(share_callback_t cb) { mSharePhotoCallback = cb; }
- void setUpdateStatusCallback(share_callback_t cb) { mUpdateStatusCallback = cb; }
- void setContentUpdatedCallback(content_updated_callback_t cb) { mContentUpdatedCallback = cb;}
-
void clearContent();
void storeContent(const LLSD& content);
const LLSD& getContent() const;
void setConnectionState(EConnectionState connection_state);
- bool isConnected() { return ((mConnectionState == FB_CONNECTED) || (mConnectionState == FB_POSTING)); }
+ bool isConnected() { return ((mConnectionState == FB_CONNECTED) || (mConnectionState == FB_POSTING) || (mConnectionState == FB_POSTED)); }
EConnectionState getConnectionState() { return mConnectionState; }
S32 generation() { return mGeneration; }
@@ -93,12 +86,8 @@ private:
LLSD mContent;
S32 mGeneration;
- share_callback_t mPostCheckinCallback;
- share_callback_t mSharePhotoCallback;
- share_callback_t mUpdateStatusCallback;
- content_updated_callback_t mContentUpdatedCallback;
-
static boost::scoped_ptr<LLEventPump> sStateWatcher;
+ static boost::scoped_ptr<LLEventPump> sContentWatcher;
};
#endif // LL_LLFACEBOOKCONNECT_H
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:
diff --git a/indra/newview/llfloatersocial.h b/indra/newview/llfloatersocial.h
index 07236c2838..5e1ee6be0e 100644
--- a/indra/newview/llfloatersocial.h
+++ b/indra/newview/llfloatersocial.h
@@ -42,7 +42,10 @@ public:
BOOL postBuild();
void draw();
void onSend();
- bool onConnectedToFacebook(const LLSD& data, const std::string& message);
+ bool onFacebookConnectStateChange(const LLSD& data);
+
+ void sendStatus();
+ void clearAndClose();
private:
LLUICtrl* mMessageTextEditor;
@@ -62,7 +65,10 @@ 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 clearAndClose();
void updateControls();
void updateResolution(BOOL do_update);
@@ -94,7 +100,10 @@ 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();
+ void clearAndClose();
private:
std::string mMapUrl;
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index 8c8cad0743..766335c982 100755
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -781,7 +781,7 @@ void LLPanelPeople::updateFriendList()
showFriendsAccordionsIfNeeded();
}
-void LLPanelPeople::updateSuggestedFriendList()
+bool LLPanelPeople::updateSuggestedFriendList()
{
if (LLFacebookConnect::instance().generation() != mFacebookListGeneration)
{
@@ -814,6 +814,8 @@ void LLPanelPeople::updateSuggestedFriendList()
mSuggestedFriends->setDirty(true, !mSuggestedFriends->filterHasMatches());
showFriendsAccordionsIfNeeded();
}
+
+ return false;
}
void LLPanelPeople::updateNearbyList()
@@ -855,7 +857,8 @@ void LLPanelPeople::updateFacebookList(bool visible)
{
if (visible)
{
- LLFacebookConnect::instance().setContentUpdatedCallback(boost::bind(&LLPanelPeople::updateSuggestedFriendList, this));
+ LLEventPumps::instance().obtain("FacebookConnectContent").stopListening("LLPanelPeople"); // just in case it is already listening
+ LLEventPumps::instance().obtain("FacebookConnectContent").listen("LLPanelPeople", boost::bind(&LLPanelPeople::updateSuggestedFriendList, this));
if (mTryToConnectToFbc)
{
@@ -866,6 +869,7 @@ void LLPanelPeople::updateFacebookList(bool visible)
}
else
{
+ LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLPanelPeople"); // just in case it is already listening
LLEventPumps::instance().obtain("FacebookConnectState").listen("LLPanelPeople", boost::bind(&LLPanelPeople::onConnectedToFacebook, this, _1));
LLFacebookConnect::instance().checkConnectionToFacebook();
}
@@ -878,7 +882,7 @@ void LLPanelPeople::updateFacebookList(bool visible)
}
else
{
- LLFacebookConnect::instance().setContentUpdatedCallback(NULL);
+ LLEventPumps::instance().obtain("FacebookConnectContent").stopListening("LLPanelPeople");
}
}
diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h
index c6ee7b8165..b746835dfb 100755
--- a/indra/newview/llpanelpeople.h
+++ b/indra/newview/llpanelpeople.h
@@ -76,7 +76,7 @@ private:
// methods indirectly called by the updaters
void updateFriendListHelpText();
void updateFriendList();
- void updateSuggestedFriendList();
+ bool updateSuggestedFriendList();
void updateNearbyList();
void updateRecentList();
void updateFacebookList(bool visible);