From 0a4ab0c64790b82edba369891a1983cd4b7f84f2 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Mon, 1 Apr 2013 23:08:16 -0700 Subject: Some not so clean code to use to show facebook friends using the existing avatar list. --- indra/newview/llavatarlist.cpp | 36 +++++++++++++++++++++ indra/newview/llavatarlist.h | 27 +++++++++++++--- indra/newview/llpanelpeople.cpp | 37 ++++------------------ indra/newview/llpanelpeople.h | 2 ++ .../newview/skins/default/xui/en/panel_people.xml | 36 +++++++++++++++++---- 5 files changed, 96 insertions(+), 42 deletions(-) diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp index 771419f60a..37de2d5793 100644 --- a/indra/newview/llavatarlist.cpp +++ b/indra/newview/llavatarlist.cpp @@ -624,3 +624,39 @@ void LLAvalineListItem::setName(const std::string& name) LLAvatarListItem::setAvatarToolTip(formatted_phone); } } + +/************************************************************************/ +/* class LLAvatarListSocial */ +/************************************************************************/ + +static LLDefaultChildRegistry::Register s("avatar_list_social"); + +LLAvatarListSocial::LLAvatarListSocial(const Params& p) : LLAvatarList(p) +{ + +} + +void LLAvatarListSocial::addSocialItem(const LLUUID& id, const std::string& name, BOOL is_online, EAddPosition pos) +{ + LLAvatarListItem* item = new LLAvatarListItem(); + // This sets the name as a side effect + item->setAvatarId(id, mSessionID, mIgnoreOnlineStatus, false); + item->setAvatarName(name); + item->setOnline(mIgnoreOnlineStatus ? true : is_online); + item->showLastInteractionTime(mShowLastInteractionTime); + + item->setAvatarIconVisible(mShowIcons); + item->setShowInfoBtn(mShowInfoBtn); + item->setShowProfileBtn(mShowProfileBtn); + item->showSpeakingIndicator(mShowSpeakingIndicator); + item->setShowPermissions(mShowPermissions); + + item->setDoubleClickCallback(boost::bind(&LLAvatarListSocial::onItemDoubleClicked, this, _1, _2, _3, _4)); + + addItem(item, id, pos); +} + +void LLAvatarListSocial::refresh() +{ + +} diff --git a/indra/newview/llavatarlist.h b/indra/newview/llavatarlist.h index 4814a88a79..cbe5956493 100644 --- a/indra/newview/llavatarlist.h +++ b/indra/newview/llavatarlist.h @@ -97,10 +97,12 @@ public: void addAvalineItem(const LLUUID& item_id, const LLUUID& session_id, const std::string& item_name); void handleDisplayNamesOptionChanged(); -protected: - void refresh(); + - void addNewItem(const LLUUID& id, const std::string& name, BOOL is_online, EAddPosition pos = ADD_BOTTOM); +protected: + virtual void refresh(); + virtual void addNewItem(const LLUUID& id, const std::string& name, BOOL is_online, EAddPosition pos = ADD_BOTTOM); + void computeDifference( const uuid_vec_t& vnew, uuid_vec_t& vadded, @@ -110,8 +112,6 @@ protected: void onItemDoubleClicked(LLUICtrl* ctrl, S32 x, S32 y, MASK mask); void updateAvatarNames(); -private: - bool isAvalineItemSelected(); bool mIgnoreOnlineStatus; @@ -205,4 +205,21 @@ private: bool mIsHideNumber; }; +class LLAvatarListSocial : public LLAvatarList +{ + public: + struct Params : public LLInitParam::Block + { + + }; + + LLAvatarListSocial(const Params&); + + void addSocialItem(const LLUUID& id, const std::string& name, BOOL is_online, EAddPosition pos = ADD_BOTTOM); + + protected: + /*virtual*/ void refresh(); +}; + + #endif // LL_LLAVATARLIST_H diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index 01d68cb9a0..7a3e6abb7f 100644 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -647,7 +647,9 @@ BOOL LLPanelPeople::postBuild() mAllFriendList->setContextMenu(&LLPanelPeopleMenus::gNearbyMenu); mOnlineFriendList->setContextMenu(&LLPanelPeopleMenus::gNearbyMenu); - mFbcTestText = getChild(FBCTEST_TAB_NAME)->getChild("fbctest_label"); + LLPanel * social_tab = getChild(FBCTEST_TAB_NAME); + social_tab->setVisibleCallback(boost::bind(&Updater::setActive, mFbcTestListUpdater, _2)); + mFacebookFriends = social_tab->getChild("facebook_friends"); setSortOrder(mRecentList, (ESortOrder)gSavedSettings.getU32("RecentPeopleSortOrder"), false); setSortOrder(mAllFriendList, (ESortOrder)gSavedSettings.getU32("FriendsSortOrder"), false); @@ -883,35 +885,10 @@ void LLPanelPeople::updateRecentList() void LLPanelPeople::updateFbcTestList() { - if (!mFbcTestText) - return; - - if (mFbcTestBrowserHandle.get()) - { - // get the browser data (from the title bar, of course!) - std::string title = mFbcTestBrowserHandle.get()->getTitle(); - - // if the data is ready (if it says the magic word) - if (title.length() >= 2 && title[0] == ':') - { - // success! :) - if (title[1] == ')') - { - mFbcTestText->setText(std::string("okay, now we can get the list of friends!")); - } - // failure :( - else if (title[1] == '(') - { - mFbcTestText->setText(std::string("hmm, the authentication failed somehow")); - } - - // close the browser window - mFbcTestBrowserHandle.get()->die(); - - // stop updating - mFbcTestListUpdater->setActive(false); - } - } + mFacebookFriends->addSocialItem(LLUUID(), "TEST", false); + + // stop updating + mFbcTestListUpdater->setActive(false); } void LLPanelPeople::buttonSetVisible(std::string btn_name, BOOL visible) diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h index dadd273603..a00b5be516 100644 --- a/indra/newview/llpanelpeople.h +++ b/indra/newview/llpanelpeople.h @@ -34,6 +34,7 @@ #include "llvoiceclient.h" class LLAvatarList; +class LLAvatarListSocial; class LLAvatarName; class LLFilterEditor; class LLGroupList; @@ -149,6 +150,7 @@ private: LLAvatarList* mNearbyList; LLAvatarList* mRecentList; LLGroupList* mGroupList; + LLAvatarListSocial* mFacebookFriends; LLNetMap* mMiniMap; LLTextBox* mFbcTestText; diff --git a/indra/newview/skins/default/xui/en/panel_people.xml b/indra/newview/skins/default/xui/en/panel_people.xml index cbb6aff4ea..f3334fd767 100644 --- a/indra/newview/skins/default/xui/en/panel_people.xml +++ b/indra/newview/skins/default/xui/en/panel_people.xml @@ -585,14 +585,36 @@ Looking for people to hang out with? Try the [secondlife:///app/worldmap World M name="fbctest_panel" top="0" width="313"> - + + height="172" + min_height="150" + name="tab_facebook" + title="Facebook Friends"> + + +