summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/llfacebookconnect.cpp51
-rw-r--r--indra/newview/llfacebookconnect.h22
-rwxr-xr-xindra/newview/llfloatersnapshot.cpp4
-rwxr-xr-xindra/newview/llpanelpeople.cpp4
-rwxr-xr-xindra/newview/llpanelsnapshotfacebook.cpp6
-rwxr-xr-xindra/newview/llviewermenu.cpp4
6 files changed, 46 insertions, 45 deletions
diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp
index 3de2351d78..ef0ae0a69e 100644
--- a/indra/newview/llfacebookconnect.cpp
+++ b/indra/newview/llfacebookconnect.cpp
@@ -57,7 +57,6 @@ void prompt_user_for_error(U32 status, const std::string& reason, const std::str
///////////////////////////////////////////////////////////////////////////////
//
-
class LLFacebookConnectHandler : public LLCommandHandler
{
public:
@@ -87,6 +86,10 @@ class LLFacebookConnectResponder : public LLHTTPClient::Responder
{
LOG_CLASS(LLFacebookConnectResponder);
public:
+ LLFacebookConnectResponder()
+ {
+ LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS);
+ }
virtual void completed(U32 status, const std::string& reason, const LLSD& content)
{
@@ -95,11 +98,12 @@ public:
LL_DEBUGS("FacebookConnect") << "Connect successful. content: " << content << LL_ENDL;
// Grab some graph data now that we are connected
- LLFacebookConnect::instance().setConnected(true);
+ LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED);
LLFacebookConnect::instance().loadFacebookFriends();
}
else
{
+ LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_FAILED);
prompt_user_for_error(status, reason, content.get("error_code"), content.get("error_description"));
LL_WARNS("FacebookConnect") << "Failed to get a response. reason: " << reason << " status: " << status << LL_ENDL;
}
@@ -169,7 +173,7 @@ public:
LL_DEBUGS("FacebookConnect") << "Disconnect successful. content: " << content << LL_ENDL;
// Clear all facebook stuff
- LLFacebookConnect::instance().setConnected(false);
+ LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED);
LLFacebookConnect::instance().clearContent();
}
else
@@ -187,10 +191,10 @@ class LLFacebookConnectedResponder : public LLHTTPClient::Responder
LOG_CLASS(LLFacebookConnectedResponder);
public:
- LLFacebookConnectedResponder(bool show_login_if_not_connected, bool show_error_if_not_connected)
- : mShowLoginIfNotConnected(show_login_if_not_connected),
- mShowErrorIfNotConnected(show_error_if_not_connected)
- {}
+ LLFacebookConnectedResponder()
+ {
+ LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS);
+ }
virtual void completed(U32 status, const std::string& reason, const LLSD& content)
{
@@ -199,7 +203,7 @@ public:
LL_DEBUGS("FacebookConnect") << "Connect successful. content: " << content << LL_ENDL;
// Grab some graph data if already connected
- LLFacebookConnect::instance().setConnected(true);
+ LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED);
LLFacebookConnect::instance().loadFacebookFriends();
}
else
@@ -207,20 +211,19 @@ public:
LL_WARNS("FacebookConnect") << "Failed to get a response. reason: " << reason << " status: " << status << LL_ENDL;
// show the facebook login page if not connected yet
- if ((status == 404) && mShowLoginIfNotConnected)
+ if (status == 404)
{
LLFacebookConnect::instance().connectToFacebook();
}
- else if(mShowErrorIfNotConnected)
+ else
{
+ LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_FAILED);
prompt_user_for_error(status, reason, content.get("error_code"), content.get("error_description"));
}
}
}
private:
- bool mShowLoginIfNotConnected;
- bool mShowErrorIfNotConnected;
};
///////////////////////////////////////////////////////////////////////////////
@@ -256,7 +259,7 @@ public:
///////////////////////////////////////////////////////////////////////////////
//
LLFacebookConnect::LLFacebookConnect()
-: mConnectedToFbc(false),
+: mConnectionState(FB_NOT_CONNECTED),
mContent(),
mGeneration(0)
{
@@ -290,23 +293,15 @@ void LLFacebookConnect::disconnectFromFacebook()
LLHTTPClient::del(getFacebookConnectURL("/connection"), new LLFacebookDisconnectResponder());
}
-void LLFacebookConnect::tryToReconnectToFacebook()
-{
- if (!mConnectedToFbc)
- {
- const bool follow_redirects=false;
- const F32 timeout=HTTP_REQUEST_EXPIRY_SECS;
- LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(false, false),
- LLSD(), timeout, follow_redirects);
- }
-}
-
void LLFacebookConnect::getConnectionToFacebook()
{
- const bool follow_redirects=false;
- const F32 timeout=HTTP_REQUEST_EXPIRY_SECS;
- LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(true, true),
- LLSD(), timeout, follow_redirects);
+ 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(),
+ LLSD(), timeout, follow_redirects);
+ }
}
void LLFacebookConnect::loadFacebookFriends()
diff --git a/indra/newview/llfacebookconnect.h b/indra/newview/llfacebookconnect.h
index 37b4e2bc94..e719314920 100644
--- a/indra/newview/llfacebookconnect.h
+++ b/indra/newview/llfacebookconnect.h
@@ -41,12 +41,19 @@ class LLFacebookConnect : public LLSingleton<LLFacebookConnect>
{
LOG_CLASS(LLFacebookConnect);
public:
+ enum EConnectionState
+ {
+ FB_NOT_CONNECTED = 0,
+ FB_CONNECTION_IN_PROGRESS = 1,
+ FB_CONNECTED = 2,
+ FB_CONNECTION_FAILED = 3
+ };
+
typedef boost::function<void(bool ok)> share_callback_t;
- void connectToFacebook(const std::string& auth_code = "");
- void disconnectFromFacebook();
- void tryToReconnectToFacebook();
- void getConnectionToFacebook();
+ void connectToFacebook(const std::string& auth_code = ""); // Initiate the complete FB connection. Please use getConnectionToFacebook() in normal use.
+ void disconnectFromFacebook(); // Disconnect from the FBC service.
+ void getConnectionToFacebook(); // 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);
@@ -62,21 +69,20 @@ public:
void storeContent(const LLSD& content);
const LLSD& getContent() const;
- void setConnected(bool connected) { mConnectedToFbc = connected; }
- bool getConnected() { return mConnectedToFbc; }
+ void setConnectionState(EConnectionState connection_state) { mConnectionState = connection_state; }
+ bool isConnected() { return (mConnectionState == FB_CONNECTED); }
S32 generation() { return mGeneration; }
void openFacebookWeb(std::string url);
private:
-
friend class LLSingleton<LLFacebookConnect>;
LLFacebookConnect();
~LLFacebookConnect() {};
std::string getFacebookConnectURL(const std::string& route = "");
- bool mConnectedToFbc;
+ EConnectionState mConnectionState;
LLSD mContent;
S32 mGeneration;
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index d60f9a48c4..0703600961 100755
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -2250,9 +2250,9 @@ void LLFloaterSnapshot::update()
// We need to pool on facebook connection as it might change any time
static bool s_facebook_connected = false;
- if (LLFacebookConnect::instance().getConnected() != s_facebook_connected)
+ if (LLFacebookConnect::instance().isConnected() != s_facebook_connected)
{
- s_facebook_connected = LLFacebookConnect::instance().getConnected();
+ s_facebook_connected = LLFacebookConnect::instance().isConnected();
changed = true;
}
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index 4f91a65dfa..24e8d40d7e 100755
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -958,7 +958,7 @@ void LLPanelPeople::updateFacebookList()
if (mTryToConnectToFbc)
{
// try to reconnect to facebook!
- LLFacebookConnect::instance().tryToReconnectToFacebook();
+ LLFacebookConnect::instance().getConnectionToFacebook();
// don't try again
mTryToConnectToFbc = false;
@@ -1749,7 +1749,7 @@ void LLPanelPeople::addParticipantToModel(LLPersonTabModel * person_folder_model
void LLPanelPeople::onLoginFbcButtonClicked()
{
- if (LLFacebookConnect::instance().getConnected())
+ if (LLFacebookConnect::instance().isConnected())
{
LLFacebookConnect::instance().disconnectFromFacebook();
}
diff --git a/indra/newview/llpanelsnapshotfacebook.cpp b/indra/newview/llpanelsnapshotfacebook.cpp
index 30ef5f326c..0a76bc3b9d 100755
--- a/indra/newview/llpanelsnapshotfacebook.cpp
+++ b/indra/newview/llpanelsnapshotfacebook.cpp
@@ -87,7 +87,7 @@ BOOL LLPanelSnapshotFacebook::postBuild()
// virtual
void LLPanelSnapshotFacebook::onOpen(const LLSD& key)
{
- if (!LLFacebookConnect::instance().getConnected())
+ if (!LLFacebookConnect::instance().isConnected())
{
LLFacebookConnect::instance().getConnectionToFacebook();
}
@@ -99,7 +99,7 @@ void LLPanelSnapshotFacebook::onOpen(const LLSD& key)
void LLPanelSnapshotFacebook::updateControls(const LLSD& info)
{
const bool have_snapshot = info.has("have-snapshot") ? info["have-snapshot"].asBoolean() : true;
- const bool is_connected = LLFacebookConnect::instance().getConnected();
+ const bool is_connected = LLFacebookConnect::instance().isConnected();
getChild<LLUICtrl>("post_btn")->setEnabled(have_snapshot && is_connected);
}
@@ -107,7 +107,7 @@ void LLPanelSnapshotFacebook::updateControls(const LLSD& info)
void LLPanelSnapshotFacebook::updateCustomResControls()
{
LLPanelSnapshot::updateCustomResControls();
- const bool is_connected = LLFacebookConnect::instance().getConnected();
+ const bool is_connected = LLFacebookConnect::instance().isConnected();
getChild<LLUICtrl>("post_btn")->setEnabled(is_connected);
}
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 67460c4bc6..ae28d6b129 100755
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -5974,7 +5974,7 @@ void handle_report_abuse()
void handle_facebook_connect()
{
- if (!LLFacebookConnect::instance().getConnected())
+ if (!LLFacebookConnect::instance().isConnected())
{
LLFacebookConnect::instance().getConnectionToFacebook();
}
@@ -5983,7 +5983,7 @@ void handle_facebook_connect()
bool enable_facebook_connect()
{
// The menu item will be disabled if we are already connected
- return !LLFacebookConnect::instance().getConnected();
+ return !LLFacebookConnect::instance().isConnected();
}
void handle_facebook_checkin()