From ac9cf045ecc14f8c650773f3fff7bc338fa468d0 Mon Sep 17 00:00:00 2001 From: Cho Date: Fri, 21 Feb 2014 02:06:03 +0000 Subject: Added Friends tab to Facebook floater for ACME-1325 --- indra/newview/llfloaterfacebook.cpp | 99 ++++++++++++++++++++++ indra/newview/llfloaterfacebook.h | 16 +++- indra/newview/llpanelpeople.cpp | 6 +- indra/newview/llpanelpeople.h | 2 +- .../skins/default/xui/en/floater_facebook.xml | 10 ++- .../default/xui/en/panel_facebook_friends.xml | 35 ++++++++ 6 files changed, 161 insertions(+), 7 deletions(-) create mode 100644 indra/newview/skins/default/xui/en/panel_facebook_friends.xml (limited to 'indra') diff --git a/indra/newview/llfloaterfacebook.cpp b/indra/newview/llfloaterfacebook.cpp index 3e58b40c75..de849b6b3f 100644 --- a/indra/newview/llfloaterfacebook.cpp +++ b/indra/newview/llfloaterfacebook.cpp @@ -48,10 +48,13 @@ #include "llviewercontrol.h" #include "llviewermedia.h" #include "lltabcontainer.h" +#include "llavatarlist.h" +#include "llpanelpeoplemenus.h" static LLRegisterPanelClassWrapper t_panel_status("llfacebookstatuspanel"); static LLRegisterPanelClassWrapper t_panel_photo("llfacebookphotopanel"); static LLRegisterPanelClassWrapper t_panel_checkin("llfacebookcheckinpanel"); +static LLRegisterPanelClassWrapper t_panel_friends("llfacebookfriendspanel"); static LLRegisterPanelClassWrapper t_panel_account("llfacebookaccountpanel"); const S32 MAX_POSTCARD_DATASIZE = 1024 * 1024; // one megabyte @@ -692,6 +695,102 @@ void LLFacebookCheckinPanel::clearAndClose() } } +/////////////////////////// +//LLFacebookFriendsPanel////// +/////////////////////////// + +LLFacebookFriendsPanel::LLFacebookFriendsPanel() : +mSuggestedFriends(NULL) +{ +} + +BOOL LLFacebookFriendsPanel::postBuild() +{ + mSuggestedFriends = getChild("suggested_friends"); + mSuggestedFriends->setContextMenu(&LLPanelPeopleMenus::gSuggestedFriendsContextMenu); + + setVisibleCallback(boost::bind(&LLFacebookFriendsPanel::updateFacebookList, this, _2)); + + return LLPanel::postBuild(); +} + +bool LLFacebookFriendsPanel::updateSuggestedFriendList() +{ + const LLAvatarTracker& av_tracker = LLAvatarTracker::instance(); + uuid_vec_t& suggested_friends = mSuggestedFriends->getIDs(); + suggested_friends.clear(); + + //Add suggested friends + LLSD friends = LLFacebookConnect::instance().getContent(); + for (LLSD::array_const_iterator i = friends.beginArray(); i != friends.endArray(); ++i) + { + LLUUID agent_id = (*i).asUUID(); + bool second_life_buddy = agent_id.notNull() ? av_tracker.isBuddy(agent_id) : false; + + if(!second_life_buddy) + { + //FB+SL but not SL friend + if (agent_id.notNull()) + { + suggested_friends.push_back(agent_id); + } + } + } + + //Force a refresh when there aren't any filter matches (prevent displaying content that shouldn't display) + mSuggestedFriends->setDirty(true, !mSuggestedFriends->filterHasMatches()); + //showFriendsAccordionsIfNeeded(); + + return false; +} + +void LLFacebookFriendsPanel::updateFacebookList(bool visible) +{ + if (visible) + { + LLEventPumps::instance().obtain("FacebookConnectContent").stopListening("LLPanelPeople"); // just in case it is already listening + LLEventPumps::instance().obtain("FacebookConnectContent").listen("LLPanelPeople", boost::bind(&LLFacebookFriendsPanel::updateSuggestedFriendList, this)); + + LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLPanelPeople"); // just in case it is already listening + LLEventPumps::instance().obtain("FacebookConnectState").listen("LLPanelPeople", boost::bind(&LLFacebookFriendsPanel::onConnectedToFacebook, this, _1)); + + //Connected + if (LLFacebookConnect::instance().isConnected()) + { + LLFacebookConnect::instance().loadFacebookFriends(); + } + //Check if connected + if ((LLFacebookConnect::instance().getConnectionState() == LLFacebookConnect::FB_NOT_CONNECTED) || + (LLFacebookConnect::instance().getConnectionState() == LLFacebookConnect::FB_CONNECTION_FAILED)) + { + LLFacebookConnect::instance().checkConnectionToFacebook(); + } + + updateSuggestedFriendList(); + } + else + { + LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLPanelPeople"); + LLEventPumps::instance().obtain("FacebookConnectContent").stopListening("LLPanelPeople"); + } +} + +bool LLFacebookFriendsPanel::onConnectedToFacebook(const LLSD& data) +{ + LLSD::Integer connection_state = data.get("enum").asInteger(); + + if (connection_state == LLFacebookConnect::FB_CONNECTED) + { + LLFacebookConnect::instance().loadFacebookFriends(); + } + else if(connection_state == LLFacebookConnect::FB_NOT_CONNECTED) + { + updateSuggestedFriendList(); + }; + + return false; +} + /////////////////////////// //LLFacebookAccountPanel////// /////////////////////////// diff --git a/indra/newview/llfloaterfacebook.h b/indra/newview/llfloaterfacebook.h index 4361dfa628..20c401d0c1 100644 --- a/indra/newview/llfloaterfacebook.h +++ b/indra/newview/llfloaterfacebook.h @@ -34,6 +34,7 @@ class LLIconCtrl; class LLCheckBoxCtrl; class LLSnapshotLivePreview; +class LLAvatarList; class LLFacebookStatusPanel : public LLPanel { @@ -119,6 +120,20 @@ private: bool mReloadingMapTexture; }; +class LLFacebookFriendsPanel : public LLPanel +{ +public: + LLFacebookFriendsPanel(); + BOOL postBuild(); + +private: + bool updateSuggestedFriendList(); + void updateFacebookList(bool visible); + bool onConnectedToFacebook(const LLSD& data); + + LLAvatarList* mSuggestedFriends; +}; + class LLFacebookAccountPanel : public LLPanel { public: @@ -146,7 +161,6 @@ private: LLUICtrl * mDisconnectButton; }; - class LLFloaterFacebook : public LLFloater { public: diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index f551fc96ee..b2e733e1ae 100755 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -505,7 +505,7 @@ public: LLPanelPeople::LLPanelPeople() : LLPanel(), - mTryToConnectToFbc(true), + mTryToConnectToFacebook(true), mTabContainer(NULL), mOnlineFriendList(NULL), mAllFriendList(NULL), @@ -865,10 +865,10 @@ void LLPanelPeople::updateFacebookList(bool visible) { LLFacebookConnect::instance().loadFacebookFriends(); } - else if(mTryToConnectToFbc) + else if(mTryToConnectToFacebook) { LLFacebookConnect::instance().checkConnectionToFacebook(); - mTryToConnectToFbc = false; + mTryToConnectToFacebook = false; } updateSuggestedFriendList(); diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h index c7141f36ee..67e190dafd 100755 --- a/indra/newview/llpanelpeople.h +++ b/indra/newview/llpanelpeople.h @@ -56,7 +56,7 @@ public: // when voice is available /*virtual*/ void onChange(EStatusType status, const std::string &channelURI, bool proximal); - bool mTryToConnectToFbc; + bool mTryToConnectToFacebook; // internals class Updater; diff --git a/indra/newview/skins/default/xui/en/floater_facebook.xml b/indra/newview/skins/default/xui/en/floater_facebook.xml index c1ff8571e9..544c443c76 100644 --- a/indra/newview/skins/default/xui/en/floater_facebook.xml +++ b/indra/newview/skins/default/xui/en/floater_facebook.xml @@ -48,13 +48,19 @@ follows="all" label="CHECK IN" name="panel_facebook_place"/> + - + name="panel_facebook_account"/> + + + + + + + -- cgit v1.2.3