summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2009-10-14 20:28:07 +0000
committerSteven Bennetts <steve@lindenlab.com>2009-10-14 20:28:07 +0000
commit7475ec05fc81e358a6979f3e9d7050ab91511c57 (patch)
tree6f8f3f6f02cf41e45827c37fb9a3970780851865 /indra
parentfd312d1929de708e5765cf1b3815cb61752fc355 (diff)
merge -r 2005-2011 https://svn.aws.productengine.com/secondlife/pe/stable-2 -> viewer-2.0.0-3
* Bugs: EXT-1472 EXT-996
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llappviewer.cpp4
-rw-r--r--indra/newview/llavatariconctrl.cpp121
-rw-r--r--indra/newview/llavatariconctrl.h42
-rw-r--r--indra/newview/llpanelteleporthistory.cpp4
-rw-r--r--indra/newview/llstartup.cpp4
-rw-r--r--indra/newview/skins/default/xui/en/floater_im_session.xml8
-rw-r--r--indra/newview/skins/default/xui/en/panel_group_control_panel.xml54
7 files changed, 172 insertions, 65 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 785179f7b3..c673db2034 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -179,6 +179,7 @@
#include "llimview.h"
#include "llviewerthrottle.h"
#include "llparcel.h"
+#include "llavatariconctrl.h"
// *FIX: These extern globals should be cleaned up.
// The globals either represent state/config/resource-storage of either
@@ -1467,6 +1468,9 @@ bool LLAppViewer::cleanup()
sImageDecodeThread = NULL;
LLLocationHistory::getInstance()->save();
+
+ LLAvatarIconIDCache::getInstance()->save();
+
delete mFastTimerLogThread;
mFastTimerLogThread = NULL;
diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp
index 1d5fa9ffa7..3e411583ac 100644
--- a/indra/newview/llavatariconctrl.cpp
+++ b/indra/newview/llavatariconctrl.cpp
@@ -50,7 +50,94 @@
static LLDefaultChildRegistry::Register<LLAvatarIconCtrl> r("avatar_icon");
-LLAvatarIconCtrl::avatar_image_map_t LLAvatarIconCtrl::sImagesCache;
+bool LLAvatarIconIDCache::LLAvatarIconIDCacheItem::expired()
+{
+ const F64 SEC_PER_DAY_PLUS_HOUR = (24.0 + 1.0) * 60.0 * 60.0;
+ F64 delta = LLDate::now().secondsSinceEpoch() - cached_time.secondsSinceEpoch();
+ if (delta > SEC_PER_DAY_PLUS_HOUR)
+ return true;
+ return false;
+}
+
+void LLAvatarIconIDCache::load ()
+{
+ llinfos << "Loading avatar icon id cache." << llendl;
+
+ // build filename for each user
+ std::string resolved_filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, mFilename);
+ llifstream file(resolved_filename);
+
+ if (!file.is_open())
+ return;
+
+ // add each line in the file to the list
+ int uuid_len = UUID_STR_LENGTH-1;
+ std::string line;
+ while (std::getline(file, line))
+ {
+ LLUUID avatar_id;
+ LLUUID icon_id;
+ LLDate date;
+
+ std::string avatar_id_str = line.substr(0,uuid_len);
+ std::string icon_id_str = line.substr(uuid_len,uuid_len);
+
+ std::string date_str = line.substr(uuid_len*2, line.length()-uuid_len*2);
+
+ if(!avatar_id.set(avatar_id_str) || !icon_id.set(icon_id_str) || !date.fromString(date_str))
+ continue;
+
+ LLAvatarIconIDCacheItem item = {icon_id,date};
+ mCache[avatar_id] = item;
+ }
+
+ file.close();
+
+}
+
+void LLAvatarIconIDCache::save ()
+{
+ std::string resolved_filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, mFilename);
+
+ // open a file for writing
+ llofstream file (resolved_filename);
+ if (!file.is_open())
+ {
+ llwarns << "can't open avatar icons cache file\"" << mFilename << "\" for writing" << llendl;
+ return;
+ }
+
+ for(std::map<LLUUID,LLAvatarIconIDCacheItem>::iterator it = mCache.begin();it!=mCache.end();++it)
+ {
+ if(!it->second.expired())
+ {
+ file << it->first << it->second.icon_id << it->second.cached_time << std::endl;
+ }
+ }
+
+ file.close();
+}
+
+LLUUID* LLAvatarIconIDCache::get (const LLUUID& avatar_id)
+{
+ std::map<LLUUID,LLAvatarIconIDCacheItem>::iterator it = mCache.find(avatar_id);
+ if(it==mCache.end())
+ return 0;
+ if(it->second.expired())
+ return 0;
+ return &it->second.icon_id;
+}
+
+void LLAvatarIconIDCache::add (const LLUUID& avatar_id,const LLUUID& icon_id)
+{
+ LLAvatarIconIDCacheItem item = {icon_id,LLDate::now()};
+ mCache[avatar_id] = item;
+}
+
+void LLAvatarIconIDCache::remove (const LLUUID& avatar_id)
+{
+ mCache.erase(avatar_id);
+}
LLAvatarIconCtrl::Params::Params()
@@ -161,18 +248,13 @@ void LLAvatarIconCtrl::setValue(const LLSD& value)
// an avatar.
// Check if cache already contains image_id for that avatar
- avatar_image_map_t::iterator it = sImagesCache.find(mAvatarId);
- if (it != sImagesCache.end())
- {
- updateFromCache(it->second);
- }
- else
+
+ if (!updateFromCache())
{
- app->addObserver(value.asUUID(), this);
- app->sendAvatarPropertiesRequest(value.asUUID());
+ app->addObserver(mAvatarId, this);
+ app->sendAvatarPropertiesRequest(mAvatarId);
}
}
-
}
else
{
@@ -182,12 +264,18 @@ void LLAvatarIconCtrl::setValue(const LLSD& value)
gCacheName->get(mAvatarId, FALSE, boost::bind(&LLAvatarIconCtrl::nameUpdatedCallback, this, _1, _2, _3, _4));
}
-void LLAvatarIconCtrl::updateFromCache(LLAvatarIconCtrl::LLImagesCacheItem data)
+bool LLAvatarIconCtrl::updateFromCache()
{
+ LLUUID* icon_id_ptr = LLAvatarIconIDCache::getInstance()->get(mAvatarId);
+ if(!icon_id_ptr)
+ return false;
+
+ const LLUUID& icon_id = *icon_id_ptr;
+
// Update the avatar
- if (data.image_id.notNull())
+ if (icon_id.notNull())
{
- LLIconCtrl::setValue(data.image_id);
+ LLIconCtrl::setValue(icon_id);
}
else
{
@@ -224,6 +312,7 @@ void LLAvatarIconCtrl::updateFromCache(LLAvatarIconCtrl::LLImagesCacheItem data)
setToolTip((LLStringExplicit)"");
}
}
+ return true;
}
//virtual
@@ -239,10 +328,8 @@ void LLAvatarIconCtrl::processProperties(void* data, EAvatarProcessorType type)
return;
}
- LLAvatarIconCtrl::LLImagesCacheItem data(avatar_data->image_id, avatar_data->flags);
-
- updateFromCache(data);
- sImagesCache.insert(std::pair<LLUUID, LLAvatarIconCtrl::LLImagesCacheItem>(mAvatarId, data));
+ LLAvatarIconIDCache::getInstance()->add(mAvatarId,avatar_data->image_id);
+ updateFromCache();
}
}
}
diff --git a/indra/newview/llavatariconctrl.h b/indra/newview/llavatariconctrl.h
index 49e304a521..77390eb233 100644
--- a/indra/newview/llavatariconctrl.h
+++ b/indra/newview/llavatariconctrl.h
@@ -37,6 +37,35 @@
#include "llavatarpropertiesprocessor.h"
#include "llviewermenu.h"
+class LLAvatarIconIDCache: public LLSingleton<LLAvatarIconIDCache>
+{
+public:
+ struct LLAvatarIconIDCacheItem
+ {
+ LLUUID icon_id;
+ LLDate cached_time;
+
+ bool expired();
+ };
+
+ LLAvatarIconIDCache():mFilename("avatar_icons_cache.txt")
+ {
+ }
+
+ void load ();
+ void save ();
+
+ LLUUID* get (const LLUUID& id);
+ void add (const LLUUID& avatar_id,const LLUUID& icon_id);
+
+ void remove (const LLUUID& id);
+protected:
+
+
+ std::string mFilename;
+ std::map<LLUUID,LLAvatarIconIDCacheItem> mCache;//we cache only LLUID and time
+};
+
class LLAvatarIconCtrl
: public LLIconCtrl, public LLAvatarPropertiesObserver
{
@@ -82,19 +111,8 @@ protected:
LLHandle<LLView> mPopupMenuHandle;
bool mDrawTooltip;
- struct LLImagesCacheItem
- {
- LLUUID image_id;
- U32 flags;
-
- LLImagesCacheItem(LLUUID image_id_, U32 flags_) : image_id(image_id_), flags(flags_) {}
- };
-
- typedef std::map<LLUUID, LLAvatarIconCtrl::LLImagesCacheItem> avatar_image_map_t;
-
- static avatar_image_map_t sImagesCache;
- void updateFromCache(LLAvatarIconCtrl::LLImagesCacheItem data);
+ bool updateFromCache();
};
#endif // LL_LLAVATARICONCTRL_H
diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp
index e71ddfb283..e1e3fe4677 100644
--- a/indra/newview/llpanelteleporthistory.cpp
+++ b/indra/newview/llpanelteleporthistory.cpp
@@ -420,7 +420,7 @@ void LLTeleportHistoryPanel::showTeleportHistory()
S32 index = hist_items.size() - 1;
for (LLTeleportHistoryStorage::slurl_list_t::const_reverse_iterator iter = hist_items.rbegin();
- iter != hist_items.rend(); ++iter)
+ iter != hist_items.rend(); ++iter, --index)
{
std::string landmark_title = (*iter).mTitle;
LLStringUtil::toUpper(landmark_title);
@@ -496,8 +496,6 @@ void LLTeleportHistoryPanel::showTeleportHistory()
{
curr_flat_view->addItem(new LLTeleportHistoryFlatItem(index, &mContextMenu, (*iter).mTitle));
}
-
- index--;
}
// Hide empty tabs from current to bottom
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 9cd3acf13e..45763dd8a7 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -189,6 +189,7 @@
#include "llwearable.h"
#include "llinventorybridge.h"
#include "llappearancemgr.h"
+#include "llavatariconctrl.h"
#if LL_WINDOWS
#include "llwindebug.h"
@@ -1021,6 +1022,9 @@ bool idle_startup()
// Load location history
LLLocationHistory::getInstance()->load();
+ // Load Avatars icons cache
+ LLAvatarIconIDCache::getInstance()->load();
+
//-------------------------------------------------
// Handle startup progress screen
//-------------------------------------------------
diff --git a/indra/newview/skins/default/xui/en/floater_im_session.xml b/indra/newview/skins/default/xui/en/floater_im_session.xml
index 0921ccfb95..611c51ad11 100644
--- a/indra/newview/skins/default/xui/en/floater_im_session.xml
+++ b/indra/newview/skins/default/xui/en/floater_im_session.xml
@@ -11,10 +11,10 @@
can_dock="true"
can_minimize="true"
visible="true"
- width="315">
+ width="365">
<layout_stack follows="left|top|right|bottom"
height="235"
- width="315"
+ width="365"
layout="topleft"
orientation="horizontal"
name="im_panels"
@@ -25,13 +25,13 @@
layout="topleft"
top_delta="-3"
min_width="96"
- width="96"
+ width="146"
height="225"
label="IM Control Panel"
user_resize="false" />
<layout_panel height="235"
width="200"
- left_delta="96"
+ left_delta="146"
top="0"
user_resize="false">
<button height="12"
diff --git a/indra/newview/skins/default/xui/en/panel_group_control_panel.xml b/indra/newview/skins/default/xui/en/panel_group_control_panel.xml
index a9363df259..be38492c82 100644
--- a/indra/newview/skins/default/xui/en/panel_group_control_panel.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_control_panel.xml
@@ -1,31 +1,27 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<panel name="panel_im_control_panel"
- width="96"
- height="215"
- border="false">
- <avatar_list
- width="90"
- column_padding="0"
- draw_heading="true"
- draw_stripes="false"
- follows="left|top|bottom|right"
- layout="topleft"
- left="3"
- name="speakers_list"
- search_column="1"
- sort_column="2"
- top="10"
- height="150" />
-
- <button name="group_info_btn"
- label="Group Info"
- left_delta="3"
- width="90"
- height="20" />
-
- <button name="call_btn"
- label="Call"
- width="90"
- height="20" />
-
+<panel
+ name="panel_im_control_panel"
+ width="146"
+ height="215"
+ border="false">
+ <avatar_list_tmp
+ color="DkGray2"
+ follows="left|top|right|bottom"
+ height="150"
+ layout="topleft"
+ left="3"
+ name="speakers_list"
+ top="10"
+ width="140"/>
+ <button
+ name="group_info_btn"
+ label="Group Info"
+ left_delta="3"
+ width="90"
+ height="20" />
+ <button
+ name="call_btn"
+ label="Call"
+ width="90"
+ height="20" />
</panel>