aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewermenufile.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-30 13:04:20 -0500
committerJacek Antonelli2009-04-30 13:07:16 -0500
commitca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch)
tree8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/newview/llviewermenufile.cpp
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz
Second Life viewer sources 1.23.0-RC
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llviewermenufile.cpp188
1 files changed, 111 insertions, 77 deletions
diff --git a/linden/indra/newview/llviewermenufile.cpp b/linden/indra/newview/llviewermenufile.cpp
index c998ba6..2925916 100644
--- a/linden/indra/newview/llviewermenufile.cpp
+++ b/linden/indra/newview/llviewermenufile.cpp
@@ -17,7 +17,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -43,6 +44,7 @@
43#include "llfloatersnapshot.h" 44#include "llfloatersnapshot.h"
44#include "llinventorymodel.h" // gInventory 45#include "llinventorymodel.h" // gInventory
45#include "llresourcedata.h" 46#include "llresourcedata.h"
47#include "llfloaterperms.h"
46#include "llstatusbar.h" 48#include "llstatusbar.h"
47#include "llviewercontrol.h" // gSavedSettings 49#include "llviewercontrol.h" // gSavedSettings
48#include "llviewerimagelist.h" 50#include "llviewerimagelist.h"
@@ -177,9 +179,9 @@ const std::string upload_pick(void* data)
177 std::string short_name = gDirUtilp->getBaseFileName(filename); 179 std::string short_name = gDirUtilp->getBaseFileName(filename);
178 180
179 // No extension 181 // No extension
180 LLStringUtil::format_map_t args; 182 LLSD args;
181 args["[FILE]"] = short_name; 183 args["FILE"] = short_name;
182 gViewerWindow->alertXml("NoFileExtension", args); 184 LLNotifications::instance().add("NoFileExtension", args);
183 return std::string(); 185 return std::string();
184 } 186 }
185 else 187 else
@@ -219,11 +221,11 @@ const std::string upload_pick(void* data)
219 { 221 {
220 //should only get here if the extension exists 222 //should only get here if the extension exists
221 //but is invalid 223 //but is invalid
222 LLStringUtil::format_map_t args; 224 LLSD args;
223 args["[EXTENSION]"] = ext; 225 args["EXTENSION"] = ext;
224 args["[VALIDS]"] = valid_extensions; 226 args["VALIDS"] = valid_extensions;
225 gViewerWindow->alertXml("InvalidFileExtension", args); 227 LLNotifications::instance().add("InvalidFileExtension", args);
226 return std::string(); 228 return NULL;
227 } 229 }
228 }//end else (non-null extension) 230 }//end else (non-null extension)
229 231
@@ -238,9 +240,9 @@ const std::string upload_pick(void* data)
238 if (check_for_invalid_wav_formats(filename,error_msg)) 240 if (check_for_invalid_wav_formats(filename,error_msg))
239 { 241 {
240 llinfos << error_msg << ": " << filename << llendl; 242 llinfos << error_msg << ": " << filename << llendl;
241 LLStringUtil::format_map_t args; 243 LLSD args;
242 args["[FILE]"] = filename; 244 args["FILE"] = filename;
243 gViewerWindow->alertXml( error_msg, args ); 245 LLNotifications::instance().add( error_msg, args );
244 return std::string(); 246 return std::string();
245 } 247 }
246 }//end if a wave/sound file 248 }//end if a wave/sound file
@@ -272,6 +274,7 @@ class LLFileUploadSound : public view_listener_t
272 { 274 {
273 LLFloaterNameDesc* floaterp = new LLFloaterNameDesc(filename); 275 LLFloaterNameDesc* floaterp = new LLFloaterNameDesc(filename);
274 LLUICtrlFactory::getInstance()->buildFloater(floaterp, "floater_sound_preview.xml"); 276 LLUICtrlFactory::getInstance()->buildFloater(floaterp, "floater_sound_preview.xml");
277 floaterp->childSetLabelArg("ok_btn", "[AMOUNT]", llformat("%d", LLGlobalEconomy::Singleton::getInstance()->getPriceUpload() ));
275 } 278 }
276 return true; 279 return true;
277 } 280 }
@@ -322,7 +325,15 @@ class LLFileUploadBulk : public view_listener_t
322 LLStringUtil::stripNonprintable(asset_name); 325 LLStringUtil::stripNonprintable(asset_name);
323 LLStringUtil::trim(asset_name); 326 LLStringUtil::trim(asset_name);
324 327
325 upload_new_resource(filename, asset_name, asset_name, 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE); // file 328 std::string display_name = LLStringUtil::null;
329 LLAssetStorage::LLStoreAssetCallback callback = NULL;
330 S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
331 void *userdata = NULL;
332 upload_new_resource(filename, asset_name, asset_name, 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE,
333 LLFloaterPerms::getNextOwnerPerms(), LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(),
334 display_name,
335 callback, expected_upload_cost, userdata);
336
326 // *NOTE: Ew, we don't iterate over the file list here, 337 // *NOTE: Ew, we don't iterate over the file list here,
327 // we handle the next files in upload_done_callback() 338 // we handle the next files in upload_done_callback()
328 } 339 }
@@ -334,10 +345,10 @@ class LLFileUploadBulk : public view_listener_t
334 } 345 }
335}; 346};
336 347
337void upload_error(const std::string& error_message, const std::string& label, const std::string& filename, const LLStringUtil::format_map_t args) 348void upload_error(const std::string& error_message, const std::string& label, const std::string& filename, const LLSD& args)
338{ 349{
339 llwarns << error_message << llendl; 350 llwarns << error_message << llendl;
340 gViewerWindow->alertXml(label, args); 351 LLNotifications::instance().add(label, args);
341 if(LLFile::remove(filename) == -1) 352 if(LLFile::remove(filename) == -1)
342 { 353 {
343 lldebugs << "unable to remove temp file" << llendl; 354 lldebugs << "unable to remove temp file" << llendl;
@@ -478,6 +489,7 @@ void handle_upload(void* data)
478 { 489 {
479 LLFloaterNameDesc* floaterp = new LLFloaterNameDesc(filename); 490 LLFloaterNameDesc* floaterp = new LLFloaterNameDesc(filename);
480 LLUICtrlFactory::getInstance()->buildFloater(floaterp, "floater_name_description.xml"); 491 LLUICtrlFactory::getInstance()->buildFloater(floaterp, "floater_name_description.xml");
492 floaterp->childSetLabelArg("ok_btn", "[AMOUNT]", llformat("%d", LLGlobalEconomy::Singleton::getInstance()->getPriceUpload() ));
481 } 493 }
482} 494}
483 495
@@ -513,23 +525,25 @@ void handle_compress_image(void*)
513} 525}
514 526
515void upload_new_resource(const std::string& src_filename, std::string name, 527void upload_new_resource(const std::string& src_filename, std::string name,
516 std::string desc, S32 compression_info, 528 std::string desc, S32 compression_info,
517 LLAssetType::EType destination_folder_type, 529 LLAssetType::EType destination_folder_type,
518 LLInventoryType::EType inv_type, 530 LLInventoryType::EType inv_type,
519 U32 next_owner_perm, 531 U32 next_owner_perms,
520 const std::string& display_name, 532 U32 group_perms,
521 LLAssetStorage::LLStoreAssetCallback callback, 533 U32 everyone_perms,
522 void *userdata) 534 const std::string& display_name,
535 LLAssetStorage::LLStoreAssetCallback callback,
536 S32 expected_upload_cost,
537 void *userdata)
523{ 538{
524 // Generate the temporary UUID. 539 // Generate the temporary UUID.
525 std::string filename = gDirUtilp->getTempFilename(); 540 std::string filename = gDirUtilp->getTempFilename();
526 LLTransactionID tid; 541 LLTransactionID tid;
527 LLAssetID uuid; 542 LLAssetID uuid;
528 543
529 LLStringUtil::format_map_t args; 544 LLSD args;
530 545
531 std::string exten = gDirUtilp->getExtension(src_filename); 546 std::string exten = gDirUtilp->getExtension(src_filename);
532
533 LLAssetType::EType asset_type = LLAssetType::AT_NONE; 547 LLAssetType::EType asset_type = LLAssetType::AT_NONE;
534 std::string error_message; 548 std::string error_message;
535 549
@@ -543,7 +557,7 @@ void upload_new_resource(const std::string& src_filename, std::string name,
543 error_message = llformat( 557 error_message = llformat(
544 "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension", 558 "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension",
545 short_name.c_str()); 559 short_name.c_str());
546 args["[FILE]"] = short_name; 560 args["FILE"] = short_name;
547 upload_error(error_message, "NofileExtension", filename, args); 561 upload_error(error_message, "NofileExtension", filename, args);
548 return; 562 return;
549 } 563 }
@@ -555,9 +569,9 @@ void upload_new_resource(const std::string& src_filename, std::string name,
555 IMG_CODEC_BMP )) 569 IMG_CODEC_BMP ))
556 { 570 {
557 error_message = llformat( "Problem with file %s:\n\n%s\n", 571 error_message = llformat( "Problem with file %s:\n\n%s\n",
558 src_filename.c_str(), LLImage::getLastError().c_str()); 572 src_filename.c_str(), LLImage::getLastError().c_str());
559 args["[FILE]"] = src_filename; 573 args["FILE"] = src_filename;
560 args["[ERROR]"] = LLImage::getLastError(); 574 args["ERROR"] = LLImage::getLastError();
561 upload_error(error_message, "ProblemWithFile", filename, args); 575 upload_error(error_message, "ProblemWithFile", filename, args);
562 return; 576 return;
563 } 577 }
@@ -571,8 +585,8 @@ void upload_new_resource(const std::string& src_filename, std::string name,
571 { 585 {
572 error_message = llformat("Problem with file %s:\n\n%s\n", 586 error_message = llformat("Problem with file %s:\n\n%s\n",
573 src_filename.c_str(), LLImage::getLastError().c_str()); 587 src_filename.c_str(), LLImage::getLastError().c_str());
574 args["[FILE]"] = src_filename; 588 args["FILE"] = src_filename;
575 args["[ERROR]"] = LLImage::getLastError(); 589 args["ERROR"] = LLImage::getLastError();
576 upload_error(error_message, "ProblemWithFile", filename, args); 590 upload_error(error_message, "ProblemWithFile", filename, args);
577 return; 591 return;
578 } 592 }
@@ -586,8 +600,8 @@ void upload_new_resource(const std::string& src_filename, std::string name,
586 { 600 {
587 error_message = llformat("Problem with file %s:\n\n%s\n", 601 error_message = llformat("Problem with file %s:\n\n%s\n",
588 src_filename.c_str(), LLImage::getLastError().c_str()); 602 src_filename.c_str(), LLImage::getLastError().c_str());
589 args["[FILE]"] = src_filename; 603 args["FILE"] = src_filename;
590 args["[ERROR]"] = LLImage::getLastError(); 604 args["ERROR"] = LLImage::getLastError();
591 upload_error(error_message, "ProblemWithFile", filename, args); 605 upload_error(error_message, "ProblemWithFile", filename, args);
592 return; 606 return;
593 } 607 }
@@ -601,8 +615,8 @@ void upload_new_resource(const std::string& src_filename, std::string name,
601 { 615 {
602 error_message = llformat("Problem with file %s:\n\n%s\n", 616 error_message = llformat("Problem with file %s:\n\n%s\n",
603 src_filename.c_str(), LLImage::getLastError().c_str()); 617 src_filename.c_str(), LLImage::getLastError().c_str());
604 args["[FILE]"] = src_filename; 618 args["FILE"] = src_filename;
605 args["[ERROR]"] = LLImage::getLastError(); 619 args["ERROR"] = LLImage::getLastError();
606 upload_error(error_message, "ProblemWithFile", filename, args); 620 upload_error(error_message, "ProblemWithFile", filename, args);
607 return; 621 return;
608 } 622 }
@@ -622,13 +636,13 @@ void upload_new_resource(const std::string& src_filename, std::string name,
622 { 636 {
623 case LLVORBISENC_DEST_OPEN_ERR: 637 case LLVORBISENC_DEST_OPEN_ERR:
624 error_message = llformat( "Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str()); 638 error_message = llformat( "Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str());
625 args["[FILE]"] = filename; 639 args["FILE"] = filename;
626 upload_error(error_message, "CannotOpenTemporarySoundFile", filename, args); 640 upload_error(error_message, "CannotOpenTemporarySoundFile", filename, args);
627 break; 641 break;
628 642
629 default: 643 default:
630 error_message = llformat("Unknown vorbis encode failure on: %s\n", src_filename.c_str()); 644 error_message = llformat("Unknown vorbis encode failure on: %s\n", src_filename.c_str());
631 args["[FILE]"] = src_filename; 645 args["FILE"] = src_filename;
632 upload_error(error_message, "UnknownVorbisEncodeFailure", filename, args); 646 upload_error(error_message, "UnknownVorbisEncodeFailure", filename, args);
633 break; 647 break;
634 } 648 }
@@ -670,7 +684,7 @@ void upload_new_resource(const std::string& src_filename, std::string name,
670 { 684 {
671 fclose(in); 685 fclose(in);
672 error_message = llformat("corrupt resource file: %s", src_filename.c_str()); 686 error_message = llformat("corrupt resource file: %s", src_filename.c_str());
673 args["[FILE]"] = src_filename; 687 args["FILE"] = src_filename;
674 upload_error(error_message, "CorruptResourceFile", filename, args); 688 upload_error(error_message, "CorruptResourceFile", filename, args);
675 return; 689 return;
676 } 690 }
@@ -698,7 +712,7 @@ void upload_new_resource(const std::string& src_filename, std::string name,
698 { 712 {
699 fclose(in); 713 fclose(in);
700 error_message = llformat("unknown linden resource file version in file: %s", src_filename.c_str()); 714 error_message = llformat("unknown linden resource file version in file: %s", src_filename.c_str());
701 args["[FILE]"] = src_filename; 715 args["FILE"] = src_filename;
702 upload_error(error_message, "UnknownResourceFileVersion", filename, args); 716 upload_error(error_message, "UnknownResourceFileVersion", filename, args);
703 return; 717 return;
704 } 718 }
@@ -740,7 +754,7 @@ void upload_new_resource(const std::string& src_filename, std::string name,
740 { 754 {
741 fclose(in); 755 fclose(in);
742 error_message = llformat( "Unable to create output file: %s", filename.c_str()); 756 error_message = llformat( "Unable to create output file: %s", filename.c_str());
743 args["[FILE]"] = filename; 757 args["FILE"] = filename;
744 upload_error(error_message, "UnableToCreateOutputFile", filename, args); 758 upload_error(error_message, "UnableToCreateOutputFile", filename, args);
745 return; 759 return;
746 } 760 }
@@ -774,8 +788,9 @@ void upload_new_resource(const std::string& src_filename, std::string name,
774 uuid = tid.makeAssetID(gAgent.getSecureSessionID()); 788 uuid = tid.makeAssetID(gAgent.getSecureSessionID());
775 // copy this file into the vfs for upload 789 // copy this file into the vfs for upload
776 S32 file_size; 790 S32 file_size;
777 apr_file_t* fp = ll_apr_file_open(filename, LL_APR_RB, &file_size); 791 LLAPRFile infile ;
778 if (fp) 792 infile.open(filename, LL_APR_RB, NULL, &file_size);
793 if (infile.getFileHandle())
779 { 794 {
780 LLVFile file(gVFS, uuid, asset_type, LLVFile::WRITE); 795 LLVFile file(gVFS, uuid, asset_type, LLVFile::WRITE);
781 796
@@ -783,11 +798,10 @@ void upload_new_resource(const std::string& src_filename, std::string name,
783 798
784 const S32 buf_size = 65536; 799 const S32 buf_size = 65536;
785 U8 copy_buf[buf_size]; 800 U8 copy_buf[buf_size];
786 while ((file_size = ll_apr_file_read(fp, copy_buf, buf_size))) 801 while ((file_size = infile.read(copy_buf, buf_size)))
787 { 802 {
788 file.write(copy_buf, file_size); 803 file.write(copy_buf, file_size);
789 } 804 }
790 apr_file_close(fp);
791 } 805 }
792 else 806 else
793 { 807 {
@@ -804,15 +818,15 @@ void upload_new_resource(const std::string& src_filename, std::string name,
804 t_disp_name = src_filename; 818 t_disp_name = src_filename;
805 } 819 }
806 upload_new_resource(tid, asset_type, name, desc, compression_info, // tid 820 upload_new_resource(tid, asset_type, name, desc, compression_info, // tid
807 destination_folder_type, inv_type, next_owner_perm, 821 destination_folder_type, inv_type, next_owner_perms, group_perms, everyone_perms,
808 display_name, callback, userdata); 822 display_name, callback, expected_upload_cost, userdata);
809 } 823 }
810 else 824 else
811 { 825 {
812 llwarns << error_message << llendl; 826 llwarns << error_message << llendl;
813 LLStringUtil::format_map_t args; 827 LLSD args;
814 args["[ERROR_MESSAGE]"] = error_message; 828 args["ERROR_MESSAGE"] = error_message;
815 gViewerWindow->alertXml("ErrorMessage", args); 829 LLNotifications::instance().add("ErrorMessage", args);
816 if(LLFile::remove(filename) == -1) 830 if(LLFile::remove(filename) == -1)
817 { 831 {
818 lldebugs << "unable to remove temp file" << llendl; 832 lldebugs << "unable to remove temp file" << llendl;
@@ -824,8 +838,10 @@ void upload_new_resource(const std::string& src_filename, std::string name,
824void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status) // StoreAssetData callback (fixed) 838void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status) // StoreAssetData callback (fixed)
825{ 839{
826 LLResourceData* data = (LLResourceData*)user_data; 840 LLResourceData* data = (LLResourceData*)user_data;
841 S32 expected_upload_cost = data ? data->mExpectedUploadCost : 0;
827 //LLAssetType::EType pref_loc = data->mPreferredLocation; 842 //LLAssetType::EType pref_loc = data->mPreferredLocation;
828 BOOL is_balance_sufficient = TRUE; 843 BOOL is_balance_sufficient = TRUE;
844
829 if(result >= 0) 845 if(result >= 0)
830 { 846 {
831 LLAssetType::EType dest_loc = (data->mPreferredLocation == LLAssetType::AT_NONE) ? data->mAssetInfo.mType : data->mPreferredLocation; 847 LLAssetType::EType dest_loc = (data->mPreferredLocation == LLAssetType::AT_NONE) ? data->mAssetInfo.mType : data->mPreferredLocation;
@@ -836,20 +852,19 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt
836 { 852 {
837 // Charge the user for the upload. 853 // Charge the user for the upload.
838 LLViewerRegion* region = gAgent.getRegion(); 854 LLViewerRegion* region = gAgent.getRegion();
839 S32 upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
840 855
841 if(!(can_afford_transaction(upload_cost))) 856 if(!(can_afford_transaction(expected_upload_cost)))
842 { 857 {
843 LLFloaterBuyCurrency::buyCurrency( 858 LLFloaterBuyCurrency::buyCurrency(
844 llformat("Uploading %s costs", 859 llformat("Uploading %s costs",
845 data->mAssetInfo.getName().c_str()), // *TODO: Translate 860 data->mAssetInfo.getName().c_str()), // *TODO: Translate
846 upload_cost); 861 expected_upload_cost);
847 is_balance_sufficient = FALSE; 862 is_balance_sufficient = FALSE;
848 } 863 }
849 else if(region) 864 else if(region)
850 { 865 {
851 // Charge user for upload 866 // Charge user for upload
852 gStatusBar->debitBalance(upload_cost); 867 gStatusBar->debitBalance(expected_upload_cost);
853 868
854 LLMessageSystem* msg = gMessageSystem; 869 LLMessageSystem* msg = gMessageSystem;
855 msg->newMessageFast(_PREHASH_MoneyTransferRequest); 870 msg->newMessageFast(_PREHASH_MoneyTransferRequest);
@@ -860,7 +875,9 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt
860 msg->addUUIDFast(_PREHASH_SourceID, gAgent.getID()); 875 msg->addUUIDFast(_PREHASH_SourceID, gAgent.getID());
861 msg->addUUIDFast(_PREHASH_DestID, LLUUID::null); 876 msg->addUUIDFast(_PREHASH_DestID, LLUUID::null);
862 msg->addU8("Flags", 0); 877 msg->addU8("Flags", 0);
863 msg->addS32Fast(_PREHASH_Amount, upload_cost); 878 // we tell the sim how much we were expecting to pay so it
879 // can respond to any discrepancy
880 msg->addS32Fast(_PREHASH_Amount, expected_upload_cost);
864 msg->addU8Fast(_PREHASH_AggregatePermNextOwner, (U8)LLAggregatePermissions::AP_EMPTY); 881 msg->addU8Fast(_PREHASH_AggregatePermNextOwner, (U8)LLAggregatePermissions::AP_EMPTY);
865 msg->addU8Fast(_PREHASH_AggregatePermInventory, (U8)LLAggregatePermissions::AP_EMPTY); 882 msg->addU8Fast(_PREHASH_AggregatePermInventory, (U8)LLAggregatePermissions::AP_EMPTY);
866 msg->addS32Fast(_PREHASH_TransactionType, TRANS_UPLOAD_CHARGE); 883 msg->addS32Fast(_PREHASH_TransactionType, TRANS_UPLOAD_CHARGE);
@@ -876,15 +893,15 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt
876 LLUUID folder_id(gInventory.findCategoryUUIDForType(dest_loc)); 893 LLUUID folder_id(gInventory.findCategoryUUIDForType(dest_loc));
877 if(folder_id.notNull()) 894 if(folder_id.notNull())
878 { 895 {
879 U32 next_owner_perm = data->mNextOwnerPerm; 896 U32 next_owner_perms = data->mNextOwnerPerm;
880 if(PERM_NONE == next_owner_perm) 897 if(PERM_NONE == next_owner_perms)
881 { 898 {
882 next_owner_perm = PERM_MOVE | PERM_TRANSFER; 899 next_owner_perms = PERM_MOVE | PERM_TRANSFER;
883 } 900 }
884 create_inventory_item(gAgent.getID(), gAgent.getSessionID(), 901 create_inventory_item(gAgent.getID(), gAgent.getSessionID(),
885 folder_id, data->mAssetInfo.mTransactionID, data->mAssetInfo.getName(), 902 folder_id, data->mAssetInfo.mTransactionID, data->mAssetInfo.getName(),
886 data->mAssetInfo.getDescription(), data->mAssetInfo.mType, 903 data->mAssetInfo.getDescription(), data->mAssetInfo.mType,
887 data->mInventoryType, NOT_WEARABLE, next_owner_perm, 904 data->mInventoryType, NOT_WEARABLE, next_owner_perms,
888 LLPointer<LLInventoryCallback>(NULL)); 905 LLPointer<LLInventoryCallback>(NULL));
889 } 906 }
890 else 907 else
@@ -895,10 +912,10 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt
895 } 912 }
896 else // if(result >= 0) 913 else // if(result >= 0)
897 { 914 {
898 LLStringUtil::format_map_t args; 915 LLSD args;
899 args["[FILE]"] = LLInventoryType::lookupHumanReadable(data->mInventoryType); 916 args["FILE"] = LLInventoryType::lookupHumanReadable(data->mInventoryType);
900 args["[REASON]"] = std::string(LLAssetStorage::getErrorString(result)); 917 args["REASON"] = std::string(LLAssetStorage::getErrorString(result));
901 gViewerWindow->alertXml("CannotUploadReason", args); 918 LLNotifications::instance().add("CannotUploadReason", args);
902 } 919 }
903 920
904 LLUploadDialog::modalUploadFinished(); 921 LLUploadDialog::modalUploadFinished();
@@ -916,20 +933,31 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt
916 LLStringUtil::stripNonprintable(asset_name); 933 LLStringUtil::stripNonprintable(asset_name);
917 LLStringUtil::trim(asset_name); 934 LLStringUtil::trim(asset_name);
918 935
936 std::string display_name = LLStringUtil::null;
937 LLAssetStorage::LLStoreAssetCallback callback = NULL;
938 void *userdata = NULL;
919 upload_new_resource(next_file, asset_name, asset_name, // file 939 upload_new_resource(next_file, asset_name, asset_name, // file
920 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE); 940 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE,
941 PERM_NONE, PERM_NONE, PERM_NONE,
942 display_name,
943 callback,
944 expected_upload_cost, // assuming next in a group of uploads is of roughly the same type, i.e. same upload cost
945 userdata);
921 } 946 }
922} 947}
923 948
924void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_type, 949void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_type,
925 std::string name, 950 std::string name,
926 std::string desc, S32 compression_info, 951 std::string desc, S32 compression_info,
927 LLAssetType::EType destination_folder_type, 952 LLAssetType::EType destination_folder_type,
928 LLInventoryType::EType inv_type, 953 LLInventoryType::EType inv_type,
929 U32 next_owner_perm, 954 U32 next_owner_perms,
930 const std::string& display_name, 955 U32 group_perms,
931 LLAssetStorage::LLStoreAssetCallback callback, 956 U32 everyone_perms,
932 void *userdata) 957 const std::string& display_name,
958 LLAssetStorage::LLStoreAssetCallback callback,
959 S32 expected_upload_cost,
960 void *userdata)
933{ 961{
934 if(gDisconnected) 962 if(gDisconnected)
935 { 963 {
@@ -978,6 +1006,7 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
978 llinfos << "UUID: " << uuid << llendl; 1006 llinfos << "UUID: " << uuid << llendl;
979 llinfos << "Name: " << name << llendl; 1007 llinfos << "Name: " << name << llendl;
980 llinfos << "Desc: " << desc << llendl; 1008 llinfos << "Desc: " << desc << llendl;
1009 llinfos << "Expected Upload Cost: " << expected_upload_cost << llendl;
981 lldebugs << "Folder: " << gInventory.findCategoryUUIDForType((destination_folder_type == LLAssetType::AT_NONE) ? asset_type : destination_folder_type) << llendl; 1010 lldebugs << "Folder: " << gInventory.findCategoryUUIDForType((destination_folder_type == LLAssetType::AT_NONE) ? asset_type : destination_folder_type) << llendl;
982 lldebugs << "Asset Type: " << LLAssetType::lookup(asset_type) << llendl; 1011 lldebugs << "Asset Type: " << LLAssetType::lookup(asset_type) << llendl;
983 std::string url = gAgent.getRegion()->getCapability("NewFileAgentInventory"); 1012 std::string url = gAgent.getRegion()->getCapability("NewFileAgentInventory");
@@ -990,10 +1019,15 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
990 body["inventory_type"] = LLInventoryType::lookup(inv_type); 1019 body["inventory_type"] = LLInventoryType::lookup(inv_type);
991 body["name"] = name; 1020 body["name"] = name;
992 body["description"] = desc; 1021 body["description"] = desc;
1022 body["next_owner_mask"] = LLSD::Integer(next_owner_perms);
1023 body["group_mask"] = LLSD::Integer(group_perms);
1024 body["everyone_mask"] = LLSD::Integer(everyone_perms);
1025 body["expected_upload_cost"] = LLSD::Integer(expected_upload_cost);
993 1026
994 std::ostringstream llsdxml; 1027 //std::ostringstream llsdxml;
995 LLSDSerialize::toXML(body, llsdxml); 1028 //LLSDSerialize::toPrettyXML(body, llsdxml);
996 lldebugs << "posting body to capability: " << llsdxml.str() << llendl; 1029 //llinfos << "posting body to capability: " << llsdxml.str() << llendl;
1030
997 LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, uuid, asset_type)); 1031 LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, uuid, asset_type));
998 } 1032 }
999 else 1033 else
@@ -1005,12 +1039,11 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
1005 LLAssetType::AT_TEXTURE == asset_type || 1039 LLAssetType::AT_TEXTURE == asset_type ||
1006 LLAssetType::AT_ANIMATION == asset_type) 1040 LLAssetType::AT_ANIMATION == asset_type)
1007 { 1041 {
1008 S32 upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
1009 S32 balance = gStatusBar->getBalance(); 1042 S32 balance = gStatusBar->getBalance();
1010 if (balance < upload_cost) 1043 if (balance < expected_upload_cost)
1011 { 1044 {
1012 // insufficient funds, bail on this upload 1045 // insufficient funds, bail on this upload
1013 LLFloaterBuyCurrency::buyCurrency("Uploading costs", upload_cost); 1046 LLFloaterBuyCurrency::buyCurrency("Uploading costs", expected_upload_cost);
1014 return; 1047 return;
1015 } 1048 }
1016 } 1049 }
@@ -1021,7 +1054,8 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
1021 data->mAssetInfo.mType = asset_type; 1054 data->mAssetInfo.mType = asset_type;
1022 data->mAssetInfo.mCreatorID = gAgentID; 1055 data->mAssetInfo.mCreatorID = gAgentID;
1023 data->mInventoryType = inv_type; 1056 data->mInventoryType = inv_type;
1024 data->mNextOwnerPerm = next_owner_perm; 1057 data->mNextOwnerPerm = next_owner_perms;
1058 data->mExpectedUploadCost = expected_upload_cost;
1025 data->mUserData = userdata; 1059 data->mUserData = userdata;
1026 data->mAssetInfo.setName(name); 1060 data->mAssetInfo.setName(name);
1027 data->mAssetInfo.setDescription(desc); 1061 data->mAssetInfo.setDescription(desc);