aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llinventorymodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llinventorymodel.cpp')
-rw-r--r--linden/indra/newview/llinventorymodel.cpp68
1 files changed, 54 insertions, 14 deletions
diff --git a/linden/indra/newview/llinventorymodel.cpp b/linden/indra/newview/llinventorymodel.cpp
index 7864aa8..e35f71b 100644
--- a/linden/indra/newview/llinventorymodel.cpp
+++ b/linden/indra/newview/llinventorymodel.cpp
@@ -47,6 +47,7 @@
47#include "llmutelist.h" 47#include "llmutelist.h"
48#include "llnotify.h" 48#include "llnotify.h"
49#include "llcallbacklist.h" 49#include "llcallbacklist.h"
50#include "llpreview.h"
50#include <deque> 51#include <deque>
51 52
52//#define DIFF_INVENTORY_FILES 53//#define DIFF_INVENTORY_FILES
@@ -1150,11 +1151,11 @@ void LLInventoryModel::cache(
1150 items, 1151 items,
1151 INCLUDE_TRASH, 1152 INCLUDE_TRASH,
1152 can_cache); 1153 can_cache);
1153 char agent_id_str[UUID_STR_LENGTH]; 1154 char agent_id_str[UUID_STR_LENGTH]; /*Flawfinder: ignore*/
1154 char inventory_filename[LL_MAX_PATH]; 1155 char inventory_filename[LL_MAX_PATH]; /*Flawfinder: ignore*/
1155 agent_id.toString(agent_id_str); 1156 agent_id.toString(agent_id_str);
1156 std::string path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, agent_id_str)); 1157 std::string path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, agent_id_str));
1157 snprintf( 1158 snprintf( /*Flawfinder: ignore*/
1158 inventory_filename, 1159 inventory_filename,
1159 LL_MAX_PATH, 1160 LL_MAX_PATH,
1160 CACHE_FORMAT_STRING, 1161 CACHE_FORMAT_STRING,
@@ -1439,11 +1440,11 @@ bool LLInventoryModel::loadSkeleton(
1439 { 1440 {
1440 cat_array_t categories; 1441 cat_array_t categories;
1441 item_array_t items; 1442 item_array_t items;
1442 char owner_id_str[UUID_STR_LENGTH]; 1443 char owner_id_str[UUID_STR_LENGTH]; /*Flawfinder: ignore*/
1443 owner_id.toString(owner_id_str); 1444 owner_id.toString(owner_id_str);
1444 std::string path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, owner_id_str)); 1445 std::string path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, owner_id_str));
1445 char inventory_filename[LL_MAX_PATH]; 1446 char inventory_filename[LL_MAX_PATH]; /*Flawfinder: ignore*/
1446 snprintf( 1447 snprintf( /*Flawfinder: ignore*/
1447 inventory_filename, 1448 inventory_filename,
1448 LL_MAX_PATH, 1449 LL_MAX_PATH,
1449 CACHE_FORMAT_STRING, 1450 CACHE_FORMAT_STRING,
@@ -1451,7 +1452,7 @@ bool LLInventoryModel::loadSkeleton(
1451 const S32 NO_VERSION = LLViewerInventoryCategory::VERSION_UNKNOWN; 1452 const S32 NO_VERSION = LLViewerInventoryCategory::VERSION_UNKNOWN;
1452 std::string gzip_filename(inventory_filename); 1453 std::string gzip_filename(inventory_filename);
1453 gzip_filename.append(".gz"); 1454 gzip_filename.append(".gz");
1454 FILE* fp = LLFile::fopen(gzip_filename.c_str(), "rb"); 1455 FILE* fp = LLFile::fopen(gzip_filename.c_str(), "rb"); /*Flawfinder: ignore*/
1455 bool remove_inventory_file = false; 1456 bool remove_inventory_file = false;
1456 if(fp) 1457 if(fp)
1457 { 1458 {
@@ -1959,19 +1960,24 @@ bool LLInventoryModel::loadFromFile(
1959 LLInventoryModel::cat_array_t& categories, 1960 LLInventoryModel::cat_array_t& categories,
1960 LLInventoryModel::item_array_t& items) 1961 LLInventoryModel::item_array_t& items)
1961{ 1962{
1963 if(!filename)
1964 {
1965 llerrs << "Filename is Null!" << llendl;
1966 return false;
1967 }
1962 llinfos << "LLInventoryModel::loadFromFile(" << filename << ")" << llendl; 1968 llinfos << "LLInventoryModel::loadFromFile(" << filename << ")" << llendl;
1963 FILE* file = LLFile::fopen(filename, "rb"); 1969 FILE* file = LLFile::fopen(filename, "rb"); /*Flawfinder: ignore*/
1964 if(!file) 1970 if(!file)
1965 { 1971 {
1966 llinfos << "unable to load inventory from: " << filename << llendl; 1972 llinfos << "unable to load inventory from: " << filename << llendl;
1967 return false; 1973 return false;
1968 } 1974 }
1969 // *NOTE: This buffer size is hard coded into scanf() below. 1975 // *NOTE: This buffer size is hard coded into scanf() below.
1970 char buffer[MAX_STRING]; 1976 char buffer[MAX_STRING]; /*Flawfinder: ignore*/
1971 char keyword[MAX_STRING]; 1977 char keyword[MAX_STRING]; /*Flawfinder: ignore*/
1972 while(!feof(file) && fgets(buffer, MAX_STRING, file)) 1978 while(!feof(file) && fgets(buffer, MAX_STRING, file))
1973 { 1979 {
1974 sscanf(buffer, " %254s", keyword); 1980 sscanf(buffer, " %254s", keyword); /* Flawfinder: ignore */
1975 if(0 == strcmp("inv_category", keyword)) 1981 if(0 == strcmp("inv_category", keyword))
1976 { 1982 {
1977 LLPointer<LLViewerInventoryCategory> inv_cat = new LLViewerInventoryCategory(LLUUID::null); 1983 LLPointer<LLViewerInventoryCategory> inv_cat = new LLViewerInventoryCategory(LLUUID::null);
@@ -2027,8 +2033,13 @@ bool LLInventoryModel::saveToFile(
2027 const cat_array_t& categories, 2033 const cat_array_t& categories,
2028 const item_array_t& items) 2034 const item_array_t& items)
2029{ 2035{
2036 if(!filename)
2037 {
2038 llerrs << "Filename is Null!" << llendl;
2039 return false;
2040 }
2030 llinfos << "LLInventoryModel::saveToFile(" << filename << ")" << llendl; 2041 llinfos << "LLInventoryModel::saveToFile(" << filename << ")" << llendl;
2031 FILE* file = LLFile::fopen(filename, "wb"); 2042 FILE* file = LLFile::fopen(filename, "wb"); /*Flawfinder: ignore*/
2032 if(!file) 2043 if(!file)
2033 { 2044 {
2034 llwarns << "unable to save inventory to: " << filename << llendl; 2045 llwarns << "unable to save inventory to: " << filename << llendl;
@@ -2304,6 +2315,8 @@ bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account, boo
2304 item_array_t items; 2315 item_array_t items;
2305 update_map_t update; 2316 update_map_t update;
2306 S32 count = msg->getNumberOfBlocksFast(_PREHASH_InventoryData); 2317 S32 count = msg->getNumberOfBlocksFast(_PREHASH_InventoryData);
2318 bool all_one_folder = true;
2319 LLUUID folder_id;
2307 for(S32 i = 0; i < count; ++i) 2320 for(S32 i = 0; i < count; ++i)
2308 { 2321 {
2309 LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem; 2322 LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
@@ -2330,6 +2343,14 @@ bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account, boo
2330 { 2343 {
2331 ++update[titem->getParentUUID()]; 2344 ++update[titem->getParentUUID()];
2332 } 2345 }
2346 if (folder_id.isNull())
2347 {
2348 folder_id = titem->getParentUUID();
2349 }
2350 else
2351 {
2352 all_one_folder = false;
2353 }
2333 } 2354 }
2334 if(account) 2355 if(account)
2335 { 2356 {
@@ -2353,6 +2374,18 @@ bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account, boo
2353 trash_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_TRASH); 2374 trash_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_TRASH);
2354 if(!gInventory.isObjectDescendentOf(lastitem->getUUID(), trash_id)) 2375 if(!gInventory.isObjectDescendentOf(lastitem->getUUID(), trash_id))
2355 { 2376 {
2377 LLMultiPreview* multi_previewp = LLMultiPreview::getAutoOpenInstance(folder_id);
2378 if (!multi_previewp && all_one_folder && count > 1)
2379 {
2380 S32 left, top;
2381 gFloaterView->getNewFloaterPosition(&left, &top);
2382
2383 multi_previewp = new LLMultiPreview(LLRect(left, top, left + 300, top - 100));
2384 LLMultiPreview::setAutoOpenInstance(multi_previewp, folder_id);
2385 }
2386
2387 LLFloater::setFloaterHost(multi_previewp);
2388
2356 bool show_keep_discard = lastitem->getPermissions().getCreator() != gAgent.getID(); 2389 bool show_keep_discard = lastitem->getPermissions().getCreator() != gAgent.getID();
2357 switch(lastitem->getType()) 2390 switch(lastitem->getType())
2358 { 2391 {
@@ -2383,6 +2416,13 @@ bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account, boo
2383 default: 2416 default:
2384 break; 2417 break;
2385 } 2418 }
2419
2420 LLFloater::setFloaterHost(NULL);
2421 if (multi_previewp)
2422 {
2423 multi_previewp->open();
2424 }
2425
2386 LLInventoryView* view = LLInventoryView::getActiveInventory(); 2426 LLInventoryView* view = LLInventoryView::getActiveInventory();
2387 if(view) 2427 if(view)
2388 { 2428 {
@@ -2814,7 +2854,7 @@ void LLInventoryModel::processMoveInventoryItem(LLMessageSystem* msg, void**)
2814 2854
2815 LLUUID item_id; 2855 LLUUID item_id;
2816 LLUUID folder_id; 2856 LLUUID folder_id;
2817 char new_name[MAX_STRING]; 2857 char new_name[MAX_STRING]; /*Flawfinder: ignore*/
2818 bool anything_changed = false; 2858 bool anything_changed = false;
2819 S32 count = msg->getNumberOfBlocksFast(_PREHASH_InventoryData); 2859 S32 count = msg->getNumberOfBlocksFast(_PREHASH_InventoryData);
2820 for(S32 i = 0; i < count; ++i) 2860 for(S32 i = 0; i < count; ++i)
@@ -2837,7 +2877,7 @@ void LLInventoryModel::processMoveInventoryItem(LLMessageSystem* msg, void**)
2837 gInventory.accountForUpdate(update); 2877 gInventory.accountForUpdate(update);
2838 2878
2839 new_item->setParent(folder_id); 2879 new_item->setParent(folder_id);
2840 if(strlen(new_name) > 0) 2880 if(strlen(new_name) > 0) /*Flawfinder: ignore*/
2841 { 2881 {
2842 new_item->rename(new_name); 2882 new_item->rename(new_name);
2843 } 2883 }