diff options
author | Merov Linden <merov@lindenlab.com> | 2014-06-17 15:12:31 -0700 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2014-06-17 15:12:31 -0700 |
commit | e3e1a527ccbab17e140f91267c847d7e799dbe6f (patch) | |
tree | 2e093acb5b77fe45e7bff78e598d2d7adc26d2b9 /indra | |
parent | c4c8debfc230b4ec6d28c7a84cd2a9bb81d6c894 (diff) |
DRTVWR-354 : Rewrite Responders for Twitter and Flickr to conform to new LLHTTPClient interface. Fix merge error in Facebook connect as well
Diffstat (limited to 'indra')
-rwxr-xr-x | indra/newview/llfacebookconnect.cpp | 15 | ||||
-rw-r--r-- | indra/newview/llflickrconnect.cpp | 183 | ||||
-rw-r--r-- | indra/newview/lltwitterconnect.cpp | 185 |
3 files changed, 224 insertions, 159 deletions
diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 1b741ecc0e..28319564e4 100755 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -181,7 +181,7 @@ public: /* virtual */ void httpSuccess() { - toast_user_for_success(); + toast_user_for_facebook_success(); LL_DEBUGS("FacebookConnect") << "Post successful. " << dumpResponse() << LL_ENDL; LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POSTED); } @@ -327,9 +327,16 @@ public: { if ( HTTP_FOUND == getStatus() ) { - LL_INFOS() << "Facebook: Info received" << LL_ENDL; - LL_DEBUGS("FacebookConnect") << "Getting Facebook info successful. info: " << getContent() << LL_ENDL; - LLFacebookConnect::instance().storeInfo(getContent()); + 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 { diff --git a/indra/newview/llflickrconnect.cpp b/indra/newview/llflickrconnect.cpp index 1898842478..b715896264 100644 --- a/indra/newview/llflickrconnect.cpp +++ b/indra/newview/llflickrconnect.cpp @@ -77,28 +77,36 @@ public: LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS); } - virtual void completed(U32 status, const std::string& reason, const LLSD& content) + /* virtual */ void httpSuccess() { - if (isGoodStatus(status)) + LL_DEBUGS("FlickrConnect") << "Connect successful. " << dumpResponse() << LL_ENDL; + LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTED); + } + + /* virtual */ void httpFailure() + { + if ( HTTP_FOUND == getStatus() ) { - LL_DEBUGS("FlickrConnect") << "Connect successful. content: " << content << LL_ENDL; - - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTED); + const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); + if (location.empty()) + { + LL_WARNS("FlickrConnect") << "Missing Location header " << dumpResponse() + << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; + } + else + { + LLFlickrConnect::instance().openFlickrWeb(location); + } } - else if (status != 302) + else { + LL_WARNS("FlickrConnect") << dumpResponse() << LL_ENDL; LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_FAILED); - log_flickr_connect_error("Connect", status, reason, content.get("error_code"), content.get("error_description")); + const LLSD& content = getContent(); + log_flickr_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) - { - LLFlickrConnect::instance().openFlickrWeb(content["location"]); - } - } }; /////////////////////////////////////////////////////////////////////////////// @@ -113,33 +121,41 @@ public: LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_POSTING); } - virtual void completed(U32 status, const std::string& reason, const LLSD& content) + /* virtual */ void httpSuccess() { - if (isGoodStatus(status)) + toast_user_for_flickr_success(); + LL_DEBUGS("FlickrConnect") << "Post successful. " << dumpResponse() << LL_ENDL; + LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_POSTED); + } + + /* virtual */ void httpFailure() + { + if ( HTTP_FOUND == getStatus() ) { - toast_user_for_flickr_success(); - LL_DEBUGS("FlickrConnect") << "Post successful. content: " << content << LL_ENDL; - - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_POSTED); + const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); + if (location.empty()) + { + LL_WARNS("FlickrConnect") << "Missing Location header " << dumpResponse() + << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; + } + else + { + LLFlickrConnect::instance().openFlickrWeb(location); + } } - else if (status == 404) + else if ( HTTP_NOT_FOUND == getStatus() ) { LLFlickrConnect::instance().connectToFlickr(); } else { + LL_WARNS("FlickrConnect") << dumpResponse() << LL_ENDL; LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_POST_FAILED); - log_flickr_connect_error("Share", status, reason, content.get("error_code"), content.get("error_description")); + const LLSD& content = getContent(); + log_flickr_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) - { - LLFlickrConnect::instance().openFlickrWeb(content["location"]); - } - } }; /////////////////////////////////////////////////////////////////////////////// @@ -163,24 +179,27 @@ public: LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_NOT_CONNECTED); } - virtual void completed(U32 status, const std::string& reason, const LLSD& content) + /* virtual */ void httpSuccess() + { + LL_DEBUGS("FlickrConnect") << "Disconnect successful. " << dumpResponse() << LL_ENDL; + setUserDisconnected(); + } + + /* virtual */ void httpFailure() { - if (isGoodStatus(status)) - { - LL_DEBUGS("FlickrConnect") << "Disconnect successful. content: " << content << LL_ENDL; - setUserDisconnected(); - - } //User not found so already disconnected - else if(status == 404) + if ( HTTP_NOT_FOUND == getStatus() ) { - LL_DEBUGS("FlickrConnect") << "Already disconnected. content: " << content << LL_ENDL; + LL_DEBUGS("FlickrConnect") << "Already disconnected. " << dumpResponse() << LL_ENDL; setUserDisconnected(); } else { + LL_WARNS("FlickrConnect") << dumpResponse() << LL_ENDL; LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_DISCONNECT_FAILED); - log_flickr_connect_error("Disconnect", status, reason, content.get("error_code"), content.get("error_description")); + const LLSD& content = getContent(); + log_flickr_connect_error("Disconnect", getStatus(), getReason(), + content.get("error_code"), content.get("error_description")); } } }; @@ -197,33 +216,34 @@ public: LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS); } - virtual void completed(U32 status, const std::string& reason, const LLSD& content) + /* virtual */ void httpSuccess() + { + LL_DEBUGS("FlickrConnect") << "Connect successful. " << dumpResponse() << LL_ENDL; + LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTED); + } + + /* virtual */ void httpFailure() { - if (isGoodStatus(status)) + // show the facebook login page if not connected yet + if ( HTTP_NOT_FOUND == getStatus() ) { - LL_DEBUGS("FlickrConnect") << "Connect successful. content: " << content << LL_ENDL; - - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTED); + LL_DEBUGS("FlickrConnect") << "Not connected. " << dumpResponse() << LL_ENDL; + if (mAutoConnect) + { + LLFlickrConnect::instance().connectToFlickr(); + } + else + { + LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_NOT_CONNECTED); + } } else { - // show the flickr login page if not connected yet - if (status == 404) - { - if (mAutoConnect) - { - LLFlickrConnect::instance().connectToFlickr(); - } - else - { - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_NOT_CONNECTED); - } - } - else - { - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_FAILED); - log_flickr_connect_error("Connected", status, reason, content.get("error_code"), content.get("error_description")); - } + LL_WARNS("FlickrConnect") << dumpResponse() << LL_ENDL; + LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_FAILED); + const LLSD& content = getContent(); + log_flickr_connect_error("Connected", getStatus(), getReason(), + content.get("error_code"), content.get("error_description")); } } @@ -238,25 +258,34 @@ class LLFlickrInfoResponder : public LLHTTPClient::Responder LOG_CLASS(LLFlickrInfoResponder); public: - virtual void completed(U32 status, const std::string& reason, const LLSD& info) + /* virtual */ void httpSuccess() + { + LL_INFOS("FlickrConnect") << "Flickr: Info received" << LL_ENDL; + LL_DEBUGS("FlickrConnect") << "Getting Flickr info successful. " << dumpResponse() << LL_ENDL; + LLFlickrConnect::instance().storeInfo(getContent()); + } + + /* virtual */ void httpFailure() { - if (isGoodStatus(status)) + if ( HTTP_FOUND == getStatus() ) { - llinfos << "Flickr: Info received" << llendl; - LL_DEBUGS("FlickrConnect") << "Getting Flickr info successful. info: " << info << LL_ENDL; - LLFlickrConnect::instance().storeInfo(info); + const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); + if (location.empty()) + { + LL_WARNS("FlickrConnect") << "Missing Location header " << dumpResponse() + << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; + } + else + { + LLFlickrConnect::instance().openFlickrWeb(location); + } } else { - log_flickr_connect_error("Info", status, reason, info.get("error_code"), info.get("error_description")); - } - } - - void completedHeader(U32 status, const std::string& reason, const LLSD& content) - { - if (status == 302) - { - LLFlickrConnect::instance().openFlickrWeb(content["location"]); + LL_WARNS("FlickrConnect") << dumpResponse() << LL_ENDL; + const LLSD& content = getContent(); + log_flickr_connect_error("Info", getStatus(), getReason(), + content.get("error_code"), content.get("error_description")); } } }; diff --git a/indra/newview/lltwitterconnect.cpp b/indra/newview/lltwitterconnect.cpp index cfdbca1b81..7088558b83 100644 --- a/indra/newview/lltwitterconnect.cpp +++ b/indra/newview/lltwitterconnect.cpp @@ -77,28 +77,36 @@ public: LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); } - virtual void completed(U32 status, const std::string& reason, const LLSD& content) + /* virtual */ void httpSuccess() { - if (isGoodStatus(status)) + LL_DEBUGS("TwitterConnect") << "Connect successful. " << dumpResponse() << LL_ENDL; + LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTED); + } + + /* virtual */ void httpFailure() + { + if ( HTTP_FOUND == getStatus() ) { - LL_DEBUGS("TwitterConnect") << "Connect successful. content: " << content << LL_ENDL; - - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTED); + const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); + if (location.empty()) + { + LL_WARNS("TwitterConnect") << "Missing Location header " << dumpResponse() + << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; + } + else + { + LLTwitterConnect::instance().openTwitterWeb(location); + } } - else if (status != 302) + else { - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_FAILED); - log_twitter_connect_error("Connect", status, reason, content.get("error_code"), content.get("error_description")); + LL_WARNS("TwitterConnect") << dumpResponse() << LL_ENDL; + LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_FAILED); + const LLSD& content = getContent(); + log_twitter_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) - { - LLTwitterConnect::instance().openTwitterWeb(content["location"]); - } - } }; /////////////////////////////////////////////////////////////////////////////// @@ -113,33 +121,41 @@ public: LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_POSTING); } - virtual void completed(U32 status, const std::string& reason, const LLSD& content) + /* virtual */ void httpSuccess() { - if (isGoodStatus(status)) + toast_user_for_twitter_success(); + LL_DEBUGS("TwitterConnect") << "Post successful. " << dumpResponse() << LL_ENDL; + LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_POSTED); + } + + /* virtual */ void httpFailure() + { + if ( HTTP_FOUND == getStatus() ) { - toast_user_for_twitter_success(); - LL_DEBUGS("TwitterConnect") << "Post successful. content: " << content << LL_ENDL; - - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_POSTED); + const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); + if (location.empty()) + { + LL_WARNS("TwitterConnect") << "Missing Location header " << dumpResponse() + << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; + } + else + { + LLTwitterConnect::instance().openTwitterWeb(location); + } } - else if (status == 404) + else if ( HTTP_NOT_FOUND == getStatus() ) { LLTwitterConnect::instance().connectToTwitter(); } else { + LL_WARNS("TwitterConnect") << dumpResponse() << LL_ENDL; LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_POST_FAILED); - log_twitter_connect_error("Share", status, reason, content.get("error_code"), content.get("error_description")); + const LLSD& content = getContent(); + log_twitter_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) - { - LLTwitterConnect::instance().openTwitterWeb(content["location"]); - } - } }; /////////////////////////////////////////////////////////////////////////////// @@ -163,24 +179,27 @@ public: LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_NOT_CONNECTED); } - virtual void completed(U32 status, const std::string& reason, const LLSD& content) + /* virtual */ void httpSuccess() + { + LL_DEBUGS("TwitterConnect") << "Disconnect successful. " << dumpResponse() << LL_ENDL; + setUserDisconnected(); + } + + /* virtual */ void httpFailure() { - if (isGoodStatus(status)) - { - LL_DEBUGS("TwitterConnect") << "Disconnect successful. content: " << content << LL_ENDL; - setUserDisconnected(); - - } //User not found so already disconnected - else if(status == 404) + if ( HTTP_NOT_FOUND == getStatus() ) { - LL_DEBUGS("TwitterConnect") << "Already disconnected. content: " << content << LL_ENDL; + LL_DEBUGS("TwitterConnect") << "Already disconnected. " << dumpResponse() << LL_ENDL; setUserDisconnected(); } else { + LL_WARNS("TwitterConnect") << dumpResponse() << LL_ENDL; LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_DISCONNECT_FAILED); - log_twitter_connect_error("Disconnect", status, reason, content.get("error_code"), content.get("error_description")); + const LLSD& content = getContent(); + log_twitter_connect_error("Disconnect", getStatus(), getReason(), + content.get("error_code"), content.get("error_description")); } } }; @@ -197,33 +216,34 @@ public: LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); } - virtual void completed(U32 status, const std::string& reason, const LLSD& content) + /* virtual */ void httpSuccess() + { + LL_DEBUGS("TwitterConnect") << "Connect successful. " << dumpResponse() << LL_ENDL; + LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTED); + } + + /* virtual */ void httpFailure() { - if (isGoodStatus(status)) + // show the facebook login page if not connected yet + if ( HTTP_NOT_FOUND == getStatus() ) { - LL_DEBUGS("TwitterConnect") << "Connect successful. content: " << content << LL_ENDL; - - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTED); + LL_DEBUGS("TwitterConnect") << "Not connected. " << dumpResponse() << LL_ENDL; + if (mAutoConnect) + { + LLTwitterConnect::instance().connectToTwitter(); + } + else + { + LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_NOT_CONNECTED); + } } else { - // show the twitter login page if not connected yet - if (status == 404) - { - if (mAutoConnect) - { - LLTwitterConnect::instance().connectToTwitter(); - } - else - { - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_NOT_CONNECTED); - } - } - else - { - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_FAILED); - log_twitter_connect_error("Connected", status, reason, content.get("error_code"), content.get("error_description")); - } + LL_WARNS("TwitterConnect") << dumpResponse() << LL_ENDL; + LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_FAILED); + const LLSD& content = getContent(); + log_twitter_connect_error("Connected", getStatus(), getReason(), + content.get("error_code"), content.get("error_description")); } } @@ -238,25 +258,34 @@ class LLTwitterInfoResponder : public LLHTTPClient::Responder LOG_CLASS(LLTwitterInfoResponder); public: - virtual void completed(U32 status, const std::string& reason, const LLSD& info) + /* virtual */ void httpSuccess() + { + LL_INFOS("TwitterConnect") << "Twitter: Info received" << LL_ENDL; + LL_DEBUGS("TwitterConnect") << "Getting Twitter info successful. " << dumpResponse() << LL_ENDL; + LLTwitterConnect::instance().storeInfo(getContent()); + } + + /* virtual */ void httpFailure() { - if (isGoodStatus(status)) + if ( HTTP_FOUND == getStatus() ) { - llinfos << "Twitter: Info received" << llendl; - LL_DEBUGS("TwitterConnect") << "Getting Twitter info successful. info: " << info << LL_ENDL; - LLTwitterConnect::instance().storeInfo(info); + const std::string& location = getResponseHeader(HTTP_IN_HEADER_LOCATION); + if (location.empty()) + { + LL_WARNS("TwitterConnect") << "Missing Location header " << dumpResponse() + << "[headers:" << getResponseHeaders() << "]" << LL_ENDL; + } + else + { + LLTwitterConnect::instance().openTwitterWeb(location); + } } else { - log_twitter_connect_error("Info", status, reason, info.get("error_code"), info.get("error_description")); - } - } - - void completedHeader(U32 status, const std::string& reason, const LLSD& content) - { - if (status == 302) - { - LLTwitterConnect::instance().openTwitterWeb(content["location"]); + LL_WARNS("TwitterConnect") << dumpResponse() << LL_ENDL; + const LLSD& content = getContent(); + log_twitter_connect_error("Info", getStatus(), getReason(), + content.get("error_code"), content.get("error_description")); } } }; |