diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llinventory/llinventory.cpp | 225 |
1 files changed, 3 insertions, 222 deletions
diff --git a/linden/indra/llinventory/llinventory.cpp b/linden/indra/llinventory/llinventory.cpp index 85fc47f..93c480e 100644 --- a/linden/indra/llinventory/llinventory.cpp +++ b/linden/indra/llinventory/llinventory.cpp | |||
@@ -40,8 +40,6 @@ | |||
40 | 40 | ||
41 | #include "llsdutil.h" | 41 | #include "llsdutil.h" |
42 | 42 | ||
43 | #include "llsdutil.h" | ||
44 | |||
45 | ///---------------------------------------------------------------------------- | 43 | ///---------------------------------------------------------------------------- |
46 | /// exported functions | 44 | /// exported functions |
47 | ///---------------------------------------------------------------------------- | 45 | ///---------------------------------------------------------------------------- |
@@ -67,187 +65,8 @@ static const std::string INV_CREATION_DATE_LABEL("created_at"); | |||
67 | const U8 TASK_INVENTORY_ITEM_KEY = 0; | 65 | const U8 TASK_INVENTORY_ITEM_KEY = 0; |
68 | const U8 TASK_INVENTORY_ASSET_KEY = 1; | 66 | const U8 TASK_INVENTORY_ASSET_KEY = 1; |
69 | 67 | ||
70 | const LLUUID MAGIC_ID("3c115e51-04f4-523c-9fa6-98aff1034730"); | 68 | const LLUUID MAGIC_ID("3c115e51-04f4-523c-9fa6-98aff1034730"); |
71 | |||
72 | // helper function which returns true if inventory type and asset type | ||
73 | // are potentially compatible. For example, an attachment must be an | ||
74 | // object, but a wearable can be a bodypart or clothing asset. | ||
75 | bool inventory_and_asset_types_match( | ||
76 | LLInventoryType::EType inventory_type, | ||
77 | LLAssetType::EType asset_type); | ||
78 | |||
79 | 69 | ||
80 | ///---------------------------------------------------------------------------- | ||
81 | /// Class LLInventoryType | ||
82 | ///---------------------------------------------------------------------------- | ||
83 | |||
84 | // Unlike asset type names, not limited to 8 characters. | ||
85 | // Need not match asset type names. | ||
86 | static const char* INVENTORY_TYPE_NAMES[LLInventoryType::IT_COUNT] = | ||
87 | { | ||
88 | "texture", // 0 | ||
89 | "sound", | ||
90 | "callcard", | ||
91 | "landmark", | ||
92 | NULL, | ||
93 | NULL, // 5 | ||
94 | "object", | ||
95 | "notecard", | ||
96 | "category", | ||
97 | "root", | ||
98 | "script", // 10 | ||
99 | NULL, | ||
100 | NULL, | ||
101 | NULL, | ||
102 | NULL, | ||
103 | "snapshot", // 15 | ||
104 | NULL, | ||
105 | "attach", | ||
106 | "wearable", | ||
107 | "animation", | ||
108 | "gesture", // 20 | ||
109 | }; | ||
110 | |||
111 | // This table is meant for decoding to human readable form. Put any | ||
112 | // and as many printable characters you want in each one. | ||
113 | // See also LLAssetType::mAssetTypeHumanNames | ||
114 | static const char* INVENTORY_TYPE_HUMAN_NAMES[LLInventoryType::IT_COUNT] = | ||
115 | { | ||
116 | "texture", // 0 | ||
117 | "sound", | ||
118 | "calling card", | ||
119 | "landmark", | ||
120 | NULL, | ||
121 | NULL, // 5 | ||
122 | "object", | ||
123 | "note card", | ||
124 | "folder", | ||
125 | "root", | ||
126 | "script", // 10 | ||
127 | NULL, | ||
128 | NULL, | ||
129 | NULL, | ||
130 | NULL, | ||
131 | "snapshot", // 15 | ||
132 | NULL, | ||
133 | "attachment", | ||
134 | "wearable", | ||
135 | "animation", | ||
136 | "gesture", // 20 | ||
137 | }; | ||
138 | |||
139 | // Maps asset types to the default inventory type for that kind of asset. | ||
140 | // Thus, "Lost and Found" is a "Category" | ||
141 | static const LLInventoryType::EType | ||
142 | DEFAULT_ASSET_FOR_INV_TYPE[LLAssetType::AT_COUNT] = | ||
143 | { | ||
144 | LLInventoryType::IT_TEXTURE, // AT_TEXTURE | ||
145 | LLInventoryType::IT_SOUND, // AT_SOUND | ||
146 | LLInventoryType::IT_CALLINGCARD, // AT_CALLINGCARD | ||
147 | LLInventoryType::IT_LANDMARK, // AT_LANDMARK | ||
148 | LLInventoryType::IT_LSL, // AT_SCRIPT | ||
149 | LLInventoryType::IT_WEARABLE, // AT_CLOTHING | ||
150 | LLInventoryType::IT_OBJECT, // AT_OBJECT | ||
151 | LLInventoryType::IT_NOTECARD, // AT_NOTECARD | ||
152 | LLInventoryType::IT_CATEGORY, // AT_CATEGORY | ||
153 | LLInventoryType::IT_ROOT_CATEGORY, // AT_ROOT_CATEGORY | ||
154 | LLInventoryType::IT_LSL, // AT_LSL_TEXT | ||
155 | LLInventoryType::IT_LSL, // AT_LSL_BYTECODE | ||
156 | LLInventoryType::IT_TEXTURE, // AT_TEXTURE_TGA | ||
157 | LLInventoryType::IT_WEARABLE, // AT_BODYPART | ||
158 | LLInventoryType::IT_CATEGORY, // AT_TRASH | ||
159 | LLInventoryType::IT_CATEGORY, // AT_SNAPSHOT_CATEGORY | ||
160 | LLInventoryType::IT_CATEGORY, // AT_LOST_AND_FOUND | ||
161 | LLInventoryType::IT_SOUND, // AT_SOUND_WAV | ||
162 | LLInventoryType::IT_NONE, // AT_IMAGE_TGA | ||
163 | LLInventoryType::IT_NONE, // AT_IMAGE_JPEG | ||
164 | LLInventoryType::IT_ANIMATION, // AT_ANIMATION | ||
165 | LLInventoryType::IT_GESTURE, // AT_GESTURE | ||
166 | }; | ||
167 | |||
168 | static const int MAX_POSSIBLE_ASSET_TYPES = 2; | ||
169 | static const LLAssetType::EType | ||
170 | INVENTORY_TO_ASSET_TYPE[LLInventoryType::IT_COUNT][MAX_POSSIBLE_ASSET_TYPES] = | ||
171 | { | ||
172 | { LLAssetType::AT_TEXTURE, LLAssetType::AT_NONE }, // IT_TEXTURE | ||
173 | { LLAssetType::AT_SOUND, LLAssetType::AT_NONE }, // IT_SOUND | ||
174 | { LLAssetType::AT_CALLINGCARD, LLAssetType::AT_NONE }, // IT_CALLINGCARD | ||
175 | { LLAssetType::AT_LANDMARK, LLAssetType::AT_NONE }, // IT_LANDMARK | ||
176 | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, | ||
177 | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, | ||
178 | { LLAssetType::AT_OBJECT, LLAssetType::AT_NONE }, // IT_OBJECT | ||
179 | { LLAssetType::AT_NOTECARD, LLAssetType::AT_NONE }, // IT_NOTECARD | ||
180 | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, // IT_CATEGORY | ||
181 | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, // IT_ROOT_CATEGORY | ||
182 | { LLAssetType::AT_LSL_TEXT, LLAssetType::AT_LSL_BYTECODE }, // IT_LSL | ||
183 | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, | ||
184 | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, | ||
185 | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, | ||
186 | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, | ||
187 | { LLAssetType::AT_TEXTURE, LLAssetType::AT_NONE }, // IT_SNAPSHOT | ||
188 | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, | ||
189 | { LLAssetType::AT_OBJECT, LLAssetType::AT_NONE }, // IT_ATTACHMENT | ||
190 | { LLAssetType::AT_CLOTHING, LLAssetType::AT_BODYPART }, // IT_WEARABLE | ||
191 | { LLAssetType::AT_ANIMATION, LLAssetType::AT_NONE }, // IT_ANIMATION | ||
192 | { LLAssetType::AT_GESTURE, LLAssetType::AT_NONE }, // IT_GESTURE | ||
193 | }; | ||
194 | |||
195 | // static | ||
196 | const char* LLInventoryType::lookup(EType type) | ||
197 | { | ||
198 | if((type >= 0) && (type < IT_COUNT)) | ||
199 | { | ||
200 | return INVENTORY_TYPE_NAMES[S32(type)]; | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | return NULL; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | // static | ||
209 | LLInventoryType::EType LLInventoryType::lookup(const char* name) | ||
210 | { | ||
211 | for(S32 i = 0; i < IT_COUNT; ++i) | ||
212 | { | ||
213 | if((INVENTORY_TYPE_NAMES[i]) | ||
214 | && (0 == strcmp(name, INVENTORY_TYPE_NAMES[i]))) | ||
215 | { | ||
216 | // match | ||
217 | return (EType)i; | ||
218 | } | ||
219 | } | ||
220 | return IT_NONE; | ||
221 | } | ||
222 | |||
223 | // XUI:translate | ||
224 | // translation from a type to a human readable form. | ||
225 | // static | ||
226 | const char* LLInventoryType::lookupHumanReadable(EType type) | ||
227 | { | ||
228 | if((type >= 0) && (type < IT_COUNT)) | ||
229 | { | ||
230 | return INVENTORY_TYPE_HUMAN_NAMES[S32(type)]; | ||
231 | } | ||
232 | else | ||
233 | { | ||
234 | return NULL; | ||
235 | } | ||
236 | } | ||
237 | |||
238 | // return the default inventory for the given asset type. | ||
239 | // static | ||
240 | LLInventoryType::EType LLInventoryType::defaultForAssetType(LLAssetType::EType asset_type) | ||
241 | { | ||
242 | if((asset_type >= 0) && (asset_type < LLAssetType::AT_COUNT)) | ||
243 | { | ||
244 | return DEFAULT_ASSET_FOR_INV_TYPE[S32(asset_type)]; | ||
245 | } | ||
246 | else | ||
247 | { | ||
248 | return IT_NONE; | ||
249 | } | ||
250 | } | ||
251 | 70 | ||
252 | ///---------------------------------------------------------------------------- | 71 | ///---------------------------------------------------------------------------- |
253 | /// Class LLInventoryObject | 72 | /// Class LLInventoryObject |
@@ -351,10 +170,6 @@ BOOL LLInventoryObject::importLegacyStream(std::istream& input_stream) | |||
351 | { | 170 | { |
352 | input_stream.getline(buffer, MAX_STRING); | 171 | input_stream.getline(buffer, MAX_STRING); |
353 | sscanf(buffer, " %254s %254s", keyword, valuestr); /* Flawfinder: ignore */ | 172 | sscanf(buffer, " %254s %254s", keyword, valuestr); /* Flawfinder: ignore */ |
354 | if(!keyword) | ||
355 | { | ||
356 | continue; | ||
357 | } | ||
358 | if(0 == strcmp("{",keyword)) | 173 | if(0 == strcmp("{",keyword)) |
359 | { | 174 | { |
360 | continue; | 175 | continue; |
@@ -722,10 +537,6 @@ BOOL LLInventoryItem::importFile(FILE* fp) | |||
722 | { | 537 | { |
723 | fgets(buffer, MAX_STRING, fp); | 538 | fgets(buffer, MAX_STRING, fp); |
724 | sscanf(buffer, " %254s %254s", keyword, valuestr); /* Flawfinder: ignore */ | 539 | sscanf(buffer, " %254s %254s", keyword, valuestr); /* Flawfinder: ignore */ |
725 | if(!keyword) | ||
726 | { | ||
727 | continue; | ||
728 | } | ||
729 | if(0 == strcmp("{",keyword)) | 540 | if(0 == strcmp("{",keyword)) |
730 | { | 541 | { |
731 | continue; | 542 | continue; |
@@ -927,10 +738,6 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream) | |||
927 | buffer, | 738 | buffer, |
928 | " %254s %254s", | 739 | " %254s %254s", |
929 | keyword, valuestr); | 740 | keyword, valuestr); |
930 | if(!keyword) | ||
931 | { | ||
932 | continue; | ||
933 | } | ||
934 | if(0 == strcmp("{",keyword)) | 741 | if(0 == strcmp("{",keyword)) |
935 | { | 742 | { |
936 | continue; | 743 | continue; |
@@ -1419,7 +1226,8 @@ void LLInventoryItem::unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size) | |||
1419 | } | 1226 | } |
1420 | else | 1227 | else |
1421 | { | 1228 | { |
1422 | llerrs << "unpackBinaryBucket failed. item_buffer or bin_bucket is Null." << llendl; | 1229 | llerrs << "unpackBinaryBucket failed. item_buffer or bin_bucket is Null." << llendl; |
1230 | delete[] item_buffer; | ||
1423 | return; | 1231 | return; |
1424 | } | 1232 | } |
1425 | item_buffer[bin_bucket_size] = '\0'; | 1233 | item_buffer[bin_bucket_size] = '\0'; |
@@ -1588,10 +1396,6 @@ BOOL LLInventoryCategory::importFile(FILE* fp) | |||
1588 | buffer, | 1396 | buffer, |
1589 | " %254s %254s", | 1397 | " %254s %254s", |
1590 | keyword, valuestr); | 1398 | keyword, valuestr); |
1591 | if(!keyword) | ||
1592 | { | ||
1593 | continue; | ||
1594 | } | ||
1595 | if(0 == strcmp("{",keyword)) | 1399 | if(0 == strcmp("{",keyword)) |
1596 | { | 1400 | { |
1597 | continue; | 1401 | continue; |
@@ -1671,10 +1475,6 @@ BOOL LLInventoryCategory::importLegacyStream(std::istream& input_stream) | |||
1671 | buffer, | 1475 | buffer, |
1672 | " %254s %254s", | 1476 | " %254s %254s", |
1673 | keyword, valuestr); | 1477 | keyword, valuestr); |
1674 | if(!keyword) | ||
1675 | { | ||
1676 | continue; | ||
1677 | } | ||
1678 | if(0 == strcmp("{",keyword)) | 1478 | if(0 == strcmp("{",keyword)) |
1679 | { | 1479 | { |
1680 | continue; | 1480 | continue; |
@@ -1739,25 +1539,6 @@ BOOL LLInventoryCategory::exportLegacyStream(std::ostream& output_stream, BOOL) | |||
1739 | /// Local function definitions | 1539 | /// Local function definitions |
1740 | ///---------------------------------------------------------------------------- | 1540 | ///---------------------------------------------------------------------------- |
1741 | 1541 | ||
1742 | bool inventory_and_asset_types_match( | ||
1743 | LLInventoryType::EType inventory_type, | ||
1744 | LLAssetType::EType asset_type) | ||
1745 | { | ||
1746 | bool rv = false; | ||
1747 | if((inventory_type >= 0) && (inventory_type < LLInventoryType::IT_COUNT)) | ||
1748 | { | ||
1749 | for(S32 i = 0; i < MAX_POSSIBLE_ASSET_TYPES; ++i) | ||
1750 | { | ||
1751 | if(INVENTORY_TO_ASSET_TYPE[inventory_type][i] == asset_type) | ||
1752 | { | ||
1753 | rv = true; | ||
1754 | break; | ||
1755 | } | ||
1756 | } | ||
1757 | } | ||
1758 | return rv; | ||
1759 | } | ||
1760 | |||
1761 | LLSD ll_create_sd_from_inventory_item(LLPointer<LLInventoryItem> item) | 1542 | LLSD ll_create_sd_from_inventory_item(LLPointer<LLInventoryItem> item) |
1762 | { | 1543 | { |
1763 | LLSD rv; | 1544 | LLSD rv; |