summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/llpanelprofileview.cpp51
-rw-r--r--indra/newview/llpanelprofileview.h8
2 files changed, 54 insertions, 5 deletions
diff --git a/indra/newview/llpanelprofileview.cpp b/indra/newview/llpanelprofileview.cpp
index 1d16c4ef5e..d4ab5013f9 100644
--- a/indra/newview/llpanelprofileview.cpp
+++ b/indra/newview/llpanelprofileview.cpp
@@ -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);
}
}
diff --git a/indra/newview/llpanelprofileview.h b/indra/newview/llpanelprofileview.h
index 07a6c3a9a0..e89ed07b53 100644
--- a/indra/newview/llpanelprofileview.h
+++ b/indra/newview/llpanelprofileview.h
@@ -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