diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llfacebookconnect.cpp | 92 | ||||
-rw-r--r-- | indra/newview/llfacebookconnect.h | 8 | ||||
-rw-r--r-- | indra/newview/llpanelpeople.cpp | 72 | ||||
-rw-r--r-- | indra/newview/llpanelpeople.h | 9 |
4 files changed, 98 insertions, 83 deletions
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<LLPersonTabModel *>(mPersonFolderView->getPersonTabModelByIndex(tab_type)); if(person_tab_model) { addParticipantToModel(person_tab_model, agent_id, name); } + */ } - */ } diff --git a/indra/newview/llfacebookconnect.h b/indra/newview/llfacebookconnect.h index d60fdacd90..c42d8c8edc 100644 --- a/indra/newview/llfacebookconnect.h +++ b/indra/newview/llfacebookconnect.h @@ -49,9 +49,14 @@ public: void loadFacebookFriends(); void hideFacebookFriends(); void connectToFacebook(const std::string& auth_code = ""); + void disconnectFromFacebook(); + void tryToReconnectToFacebook(); + void getConnectionToFacebook(); + void showFacebookFriends(const LLSD& friends); void setConnected(bool connected) { mConnectedToFbc = connected; } + bool getConnected() { return mConnectedToFbc; } private: @@ -59,7 +64,8 @@ private: LLFacebookConnect(); ~LLFacebookConnect() {}; - + std::string getFacebookConnectURL(const std::string& route = ""); + bool mConnectedToFbc; }; diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index ce3ae48aca..02a254b76c 100644 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -54,8 +54,8 @@ #include "llcallingcard.h" // for LLAvatarTracker #include "llcallbacklist.h" #include "llerror.h" +#include "llfacebookconnect.h" #include "llfloateravatarpicker.h" -//#include "llfloaterminiinspector.h" #include "llfriendcard.h" #include "llgroupactions.h" #include "llgrouplist.h" @@ -76,7 +76,6 @@ #include "llspeakers.h" #include "llfloaterwebcontent.h" #include "llurlaction.h" -#include "llcommandhandler.h" #define FRIEND_LIST_UPDATE_TIMEOUT 0.5 #define NEARBY_LIST_UPDATE_INTERVAL 1 @@ -91,35 +90,6 @@ static const std::string FBCTEST_TAB_NAME = "fbctest_panel"; static const std::string FBCTESTTWO_TAB_NAME = "fbctesttwo_panel"; static const std::string COLLAPSED_BY_USER = "collapsed_by_user"; -class LLFacebookConnectHandler : public LLCommandHandler -{ -public: - LLFacebookConnectHandler() : LLCommandHandler("fbc", UNTRUSTED_THROTTLE), mPanelPeople(NULL) { } - - LLPanelPeople* mPanelPeople; - - 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")) - { - if (mPanelPeople) - { - mPanelPeople->connectToFacebook(query_map["code"]); - mPanelPeople = NULL; - } - } - return true; - } - } - return false; - } -}; -LLFacebookConnectHandler gFacebookConnectHandler; /** Comparator for comparing avatar items by last interaction date */ class LLAvatarItemRecentComparator : public LLAvatarItemComparator @@ -577,7 +547,6 @@ private: LLPanelPeople::LLPanelPeople() : LLPanel(), - mConnectedToFbc(false), mPersonFolderView(NULL), mTryToConnectToFbc(true), mTabContainer(NULL), @@ -947,7 +916,7 @@ void LLPanelPeople::updateFbcTestList() if (mTryToConnectToFbc) { // try to reconnect to facebook! - tryToReconnectToFacebook(); + LLFacebookConnect::instance().tryToReconnectToFacebook(); // don't try again mTryToConnectToFbc = false; @@ -1633,11 +1602,12 @@ bool LLPanelPeople::isAccordionCollapsedByUser(const std::string& name) return isAccordionCollapsedByUser(getChild<LLUICtrl>(name)); } +/* void LLPanelPeople::openFacebookWeb(std::string url) { - gFacebookConnectHandler.mPanelPeople = this; LLUrlAction::openURLExternal(url); } +*/ void LLPanelPeople::addTestParticipant() { @@ -1691,43 +1661,15 @@ void LLPanelPeople::addParticipantToModel(LLPersonTabModel * person_folder_model person_folder_model->addParticipant(person_model); } -void LLPanelPeople::tryToReconnectToFacebook() -{ - if (!mConnectedToFbc) - { - const bool follow_redirects=false; - const F32 timeout=HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/connection"), new FacebookConnectedResponder(this, false), - LLSD(), timeout, follow_redirects); - } -} - -void LLPanelPeople::disconnectFromFacebook() -{ - LLHTTPClient::del(getFacebookConnectURL("/connection"), new FacebookDisconnectResponder(this)); -} - -std::string LLPanelPeople::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 LLPanelPeople::onLoginFbcButtonClicked() { - if (mConnectedToFbc) + if (LLFacebookConnect::instance().getConnected()) { - disconnectFromFacebook(); + LLFacebookConnect::instance().disconnectFromFacebook(); } else { - const bool follow_redirects=false; - const F32 timeout=HTTP_REQUEST_EXPIRY_SECS; - LLHTTPClient::get(getFacebookConnectURL("/connection"), new FacebookConnectedResponder(this, true), - LLSD(), timeout, follow_redirects); + LLFacebookConnect::instance().getConnectionToFacebook(); } } diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h index fa354f7ecb..2f74064327 100644 --- a/indra/newview/llpanelpeople.h +++ b/indra/newview/llpanelpeople.h @@ -62,16 +62,11 @@ public: static void idle(void * user_data); - void openFacebookWeb(std::string url); +// void openFacebookWeb(std::string url); void addTestParticipant(); void addParticipantToModel(LLPersonTabModel * session_model, const LLUUID& agent_id, const std::string& name); - void tryToReconnectToFacebook(); - void disconnectFromFacebook(); - std::string getFacebookConnectURL(const std::string& route = ""); - - bool mConnectedToFbc; - bool mTryToConnectToFbc; + bool mTryToConnectToFbc; // internals class Updater; |