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.cpp369
1 files changed, 257 insertions, 112 deletions
diff --git a/linden/indra/newview/llinventorymodel.cpp b/linden/indra/newview/llinventorymodel.cpp
index 1c7a049..58a2bdc 100644
--- a/linden/indra/newview/llinventorymodel.cpp
+++ b/linden/indra/newview/llinventorymodel.cpp
@@ -186,7 +186,16 @@ LLInventoryModel gInventory;
186// Default constructor 186// Default constructor
187LLInventoryModel::LLInventoryModel() : 187LLInventoryModel::LLInventoryModel() :
188 mModifyMask(LLInventoryObserver::ALL), 188 mModifyMask(LLInventoryObserver::ALL),
189 mChangedItemIDs(),
190 mCategoryMap(),
191 mItemMap(),
192 mCategoryLock(),
193 mItemLock(),
189 mLastItem(NULL), 194 mLastItem(NULL),
195 mAnimationsFolderUUID(LLUUID::null),
196 mParentChildCategoryTree(),
197 mParentChildItemTree(),
198 mObservers(),
190 mIsAgentInvUsable(false) 199 mIsAgentInvUsable(false)
191{ 200{
192} 201}
@@ -404,7 +413,7 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,
404 413
405 if(preferred_type == LLAssetType::AT_SIMSTATE) 414 if(preferred_type == LLAssetType::AT_SIMSTATE)
406 { 415 {
407 lldebugs << "Attempt to create simstate category." << llendl; 416 LL_DEBUGS("Inventory") << "Attempt to create simstate category." << LL_ENDL;
408 return id; 417 return id;
409 } 418 }
410 419
@@ -761,7 +770,7 @@ void LLInventoryModel::updateCategory(const LLViewerInventoryCategory* cat)
761 770
762void LLInventoryModel::moveObject(const LLUUID& object_id, const LLUUID& cat_id) 771void LLInventoryModel::moveObject(const LLUUID& object_id, const LLUUID& cat_id)
763{ 772{
764 lldebugs << "LLInventoryModel::moveObject()" << llendl; 773 LL_DEBUGS("Inventory") << "LLInventoryModel::moveObject()" << LL_ENDL;
765 if(!isInventoryUsable()) 774 if(!isInventoryUsable())
766 { 775 {
767 llwarns << "Inventory is broken." << llendl; 776 llwarns << "Inventory is broken." << llendl;
@@ -803,11 +812,11 @@ void LLInventoryModel::moveObject(const LLUUID& object_id, const LLUUID& cat_id)
803// Delete a particular inventory object by ID. 812// Delete a particular inventory object by ID.
804void LLInventoryModel::deleteObject(const LLUUID& id) 813void LLInventoryModel::deleteObject(const LLUUID& id)
805{ 814{
806 lldebugs << "LLInventoryModel::deleteObject()" << llendl; 815 LL_DEBUGS("Inventory") << "LLInventoryModel::deleteObject()" << LL_ENDL;
807 LLPointer<LLInventoryObject> obj = getObject(id); 816 LLPointer<LLInventoryObject> obj = getObject(id);
808 if(obj) 817 if(obj)
809 { 818 {
810 lldebugs << "Deleting inventory object " << id << llendl; 819 LL_DEBUGS("Inventory") << "Deleting inventory object " << id << LL_ENDL;
811 mLastItem = NULL; 820 mLastItem = NULL;
812 LLUUID parent_id = obj->getParentUUID(); 821 LLUUID parent_id = obj->getParentUUID();
813 mCategoryMap.erase(id); 822 mCategoryMap.erase(id);
@@ -1103,8 +1112,8 @@ void LLInventoryModel::fetchInventoryResponder::result(const LLSD& content)
1103 LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem; 1112 LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
1104 titem->unpackMessage(content["items"][i]); 1113 titem->unpackMessage(content["items"][i]);
1105 1114
1106 lldebugs << "LLInventoryModel::messageUpdateCore() item id:" 1115 LL_DEBUGS("Inventory") << "LLInventoryModel::messageUpdateCore() item id:"
1107 << titem->getUUID() << llendl; 1116 << titem->getUUID() << LL_ENDL;
1108 items.push_back(titem); 1117 items.push_back(titem);
1109 // examine update for changes. 1118 // examine update for changes.
1110 LLViewerInventoryItem* itemp = gInventory.getItem(titem->getUUID()); 1119 LLViewerInventoryItem* itemp = gInventory.getItem(titem->getUUID());
@@ -1673,8 +1682,8 @@ void LLInventoryModel::cache(
1673 const LLUUID& parent_folder_id, 1682 const LLUUID& parent_folder_id,
1674 const LLUUID& agent_id) 1683 const LLUUID& agent_id)
1675{ 1684{
1676 lldebugs << "Caching " << parent_folder_id << " for " << agent_id 1685 LL_DEBUGS("Inventory") << "Caching " << parent_folder_id << " for " << agent_id
1677 << llendl; 1686 << LL_ENDL;
1678 LLViewerInventoryCategory* root_cat = getCategory(parent_folder_id); 1687 LLViewerInventoryCategory* root_cat = getCategory(parent_folder_id);
1679 if(!root_cat) return; 1688 if(!root_cat) return;
1680 cat_array_t categories; 1689 cat_array_t categories;
@@ -1699,7 +1708,7 @@ void LLInventoryModel::cache(
1699 gzip_filename.append(".gz"); 1708 gzip_filename.append(".gz");
1700 if(gzip_file(inventory_filename, gzip_filename)) 1709 if(gzip_file(inventory_filename, gzip_filename))
1701 { 1710 {
1702 lldebugs << "Successfully compressed " << inventory_filename << llendl; 1711 LL_DEBUGS("Inventory") << "Successfully compressed " << inventory_filename << LL_ENDL;
1703 LLFile::remove(inventory_filename); 1712 LLFile::remove(inventory_filename);
1704 } 1713 }
1705 else 1714 else
@@ -1781,8 +1790,8 @@ void LLInventoryModel::accountForUpdate(const LLCategoryUpdate& update)
1781 } 1790 }
1782 if(!accounted) 1791 if(!accounted)
1783 { 1792 {
1784 lldebugs << "No accounting for: '" << cat->getName() << "' " 1793 LL_DEBUGS("Inventory") << "No accounting for: '" << cat->getName() << "' "
1785 << version << llendl; 1794 << version << LL_ENDL;
1786 } 1795 }
1787 } 1796 }
1788 else 1797 else
@@ -1914,40 +1923,72 @@ bool LLInventoryModel::isCategoryComplete(const LLUUID& cat_id) const
1914 return false; 1923 return false;
1915} 1924}
1916 1925
1917bool LLInventoryModel::loadSkeleton( 1926bool LLInventoryModel::loadSkeleton(const LLInventoryModel::options_t& options,
1918 const LLInventoryModel::options_t& options, 1927 const LLUUID& owner_id)
1919 const LLUUID& owner_id)
1920{ 1928{
1921 lldebugs << "importing inventory skeleton for " << owner_id << llendl; 1929 LL_DEBUGS("Inventory") << "importing inventory skeleton for " << owner_id << LL_ENDL;
1922 1930
1923 typedef std::set<LLPointer<LLViewerInventoryCategory>, InventoryIDPtrLess> cat_set_t; 1931 typedef std::set<LLPointer<LLViewerInventoryCategory>, InventoryIDPtrLess> cat_set_t;
1924 cat_set_t temp_cats; 1932 cat_set_t temp_cats;
1925 1933
1926 update_map_t child_counts; 1934 update_map_t child_counts;
1927
1928 LLUUID id; 1935 LLUUID id;
1929 LLAssetType::EType preferred_type; 1936 LLAssetType::EType preferred_type;
1930 bool rv = true; 1937 bool rv = true;
1931 for(options_t::const_iterator it = options.begin(); it < options.end(); ++it) 1938 bool clean_cat = false;
1939
1940 for (options_t::const_iterator it = options.begin(); it < options.end(); ++it)
1932 { 1941 {
1933 LLPointer<LLViewerInventoryCategory> cat = new LLViewerInventoryCategory(owner_id); 1942 LLPointer<LLViewerInventoryCategory> cat = new LLViewerInventoryCategory(owner_id);
1943
1934 response_t::const_iterator no_response = (*it).end(); 1944 response_t::const_iterator no_response = (*it).end();
1935 response_t::const_iterator skel; 1945 response_t::const_iterator skel;
1936 skel = (*it).find("name"); 1946
1937 if(skel == no_response) goto clean_cat; 1947 clean_cat = false;
1938 cat->rename(std::string((*skel).second)); 1948
1939 skel = (*it).find("folder_id"); 1949 skel = (*it).find("folder_id");
1940 if(skel == no_response) goto clean_cat; 1950 if (skel == no_response)
1941 id.set((*skel).second); 1951 {
1952 clean_cat = true;
1953 }
1954 else
1955 {
1956 id.set((*skel).second);
1957 }
1958
1942 // if an id is null, it locks the viewer. 1959 // if an id is null, it locks the viewer.
1943 if(id.isNull()) goto clean_cat; 1960 if (id.isNull())
1944 cat->setUUID(id); 1961 {
1962 clean_cat = true;
1963 }
1964 else
1965 {
1966 cat->setUUID(id);
1967 }
1968
1945 skel = (*it).find("parent_id"); 1969 skel = (*it).find("parent_id");
1946 if(skel == no_response) goto clean_cat; 1970 if (skel == no_response)
1947 id.set((*skel).second); 1971 {
1948 cat->setParent(id); 1972 clean_cat = true;
1973 }
1974 else
1975 {
1976 id.set((*skel).second);
1977 cat->setParent(id);
1978 }
1979
1980 skel = (*it).find("name");
1981 if (skel == no_response)
1982 {
1983 clean_cat = true;
1984 }
1985 else
1986 {
1987 cat->rename(std::string((*skel).second));
1988 }
1989
1949 skel = (*it).find("type_default"); 1990 skel = (*it).find("type_default");
1950 if(skel == no_response) 1991 if (skel == no_response)
1951 { 1992 {
1952 preferred_type = LLAssetType::AT_NONE; 1993 preferred_type = LLAssetType::AT_NONE;
1953 } 1994 }
@@ -1955,40 +1996,71 @@ bool LLInventoryModel::loadSkeleton(
1955 { 1996 {
1956 S32 t = atoi((*skel).second.c_str()); 1997 S32 t = atoi((*skel).second.c_str());
1957 preferred_type = (LLAssetType::EType)t; 1998 preferred_type = (LLAssetType::EType)t;
1999
2000 // This UUID is different for each avatar and "Animations" is hardcoded into the skeleton -- MC
2001 if (LLAssetType::AT_ANIMATION == preferred_type && cat->getName() == "Animations")
2002 {
2003 //llinfos << "Animations folder uuid from skeleton: " << cat->getUUID() << llendl;
2004 mAnimationsFolderUUID = id;
2005 }
1958 } 2006 }
1959 cat->setPreferredType(preferred_type); 2007 cat->setPreferredType(preferred_type);
2008
1960 skel = (*it).find("version"); 2009 skel = (*it).find("version");
1961 if(skel == no_response) goto clean_cat; 2010 if (skel == no_response)
1962 cat->setVersion(atoi((*skel).second.c_str())); 2011 {
1963 temp_cats.insert(cat); 2012 clean_cat = true;
1964 continue; 2013 }
1965 clean_cat: 2014 else
1966 llwarns << "Unable to import near " << cat->getName() << llendl; 2015 {
1967 rv = false; 2016 cat->setVersion(atoi((*skel).second.c_str()));
1968 //delete cat; // automatic when cat is reasigned or destroyed 2017 }
2018
2019 if (clean_cat)
2020 {
2021 llwarns << "Unable to import near " << cat->getName() << llendl;
2022 rv = false;
2023 //delete cat; // automatic when cat is reasigned or destroyed
2024 temp_cats.clear();
2025 break;
2026 }
2027 else
2028 {
2029 temp_cats.insert(cat);
2030 }
1969 } 2031 }
1970 2032
1971 S32 cached_category_count = 0; 2033 S32 cached_category_count = 0;
1972 S32 cached_item_count = 0; 2034 S32 cached_item_count = 0;
1973 if(!temp_cats.empty()) 2035 if (temp_cats.empty())
2036 {
2037 LL_WARNS("Inventory") << "No categories found! Cannot continue!" << LL_ENDL;
2038 }
2039 else
1974 { 2040 {
1975 cat_array_t categories; 2041 cat_array_t categories;
1976 item_array_t items; 2042 item_array_t items;
1977 std::string owner_id_str; 2043 std::string owner_id_str;
1978 owner_id.toString(owner_id_str); 2044 owner_id.toString(owner_id_str);
2045
1979 std::string path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, owner_id_str)); 2046 std::string path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, owner_id_str));
1980 std::string inventory_filename; 2047 std::string inventory_filename;
1981 inventory_filename = llformat(CACHE_FORMAT_STRING, path.c_str()); 2048 inventory_filename = llformat(CACHE_FORMAT_STRING, path.c_str());
2049
1982 const S32 NO_VERSION = LLViewerInventoryCategory::VERSION_UNKNOWN; 2050 const S32 NO_VERSION = LLViewerInventoryCategory::VERSION_UNKNOWN;
2051
1983 std::string gzip_filename(inventory_filename); 2052 std::string gzip_filename(inventory_filename);
1984 gzip_filename.append(".gz"); 2053 gzip_filename.append(".gz");
1985 LLFILE* fp = LLFile::fopen(gzip_filename, "rb"); 2054 LLFILE* fp = LLFile::fopen(gzip_filename, "rb");
2055
1986 bool remove_inventory_file = false; 2056 bool remove_inventory_file = false;
1987 if(fp) 2057
2058 // try to ungzip the inventory -- MC
2059 if (fp)
1988 { 2060 {
1989 fclose(fp); 2061 fclose(fp);
1990 fp = NULL; 2062 fp = NULL;
1991 if(gunzip_file(gzip_filename, inventory_filename)) 2063 if (gunzip_file(gzip_filename, inventory_filename))
1992 { 2064 {
1993 // we only want to remove the inventory file if it was 2065 // we only want to remove the inventory file if it was
1994 // gzipped before we loaded, and we successfully 2066 // gzipped before we loaded, and we successfully
@@ -2000,7 +2072,9 @@ bool LLInventoryModel::loadSkeleton(
2000 llinfos << "Unable to gunzip " << gzip_filename << llendl; 2072 llinfos << "Unable to gunzip " << gzip_filename << llendl;
2001 } 2073 }
2002 } 2074 }
2003 if(loadFromFile(inventory_filename, categories, items)) 2075
2076 // begin cache loading -- MC
2077 if (loadFromFile(inventory_filename, categories, items))
2004 { 2078 {
2005 // We were able to find a cache of files. So, use what we 2079 // We were able to find a cache of files. So, use what we
2006 // found to generate a set of categories we should add. We 2080 // found to generate a set of categories we should add. We
@@ -2009,10 +2083,11 @@ bool LLInventoryModel::loadSkeleton(
2009 S32 count = categories.count(); 2083 S32 count = categories.count();
2010 cat_set_t::iterator not_cached = temp_cats.end(); 2084 cat_set_t::iterator not_cached = temp_cats.end();
2011 std::set<LLUUID> cached_ids; 2085 std::set<LLUUID> cached_ids;
2012 for(S32 i = 0; i < count; ++i) 2086 for (S32 i = 0; i < count; ++i)
2013 { 2087 {
2014 LLViewerInventoryCategory* cat = categories[i]; 2088 LLViewerInventoryCategory* cat = categories[i];
2015 cat_set_t::iterator cit = temp_cats.find(cat); 2089 cat_set_t::iterator cit = temp_cats.find(cat);
2090
2016 if (cit == temp_cats.end()) 2091 if (cit == temp_cats.end())
2017 { 2092 {
2018 continue; // cache corruption?? not sure why this happens -SJB 2093 continue; // cache corruption?? not sure why this happens -SJB
@@ -2021,18 +2096,23 @@ bool LLInventoryModel::loadSkeleton(
2021 2096
2022 // we can safely ignore anything loaded from file, but 2097 // we can safely ignore anything loaded from file, but
2023 // not sent down in the skeleton. 2098 // not sent down in the skeleton.
2024 if(cit == not_cached) 2099 if (cit == not_cached)
2025 { 2100 {
2026 continue; 2101 continue;
2027 } 2102 }
2028 if(cat->getVersion() != tcat->getVersion()) 2103
2104 // We insert them anyway to keep the cache from breaking.
2105 // If we delete or add a folder (aka "category") then the server
2106 // increments the version and we reload the items on next login anyway
2107 // this *may* result in duplicates that are cleared on relog-- MC
2108 /*if (cat->getVersion() != tcat->getVersion())
2029 { 2109 {
2030 // if the cached version does not match the server version, 2110 // if the cached version does not match the server version,
2031 // throw away the version we have so we can fetch the 2111 // throw away the version we have so we can fetch the
2032 // correct contents the next time the viewer opens the folder. 2112 // correct contents the next time the viewer opens the folder.
2033 tcat->setVersion(NO_VERSION); 2113 tcat->setVersion(NO_VERSION);
2034 } 2114 }
2035 else 2115 else*/
2036 { 2116 {
2037 cached_ids.insert(tcat->getUUID()); 2117 cached_ids.insert(tcat->getUUID());
2038 } 2118 }
@@ -2041,9 +2121,9 @@ bool LLInventoryModel::loadSkeleton(
2041 // go ahead and add the cats returned during the download 2121 // go ahead and add the cats returned during the download
2042 std::set<LLUUID>::iterator not_cached_id = cached_ids.end(); 2122 std::set<LLUUID>::iterator not_cached_id = cached_ids.end();
2043 cached_category_count = cached_ids.size(); 2123 cached_category_count = cached_ids.size();
2044 for(cat_set_t::iterator it = temp_cats.begin(); it != temp_cats.end(); ++it) 2124 for (cat_set_t::iterator it = temp_cats.begin(); it != temp_cats.end(); ++it)
2045 { 2125 {
2046 if(cached_ids.find((*it)->getUUID()) == not_cached_id) 2126 if (cached_ids.find((*it)->getUUID()) == not_cached_id)
2047 { 2127 {
2048 // this check is performed so that we do not 2128 // this check is performed so that we do not
2049 // mark new folders in the skeleton (and not in cache) 2129 // mark new folders in the skeleton (and not in cache)
@@ -2058,15 +2138,14 @@ bool LLInventoryModel::loadSkeleton(
2058 // Add all the items loaded which are parented to a 2138 // Add all the items loaded which are parented to a
2059 // category with a correctly cached parent 2139 // category with a correctly cached parent
2060 count = items.count(); 2140 count = items.count();
2061 cat_map_t::iterator unparented = mCategoryMap.end(); 2141 for (int i = 0; i < count; ++i)
2062 for(int i = 0; i < count; ++i)
2063 { 2142 {
2064 cat_map_t::iterator cit = mCategoryMap.find(items[i]->getParentUUID()); 2143 cat_map_t::iterator cit = mCategoryMap.find(items[i]->getParentUUID());
2065 2144
2066 if(cit != unparented) 2145 if (cit != mCategoryMap.end())
2067 { 2146 {
2068 LLViewerInventoryCategory* cat = cit->second; 2147 LLViewerInventoryCategory* cat = cit->second;
2069 if(cat->getVersion() != NO_VERSION) 2148 if (cat->getVersion() != NO_VERSION)
2070 { 2149 {
2071 addItem(items[i]); 2150 addItem(items[i]);
2072 cached_item_count += 1; 2151 cached_item_count += 1;
@@ -2079,7 +2158,7 @@ bool LLInventoryModel::loadSkeleton(
2079 { 2158 {
2080 // go ahead and add everything after stripping the version 2159 // go ahead and add everything after stripping the version
2081 // information. 2160 // information.
2082 for(cat_set_t::iterator it = temp_cats.begin(); it != temp_cats.end(); ++it) 2161 for (cat_set_t::iterator it = temp_cats.begin(); it != temp_cats.end(); ++it)
2083 { 2162 {
2084 LLViewerInventoryCategory *llvic = (*it); 2163 LLViewerInventoryCategory *llvic = (*it);
2085 llvic->setVersion(NO_VERSION); 2164 llvic->setVersion(NO_VERSION);
@@ -2092,13 +2171,13 @@ bool LLInventoryModel::loadSkeleton(
2092 // needlessly fetch descendents for categories which we have. 2171 // needlessly fetch descendents for categories which we have.
2093 update_map_t::iterator no_child_counts = child_counts.end(); 2172 update_map_t::iterator no_child_counts = child_counts.end();
2094 update_map_t::iterator the_count; 2173 update_map_t::iterator the_count;
2095 for(cat_set_t::iterator it = temp_cats.begin(); it != temp_cats.end(); ++it) 2174 for (cat_set_t::iterator it = temp_cats.begin(); it != temp_cats.end(); ++it)
2096 { 2175 {
2097 LLViewerInventoryCategory* cat = (*it); 2176 LLViewerInventoryCategory* cat = (*it);
2098 if(cat->getVersion() != NO_VERSION) 2177 if (cat->getVersion() != NO_VERSION)
2099 { 2178 {
2100 the_count = child_counts.find(cat->getUUID()); 2179 the_count = child_counts.find(cat->getUUID());
2101 if(the_count != no_child_counts) 2180 if (the_count != no_child_counts)
2102 { 2181 {
2103 cat->setDescendentCount((*the_count).second.mValue); 2182 cat->setDescendentCount((*the_count).second.mValue);
2104 } 2183 }
@@ -2109,7 +2188,7 @@ bool LLInventoryModel::loadSkeleton(
2109 } 2188 }
2110 } 2189 }
2111 2190
2112 if(remove_inventory_file) 2191 if (remove_inventory_file)
2113 { 2192 {
2114 // clean up the gunzipped file. 2193 // clean up the gunzipped file.
2115 LLFile::remove(inventory_filename); 2194 LLFile::remove(inventory_filename);
@@ -2118,53 +2197,98 @@ bool LLInventoryModel::loadSkeleton(
2118 } 2197 }
2119 2198
2120 LL_DEBUGS("Inventory") << "Successfully loaded " << cached_category_count 2199 LL_DEBUGS("Inventory") << "Successfully loaded " << cached_category_count
2121 << " categories and " << cached_item_count << " items from cache." 2200 << " categories and " << cached_item_count << " items from cache skeleton."
2122 << LL_ENDL; 2201 << LL_ENDL;
2123 2202
2124 return rv; 2203 return rv;
2125} 2204}
2126 2205
2127bool LLInventoryModel::loadMeat( 2206bool LLInventoryModel::loadMeat(const LLInventoryModel::options_t& options,
2128 const LLInventoryModel::options_t& options, const LLUUID& owner_id) 2207 const LLUUID& owner_id)
2129{ 2208{
2130 llinfos << "importing inventory for " << owner_id << llendl; 2209 llinfos << "importing inventory for " << owner_id << llendl;
2131 LLPermissions default_perm; 2210 LLPermissions default_perm;
2132 default_perm.init(LLUUID::null, owner_id, LLUUID::null, LLUUID::null); 2211 default_perm.init(LLUUID::null, owner_id, LLUUID::null, LLUUID::null);
2133 LLPointer<LLViewerInventoryItem> item; 2212 LLPointer<LLViewerInventoryItem> item;
2134 LLUUID id; 2213 LLUUID id;
2135 LLAssetType::EType type; 2214 LLAssetType::EType type = LLAssetType::AT_NONE;
2136 LLInventoryType::EType inv_type; 2215 LLInventoryType::EType inv_type;
2216
2137 bool rv = true; 2217 bool rv = true;
2138 for(options_t::const_iterator it = options.begin(); it < options.end(); ++it) 2218 bool clean_item = false;
2219 static S32 cached_meat_count = 0;
2220
2221 for (options_t::const_iterator it = options.begin(); it < options.end(); ++it)
2139 { 2222 {
2140 item = new LLViewerInventoryItem; 2223 item = new LLViewerInventoryItem;
2224
2141 response_t::const_iterator no_response = (*it).end(); 2225 response_t::const_iterator no_response = (*it).end();
2142 response_t::const_iterator meat; 2226 response_t::const_iterator meat;
2227
2228 clean_item = false;
2229
2143 meat = (*it).find("name"); 2230 meat = (*it).find("name");
2144 if(meat == no_response) goto clean_item; 2231 if (meat == no_response)
2145 item->rename(std::string((*meat).second)); 2232 {
2233 clean_item = true;
2234 }
2235 else
2236 {
2237 item->rename(std::string((*meat).second));
2238 }
2239
2146 meat = (*it).find("item_id"); 2240 meat = (*it).find("item_id");
2147 if(meat == no_response) goto clean_item; 2241 if (meat == no_response)
2148 id.set((*meat).second); 2242 {
2149 item->setUUID(id); 2243 clean_item = true;
2244 }
2245 else
2246 {
2247 id.set((*meat).second);
2248 item->setUUID(id);
2249 }
2250
2150 meat = (*it).find("parent_id"); 2251 meat = (*it).find("parent_id");
2151 if(meat == no_response) goto clean_item; 2252 if (meat == no_response)
2152 id.set((*meat).second); 2253 {
2153 item->setParent(id); 2254 clean_item = true;
2255 }
2256 else
2257 {
2258 id.set((*meat).second);
2259 item->setParent(id);
2260 }
2261
2154 meat = (*it).find("type"); 2262 meat = (*it).find("type");
2155 if(meat == no_response) goto clean_item; 2263 if (meat == no_response)
2156 type = (LLAssetType::EType)atoi((*meat).second.c_str()); 2264 {
2157 item->setType(type); 2265 clean_item = true;
2266 }
2267 else
2268 {
2269 type = (LLAssetType::EType)atoi((*meat).second.c_str());
2270 item->setType(type);
2271 }
2272
2273 // Do we want to clean if there's no inv_type too? -- MC
2158 meat = (*it).find("inv_type"); 2274 meat = (*it).find("inv_type");
2159 if(meat != no_response) 2275 if (meat != no_response)
2160 { 2276 {
2161 inv_type = (LLInventoryType::EType)atoi((*meat).second.c_str()); 2277 inv_type = (LLInventoryType::EType)atoi((*meat).second.c_str());
2162 item->setInventoryType(inv_type); 2278 item->setInventoryType(inv_type);
2163 } 2279 }
2280
2164 meat = (*it).find("data_id"); 2281 meat = (*it).find("data_id");
2165 if(meat == no_response) goto clean_item; 2282 if (meat == no_response)
2166 id.set((*meat).second); 2283 {
2167 if(LLAssetType::AT_CALLINGCARD == type) 2284 clean_item = true;
2285 }
2286 else
2287 {
2288 id.set((*meat).second);
2289 }
2290
2291 if (LLAssetType::AT_CALLINGCARD == type)
2168 { 2292 {
2169 LLPermissions perm; 2293 LLPermissions perm;
2170 perm.init(id, owner_id, LLUUID::null, LLUUID::null); 2294 perm.init(id, owner_id, LLUUID::null, LLUUID::null);
@@ -2173,37 +2297,48 @@ bool LLInventoryModel::loadMeat(
2173 else 2297 else
2174 { 2298 {
2175 meat = (*it).find("perm_mask"); 2299 meat = (*it).find("perm_mask");
2176 if(meat != no_response) 2300 if (meat != no_response)
2177 { 2301 {
2178 PermissionMask perm_mask = atoi((*meat).second.c_str()); 2302 PermissionMask perm_mask = atoi((*meat).second.c_str());
2179 default_perm.initMasks( 2303 default_perm.initMasks(perm_mask, perm_mask, perm_mask, perm_mask, perm_mask);
2180 perm_mask, perm_mask, perm_mask, perm_mask, perm_mask);
2181 } 2304 }
2182 else 2305 else
2183 { 2306 {
2184 default_perm.initMasks( 2307 default_perm.initMasks(PERM_NONE, PERM_NONE, PERM_NONE, PERM_NONE, PERM_NONE);
2185 PERM_NONE, PERM_NONE, PERM_NONE, PERM_NONE, PERM_NONE);
2186 } 2308 }
2187 item->setPermissions(default_perm); 2309 item->setPermissions(default_perm);
2188 item->setAssetUUID(id); 2310 item->setAssetUUID(id);
2189 } 2311 }
2312
2190 meat = (*it).find("flags"); 2313 meat = (*it).find("flags");
2191 if(meat != no_response) 2314 if (meat != no_response)
2192 { 2315 {
2193 item->setFlags(strtoul((*meat).second.c_str(), NULL, 0)); 2316 item->setFlags(strtoul((*meat).second.c_str(), NULL, 0));
2194 } 2317 }
2318
2195 meat = (*it).find("time"); 2319 meat = (*it).find("time");
2196 if(meat != no_response) 2320 if (meat != no_response)
2197 { 2321 {
2198 item->setCreationDate(atoi((*meat).second.c_str())); 2322 item->setCreationDate(atoi((*meat).second.c_str()));
2199 } 2323 }
2200 addItem(item); 2324
2201 continue; 2325 if (clean_item)
2202 clean_item: 2326 {
2203 llwarns << "Unable to import near " << item->getName() << llendl; 2327 llwarns << "Unable to import near " << item->getName() << llendl;
2204 rv = false; 2328 rv = false;
2205 //delete item; // automatic when item is reassigned or destroyed 2329 //delete item; // automatic when item is reassigned or destroyed
2330 break;
2331 }
2332 else
2333 {
2334 addItem(item);
2335 cached_meat_count++;
2336 }
2206 } 2337 }
2338
2339 LL_DEBUGS("Inventory") << "Successfully added " << cached_meat_count << " items from cache."
2340 << LL_ENDL;
2341
2207 return rv; 2342 return rv;
2208} 2343}
2209 2344
@@ -2528,6 +2663,7 @@ bool LLInventoryModel::loadFromFile(const std::string& filename,
2528 // *NOTE: This buffer size is hard coded into scanf() below. 2663 // *NOTE: This buffer size is hard coded into scanf() below.
2529 char buffer[MAX_STRING]; /*Flawfinder: ignore*/ 2664 char buffer[MAX_STRING]; /*Flawfinder: ignore*/
2530 char keyword[MAX_STRING]; /*Flawfinder: ignore*/ 2665 char keyword[MAX_STRING]; /*Flawfinder: ignore*/
2666 static S32 item_count_total = 0;
2531 while(!feof(file) && fgets(buffer, MAX_STRING, file)) 2667 while(!feof(file) && fgets(buffer, MAX_STRING, file))
2532 { 2668 {
2533 sscanf(buffer, " %254s", keyword); /* Flawfinder: ignore */ 2669 sscanf(buffer, " %254s", keyword); /* Flawfinder: ignore */
@@ -2552,16 +2688,17 @@ bool LLInventoryModel::loadFromFile(const std::string& filename,
2552 // *FIX: Need a better solution, this prevents the 2688 // *FIX: Need a better solution, this prevents the
2553 // application from freezing, but breaks inventory 2689 // application from freezing, but breaks inventory
2554 // caching. 2690 // caching.
2555 if(inv_item->getUUID().isNull()) 2691 //if(inv_item->getUUID().isNull())MCCABE
2556 { 2692 //{
2557 //delete inv_item; // automatic when inv_cat is reassigned or destroyed 2693 // //delete inv_item; // automatic when inv_cat is reassigned or destroyed
2558 llwarns << "Ignoring inventory with null item id: " 2694 // llwarns << "Ignoring inventory with null item id: "
2559 << inv_item->getName() << llendl; 2695 // << inv_item->getName() << llendl;
2560 2696 //
2561 } 2697 //}
2562 else 2698 //else
2563 { 2699 {
2564 items.put(inv_item); 2700 items.put(inv_item);
2701 item_count_total++;
2565 } 2702 }
2566 } 2703 }
2567 else 2704 else
@@ -2576,6 +2713,7 @@ bool LLInventoryModel::loadFromFile(const std::string& filename,
2576 << llendl; 2713 << llendl;
2577 } 2714 }
2578 } 2715 }
2716 LL_DEBUGS("Inventory") << "Inventory items loaded from file: " << item_count_total << LL_ENDL;
2579 fclose(file); 2717 fclose(file);
2580 return true; 2718 return true;
2581} 2719}
@@ -2598,6 +2736,9 @@ bool LLInventoryModel::saveToFile(const std::string& filename,
2598 return false; 2736 return false;
2599 } 2737 }
2600 2738
2739 static S32 count_total = 0;
2740 static S32 category_total = 0;
2741
2601 S32 count = categories.count(); 2742 S32 count = categories.count();
2602 S32 i; 2743 S32 i;
2603 for(i = 0; i < count; ++i) 2744 for(i = 0; i < count; ++i)
@@ -2606,6 +2747,7 @@ bool LLInventoryModel::saveToFile(const std::string& filename,
2606 if(cat->getVersion() != LLViewerInventoryCategory::VERSION_UNKNOWN) 2747 if(cat->getVersion() != LLViewerInventoryCategory::VERSION_UNKNOWN)
2607 { 2748 {
2608 cat->exportFileLocal(file); 2749 cat->exportFileLocal(file);
2750 category_total++;
2609 } 2751 }
2610 } 2752 }
2611 2753
@@ -2613,8 +2755,11 @@ bool LLInventoryModel::saveToFile(const std::string& filename,
2613 for(i = 0; i < count; ++i) 2755 for(i = 0; i < count; ++i)
2614 { 2756 {
2615 items[i]->exportFile(file); 2757 items[i]->exportFile(file);
2758 count_total++;
2616 } 2759 }
2617 2760
2761 LL_DEBUGS("Inventory") << "Cached " << category_total << " categories and " << count_total << " inventory items" << LL_ENDL;
2762
2618 fclose(file); 2763 fclose(file);
2619 return true; 2764 return true;
2620} 2765}
@@ -2709,8 +2854,8 @@ bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account)
2709 { 2854 {
2710 LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem; 2855 LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
2711 titem->unpackMessage(msg, _PREHASH_InventoryData, i); 2856 titem->unpackMessage(msg, _PREHASH_InventoryData, i);
2712 lldebugs << "LLInventoryModel::messageUpdateCore() item id:" 2857 LL_DEBUGS("Inventory") << "LLInventoryModel::messageUpdateCore() item id:"
2713 << titem->getUUID() << llendl; 2858 << titem->getUUID() << LL_ENDL;
2714 items.push_back(titem); 2859 items.push_back(titem);
2715 // examine update for changes. 2860 // examine update for changes.
2716 LLViewerInventoryItem* itemp = gInventory.getItem(titem->getUUID()); 2861 LLViewerInventoryItem* itemp = gInventory.getItem(titem->getUUID());
@@ -2759,7 +2904,7 @@ bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account)
2759// static 2904// static
2760void LLInventoryModel::processRemoveInventoryItem(LLMessageSystem* msg, void**) 2905void LLInventoryModel::processRemoveInventoryItem(LLMessageSystem* msg, void**)
2761{ 2906{
2762 lldebugs << "LLInventoryModel::processRemoveInventoryItem()" << llendl; 2907 LL_DEBUGS("Inventory") << "LLInventoryModel::processRemoveInventoryItem()" << LL_ENDL;
2763 LLUUID agent_id, item_id; 2908 LLUUID agent_id, item_id;
2764 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id); 2909 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
2765 if(agent_id != gAgent.getID()) 2910 if(agent_id != gAgent.getID())
@@ -2796,7 +2941,7 @@ void LLInventoryModel::processRemoveInventoryItem(LLMessageSystem* msg, void**)
2796void LLInventoryModel::processUpdateInventoryFolder(LLMessageSystem* msg, 2941void LLInventoryModel::processUpdateInventoryFolder(LLMessageSystem* msg,
2797 void**) 2942 void**)
2798{ 2943{
2799 lldebugs << "LLInventoryModel::processUpdateInventoryFolder()" << llendl; 2944 LL_DEBUGS("Inventory") << "LLInventoryModel::processUpdateInventoryFolder()" << LL_ENDL;
2800 LLUUID agent_id, folder_id, parent_id; 2945 LLUUID agent_id, folder_id, parent_id;
2801 //char name[DB_INV_ITEM_NAME_BUF_SIZE]; 2946 //char name[DB_INV_ITEM_NAME_BUF_SIZE];
2802 msg->getUUIDFast(_PREHASH_FolderData, _PREHASH_AgentID, agent_id); 2947 msg->getUUIDFast(_PREHASH_FolderData, _PREHASH_AgentID, agent_id);
@@ -2856,7 +3001,7 @@ void LLInventoryModel::processUpdateInventoryFolder(LLMessageSystem* msg,
2856void LLInventoryModel::processRemoveInventoryFolder(LLMessageSystem* msg, 3001void LLInventoryModel::processRemoveInventoryFolder(LLMessageSystem* msg,
2857 void**) 3002 void**)
2858{ 3003{
2859 lldebugs << "LLInventoryModel::processRemoveInventoryFolder()" << llendl; 3004 LL_DEBUGS("Inventory") << "LLInventoryModel::processRemoveInventoryFolder()" << LL_ENDL;
2860 LLUUID agent_id, folder_id; 3005 LLUUID agent_id, folder_id;
2861 msg->getUUIDFast(_PREHASH_FolderData, _PREHASH_AgentID, agent_id); 3006 msg->getUUIDFast(_PREHASH_FolderData, _PREHASH_AgentID, agent_id);
2862 if(agent_id != gAgent.getID()) 3007 if(agent_id != gAgent.getID())
@@ -2905,8 +3050,8 @@ void LLInventoryModel::processSaveAssetIntoInventory(LLMessageSystem* msg,
2905 // The viewer ignores the asset id because this message is only 3050 // The viewer ignores the asset id because this message is only
2906 // used for attachments/objects, so the asset id is not used in 3051 // used for attachments/objects, so the asset id is not used in
2907 // the viewer anyway. 3052 // the viewer anyway.
2908 lldebugs << "LLInventoryModel::processSaveAssetIntoInventory itemID=" 3053 LL_DEBUGS("Inventory") << "LLInventoryModel::processSaveAssetIntoInventory itemID="
2909 << item_id << llendl; 3054 << item_id << LL_ENDL;
2910 LLViewerInventoryItem* item = gInventory.getItem( item_id ); 3055 LLViewerInventoryItem* item = gInventory.getItem( item_id );
2911 if( item ) 3056 if( item )
2912 { 3057 {
@@ -3173,7 +3318,7 @@ void LLInventoryModel::processInventoryDescendents(LLMessageSystem* msg,void**)
3173// static 3318// static
3174void LLInventoryModel::processMoveInventoryItem(LLMessageSystem* msg, void**) 3319void LLInventoryModel::processMoveInventoryItem(LLMessageSystem* msg, void**)
3175{ 3320{
3176 lldebugs << "LLInventoryModel::processMoveInventoryItem()" << llendl; 3321 LL_DEBUGS("Inventory") << "LLInventoryModel::processMoveInventoryItem()" << LL_ENDL;
3177 LLUUID agent_id; 3322 LLUUID agent_id;
3178 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id); 3323 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
3179 if(agent_id != gAgent.getID()) 3324 if(agent_id != gAgent.getID())
@@ -3198,8 +3343,8 @@ void LLInventoryModel::processMoveInventoryItem(LLMessageSystem* msg, void**)
3198 msg->getUUIDFast(_PREHASH_InventoryData, _PREHASH_FolderID, folder_id, i); 3343 msg->getUUIDFast(_PREHASH_InventoryData, _PREHASH_FolderID, folder_id, i);
3199 msg->getString("InventoryData", "NewName", new_name, i); 3344 msg->getString("InventoryData", "NewName", new_name, i);
3200 3345
3201 lldebugs << "moving item " << item_id << " to folder " 3346 LL_DEBUGS("Inventory") << "moving item " << item_id << " to folder "
3202 << folder_id << llendl; 3347 << folder_id << LL_ENDL;
3203 update_list_t update; 3348 update_list_t update;
3204 LLCategoryUpdate old_folder(item->getParentUUID(), -1); 3349 LLCategoryUpdate old_folder(item->getParentUUID(), -1);
3205 update.push_back(old_folder); 3350 update.push_back(old_folder);
@@ -3759,7 +3904,7 @@ void LLInventoryFetchComboObserver::fetch(
3759 const folder_ref_t& folder_ids, 3904 const folder_ref_t& folder_ids,
3760 const item_ref_t& item_ids) 3905 const item_ref_t& item_ids)
3761{ 3906{
3762 lldebugs << "LLInventoryFetchComboObserver::fetch()" << llendl; 3907 LL_DEBUGS("Inventory") << "LLInventoryFetchComboObserver::fetch()" << LL_ENDL;
3763 for(folder_ref_t::const_iterator fit = folder_ids.begin(); fit != folder_ids.end(); ++fit) 3908 for(folder_ref_t::const_iterator fit = folder_ids.begin(); fit != folder_ids.end(); ++fit)
3764 { 3909 {
3765 LLViewerInventoryCategory* cat = gInventory.getCategory(*fit); 3910 LLViewerInventoryCategory* cat = gInventory.getCategory(*fit);
@@ -3767,13 +3912,13 @@ void LLInventoryFetchComboObserver::fetch(
3767 if(!gInventory.isCategoryComplete(*fit)) 3912 if(!gInventory.isCategoryComplete(*fit))
3768 { 3913 {
3769 cat->fetchDescendents(); 3914 cat->fetchDescendents();
3770 lldebugs << "fetching folder " << *fit <<llendl; 3915 LL_DEBUGS("Inventory") << "fetching folder " << *fit << LL_ENDL;
3771 mIncompleteFolders.push_back(*fit); 3916 mIncompleteFolders.push_back(*fit);
3772 } 3917 }
3773 else 3918 else
3774 { 3919 {
3775 mCompleteFolders.push_back(*fit); 3920 mCompleteFolders.push_back(*fit);
3776 lldebugs << "completing folder " << *fit <<llendl; 3921 LL_DEBUGS("Inventory") << "completing folder " << *fit << LL_ENDL;
3777 } 3922 }
3778 } 3923 }
3779 3924
@@ -3788,14 +3933,14 @@ void LLInventoryFetchComboObserver::fetch(
3788 LLViewerInventoryItem* item = gInventory.getItem(*iit); 3933 LLViewerInventoryItem* item = gInventory.getItem(*iit);
3789 if(!item) 3934 if(!item)
3790 { 3935 {
3791 lldebugs << "uanble to find item " << *iit << llendl; 3936 LL_DEBUGS("Inventory") << "uanble to find item " << *iit << LL_ENDL;
3792 continue; 3937 continue;
3793 } 3938 }
3794 if(item->isComplete()) 3939 if(item->isComplete())
3795 { 3940 {
3796 // It's complete, so put it on the complete container. 3941 // It's complete, so put it on the complete container.
3797 mCompleteItems.push_back(*iit); 3942 mCompleteItems.push_back(*iit);
3798 lldebugs << "completing item " << *iit << llendl; 3943 LL_DEBUGS("Inventory") << "completing item " << *iit << LL_ENDL;
3799 continue; 3944 continue;
3800 } 3945 }
3801 else 3946 else
@@ -3812,7 +3957,7 @@ void LLInventoryFetchComboObserver::fetch(
3812 } 3957 }
3813 else 3958 else
3814 { 3959 {
3815 lldebugs << "not worrying about " << *iit << llendl; 3960 LL_DEBUGS("Inventory") << "not worrying about " << *iit << LL_ENDL;
3816 } 3961 }
3817 } 3962 }
3818 fetch_items_from_llsd(items_llsd); 3963 fetch_items_from_llsd(items_llsd);