summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llfacebookconnect.cpp53
-rw-r--r--indra/newview/llfacebookconnect.h15
-rw-r--r--indra/newview/llfloatersocial.cpp4
-rwxr-xr-xindra/newview/llpanelpeople.cpp26
-rwxr-xr-xindra/newview/llpanelpeople.h2
5 files changed, 58 insertions, 42 deletions
diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp
index 5d6c496275..8a86ff6377 100644
--- a/indra/newview/llfacebookconnect.cpp
+++ b/indra/newview/llfacebookconnect.cpp
@@ -38,7 +38,9 @@
#include "llimagepng.h"
#include "llimagejpeg.h"
#include "lltrans.h"
+#include "llevents.h"
+boost::scoped_ptr<LLEventPump> LLFacebookConnect::sStateWatcher(new LLEventStream("FacebookConnectState"));
// 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)
@@ -93,11 +95,6 @@ public:
{
LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS);
}
-
- LLFacebookConnectResponder(LLFacebookConnect::connect_callback_t cb) : mConnectCallback(cb)
- {
- LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS);
- }
virtual void completed(U32 status, const std::string& reason, const LLSD& content)
{
@@ -107,11 +104,6 @@ public:
// Grab some graph data now that we are connected
LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED);
-
- if (mConnectCallback)
- {
- mConnectCallback();
- }
}
else
{
@@ -127,9 +119,6 @@ public:
LLFacebookConnect::instance().openFacebookWeb(content["location"]);
}
}
-
-private:
- LLFacebookConnect::connect_callback_t mConnectCallback;
};
///////////////////////////////////////////////////////////////////////////////
@@ -208,11 +197,6 @@ public:
LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS);
}
- LLFacebookConnectedResponder(bool auto_connect, LLFacebookConnect::connect_callback_t cb) : mAutoConnect(auto_connect), mConnectCallback(cb)
- {
- LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS);
- }
-
virtual void completed(U32 status, const std::string& reason, const LLSD& content)
{
if (isGoodStatus(status))
@@ -220,11 +204,6 @@ public:
LL_DEBUGS("FacebookConnect") << "Connect successful. content: " << content << LL_ENDL;
LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED);
-
- if (mConnectCallback)
- {
- mConnectCallback();
- }
}
else
{
@@ -250,7 +229,6 @@ public:
private:
bool mAutoConnect;
- LLFacebookConnect::connect_callback_t mConnectCallback;
};
///////////////////////////////////////////////////////////////////////////////
@@ -306,13 +284,13 @@ std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route)
return url;
}
-void LLFacebookConnect::connectToFacebook(const std::string& auth_code, connect_callback_t cb)
+void LLFacebookConnect::connectToFacebook(const std::string& auth_code)
{
LLSD body;
if (!auth_code.empty())
body["code"] = auth_code;
- LLHTTPClient::put(getFacebookConnectURL("/connection"), body, new LLFacebookConnectResponder(cb));
+ LLHTTPClient::put(getFacebookConnectURL("/connection"), body, new LLFacebookConnectResponder());
}
void LLFacebookConnect::disconnectFromFacebook()
@@ -320,21 +298,21 @@ void LLFacebookConnect::disconnectFromFacebook()
LLHTTPClient::del(getFacebookConnectURL("/connection"), new LLFacebookDisconnectResponder());
}
-void LLFacebookConnect::getConnectionToFacebook(bool auto_connect, connect_callback_t cb)
+void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect)
{
if ((mConnectionState == FB_NOT_CONNECTED) || (mConnectionState == FB_CONNECTION_FAILED))
{
const bool follow_redirects = false;
- const F32 timeout=HTTP_REQUEST_EXPIRY_SECS;
- LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(auto_connect, cb),
+ const F32 timeout = HTTP_REQUEST_EXPIRY_SECS;
+ LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(auto_connect),
LLSD(), timeout, follow_redirects);
}
}
void LLFacebookConnect::loadFacebookFriends()
{
- const bool follow_redirects=false;
- const F32 timeout=HTTP_REQUEST_EXPIRY_SECS;
+ const bool follow_redirects = false;
+ const F32 timeout = HTTP_REQUEST_EXPIRY_SECS;
LLHTTPClient::get(getFacebookConnectURL("/friends"), new LLFacebookFriendsResponder(),
LLSD(), timeout, follow_redirects);
}
@@ -451,6 +429,19 @@ void LLFacebookConnect::clearContent()
mContent = LLSD();
}
+void LLFacebookConnect::setConnectionState(LLFacebookConnect::EConnectionState connection_state)
+{
+ if (mConnectionState != connection_state)
+ {
+ LLSD state_info;
+ state_info["enum"] = connection_state;
+ sStateWatcher->post(state_info);
+ }
+
+ mConnectionState = connection_state;
+}
+
+
diff --git a/indra/newview/llfacebookconnect.h b/indra/newview/llfacebookconnect.h
index abd6fb385d..4e95fc3545 100644
--- a/indra/newview/llfacebookconnect.h
+++ b/indra/newview/llfacebookconnect.h
@@ -31,6 +31,8 @@
#include "llsingleton.h"
#include "llimage.h"
+class LLEventPump;
+
/**
* @class LLFacebookConnect
*
@@ -49,13 +51,12 @@ public:
FB_CONNECTION_FAILED = 3
};
- typedef boost::function<void()> connect_callback_t;
typedef boost::function<void(bool ok)> share_callback_t;
typedef boost::function<void()> content_updated_callback_t;
- void connectToFacebook(const std::string& auth_code = "", connect_callback_t cb = connect_callback_t()); // Initiate the complete FB connection. Please use getConnectionToFacebook() in normal use.
- void disconnectFromFacebook(); // Disconnect from the FBC service.
- void getConnectionToFacebook(bool auto_connect = false, connect_callback_t cb = connect_callback_t()); // Check if an access token is available on the FBC service. If not, call connectToFacebook().
+ 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().
void loadFacebookFriends();
void postCheckin(const std::string& location, const std::string& name, const std::string& description, const std::string& picture, const std::string& message);
@@ -72,8 +73,8 @@ public:
void storeContent(const LLSD& content);
const LLSD& getContent() const;
- void setConnectionState(EConnectionState connection_state) { mConnectionState = connection_state; }
- bool isConnected() { return (mConnectionState == FB_CONNECTED); }
+ void setConnectionState(EConnectionState connection_state);
+ bool isConnected() { return (mConnectionState == FB_CONNECTED); }
S32 generation() { return mGeneration; }
void openFacebookWeb(std::string url);
@@ -93,6 +94,8 @@ private:
share_callback_t mSharePhotoCallback;
share_callback_t mUpdateStatusCallback;
content_updated_callback_t mContentUpdatedCallback;
+
+ static boost::scoped_ptr<LLEventPump> sStateWatcher;
};
#endif // LL_LLFACEBOOKCONNECT_H
diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp
index 4660644969..50d641865b 100644
--- a/indra/newview/llfloatersocial.cpp
+++ b/indra/newview/llfloatersocial.cpp
@@ -536,8 +536,8 @@ void LLFloaterSocial::onCancel()
BOOL LLFloaterSocial::postBuild()
{
- // Initiate a connection to Facebook (getConnectionToFacebook() handles the already connected state)
- LLFacebookConnect::instance().getConnectionToFacebook(true);
+ // 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/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index bd4813f945..8c8cad0743 100755
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -839,16 +839,36 @@ void LLPanelPeople::updateRecentList()
mRecentList->setDirty();
}
+bool LLPanelPeople::onConnectedToFacebook(const LLSD& data)
+{
+ if (data.get("enum").asInteger() == LLFacebookConnect::FB_CONNECTED)
+ {
+ LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLPanelPeople");
+
+ LLFacebookConnect::instance().loadFacebookFriends();
+ }
+
+ return false;
+}
+
void LLPanelPeople::updateFacebookList(bool visible)
{
- if(visible)
+ if (visible)
{
LLFacebookConnect::instance().setContentUpdatedCallback(boost::bind(&LLPanelPeople::updateSuggestedFriendList, this));
if (mTryToConnectToFbc)
- {
+ {
// try to reconnect to facebook!
- LLFacebookConnect::instance().getConnectionToFacebook(false, boost::bind(&LLFacebookConnect::loadFacebookFriends, &LLFacebookConnect::instance()));
+ if (LLFacebookConnect::instance().isConnected())
+ {
+ LLFacebookConnect::instance().loadFacebookFriends();
+ }
+ else
+ {
+ LLEventPumps::instance().obtain("FacebookConnectState").listen("LLPanelPeople", boost::bind(&LLPanelPeople::onConnectedToFacebook, this, _1));
+ LLFacebookConnect::instance().checkConnectionToFacebook();
+ }
// don't try again
mTryToConnectToFbc = false;
diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h
index 666702a08c..c6ee7b8165 100755
--- a/indra/newview/llpanelpeople.h
+++ b/indra/newview/llpanelpeople.h
@@ -126,6 +126,8 @@ private:
void onFriendListRefreshComplete(LLUICtrl*ctrl, const LLSD& param);
+ bool onConnectedToFacebook(const LLSD& data);
+
void setAccordionCollapsedByUser(LLUICtrl* acc_tab, bool collapsed);
void setAccordionCollapsedByUser(const std::string& name, bool collapsed);
bool isAccordionCollapsedByUser(LLUICtrl* acc_tab);