diff options
-rw-r--r-- | indra/newview/llfacebookconnect.cpp | 100 | ||||
-rw-r--r-- | indra/newview/llfacebookconnect.h | 19 | ||||
-rw-r--r-- | indra/newview/llpanelpeople.cpp | 54 | ||||
-rw-r--r-- | indra/newview/llpanelpeople.h | 5 |
4 files changed, 88 insertions, 90 deletions
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<LLPersonTabModel *>(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(); } diff --git a/indra/newview/llfacebookconnect.h b/indra/newview/llfacebookconnect.h index c42d8c8edc..691aaa9131 100644 --- a/indra/newview/llfacebookconnect.h +++ b/indra/newview/llfacebookconnect.h @@ -40,24 +40,21 @@ class LLFacebookConnect : public LLSingleton<LLFacebookConnect> { LOG_CLASS(LLFacebookConnect); public: - /* - * Performs initial setup, by requesting config data from the web service if - * it has not already been received. - */ - void init(); - - void loadFacebookFriends(); - void hideFacebookFriends(); void connectToFacebook(const std::string& auth_code = ""); void disconnectFromFacebook(); void tryToReconnectToFacebook(); void getConnectionToFacebook(); - void showFacebookFriends(const LLSD& friends); + void loadFacebookFriends(); + + void clearContent(); + void storeContent(const LLSD& content); + const LLSD& getContent() const; void setConnected(bool connected) { mConnectedToFbc = connected; } bool getConnected() { return mConnectedToFbc; } - + S32 generation() { return mGeneration; } + private: friend class LLSingleton<LLFacebookConnect>; @@ -67,6 +64,8 @@ private: std::string getFacebookConnectURL(const std::string& route = ""); bool mConnectedToFbc; + LLSD mContent; + S32 mGeneration; }; #endif // LL_LLFACEBOOKCONNECT_H diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index 02a254b76c..8648a44c55 100644 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -555,12 +555,13 @@ LLPanelPeople::LLPanelPeople() mNearbyList(NULL), mRecentList(NULL), mGroupList(NULL), - mMiniMap(NULL) + mMiniMap(NULL), + mFacebookListGeneration(0) { mFriendListUpdater = new LLFriendListUpdater(boost::bind(&LLPanelPeople::updateFriendList, this)); mNearbyListUpdater = new LLNearbyListUpdater(boost::bind(&LLPanelPeople::updateNearbyList, this)); mRecentListUpdater = new LLRecentListUpdater(boost::bind(&LLPanelPeople::updateRecentList, this)); - mFbcTestListUpdater = new LLFbcTestListUpdater(boost::bind(&LLPanelPeople::updateFbcTestList, this)); + mFacebookListUpdater = new LLFbcTestListUpdater(boost::bind(&LLPanelPeople::updateFacebookList, this)); mButtonsUpdater = new LLButtonsUpdater(boost::bind(&LLPanelPeople::updateButtons, this)); mCommitCallbackRegistrar.add("People.loginFBC", boost::bind(&LLPanelPeople::onLoginFbcButtonClicked, this)); @@ -595,7 +596,7 @@ LLPanelPeople::~LLPanelPeople() delete mNearbyListUpdater; delete mFriendListUpdater; delete mRecentListUpdater; - delete mFbcTestListUpdater; + delete mFacebookListUpdater; if(LLVoiceClient::instanceExists()) { @@ -683,13 +684,17 @@ BOOL LLPanelPeople::postBuild() mAllFriendList->setContextMenu(&LLPanelPeopleMenus::gPeopleContextMenu); mOnlineFriendList->setContextMenu(&LLPanelPeopleMenus::gPeopleContextMenu); + //===Temporary ======================================================================== + LLPanel * social_tab = getChild<LLPanel>(FBCTEST_TAB_NAME); mFacebookFriends = social_tab->getChild<LLSocialList>("facebook_friends"); - social_tab->setVisibleCallback(boost::bind(&Updater::setActive, mFbcTestListUpdater, _2)); + // Note: we use the same updater for both test lists (brute force but OK since it's temporary) + social_tab->setVisibleCallback(boost::bind(&Updater::setActive, mFacebookListUpdater, _2)); //===Test START======================================================================== LLPanel * socialtwo_tab = getChild<LLPanel>(FBCTESTTWO_TAB_NAME); + socialtwo_tab->setVisibleCallback(boost::bind(&Updater::setActive, mFacebookListUpdater, _2)); //Create folder view LLPersonModelCommon* base_item = new LLPersonModelCommon(mPersonFolderViewModel); @@ -911,7 +916,7 @@ void LLPanelPeople::updateRecentList() mRecentList->setDirty(); } -void LLPanelPeople::updateFbcTestList() +void LLPanelPeople::updateFacebookList() { if (mTryToConnectToFbc) { @@ -922,8 +927,45 @@ void LLPanelPeople::updateFbcTestList() mTryToConnectToFbc = false; // stop updating - mFbcTestListUpdater->setActive(false); + mFacebookListUpdater->setActive(false); } + + if (LLFacebookConnect::instance().generation() != mFacebookListGeneration) + { + mFacebookListGeneration = LLFacebookConnect::instance().generation(); + LLSD friends = LLFacebookConnect::instance().getContent(); + + 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<LLPersonTabModel *>(mPersonFolderView->getPersonTabModelByIndex(tab_type)); + if (person_tab_model) + { + addParticipantToModel(person_tab_model, agent_id, name); + } + } + } } void LLPanelPeople::updateButtons() diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h index 2f74064327..6b5514deaf 100644 --- a/indra/newview/llpanelpeople.h +++ b/indra/newview/llpanelpeople.h @@ -88,7 +88,7 @@ private: void updateFriendList(); void updateNearbyList(); void updateRecentList(); - void updateFbcTestList(); + void updateFacebookList(); bool isItemsFreeOfFriends(const uuid_vec_t& uuids); @@ -152,6 +152,7 @@ private: LLAvatarList* mRecentList; LLGroupList* mGroupList; LLSocialList* mFacebookFriends; + S32 mFacebookListGeneration; LLNetMap* mMiniMap; std::vector<std::string> mSavedOriginalFilters; @@ -162,7 +163,7 @@ private: Updater* mFriendListUpdater; Updater* mNearbyListUpdater; Updater* mRecentListUpdater; - Updater* mFbcTestListUpdater; + Updater* mFacebookListUpdater; Updater* mButtonsUpdater; LLMenuButton* mFBCGearButton; LLHandle< LLFloater > mPicker; |