aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llinventory/llinventory.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llinventory/llinventory.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to '')
-rw-r--r--linden/indra/llinventory/llinventory.cpp228
1 files changed, 117 insertions, 111 deletions
diff --git a/linden/indra/llinventory/llinventory.cpp b/linden/indra/llinventory/llinventory.cpp
index 8cd0700..457a0cb 100644
--- a/linden/indra/llinventory/llinventory.cpp
+++ b/linden/indra/llinventory/llinventory.cpp
@@ -78,16 +78,16 @@ LLInventoryObject::LLInventoryObject(
78 const LLUUID& uuid, 78 const LLUUID& uuid,
79 const LLUUID& parent_uuid, 79 const LLUUID& parent_uuid,
80 LLAssetType::EType type, 80 LLAssetType::EType type,
81 const LLString& name) : 81 const std::string& name) :
82 mUUID(uuid), 82 mUUID(uuid),
83 mParentUUID(parent_uuid), 83 mParentUUID(parent_uuid),
84 mType(type), 84 mType(type),
85 mName(name) 85 mName(name)
86{ 86{
87 LLString::replaceNonstandardASCII(mName, ' '); 87 LLStringUtil::replaceNonstandardASCII(mName, ' ');
88 LLString::replaceChar(mName, '|', ' '); 88 LLStringUtil::replaceChar(mName, '|', ' ');
89 LLString::trim(mName); 89 LLStringUtil::trim(mName);
90 LLString::truncate(mName, DB_INV_ITEM_NAME_STR_LEN); 90 LLStringUtil::truncate(mName, DB_INV_ITEM_NAME_STR_LEN);
91} 91}
92 92
93LLInventoryObject::LLInventoryObject() : 93LLInventoryObject::LLInventoryObject() :
@@ -117,7 +117,7 @@ const LLUUID& LLInventoryObject::getParentUUID() const
117 return mParentUUID; 117 return mParentUUID;
118} 118}
119 119
120const LLString& LLInventoryObject::getName() const 120const std::string& LLInventoryObject::getName() const
121{ 121{
122 return mName; 122 return mName;
123} 123}
@@ -132,13 +132,13 @@ void LLInventoryObject::setUUID(const LLUUID& new_uuid)
132 mUUID = new_uuid; 132 mUUID = new_uuid;
133} 133}
134 134
135void LLInventoryObject::rename(const LLString& n) 135void LLInventoryObject::rename(const std::string& n)
136{ 136{
137 LLString new_name(n); 137 std::string new_name(n);
138 LLString::replaceNonstandardASCII(new_name, ' '); 138 LLStringUtil::replaceNonstandardASCII(new_name, ' ');
139 LLString::replaceChar(new_name, '|', ' '); 139 LLStringUtil::replaceChar(new_name, '|', ' ');
140 LLString::trim(new_name); 140 LLStringUtil::trim(new_name);
141 LLString::truncate(new_name, DB_INV_ITEM_NAME_STR_LEN); 141 LLStringUtil::truncate(new_name, DB_INV_ITEM_NAME_STR_LEN);
142 142
143 if( new_name != mName ) 143 if( new_name != mName )
144 { 144 {
@@ -201,10 +201,10 @@ BOOL LLInventoryObject::importLegacyStream(std::istream& input_stream)
201 " %254s %254[^|]", 201 " %254s %254[^|]",
202 keyword, valuestr); 202 keyword, valuestr);
203 mName.assign(valuestr); 203 mName.assign(valuestr);
204 LLString::replaceNonstandardASCII(mName, ' '); 204 LLStringUtil::replaceNonstandardASCII(mName, ' ');
205 LLString::replaceChar(mName, '|', ' '); 205 LLStringUtil::replaceChar(mName, '|', ' ');
206 LLString::trim(mName); 206 LLStringUtil::trim(mName);
207 LLString::truncate(mName, DB_INV_ITEM_NAME_STR_LEN); 207 LLStringUtil::truncate(mName, DB_INV_ITEM_NAME_STR_LEN);
208 } 208 }
209 else 209 else
210 { 210 {
@@ -219,12 +219,12 @@ BOOL LLInventoryObject::importLegacyStream(std::istream& input_stream)
219// not sure whether exportLegacyStream(llofstream(fp)) would work, fp may need to get icramented... 219// not sure whether exportLegacyStream(llofstream(fp)) would work, fp may need to get icramented...
220BOOL LLInventoryObject::exportFile(LLFILE* fp, BOOL) const 220BOOL LLInventoryObject::exportFile(LLFILE* fp, BOOL) const
221{ 221{
222 char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ 222 std::string uuid_str;
223 fprintf(fp, "\tinv_object\t0\n\t{\n"); 223 fprintf(fp, "\tinv_object\t0\n\t{\n");
224 mUUID.toString(uuid_str); 224 mUUID.toString(uuid_str);
225 fprintf(fp, "\t\tobj_id\t%s\n", uuid_str); 225 fprintf(fp, "\t\tobj_id\t%s\n", uuid_str.c_str());
226 mParentUUID.toString(uuid_str); 226 mParentUUID.toString(uuid_str);
227 fprintf(fp, "\t\tparent_id\t%s\n", uuid_str); 227 fprintf(fp, "\t\tparent_id\t%s\n", uuid_str.c_str());
228 fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType)); 228 fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType));
229 fprintf(fp, "\t\tname\t%s|\n", mName.c_str()); 229 fprintf(fp, "\t\tname\t%s|\n", mName.c_str());
230 fprintf(fp,"\t}\n"); 230 fprintf(fp,"\t}\n");
@@ -233,7 +233,7 @@ BOOL LLInventoryObject::exportFile(LLFILE* fp, BOOL) const
233 233
234BOOL LLInventoryObject::exportLegacyStream(std::ostream& output_stream, BOOL) const 234BOOL LLInventoryObject::exportLegacyStream(std::ostream& output_stream, BOOL) const
235{ 235{
236 char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ 236 std::string uuid_str;
237 output_stream << "\tinv_object\t0\n\t{\n"; 237 output_stream << "\tinv_object\t0\n\t{\n";
238 mUUID.toString(uuid_str); 238 mUUID.toString(uuid_str);
239 output_stream << "\t\tobj_id\t" << uuid_str << "\n"; 239 output_stream << "\t\tobj_id\t" << uuid_str << "\n";
@@ -276,8 +276,8 @@ LLInventoryItem::LLInventoryItem(
276 const LLUUID& asset_uuid, 276 const LLUUID& asset_uuid,
277 LLAssetType::EType type, 277 LLAssetType::EType type,
278 LLInventoryType::EType inv_type, 278 LLInventoryType::EType inv_type,
279 const LLString& name, 279 const std::string& name,
280 const LLString& desc, 280 const std::string& desc,
281 const LLSaleInfo& sale_info, 281 const LLSaleInfo& sale_info,
282 U32 flags, 282 U32 flags,
283 S32 creation_date_utc) : 283 S32 creation_date_utc) :
@@ -290,8 +290,8 @@ LLInventoryItem::LLInventoryItem(
290 mFlags(flags), 290 mFlags(flags),
291 mCreationDate(creation_date_utc) 291 mCreationDate(creation_date_utc)
292{ 292{
293 LLString::replaceNonstandardASCII(mDescription, ' '); 293 LLStringUtil::replaceNonstandardASCII(mDescription, ' ');
294 LLString::replaceChar(mDescription, '|', ' '); 294 LLStringUtil::replaceChar(mDescription, '|', ' ');
295} 295}
296 296
297LLInventoryItem::LLInventoryItem() : 297LLInventoryItem::LLInventoryItem() :
@@ -359,12 +359,12 @@ void LLInventoryItem::setAssetUUID(const LLUUID& asset_id)
359} 359}
360 360
361 361
362const LLString& LLInventoryItem::getDescription() const 362const std::string& LLInventoryItem::getDescription() const
363{ 363{
364 return mDescription; 364 return mDescription;
365} 365}
366 366
367S32 LLInventoryItem::getCreationDate() const 367time_t LLInventoryItem::getCreationDate() const
368{ 368{
369 return mCreationDate; 369 return mCreationDate;
370} 370}
@@ -396,11 +396,11 @@ U32 LLInventoryItem::getCRC32() const
396} 396}
397 397
398 398
399void LLInventoryItem::setDescription(const LLString& d) 399void LLInventoryItem::setDescription(const std::string& d)
400{ 400{
401 LLString new_desc(d); 401 std::string new_desc(d);
402 LLString::replaceNonstandardASCII(new_desc, ' '); 402 LLStringUtil::replaceNonstandardASCII(new_desc, ' ');
403 LLString::replaceChar(new_desc, '|', ' '); 403 LLStringUtil::replaceChar(new_desc, '|', ' ');
404 if( new_desc != mDescription ) 404 if( new_desc != mDescription )
405 { 405 {
406 mDescription = new_desc; 406 mDescription = new_desc;
@@ -422,7 +422,7 @@ void LLInventoryItem::setFlags(U32 flags)
422 mFlags = flags; 422 mFlags = flags;
423} 423}
424 424
425void LLInventoryItem::setCreationDate(S32 creation_date_utc) 425void LLInventoryItem::setCreationDate(time_t creation_date_utc)
426{ 426{
427 mCreationDate = creation_date_utc; 427 mCreationDate = creation_date_utc;
428} 428}
@@ -486,17 +486,15 @@ BOOL LLInventoryItem::unpackMessage(LLMessageSystem* msg, const char* block, S32
486 486
487 mSaleInfo.unpackMultiMessage(msg, block, block_num); 487 mSaleInfo.unpackMultiMessage(msg, block, block_num);
488 488
489 char name[DB_INV_ITEM_NAME_BUF_SIZE]; /* Flawfinder: ignore */ 489 msg->getStringFast(block, _PREHASH_Name, mName, block_num);
490 msg->getStringFast(block, _PREHASH_Name, DB_INV_ITEM_NAME_BUF_SIZE, name, block_num); 490 LLStringUtil::replaceNonstandardASCII(mName, ' ');
491 mName.assign(name);
492 LLString::replaceNonstandardASCII(mName, ' ');
493 491
494 char desc[DB_INV_ITEM_DESC_BUF_SIZE]; /* Flawfinder: ignore */ 492 msg->getStringFast(block, _PREHASH_Description, mDescription, block_num);
495 msg->getStringFast(block, _PREHASH_Description, DB_INV_ITEM_DESC_BUF_SIZE, desc, block_num); 493 LLStringUtil::replaceNonstandardASCII(mDescription, ' ');
496 mDescription.assign(desc);
497 LLString::replaceNonstandardASCII(mDescription, ' ');
498 494
499 msg->getS32(block, "CreationDate", mCreationDate, block_num); 495 S32 date;
496 msg->getS32(block, "CreationDate", date, block_num);
497 mCreationDate = date;
500 498
501 U32 local_crc = getCRC32(); 499 U32 local_crc = getCRC32();
502 U32 remote_crc = 0; 500 U32 remote_crc = 0;
@@ -602,7 +600,7 @@ BOOL LLInventoryItem::importFile(LLFILE* fp)
602 } 600 }
603 else if(0 == strcmp("inv_type", keyword)) 601 else if(0 == strcmp("inv_type", keyword))
604 { 602 {
605 mInventoryType = LLInventoryType::lookup(valuestr); 603 mInventoryType = LLInventoryType::lookup(std::string(valuestr));
606 } 604 }
607 else if(0 == strcmp("flags", keyword)) 605 else if(0 == strcmp("flags", keyword))
608 { 606 {
@@ -624,8 +622,8 @@ BOOL LLInventoryItem::importFile(LLFILE* fp)
624 } 622 }
625 623
626 mName.assign(valuestr); 624 mName.assign(valuestr);
627 LLString::replaceNonstandardASCII(mName, ' '); 625 LLStringUtil::replaceNonstandardASCII(mName, ' ');
628 LLString::replaceChar(mName, '|', ' '); 626 LLStringUtil::replaceChar(mName, '|', ' ');
629 } 627 }
630 else if(0 == strcmp("desc", keyword)) 628 else if(0 == strcmp("desc", keyword))
631 { 629 {
@@ -642,7 +640,7 @@ BOOL LLInventoryItem::importFile(LLFILE* fp)
642 } 640 }
643 641
644 mDescription.assign(valuestr); 642 mDescription.assign(valuestr);
645 LLString::replaceNonstandardASCII(mDescription, ' '); 643 LLStringUtil::replaceNonstandardASCII(mDescription, ' ');
646 /* TODO -- ask Ian about this code 644 /* TODO -- ask Ian about this code
647 const char *donkey = mDescription.c_str(); 645 const char *donkey = mDescription.c_str();
648 if (donkey[0] == '|') 646 if (donkey[0] == '|')
@@ -653,7 +651,9 @@ BOOL LLInventoryItem::importFile(LLFILE* fp)
653 } 651 }
654 else if(0 == strcmp("creation_date", keyword)) 652 else if(0 == strcmp("creation_date", keyword))
655 { 653 {
656 sscanf(valuestr, "%d", &mCreationDate); 654 S32 date;
655 sscanf(valuestr, "%d", &date);
656 mCreationDate = date;
657 } 657 }
658 else 658 else
659 { 659 {
@@ -676,12 +676,12 @@ BOOL LLInventoryItem::importFile(LLFILE* fp)
676 676
677BOOL LLInventoryItem::exportFile(LLFILE* fp, BOOL include_asset_key) const 677BOOL LLInventoryItem::exportFile(LLFILE* fp, BOOL include_asset_key) const
678{ 678{
679 char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ 679 std::string uuid_str;
680 fprintf(fp, "\tinv_item\t0\n\t{\n"); 680 fprintf(fp, "\tinv_item\t0\n\t{\n");
681 mUUID.toString(uuid_str); 681 mUUID.toString(uuid_str);
682 fprintf(fp, "\t\titem_id\t%s\n", uuid_str); 682 fprintf(fp, "\t\titem_id\t%s\n", uuid_str.c_str());
683 mParentUUID.toString(uuid_str); 683 mParentUUID.toString(uuid_str);
684 fprintf(fp, "\t\tparent_id\t%s\n", uuid_str); 684 fprintf(fp, "\t\tparent_id\t%s\n", uuid_str.c_str());
685 mPermissions.exportFile(fp); 685 mPermissions.exportFile(fp);
686 686
687 // Check for permissions to see the asset id, and if so write it 687 // Check for permissions to see the asset id, and if so write it
@@ -693,7 +693,7 @@ BOOL LLInventoryItem::exportFile(LLFILE* fp, BOOL include_asset_key) const
693 || (mAssetUUID.isNull())) 693 || (mAssetUUID.isNull()))
694 { 694 {
695 mAssetUUID.toString(uuid_str); 695 mAssetUUID.toString(uuid_str);
696 fprintf(fp, "\t\tasset_id\t%s\n", uuid_str); 696 fprintf(fp, "\t\tasset_id\t%s\n", uuid_str.c_str());
697 } 697 }
698 else 698 else
699 { 699 {
@@ -701,13 +701,13 @@ BOOL LLInventoryItem::exportFile(LLFILE* fp, BOOL include_asset_key) const
701 LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES); 701 LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
702 cipher.encrypt(shadow_id.mData, UUID_BYTES); 702 cipher.encrypt(shadow_id.mData, UUID_BYTES);
703 shadow_id.toString(uuid_str); 703 shadow_id.toString(uuid_str);
704 fprintf(fp, "\t\tshadow_id\t%s\n", uuid_str); 704 fprintf(fp, "\t\tshadow_id\t%s\n", uuid_str.c_str());
705 } 705 }
706 } 706 }
707 else 707 else
708 { 708 {
709 LLUUID::null.toString(uuid_str); 709 LLUUID::null.toString(uuid_str);
710 fprintf(fp, "\t\tasset_id\t%s\n", uuid_str); 710 fprintf(fp, "\t\tasset_id\t%s\n", uuid_str.c_str());
711 } 711 }
712 fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType)); 712 fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType));
713 const char* inv_type_str = LLInventoryType::lookup(mInventoryType); 713 const char* inv_type_str = LLInventoryType::lookup(mInventoryType);
@@ -716,7 +716,7 @@ BOOL LLInventoryItem::exportFile(LLFILE* fp, BOOL include_asset_key) const
716 mSaleInfo.exportFile(fp); 716 mSaleInfo.exportFile(fp);
717 fprintf(fp, "\t\tname\t%s|\n", mName.c_str()); 717 fprintf(fp, "\t\tname\t%s|\n", mName.c_str());
718 fprintf(fp, "\t\tdesc\t%s|\n", mDescription.c_str()); 718 fprintf(fp, "\t\tdesc\t%s|\n", mDescription.c_str());
719 fprintf(fp, "\t\tcreation_date\t%d\n", mCreationDate); 719 fprintf(fp, "\t\tcreation_date\t%d\n", (S32) mCreationDate);
720 fprintf(fp,"\t}\n"); 720 fprintf(fp,"\t}\n");
721 return TRUE; 721 return TRUE;
722} 722}
@@ -803,7 +803,7 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream)
803 } 803 }
804 else if(0 == strcmp("inv_type", keyword)) 804 else if(0 == strcmp("inv_type", keyword))
805 { 805 {
806 mInventoryType = LLInventoryType::lookup(valuestr); 806 mInventoryType = LLInventoryType::lookup(std::string(valuestr));
807 } 807 }
808 else if(0 == strcmp("flags", keyword)) 808 else if(0 == strcmp("flags", keyword))
809 { 809 {
@@ -825,8 +825,8 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream)
825 } 825 }
826 826
827 mName.assign(valuestr); 827 mName.assign(valuestr);
828 LLString::replaceNonstandardASCII(mName, ' '); 828 LLStringUtil::replaceNonstandardASCII(mName, ' ');
829 LLString::replaceChar(mName, '|', ' '); 829 LLStringUtil::replaceChar(mName, '|', ' ');
830 } 830 }
831 else if(0 == strcmp("desc", keyword)) 831 else if(0 == strcmp("desc", keyword))
832 { 832 {
@@ -843,7 +843,7 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream)
843 } 843 }
844 844
845 mDescription.assign(valuestr); 845 mDescription.assign(valuestr);
846 LLString::replaceNonstandardASCII(mDescription, ' '); 846 LLStringUtil::replaceNonstandardASCII(mDescription, ' ');
847 /* TODO -- ask Ian about this code 847 /* TODO -- ask Ian about this code
848 const char *donkey = mDescription.c_str(); 848 const char *donkey = mDescription.c_str();
849 if (donkey[0] == '|') 849 if (donkey[0] == '|')
@@ -854,7 +854,9 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream)
854 } 854 }
855 else if(0 == strcmp("creation_date", keyword)) 855 else if(0 == strcmp("creation_date", keyword))
856 { 856 {
857 sscanf(valuestr, "%d", &mCreationDate); 857 S32 date;
858 sscanf(valuestr, "%d", &date);
859 mCreationDate = date;
858 } 860 }
859 else 861 else
860 { 862 {
@@ -877,7 +879,7 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream)
877 879
878BOOL LLInventoryItem::exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key) const 880BOOL LLInventoryItem::exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key) const
879{ 881{
880 char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ 882 std::string uuid_str;
881 output_stream << "\tinv_item\t0\n\t{\n"; 883 output_stream << "\tinv_item\t0\n\t{\n";
882 mUUID.toString(uuid_str); 884 mUUID.toString(uuid_str);
883 output_stream << "\t\titem_id\t" << uuid_str << "\n"; 885 output_stream << "\t\titem_id\t" << uuid_str << "\n";
@@ -914,8 +916,8 @@ BOOL LLInventoryItem::exportLegacyStream(std::ostream& output_stream, BOOL inclu
914 const char* inv_type_str = LLInventoryType::lookup(mInventoryType); 916 const char* inv_type_str = LLInventoryType::lookup(mInventoryType);
915 if(inv_type_str) 917 if(inv_type_str)
916 output_stream << "\t\tinv_type\t" << inv_type_str << "\n"; 918 output_stream << "\t\tinv_type\t" << inv_type_str << "\n";
917 char buffer[32]; /* Flawfinder: ignore */ 919 std::string buffer;
918 snprintf(buffer, sizeof(buffer), "\t\tflags\t%08x\n", mFlags); /* Flawfinder: ignore */ 920 buffer = llformat( "\t\tflags\t%08x\n", mFlags);
919 output_stream << buffer; 921 output_stream << buffer;
920 mSaleInfo.exportLegacyStream(output_stream); 922 mSaleInfo.exportLegacyStream(output_stream);
921 output_stream << "\t\tname\t" << mName.c_str() << "|\n"; 923 output_stream << "\t\tname\t" << mName.c_str() << "|\n";
@@ -956,7 +958,7 @@ LLSD LLInventoryItem::asLLSD() const
956 sd[INV_SALE_INFO_LABEL] = mSaleInfo; 958 sd[INV_SALE_INFO_LABEL] = mSaleInfo;
957 sd[INV_NAME_LABEL] = mName; 959 sd[INV_NAME_LABEL] = mName;
958 sd[INV_DESC_LABEL] = mDescription; 960 sd[INV_DESC_LABEL] = mDescription;
959 sd[INV_CREATION_DATE_LABEL] = mCreationDate; 961 sd[INV_CREATION_DATE_LABEL] = (S32) mCreationDate;
960 962
961 return sd; 963 return sd;
962} 964}
@@ -1024,12 +1026,12 @@ bool LLInventoryItem::fromLLSD(LLSD& sd)
1024 w = INV_ASSET_TYPE_LABEL; 1026 w = INV_ASSET_TYPE_LABEL;
1025 if (sd.has(w)) 1027 if (sd.has(w))
1026 { 1028 {
1027 mType = LLAssetType::lookup(sd[w].asString().c_str()); 1029 mType = LLAssetType::lookup(sd[w].asString());
1028 } 1030 }
1029 w = INV_INVENTORY_TYPE_LABEL; 1031 w = INV_INVENTORY_TYPE_LABEL;
1030 if (sd.has(w)) 1032 if (sd.has(w))
1031 { 1033 {
1032 mInventoryType = LLInventoryType::lookup(sd[w].asString().c_str()); 1034 mInventoryType = LLInventoryType::lookup(sd[w].asString());
1033 } 1035 }
1034 w = INV_FLAGS_LABEL; 1036 w = INV_FLAGS_LABEL;
1035 if (sd.has(w)) 1037 if (sd.has(w))
@@ -1040,19 +1042,19 @@ bool LLInventoryItem::fromLLSD(LLSD& sd)
1040 if (sd.has(w)) 1042 if (sd.has(w))
1041 { 1043 {
1042 mName = sd[w].asString(); 1044 mName = sd[w].asString();
1043 LLString::replaceNonstandardASCII(mName, ' '); 1045 LLStringUtil::replaceNonstandardASCII(mName, ' ');
1044 LLString::replaceChar(mName, '|', ' '); 1046 LLStringUtil::replaceChar(mName, '|', ' ');
1045 } 1047 }
1046 w = INV_DESC_LABEL; 1048 w = INV_DESC_LABEL;
1047 if (sd.has(w)) 1049 if (sd.has(w))
1048 { 1050 {
1049 mDescription = sd[w].asString(); 1051 mDescription = sd[w].asString();
1050 LLString::replaceNonstandardASCII(mDescription, ' '); 1052 LLStringUtil::replaceNonstandardASCII(mDescription, ' ');
1051 } 1053 }
1052 w = INV_CREATION_DATE_LABEL; 1054 w = INV_CREATION_DATE_LABEL;
1053 if (sd.has(w)) 1055 if (sd.has(w))
1054 { 1056 {
1055 mCreationDate = sd[w]; 1057 mCreationDate = sd[w].asInteger();
1056 } 1058 }
1057 1059
1058 // Need to convert 1.0 simstate files to a useful inventory type 1060 // Need to convert 1.0 simstate files to a useful inventory type
@@ -1101,22 +1103,23 @@ LLXMLNode *LLInventoryItem::exportFileXML(BOOL include_asset_key) const
1101 } 1103 }
1102 } 1104 }
1103 1105
1104 LLString type_str = LLAssetType::lookup(mType); 1106 std::string type_str = LLAssetType::lookup(mType);
1105 LLString inv_type_str = LLInventoryType::lookup(mInventoryType); 1107 std::string inv_type_str = LLInventoryType::lookup(mInventoryType);
1106 1108
1107 ret->createChild("asset_type", FALSE)->setStringValue(1, &type_str); 1109 ret->createChild("asset_type", FALSE)->setStringValue(type_str);
1108 ret->createChild("inventory_type", FALSE)->setStringValue(1, &inv_type_str); 1110 ret->createChild("inventory_type", FALSE)->setStringValue(inv_type_str);
1109 S32 tmp_flags = (S32) mFlags; 1111 S32 tmp_flags = (S32) mFlags;
1110 ret->createChild("flags", FALSE)->setByteValue(4, (U8*)(&tmp_flags), LLXMLNode::ENCODING_HEX); 1112 ret->createChild("flags", FALSE)->setByteValue(4, (U8*)(&tmp_flags), LLXMLNode::ENCODING_HEX);
1111 1113
1112 mSaleInfo.exportFileXML()->setParent(ret); 1114 mSaleInfo.exportFileXML()->setParent(ret);
1113 1115
1114 LLString temp; 1116 std::string temp;
1115 temp.assign(mName); 1117 temp.assign(mName);
1116 ret->createChild("name", FALSE)->setStringValue(1, &temp); 1118 ret->createChild("name", FALSE)->setStringValue(temp);
1117 temp.assign(mDescription); 1119 temp.assign(mDescription);
1118 ret->createChild("description", FALSE)->setStringValue(1, &temp); 1120 ret->createChild("description", FALSE)->setStringValue(temp);
1119 ret->createChild("creation_date", FALSE)->setIntValue(1, &mCreationDate); 1121 S32 date = mCreationDate;
1122 ret->createChild("creation_date", FALSE)->setIntValue(1, &date);
1120 1123
1121 return ret; 1124 return ret;
1122} 1125}
@@ -1143,9 +1146,9 @@ BOOL LLInventoryItem::importXML(LLXMLNode* node)
1143 cipher.decrypt(mAssetUUID.mData, UUID_BYTES); 1146 cipher.decrypt(mAssetUUID.mData, UUID_BYTES);
1144 } 1147 }
1145 if (node->getChild("asset_type", sub_node)) 1148 if (node->getChild("asset_type", sub_node))
1146 mType = LLAssetType::lookup(sub_node->getValue().c_str()); 1149 mType = LLAssetType::lookup(sub_node->getValue());
1147 if (node->getChild("inventory_type", sub_node)) 1150 if (node->getChild("inventory_type", sub_node))
1148 mInventoryType = LLInventoryType::lookup(sub_node->getValue().c_str()); 1151 mInventoryType = LLInventoryType::lookup(sub_node->getValue());
1149 if (node->getChild("flags", sub_node)) 1152 if (node->getChild("flags", sub_node))
1150 { 1153 {
1151 S32 tmp_flags = 0; 1154 S32 tmp_flags = 0;
@@ -1159,7 +1162,12 @@ BOOL LLInventoryItem::importXML(LLXMLNode* node)
1159 if (node->getChild("description", sub_node)) 1162 if (node->getChild("description", sub_node))
1160 mDescription = sub_node->getValue(); 1163 mDescription = sub_node->getValue();
1161 if (node->getChild("creation_date", sub_node)) 1164 if (node->getChild("creation_date", sub_node))
1162 success = success && (1 == sub_node->getIntValue(1, &mCreationDate)); 1165 {
1166 S32 date = 0;
1167 success = success && (1 == sub_node->getIntValue(1, &date));
1168 mCreationDate = date;
1169 }
1170
1163 if (!success) 1171 if (!success)
1164 { 1172 {
1165 lldebugs << "LLInventory::importXML() failed for node named '" 1173 lldebugs << "LLInventory::importXML() failed for node named '"
@@ -1186,32 +1194,32 @@ S32 LLInventoryItem::packBinaryBucket(U8* bin_bucket, LLPermissions* perm_overri
1186 1194
1187 // describe the inventory item 1195 // describe the inventory item
1188 char* buffer = (char*) bin_bucket; 1196 char* buffer = (char*) bin_bucket;
1189 char creator_id_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ 1197 std::string creator_id_str;
1190 1198
1191 perm.getCreator().toString(creator_id_str); 1199 perm.getCreator().toString(creator_id_str);
1192 char owner_id_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ 1200 std::string owner_id_str;
1193 perm.getOwner().toString(owner_id_str); 1201 perm.getOwner().toString(owner_id_str);
1194 char last_owner_id_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ 1202 std::string last_owner_id_str;
1195 perm.getLastOwner().toString(last_owner_id_str); 1203 perm.getLastOwner().toString(last_owner_id_str);
1196 char group_id_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ 1204 std::string group_id_str;
1197 perm.getGroup().toString(group_id_str); 1205 perm.getGroup().toString(group_id_str);
1198 char asset_id_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ 1206 std::string asset_id_str;
1199 getAssetUUID().toString(asset_id_str); 1207 getAssetUUID().toString(asset_id_str);
1200 S32 size = sprintf(buffer, /* Flawfinder: ignore */ 1208 S32 size = sprintf(buffer, /* Flawfinder: ignore */
1201 "%d|%d|%s|%s|%s|%s|%s|%x|%x|%x|%x|%x|%s|%s|%d|%d|%x", 1209 "%d|%d|%s|%s|%s|%s|%s|%x|%x|%x|%x|%x|%s|%s|%d|%d|%x",
1202 getType(), 1210 getType(),
1203 getInventoryType(), 1211 getInventoryType(),
1204 getName().c_str(), 1212 getName().c_str(),
1205 creator_id_str, 1213 creator_id_str.c_str(),
1206 owner_id_str, 1214 owner_id_str.c_str(),
1207 last_owner_id_str, 1215 last_owner_id_str.c_str(),
1208 group_id_str, 1216 group_id_str.c_str(),
1209 perm.getMaskBase(), 1217 perm.getMaskBase(),
1210 perm.getMaskOwner(), 1218 perm.getMaskOwner(),
1211 perm.getMaskGroup(), 1219 perm.getMaskGroup(),
1212 perm.getMaskEveryone(), 1220 perm.getMaskEveryone(),
1213 perm.getMaskNextOwner(), 1221 perm.getMaskNextOwner(),
1214 asset_id_str, 1222 asset_id_str.c_str(),
1215 getDescription().c_str(), 1223 getDescription().c_str(),
1216 getSaleInfo().getSaleType(), 1224 getSaleInfo().getSaleType(),
1217 getSaleInfo().getSalePrice(), 1225 getSaleInfo().getSalePrice(),
@@ -1262,7 +1270,7 @@ void LLInventoryItem::unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size)
1262 inv_type = (LLInventoryType::EType)(atoi((*(iter++)).c_str())); 1270 inv_type = (LLInventoryType::EType)(atoi((*(iter++)).c_str()));
1263 setInventoryType( inv_type ); 1271 setInventoryType( inv_type );
1264 1272
1265 LLString name((*(iter++)).c_str()); 1273 std::string name((*(iter++)).c_str());
1266 rename( name ); 1274 rename( name );
1267 1275
1268 LLUUID creator_id((*(iter++)).c_str()); 1276 LLUUID creator_id((*(iter++)).c_str());
@@ -1283,7 +1291,7 @@ void LLInventoryItem::unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size)
1283 LLUUID asset_id((*(iter++)).c_str()); 1291 LLUUID asset_id((*(iter++)).c_str());
1284 setAssetUUID(asset_id); 1292 setAssetUUID(asset_id);
1285 1293
1286 LLString desc((*(iter++)).c_str()); 1294 std::string desc((*(iter++)).c_str());
1287 setDescription(desc); 1295 setDescription(desc);
1288 1296
1289 LLSaleInfo::EForSale sale_type; 1297 LLSaleInfo::EForSale sale_type;
@@ -1302,7 +1310,7 @@ void LLInventoryItem::unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size)
1302// returns TRUE if a should appear before b 1310// returns TRUE if a should appear before b
1303BOOL item_dictionary_sort( LLInventoryItem* a, LLInventoryItem* b ) 1311BOOL item_dictionary_sort( LLInventoryItem* a, LLInventoryItem* b )
1304{ 1312{
1305 return (LLString::compareDict( a->getName().c_str(), b->getName().c_str() ) < 0); 1313 return (LLStringUtil::compareDict( a->getName().c_str(), b->getName().c_str() ) < 0);
1306} 1314}
1307 1315
1308// returns TRUE if a should appear before b 1316// returns TRUE if a should appear before b
@@ -1320,7 +1328,7 @@ LLInventoryCategory::LLInventoryCategory(
1320 const LLUUID& uuid, 1328 const LLUUID& uuid,
1321 const LLUUID& parent_uuid, 1329 const LLUUID& parent_uuid,
1322 LLAssetType::EType preferred_type, 1330 LLAssetType::EType preferred_type,
1323 const LLString& name) : 1331 const std::string& name) :
1324 LLInventoryObject(uuid, parent_uuid, LLAssetType::AT_CATEGORY, name), 1332 LLInventoryObject(uuid, parent_uuid, LLAssetType::AT_CATEGORY, name),
1325 mPreferredType(preferred_type) 1333 mPreferredType(preferred_type)
1326{ 1334{
@@ -1406,8 +1414,8 @@ bool LLInventoryCategory::fromLLSD(LLSD& sd)
1406 if (sd.has(w)) 1414 if (sd.has(w))
1407 { 1415 {
1408 mName = sd[w].asString(); 1416 mName = sd[w].asString();
1409 LLString::replaceNonstandardASCII(mName, ' '); 1417 LLStringUtil::replaceNonstandardASCII(mName, ' ');
1410 LLString::replaceChar(mName, '|', ' '); 1418 LLStringUtil::replaceChar(mName, '|', ' ');
1411 } 1419 }
1412 return true; 1420 return true;
1413} 1421}
@@ -1422,10 +1430,8 @@ void LLInventoryCategory::unpackMessage(LLMessageSystem* msg,
1422 S8 type; 1430 S8 type;
1423 msg->getS8Fast(block, _PREHASH_Type, type, block_num); 1431 msg->getS8Fast(block, _PREHASH_Type, type, block_num);
1424 mPreferredType = static_cast<LLAssetType::EType>(type); 1432 mPreferredType = static_cast<LLAssetType::EType>(type);
1425 char name[DB_INV_ITEM_NAME_BUF_SIZE]; /* Flawfinder: ignore */ 1433 msg->getStringFast(block, _PREHASH_Name, mName, block_num);
1426 msg->getStringFast(block, _PREHASH_Name, DB_INV_ITEM_NAME_BUF_SIZE, name, block_num); 1434 LLStringUtil::replaceNonstandardASCII(mName, ' ');
1427 mName.assign(name);
1428 LLString::replaceNonstandardASCII(mName, ' ');
1429} 1435}
1430 1436
1431// virtual 1437// virtual
@@ -1483,8 +1489,8 @@ BOOL LLInventoryCategory::importFile(LLFILE* fp)
1483 " %254s %254[^|]", 1489 " %254s %254[^|]",
1484 keyword, valuestr); 1490 keyword, valuestr);
1485 mName.assign(valuestr); 1491 mName.assign(valuestr);
1486 LLString::replaceNonstandardASCII(mName, ' '); 1492 LLStringUtil::replaceNonstandardASCII(mName, ' ');
1487 LLString::replaceChar(mName, '|', ' '); 1493 LLStringUtil::replaceChar(mName, '|', ' ');
1488 } 1494 }
1489 else 1495 else
1490 { 1496 {
@@ -1497,12 +1503,12 @@ BOOL LLInventoryCategory::importFile(LLFILE* fp)
1497 1503
1498BOOL LLInventoryCategory::exportFile(LLFILE* fp, BOOL) const 1504BOOL LLInventoryCategory::exportFile(LLFILE* fp, BOOL) const
1499{ 1505{
1500 char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ 1506 std::string uuid_str;
1501 fprintf(fp, "\tinv_category\t0\n\t{\n"); 1507 fprintf(fp, "\tinv_category\t0\n\t{\n");
1502 mUUID.toString(uuid_str); 1508 mUUID.toString(uuid_str);
1503 fprintf(fp, "\t\tcat_id\t%s\n", uuid_str); 1509 fprintf(fp, "\t\tcat_id\t%s\n", uuid_str.c_str());
1504 mParentUUID.toString(uuid_str); 1510 mParentUUID.toString(uuid_str);
1505 fprintf(fp, "\t\tparent_id\t%s\n", uuid_str); 1511 fprintf(fp, "\t\tparent_id\t%s\n", uuid_str.c_str());
1506 fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType)); 1512 fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType));
1507 fprintf(fp, "\t\tpref_type\t%s\n", LLAssetType::lookup(mPreferredType)); 1513 fprintf(fp, "\t\tpref_type\t%s\n", LLAssetType::lookup(mPreferredType));
1508 fprintf(fp, "\t\tname\t%s|\n", mName.c_str()); 1514 fprintf(fp, "\t\tname\t%s|\n", mName.c_str());
@@ -1562,8 +1568,8 @@ BOOL LLInventoryCategory::importLegacyStream(std::istream& input_stream)
1562 " %254s %254[^|]", 1568 " %254s %254[^|]",
1563 keyword, valuestr); 1569 keyword, valuestr);
1564 mName.assign(valuestr); 1570 mName.assign(valuestr);
1565 LLString::replaceNonstandardASCII(mName, ' '); 1571 LLStringUtil::replaceNonstandardASCII(mName, ' ');
1566 LLString::replaceChar(mName, '|', ' '); 1572 LLStringUtil::replaceChar(mName, '|', ' ');
1567 } 1573 }
1568 else 1574 else
1569 { 1575 {
@@ -1576,7 +1582,7 @@ BOOL LLInventoryCategory::importLegacyStream(std::istream& input_stream)
1576 1582
1577BOOL LLInventoryCategory::exportLegacyStream(std::ostream& output_stream, BOOL) const 1583BOOL LLInventoryCategory::exportLegacyStream(std::ostream& output_stream, BOOL) const
1578{ 1584{
1579 char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ 1585 std::string uuid_str;
1580 output_stream << "\tinv_category\t0\n\t{\n"; 1586 output_stream << "\tinv_category\t0\n\t{\n";
1581 mUUID.toString(uuid_str); 1587 mUUID.toString(uuid_str);
1582 output_stream << "\t\tcat_id\t" << uuid_str << "\n"; 1588 output_stream << "\t\tcat_id\t" << uuid_str << "\n";
@@ -1615,7 +1621,7 @@ LLSD ll_create_sd_from_inventory_item(LLPointer<LLInventoryItem> item)
1615 rv[INV_INVENTORY_TYPE_LABEL] = 1621 rv[INV_INVENTORY_TYPE_LABEL] =
1616 LLInventoryType::lookup(item->getInventoryType()); 1622 LLInventoryType::lookup(item->getInventoryType());
1617 rv[INV_FLAGS_LABEL] = (S32)item->getFlags(); 1623 rv[INV_FLAGS_LABEL] = (S32)item->getFlags();
1618 rv[INV_CREATION_DATE_LABEL] = item->getCreationDate(); 1624 rv[INV_CREATION_DATE_LABEL] = (S32)item->getCreationDate();
1619 return rv; 1625 return rv;
1620} 1626}
1621 1627
@@ -1626,7 +1632,7 @@ LLPointer<LLInventoryItem> ll_create_item_from_sd(const LLSD& sd_item)
1626 rv->setParent(sd_item[INV_PARENT_ID_LABEL].asUUID()); 1632 rv->setParent(sd_item[INV_PARENT_ID_LABEL].asUUID());
1627 rv->rename(sd_item[INV_NAME_LABEL].asString()); 1633 rv->rename(sd_item[INV_NAME_LABEL].asString());
1628 rv->setType( 1634 rv->setType(
1629 LLAssetType::lookup(sd_item[INV_ASSET_TYPE_LABEL].asString().c_str())); 1635 LLAssetType::lookup(sd_item[INV_ASSET_TYPE_LABEL].asString()));
1630 if (sd_item.has("shadow_id")) 1636 if (sd_item.has("shadow_id"))
1631 { 1637 {
1632 LLUUID asset_id = sd_item["shadow_id"]; 1638 LLUUID asset_id = sd_item["shadow_id"];
@@ -1643,7 +1649,7 @@ LLPointer<LLInventoryItem> ll_create_item_from_sd(const LLSD& sd_item)
1643 rv->setPermissions(ll_permissions_from_sd(sd_item[INV_PERMISSIONS_LABEL])); 1649 rv->setPermissions(ll_permissions_from_sd(sd_item[INV_PERMISSIONS_LABEL]));
1644 rv->setInventoryType( 1650 rv->setInventoryType(
1645 LLInventoryType::lookup( 1651 LLInventoryType::lookup(
1646 sd_item[INV_INVENTORY_TYPE_LABEL].asString().c_str())); 1652 sd_item[INV_INVENTORY_TYPE_LABEL].asString()));
1647 rv->setFlags((U32)(sd_item[INV_FLAGS_LABEL].asInteger())); 1653 rv->setFlags((U32)(sd_item[INV_FLAGS_LABEL].asInteger()));
1648 rv->setCreationDate(sd_item[INV_CREATION_DATE_LABEL].asInteger()); 1654 rv->setCreationDate(sd_item[INV_CREATION_DATE_LABEL].asInteger());
1649 return rv; 1655 return rv;
@@ -1678,9 +1684,9 @@ LLPointer<LLInventoryCategory> ll_create_category_from_sd(const LLSD& sd_cat)
1678 rv->setParent(sd_cat[INV_PARENT_ID_LABEL].asUUID()); 1684 rv->setParent(sd_cat[INV_PARENT_ID_LABEL].asUUID());
1679 rv->rename(sd_cat[INV_NAME_LABEL].asString()); 1685 rv->rename(sd_cat[INV_NAME_LABEL].asString());
1680 rv->setType( 1686 rv->setType(
1681 LLAssetType::lookup(sd_cat[INV_ASSET_TYPE_LABEL].asString().c_str())); 1687 LLAssetType::lookup(sd_cat[INV_ASSET_TYPE_LABEL].asString()));
1682 rv->setPreferredType( 1688 rv->setPreferredType(
1683 LLAssetType::lookup( 1689 LLAssetType::lookup(
1684 sd_cat[INV_PREFERRED_TYPE_LABEL].asString().c_str())); 1690 sd_cat[INV_PREFERRED_TYPE_LABEL].asString()));
1685 return rv; 1691 return rv;
1686} 1692}