diff options
author | Jacek Antonelli | 2009-11-19 04:19:06 -0600 |
---|---|---|
committer | Jacek Antonelli | 2009-11-19 04:19:06 -0600 |
commit | 1d443b7a94ed6f9ef1d408caef72fcbc0b1ee427 (patch) | |
tree | e09ccbc010e326a48fd91ba15b58afd7fb836b3f /linden/indra/newview/llviewermenufile.cpp | |
parent | Fixed minor formatting issue in MANIFESTO.txt. (diff) | |
parent | Fixed CMake setting errors (diff) | |
download | meta-impy-1d443b7a94ed6f9ef1d408caef72fcbc0b1ee427.zip meta-impy-1d443b7a94ed6f9ef1d408caef72fcbc0b1ee427.tar.gz meta-impy-1d443b7a94ed6f9ef1d408caef72fcbc0b1ee427.tar.bz2 meta-impy-1d443b7a94ed6f9ef1d408caef72fcbc0b1ee427.tar.xz |
Merge remote branch 'mccabe/1.3.0-next' into next
Conflicts:
linden/indra/cmake/00-Common.cmake
linden/indra/newview/skins/default/xui/de/floater_about.xml
linden/indra/newview/skins/default/xui/fr/floater_about.xml
linden/indra/newview/skins/default/xui/ja/floater_about.xml
linden/indra/newview/skins/default/xui/ko/floater_about.xml
linden/indra/newview/skins/default/xui/zh/floater_about.xml
linden/install.xml
Diffstat (limited to 'linden/indra/newview/llviewermenufile.cpp')
-rw-r--r-- | linden/indra/newview/llviewermenufile.cpp | 188 |
1 files changed, 111 insertions, 77 deletions
diff --git a/linden/indra/newview/llviewermenufile.cpp b/linden/indra/newview/llviewermenufile.cpp index 26b5086..178fc97 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 | ||
337 | void upload_error(const std::string& error_message, const std::string& label, const std::string& filename, const LLStringUtil::format_map_t args) | 348 | void 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; |
@@ -487,6 +498,7 @@ void handle_upload(void* data) | |||
487 | { | 498 | { |
488 | LLFloaterNameDesc* floaterp = new LLFloaterNameDesc(filename); | 499 | LLFloaterNameDesc* floaterp = new LLFloaterNameDesc(filename); |
489 | LLUICtrlFactory::getInstance()->buildFloater(floaterp, "floater_name_description.xml"); | 500 | LLUICtrlFactory::getInstance()->buildFloater(floaterp, "floater_name_description.xml"); |
501 | floaterp->childSetLabelArg("ok_btn", "[AMOUNT]", llformat("%d", LLGlobalEconomy::Singleton::getInstance()->getPriceUpload() )); | ||
490 | } | 502 | } |
491 | } | 503 | } |
492 | 504 | ||
@@ -522,23 +534,25 @@ void handle_compress_image(void*) | |||
522 | } | 534 | } |
523 | 535 | ||
524 | void upload_new_resource(const std::string& src_filename, std::string name, | 536 | void upload_new_resource(const std::string& src_filename, std::string name, |
525 | std::string desc, S32 compression_info, | 537 | std::string desc, S32 compression_info, |
526 | LLAssetType::EType destination_folder_type, | 538 | LLAssetType::EType destination_folder_type, |
527 | LLInventoryType::EType inv_type, | 539 | LLInventoryType::EType inv_type, |
528 | U32 next_owner_perm, | 540 | U32 next_owner_perms, |
529 | const std::string& display_name, | 541 | U32 group_perms, |
530 | LLAssetStorage::LLStoreAssetCallback callback, | 542 | U32 everyone_perms, |
531 | void *userdata) | 543 | const std::string& display_name, |
544 | LLAssetStorage::LLStoreAssetCallback callback, | ||
545 | S32 expected_upload_cost, | ||
546 | void *userdata) | ||
532 | { | 547 | { |
533 | // Generate the temporary UUID. | 548 | // Generate the temporary UUID. |
534 | std::string filename = gDirUtilp->getTempFilename(); | 549 | std::string filename = gDirUtilp->getTempFilename(); |
535 | LLTransactionID tid; | 550 | LLTransactionID tid; |
536 | LLAssetID uuid; | 551 | LLAssetID uuid; |
537 | 552 | ||
538 | LLStringUtil::format_map_t args; | 553 | LLSD args; |
539 | 554 | ||
540 | std::string exten = gDirUtilp->getExtension(src_filename); | 555 | std::string exten = gDirUtilp->getExtension(src_filename); |
541 | |||
542 | LLAssetType::EType asset_type = LLAssetType::AT_NONE; | 556 | LLAssetType::EType asset_type = LLAssetType::AT_NONE; |
543 | std::string error_message; | 557 | std::string error_message; |
544 | 558 | ||
@@ -552,7 +566,7 @@ void upload_new_resource(const std::string& src_filename, std::string name, | |||
552 | error_message = llformat( | 566 | error_message = llformat( |
553 | "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension", | 567 | "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension", |
554 | short_name.c_str()); | 568 | short_name.c_str()); |
555 | args["[FILE]"] = short_name; | 569 | args["FILE"] = short_name; |
556 | upload_error(error_message, "NofileExtension", filename, args); | 570 | upload_error(error_message, "NofileExtension", filename, args); |
557 | return; | 571 | return; |
558 | } | 572 | } |
@@ -564,9 +578,9 @@ void upload_new_resource(const std::string& src_filename, std::string name, | |||
564 | IMG_CODEC_BMP )) | 578 | IMG_CODEC_BMP )) |
565 | { | 579 | { |
566 | error_message = llformat( "Problem with file %s:\n\n%s\n", | 580 | error_message = llformat( "Problem with file %s:\n\n%s\n", |
567 | src_filename.c_str(), LLImage::getLastError().c_str()); | 581 | src_filename.c_str(), LLImage::getLastError().c_str()); |
568 | args["[FILE]"] = src_filename; | 582 | args["FILE"] = src_filename; |
569 | args["[ERROR]"] = LLImage::getLastError(); | 583 | args["ERROR"] = LLImage::getLastError(); |
570 | upload_error(error_message, "ProblemWithFile", filename, args); | 584 | upload_error(error_message, "ProblemWithFile", filename, args); |
571 | return; | 585 | return; |
572 | } | 586 | } |
@@ -580,8 +594,8 @@ void upload_new_resource(const std::string& src_filename, std::string name, | |||
580 | { | 594 | { |
581 | error_message = llformat("Problem with file %s:\n\n%s\n", | 595 | error_message = llformat("Problem with file %s:\n\n%s\n", |
582 | src_filename.c_str(), LLImage::getLastError().c_str()); | 596 | src_filename.c_str(), LLImage::getLastError().c_str()); |
583 | args["[FILE]"] = src_filename; | 597 | args["FILE"] = src_filename; |
584 | args["[ERROR]"] = LLImage::getLastError(); | 598 | args["ERROR"] = LLImage::getLastError(); |
585 | upload_error(error_message, "ProblemWithFile", filename, args); | 599 | upload_error(error_message, "ProblemWithFile", filename, args); |
586 | return; | 600 | return; |
587 | } | 601 | } |
@@ -595,8 +609,8 @@ void upload_new_resource(const std::string& src_filename, std::string name, | |||
595 | { | 609 | { |
596 | error_message = llformat("Problem with file %s:\n\n%s\n", | 610 | error_message = llformat("Problem with file %s:\n\n%s\n", |
597 | src_filename.c_str(), LLImage::getLastError().c_str()); | 611 | src_filename.c_str(), LLImage::getLastError().c_str()); |
598 | args["[FILE]"] = src_filename; | 612 | args["FILE"] = src_filename; |
599 | args["[ERROR]"] = LLImage::getLastError(); | 613 | args["ERROR"] = LLImage::getLastError(); |
600 | upload_error(error_message, "ProblemWithFile", filename, args); | 614 | upload_error(error_message, "ProblemWithFile", filename, args); |
601 | return; | 615 | return; |
602 | } | 616 | } |
@@ -610,8 +624,8 @@ void upload_new_resource(const std::string& src_filename, std::string name, | |||
610 | { | 624 | { |
611 | error_message = llformat("Problem with file %s:\n\n%s\n", | 625 | error_message = llformat("Problem with file %s:\n\n%s\n", |
612 | src_filename.c_str(), LLImage::getLastError().c_str()); | 626 | src_filename.c_str(), LLImage::getLastError().c_str()); |
613 | args["[FILE]"] = src_filename; | 627 | args["FILE"] = src_filename; |
614 | args["[ERROR]"] = LLImage::getLastError(); | 628 | args["ERROR"] = LLImage::getLastError(); |
615 | upload_error(error_message, "ProblemWithFile", filename, args); | 629 | upload_error(error_message, "ProblemWithFile", filename, args); |
616 | return; | 630 | return; |
617 | } | 631 | } |
@@ -631,13 +645,13 @@ void upload_new_resource(const std::string& src_filename, std::string name, | |||
631 | { | 645 | { |
632 | case LLVORBISENC_DEST_OPEN_ERR: | 646 | case LLVORBISENC_DEST_OPEN_ERR: |
633 | error_message = llformat( "Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str()); | 647 | error_message = llformat( "Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str()); |
634 | args["[FILE]"] = filename; | 648 | args["FILE"] = filename; |
635 | upload_error(error_message, "CannotOpenTemporarySoundFile", filename, args); | 649 | upload_error(error_message, "CannotOpenTemporarySoundFile", filename, args); |
636 | break; | 650 | break; |
637 | 651 | ||
638 | default: | 652 | default: |
639 | error_message = llformat("Unknown vorbis encode failure on: %s\n", src_filename.c_str()); | 653 | error_message = llformat("Unknown vorbis encode failure on: %s\n", src_filename.c_str()); |
640 | args["[FILE]"] = src_filename; | 654 | args["FILE"] = src_filename; |
641 | upload_error(error_message, "UnknownVorbisEncodeFailure", filename, args); | 655 | upload_error(error_message, "UnknownVorbisEncodeFailure", filename, args); |
642 | break; | 656 | break; |
643 | } | 657 | } |
@@ -679,7 +693,7 @@ void upload_new_resource(const std::string& src_filename, std::string name, | |||
679 | { | 693 | { |
680 | fclose(in); | 694 | fclose(in); |
681 | error_message = llformat("corrupt resource file: %s", src_filename.c_str()); | 695 | error_message = llformat("corrupt resource file: %s", src_filename.c_str()); |
682 | args["[FILE]"] = src_filename; | 696 | args["FILE"] = src_filename; |
683 | upload_error(error_message, "CorruptResourceFile", filename, args); | 697 | upload_error(error_message, "CorruptResourceFile", filename, args); |
684 | return; | 698 | return; |
685 | } | 699 | } |
@@ -707,7 +721,7 @@ void upload_new_resource(const std::string& src_filename, std::string name, | |||
707 | { | 721 | { |
708 | fclose(in); | 722 | fclose(in); |
709 | error_message = llformat("unknown linden resource file version in file: %s", src_filename.c_str()); | 723 | error_message = llformat("unknown linden resource file version in file: %s", src_filename.c_str()); |
710 | args["[FILE]"] = src_filename; | 724 | args["FILE"] = src_filename; |
711 | upload_error(error_message, "UnknownResourceFileVersion", filename, args); | 725 | upload_error(error_message, "UnknownResourceFileVersion", filename, args); |
712 | return; | 726 | return; |
713 | } | 727 | } |
@@ -749,7 +763,7 @@ void upload_new_resource(const std::string& src_filename, std::string name, | |||
749 | { | 763 | { |
750 | fclose(in); | 764 | fclose(in); |
751 | error_message = llformat( "Unable to create output file: %s", filename.c_str()); | 765 | error_message = llformat( "Unable to create output file: %s", filename.c_str()); |
752 | args["[FILE]"] = filename; | 766 | args["FILE"] = filename; |
753 | upload_error(error_message, "UnableToCreateOutputFile", filename, args); | 767 | upload_error(error_message, "UnableToCreateOutputFile", filename, args); |
754 | return; | 768 | return; |
755 | } | 769 | } |
@@ -783,8 +797,9 @@ void upload_new_resource(const std::string& src_filename, std::string name, | |||
783 | uuid = tid.makeAssetID(gAgent.getSecureSessionID()); | 797 | uuid = tid.makeAssetID(gAgent.getSecureSessionID()); |
784 | // copy this file into the vfs for upload | 798 | // copy this file into the vfs for upload |
785 | S32 file_size; | 799 | S32 file_size; |
786 | apr_file_t* fp = ll_apr_file_open(filename, LL_APR_RB, &file_size); | 800 | LLAPRFile infile ; |
787 | if (fp) | 801 | infile.open(filename, LL_APR_RB, NULL, &file_size); |
802 | if (infile.getFileHandle()) | ||
788 | { | 803 | { |
789 | LLVFile file(gVFS, uuid, asset_type, LLVFile::WRITE); | 804 | LLVFile file(gVFS, uuid, asset_type, LLVFile::WRITE); |
790 | 805 | ||
@@ -792,11 +807,10 @@ void upload_new_resource(const std::string& src_filename, std::string name, | |||
792 | 807 | ||
793 | const S32 buf_size = 65536; | 808 | const S32 buf_size = 65536; |
794 | U8 copy_buf[buf_size]; | 809 | U8 copy_buf[buf_size]; |
795 | while ((file_size = ll_apr_file_read(fp, copy_buf, buf_size))) | 810 | while ((file_size = infile.read(copy_buf, buf_size))) |
796 | { | 811 | { |
797 | file.write(copy_buf, file_size); | 812 | file.write(copy_buf, file_size); |
798 | } | 813 | } |
799 | apr_file_close(fp); | ||
800 | } | 814 | } |
801 | else | 815 | else |
802 | { | 816 | { |
@@ -813,15 +827,15 @@ void upload_new_resource(const std::string& src_filename, std::string name, | |||
813 | t_disp_name = src_filename; | 827 | t_disp_name = src_filename; |
814 | } | 828 | } |
815 | upload_new_resource(tid, asset_type, name, desc, compression_info, // tid | 829 | upload_new_resource(tid, asset_type, name, desc, compression_info, // tid |
816 | destination_folder_type, inv_type, next_owner_perm, | 830 | destination_folder_type, inv_type, next_owner_perms, group_perms, everyone_perms, |
817 | display_name, callback, userdata); | 831 | display_name, callback, expected_upload_cost, userdata); |
818 | } | 832 | } |
819 | else | 833 | else |
820 | { | 834 | { |
821 | llwarns << error_message << llendl; | 835 | llwarns << error_message << llendl; |
822 | LLStringUtil::format_map_t args; | 836 | LLSD args; |
823 | args["[ERROR_MESSAGE]"] = error_message; | 837 | args["ERROR_MESSAGE"] = error_message; |
824 | gViewerWindow->alertXml("ErrorMessage", args); | 838 | LLNotifications::instance().add("ErrorMessage", args); |
825 | if(LLFile::remove(filename) == -1) | 839 | if(LLFile::remove(filename) == -1) |
826 | { | 840 | { |
827 | lldebugs << "unable to remove temp file" << llendl; | 841 | lldebugs << "unable to remove temp file" << llendl; |
@@ -833,8 +847,10 @@ void upload_new_resource(const std::string& src_filename, std::string name, | |||
833 | void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status) // StoreAssetData callback (fixed) | 847 | void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status) // StoreAssetData callback (fixed) |
834 | { | 848 | { |
835 | LLResourceData* data = (LLResourceData*)user_data; | 849 | LLResourceData* data = (LLResourceData*)user_data; |
850 | S32 expected_upload_cost = data ? data->mExpectedUploadCost : 0; | ||
836 | //LLAssetType::EType pref_loc = data->mPreferredLocation; | 851 | //LLAssetType::EType pref_loc = data->mPreferredLocation; |
837 | BOOL is_balance_sufficient = TRUE; | 852 | BOOL is_balance_sufficient = TRUE; |
853 | |||
838 | if(result >= 0) | 854 | if(result >= 0) |
839 | { | 855 | { |
840 | LLAssetType::EType dest_loc = (data->mPreferredLocation == LLAssetType::AT_NONE) ? data->mAssetInfo.mType : data->mPreferredLocation; | 856 | LLAssetType::EType dest_loc = (data->mPreferredLocation == LLAssetType::AT_NONE) ? data->mAssetInfo.mType : data->mPreferredLocation; |
@@ -845,20 +861,19 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt | |||
845 | { | 861 | { |
846 | // Charge the user for the upload. | 862 | // Charge the user for the upload. |
847 | LLViewerRegion* region = gAgent.getRegion(); | 863 | LLViewerRegion* region = gAgent.getRegion(); |
848 | S32 upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); | ||
849 | 864 | ||
850 | if(!(can_afford_transaction(upload_cost))) | 865 | if(!(can_afford_transaction(expected_upload_cost))) |
851 | { | 866 | { |
852 | LLFloaterBuyCurrency::buyCurrency( | 867 | LLFloaterBuyCurrency::buyCurrency( |
853 | llformat("Uploading %s costs", | 868 | llformat("Uploading %s costs", |
854 | data->mAssetInfo.getName().c_str()), // *TODO: Translate | 869 | data->mAssetInfo.getName().c_str()), // *TODO: Translate |
855 | upload_cost); | 870 | expected_upload_cost); |
856 | is_balance_sufficient = FALSE; | 871 | is_balance_sufficient = FALSE; |
857 | } | 872 | } |
858 | else if(region) | 873 | else if(region) |
859 | { | 874 | { |
860 | // Charge user for upload | 875 | // Charge user for upload |
861 | gStatusBar->debitBalance(upload_cost); | 876 | gStatusBar->debitBalance(expected_upload_cost); |
862 | 877 | ||
863 | LLMessageSystem* msg = gMessageSystem; | 878 | LLMessageSystem* msg = gMessageSystem; |
864 | msg->newMessageFast(_PREHASH_MoneyTransferRequest); | 879 | msg->newMessageFast(_PREHASH_MoneyTransferRequest); |
@@ -869,7 +884,9 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt | |||
869 | msg->addUUIDFast(_PREHASH_SourceID, gAgent.getID()); | 884 | msg->addUUIDFast(_PREHASH_SourceID, gAgent.getID()); |
870 | msg->addUUIDFast(_PREHASH_DestID, LLUUID::null); | 885 | msg->addUUIDFast(_PREHASH_DestID, LLUUID::null); |
871 | msg->addU8("Flags", 0); | 886 | msg->addU8("Flags", 0); |
872 | msg->addS32Fast(_PREHASH_Amount, upload_cost); | 887 | // we tell the sim how much we were expecting to pay so it |
888 | // can respond to any discrepancy | ||
889 | msg->addS32Fast(_PREHASH_Amount, expected_upload_cost); | ||
873 | msg->addU8Fast(_PREHASH_AggregatePermNextOwner, (U8)LLAggregatePermissions::AP_EMPTY); | 890 | msg->addU8Fast(_PREHASH_AggregatePermNextOwner, (U8)LLAggregatePermissions::AP_EMPTY); |
874 | msg->addU8Fast(_PREHASH_AggregatePermInventory, (U8)LLAggregatePermissions::AP_EMPTY); | 891 | msg->addU8Fast(_PREHASH_AggregatePermInventory, (U8)LLAggregatePermissions::AP_EMPTY); |
875 | msg->addS32Fast(_PREHASH_TransactionType, TRANS_UPLOAD_CHARGE); | 892 | msg->addS32Fast(_PREHASH_TransactionType, TRANS_UPLOAD_CHARGE); |
@@ -885,15 +902,15 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt | |||
885 | LLUUID folder_id(gInventory.findCategoryUUIDForType(dest_loc)); | 902 | LLUUID folder_id(gInventory.findCategoryUUIDForType(dest_loc)); |
886 | if(folder_id.notNull()) | 903 | if(folder_id.notNull()) |
887 | { | 904 | { |
888 | U32 next_owner_perm = data->mNextOwnerPerm; | 905 | U32 next_owner_perms = data->mNextOwnerPerm; |
889 | if(PERM_NONE == next_owner_perm) | 906 | if(PERM_NONE == next_owner_perms) |
890 | { | 907 | { |
891 | next_owner_perm = PERM_MOVE | PERM_TRANSFER; | 908 | next_owner_perms = PERM_MOVE | PERM_TRANSFER; |
892 | } | 909 | } |
893 | create_inventory_item(gAgent.getID(), gAgent.getSessionID(), | 910 | create_inventory_item(gAgent.getID(), gAgent.getSessionID(), |
894 | folder_id, data->mAssetInfo.mTransactionID, data->mAssetInfo.getName(), | 911 | folder_id, data->mAssetInfo.mTransactionID, data->mAssetInfo.getName(), |
895 | data->mAssetInfo.getDescription(), data->mAssetInfo.mType, | 912 | data->mAssetInfo.getDescription(), data->mAssetInfo.mType, |
896 | data->mInventoryType, NOT_WEARABLE, next_owner_perm, | 913 | data->mInventoryType, NOT_WEARABLE, next_owner_perms, |
897 | LLPointer<LLInventoryCallback>(NULL)); | 914 | LLPointer<LLInventoryCallback>(NULL)); |
898 | } | 915 | } |
899 | else | 916 | else |
@@ -904,10 +921,10 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt | |||
904 | } | 921 | } |
905 | else // if(result >= 0) | 922 | else // if(result >= 0) |
906 | { | 923 | { |
907 | LLStringUtil::format_map_t args; | 924 | LLSD args; |
908 | args["[FILE]"] = LLInventoryType::lookupHumanReadable(data->mInventoryType); | 925 | args["FILE"] = LLInventoryType::lookupHumanReadable(data->mInventoryType); |
909 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(result)); | 926 | args["REASON"] = std::string(LLAssetStorage::getErrorString(result)); |
910 | gViewerWindow->alertXml("CannotUploadReason", args); | 927 | LLNotifications::instance().add("CannotUploadReason", args); |
911 | } | 928 | } |
912 | 929 | ||
913 | LLUploadDialog::modalUploadFinished(); | 930 | LLUploadDialog::modalUploadFinished(); |
@@ -925,20 +942,31 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt | |||
925 | LLStringUtil::stripNonprintable(asset_name); | 942 | LLStringUtil::stripNonprintable(asset_name); |
926 | LLStringUtil::trim(asset_name); | 943 | LLStringUtil::trim(asset_name); |
927 | 944 | ||
945 | std::string display_name = LLStringUtil::null; | ||
946 | LLAssetStorage::LLStoreAssetCallback callback = NULL; | ||
947 | void *userdata = NULL; | ||
928 | upload_new_resource(next_file, asset_name, asset_name, // file | 948 | upload_new_resource(next_file, asset_name, asset_name, // file |
929 | 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE); | 949 | 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE, |
950 | PERM_NONE, PERM_NONE, PERM_NONE, | ||
951 | display_name, | ||
952 | callback, | ||
953 | expected_upload_cost, // assuming next in a group of uploads is of roughly the same type, i.e. same upload cost | ||
954 | userdata); | ||
930 | } | 955 | } |
931 | } | 956 | } |
932 | 957 | ||
933 | void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_type, | 958 | void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_type, |
934 | std::string name, | 959 | std::string name, |
935 | std::string desc, S32 compression_info, | 960 | std::string desc, S32 compression_info, |
936 | LLAssetType::EType destination_folder_type, | 961 | LLAssetType::EType destination_folder_type, |
937 | LLInventoryType::EType inv_type, | 962 | LLInventoryType::EType inv_type, |
938 | U32 next_owner_perm, | 963 | U32 next_owner_perms, |
939 | const std::string& display_name, | 964 | U32 group_perms, |
940 | LLAssetStorage::LLStoreAssetCallback callback, | 965 | U32 everyone_perms, |
941 | void *userdata) | 966 | const std::string& display_name, |
967 | LLAssetStorage::LLStoreAssetCallback callback, | ||
968 | S32 expected_upload_cost, | ||
969 | void *userdata) | ||
942 | { | 970 | { |
943 | LLAssetID uuid = tid.makeAssetID(gAgent.getSecureSessionID()); | 971 | LLAssetID uuid = tid.makeAssetID(gAgent.getSecureSessionID()); |
944 | 972 | ||
@@ -982,6 +1010,7 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty | |||
982 | llinfos << "UUID: " << uuid << llendl; | 1010 | llinfos << "UUID: " << uuid << llendl; |
983 | llinfos << "Name: " << name << llendl; | 1011 | llinfos << "Name: " << name << llendl; |
984 | llinfos << "Desc: " << desc << llendl; | 1012 | llinfos << "Desc: " << desc << llendl; |
1013 | llinfos << "Expected Upload Cost: " << expected_upload_cost << llendl; | ||
985 | lldebugs << "Folder: " << gInventory.findCategoryUUIDForType((destination_folder_type == LLAssetType::AT_NONE) ? asset_type : destination_folder_type) << llendl; | 1014 | lldebugs << "Folder: " << gInventory.findCategoryUUIDForType((destination_folder_type == LLAssetType::AT_NONE) ? asset_type : destination_folder_type) << llendl; |
986 | lldebugs << "Asset Type: " << LLAssetType::lookup(asset_type) << llendl; | 1015 | lldebugs << "Asset Type: " << LLAssetType::lookup(asset_type) << llendl; |
987 | std::string url = gAgent.getRegion()->getCapability("NewFileAgentInventory"); | 1016 | std::string url = gAgent.getRegion()->getCapability("NewFileAgentInventory"); |
@@ -994,10 +1023,15 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty | |||
994 | body["inventory_type"] = LLInventoryType::lookup(inv_type); | 1023 | body["inventory_type"] = LLInventoryType::lookup(inv_type); |
995 | body["name"] = name; | 1024 | body["name"] = name; |
996 | body["description"] = desc; | 1025 | body["description"] = desc; |
1026 | body["next_owner_mask"] = LLSD::Integer(next_owner_perms); | ||
1027 | body["group_mask"] = LLSD::Integer(group_perms); | ||
1028 | body["everyone_mask"] = LLSD::Integer(everyone_perms); | ||
1029 | body["expected_upload_cost"] = LLSD::Integer(expected_upload_cost); | ||
997 | 1030 | ||
998 | std::ostringstream llsdxml; | 1031 | //std::ostringstream llsdxml; |
999 | LLSDSerialize::toXML(body, llsdxml); | 1032 | //LLSDSerialize::toPrettyXML(body, llsdxml); |
1000 | lldebugs << "posting body to capability: " << llsdxml.str() << llendl; | 1033 | //llinfos << "posting body to capability: " << llsdxml.str() << llendl; |
1034 | |||
1001 | LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, uuid, asset_type)); | 1035 | LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, uuid, asset_type)); |
1002 | } | 1036 | } |
1003 | else | 1037 | else |
@@ -1009,12 +1043,11 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty | |||
1009 | LLAssetType::AT_TEXTURE == asset_type || | 1043 | LLAssetType::AT_TEXTURE == asset_type || |
1010 | LLAssetType::AT_ANIMATION == asset_type) | 1044 | LLAssetType::AT_ANIMATION == asset_type) |
1011 | { | 1045 | { |
1012 | S32 upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); | ||
1013 | S32 balance = gStatusBar->getBalance(); | 1046 | S32 balance = gStatusBar->getBalance(); |
1014 | if (balance < upload_cost) | 1047 | if (balance < expected_upload_cost) |
1015 | { | 1048 | { |
1016 | // insufficient funds, bail on this upload | 1049 | // insufficient funds, bail on this upload |
1017 | LLFloaterBuyCurrency::buyCurrency("Uploading costs", upload_cost); | 1050 | LLFloaterBuyCurrency::buyCurrency("Uploading costs", expected_upload_cost); |
1018 | return; | 1051 | return; |
1019 | } | 1052 | } |
1020 | } | 1053 | } |
@@ -1025,7 +1058,8 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty | |||
1025 | data->mAssetInfo.mType = asset_type; | 1058 | data->mAssetInfo.mType = asset_type; |
1026 | data->mAssetInfo.mCreatorID = gAgentID; | 1059 | data->mAssetInfo.mCreatorID = gAgentID; |
1027 | data->mInventoryType = inv_type; | 1060 | data->mInventoryType = inv_type; |
1028 | data->mNextOwnerPerm = next_owner_perm; | 1061 | data->mNextOwnerPerm = next_owner_perms; |
1062 | data->mExpectedUploadCost = expected_upload_cost; | ||
1029 | data->mUserData = userdata; | 1063 | data->mUserData = userdata; |
1030 | data->mAssetInfo.setName(name); | 1064 | data->mAssetInfo.setName(name); |
1031 | data->mAssetInfo.setDescription(desc); | 1065 | data->mAssetInfo.setDescription(desc); |