summaryrefslogtreecommitdiff
path: root/indra/newview/llviewermenufile.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2019-11-18 17:15:11 +0000
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2019-11-18 17:15:11 +0000
commitd12e10be377e692f5164ba914b8f038e66b0d45c (patch)
treecad44c4d672f460625f7a30210f41bb801c92cd1 /indra/newview/llviewermenufile.cpp
parent65550520ed00699098b221a1166e4c1763333d58 (diff)
SL-10499 - bulk upload behavior adjusted to account for possibly different upload prices for different asset types. Also added a confirmation dialog for bulk upload.
Diffstat (limited to 'indra/newview/llviewermenufile.cpp')
-rw-r--r--indra/newview/llviewermenufile.cpp104
1 files changed, 81 insertions, 23 deletions
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index b1606958e1..90fbbcc8d2 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -404,24 +404,19 @@ const void upload_single_file(const std::vector<std::string>& filenames, LLFileP
return;
}
-
-const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker::ELoadFilter type)
+void do_bulk_upload(std::vector<std::string> filenames, const LLSD& notification, const LLSD& response)
{
- // TODO:
- // Check user balance for entire cost
- // Charge user entire cost
- // Loop, uploading
- // If an upload fails, refund the user for that one
- //
- // Also fix single upload to charge first, then refund
+ S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+ if (option != 0)
+ {
+ // Cancel upload
+ return;
+ }
- // FIXME PREMIUM - upload_cost should be per-file, depends on asset type
- S32 expected_upload_cost = LLAgentBenefits::instance().getTextureUploadCost();
for (std::vector<std::string>::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter)
{
std::string filename = (*in_iter);
- if (!check_file_extension(filename, type)) continue;
-
+
std::string name = gDirUtilp->getBaseFileName(filename, true);
std::string asset_name = name;
LLStringUtil::replaceNonstandardASCII(asset_name, '?');
@@ -429,17 +424,80 @@ const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker::
LLStringUtil::stripNonprintable(asset_name);
LLStringUtil::trim(asset_name);
- LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo(
- filename,
- asset_name,
- asset_name, 0,
- LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
- LLFloaterPerms::getNextOwnerPerms("Uploads"),
- LLFloaterPerms::getGroupPerms("Uploads"),
- LLFloaterPerms::getEveryonePerms("Uploads"),
- expected_upload_cost));
+ std::string ext = gDirUtilp->getExtension(filename);
+ LLAssetType::EType asset_type;
+ U32 codec;
+ S32 expected_upload_cost;
+ if (LLResourceUploadInfo::findAssetTypeAndCodecOfExtension(ext, asset_type, codec) &&
+ LLAgentBenefits::instance().findUploadCost(asset_type, expected_upload_cost))
+ {
+ LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo(
+ filename,
+ asset_name,
+ asset_name, 0,
+ LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
+ LLFloaterPerms::getNextOwnerPerms("Uploads"),
+ LLFloaterPerms::getGroupPerms("Uploads"),
+ LLFloaterPerms::getEveryonePerms("Uploads"),
+ expected_upload_cost));
+
+ upload_new_resource(uploadInfo, NULL, NULL);
+ }
+ }
+}
- upload_new_resource(uploadInfo, NULL, NULL);
+bool get_bulk_upload_expected_cost(const std::vector<std::string>& filenames, S32& total_cost)
+{
+ bool succ = true;
+ total_cost = 0;
+ for (std::vector<std::string>::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter)
+ {
+ std::string filename = (*in_iter);
+ std::string ext = gDirUtilp->getExtension(filename);
+
+ LLAssetType::EType asset_type;
+ U32 codec;
+ S32 cost;
+
+ if (LLResourceUploadInfo::findAssetTypeAndCodecOfExtension(ext, asset_type, codec) &&
+ LLAgentBenefits::instance().findUploadCost(asset_type, cost))
+ {
+ total_cost += cost;
+ }
+ }
+
+ return succ;
+}
+
+const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker::ELoadFilter type)
+{
+ // TODO:
+ // Check user balance for entire cost
+ // Charge user entire cost
+ // Loop, uploading
+ // If an upload fails, refund the user for that one
+ //
+ // Also fix single upload to charge first, then refund
+
+ // FIXME PREMIUM what about known types that can't be bulk uploaded
+ // (bvh)? These will fail in the item by item upload but won't be
+ // mentioned in the notification.
+ std::vector<std::string> filtered_filenames;
+ for (std::vector<std::string>::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter)
+ {
+ const std::string& filename = *in_iter;
+ if (check_file_extension(filename, type))
+ {
+ filtered_filenames.push_back(filename);
+ }
+ }
+ S32 expected_upload_cost;
+ if (get_bulk_upload_expected_cost(filtered_filenames, expected_upload_cost))
+ {
+ LLSD args;
+ args["COST"] = expected_upload_cost;
+ args["COUNT"] = (S32) filtered_filenames.size();
+ LLNotificationsUtil::add("BulkUploadCostConfirmation", args, LLSD(), boost::bind(do_bulk_upload, filtered_filenames, _1, _2));
}
}