From 14be8efcc6a9797d2041e56addd0897f0b4234ea Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 8 May 2013 16:53:52 -0700 Subject: ACME-348 : WIP : LLFacebookConnect refactoring --- indra/newview/llfacebookconnect.cpp | 215 ++++++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 indra/newview/llfacebookconnect.cpp (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp new file mode 100644 index 0000000000..1962f6fd97 --- /dev/null +++ b/indra/newview/llfacebookconnect.cpp @@ -0,0 +1,215 @@ +/** + * @file llfacebookconnect.h + * @author Merov, Cho, Gil + * @brief Connection to Facebook Service + * + * $LicenseInfo:firstyear=2013&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2013, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfacebookconnect.h" + +/////////////////////////////////////////////////////////////////////////////// +// +class LLFacebookConnectResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLFacebookConnectResponder); +public: + + virtual void completed(U32 status, const std::string& reason, const LLSD& content) + { + if (isGoodStatus(status)) + { + LL_DEBUGS("FacebookConnect") << "Connect successful. content: " << content << LL_ENDL; + + // Grab some graph data now that we are connected + LLFacebookConnect::instance().setConnected(true); + LLFacebookConnect::instance().loadFacebookFriends(); + } + else + { + LL_WARNS("FacebookConnect") << "Failed to get a response. reason: " << reason << " status: " << status << LL_ENDL; + } + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// +class LLFacebookDisconnectResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLFacebookDisconnectResponder); +public: + + virtual void completed(U32 status, const std::string& reason, const LLSD& content) + { + if (isGoodStatus(status)) + { + LL_DEBUGS("FacebookConnect") << "Disconnect successful. content: " << content << LL_ENDL; + + // Hide all the facebook stuff + LLFacebookConnect::instance().setConnected(false); + LLFacebookConnect::instance().hideFacebookFriends(); + } + else + { + LL_WARNS("FacebookConnect") << "Failed to get a response. reason: " << reason << " status: " << status << LL_ENDL; + } + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// +class LLFacebookConnectedResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLFacebookDisconnectResponder); +public: + + LLFacebookConnectedResponder(bool show_login_if_not_connected) : mShowLoginIfNotConnected(show_login_if_not_connected) {} + + virtual void completed(U32 status, const std::string& reason, const LLSD& content) + { + if (isGoodStatus(status)) + { + LL_DEBUGS("FacebookConnect") << "Connect successful. content: " << content << LL_ENDL; + + // Grab some graph data if already connected + LLFacebookConnect::instance().setConnected(true); + LLFacebookConnect::instance().loadFacebookFriends(); + } + else + { + 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) + { + LLFacebookConnect::instance().connectToFacebook(); + } + } + } + +private: + bool mShowLoginIfNotConnected; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +class LLFacebookFriendsResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLFacebookFriendsResponder); +public: + + virtual void completed(U32 status, const std::string& reason, const LLSD& content) + { + if (isGoodStatus(status)) + { + LL_DEBUGS("FacebookConnect") << "Getting Facebook friends successful. content: " << content << LL_ENDL; + + // Display the list of friends + LLFacebookConnect::instance().showFacebookFriends(content); + } + else + { + LL_WARNS("FacebookConnect") << "Failed to get a response. reason: " << reason << " status: " << status << LL_ENDL; + } + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// +LLFacebookConnect::LLFacebookConnect() +: mConnectedToFbc(false) +{ +} + +void LLFacebookConnect::init() +{ +} + +void LLFacebookConnect::loadFacebookFriends() +{ + const bool follow_redirects=false; + const F32 timeout=HTTP_REQUEST_EXPIRY_SECS; + LLHTTPClient::get(getFacebookConnectURL("/friend"), new FacebookFriendsResponder(this), + LLSD(), timeout, follow_redirects); +} + +void LLFacebookConnect::hideFacebookFriends() +{ + // That needs to be done in llpanelpeople... + //mFacebookFriends->clear(); +} + +void LLFacebookConnect::connectToFacebook(const std::string& auth_code) +{ + LLSD body; + if (!auth_code.empty()) + body["code"] = auth_code; + + LLHTTPClient::put(getFacebookConnectURL("/connection"), body, new FacebookConnectResponder(this)); +} + +void LLFacebookConnect::showFacebookFriends(const LLSD& friends) +{ + /* All that needs to be rewritten to + mFacebookFriends->clear(); + LLPersonTabModel::tab_type tab_type; + LLAvatarTracker& avatar_tracker = LLAvatarTracker::instance(); + + for (LLSD::map_const_iterator i = friends.beginMap(); i != friends.endMap(); ++i) + { + std::string name = i->second["name"].asString(); + LLUUID agent_id = i->second.has("agent_id") ? i->second["agent_id"].asUUID() : LLUUID(NULL); + + //add to avatar list + mFacebookFriends->addNewItem(agent_id, name, false); + + //FB+SL but not SL friend + if(agent_id.notNull() && !avatar_tracker.isBuddy(agent_id)) + { + tab_type = LLPersonTabModel::FB_SL_NON_SL_FRIEND; + } + //FB only friend + else + { + tab_type = LLPersonTabModel::FB_ONLY_FRIEND; + } + + //Add to person tab model + LLPersonTabModel * person_tab_model = dynamic_cast(mPersonFolderView->getPersonTabModelByIndex(tab_type)); + if(person_tab_model) + { + addParticipantToModel(person_tab_model, agent_id, name); + } + } + */ +} + + + + + + + + -- cgit v1.2.3 From 62eda57ea1f4d3e39aa34010f7709908f24fb6e2 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 9 May 2013 10:25:21 -0700 Subject: ACME-348 : WIP : LLFacebookConnect refactorin completed. Not functional yet though. --- indra/newview/llfacebookconnect.cpp | 92 +++++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 10 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 1962f6fd97..ec2085c2ac 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -29,6 +29,38 @@ #include "llfacebookconnect.h" +#include "llagent.h" +#include "llcallingcard.h" // for LLAvatarTracker +//#include "llcommandhandler.h" +#include "llhttpclient.h" + +/////////////////////////////////////////////////////////////////////////////// +// +/* +class LLFacebookConnectHandler : public LLCommandHandler +{ +public: + LLFacebookConnectHandler() : LLCommandHandler("fbc", UNTRUSTED_THROTTLE) { } + + bool handle(const LLSD& tokens, const LLSD& query_map, LLMediaCtrl* web) + { + if (tokens.size() > 0) + { + if (tokens[0].asString() == "connect") + { + if (query_map.has("code")) + { + LLFacebookConnect::instance().connectToFacebook(query_map["code"]); + } + return true; + } + } + return false; + } +}; +LLFacebookConnectHandler gFacebookConnectHandler; +*/ + /////////////////////////////////////////////////////////////////////////////// // class LLFacebookConnectResponder : public LLHTTPClient::Responder @@ -81,7 +113,7 @@ public: // class LLFacebookConnectedResponder : public LLHTTPClient::Responder { - LOG_CLASS(LLFacebookDisconnectResponder); + LOG_CLASS(LLFacebookConnectedResponder); public: LLFacebookConnectedResponder(bool show_login_if_not_connected) : mShowLoginIfNotConnected(show_login_if_not_connected) {} @@ -147,11 +179,20 @@ void LLFacebookConnect::init() { } +std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) +{ + //static std::string sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect"); + static std::string sFacebookConnectUrl = "https://pdp15.lindenlab.com/fbc/agent/" + gAgentID.asString(); // TEMPORARY HACK FOR FB DEMO - Cho + std::string url = sFacebookConnectUrl + route; + llinfos << url << llendl; + return url; +} + void LLFacebookConnect::loadFacebookFriends() { const bool follow_redirects=false; const F32 timeout=HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/friend"), new FacebookFriendsResponder(this), + LLHTTPClient::get(getFacebookConnectURL("/friend"), new LLFacebookFriendsResponder(), LLSD(), timeout, follow_redirects); } @@ -167,15 +208,41 @@ void LLFacebookConnect::connectToFacebook(const std::string& auth_code) if (!auth_code.empty()) body["code"] = auth_code; - LLHTTPClient::put(getFacebookConnectURL("/connection"), body, new FacebookConnectResponder(this)); + LLHTTPClient::put(getFacebookConnectURL("/connection"), body, new LLFacebookConnectResponder()); +} + +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), + 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), + LLSD(), timeout, follow_redirects); } void LLFacebookConnect::showFacebookFriends(const LLSD& friends) { - /* All that needs to be rewritten to - mFacebookFriends->clear(); - LLPersonTabModel::tab_type tab_type; + /* All that needs to be rewritten a different way */ + // FOR TESTING ONLY!! Print out the data in the log + //mFacebookFriends->clear(); + //LLPersonTabModel::tab_type tab_type; LLAvatarTracker& avatar_tracker = LLAvatarTracker::instance(); + llinfos << "LLFacebookConnect::showFacebookFriends" << llendl; for (LLSD::map_const_iterator i = friends.beginMap(); i != friends.endMap(); ++i) { @@ -183,27 +250,32 @@ void LLFacebookConnect::showFacebookFriends(const LLSD& friends) LLUUID agent_id = i->second.has("agent_id") ? i->second["agent_id"].asUUID() : LLUUID(NULL); //add to avatar list - mFacebookFriends->addNewItem(agent_id, name, false); + //mFacebookFriends->addNewItem(agent_id, name, false); //FB+SL but not SL friend + bool is_SL_friend = false; if(agent_id.notNull() && !avatar_tracker.isBuddy(agent_id)) { - tab_type = LLPersonTabModel::FB_SL_NON_SL_FRIEND; + //tab_type = LLPersonTabModel::FB_SL_NON_SL_FRIEND; + is_SL_friend = false; } //FB only friend else { - tab_type = LLPersonTabModel::FB_ONLY_FRIEND; + //tab_type = LLPersonTabModel::FB_ONLY_FRIEND; + is_SL_friend = true; } + llinfos << "LLFacebookConnect : agent_id = " << agent_id << ", name = " << name << ", SL friend = " << is_SL_friend << llendl; //Add to person tab model + /* LLPersonTabModel * person_tab_model = dynamic_cast(mPersonFolderView->getPersonTabModelByIndex(tab_type)); if(person_tab_model) { addParticipantToModel(person_tab_model, agent_id, name); } + */ } - */ } -- cgit v1.2.3 From f90d93f75da6481dc1b308dfb76dd767e7623ea5 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 10 May 2013 15:10:53 -0700 Subject: ACME-348 : WIP : Add some traces to work out the protocol (temporary) --- indra/newview/llfacebookconnect.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index ec2085c2ac..e7f039aff1 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -173,6 +173,7 @@ public: LLFacebookConnect::LLFacebookConnect() : mConnectedToFbc(false) { + llinfos << "Merov : LLFacebookConnect::LLFacebookConnect" << llendl; } void LLFacebookConnect::init() @@ -181,6 +182,7 @@ void LLFacebookConnect::init() std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) { + llinfos << "Merov : LLFacebookConnect::getFacebookConnectURL. route = " << route << llendl; //static std::string sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect"); static std::string sFacebookConnectUrl = "https://pdp15.lindenlab.com/fbc/agent/" + gAgentID.asString(); // TEMPORARY HACK FOR FB DEMO - Cho std::string url = sFacebookConnectUrl + route; @@ -190,6 +192,7 @@ std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) void LLFacebookConnect::loadFacebookFriends() { + llinfos << "Merov : LLFacebookConnect::loadFacebookFriends" << llendl; const bool follow_redirects=false; const F32 timeout=HTTP_REQUEST_EXPIRY_SECS; LLHTTPClient::get(getFacebookConnectURL("/friend"), new LLFacebookFriendsResponder(), @@ -198,12 +201,14 @@ void LLFacebookConnect::loadFacebookFriends() void LLFacebookConnect::hideFacebookFriends() { + llinfos << "Merov : LLFacebookConnect::hideFacebookFriends" << llendl; // That needs to be done in llpanelpeople... //mFacebookFriends->clear(); } void LLFacebookConnect::connectToFacebook(const std::string& auth_code) { + llinfos << "Merov : LLFacebookConnect::connectToFacebook" << llendl; LLSD body; if (!auth_code.empty()) body["code"] = auth_code; @@ -213,11 +218,13 @@ void LLFacebookConnect::connectToFacebook(const std::string& auth_code) void LLFacebookConnect::disconnectFromFacebook() { + llinfos << "Merov : LLFacebookConnect::disconnectFromFacebook" << llendl; LLHTTPClient::del(getFacebookConnectURL("/connection"), new LLFacebookDisconnectResponder()); } void LLFacebookConnect::tryToReconnectToFacebook() { + llinfos << "Merov : LLFacebookConnect::tryToReconnectToFacebook" << llendl; if (!mConnectedToFbc) { const bool follow_redirects=false; @@ -229,6 +236,7 @@ void LLFacebookConnect::tryToReconnectToFacebook() void LLFacebookConnect::getConnectionToFacebook() { + llinfos << "Merov : LLFacebookConnect::getConnectionToFacebook" << llendl; const bool follow_redirects=false; const F32 timeout=HTTP_REQUEST_EXPIRY_SECS; LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(true), @@ -242,7 +250,7 @@ void LLFacebookConnect::showFacebookFriends(const LLSD& friends) //mFacebookFriends->clear(); //LLPersonTabModel::tab_type tab_type; LLAvatarTracker& avatar_tracker = LLAvatarTracker::instance(); - llinfos << "LLFacebookConnect::showFacebookFriends" << llendl; + llinfos << "Merov : LLFacebookConnect::showFacebookFriends" << llendl; for (LLSD::map_const_iterator i = friends.beginMap(); i != friends.endMap(); ++i) { @@ -257,15 +265,15 @@ void LLFacebookConnect::showFacebookFriends(const LLSD& friends) if(agent_id.notNull() && !avatar_tracker.isBuddy(agent_id)) { //tab_type = LLPersonTabModel::FB_SL_NON_SL_FRIEND; - is_SL_friend = false; + is_SL_friend = true; } //FB only friend else { //tab_type = LLPersonTabModel::FB_ONLY_FRIEND; - is_SL_friend = true; + is_SL_friend = false; } - llinfos << "LLFacebookConnect : agent_id = " << agent_id << ", name = " << name << ", SL friend = " << is_SL_friend << llendl; + llinfos << "Merov : LLFacebookConnect : agent_id = " << agent_id << ", name = " << name << ", SL friend = " << is_SL_friend << llendl; //Add to person tab model /* -- cgit v1.2.3 From 7c4bfc8f55ebc581ddac0c2394b07b24d240d1a6 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 10 May 2013 18:25:45 -0700 Subject: ACME-348 : Completed : Facebook Connect refactored, LLPeoplePanel test list hooked correctly. --- indra/newview/llfacebookconnect.cpp | 100 ++++++++++-------------------------- 1 file changed, 28 insertions(+), 72 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index e7f039aff1..7f8e3afe89 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -98,9 +98,9 @@ public: { LL_DEBUGS("FacebookConnect") << "Disconnect successful. content: " << content << LL_ENDL; - // Hide all the facebook stuff + // Clear all facebook stuff LLFacebookConnect::instance().setConnected(false); - LLFacebookConnect::instance().hideFacebookFriends(); + LLFacebookConnect::instance().clearContent(); } else { @@ -156,9 +156,7 @@ public: if (isGoodStatus(status)) { LL_DEBUGS("FacebookConnect") << "Getting Facebook friends successful. content: " << content << LL_ENDL; - - // Display the list of friends - LLFacebookConnect::instance().showFacebookFriends(content); + LLFacebookConnect::instance().storeContent(content); } else { @@ -171,18 +169,14 @@ public: /////////////////////////////////////////////////////////////////////////////// // LLFacebookConnect::LLFacebookConnect() -: mConnectedToFbc(false) -{ - llinfos << "Merov : LLFacebookConnect::LLFacebookConnect" << llendl; -} - -void LLFacebookConnect::init() +: mConnectedToFbc(false), + mContent(), + mGeneration(0) { } std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) { - llinfos << "Merov : LLFacebookConnect::getFacebookConnectURL. route = " << route << llendl; //static std::string sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect"); static std::string sFacebookConnectUrl = "https://pdp15.lindenlab.com/fbc/agent/" + gAgentID.asString(); // TEMPORARY HACK FOR FB DEMO - Cho std::string url = sFacebookConnectUrl + route; @@ -190,25 +184,8 @@ std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) return url; } -void LLFacebookConnect::loadFacebookFriends() -{ - llinfos << "Merov : LLFacebookConnect::loadFacebookFriends" << llendl; - const bool follow_redirects=false; - const F32 timeout=HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/friend"), new LLFacebookFriendsResponder(), - LLSD(), timeout, follow_redirects); -} - -void LLFacebookConnect::hideFacebookFriends() -{ - llinfos << "Merov : LLFacebookConnect::hideFacebookFriends" << llendl; - // That needs to be done in llpanelpeople... - //mFacebookFriends->clear(); -} - void LLFacebookConnect::connectToFacebook(const std::string& auth_code) { - llinfos << "Merov : LLFacebookConnect::connectToFacebook" << llendl; LLSD body; if (!auth_code.empty()) body["code"] = auth_code; @@ -218,13 +195,11 @@ void LLFacebookConnect::connectToFacebook(const std::string& auth_code) void LLFacebookConnect::disconnectFromFacebook() { - llinfos << "Merov : LLFacebookConnect::disconnectFromFacebook" << llendl; LLHTTPClient::del(getFacebookConnectURL("/connection"), new LLFacebookDisconnectResponder()); } void LLFacebookConnect::tryToReconnectToFacebook() { - llinfos << "Merov : LLFacebookConnect::tryToReconnectToFacebook" << llendl; if (!mConnectedToFbc) { const bool follow_redirects=false; @@ -236,54 +211,35 @@ void LLFacebookConnect::tryToReconnectToFacebook() void LLFacebookConnect::getConnectionToFacebook() { - llinfos << "Merov : LLFacebookConnect::getConnectionToFacebook" << llendl; const bool follow_redirects=false; const F32 timeout=HTTP_REQUEST_EXPIRY_SECS; LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(true), LLSD(), timeout, follow_redirects); } -void LLFacebookConnect::showFacebookFriends(const LLSD& friends) +void LLFacebookConnect::loadFacebookFriends() { - /* All that needs to be rewritten a different way */ - // FOR TESTING ONLY!! Print out the data in the log - //mFacebookFriends->clear(); - //LLPersonTabModel::tab_type tab_type; - LLAvatarTracker& avatar_tracker = LLAvatarTracker::instance(); - llinfos << "Merov : LLFacebookConnect::showFacebookFriends" << llendl; - - for (LLSD::map_const_iterator i = friends.beginMap(); i != friends.endMap(); ++i) - { - std::string name = i->second["name"].asString(); - LLUUID agent_id = i->second.has("agent_id") ? i->second["agent_id"].asUUID() : LLUUID(NULL); - - //add to avatar list - //mFacebookFriends->addNewItem(agent_id, name, false); - - //FB+SL but not SL friend - bool is_SL_friend = false; - if(agent_id.notNull() && !avatar_tracker.isBuddy(agent_id)) - { - //tab_type = LLPersonTabModel::FB_SL_NON_SL_FRIEND; - is_SL_friend = true; - } - //FB only friend - else - { - //tab_type = LLPersonTabModel::FB_ONLY_FRIEND; - is_SL_friend = false; - } - llinfos << "Merov : LLFacebookConnect : agent_id = " << agent_id << ", name = " << name << ", SL friend = " << is_SL_friend << llendl; - - //Add to person tab model - /* - LLPersonTabModel * person_tab_model = dynamic_cast(mPersonFolderView->getPersonTabModelByIndex(tab_type)); - if(person_tab_model) - { - addParticipantToModel(person_tab_model, agent_id, name); - } - */ - } + const bool follow_redirects=false; + const F32 timeout=HTTP_REQUEST_EXPIRY_SECS; + LLHTTPClient::get(getFacebookConnectURL("/friend"), new LLFacebookFriendsResponder(), + LLSD(), timeout, follow_redirects); +} + +void LLFacebookConnect::storeContent(const LLSD& content) +{ + mGeneration++; + mContent = content; +} + +const LLSD& LLFacebookConnect::getContent() const +{ + return mContent; +} + +void LLFacebookConnect::clearContent() +{ + mGeneration++; + mContent = LLSD(); } -- cgit v1.2.3 From dbef09a2bb629cf6001a3963f6899bcac53b7774 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 13 May 2013 18:29:28 -0700 Subject: ACME-344 : Menu hooked up. Readded the missing completedHeader() methods in responder that I mistakenly took out during the refactor. --- indra/newview/llfacebookconnect.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 7f8e3afe89..39aa82dc7a 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -31,12 +31,13 @@ #include "llagent.h" #include "llcallingcard.h" // for LLAvatarTracker -//#include "llcommandhandler.h" +#include "llcommandhandler.h" #include "llhttpclient.h" +#include "llurlaction.h" /////////////////////////////////////////////////////////////////////////////// // -/* + class LLFacebookConnectHandler : public LLCommandHandler { public: @@ -59,7 +60,6 @@ public: } }; LLFacebookConnectHandler gFacebookConnectHandler; -*/ /////////////////////////////////////////////////////////////////////////////// // @@ -83,6 +83,15 @@ public: LL_WARNS("FacebookConnect") << "Failed to get a response. reason: " << reason << " status: " << status << LL_ENDL; } } + + void completedHeader(U32 status, const std::string& reason, const LLSD& content) + { + if (status == 302) + { + LLFacebookConnect::instance().openFacebookWeb(content["location"]); + } + } + }; /////////////////////////////////////////////////////////////////////////////// @@ -163,6 +172,14 @@ public: LL_WARNS("FacebookConnect") << "Failed to get a response. reason: " << reason << " status: " << status << LL_ENDL; } } + + void completedHeader(U32 status, const std::string& reason, const LLSD& content) + { + if (status == 302) + { + LLFacebookConnect::instance().openFacebookWeb(content["location"]); + } + } }; @@ -175,6 +192,11 @@ LLFacebookConnect::LLFacebookConnect() { } +void LLFacebookConnect::openFacebookWeb(std::string url) +{ + LLUrlAction::openURLExternal(url); +} + std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) { //static std::string sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect"); -- cgit v1.2.3 From 53ed2e4ac67088dce27f4c391d3e980e2d63154b Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 20 May 2013 19:32:55 -0700 Subject: ACME-381 : Implement experimental checkin feature (used to test publish_actions permissions workflow) --- indra/newview/llfacebookconnect.cpp | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 39aa82dc7a..eb70cf4d10 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -94,6 +94,35 @@ public: }; +/////////////////////////////////////////////////////////////////////////////// +// +class LLFacebookPostResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLFacebookPostResponder); +public: + + virtual void completed(U32 status, const std::string& reason, const LLSD& content) + { + if (isGoodStatus(status)) + { + LL_DEBUGS("FacebookConnect") << "Post successful. content: " << content << LL_ENDL; + } + else + { + LL_WARNS("FacebookConnect") << "Failed to get a post response. reason: " << reason << " status: " << status << LL_ENDL; + } + } + + void completedHeader(U32 status, const std::string& reason, const LLSD& content) + { + if (status == 302) + { + LLFacebookConnect::instance().openFacebookWeb(content["location"]); + } + } + +}; + /////////////////////////////////////////////////////////////////////////////// // class LLFacebookDisconnectResponder : public LLHTTPClient::Responder @@ -247,6 +276,20 @@ void LLFacebookConnect::loadFacebookFriends() LLSD(), timeout, follow_redirects); } +void LLFacebookConnect::postCheckinMessage(const std::string& message, const std::string& url) +{ + // Note: We need to improve the API support to provide all the relevant data if possible + // Full set described : http://facebook-python-library.docs-library.appspot.com/facebook-python/library-manual.html + LLSD body; + if (!message.empty()) + body["message"] = message; + if (!url.empty()) + body["link"] = url; + + // Note: we can use that route for different publish action. We should be able to use the same responder. + LLHTTPClient::post(getFacebookConnectURL("/share"), body, new LLFacebookPostResponder()); +} + void LLFacebookConnect::storeContent(const LLSD& content) { mGeneration++; -- cgit v1.2.3 From ff291257886badc495d04d59f78cfc9858964702 Mon Sep 17 00:00:00 2001 From: Cho Date: Wed, 29 May 2013 01:31:48 +0100 Subject: updated postCheckinMessage to use new parameters and new route path --- indra/newview/llfacebookconnect.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index eb70cf4d10..86da748f0f 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -276,18 +276,24 @@ void LLFacebookConnect::loadFacebookFriends() LLSD(), timeout, follow_redirects); } -void LLFacebookConnect::postCheckinMessage(const std::string& message, const std::string& url) +void LLFacebookConnect::postCheckinMessage(const std::string& message, const std::string& link, const std::string& name, const std::string& caption, const std::string& description, const std::string& picture) { - // Note: We need to improve the API support to provide all the relevant data if possible - // Full set described : http://facebook-python-library.docs-library.appspot.com/facebook-python/library-manual.html - LLSD body; + LLSD body; if (!message.empty()) body["message"] = message; - if (!url.empty()) - body["link"] = url; + if (!link.empty()) + body["link"] = link; + if (!name.empty()) + body["name"] = name; + if (!caption.empty()) + body["caption"] = caption; + if (!description.empty()) + body["description"] = description; + if (!picture.empty()) + body["picture"] = picture; // Note: we can use that route for different publish action. We should be able to use the same responder. - LLHTTPClient::post(getFacebookConnectURL("/share"), body, new LLFacebookPostResponder()); + LLHTTPClient::post(getFacebookConnectURL("/share/wall"), body, new LLFacebookPostResponder()); } void LLFacebookConnect::storeContent(const LLSD& content) -- cgit v1.2.3 From bbac06deb72e036b60a73bfb0e50d8f6a6a0fe86 Mon Sep 17 00:00:00 2001 From: Cho Date: Sat, 1 Jun 2013 01:55:40 +0100 Subject: added LLFacebookConnect::sharePhoto() for ACME-467 --- indra/newview/llfacebookconnect.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 86da748f0f..5013a5cb40 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -211,7 +211,6 @@ public: } }; - /////////////////////////////////////////////////////////////////////////////// // LLFacebookConnect::LLFacebookConnect() @@ -296,6 +295,16 @@ void LLFacebookConnect::postCheckinMessage(const std::string& message, const std LLHTTPClient::post(getFacebookConnectURL("/share/wall"), body, new LLFacebookPostResponder()); } +void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::string& caption) +{ + LLSD body; + body["image"] = image_url; + body["caption"] = caption; + + // Note: we can use that route for different publish action. We should be able to use the same responder. + LLHTTPClient::post(getFacebookConnectURL("/share/photo"), body, new LLFacebookPostResponder()); +} + void LLFacebookConnect::storeContent(const LLSD& content) { mGeneration++; -- cgit v1.2.3 From abcb3e85628712da4d61fda6e68bb86a29e1f965 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Tue, 4 Jun 2013 18:39:41 -0700 Subject: ACME-471: Once connected to facebook, a user can use the 'Check in to Facebook' button under the 'Me' menu to make a check in post to Facebook --- indra/newview/llfacebookconnect.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 5013a5cb40..668ba04406 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -275,6 +275,24 @@ void LLFacebookConnect::loadFacebookFriends() LLSD(), timeout, follow_redirects); } +void LLFacebookConnect::postCheckin(const std::string& location, const std::string& name, const std::string& description, const std::string& image, const std::string& message) +{ + 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"), body, new LLFacebookPostResponder()); +} + void LLFacebookConnect::postCheckinMessage(const std::string& message, const std::string& link, const std::string& name, const std::string& caption, const std::string& description, const std::string& picture) { LLSD body; -- cgit v1.2.3 From 54e879cc22ec342f57cec23d38ba269b83489111 Mon Sep 17 00:00:00 2001 From: Cho Date: Sat, 8 Jun 2013 00:48:46 +0100 Subject: added Facebook status update feature for ACME-502, ACME-503, and ACME-504 --- indra/newview/llfacebookconnect.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 668ba04406..79e8d98668 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -323,6 +323,15 @@ void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::stri LLHTTPClient::post(getFacebookConnectURL("/share/photo"), body, new LLFacebookPostResponder()); } +void LLFacebookConnect::updateStatus(const std::string& message) +{ + LLSD body; + 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/wall"), body, new LLFacebookPostResponder()); +} + void LLFacebookConnect::storeContent(const LLSD& content) { mGeneration++; -- cgit v1.2.3 From 2b138990f8531df51f38e5e15309e1c92483dd05 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 7 Jun 2013 18:05:14 -0700 Subject: ACME-508 : Surface facebook connection errors in a modal notification dialog --- indra/newview/llfacebookconnect.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 668ba04406..4c9de17e2e 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -33,6 +33,7 @@ #include "llcallingcard.h" // for LLAvatarTracker #include "llcommandhandler.h" #include "llhttpclient.h" +#include "llnotificationsutil.h" #include "llurlaction.h" /////////////////////////////////////////////////////////////////////////////// @@ -80,6 +81,11 @@ public: } else { + LLSD args(LLSD::emptyMap()); + std::stringstream msg; + msg << reason << " (Code " << status << ")"; + args["FAIL_REASON"] = msg.str(); + LLNotificationsUtil::add("FacebookCannotConnect",args); LL_WARNS("FacebookConnect") << "Failed to get a response. reason: " << reason << " status: " << status << LL_ENDL; } } @@ -109,6 +115,11 @@ public: } else { + LLSD args(LLSD::emptyMap()); + std::stringstream msg; + msg << reason << " (Code " << status << ")"; + args["FAIL_REASON"] = msg.str(); + LLNotificationsUtil::add("FacebookCannotConnect",args); LL_WARNS("FacebookConnect") << "Failed to get a post response. reason: " << reason << " status: " << status << LL_ENDL; } } @@ -142,6 +153,11 @@ public: } else { + LLSD args(LLSD::emptyMap()); + std::stringstream msg; + msg << reason << " (Code " << status << ")"; + args["FAIL_REASON"] = msg.str(); + LLNotificationsUtil::add("FacebookCannotConnect",args); LL_WARNS("FacebookConnect") << "Failed to get a response. reason: " << reason << " status: " << status << LL_ENDL; } } @@ -175,6 +191,14 @@ public: { LLFacebookConnect::instance().connectToFacebook(); } + else + { + LLSD args(LLSD::emptyMap()); + std::stringstream msg; + msg << reason << " (Code " << status << ")"; + args["FAIL_REASON"] = msg.str(); + LLNotificationsUtil::add("FacebookCannotConnect",args); + } } } @@ -198,6 +222,11 @@ public: } else { + LLSD args(LLSD::emptyMap()); + std::stringstream msg; + msg << reason << " (Code " << status << ")"; + args["FAIL_REASON"] = msg.str(); + LLNotificationsUtil::add("FacebookCannotConnect",args); LL_WARNS("FacebookConnect") << "Failed to get a response. reason: " << reason << " status: " << status << LL_ENDL; } } -- cgit v1.2.3 From e3f093a87157c012ab4e9d378cc26876b7b91900 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 10 Jun 2013 16:01:41 -0700 Subject: ACME-464, ACME-509 : Skip 302 error when prompting the user for errors --- indra/newview/llfacebookconnect.cpp | 49 +++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 27 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 1986814815..348e2c2e90 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -36,6 +36,21 @@ #include "llnotificationsutil.h" #include "llurlaction.h" + +// Local function +void prompt_user_for_error(U32 status, const std::string& reason) +{ + // Note: 302 (redirect) is *not* an error that warrants prompting the user + if (status != 302) + { + LLSD args(LLSD::emptyMap()); + std::stringstream msg; + msg << reason << " (Code " << status << ")"; + args["FAIL_REASON"] = msg.str(); + LLNotificationsUtil::add("FacebookCannotConnect",args); + } +} + /////////////////////////////////////////////////////////////////////////////// // @@ -81,12 +96,8 @@ public: } else { - LLSD args(LLSD::emptyMap()); - std::stringstream msg; - msg << reason << " (Code " << status << ")"; - args["FAIL_REASON"] = msg.str(); - LLNotificationsUtil::add("FacebookCannotConnect",args); - LL_WARNS("FacebookConnect") << "Failed to get a response. reason: " << reason << " status: " << status << LL_ENDL; + prompt_user_for_error(status,reason); + LL_WARNS("FacebookConnect") << "Failed to get a response. reason: " << reason << " status: " << status << LL_ENDL; } } @@ -115,12 +126,8 @@ public: } else { - LLSD args(LLSD::emptyMap()); - std::stringstream msg; - msg << reason << " (Code " << status << ")"; - args["FAIL_REASON"] = msg.str(); - LLNotificationsUtil::add("FacebookCannotConnect",args); - LL_WARNS("FacebookConnect") << "Failed to get a post response. reason: " << reason << " status: " << status << LL_ENDL; + prompt_user_for_error(status,reason); + LL_WARNS("FacebookConnect") << "Failed to get a post response. reason: " << reason << " status: " << status << LL_ENDL; } } @@ -153,11 +160,7 @@ public: } else { - LLSD args(LLSD::emptyMap()); - std::stringstream msg; - msg << reason << " (Code " << status << ")"; - args["FAIL_REASON"] = msg.str(); - LLNotificationsUtil::add("FacebookCannotConnect",args); + prompt_user_for_error(status,reason); LL_WARNS("FacebookConnect") << "Failed to get a response. reason: " << reason << " status: " << status << LL_ENDL; } } @@ -193,11 +196,7 @@ public: } else { - LLSD args(LLSD::emptyMap()); - std::stringstream msg; - msg << reason << " (Code " << status << ")"; - args["FAIL_REASON"] = msg.str(); - LLNotificationsUtil::add("FacebookCannotConnect",args); + prompt_user_for_error(status,reason); } } } @@ -222,11 +221,7 @@ public: } else { - LLSD args(LLSD::emptyMap()); - std::stringstream msg; - msg << reason << " (Code " << status << ")"; - args["FAIL_REASON"] = msg.str(); - LLNotificationsUtil::add("FacebookCannotConnect",args); + prompt_user_for_error(status,reason); LL_WARNS("FacebookConnect") << "Failed to get a response. reason: " << reason << " status: " << status << LL_ENDL; } } -- cgit v1.2.3 From 933debfc10d09d1d25fd196597904fc9753b4cb0 Mon Sep 17 00:00:00 2001 From: Cho Date: Wed, 12 Jun 2013 01:16:27 +0100 Subject: cleaned up FBC snapshot feature and made it work with new direct upload route on FBC API --- indra/newview/llfacebookconnect.cpp | 107 ++++++++++++++++++++++++------------ 1 file changed, 73 insertions(+), 34 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 348e2c2e90..b0b773d508 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -35,19 +35,23 @@ #include "llhttpclient.h" #include "llnotificationsutil.h" #include "llurlaction.h" +#include "llimagepng.h" // Local function -void prompt_user_for_error(U32 status, const std::string& reason) +void prompt_user_for_error(U32 status, const std::string& reason, const std::string& code, const std::string& description) { // Note: 302 (redirect) is *not* an error that warrants prompting the user if (status != 302) { LLSD args(LLSD::emptyMap()); std::stringstream msg; - msg << reason << " (Code " << status << ")"; - args["FAIL_REASON"] = msg.str(); - LLNotificationsUtil::add("FacebookCannotConnect",args); + msg << status; + args["STATUS"] = msg.str(); + args["REASON"] = reason; + args["CODE"] = code; + args["DESCRIPTION"] = description; + LLNotificationsUtil::add("FacebookCannotConnect", args); } } @@ -96,7 +100,7 @@ public: } else { - prompt_user_for_error(status,reason); + 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; } } @@ -113,11 +117,14 @@ public: /////////////////////////////////////////////////////////////////////////////// // -class LLFacebookPostResponder : public LLHTTPClient::Responder +class LLFacebookShareResponder : public LLHTTPClient::Responder { - LOG_CLASS(LLFacebookPostResponder); + LOG_CLASS(LLFacebookShareResponder); public: + LLFacebookShareResponder() {} + LLFacebookShareResponder(LLFacebookConnect::share_callback_t cb) : mShareCallback(cb) {} + virtual void completed(U32 status, const std::string& reason, const LLSD& content) { if (isGoodStatus(status)) @@ -126,9 +133,14 @@ public: } else { - prompt_user_for_error(status,reason); + prompt_user_for_error(status, reason, content.get("error_code"), content.get("error_description")); LL_WARNS("FacebookConnect") << "Failed to get a post response. reason: " << reason << " status: " << status << LL_ENDL; } + + if (mShareCallback) + { + mShareCallback(isGoodStatus(status)); + } } void completedHeader(U32 status, const std::string& reason, const LLSD& content) @@ -139,6 +151,8 @@ public: } } +private: + LLFacebookConnect::share_callback_t mShareCallback; }; /////////////////////////////////////////////////////////////////////////////// @@ -160,7 +174,7 @@ public: } else { - prompt_user_for_error(status,reason); + 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; } } @@ -196,7 +210,7 @@ public: } else { - prompt_user_for_error(status,reason); + prompt_user_for_error(status, reason, content.get("error_code"), content.get("error_description")); } } } @@ -221,7 +235,7 @@ public: } else { - prompt_user_for_error(status,reason); + 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; } } @@ -314,27 +328,7 @@ void LLFacebookConnect::postCheckin(const std::string& location, const std::stri 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"), body, new LLFacebookPostResponder()); -} - -void LLFacebookConnect::postCheckinMessage(const std::string& message, const std::string& link, const std::string& name, const std::string& caption, const std::string& description, const std::string& picture) -{ - LLSD body; - if (!message.empty()) - body["message"] = message; - if (!link.empty()) - body["link"] = link; - if (!name.empty()) - body["name"] = name; - if (!caption.empty()) - body["caption"] = caption; - if (!description.empty()) - body["description"] = description; - if (!picture.empty()) - body["picture"] = picture; - - // Note: we can use that route for different publish action. We should be able to use the same responder. - LLHTTPClient::post(getFacebookConnectURL("/share/wall"), body, new LLFacebookPostResponder()); + LLHTTPClient::post(getFacebookConnectURL("/share/checkin"), body, new LLFacebookShareResponder(mPostCheckinCallback)); } void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::string& caption) @@ -344,7 +338,52 @@ void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::stri body["caption"] = caption; // Note: we can use that route for different publish action. We should be able to use the same responder. - LLHTTPClient::post(getFacebookConnectURL("/share/photo"), body, new LLFacebookPostResponder()); + LLHTTPClient::post(getFacebookConnectURL("/share/photo"), body, new LLFacebookShareResponder()); +} + +void LLFacebookConnect::sharePhoto(LLPointer image, const std::string& caption) +{ + // All this code is mostly copied from LLWebProfile::post() + if (dynamic_cast(image.get()) == 0) + { + llwarns << "Image to upload is not a PNG" << llendl; + llassert(dynamic_cast(image.get()) != 0); + return; + } + + const std::string boundary = "----------------------------0123abcdefab"; + + LLSD headers; + headers["Content-Type"] = "multipart/form-data; boundary=" + boundary; + + std::ostringstream body; + + // *NOTE: The order seems to matter. + body << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"caption\"\r\n\r\n" + << caption << "\r\n"; + + body << "--" << boundary << "\r\n" + << "Content-Disposition: form-data; name=\"image\"; filename=\"snapshot.png\"\r\n" + << "Content-Type: image/png\r\n\r\n"; + + // Insert the image data. + // *FIX: Treating this as a string will probably screw it up ... + U8* image_data = image->getData(); + for (S32 i = 0; i < image->getDataSize(); ++i) + { + body << image_data[i]; + } + + body << "\r\n--" << boundary << "--\r\n"; + + // postRaw() takes ownership of the buffer and releases it later. + size_t size = body.str().size(); + U8 *data = new U8[size]; + memcpy(data, body.str().data(), size); + + // Note: we can use that route for different publish action. We should be able to use the same responder. + LLHTTPClient::postRaw(getFacebookConnectURL("/share/photo"), data, size, new LLFacebookShareResponder(mSharePhotoCallback), headers); } void LLFacebookConnect::updateStatus(const std::string& message) @@ -353,7 +392,7 @@ void LLFacebookConnect::updateStatus(const std::string& message) 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/wall"), body, new LLFacebookPostResponder()); + LLHTTPClient::post(getFacebookConnectURL("/share/wall"), body, new LLFacebookShareResponder(mUpdateStatusCallback)); } void LLFacebookConnect::storeContent(const LLSD& content) -- cgit v1.2.3 From f5fb235aac7bb437416d5c665ff43ed5685a6755 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Thu, 13 Jun 2013 16:57:04 -0700 Subject: ACME-537: Prevented error code for showing up when disconnected from FB and opening the 'Friends' tab of the people panel. --- indra/newview/llfacebookconnect.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index b0b773d508..3de2351d78 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -187,7 +187,10 @@ class LLFacebookConnectedResponder : public LLHTTPClient::Responder LOG_CLASS(LLFacebookConnectedResponder); public: - LLFacebookConnectedResponder(bool show_login_if_not_connected) : mShowLoginIfNotConnected(show_login_if_not_connected) {} + 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) + {} virtual void completed(U32 status, const std::string& reason, const LLSD& content) { @@ -208,7 +211,7 @@ public: { LLFacebookConnect::instance().connectToFacebook(); } - else + else if(mShowErrorIfNotConnected) { prompt_user_for_error(status, reason, content.get("error_code"), content.get("error_description")); } @@ -217,6 +220,7 @@ public: private: bool mShowLoginIfNotConnected; + bool mShowErrorIfNotConnected; }; /////////////////////////////////////////////////////////////////////////////// @@ -292,7 +296,7 @@ void LLFacebookConnect::tryToReconnectToFacebook() { const bool follow_redirects=false; const F32 timeout=HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(false), + LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(false, false), LLSD(), timeout, follow_redirects); } } @@ -301,7 +305,7 @@ void LLFacebookConnect::getConnectionToFacebook() { const bool follow_redirects=false; const F32 timeout=HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(true), + LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(true, true), LLSD(), timeout, follow_redirects); } -- cgit v1.2.3 From 37dcc335321fb7a16b99fe4f159aa68ad8ec5d76 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Fri, 14 Jun 2013 16:07:03 -0700 Subject: ACME-558 Update LLPanelPeople to use the friends list callback and remove the timer dependencies --- indra/newview/llfacebookconnect.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 3de2351d78..6b9d753721 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -403,6 +403,11 @@ void LLFacebookConnect::storeContent(const LLSD& content) { mGeneration++; mContent = content; + + if(mContentUpdatedCallback) + { + mContentUpdatedCallback(); + } } const LLSD& LLFacebookConnect::getContent() const -- cgit v1.2.3 From 2eb466908e8056f9b890d06d449ad8d10d3ff4cf Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 14 Jun 2013 20:01:33 -0700 Subject: ACME-520 : Add more extended state in LLFacebookConnect and handle it consistently and transparently from the public interface --- indra/newview/llfacebookconnect.cpp | 51 +++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 28 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') 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() -- cgit v1.2.3 From efa555cc5c5fa0b3d25f37fd8782aff5874d3779 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Mon, 17 Jun 2013 14:59:03 -0700 Subject: ACME-558: Adding logging information, when a friends list is received the log message 'Facebook: Friends list received' will be displayed. When the suggested friends list is updated the log message 'Facebook: Updating Suggested Friends List' will be displayed. --- indra/newview/llfacebookconnect.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 6b9d753721..95c458ac04 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -234,6 +234,7 @@ public: { if (isGoodStatus(status)) { + llinfos << "Facebook: Friends list received" << llendl; LL_DEBUGS("FacebookConnect") << "Getting Facebook friends successful. content: " << content << LL_ENDL; LLFacebookConnect::instance().storeContent(content); } -- cgit v1.2.3 From d1d495870ac44ad0358f655357ff0583d60f263f Mon Sep 17 00:00:00 2001 From: Cho Date: Wed, 19 Jun 2013 01:36:23 +0100 Subject: updated viewer to use new /friends route for ACME-534 --- indra/newview/llfacebookconnect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 36a40790ec..64fc81cc93 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -309,7 +309,7 @@ void LLFacebookConnect::loadFacebookFriends() { const bool follow_redirects=false; const F32 timeout=HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/friend"), new LLFacebookFriendsResponder(), + LLHTTPClient::get(getFacebookConnectURL("/friends"), new LLFacebookFriendsResponder(), LLSD(), timeout, follow_redirects); } -- cgit v1.2.3 From 9f0646bcc0b24d9f3c13446399505eddc768a4ce Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 25 Jun 2013 12:43:37 -0700 Subject: ACME-580, ACME-572, ACME-591 : Added a toast notification when posting to Facebook successfully --- indra/newview/llfacebookconnect.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 64fc81cc93..fe4e7fe69e 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -36,9 +36,10 @@ #include "llnotificationsutil.h" #include "llurlaction.h" #include "llimagepng.h" +#include "lltrans.h" -// Local function +// Local functions void prompt_user_for_error(U32 status, const std::string& reason, const std::string& code, const std::string& description) { // Note: 302 (redirect) is *not* an error that warrants prompting the user @@ -55,6 +56,13 @@ void prompt_user_for_error(U32 status, const std::string& reason, const std::str } } +void toast_user_for_success() +{ + LLSD args; + args["MESSAGE"] = LLTrans::getString("facebook_post_success"); + LLNotificationsUtil::add("SystemMessage", args); +} + /////////////////////////////////////////////////////////////////////////////// // class LLFacebookConnectHandler : public LLCommandHandler @@ -133,6 +141,7 @@ public: { if (isGoodStatus(status)) { + toast_user_for_success(); LL_DEBUGS("FacebookConnect") << "Post successful. content: " << content << LL_ENDL; } else -- cgit v1.2.3 From 26832818780ffe5052443db3c6bbfca15575a5b5 Mon Sep 17 00:00:00 2001 From: Cho Date: Thu, 27 Jun 2013 19:34:39 +0100 Subject: changed FBC photo sharing to use JPEG instead of PNG for ACME-636 --- indra/newview/llfacebookconnect.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index fe4e7fe69e..cf0f554149 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -36,6 +36,7 @@ #include "llnotificationsutil.h" #include "llurlaction.h" #include "llimagepng.h" +#include "llimagejpeg.h" #include "lltrans.h" @@ -352,14 +353,22 @@ void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::stri void LLFacebookConnect::sharePhoto(LLPointer image, const std::string& caption) { - // All this code is mostly copied from LLWebProfile::post() - if (dynamic_cast(image.get()) == 0) + std::string imageFormat; + if (dynamic_cast(image.get())) + { + imageFormat = "png"; + } + else if (dynamic_cast(image.get())) + { + imageFormat = "jpg"; + } + else { - llwarns << "Image to upload is not a PNG" << llendl; - llassert(dynamic_cast(image.get()) != 0); + llwarns << "Image to upload is not a PNG or JPEG" << llendl; return; } - + + // All this code is mostly copied from LLWebProfile::post() const std::string boundary = "----------------------------0123abcdefab"; LLSD headers; @@ -373,8 +382,8 @@ void LLFacebookConnect::sharePhoto(LLPointer image, const std: << caption << "\r\n"; body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"image\"; filename=\"snapshot.png\"\r\n" - << "Content-Type: image/png\r\n\r\n"; + << "Content-Disposition: form-data; name=\"image\"; filename=\"snapshot." << imageFormat << "\"\r\n" + << "Content-Type: image/" << imageFormat << "\r\n\r\n"; // Insert the image data. // *FIX: Treating this as a string will probably screw it up ... -- cgit v1.2.3 From 0e50cbc2edacdecf32071c97c2ce5349db5ef5e9 Mon Sep 17 00:00:00 2001 From: Cho Date: Fri, 28 Jun 2013 01:21:14 +0100 Subject: made it optional to autoconnect in LLFacebookConnect::getConnectionToFacebook() for ACME-648 --- indra/newview/llfacebookconnect.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index cf0f554149..52268daa36 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -201,9 +201,9 @@ class LLFacebookConnectedResponder : public LLHTTPClient::Responder LOG_CLASS(LLFacebookConnectedResponder); public: - LLFacebookConnectedResponder() + LLFacebookConnectedResponder(bool auto_connect) : mAutoConnect(auto_connect) { - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); } virtual void completed(U32 status, const std::string& reason, const LLSD& content) @@ -223,7 +223,14 @@ public: // show the facebook login page if not connected yet if (status == 404) { - LLFacebookConnect::instance().connectToFacebook(); + if (mAutoConnect) + { + LLFacebookConnect::instance().connectToFacebook(); + } + else + { + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED); + } } else { @@ -234,6 +241,7 @@ public: } private: + bool mAutoConnect; }; /////////////////////////////////////////////////////////////////////////////// @@ -304,13 +312,13 @@ void LLFacebookConnect::disconnectFromFacebook() LLHTTPClient::del(getFacebookConnectURL("/connection"), new LLFacebookDisconnectResponder()); } -void LLFacebookConnect::getConnectionToFacebook() +void LLFacebookConnect::getConnectionToFacebook(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(), + LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(auto_connect), LLSD(), timeout, follow_redirects); } } -- cgit v1.2.3 From 89ae19e57edc9abfd300b17caf2719d7794dabf9 Mon Sep 17 00:00:00 2001 From: Cho Date: Fri, 28 Jun 2013 20:19:17 +0100 Subject: removed old error popups and added better logging for ACME-653 --- indra/newview/llfacebookconnect.cpp | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 52268daa36..dc450aab7a 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -41,19 +41,12 @@ // Local functions -void prompt_user_for_error(U32 status, const std::string& reason, const std::string& code, const std::string& description) +void log_facebook_connect_error(const std::string& request, U32 status, const std::string& reason, const std::string& code, const std::string& description) { - // Note: 302 (redirect) is *not* an error that warrants prompting the user + // Note: 302 (redirect) is *not* an error that warrants logging if (status != 302) { - LLSD args(LLSD::emptyMap()); - std::stringstream msg; - msg << status; - args["STATUS"] = msg.str(); - args["REASON"] = reason; - args["CODE"] = code; - args["DESCRIPTION"] = description; - LLNotificationsUtil::add("FacebookCannotConnect", args); + LL_WARNS("FacebookConnect") << request << " request failed with a " << status << " " << reason << ". Reason: " << code << "(" << description << ")" << LL_ENDL; } } @@ -113,8 +106,7 @@ public: 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; + log_facebook_connect_error("Connect", status, reason, content.get("error_code"), content.get("error_description")); } } @@ -147,8 +139,7 @@ public: } else { - prompt_user_for_error(status, reason, content.get("error_code"), content.get("error_description")); - LL_WARNS("FacebookConnect") << "Failed to get a post response. reason: " << reason << " status: " << status << LL_ENDL; + log_facebook_connect_error("Share", status, reason, content.get("error_code"), content.get("error_description")); } if (mShareCallback) @@ -188,8 +179,7 @@ public: } else { - 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; + log_facebook_connect_error("Disconnect", status, reason, content.get("error_code"), content.get("error_description")); } } }; @@ -218,8 +208,6 @@ public: } else { - 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) { @@ -235,7 +223,7 @@ public: else { LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_FAILED); - prompt_user_for_error(status, reason, content.get("error_code"), content.get("error_description")); + log_facebook_connect_error("Connected", status, reason, content.get("error_code"), content.get("error_description")); } } } @@ -261,8 +249,7 @@ public: } else { - 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; + log_facebook_connect_error("Friends", status, reason, content.get("error_code"), content.get("error_description")); } } -- cgit v1.2.3 From fa1e0e486a2c32911e6bfe9d72264c3d9ebe1d9f Mon Sep 17 00:00:00 2001 From: Cho Date: Mon, 1 Jul 2013 23:27:52 +0100 Subject: Removed image URL callback from LLWebProfile for ACME-657 --- indra/newview/llfacebookconnect.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index dc450aab7a..24100a9a55 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -101,7 +101,6 @@ public: // Grab some graph data now that we are connected LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED); - LLFacebookConnect::instance().loadFacebookFriends(); } else { @@ -204,7 +203,6 @@ public: // Grab some graph data if already connected LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED); - LLFacebookConnect::instance().loadFacebookFriends(); } else { -- cgit v1.2.3 From 1449e645c61f3b31568e38e3c4daf531189323c6 Mon Sep 17 00:00:00 2001 From: Cho Date: Tue, 2 Jul 2013 01:21:38 +0100 Subject: added callback to LLFacebookConnect upon connect for ACME-659 --- indra/newview/llfacebookconnect.cpp | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 24100a9a55..5d6c496275 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -88,7 +88,13 @@ class LLFacebookConnectResponder : public LLHTTPClient::Responder { LOG_CLASS(LLFacebookConnectResponder); public: + LLFacebookConnectResponder() + { + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); + } + + LLFacebookConnectResponder(LLFacebookConnect::connect_callback_t cb) : mConnectCallback(cb) { LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); } @@ -101,6 +107,11 @@ public: // Grab some graph data now that we are connected LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED); + + if (mConnectCallback) + { + mConnectCallback(); + } } else { @@ -117,6 +128,8 @@ public: } } +private: + LLFacebookConnect::connect_callback_t mConnectCallback; }; /////////////////////////////////////////////////////////////////////////////// @@ -195,14 +208,23 @@ 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)) { LL_DEBUGS("FacebookConnect") << "Connect successful. content: " << content << LL_ENDL; - // Grab some graph data if already connected LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED); + + if (mConnectCallback) + { + mConnectCallback(); + } } else { @@ -228,6 +250,7 @@ public: private: bool mAutoConnect; + LLFacebookConnect::connect_callback_t mConnectCallback; }; /////////////////////////////////////////////////////////////////////////////// @@ -283,13 +306,13 @@ std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) return url; } -void LLFacebookConnect::connectToFacebook(const std::string& auth_code) +void LLFacebookConnect::connectToFacebook(const std::string& auth_code, connect_callback_t cb) { LLSD body; if (!auth_code.empty()) body["code"] = auth_code; - LLHTTPClient::put(getFacebookConnectURL("/connection"), body, new LLFacebookConnectResponder()); + LLHTTPClient::put(getFacebookConnectURL("/connection"), body, new LLFacebookConnectResponder(cb)); } void LLFacebookConnect::disconnectFromFacebook() @@ -297,13 +320,13 @@ void LLFacebookConnect::disconnectFromFacebook() LLHTTPClient::del(getFacebookConnectURL("/connection"), new LLFacebookDisconnectResponder()); } -void LLFacebookConnect::getConnectionToFacebook(bool auto_connect) +void LLFacebookConnect::getConnectionToFacebook(bool auto_connect, connect_callback_t cb) { if ((mConnectionState == FB_NOT_CONNECTED) || (mConnectionState == FB_CONNECTION_FAILED)) { - const bool follow_redirects=false; + const bool follow_redirects = false; const F32 timeout=HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(auto_connect), + LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(auto_connect, cb), LLSD(), timeout, follow_redirects); } } -- cgit v1.2.3 From 853ad9d70ddcf0cdd354672a5c7baa858de1bb22 Mon Sep 17 00:00:00 2001 From: Cho Date: Wed, 3 Jul 2013 00:35:10 +0100 Subject: Implemented events for LLFacebookConnect state changes for ACME-662 --- indra/newview/llfacebookconnect.cpp | 53 +++++++++++++++---------------------- 1 file changed, 22 insertions(+), 31 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') 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 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) @@ -90,11 +92,6 @@ class LLFacebookConnectResponder : public LLHTTPClient::Responder public: LLFacebookConnectResponder() - { - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); - } - - LLFacebookConnectResponder(LLFacebookConnect::connect_callback_t cb) : mConnectCallback(cb) { LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_IN_PROGRESS); } @@ -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; +} + + -- cgit v1.2.3 From b070533bdaa78fb2d94ec49a2ea3d9a9ada3d437 Mon Sep 17 00:00:00 2001 From: Cho Date: Wed, 3 Jul 2013 01:38:30 +0100 Subject: added FB_POSTING and PB_POST_FAILED states to LLFacebookConnect for ACME-663 --- indra/newview/llfacebookconnect.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 8a86ff6377..30fb63084b 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -128,8 +128,15 @@ class LLFacebookShareResponder : public LLHTTPClient::Responder LOG_CLASS(LLFacebookShareResponder); public: - LLFacebookShareResponder() {} - LLFacebookShareResponder(LLFacebookConnect::share_callback_t cb) : mShareCallback(cb) {} + LLFacebookShareResponder() + { + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POSTING); + } + + LLFacebookShareResponder(LLFacebookConnect::share_callback_t cb) : mShareCallback(cb) + { + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POSTING); + } virtual void completed(U32 status, const std::string& reason, const LLSD& content) { @@ -137,9 +144,12 @@ public: { toast_user_for_success(); LL_DEBUGS("FacebookConnect") << "Post successful. content: " << content << LL_ENDL; + + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED); } else { + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POST_FAILED); log_facebook_connect_error("Share", status, reason, content.get("error_code"), content.get("error_description")); } @@ -300,7 +310,7 @@ void LLFacebookConnect::disconnectFromFacebook() void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect) { - if ((mConnectionState == FB_NOT_CONNECTED) || (mConnectionState == FB_CONNECTION_FAILED)) + if ((mConnectionState == FB_NOT_CONNECTED) || (mConnectionState == FB_CONNECTION_FAILED) || (mConnectionState == FB_POST_FAILED)) { const bool follow_redirects = false; const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; -- cgit v1.2.3 From ad8aeecb8331ca68eef9a12536c80a4658885ccb Mon Sep 17 00:00:00 2001 From: Cho Date: Thu, 4 Jul 2013 01:29:54 +0100 Subject: Added auto-connect upon 404 from a POST in LLFacebookConnect, and added FB_POSTED state, for ACME-667 --- indra/newview/llfacebookconnect.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 30fb63084b..07204531de 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -145,7 +145,11 @@ public: toast_user_for_success(); LL_DEBUGS("FacebookConnect") << "Post successful. content: " << content << LL_ENDL; - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED); + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POSTED); + } + else if (status == 404) + { + LLFacebookConnect::instance().connectToFacebook(); } else { -- cgit v1.2.3 From 85824ebc0931d4ac89e375b35dbccd1295746e31 Mon Sep 17 00:00:00 2001 From: Cho Date: Thu, 4 Jul 2013 02:13:47 +0100 Subject: Removed share callbacks from LLFacebookConnect --- indra/newview/llfacebookconnect.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 07204531de..816947827c 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -133,11 +133,6 @@ public: LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POSTING); } - LLFacebookShareResponder(LLFacebookConnect::share_callback_t cb) : mShareCallback(cb) - { - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POSTING); - } - virtual void completed(U32 status, const std::string& reason, const LLSD& content) { if (isGoodStatus(status)) @@ -156,11 +151,6 @@ public: LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_POST_FAILED); log_facebook_connect_error("Share", status, reason, content.get("error_code"), content.get("error_description")); } - - if (mShareCallback) - { - mShareCallback(isGoodStatus(status)); - } } void completedHeader(U32 status, const std::string& reason, const LLSD& content) @@ -170,9 +160,6 @@ public: LLFacebookConnect::instance().openFacebookWeb(content["location"]); } } - -private: - LLFacebookConnect::share_callback_t mShareCallback; }; /////////////////////////////////////////////////////////////////////////////// @@ -346,7 +333,7 @@ void LLFacebookConnect::postCheckin(const std::string& location, const std::stri 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"), body, new LLFacebookShareResponder(mPostCheckinCallback)); + LLHTTPClient::post(getFacebookConnectURL("/share/checkin"), body, new LLFacebookShareResponder()); } void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::string& caption) @@ -409,7 +396,7 @@ void LLFacebookConnect::sharePhoto(LLPointer image, const std: memcpy(data, body.str().data(), size); // Note: we can use that route for different publish action. We should be able to use the same responder. - LLHTTPClient::postRaw(getFacebookConnectURL("/share/photo"), data, size, new LLFacebookShareResponder(mSharePhotoCallback), headers); + LLHTTPClient::postRaw(getFacebookConnectURL("/share/photo"), data, size, new LLFacebookShareResponder(), headers); } void LLFacebookConnect::updateStatus(const std::string& message) @@ -418,7 +405,7 @@ void LLFacebookConnect::updateStatus(const std::string& message) 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/wall"), body, new LLFacebookShareResponder(mUpdateStatusCallback)); + LLHTTPClient::post(getFacebookConnectURL("/share/wall"), body, new LLFacebookShareResponder()); } void LLFacebookConnect::storeContent(const LLSD& content) -- cgit v1.2.3 From f7a1f7b784fff0579e4d1fecd8265d0f960bd7f4 Mon Sep 17 00:00:00 2001 From: Cho Date: Thu, 4 Jul 2013 02:43:09 +0100 Subject: Replaced content change callback with an event in LLFacebookConnect for ACME-648 (more or less) --- indra/newview/llfacebookconnect.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 816947827c..30ebedca25 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -41,6 +41,7 @@ #include "llevents.h" boost::scoped_ptr LLFacebookConnect::sStateWatcher(new LLEventStream("FacebookConnectState")); +boost::scoped_ptr LLFacebookConnect::sContentWatcher(new LLEventStream("FacebookConnectContent")); // 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) @@ -413,10 +414,7 @@ void LLFacebookConnect::storeContent(const LLSD& content) mGeneration++; mContent = content; - if(mContentUpdatedCallback) - { - mContentUpdatedCallback(); - } + sContentWatcher->post(content); } const LLSD& LLFacebookConnect::getContent() const @@ -441,12 +439,3 @@ void LLFacebookConnect::setConnectionState(LLFacebookConnect::EConnectionState c mConnectionState = connection_state; } - - - - - - - - - -- cgit v1.2.3 From 36db132f236d4a3606b42a2a6af1b31c47892706 Mon Sep 17 00:00:00 2001 From: Cho Date: Fri, 12 Jul 2013 01:29:57 +0100 Subject: added state parameter to PUT /connection route for ACME-692 --- indra/newview/llfacebookconnect.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 30ebedca25..0d11658d07 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -75,7 +75,7 @@ public: { if (query_map.has("code")) { - LLFacebookConnect::instance().connectToFacebook(query_map["code"]); + LLFacebookConnect::instance().connectToFacebook(query_map["code"], query_map.get("state")); } return true; } @@ -286,11 +286,13 @@ std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) return url; } -void LLFacebookConnect::connectToFacebook(const std::string& auth_code) +void LLFacebookConnect::connectToFacebook(const std::string& auth_code, const std::string& auth_state) { 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()); } -- cgit v1.2.3 From fdea8c66de408a2054bbe86b1967cea11409c313 Mon Sep 17 00:00:00 2001 From: Cho Date: Tue, 16 Jul 2013 22:15:14 +0100 Subject: switched FB auth to in-viewer browser for ACME-733 --- indra/newview/llfacebookconnect.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 0d11658d07..cf77dd365b 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -40,6 +40,9 @@ #include "lltrans.h" #include "llevents.h" +#include "llfloaterwebcontent.h" +#include "llfloaterreg.h" + boost::scoped_ptr LLFacebookConnect::sStateWatcher(new LLEventStream("FacebookConnectState")); boost::scoped_ptr LLFacebookConnect::sContentWatcher(new LLEventStream("FacebookConnectContent")); @@ -274,7 +277,12 @@ LLFacebookConnect::LLFacebookConnect() void LLFacebookConnect::openFacebookWeb(std::string url) { - LLUrlAction::openURLExternal(url); + // Open the URL in an internal browser window without navigation UI + LLFloaterWebContent::Params p; + p.url(url).show_chrome(false); + LLFloaterReg::showInstance("web_content", p); + + //LLUrlAction::openURLExternal(url); } std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) -- cgit v1.2.3 From 3d6a98d845c871377a52fc924ce06329db34a776 Mon Sep 17 00:00:00 2001 From: Cho Date: Wed, 17 Jul 2013 02:59:40 +0100 Subject: created floater_fbc_web for ACME-734 and ACME-735 --- indra/newview/llfacebookconnect.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index cf77dd365b..ac92fc6ed5 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -52,7 +52,7 @@ void log_facebook_connect_error(const std::string& request, U32 status, const st // Note: 302 (redirect) is *not* an error that warrants logging if (status != 302) { - LL_WARNS("FacebookConnect") << request << " request failed with a " << status << " " << reason << ". Reason: " << code << "(" << description << ")" << LL_ENDL; + LL_WARNS("FacebookConnect") << request << " request failed with a " << status << " " << reason << ". Reason: " << code << " (" << description << ")" << LL_ENDL; } } @@ -76,10 +76,18 @@ public: { if (tokens[0].asString() == "connect") { + // connect to facebook if (query_map.has("code")) { LLFacebookConnect::instance().connectToFacebook(query_map["code"], query_map.get("state")); } + + // this command probably came from the fbc_web browser, so close it + LLFloater* fbc_web = LLFloaterReg::getInstance("fbc_web"); + if (fbc_web) + { + fbc_web->closeFloater(); + } return true; } } @@ -280,7 +288,7 @@ 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(false); - LLFloaterReg::showInstance("web_content", p); + LLFloaterReg::showInstance("fbc_web", p); //LLUrlAction::openURLExternal(url); } -- cgit v1.2.3 From 16709a9bef3ebf24c60eac29f7c5cb743e855da1 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 18 Jul 2013 21:05:41 -0700 Subject: ACME-734 : WIP : Implemented changes for https URL in the address bar and added options to web floater to hide history and disable buttons --- indra/newview/llfacebookconnect.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index ac92fc6ed5..eb9b93161c 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -287,7 +287,11 @@ 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(false); + p.url(url).show_chrome(true); + p.url(url).allow_address_entry(false); + p.url(url).allow_back_forward_navigation(false); + p.url(url).save_url_history(false); + p.url(url).trusted_content(true); LLFloaterReg::showInstance("fbc_web", p); //LLUrlAction::openURLExternal(url); -- cgit v1.2.3 From c3c61018cd2d6547c4976c04edc4d3212cf3fb31 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Fri, 19 Jul 2013 16:36:55 -0700 Subject: ACME-732 Create the viewer side info route responder --- indra/newview/llfacebookconnect.cpp | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index ac92fc6ed5..51abbdf82f 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -44,6 +44,7 @@ #include "llfloaterreg.h" boost::scoped_ptr LLFacebookConnect::sStateWatcher(new LLEventStream("FacebookConnectState")); +boost::scoped_ptr LLFacebookConnect::sInfoWatcher(new LLEventStream("FacebookConnectInfo")); boost::scoped_ptr LLFacebookConnect::sContentWatcher(new LLEventStream("FacebookConnectContent")); // Local functions @@ -244,6 +245,36 @@ private: bool mAutoConnect; }; +/////////////////////////////////////////////////////////////////////////////// +// +class LLFacebookInfoResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLFacebookInfoResponder); +public: + + virtual void completed(U32 status, const std::string& reason, const LLSD& info) + { + 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")); + } + } + + void completedHeader(U32 status, const std::string& reason, const LLSD& content) + { + if (status == 302) + { + LLFacebookConnect::instance().openFacebookWeb(content["location"]); + } + } +}; + /////////////////////////////////////////////////////////////////////////////// // class LLFacebookFriendsResponder : public LLHTTPClient::Responder @@ -329,6 +360,14 @@ void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect) } } +void LLFacebookConnect::loadFacebookInfo() +{ + const bool follow_redirects = false; + const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; + LLHTTPClient::get(getFacebookConnectURL("/info"), new LLFacebookInfoResponder(), + LLSD(), timeout, follow_redirects); +} + void LLFacebookConnect::loadFacebookFriends() { const bool follow_redirects = false; @@ -427,6 +466,17 @@ void LLFacebookConnect::updateStatus(const std::string& message) LLHTTPClient::post(getFacebookConnectURL("/share/wall"), body, new LLFacebookShareResponder()); } +void LLFacebookConnect::storeInfo(const LLSD& info) +{ + mInfo = info; + sInfoWatcher->post(info); +} + +const LLSD& LLFacebookConnect::getInfo() const +{ + return mInfo; +} + void LLFacebookConnect::storeContent(const LLSD& content) { mGeneration++; -- cgit v1.2.3 From eadb42eb9d202c38ca2761be07ee4376863550ce Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 19 Jul 2013 22:35:45 -0700 Subject: ACME-734 : Fix : Feed browsing history but without the query part --- indra/newview/llfacebookconnect.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index f0b735c5ca..7c1e7b3b16 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -321,7 +321,6 @@ void LLFacebookConnect::openFacebookWeb(std::string url) p.url(url).show_chrome(true); p.url(url).allow_address_entry(false); p.url(url).allow_back_forward_navigation(false); - p.url(url).save_url_history(false); p.url(url).trusted_content(true); LLFloaterReg::showInstance("fbc_web", p); -- cgit v1.2.3 From 882b2508db4519b328016802ab72093df7911e68 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Mon, 22 Jul 2013 18:49:22 -0700 Subject: ACME-729 Implement the 'Use another account...' button --- indra/newview/llfacebookconnect.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 7c1e7b3b16..0d6806d252 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -245,6 +245,35 @@ private: bool mAutoConnect; }; +/////////////////////////////////////////////////////////////////////////////// +// +class LLFacebookDisconnectThenConnectResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLFacebookDisconnectThenConnectResponder); +public: + + virtual void completed(U32 status, const std::string& reason, const LLSD& content) + { + if (isGoodStatus(status)) + { + LL_DEBUGS("FacebookConnect") << "Disconnect successful. content: " << content << LL_ENDL; + + // Clear all facebook stuff + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED); + LLFacebookConnect::instance().clearContent(); + + LLViewerMedia::clearAllCookies(); + + //Now attempt to reconnect + LLFacebookConnect::instance().checkConnectionToFacebook(true); + } + else + { + log_facebook_connect_error("Disconnect", status, reason, content.get("error_code"), content.get("error_description")); + } + } +}; + /////////////////////////////////////////////////////////////////////////////// // class LLFacebookInfoResponder : public LLHTTPClient::Responder @@ -363,6 +392,11 @@ void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect) } } +void LLFacebookConnect::disconnectThenConnectToFacebook() +{ + LLHTTPClient::del(getFacebookConnectURL("/connection"), new LLFacebookDisconnectThenConnectResponder()); +} + void LLFacebookConnect::loadFacebookInfo() { const bool follow_redirects = false; -- cgit v1.2.3 From 66522bb6bdff50f5f6838c1410e2cc4ab45a0a62 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Tue, 23 Jul 2013 13:31:41 -0700 Subject: ACME-677 Make the 'Connect...', 'Disconnect' and 'Use another account...' buttons disabled upon clicking --- indra/newview/llfacebookconnect.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 0d6806d252..cccfb6f2b8 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -181,7 +181,12 @@ class LLFacebookDisconnectResponder : public LLHTTPClient::Responder { LOG_CLASS(LLFacebookDisconnectResponder); public: - + + LLFacebookDisconnectResponder() + { + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_DISCONNECTING); + } + virtual void completed(U32 status, const std::string& reason, const LLSD& content) { if (isGoodStatus(status)) @@ -252,6 +257,11 @@ class LLFacebookDisconnectThenConnectResponder : public LLHTTPClient::Responder LOG_CLASS(LLFacebookDisconnectThenConnectResponder); public: + LLFacebookDisconnectThenConnectResponder() + { + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_DISCONNECTING); + } + virtual void completed(U32 status, const std::string& reason, const LLSD& content) { if (isGoodStatus(status)) -- cgit v1.2.3 From 91c8740c3533bcf870a191fad30fef1fafbe88c7 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Wed, 24 Jul 2013 17:17:19 -0700 Subject: ACME-602 Remove logging code that reveals use of suggested friends --- indra/newview/llfacebookconnect.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index cccfb6f2b8..486195a483 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -325,7 +325,6 @@ public: { if (isGoodStatus(status)) { - llinfos << "Facebook: Friends list received" << llendl; LL_DEBUGS("FacebookConnect") << "Getting Facebook friends successful. content: " << content << LL_ENDL; LLFacebookConnect::instance().storeContent(content); } -- cgit v1.2.3 From 0254b74abfeadb1dea8b37435288512887baff0d Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Thu, 25 Jul 2013 16:04:58 -0700 Subject: ACME-773 Remove the 'Use another account...' in the ACCOUNT panel --- indra/newview/llfacebookconnect.cpp | 39 ------------------------------------- 1 file changed, 39 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 486195a483..8c75d0efc6 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -250,40 +250,6 @@ private: bool mAutoConnect; }; -/////////////////////////////////////////////////////////////////////////////// -// -class LLFacebookDisconnectThenConnectResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLFacebookDisconnectThenConnectResponder); -public: - - LLFacebookDisconnectThenConnectResponder() - { - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_DISCONNECTING); - } - - virtual void completed(U32 status, const std::string& reason, const LLSD& content) - { - if (isGoodStatus(status)) - { - LL_DEBUGS("FacebookConnect") << "Disconnect successful. content: " << content << LL_ENDL; - - // Clear all facebook stuff - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED); - LLFacebookConnect::instance().clearContent(); - - LLViewerMedia::clearAllCookies(); - - //Now attempt to reconnect - LLFacebookConnect::instance().checkConnectionToFacebook(true); - } - else - { - log_facebook_connect_error("Disconnect", status, reason, content.get("error_code"), content.get("error_description")); - } - } -}; - /////////////////////////////////////////////////////////////////////////////// // class LLFacebookInfoResponder : public LLHTTPClient::Responder @@ -401,11 +367,6 @@ void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect) } } -void LLFacebookConnect::disconnectThenConnectToFacebook() -{ - LLHTTPClient::del(getFacebookConnectURL("/connection"), new LLFacebookDisconnectThenConnectResponder()); -} - void LLFacebookConnect::loadFacebookInfo() { const bool follow_redirects = false; -- cgit v1.2.3 From 85c8c1daf05e09c2b8524c6b418378063467f597 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 30 Jul 2013 13:02:29 -0700 Subject: ACME-757 : Change the hard coded url to fbc service (still a hack) --- indra/newview/llfacebookconnect.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 8c75d0efc6..29187bcabc 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -334,7 +334,8 @@ void LLFacebookConnect::openFacebookWeb(std::string url) std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) { //static std::string sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect"); - static std::string sFacebookConnectUrl = "https://pdp15.lindenlab.com/fbc/agent/" + gAgentID.asString(); // TEMPORARY HACK FOR FB DEMO - Cho + static std::string sFacebookConnectUrl = "http://int.fbc.aditi.lindenlab.com/agent/" + gAgentID.asString(); // TEMPORARY HACK FOR FB DEMO - Cho + std::string url = sFacebookConnectUrl + route; llinfos << url << llendl; return url; -- cgit v1.2.3 From d0764f57a5b9591b452b6718d53a8169499e1856 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Wed, 31 Jul 2013 13:03:57 -0700 Subject: ACME-757: Switching back to pdp15 host for testing. --- indra/newview/llfacebookconnect.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 29187bcabc..2dbbb71cab 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -334,8 +334,9 @@ void LLFacebookConnect::openFacebookWeb(std::string url) std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) { //static std::string sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect"); - static std::string sFacebookConnectUrl = "http://int.fbc.aditi.lindenlab.com/agent/" + gAgentID.asString(); // TEMPORARY HACK FOR FB DEMO - Cho - + //static std::string sFacebookConnectUrl = "http://int.fbc.aditi.lindenlab.com/agent/" + gAgentID.asString(); // TEMPORARY HACK FOR FB DEMO - Cho + static std::string sFacebookConnectUrl = "http://pdp15.lindenlab.com/fbc/agent/" + gAgentID.asString(); // ANOTHER HACK SO WE POINT TO PDP15 + std::string url = sFacebookConnectUrl + route; llinfos << url << llendl; return url; -- cgit v1.2.3 From a2b1e06c3def4a8a97a41f3379c336864ede21f8 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Wed, 31 Jul 2013 19:04:45 -0700 Subject: ACME-778: Adjusted the facebook code so that isConnected() does not depend on state changes. Instead it returns true if the user successfully connected and false if the user successfully disconnected. --- indra/newview/llfacebookconnect.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 2dbbb71cab..a7b7224d28 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -199,6 +199,7 @@ public: } else { + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_DISCONNECT_FAILED); log_facebook_connect_error("Disconnect", status, reason, content.get("error_code"), content.get("error_description")); } } @@ -313,6 +314,8 @@ public: // LLFacebookConnect::LLFacebookConnect() : mConnectionState(FB_NOT_CONNECTED), + mConnected(false), + mInfo(), mContent(), mGeneration(0) { @@ -334,8 +337,7 @@ void LLFacebookConnect::openFacebookWeb(std::string url) std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) { //static std::string sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect"); - //static std::string sFacebookConnectUrl = "http://int.fbc.aditi.lindenlab.com/agent/" + gAgentID.asString(); // TEMPORARY HACK FOR FB DEMO - Cho - static std::string sFacebookConnectUrl = "http://pdp15.lindenlab.com/fbc/agent/" + gAgentID.asString(); // ANOTHER HACK SO WE POINT TO PDP15 + static std::string sFacebookConnectUrl = "http://int.fbc.aditi.lindenlab.com/fbc/agent/" + gAgentID.asString(); // TEMPORARY HACK FOR FB DEMO - Cho std::string url = sFacebookConnectUrl + route; llinfos << url << llendl; @@ -360,13 +362,10 @@ void LLFacebookConnect::disconnectFromFacebook() void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect) { - if ((mConnectionState == FB_NOT_CONNECTED) || (mConnectionState == FB_CONNECTION_FAILED) || (mConnectionState == FB_POST_FAILED)) - { const bool follow_redirects = false; const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(auto_connect), LLSD(), timeout, follow_redirects); - } } void LLFacebookConnect::loadFacebookInfo() @@ -507,6 +506,15 @@ void LLFacebookConnect::clearContent() void LLFacebookConnect::setConnectionState(LLFacebookConnect::EConnectionState connection_state) { + if(connection_state == FB_CONNECTED) + { + setConnected(true); + } + else if(connection_state == FB_NOT_CONNECTED) + { + setConnected(false); + } + if (mConnectionState != connection_state) { LLSD state_info; @@ -516,3 +524,8 @@ void LLFacebookConnect::setConnectionState(LLFacebookConnect::EConnectionState c mConnectionState = connection_state; } + +void LLFacebookConnect::setConnected(bool connected) +{ + mConnected = connected; +} -- cgit v1.2.3 From 1f6d19436e659954d766d6d3698d0bfabde4fa81 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Thu, 1 Aug 2013 15:12:58 -0700 Subject: ACME: add SLShareHost variable to settings.xml, which allows changing the fb service host location as needed. --- indra/newview/llfacebookconnect.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index a7b7224d28..dbebe8d14a 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -32,6 +32,7 @@ #include "llagent.h" #include "llcallingcard.h" // for LLAvatarTracker #include "llcommandhandler.h" +#include "llcontrol.h" #include "llhttpclient.h" #include "llnotificationsutil.h" #include "llurlaction.h" @@ -47,6 +48,8 @@ boost::scoped_ptr LLFacebookConnect::sStateWatcher(new LLEventStrea boost::scoped_ptr LLFacebookConnect::sInfoWatcher(new LLEventStream("FacebookConnectInfo")); boost::scoped_ptr LLFacebookConnect::sContentWatcher(new LLEventStream("FacebookConnectContent")); +extern LLControlGroup gSavedSettings; + // 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) { @@ -336,8 +339,10 @@ void LLFacebookConnect::openFacebookWeb(std::string url) std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) { + //TODO GIL : Remove this code along with extern and llcontrol.h header + std::string host = gSavedSettings.getString("SLShareHost"); //static std::string sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect"); - static std::string sFacebookConnectUrl = "http://int.fbc.aditi.lindenlab.com/fbc/agent/" + gAgentID.asString(); // TEMPORARY HACK FOR FB DEMO - Cho + static std::string sFacebookConnectUrl = host + "/fbc/agent/" + gAgentID.asString(); // TEMPORARY HACK FOR FB DEMO - Cho std::string url = sFacebookConnectUrl + route; llinfos << url << llendl; -- cgit v1.2.3 From 7bcda3a511f47a465cb8e22eb3c36e1e82d19f17 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 1 Aug 2013 20:53:27 -0700 Subject: ACME-785 : Use a specific notifytip message (without the OK button) for fbc success notification --- indra/newview/llfacebookconnect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index a7b7224d28..0179b3f6b1 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -61,7 +61,7 @@ void toast_user_for_success() { LLSD args; args["MESSAGE"] = LLTrans::getString("facebook_post_success"); - LLNotificationsUtil::add("SystemMessage", args); + LLNotificationsUtil::add("FacebookConnect", args); } /////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From b19b2737b2965900e55485a5887815ce97aa9dd7 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 1 Aug 2013 21:46:37 -0700 Subject: ACME-761 : Use the cap for the service url unless overridden by the SLShareHost setting from settings.xml --- indra/newview/llfacebookconnect.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 26fc480658..e4ac2a4960 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -40,6 +40,7 @@ #include "llimagejpeg.h" #include "lltrans.h" #include "llevents.h" +#include "llviewerregion.h" #include "llfloaterwebcontent.h" #include "llfloaterreg.h" @@ -339,13 +340,21 @@ void LLFacebookConnect::openFacebookWeb(std::string url) std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) { - //TODO GIL : Remove this code along with extern and llcontrol.h header + static std::string sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect"); + + //*TODO : Remove this code along with extern and llcontrol.h header std::string host = gSavedSettings.getString("SLShareHost"); - //static std::string sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect"); - static std::string sFacebookConnectUrl = host + "/fbc/agent/" + gAgentID.asString(); // TEMPORARY HACK FOR FB DEMO - Cho + if (!host.empty()) + { + sFacebookConnectUrl = host + "/fbc/agent/" + gAgentID.asString(); // TEMPORARY HACK FOR FB DEMO - Cho + } + else + { + sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect"); + } + //End removable part std::string url = sFacebookConnectUrl + route; - llinfos << url << llendl; return url; } -- cgit v1.2.3 From a4bad4ba21787c6895368f5eb5cda7c3881d57da Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Fri, 2 Aug 2013 18:58:37 -0700 Subject: ACME-744: Temporary solution. The internal browser was not setting keyboard focus properly...as to why an investigation is needed. For now explicly setting keyboard focus to the internal browser after it is displayed. --- indra/newview/llfacebookconnect.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index e4ac2a4960..560208c31e 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -333,7 +333,9 @@ void LLFacebookConnect::openFacebookWeb(std::string url) p.url(url).allow_address_entry(false); p.url(url).allow_back_forward_navigation(false); p.url(url).trusted_content(true); - LLFloaterReg::showInstance("fbc_web", p); + LLFloater *floater = LLFloaterReg::showInstance("fbc_web", p); + //TODO Gil: Hack to give the focus to the web browser to show cursor, will fix + gFocusMgr.setKeyboardFocus( floater ); //LLUrlAction::openURLExternal(url); } -- cgit v1.2.3 From 35278461964653fc032995afdc366f096c937a14 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 2 Aug 2013 19:25:10 -0700 Subject: ACME-796 : Do not flip the fbc state to failure while connecting through web browser. Handle the dismiss case as best as possible. --- indra/newview/llfacebookconnect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index e4ac2a4960..98fd8b1d7b 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -122,7 +122,7 @@ public: // Grab some graph data now that we are connected LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED); } - else + else if (status != 302) { LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTION_FAILED); log_facebook_connect_error("Connect", status, reason, content.get("error_code"), content.get("error_description")); -- cgit v1.2.3 From c7342bc6c0950add28918159935b8001c4ad2dc8 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Tue, 6 Aug 2013 10:27:18 -0700 Subject: ACME-744: Adjusted comment to be more clear --- indra/newview/llfacebookconnect.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 645f62579d..ad776b2d1a 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -334,7 +334,10 @@ void LLFacebookConnect::openFacebookWeb(std::string url) p.url(url).allow_back_forward_navigation(false); p.url(url).trusted_content(true); LLFloater *floater = LLFloaterReg::showInstance("fbc_web", p); - //TODO Gil: Hack to give the focus to the web browser to show cursor, will fix + //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 + //occurs on the "webbrowser" panel part of the floater, a mouse cursor will properly show and the "webbrowser" will gain focus. + //fbc_web floater contains the "webbrowser" panel. JIRA: ACME-744 gFocusMgr.setKeyboardFocus( floater ); //LLUrlAction::openURLExternal(url); -- cgit v1.2.3 From 3e08ccf6abb6f6ca7f1fa2fc6e80fd6589203f28 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Tue, 6 Aug 2013 17:12:32 -0700 Subject: ACME-801: Adding a suggested friend as a friend does not remove them from the suggested friend list --- indra/newview/llfacebookconnect.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index ad776b2d1a..bdc17773d7 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -320,8 +320,7 @@ LLFacebookConnect::LLFacebookConnect() : mConnectionState(FB_NOT_CONNECTED), mConnected(false), mInfo(), - mContent(), - mGeneration(0) + mContent() { } @@ -506,7 +505,6 @@ const LLSD& LLFacebookConnect::getInfo() const void LLFacebookConnect::storeContent(const LLSD& content) { - mGeneration++; mContent = content; sContentWatcher->post(content); @@ -519,7 +517,6 @@ const LLSD& LLFacebookConnect::getContent() const void LLFacebookConnect::clearContent() { - mGeneration++; mContent = LLSD(); } -- cgit v1.2.3 From 481abb13812214d7d5f1124f8eb80f1cc1b08c19 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Fri, 9 Aug 2013 18:31:10 -0700 Subject: ACME 824: Suggested Friends do not repopulate if you disconnect and reconnect to Facebook API in same viewer session --- indra/newview/llfacebookconnect.cpp | 47 ++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index bdc17773d7..5551acff0d 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -197,9 +197,11 @@ public: { LL_DEBUGS("FacebookConnect") << "Disconnect successful. content: " << content << LL_ENDL; - // Clear all facebook stuff - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED); + // Clear data + LLFacebookConnect::instance().clearInfo(); LLFacebookConnect::instance().clearContent(); + //Notify state change + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED); } else { @@ -320,7 +322,9 @@ LLFacebookConnect::LLFacebookConnect() : mConnectionState(FB_NOT_CONNECTED), mConnected(false), mInfo(), - mContent() + mContent(), + mRefreshInfo(false), + mRefreshContent(false) { } @@ -388,18 +392,24 @@ void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect) void LLFacebookConnect::loadFacebookInfo() { - const bool follow_redirects = false; - const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/info"), new LLFacebookInfoResponder(), - LLSD(), timeout, follow_redirects); + if(mRefreshInfo) + { + const bool follow_redirects = false; + const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; + LLHTTPClient::get(getFacebookConnectURL("/info"), new LLFacebookInfoResponder(), + LLSD(), timeout, follow_redirects); + } } void LLFacebookConnect::loadFacebookFriends() { - const bool follow_redirects = false; - const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/friends"), new LLFacebookFriendsResponder(), - LLSD(), timeout, follow_redirects); + if(mRefreshContent) + { + const bool follow_redirects = false; + const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; + LLHTTPClient::get(getFacebookConnectURL("/friends"), new LLFacebookFriendsResponder(), + LLSD(), timeout, follow_redirects); + } } void LLFacebookConnect::postCheckin(const std::string& location, const std::string& name, const std::string& description, const std::string& image, const std::string& message) @@ -495,6 +505,8 @@ void LLFacebookConnect::updateStatus(const std::string& message) void LLFacebookConnect::storeInfo(const LLSD& info) { mInfo = info; + mRefreshInfo = false; + sInfoWatcher->post(info); } @@ -503,9 +515,15 @@ const LLSD& LLFacebookConnect::getInfo() const return mInfo; } +void LLFacebookConnect::clearInfo() +{ + mInfo = LLSD(); +} + void LLFacebookConnect::storeContent(const LLSD& content) { mContent = content; + mRefreshContent = false; sContentWatcher->post(content); } @@ -520,11 +538,18 @@ void LLFacebookConnect::clearContent() mContent = LLSD(); } +void LLFacebookConnect::setDataDirty() +{ + mRefreshInfo = true; + mRefreshContent = true; +} + void LLFacebookConnect::setConnectionState(LLFacebookConnect::EConnectionState connection_state) { if(connection_state == FB_CONNECTED) { setConnected(true); + setDataDirty(); } else if(connection_state == FB_NOT_CONNECTED) { -- cgit v1.2.3 From d0e964289ec9888686619c4edd756edd622ca214 Mon Sep 17 00:00:00 2001 From: Cho Date: Tue, 13 Aug 2013 01:47:20 +0100 Subject: added read_from_master parameter for ACME-829 --- indra/newview/llfacebookconnect.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 5551acff0d..0a4fefbd24 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -119,7 +119,6 @@ public: { LL_DEBUGS("FacebookConnect") << "Connect successful. content: " << content << LL_ENDL; - // Grab some graph data now that we are connected LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_CONNECTED); } else if (status != 302) @@ -324,7 +323,8 @@ LLFacebookConnect::LLFacebookConnect() mInfo(), mContent(), mRefreshInfo(false), - mRefreshContent(false) + mRefreshContent(false), + mReadFromMaster(false) { } @@ -346,7 +346,7 @@ void LLFacebookConnect::openFacebookWeb(std::string url) //LLUrlAction::openURLExternal(url); } -std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) +std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route, bool include_read_from_master) { static std::string sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect"); @@ -363,6 +363,10 @@ std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route) //End removable part std::string url = sFacebookConnectUrl + route; + if (include_read_from_master && mReadFromMaster) + { + url += "?read_from_master=true"; + } return url; } @@ -384,10 +388,10 @@ void LLFacebookConnect::disconnectFromFacebook() void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect) { - const bool follow_redirects = false; - const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/connection"), new LLFacebookConnectedResponder(auto_connect), - LLSD(), timeout, follow_redirects); + const bool follow_redirects = false; + const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; + LLHTTPClient::get(getFacebookConnectURL("/connection", true), new LLFacebookConnectedResponder(auto_connect), + LLSD(), timeout, follow_redirects); } void LLFacebookConnect::loadFacebookInfo() @@ -396,7 +400,7 @@ void LLFacebookConnect::loadFacebookInfo() { const bool follow_redirects = false; const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/info"), new LLFacebookInfoResponder(), + LLHTTPClient::get(getFacebookConnectURL("/info", true), new LLFacebookInfoResponder(), LLSD(), timeout, follow_redirects); } } @@ -407,7 +411,7 @@ void LLFacebookConnect::loadFacebookFriends() { const bool follow_redirects = false; const F32 timeout = HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/friends"), new LLFacebookFriendsResponder(), + LLHTTPClient::get(getFacebookConnectURL("/friends", true), new LLFacebookFriendsResponder(), LLSD(), timeout, follow_redirects); } } @@ -427,7 +431,7 @@ void LLFacebookConnect::postCheckin(const std::string& location, const std::stri 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"), body, new LLFacebookShareResponder()); + LLHTTPClient::post(getFacebookConnectURL("/share/checkin", true), body, new LLFacebookShareResponder()); } void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::string& caption) @@ -437,7 +441,7 @@ void LLFacebookConnect::sharePhoto(const std::string& image_url, const std::stri body["caption"] = caption; // Note: we can use that route for different publish action. We should be able to use the same responder. - LLHTTPClient::post(getFacebookConnectURL("/share/photo"), body, new LLFacebookShareResponder()); + LLHTTPClient::post(getFacebookConnectURL("/share/photo", true), body, new LLFacebookShareResponder()); } void LLFacebookConnect::sharePhoto(LLPointer image, const std::string& caption) @@ -490,7 +494,7 @@ void LLFacebookConnect::sharePhoto(LLPointer image, const std: memcpy(data, body.str().data(), size); // Note: we can use that route for different publish action. We should be able to use the same responder. - LLHTTPClient::postRaw(getFacebookConnectURL("/share/photo"), data, size, new LLFacebookShareResponder(), headers); + LLHTTPClient::postRaw(getFacebookConnectURL("/share/photo", true), data, size, new LLFacebookShareResponder(), headers); } void LLFacebookConnect::updateStatus(const std::string& message) @@ -499,7 +503,7 @@ void LLFacebookConnect::updateStatus(const std::string& message) 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/wall"), body, new LLFacebookShareResponder()); + LLHTTPClient::post(getFacebookConnectURL("/share/wall", true), body, new LLFacebookShareResponder()); } void LLFacebookConnect::storeInfo(const LLSD& info) @@ -548,6 +552,7 @@ void LLFacebookConnect::setConnectionState(LLFacebookConnect::EConnectionState c { if(connection_state == FB_CONNECTED) { + mReadFromMaster = true; setConnected(true); setDataDirty(); } @@ -555,6 +560,10 @@ void LLFacebookConnect::setConnectionState(LLFacebookConnect::EConnectionState c { setConnected(false); } + else if(connection_state == FB_POSTED) + { + mReadFromMaster = false; + } if (mConnectionState != connection_state) { -- cgit v1.2.3 From 4595978d59d905bc9ef95efd759eac8cb62b57c3 Mon Sep 17 00:00:00 2001 From: Cho Date: Wed, 14 Aug 2013 20:02:31 +0100 Subject: removed momentary error message upon connecting to Facebook --- indra/newview/llfacebookconnect.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 0a4fefbd24..abfacdb93c 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -81,18 +81,18 @@ public: { if (tokens[0].asString() == "connect") { - // connect to facebook - if (query_map.has("code")) - { - LLFacebookConnect::instance().connectToFacebook(query_map["code"], query_map.get("state")); - } - // this command probably came from the fbc_web browser, so close it LLFloater* fbc_web = LLFloaterReg::getInstance("fbc_web"); if (fbc_web) { fbc_web->closeFloater(); } + + // connect to facebook + if (query_map.has("code")) + { + LLFacebookConnect::instance().connectToFacebook(query_map["code"], query_map.get("state")); + } return true; } } -- cgit v1.2.3 From ed828365b8a5371b1deadaa8cc1c2f1fdf729227 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Thu, 29 Aug 2013 16:05:49 -0700 Subject: ACME-866 User receives error when hitting Disconnect in Facebook floater, if access token was cleared manually on backend: Problem was that when the user was already disconnected the Facebook connection state was not being set to disconnected. --- indra/newview/llfacebookconnect.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index abfacdb93c..451c0f5767 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -190,17 +190,28 @@ public: LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_DISCONNECTING); } + void setUserDisconnected() + { + // Clear data + LLFacebookConnect::instance().clearInfo(); + LLFacebookConnect::instance().clearContent(); + //Notify state change + LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED); + } + virtual void completed(U32 status, const std::string& reason, const LLSD& content) { - if (isGoodStatus(status)) + if (isGoodStatus(status)) { LL_DEBUGS("FacebookConnect") << "Disconnect successful. content: " << content << LL_ENDL; - - // Clear data - LLFacebookConnect::instance().clearInfo(); - LLFacebookConnect::instance().clearContent(); - //Notify state change - LLFacebookConnect::instance().setConnectionState(LLFacebookConnect::FB_NOT_CONNECTED); + setUserDisconnected(); + + } + //User not found so already disconnected + else if(status == 404) + { + LL_DEBUGS("FacebookConnect") << "Already disconnected. content: " << content << LL_ENDL; + setUserDisconnected(); } else { -- cgit v1.2.3 From 3ba9cf20486ac80276f262c57a9280dc875504eb Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Tue, 3 Sep 2013 19:11:20 -0700 Subject: ACME-789: Remove SLShareHost setting from settings.xml --- indra/newview/llfacebookconnect.cpp | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 451c0f5767..9c70757278 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -32,7 +32,6 @@ #include "llagent.h" #include "llcallingcard.h" // for LLAvatarTracker #include "llcommandhandler.h" -#include "llcontrol.h" #include "llhttpclient.h" #include "llnotificationsutil.h" #include "llurlaction.h" @@ -49,8 +48,6 @@ boost::scoped_ptr LLFacebookConnect::sStateWatcher(new LLEventStrea boost::scoped_ptr LLFacebookConnect::sInfoWatcher(new LLEventStream("FacebookConnectInfo")); boost::scoped_ptr LLFacebookConnect::sContentWatcher(new LLEventStream("FacebookConnectContent")); -extern LLControlGroup gSavedSettings; - // 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) { @@ -360,18 +357,6 @@ void LLFacebookConnect::openFacebookWeb(std::string url) std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route, bool include_read_from_master) { static std::string sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect"); - - //*TODO : Remove this code along with extern and llcontrol.h header - std::string host = gSavedSettings.getString("SLShareHost"); - if (!host.empty()) - { - sFacebookConnectUrl = host + "/fbc/agent/" + gAgentID.asString(); // TEMPORARY HACK FOR FB DEMO - Cho - } - else - { - sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect"); - } - //End removable part std::string url = sFacebookConnectUrl + route; if (include_read_from_master && mReadFromMaster) -- cgit v1.2.3 From bf22b7150d2884fb68982764cd6a122d9c23909a Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 6 Sep 2013 18:26:21 -0700 Subject: ACME-905 : Get the FacebookConnect cap each time we need it (it's not that much) --- indra/newview/llfacebookconnect.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 9c70757278..611d18d6d6 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -356,9 +356,9 @@ void LLFacebookConnect::openFacebookWeb(std::string url) std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route, bool include_read_from_master) { - static std::string sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect"); - - std::string url = sFacebookConnectUrl + route; + std::string url = gAgent.getRegion()->getCapability("FacebookConnect"); + url += route; + if (include_read_from_master && mReadFromMaster) { url += "?read_from_master=true"; -- cgit v1.2.3 From 3a57a67c5d386cfa6df004915ecb0104b3207e72 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 28 Oct 2013 17:15:57 -0700 Subject: ACME-1099 : Fix crash when getting the Facebook cap from a (potentially null) region --- indra/newview/llfacebookconnect.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'indra/newview/llfacebookconnect.cpp') diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp index 611d18d6d6..9a20ce8f1b 100644 --- a/indra/newview/llfacebookconnect.cpp +++ b/indra/newview/llfacebookconnect.cpp @@ -356,13 +356,18 @@ void LLFacebookConnect::openFacebookWeb(std::string url) std::string LLFacebookConnect::getFacebookConnectURL(const std::string& route, bool include_read_from_master) { - std::string url = gAgent.getRegion()->getCapability("FacebookConnect"); - url += route; + std::string url(""); + LLViewerRegion *regionp = gAgent.getRegion(); + if (regionp) + { + url = regionp->getCapability("FacebookConnect"); + url += route; - if (include_read_from_master && mReadFromMaster) - { - url += "?read_from_master=true"; - } + if (include_read_from_master && mReadFromMaster) + { + url += "?read_from_master=true"; + } + } return url; } -- cgit v1.2.3