diff options
Diffstat (limited to 'indra/newview/llfacebookconnect.cpp')
-rw-r--r-- | indra/newview/llfacebookconnect.cpp | 79 |
1 files changed, 61 insertions, 18 deletions
diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 9a20ce8f1b..e3ddb31935 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -28,6 +28,8 @@ #include "llviewerprecompiledheaders.h" #include "llfacebookconnect.h" +#include "llflickrconnect.h" +#include "lltwitterconnect.h" #include "llagent.h" #include "llcallingcard.h" // for LLAvatarTracker @@ -58,7 +60,7 @@ void log_facebook_connect_error(const std::string& request, U32 status, const st } } -void toast_user_for_success() +void toast_user_for_facebook_success() { LLSD args; args["MESSAGE"] = LLTrans::getString("facebook_post_success"); @@ -74,23 +76,46 @@ public: bool handle(const LLSD& tokens, const LLSD& query_map, LLMediaCtrl* web) { - if (tokens.size() > 0) + if (tokens.size() >= 1) { if (tokens[0].asString() == "connect") { - // this command probably came from the fbc_web browser, so close it - LLFloater* fbc_web = LLFloaterReg::getInstance("fbc_web"); - if (fbc_web) + if (tokens.size() >= 2 && tokens[1].asString() == "flickr") { - fbc_web->closeFloater(); + // this command probably came from the flickr_web browser, so close it + LLFloaterReg::hideInstance("flickr_web"); + + // connect to flickr + if (query_map.has("oauth_token")) + { + LLFlickrConnect::instance().connectToFlickr(query_map["oauth_token"], query_map.get("oauth_verifier")); + } + return true; } - - // connect to facebook - if (query_map.has("code")) + else if (tokens.size() >= 2 && tokens[1].asString() == "twitter") + { + // this command probably came from the twitter_web browser, so close it + LLFloaterReg::hideInstance("twitter_web"); + + // connect to twitter + if (query_map.has("oauth_token")) + { + LLTwitterConnect::instance().connectToTwitter(query_map["oauth_token"], query_map.get("oauth_verifier")); + } + return true; + } + else //if (tokens.size() >= 2 && tokens[1].asString() == "facebook") { - LLFacebookConnect::instance().connectToFacebook(query_map["code"], query_map.get("state")); + // this command probably came from the fbc_web browser, so close it + LLFloaterReg::hideInstance("fbc_web"); + + // connect to facebook + if (query_map.has("code")) + { + LLFacebookConnect::instance().connectToFacebook(query_map["code"], query_map.get("state")); + } + return true; } - return true; } } return false; @@ -150,7 +175,7 @@ public: { if (isGoodStatus(status)) { - toast_user_for_success(); + toast_user_for_facebook_success(); LL_DEBUGS("FacebookConnect") << "Post successful. content: " << content << LL_ENDL; LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POSTED); @@ -340,10 +365,12 @@ void LLFacebookConnect::openFacebookWeb(std::string url) { // Open the URL in an internal browser window without navigation UI LLFloaterWebContent::Params p; - p.url(url).show_chrome(true); - p.url(url).allow_address_entry(false); - p.url(url).allow_back_forward_navigation(false); - p.url(url).trusted_content(true); + p.url(url); + p.show_chrome(true); + p.allow_address_entry(false); + p.allow_back_forward_navigation(false); + p.trusted_content(true); + p.clean_browser(true); LLFloater *floater = LLFloaterReg::showInstance("fbc_web", p); //the internal web browser has a bug that prevents it from gaining focus unless a mouse event occurs first (it seems). //So when showing the internal web browser, set focus to it's containing floater "fbc_web". When a mouse event @@ -360,6 +387,7 @@ std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route, b LLViewerRegion *regionp = gAgent.getRegion(); if (regionp) { + //url = "http://pdp15.lindenlab.com/fbc/agent/" + gAgentID.asString(); // TEMPORARY FOR TESTING - CHO url = regionp->getCapability("FacebookConnect"); url += route; @@ -375,9 +403,13 @@ void LLFacebookConnect::connectToFacebook(const std::string& auth_code, const st { LLSD body; if (!auth_code.empty()) + { body["code"] = auth_code; + } if (!auth_state.empty()) + { body["state"] = auth_state; + } LLHTTPClient::put(getFacebookConnectURL("/connection"), body, new LLFacebookConnectResponder()); } @@ -421,15 +453,25 @@ void LLFacebookConnect::postCheckin(const std::string& location, const std::stri { LLSD body; if (!location.empty()) + { body["location"] = location; + } if (!name.empty()) + { body["name"] = name; + } if (!description.empty()) + { body["description"] = description; + } if (!image.empty()) + { body["image"] = image; + } if (!message.empty()) + { 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", true), body, new LLFacebookShareResponder()); @@ -568,12 +610,13 @@ void LLFacebookConnect::setConnectionState(LLFacebookConnect::EConnectionState c if (mConnectionState != connection_state) { + // set the connection state before notifying watchers + mConnectionState = connection_state; + LLSD state_info; state_info["enum"] = connection_state; sStateWatcher->post(state_info); } - - mConnectionState = connection_state; } void LLFacebookConnect::setConnected(bool connected) |