Implemented major task EXT-2022 (Show profile online status for non-friend avatar too.)

- imlemented like in viewer 1.23 behavior: show Online status according to avatar properties requested from server.

--HG--
branch : product-engine
meow-7.2.2
Mike Antipov 2009-10-30 19:30:23 +02:00
parent b2526cde23
commit 73efd4802b
2 changed files with 54 additions and 5 deletions

View File

@ -32,10 +32,12 @@
#include "llviewerprecompiledheaders.h"
#include "llavatarconstants.h"
#include "lluserrelations.h"
#include "llpanelprofileview.h"
#include "llavatarpropertiesprocessor.h"
#include "llcallingcard.h"
#include "llpanelavatar.h"
#include "llpanelpicks.h"
@ -48,14 +50,46 @@ static std::string PANEL_NOTES = "panel_notes";
static const std::string PANEL_PROFILE = "panel_profile";
static const std::string PANEL_PICKS = "panel_picks";
class AvatarStatusObserver : public LLAvatarPropertiesObserver
{
public:
AvatarStatusObserver(LLPanelProfileView* profile_view)
{
mProfileView = profile_view;
}
void processProperties(void* data, EAvatarProcessorType type)
{
if(APT_PROPERTIES != type) return;
const LLAvatarData* avatar_data = static_cast<const LLAvatarData*>(data);
if(avatar_data && mProfileView->getAvatarId() == avatar_data->avatar_id)
{
mProfileView->processOnlineStatus(avatar_data->flags & AVATAR_ONLINE);
LLAvatarPropertiesProcessor::instance().removeObserver(mProfileView->getAvatarId(), this);
}
}
void subscribe()
{
LLAvatarPropertiesProcessor::instance().addObserver(mProfileView->getAvatarId(), this);
}
private:
LLPanelProfileView* mProfileView;
};
LLPanelProfileView::LLPanelProfileView()
: LLPanelProfile()
, mStatusText(NULL)
, mAvatarStatusObserver(NULL)
{
mAvatarStatusObserver = new AvatarStatusObserver(this);
}
LLPanelProfileView::~LLPanelProfileView(void)
{
delete mAvatarStatusObserver;
}
/*virtual*/
@ -66,6 +100,9 @@ void LLPanelProfileView::onOpen(const LLSD& key)
{
id = key["id"];
}
// subscribe observer to get online status. Request will be sent by LLPanelAvatarProfile itself
mAvatarStatusObserver->subscribe();
if(id.notNull() && getAvatarId() != id)
{
setAvatarId(id);
@ -74,10 +111,12 @@ void LLPanelProfileView::onOpen(const LLSD& key)
// Update the avatar name.
gCacheName->get(getAvatarId(), FALSE,
boost::bind(&LLPanelProfileView::onAvatarNameCached, this, _1, _2, _3, _4));
/*
// disable this part of code according to EXT-2022. See processOnlineStatus
// status should only show if viewer has permission to view online/offline. EXT-453
mStatusText->setVisible(isGrantedToSeeOnlineStatus());
updateOnlineStatus();
*/
LLPanelProfile::onOpen(key);
}
@ -93,6 +132,7 @@ BOOL LLPanelProfileView::postBuild()
getTabContainer()[PANEL_PROFILE]->childSetVisible("status_combo", FALSE);
mStatusText = getChild<LLTextBox>("status");
mStatusText->setVisible(false);
childSetCommitCallback("back",boost::bind(&LLPanelProfileView::onBackBtnClick,this),NULL);
@ -135,13 +175,18 @@ void LLPanelProfileView::updateOnlineStatus()
return;
bool online = relationship->isOnline();
// std::string statusName();
std::string status = getString(online ? "status_online" : "status_offline");
mStatusText->setValue(status);
}
void LLPanelProfileView::processOnlineStatus(bool online)
{
mAvatarIsOnline = online;
mStatusText->setVisible(online);
}
void LLPanelProfileView::onAvatarNameCached(const LLUUID& id, const std::string& first_name, const std::string& last_name, BOOL is_group)
{
llassert(getAvatarId() == id);
@ -155,7 +200,7 @@ void LLPanelProfileView::togglePanel(LLPanel* panel)
{
// LLPanelProfile::togglePanel shows/hides all children,
// we don't want to display online status for non friends, so re-hide it here
mStatusText->setVisible(isGrantedToSeeOnlineStatus());
mStatusText->setVisible(mAvatarIsOnline);
}
}

View File

@ -49,6 +49,7 @@ class LLPanelProfileView : public LLPanelProfile
{
LOG_CLASS(LLPanelProfileView);
friend class LLUICtrlFactory;
friend class AvatarStatusObserver;
public:
@ -65,8 +66,9 @@ public:
protected:
void onBackBtnClick();
bool isGrantedToSeeOnlineStatus();
void updateOnlineStatus();
bool isGrantedToSeeOnlineStatus(); // deprecated after EXT-2022 is implemented
void updateOnlineStatus(); // deprecated after EXT-2022 is implemented
void processOnlineStatus(bool online);
private:
// LLCacheName will call this function when avatar name is loaded from server.
@ -78,6 +80,8 @@ private:
BOOL is_group);
LLTextBox* mStatusText;
AvatarStatusObserver* mAvatarStatusObserver;
bool mAvatarIsOnline;
};
#endif //LL_LLPANELPROFILEVIEW_H