From a3219972a035cc2d7fea8d9f59860a9262f4235c Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Thu, 30 Jun 2011 22:30:08 -0700 Subject: Created new window for selectively clearing different parts of the cache from disk --- linden/indra/newview/CMakeLists.txt | 2 + linden/indra/newview/app_settings/cmd_line.xml | 2 +- linden/indra/newview/app_settings/settings.xml | 71 +++++++++++++--- linden/indra/newview/floatercache.cpp | 97 ++++++++++++++++++++++ linden/indra/newview/floatercache.h | 50 +++++++++++ linden/indra/newview/llappviewer.cpp | 64 ++++++++++++-- linden/indra/newview/llpanelnetwork.cpp | 6 +- .../default/xui/en-us/floater_clear_cache.xml | 28 +++++++ .../skins/default/xui/en-us/notifications.xml | 7 -- 9 files changed, 299 insertions(+), 28 deletions(-) create mode 100644 linden/indra/newview/floatercache.cpp create mode 100644 linden/indra/newview/floatercache.h create mode 100644 linden/indra/newview/skins/default/xui/en-us/floater_clear_cache.xml diff --git a/linden/indra/newview/CMakeLists.txt b/linden/indra/newview/CMakeLists.txt index 46da492..1b9f75a 100644 --- a/linden/indra/newview/CMakeLists.txt +++ b/linden/indra/newview/CMakeLists.txt @@ -78,6 +78,7 @@ set(viewer_SOURCE_FILES floaterao.cpp floaterbusy.cpp floatercommandline.cpp + floatercache.cpp floaterdice.cpp floatergriddefault.cpp floatergridmanager.cpp @@ -536,6 +537,7 @@ set(viewer_HEADER_FILES floaterao.h floaterbusy.h floatercommandline.h + floatercache.h floaterdice.h floatergriddefault.h floatergridmanager.h diff --git a/linden/indra/newview/app_settings/cmd_line.xml b/linden/indra/newview/app_settings/cmd_line.xml index f5c6cdb..9fd4669 100644 --- a/linden/indra/newview/app_settings/cmd_line.xml +++ b/linden/indra/newview/app_settings/cmd_line.xml @@ -157,7 +157,7 @@ desc Delete files in the cache. map-to - PurgeCacheOnNextStartup + PurgeCacheOnStartup noinvlib diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index eb59254..7d9a0ca 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -2571,6 +2571,66 @@ + + + + PurgeCacheOnStartup + + Comment + Clear local file cache every time viewer is run (cmd line --purge) + Persist + 1 + Type + Boolean + Value + 0 + + ClearTextureCache + + Comment + Clear texture cache + Persist + 1 + Type + Boolean + Value + 0 + + ClearObjectCache + + Comment + Clear object cache + Persist + 1 + Type + Boolean + Value + 0 + + ClearInvCache + + Comment + Clear inventory cache + Persist + 1 + Type + Boolean + Value + 0 + + ClearNameCache + + Comment + Clear cached avatar names/uuids + Persist + 1 + Type + Boolean + Value + 0 + + + @@ -9334,17 +9394,6 @@ Value 0 - PurgeCacheOnStartup - - Comment - Clear local file cache every time viewer is run - Persist - 1 - Type - Boolean - Value - 0 - PushToTalkButton Comment diff --git a/linden/indra/newview/floatercache.cpp b/linden/indra/newview/floatercache.cpp new file mode 100644 index 0000000..3d3091f --- /dev/null +++ b/linden/indra/newview/floatercache.cpp @@ -0,0 +1,97 @@ +/** +* @file floatercache.cpp +* @brief clear cache window for Imprudence +* +* $LicenseInfo:firstyear=2009&license=viewergpl$ +* +* Copyright (c) 2011, McCabe Maxsted +* +* Imprudence Viewer Source Code +* The source code in this file ("Source Code") is provided to you +* under the terms of the GNU General Public License, version 2.0 +* ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in +* this distribution, or online at +* http://secondlifegrid.net/programs/open_source/licensing/gplv2 +* +* There are special exceptions to the terms and conditions of the GPL as +* it is applied to this Source Code. View the full text of the exception +* in the file doc/FLOSS-exception.txt in this software distribution, or +* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception +* +* By copying, modifying or distributing this software, you acknowledge +* that you have read and understood your obligations described above, +* and agree to abide by those obligations. +* +* ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO +* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, +* COMPLETENESS OR PERFORMANCE. +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" + +#include "floatercache.h" + +#include "llcheckboxctrl.h" +#include "lluictrlfactory.h" + +#include "llviewercontrol.h" + + +FloaterCache::FloaterCache(const LLSD& seed) : LLFloater("Clear Cache") +{ + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_clear_cache.xml"); +} + +FloaterCache::~FloaterCache() +{ +} + +BOOL FloaterCache::postBuild() +{ + getChild("texture_cache")->setValue(gSavedSettings.getBOOL("ClearTextureCache")); + getChild("object_cache")->setValue(gSavedSettings.getBOOL("ClearObjectCache")); + getChild("inv_cache")->setValue(gSavedSettings.getBOOL("ClearInvCache")); + getChild("name_cache")->setValue(gSavedSettings.getBOOL("ClearNameCache")); + + childSetAction("btn_ok", onClickOK, this); + childSetAction("btn_cancel", onClickCancel, this); + + return TRUE; +} + +// static +void FloaterCache::onClickOK(void* data) +{ + FloaterCache* self = (FloaterCache*)data; + if (self) + { + bool purge_textures = self->getChild("texture_cache")->getValue().asBoolean(); + bool purge_objects = self->getChild("object_cache")->getValue().asBoolean(); + bool purge_inv = self->getChild("inv_cache")->getValue().asBoolean(); + bool purge_names = self->getChild("name_cache")->getValue().asBoolean(); + + gSavedSettings.setBOOL("ClearTextureCache", purge_textures); + gSavedSettings.setBOOL("ClearObjectCache", purge_objects); + gSavedSettings.setBOOL("ClearInvCache", purge_inv); + gSavedSettings.setBOOL("ClearNameCache", purge_names); + + if (purge_textures || purge_objects || purge_inv || purge_names) + { + // flag client cache for clearing next time the client runs + gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE); + } + + self->close(); + } +} + +// static +void FloaterCache::onClickCancel(void* data) +{ + FloaterCache* self = (FloaterCache*)data; + if (self) + { + self->close(); + } +} diff --git a/linden/indra/newview/floatercache.h b/linden/indra/newview/floatercache.h new file mode 100644 index 0000000..ea3c53e --- /dev/null +++ b/linden/indra/newview/floatercache.h @@ -0,0 +1,50 @@ +/** +* @file floatercache.h +* @brief clear cache window for Imprudence +* +* $LicenseInfo:firstyear=2009&license=viewergpl$ +* +* Copyright (c) 2011, McCabe Maxsted +* +* Imprudence Viewer Source Code +* The source code in this file ("Source Code") is provided to you +* under the terms of the GNU General Public License, version 2.0 +* ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in +* this distribution, or online at +* http://secondlifegrid.net/programs/open_source/licensing/gplv2 +* +* There are special exceptions to the terms and conditions of the GPL as +* it is applied to this Source Code. View the full text of the exception +* in the file doc/FLOSS-exception.txt in this software distribution, or +* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception +* +* By copying, modifying or distributing this software, you acknowledge +* that you have read and understood your obligations described above, +* and agree to abide by those obligations. +* +* ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO +* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, +* COMPLETENESS OR PERFORMANCE. +* $/LicenseInfo$ +*/ + +#ifndef floatercache_h +#define floatercache_h + +#include "llfloater.h" + +class FloaterCache : public LLFloater, public LLFloaterSingleton +{ +public: + + FloaterCache(const LLSD& seed); + virtual ~FloaterCache(); + BOOL postBuild(); + +private: + + static void onClickOK(void* data); + static void onClickCancel(void* data); +}; + +#endif //floatercache_h diff --git a/linden/indra/newview/llappviewer.cpp b/linden/indra/newview/llappviewer.cpp index c9ab291..2fab25b 100644 --- a/linden/indra/newview/llappviewer.cpp +++ b/linden/indra/newview/llappviewer.cpp @@ -2963,10 +2963,11 @@ bool LLAppViewer::initCache() { mPurgeCache = false; // Purge cache if user requested it - if (gSavedSettings.getBOOL("PurgeCacheOnStartup") || - gSavedSettings.getBOOL("PurgeCacheOnNextStartup")) + if (gSavedSettings.getBOOL("PurgeCacheOnStartup") || // cmd-line -- MC + gSavedSettings.getBOOL("PurgeCacheOnNextStartup")) // ui -- MC { gSavedSettings.setBOOL("PurgeCacheOnNextStartup", false); + gSavedSettings.setBOOL("PurgeCacheOnStartup", FALSE); mPurgeCache = true; } // Purge cache if it belongs to an old version @@ -3175,10 +3176,61 @@ bool LLAppViewer::initCache() void LLAppViewer::purgeCache() { - LL_INFOS("AppCache") << "Purging Cache and Texture Cache..." << llendl; - LLAppViewer::getTextureCache()->purgeCache(LL_PATH_CACHE); - std::string mask = gDirUtilp->getDirDelimiter() + "*.*"; - gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""),mask); + LL_INFOS("AppCache") << "Begin purging cachees..." << llendl; + if (gSavedSettings.getBOOL("PurgeCacheOnStartup")) // purging from cmd line + { + LLAppViewer::getTextureCache()->purgeCache(LL_PATH_CACHE); + std::string mask = gDirUtilp->getDirDelimiter() + "*.*"; + gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""), mask); + } + else // purging cache from ui + { + if (gSavedSettings.getBOOL("ClearTextureCache")) + { + LLAppViewer::getTextureCache()->purgeCache(LL_PATH_CACHE); + gSavedSettings.setBOOL("ClearTextureCache", FALSE); + } + + if (gSavedSettings.getBOOL("ClearObjectCache")) + { + std::string mask = gDirUtilp->getDirDelimiter() + "*.slc"; + gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""), mask); + gSavedSettings.setBOOL("ClearObjectCache", FALSE); + } + + if (gSavedSettings.getBOOL("ClearInvCache")) + { + std::vector masks; + masks.push_back(gDirUtilp->getDirDelimiter() + "*.inv.gz"); + masks.push_back(gDirUtilp->getDirDelimiter() + VFS_DATA_FILE_BASE + "*"); + masks.push_back(gDirUtilp->getDirDelimiter() + VFS_INDEX_FILE_BASE + "*"); + + for (std::vector::iterator vIt = masks.begin(); + vIt != masks.end(); ++vIt) + { + gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""), (*vIt)); + } + + gSavedSettings.setBOOL("ClearInvCache", FALSE); + } + + if (gSavedSettings.getBOOL("ClearNameCache")) + { + // ick @ not making these variables -- MC + std::vector masks; + masks.push_back(gDirUtilp->getDirDelimiter() + "name.cache"); + masks.push_back(gDirUtilp->getDirDelimiter() + "avatar_name_cache.xml"); + masks.push_back(gDirUtilp->getDirDelimiter() + "*.cached_mute"); + + for (std::vector::iterator vIt = masks.begin(); + vIt != masks.end(); ++vIt) + { + gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""), (*vIt)); + } + + gSavedSettings.setBOOL("ClearNameCache", FALSE); + } + } } const std::string& LLAppViewer::getSecondLifeTitle() const diff --git a/linden/indra/newview/llpanelnetwork.cpp b/linden/indra/newview/llpanelnetwork.cpp index b4ebe42..70d88d9 100644 --- a/linden/indra/newview/llpanelnetwork.cpp +++ b/linden/indra/newview/llpanelnetwork.cpp @@ -45,6 +45,7 @@ #include "llviewerwindow.h" // project includes +#include "floatercache.h" #include "llcheckboxctrl.h" #include "hippogridmanager.h" #include "lluictrlfactory.h" @@ -267,9 +268,8 @@ void LLPanelNetwork::refresh() // static void LLPanelNetwork::onClickClearDiskCache(void*) { - // flag client cache for clearing next time the client runs - gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE); - LLNotifications::instance().add("CacheWillClear"); + FloaterCache::getInstance()->open(); + FloaterCache::getInstance()->center(); } // static diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_clear_cache.xml b/linden/indra/newview/skins/default/xui/en-us/floater_clear_cache.xml new file mode 100644 index 0000000..e965b28 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/en-us/floater_clear_cache.xml @@ -0,0 +1,28 @@ + + + +Cache Will Be Cleared After +You Restart Imprudence + + + + + +