diff options
Diffstat (limited to 'linden/indra/newview/llwearable.cpp')
-rw-r--r-- | linden/indra/newview/llwearable.cpp | 86 |
1 files changed, 58 insertions, 28 deletions
diff --git a/linden/indra/newview/llwearable.cpp b/linden/indra/newview/llwearable.cpp index 310eae5..3e3f7ab 100644 --- a/linden/indra/newview/llwearable.cpp +++ b/linden/indra/newview/llwearable.cpp | |||
@@ -34,11 +34,13 @@ | |||
34 | #include "llquantize.h" | 34 | #include "llquantize.h" |
35 | 35 | ||
36 | #include "llagent.h" | 36 | #include "llagent.h" |
37 | #include "llassetuploadresponders.h" | ||
37 | #include "llviewerwindow.h" | 38 | #include "llviewerwindow.h" |
38 | #include "llfloatercustomize.h" | 39 | #include "llfloatercustomize.h" |
39 | #include "llinventorymodel.h" | 40 | #include "llinventorymodel.h" |
40 | #include "llviewerimagelist.h" | 41 | #include "llviewerimagelist.h" |
41 | #include "llviewerinventory.h" | 42 | #include "llviewerinventory.h" |
43 | #include "llviewerregion.h" | ||
42 | #include "llvoavatar.h" | 44 | #include "llvoavatar.h" |
43 | #include "llwearable.h" | 45 | #include "llwearable.h" |
44 | 46 | ||
@@ -148,10 +150,10 @@ EWearableType LLWearable::typeNameToType( const LLString& type_name ) | |||
148 | } | 150 | } |
149 | 151 | ||
150 | 152 | ||
151 | const char* terse_F32_to_string( F32 f, char s[MAX_STRING] ) | 153 | const char* terse_F32_to_string( F32 f, char s[MAX_STRING] ) /* Flawfinder: ignore */ |
152 | { | 154 | { |
153 | char* r = s; | 155 | char* r = s; |
154 | S32 len = sprintf( s, "%.2f", f ); | 156 | S32 len = snprintf( s, MAX_STRING, "%.2f", f ); /* Flawfinder: ignore */ |
155 | 157 | ||
156 | // "1.20" -> "1.2" | 158 | // "1.20" -> "1.2" |
157 | // "24.00" -> "24." | 159 | // "24.00" -> "24." |
@@ -230,7 +232,7 @@ BOOL LLWearable::exportFile( FILE* file ) | |||
230 | return FALSE; | 232 | return FALSE; |
231 | } | 233 | } |
232 | 234 | ||
233 | char s[ MAX_STRING ]; | 235 | char s[ MAX_STRING ]; /* Flawfinder: ignore */ |
234 | for( F32* param_weightp = mVisualParamMap.getFirstData(); param_weightp; param_weightp = mVisualParamMap.getNextData() ) | 236 | for( F32* param_weightp = mVisualParamMap.getFirstData(); param_weightp; param_weightp = mVisualParamMap.getNextData() ) |
235 | { | 237 | { |
236 | S32 param_id = mVisualParamMap.getCurrentKeyWithoutIncrement(); | 238 | S32 param_id = mVisualParamMap.getCurrentKeyWithoutIncrement(); |
@@ -250,7 +252,7 @@ BOOL LLWearable::exportFile( FILE* file ) | |||
250 | for( LLUUID* image_id = mTEMap.getFirstData(); image_id; image_id = mTEMap.getNextData() ) | 252 | for( LLUUID* image_id = mTEMap.getFirstData(); image_id; image_id = mTEMap.getNextData() ) |
251 | { | 253 | { |
252 | S32 te = mTEMap.getCurrentKeyWithoutIncrement(); | 254 | S32 te = mTEMap.getCurrentKeyWithoutIncrement(); |
253 | char image_id_string[UUID_STR_LENGTH]; | 255 | char image_id_string[UUID_STR_LENGTH]; /* Flawfinder: ignore */ |
254 | image_id->toString( image_id_string ); | 256 | image_id->toString( image_id_string ); |
255 | if( fprintf( file, "%d %s\n", te, image_id_string) < 0 ) | 257 | if( fprintf( file, "%d %s\n", te, image_id_string) < 0 ) |
256 | { | 258 | { |
@@ -268,7 +270,7 @@ BOOL LLWearable::importFile( FILE* file ) | |||
268 | // *NOTE: changing the type or size of this buffer will require | 270 | // *NOTE: changing the type or size of this buffer will require |
269 | // changes in the fscanf() code below. You would be better off | 271 | // changes in the fscanf() code below. You would be better off |
270 | // rewriting this to use streams and not require an open FILE. | 272 | // rewriting this to use streams and not require an open FILE. |
271 | char text_buffer[2048]; | 273 | char text_buffer[2048]; /* Flawfinder: ignore */ |
272 | S32 fields_read = 0; | 274 | S32 fields_read = 0; |
273 | 275 | ||
274 | // read header and version | 276 | // read header and version |
@@ -289,7 +291,7 @@ BOOL LLWearable::importFile( FILE* file ) | |||
289 | } | 291 | } |
290 | 292 | ||
291 | // name | 293 | // name |
292 | char next_char = fgetc( file ); | 294 | char next_char = fgetc( file ); /* Flawfinder: ignore */ |
293 | if( '\n' == next_char ) | 295 | if( '\n' == next_char ) |
294 | { | 296 | { |
295 | // no name | 297 | // no name |
@@ -298,8 +300,11 @@ BOOL LLWearable::importFile( FILE* file ) | |||
298 | else | 300 | else |
299 | { | 301 | { |
300 | ungetc( next_char, file ); | 302 | ungetc( next_char, file ); |
301 | fields_read = fscanf( file, "%2047[^\n]", text_buffer ); | 303 | fields_read = fscanf( /* Flawfinder: ignore */ |
302 | if( (1 != fields_read) || (fgetc( file ) != '\n') ) | 304 | file, |
305 | "%2047[^\n]", | ||
306 | text_buffer); | ||
307 | if( (1 != fields_read) || (fgetc( file ) != '\n') ) /* Flawfinder: ignore */ | ||
303 | { | 308 | { |
304 | llwarns << "Bad Wearable asset: early end of file" << llendl; | 309 | llwarns << "Bad Wearable asset: early end of file" << llendl; |
305 | return FALSE; | 310 | return FALSE; |
@@ -309,7 +314,7 @@ BOOL LLWearable::importFile( FILE* file ) | |||
309 | } | 314 | } |
310 | 315 | ||
311 | // description | 316 | // description |
312 | next_char = fgetc( file ); | 317 | next_char = fgetc( file ); /* Flawfinder: ignore */ |
313 | if( '\n' == next_char ) | 318 | if( '\n' == next_char ) |
314 | { | 319 | { |
315 | // no description | 320 | // no description |
@@ -318,8 +323,11 @@ BOOL LLWearable::importFile( FILE* file ) | |||
318 | else | 323 | else |
319 | { | 324 | { |
320 | ungetc( next_char, file ); | 325 | ungetc( next_char, file ); |
321 | fields_read = fscanf( file, "%2047[^\n]", text_buffer ); | 326 | fields_read = fscanf( /* Flawfinder: ignore */ |
322 | if( (1 != fields_read) || (fgetc( file ) != '\n') ) | 327 | file, |
328 | "%2047[^\n]", | ||
329 | text_buffer ); | ||
330 | if( (1 != fields_read) || (fgetc( file ) != '\n') ) /* Flawfinder: ignore */ | ||
323 | { | 331 | { |
324 | llwarns << "Bad Wearable asset: early end of file" << llendl; | 332 | llwarns << "Bad Wearable asset: early end of file" << llendl; |
325 | return FALSE; | 333 | return FALSE; |
@@ -425,7 +433,10 @@ BOOL LLWearable::importFile( FILE* file ) | |||
425 | for( i = 0; i < num_textures; i++ ) | 433 | for( i = 0; i < num_textures; i++ ) |
426 | { | 434 | { |
427 | S32 te = 0; | 435 | S32 te = 0; |
428 | fields_read = fscanf( file, "%d %2047s\n", &te, text_buffer); | 436 | fields_read = fscanf( /* Flawfinder: ignore */ |
437 | file, | ||
438 | "%d %2047s\n", | ||
439 | &te, text_buffer); | ||
429 | if( fields_read != 2 ) | 440 | if( fields_read != 2 ) |
430 | { | 441 | { |
431 | llwarns << "Bad Wearable asset: bad texture, #" << i << llendl; | 442 | llwarns << "Bad Wearable asset: bad texture, #" << i << llendl; |
@@ -863,11 +874,11 @@ void LLWearable::saveNewAsset() | |||
863 | // llinfos << "LLWearable::saveNewAsset() type: " << getTypeName() << llendl; | 874 | // llinfos << "LLWearable::saveNewAsset() type: " << getTypeName() << llendl; |
864 | //dump(); | 875 | //dump(); |
865 | 876 | ||
866 | char new_asset_id_string[UUID_STR_LENGTH]; | 877 | char new_asset_id_string[UUID_STR_LENGTH]; /* Flawfinder: ignore */ |
867 | mAssetID.toString(new_asset_id_string); | 878 | mAssetID.toString(new_asset_id_string); |
868 | char filename[LL_MAX_PATH]; | 879 | char filename[LL_MAX_PATH]; /* Flawfinder: ignore */ |
869 | sprintf(filename, "%s.wbl", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,new_asset_id_string).c_str()); | 880 | snprintf(filename, LL_MAX_PATH, "%s.wbl", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,new_asset_id_string).c_str()); /* Flawfinder: ignore */ |
870 | FILE* fp = LLFile::fopen(filename, "wb"); | 881 | FILE* fp = LLFile::fopen(filename, "wb"); /* Flawfinder: ignore */ |
871 | BOOL successful_save = FALSE; | 882 | BOOL successful_save = FALSE; |
872 | if(fp && exportFile(fp)) | 883 | if(fp && exportFile(fp)) |
873 | { | 884 | { |
@@ -880,8 +891,9 @@ void LLWearable::saveNewAsset() | |||
880 | } | 891 | } |
881 | if(!successful_save) | 892 | if(!successful_save) |
882 | { | 893 | { |
883 | char buffer[2*MAX_STRING]; | 894 | char buffer[2*MAX_STRING]; /* Flawfinder: ignore */ |
884 | sprintf(buffer, | 895 | snprintf(buffer, /* Flawfinder: ignore */ |
896 | sizeof(buffer), | ||
885 | "Unable to save '%s' to wearable file.", | 897 | "Unable to save '%s' to wearable file.", |
886 | mName.c_str()); | 898 | mName.c_str()); |
887 | llwarns << buffer << llendl; | 899 | llwarns << buffer << llendl; |
@@ -895,11 +907,28 @@ void LLWearable::saveNewAsset() | |||
895 | // save it out to database | 907 | // save it out to database |
896 | if( gAssetStorage ) | 908 | if( gAssetStorage ) |
897 | { | 909 | { |
898 | LLWearableSaveData* data = new LLWearableSaveData; | 910 | /* |
899 | data->mType = mType; | 911 | std::string url = gAgent.getRegion()->getCapability("NewAgentInventory"); |
900 | gAssetStorage->storeAssetData(filename, mTransactionID, getAssetType(), | 912 | if (!url.empty()) |
901 | &LLWearable::onSaveNewAssetComplete, | 913 | { |
902 | (void*)data); | 914 | llinfos << "Update Agent Inventory via capability" << llendl; |
915 | LLSD body; | ||
916 | body["folder_id"] = gInventory.findCategoryUUIDForType(getAssetType()); | ||
917 | body["asset_type"] = LLAssetType::lookup(getAssetType()); | ||
918 | body["inventory_type"] = LLInventoryType::lookup(LLInventoryType::IT_WEARABLE); | ||
919 | body["name"] = getName(); | ||
920 | body["description"] = getDescription(); | ||
921 | LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, filename)); | ||
922 | } | ||
923 | else | ||
924 | { | ||
925 | } | ||
926 | */ | ||
927 | LLWearableSaveData* data = new LLWearableSaveData; | ||
928 | data->mType = mType; | ||
929 | gAssetStorage->storeAssetData(filename, mTransactionID, getAssetType(), | ||
930 | &LLWearable::onSaveNewAssetComplete, | ||
931 | (void*)data); | ||
903 | } | 932 | } |
904 | } | 933 | } |
905 | 934 | ||
@@ -915,8 +944,9 @@ void LLWearable::onSaveNewAssetComplete(const LLUUID& new_asset_id, void* userda | |||
915 | } | 944 | } |
916 | else | 945 | else |
917 | { | 946 | { |
918 | char buffer[2*MAX_STRING]; | 947 | char buffer[2*MAX_STRING]; /* Flawfinder: ignore */ |
919 | sprintf(buffer, | 948 | snprintf(buffer, /* Flawfinder: ignore */ |
949 | sizeof(buffer), | ||
920 | "Unable to save %s to central asset store.", | 950 | "Unable to save %s to central asset store.", |
921 | type_name); | 951 | type_name); |
922 | llwarns << buffer << " Status: " << status << llendl; | 952 | llwarns << buffer << " Status: " << status << llendl; |
@@ -926,10 +956,10 @@ void LLWearable::onSaveNewAssetComplete(const LLUUID& new_asset_id, void* userda | |||
926 | } | 956 | } |
927 | 957 | ||
928 | // Delete temp file | 958 | // Delete temp file |
929 | char new_asset_id_string[UUID_STR_LENGTH]; | 959 | char new_asset_id_string[UUID_STR_LENGTH]; /* Flawfinder: ignore */ |
930 | new_asset_id.toString(new_asset_id_string); | 960 | new_asset_id.toString(new_asset_id_string); |
931 | char src_filename[LL_MAX_PATH]; | 961 | char src_filename[LL_MAX_PATH]; /* Flawfinder: ignore */ |
932 | sprintf(src_filename, "%s.wbl", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,new_asset_id_string).c_str()); | 962 | snprintf(src_filename, LL_MAX_PATH, "%s.wbl", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,new_asset_id_string).c_str()); /* Flawfinder: ignore */ |
933 | LLFile::remove(src_filename); | 963 | LLFile::remove(src_filename); |
934 | 964 | ||
935 | // delete the context data | 965 | // delete the context data |