summaryrefslogtreecommitdiff
path: root/indra/newview/llfacebookconnect.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfacebookconnect.cpp')
-rw-r--r--indra/newview/llfacebookconnect.cpp224
1 files changed, 131 insertions, 93 deletions
diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp
index 9a20ce8f1b..b1544d606c 100644
--- a/indra/newview/llfacebookconnect.cpp
+++ b/indra/newview/llfacebookconnect.cpp
@@ -110,28 +110,36 @@ public:
LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS);
}
- virtual void completed(U32 status, const std::string& reason, const LLSD& content)
+ /* virtual */ void httpSuccess()
{
- if (isGoodStatus(status))
+ LL_DEBUGS("FacebookConnect") << "Connect successful. " << dumpResponse() << LL_ENDL;
+ LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED);
+ }
+
+ /* virtual */ void httpFailure()
+ {
+ if ( HTTP_FOUND == getStatus() )
{
- LL_DEBUGS("FacebookConnect") << "Connect successful. content: " << content << LL_ENDL;
-
- LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED);
+ const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION);
+ if (location.empty())
+ {
+ LL_WARNS("FacebookConnect") << "Missing Location header " << dumpResponse()
+ << "[headers:" << getResponseHeaders() << "]" << LL_ENDL;
+ }
+ else
+ {
+ LLFacebookConnect::instance().openFacebookWeb(location);
+ }
}
- else if (status != 302)
+ else
{
- LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_FAILED);
- log_facebook_connect_error("Connect", status, reason, content.get("error_code"), content.get("error_description"));
+ LL_WARNS("FacebookConnect") << dumpResponse() << LL_ENDL;
+ LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_FAILED);
+ const LLSD& content = getContent();
+ log_facebook_connect_error("Connect", getStatus(), getReason(),
+ content.get("error_code"), content.get("error_description"));
}
}
-
- void completedHeader(U32 status, const std::string& reason, const LLSD& content)
- {
- if (status == 302)
- {
- LLFacebookConnect::instance().openFacebookWeb(content["location"]);
- }
- }
};
///////////////////////////////////////////////////////////////////////////////
@@ -145,34 +153,42 @@ public:
{
LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POSTING);
}
-
- virtual void completed(U32 status, const std::string& reason, const LLSD& content)
+
+ /* virtual */ void httpSuccess()
+ {
+ toast_user_for_success();
+ LL_DEBUGS("FacebookConnect") << "Post successful. " << dumpResponse() << LL_ENDL;
+ LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POSTED);
+ }
+
+ /* virtual */ void httpFailure()
{
- if (isGoodStatus(status))
+ if ( HTTP_FOUND == getStatus() )
{
- toast_user_for_success();
- LL_DEBUGS("FacebookConnect") << "Post successful. content: " << content << LL_ENDL;
-
- LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POSTED);
+ const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION);
+ if (location.empty())
+ {
+ LL_WARNS("FacebookConnect") << "Missing Location header " << dumpResponse()
+ << "[headers:" << getResponseHeaders() << "]" << LL_ENDL;
+ }
+ else
+ {
+ LLFacebookConnect::instance().openFacebookWeb(location);
+ }
}
- else if (status == 404)
+ else if ( HTTP_NOT_FOUND == getStatus() )
{
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"));
+ LL_WARNS("FacebookConnect") << dumpResponse() << LL_ENDL;
+ LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POST_FAILED);
+ const LLSD& content = getContent();
+ log_facebook_connect_error("Share", getStatus(), getReason(),
+ content.get("error_code"), content.get("error_description"));
}
}
-
- void completedHeader(U32 status, const std::string& reason, const LLSD& content)
- {
- if (status == 302)
- {
- LLFacebookConnect::instance().openFacebookWeb(content["location"]);
- }
- }
};
///////////////////////////////////////////////////////////////////////////////
@@ -196,24 +212,27 @@ public:
LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED);
}
- virtual void completed(U32 status, const std::string& reason, const LLSD& content)
+ /* virtual */ void httpSuccess()
{
- if (isGoodStatus(status))
- {
- LL_DEBUGS("FacebookConnect") << "Disconnect successful. content: " << content << LL_ENDL;
- setUserDisconnected();
+ LL_DEBUGS("FacebookConnect") << "Disconnect successful. " << dumpResponse() << LL_ENDL;
+ setUserDisconnected();
+ }
- }
+ /* virtual */ void httpFailure()
+ {
//User not found so already disconnected
- else if(status == 404)
+ if ( HTTP_NOT_FOUND == getStatus() )
{
- LL_DEBUGS("FacebookConnect") << "Already disconnected. content: " << content << LL_ENDL;
+ LL_DEBUGS("FacebookConnect") << "Already disconnected. " << dumpResponse() << LL_ENDL;
setUserDisconnected();
}
else
{
+ LL_WARNS("FacebookConnect") << dumpResponse() << LL_ENDL;
LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_DISCONNECT_FAILED);
- log_facebook_connect_error("Disconnect", status, reason, content.get("error_code"), content.get("error_description"));
+ const LLSD& content = getContent();
+ log_facebook_connect_error("Disconnect", getStatus(), getReason(),
+ content.get("error_code"), content.get("error_description"));
}
}
};
@@ -229,34 +248,35 @@ public:
{
LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS);
}
-
- virtual void completed(U32 status, const std::string& reason, const LLSD& content)
+
+ /* virtual */ void httpSuccess()
+ {
+ LL_DEBUGS("FacebookConnect") << "Connect successful. " << dumpResponse() << LL_ENDL;
+ LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED);
+ }
+
+ /* virtual */ void httpFailure()
{
- if (isGoodStatus(status))
+ // show the facebook login page if not connected yet
+ if ( HTTP_NOT_FOUND == getStatus() )
{
- LL_DEBUGS("FacebookConnect") << "Connect successful. content: " << content << LL_ENDL;
-
- LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED);
+ LL_DEBUGS("FacebookConnect") << "Not connected. " << dumpResponse() << LL_ENDL;
+ if (mAutoConnect)
+ {
+ LLFacebookConnect::instance().connectToFacebook();
+ }
+ else
+ {
+ LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED);
+ }
}
else
{
- // show the facebook login page if not connected yet
- if (status == 404)
- {
- if (mAutoConnect)
- {
- LLFacebookConnect::instance().connectToFacebook();
- }
- else
- {
- LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED);
- }
- }
- else
- {
- LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_FAILED);
- log_facebook_connect_error("Connected", status, reason, content.get("error_code"), content.get("error_description"));
- }
+ LL_WARNS("FacebookConnect") << dumpResponse() << LL_ENDL;
+ LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_DISCONNECT_FAILED);
+ const LLSD& content = getContent();
+ log_facebook_connect_error("Connected", getStatus(), getReason(),
+ content.get("error_code"), content.get("error_description"));
}
}
@@ -271,25 +291,34 @@ class LLFacebookInfoResponder : public LLHTTPClient::Responder
LOG_CLASS(LLFacebookInfoResponder);
public:
- virtual void completed(U32 status, const std::string& reason, const LLSD& info)
+ /* virtual */ void httpSuccess()
{
- if (isGoodStatus(status))
- {
- llinfos << "Facebook: Info received" << llendl;
- LL_DEBUGS("FacebookConnect") << "Getting Facebook info successful. info: " << info << LL_ENDL;
- LLFacebookConnect::instance().storeInfo(info);
- }
- else
- {
- log_facebook_connect_error("Info", status, reason, info.get("error_code"), info.get("error_description"));
- }
+ LL_INFOS("FacebookConnect") << "Facebook: Info received" << LL_ENDL;
+ LL_DEBUGS("FacebookConnect") << "Getting Facebook info successful. " << dumpResponse() << LL_ENDL;
+ LLFacebookConnect::instance().storeInfo(getContent());
}
- void completedHeader(U32 status, const std::string& reason, const LLSD& content)
+ /* virtual */ void httpFailure()
{
- if (status == 302)
+ if ( HTTP_FOUND == getStatus() )
+ {
+ const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION);
+ if (location.empty())
+ {
+ LL_WARNS("FacebookConnect") << "Missing Location header " << dumpResponse()
+ << "[headers:" << getResponseHeaders() << "]" << LL_ENDL;
+ }
+ else
+ {
+ LLFacebookConnect::instance().openFacebookWeb(location);
+ }
+ }
+ else
{
- LLFacebookConnect::instance().openFacebookWeb(content["location"]);
+ LL_WARNS("FacebookConnect") << dumpResponse() << LL_ENDL;
+ const LLSD& content = getContent();
+ log_facebook_connect_error("Info", getStatus(), getReason(),
+ content.get("error_code"), content.get("error_description"));
}
}
};
@@ -300,27 +329,36 @@ class LLFacebookFriendsResponder : public LLHTTPClient::Responder
{
LOG_CLASS(LLFacebookFriendsResponder);
public:
+
+ /* virtual */ void httpSuccess()
+ {
+ LL_DEBUGS("FacebookConnect") << "Getting Facebook friends successful. " << dumpResponse() << LL_ENDL;
+ LLFacebookConnect::instance().storeContent(getContent());
+ }
- virtual void completed(U32 status, const std::string& reason, const LLSD& content)
+ /* virtual */ void httpFailure()
{
- if (isGoodStatus(status))
+ if ( HTTP_FOUND == getStatus() )
{
- LL_DEBUGS("FacebookConnect") << "Getting Facebook friends successful. content: " << content << LL_ENDL;
- LLFacebookConnect::instance().storeContent(content);
+ const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION);
+ if (location.empty())
+ {
+ LL_WARNS("FacebookConnect") << "Missing Location header " << dumpResponse()
+ << "[headers:" << getResponseHeaders() << "]" << LL_ENDL;
+ }
+ else
+ {
+ LLFacebookConnect::instance().openFacebookWeb(location);
+ }
}
else
{
- log_facebook_connect_error("Friends", status, reason, content.get("error_code"), content.get("error_description"));
+ LL_WARNS("FacebookConnect") << dumpResponse() << LL_ENDL;
+ const LLSD& content = getContent();
+ log_facebook_connect_error("Friends", getStatus(), getReason(),
+ content.get("error_code"), content.get("error_description"));
}
}
-
- void completedHeader(U32 status, const std::string& reason, const LLSD& content)
- {
- if (status == 302)
- {
- LLFacebookConnect::instance().openFacebookWeb(content["location"]);
- }
- }
};
///////////////////////////////////////////////////////////////////////////////