From ddb63e7fb70eefea200fbb385efe86e50e5c1e12 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 30 Jun 2015 17:11:10 -0700 Subject: Initial checkin for uploading via coroutine. --- indra/newview/llviewerassetupload.cpp | 138 ++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 indra/newview/llviewerassetupload.cpp (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp new file mode 100644 index 0000000000..3f21cf2b7e --- /dev/null +++ b/indra/newview/llviewerassetupload.cpp @@ -0,0 +1,138 @@ +/** +* @file llviewerassetupload.cpp +* @author optional +* @brief brief description of the file +* +* $LicenseInfo:firstyear=2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2011, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" + +#include "linden_common.h" +#include "llviewerassetupload.h" +#include "llviewertexturelist.h" +#include "llimage.h" +#include "lltrans.h" +#include "lluuid.h" +#include "llvorbisencode.h" +#include "lluploaddialog.h" +#include "lleconomy.h" + +//========================================================================= +/*static*/ +void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, + std::string url, NewResourceUploadInfo::ptr_t uploadInfo) +{ + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + uploadInfo->prepareUpload(); + uploadInfo->logPreparedUpload(); + + std::string uploadMessage = "Uploading...\n\n"; + uploadMessage.append(uploadInfo->getDisplayName()); + LLUploadDialog::modalUploadDialog(uploadMessage); + + LLSD body = uploadInfo->generatePostBody(); + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, body); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + + } + + std::string uploader = result["uploader"].asString(); + + result = httpAdapter->postFileAndYield(self, httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); + + if (!status) + { + + } + + S32 expected_upload_cost = 0; + + // Update L$ and ownership credit information + // since it probably changed on the server + if (uploadInfo->getAssetType() == LLAssetType::AT_TEXTURE || + uploadInfo->getAssetType() == LLAssetType::AT_SOUND || + uploadInfo->getAssetType() == LLAssetType::AT_ANIMATION || + uploadInfo->getAssetType() == LLAssetType::AT_MESH) + { + expected_upload_cost = + LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); + } + + on_new_single_inventory_upload_complete( + uploadInfo->getAssetType(), + uploadInfo->getInventoryType(), + uploadInfo->getAssetTypeString(), // note the paramert calls for inv_type string... + uploadInfo->getFolderId(), + uploadInfo->getName(), + uploadInfo->getDescription(), + result, + expected_upload_cost); + +#if 0 + + LLSD initalBody = generate_new_resource_upload_capability_body(); + + + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, initalBody); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + + } + + std::string state = result["state"].asString(); + + if (state == "upload") + { +// Upload the file... + result = httpAdapter->postFileAndYield(self, httpRequest, url, initalBody); + + httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + state = result["state"].asString(); + } + + if (state == "complete") + { + // done with the upload. + } + else + { + // an error occurred + } +#endif +} + +//========================================================================= -- cgit v1.2.3 From b262ded7e0cf21314524bf702b0e4fe28a3c3060 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 1 Jul 2015 18:33:29 -0400 Subject: MAINT-5351: Remove 'self' parameter from coroutine functions. lleventcoro_test.cpp runs clean (as modified for new API), and all the rest builds clean, but the resulting viewer is as yet untested. --- indra/newview/llviewerassetupload.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 3f21cf2b7e..b6bc17c6c9 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -39,7 +39,7 @@ //========================================================================= /*static*/ -void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, +void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo) { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); @@ -53,7 +53,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore LLSD body = uploadInfo->generatePostBody(); - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, body); + LLSD result = httpAdapter->postAndYield(httpRequest, url, body); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -65,7 +65,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore std::string uploader = result["uploader"].asString(); - result = httpAdapter->postFileAndYield(self, httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); + result = httpAdapter->postFileAndYield(httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); if (!status) { @@ -101,7 +101,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, initalBody); + LLSD result = httpAdapter->postAndYield(httpRequest, url, initalBody); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -116,7 +116,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore if (state == "upload") { // Upload the file... - result = httpAdapter->postFileAndYield(self, httpRequest, url, initalBody); + result = httpAdapter->postFileAndYield(httpRequest, url, initalBody); httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); -- cgit v1.2.3 From f8a7eda55bdd34eeb2fafed21d23d26cd25f924d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Jul 2015 09:17:48 -0700 Subject: Adjusting uploadinfo object for expansion. Commit is prelim to allow merge from selfless. --- indra/newview/llviewerassetupload.cpp | 147 +++++++++++++++++++++++++--------- 1 file changed, 107 insertions(+), 40 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 3f21cf2b7e..e2394e20d5 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -35,7 +35,14 @@ #include "lluuid.h" #include "llvorbisencode.h" #include "lluploaddialog.h" +#include "llpreviewscript.h" +#include "llnotificationsutil.h" #include "lleconomy.h" +#include "llagent.h" +#include "llfloaterreg.h" +#include "llstatusbar.h" +#include "llinventorypanel.h" +#include "llsdutil.h" //========================================================================= /*static*/ @@ -44,35 +51,49 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - uploadInfo->prepareUpload(); + LLSD result = uploadInfo->prepareUpload(); uploadInfo->logPreparedUpload(); + if (result.has("error")) + { + HandleUploadError(LLCore::HttpStatus(499), result, uploadInfo); + return; + } + + //self.yield(); + std::string uploadMessage = "Uploading...\n\n"; uploadMessage.append(uploadInfo->getDisplayName()); LLUploadDialog::modalUploadDialog(uploadMessage); LLSD body = uploadInfo->generatePostBody(); - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, body); + result = httpAdapter->postAndYield(self, httpRequest, url, body); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - if (!status) + if ((!status) || (result.has("error"))) { - + HandleUploadError(status, result, uploadInfo); + LLUploadDialog::modalUploadFinished(); + return; } std::string uploader = result["uploader"].asString(); result = httpAdapter->postFileAndYield(self, httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); + httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { - + HandleUploadError(status, result, uploadInfo); + LLUploadDialog::modalUploadFinished(); + return; } - S32 expected_upload_cost = 0; + S32 uploadPrice = 0; // Update L$ and ownership credit information // since it probably changed on the server @@ -81,58 +102,104 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore uploadInfo->getAssetType() == LLAssetType::AT_ANIMATION || uploadInfo->getAssetType() == LLAssetType::AT_MESH) { - expected_upload_cost = - LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); + uploadPrice = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); } - on_new_single_inventory_upload_complete( - uploadInfo->getAssetType(), - uploadInfo->getInventoryType(), - uploadInfo->getAssetTypeString(), // note the paramert calls for inv_type string... - uploadInfo->getFolderId(), - uploadInfo->getName(), - uploadInfo->getDescription(), - result, - expected_upload_cost); - -#if 0 - - LLSD initalBody = generate_new_resource_upload_capability_body(); - + bool success = false; + if (uploadPrice > 0) + { + // this upload costed us L$, update our balance + // and display something saying that it cost L$ + LLStatusBar::sendMoneyBalanceRequest(); - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, initalBody); + LLSD args; + args["AMOUNT"] = llformat("%d", uploadPrice); + LLNotificationsUtil::add("UploadPayment", args); + } - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + LLUUID serverInventoryItem = uploadInfo->finishUpload(result); - if (!status) + if (serverInventoryItem.notNull()) { - + success = true; + + // Show the preview panel for textures and sounds to let + // user know that the image (or snapshot) arrived intact. + LLInventoryPanel* panel = LLInventoryPanel::getActiveInventoryPanel(); + if (panel) + { + LLFocusableElement* focus = gFocusMgr.getKeyboardFocus(); + panel->setSelection(serverInventoryItem, TAKE_FOCUS_NO); + + // restore keyboard focus + gFocusMgr.setKeyboardFocus(focus); + } + } + else + { + LL_WARNS() << "Can't find a folder to put it in" << LL_ENDL; } - std::string state = result["state"].asString(); + // remove the "Uploading..." message + LLUploadDialog::modalUploadFinished(); - if (state == "upload") + // Let the Snapshot floater know we have finished uploading a snapshot to inventory. + LLFloater* floater_snapshot = LLFloaterReg::findInstance("snapshot"); + if (uploadInfo->getAssetType() == LLAssetType::AT_TEXTURE && floater_snapshot) { -// Upload the file... - result = httpAdapter->postFileAndYield(self, httpRequest, url, initalBody); + floater_snapshot->notify(LLSD().with("set-finished", LLSD().with("ok", success).with("msg", "inventory"))); + } +} - httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); +//========================================================================= +/*static*/ +void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &result, NewResourceUploadInfo::ptr_t &uploadInfo) +{ + std::string reason; + std::string label("CannotUploadReason"); - state = result["state"].asString(); + LL_WARNS() << ll_pretty_print_sd(result) << LL_ENDL; + + if (result.has("label")) + { + label = result["label"]; } - if (state == "complete") + if (result.has("message")) { - // done with the upload. + reason = result["message"]; } else { - // an error occurred + if (status.getType() == 499) + { + reason = "The server is experiencing unexpected difficulties."; + } + else + { + reason = "Error in upload request. Please visit " + "http://secondlife.com/support for help fixing this problem."; + } } -#endif -} -//========================================================================= + LLSD args; + args["FILE"] = uploadInfo->getDisplayName(); + args["REASON"] = reason; + + LLNotificationsUtil::add(label, args); + + // unfreeze script preview + if (uploadInfo->getAssetType() == LLAssetType::AT_LSL_TEXT) + { + LLPreviewLSL* preview = LLFloaterReg::findTypedInstance("preview_script", + uploadInfo->getItemId()); + if (preview) + { + LLSD errors; + errors.append(LLTrans::getString("UploadFailed") + reason); + preview->callbackLSLCompileFailed(errors); + } + } + +} -- cgit v1.2.3 From 99aa00293b1d79eb47cfe2caa85a5740a2959297 Mon Sep 17 00:00:00 2001 From: rider Date: Fri, 3 Jul 2015 09:39:18 -0700 Subject: Remove ambiguous assignment. --- indra/newview/llviewerassetupload.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index cd4e7c33ef..717b14bb72 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -163,12 +163,12 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res if (result.has("label")) { - label = result["label"]; + label = result["label"].asString(); } if (result.has("message")) { - reason = result["message"]; + reason = result["message"].asString(); } else { -- cgit v1.2.3 From 5a8580f7cb8976b2305a9fd7de7fe3b568e71b94 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 7 Jul 2015 10:09:55 -0700 Subject: Clean up viewrmenufile into viewrassetuplod --- indra/newview/llviewerassetupload.cpp | 351 +++++++++++++++++++++++++++++++++- 1 file changed, 350 insertions(+), 1 deletion(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 717b14bb72..1730523d8e 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -28,7 +28,6 @@ #include "llviewerprecompiledheaders.h" #include "linden_common.h" -#include "llviewerassetupload.h" #include "llviewertexturelist.h" #include "llimage.h" #include "lltrans.h" @@ -43,6 +42,356 @@ #include "llstatusbar.h" #include "llinventorypanel.h" #include "llsdutil.h" +#include "llviewerassetupload.h" +#include "llappviewer.h" +#include "llviewerstats.h" +#include "llvfile.h" + +LLSD NewResourceUploadInfo::prepareUpload() +{ + if (mAssetId.isNull()) + generateNewAssetId(); + + incrementUploadStats(); + assignDefaults(); + + return LLSD().with("success", LLSD::Boolean(true)); +} + +std::string NewResourceUploadInfo::getAssetTypeString() const +{ + return LLAssetType::lookup(mAssetType); +} + +std::string NewResourceUploadInfo::getInventoryTypeString() const +{ + return LLInventoryType::lookup(mInventoryType); +} + +LLSD NewResourceUploadInfo::generatePostBody() +{ + LLSD body; + + body["folder_id"] = mFolderId; + body["asset_type"] = getAssetTypeString(); + body["inventory_type"] = getInventoryTypeString(); + body["name"] = mName; + body["description"] = mDescription; + body["next_owner_mask"] = LLSD::Integer(mNextOwnerPerms); + body["group_mask"] = LLSD::Integer(mGroupPerms); + body["everyone_mask"] = LLSD::Integer(mEveryonePerms); + + return body; + +} + +void NewResourceUploadInfo::logPreparedUpload() +{ + LL_INFOS() << "*** Uploading: " << std::endl << + "Type: " << LLAssetType::lookup(mAssetType) << std::endl << + "UUID: " << mAssetId.asString() << std::endl << + "Name: " << mName << std::endl << + "Desc: " << mDescription << std::endl << + "Expected Upload Cost: " << mExpectedUploadCost << std::endl << + "Folder: " << mFolderId << std::endl << + "Asset Type: " << LLAssetType::lookup(mAssetType) << LL_ENDL; +} + +LLUUID NewResourceUploadInfo::finishUpload(LLSD &result) +{ + if (getFolderId().isNull()) + { + return LLUUID::null; + } + + U32 permsEveryone = PERM_NONE; + U32 permsGroup = PERM_NONE; + U32 permsNextOwner = PERM_ALL; + + if (result.has("new_next_owner_mask")) + { + // The server provided creation perms so use them. + // Do not assume we got the perms we asked for in + // since the server may not have granted them all. + permsEveryone = result["new_everyone_mask"].asInteger(); + permsGroup = result["new_group_mask"].asInteger(); + permsNextOwner = result["new_next_owner_mask"].asInteger(); + } + else + { + // The server doesn't provide creation perms + // so use old assumption-based perms. + if (getAssetTypeString() != "snapshot") + { + permsNextOwner = PERM_MOVE | PERM_TRANSFER; + } + } + + LLPermissions new_perms; + new_perms.init( + gAgent.getID(), + gAgent.getID(), + LLUUID::null, + LLUUID::null); + + new_perms.initMasks( + PERM_ALL, + PERM_ALL, + permsEveryone, + permsGroup, + permsNextOwner); + + U32 flagsInventoryItem = 0; + if (result.has("inventory_flags")) + { + flagsInventoryItem = static_cast(result["inventory_flags"].asInteger()); + if (flagsInventoryItem != 0) + { + LL_INFOS() << "inventory_item_flags " << flagsInventoryItem << LL_ENDL; + } + } + S32 creationDate = time_corrected(); + + LLUUID serverInventoryItem = result["new_inventory_item"].asUUID(); + LLUUID serverAssetId = result["new_asset"].asUUID(); + + LLPointer item = new LLViewerInventoryItem( + serverInventoryItem, + getFolderId(), + new_perms, + serverAssetId, + getAssetType(), + getInventoryType(), + getName(), + getDescription(), + LLSaleInfo::DEFAULT, + flagsInventoryItem, + creationDate); + + gInventory.updateItem(item); + gInventory.notifyObservers(); + + return serverInventoryItem; +} + + +LLAssetID NewResourceUploadInfo::generateNewAssetId() +{ + if (gDisconnected) + { + LLAssetID rv; + + rv.setNull(); + return rv; + } + mAssetId = mTransactionId.makeAssetID(gAgent.getSecureSessionID()); + + return mAssetId; +} + +void NewResourceUploadInfo::incrementUploadStats() const +{ + if (LLAssetType::AT_SOUND == mAssetType) + { + add(LLStatViewer::UPLOAD_SOUND, 1); + } + else if (LLAssetType::AT_TEXTURE == mAssetType) + { + add(LLStatViewer::UPLOAD_TEXTURE, 1); + } + else if (LLAssetType::AT_ANIMATION == mAssetType) + { + add(LLStatViewer::ANIMATION_UPLOADS, 1); + } +} + +void NewResourceUploadInfo::assignDefaults() +{ + if (LLInventoryType::IT_NONE == mInventoryType) + { + mInventoryType = LLInventoryType::defaultForAssetType(mAssetType); + } + LLStringUtil::stripNonprintable(mName); + LLStringUtil::stripNonprintable(mDescription); + + if (mName.empty()) + { + mName = "(No Name)"; + } + if (mDescription.empty()) + { + mDescription = "(No Description)"; + } + + mFolderId = gInventory.findCategoryUUIDForType( + (mDestinationFolderType == LLFolderType::FT_NONE) ? + (LLFolderType::EType)mAssetType : mDestinationFolderType); + +} + +std::string NewResourceUploadInfo::getDisplayName() const +{ + return (mName.empty()) ? mAssetId.asString() : mName; +}; + +//========================================================================= +NewFileResourceUploadInfo::NewFileResourceUploadInfo( + std::string fileName, + std::string name, + std::string description, + S32 compressionInfo, + LLFolderType::EType destinationType, + LLInventoryType::EType inventoryType, + U32 nextOWnerPerms, + U32 groupPerms, + U32 everyonePerms, + S32 expectedCost) : + NewResourceUploadInfo(name, description, compressionInfo, + destinationType, inventoryType, + nextOWnerPerms, groupPerms, everyonePerms, expectedCost), + mFileName(fileName) +{ + LLTransactionID tid; + tid.generate(); + setTransactionId(tid); +} + + + +LLSD NewFileResourceUploadInfo::prepareUpload() +{ + generateNewAssetId(); + + LLSD result = exportTempFile(); + if (result.has("error")) + return result; + + return NewResourceUploadInfo::prepareUpload(); +} + +LLSD NewFileResourceUploadInfo::exportTempFile() +{ + std::string filename = gDirUtilp->getTempFilename(); + + std::string exten = gDirUtilp->getExtension(getFileName()); + U32 codec = LLImageBase::getCodecFromExtension(exten); + + LLAssetType::EType assetType = LLAssetType::AT_NONE; + std::string errorMessage; + std::string errorLabel; + + bool error = false; + + if (exten.empty()) + { + std::string shortName = gDirUtilp->getBaseFileName(filename); + + // No extension + errorMessage = llformat( + "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension", + shortName.c_str()); + errorLabel = "NoFileExtension"; + error = true; + } + else if (codec != IMG_CODEC_INVALID) + { + // It's an image file, the upload procedure is the same for all + assetType = LLAssetType::AT_TEXTURE; + if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec)) + { + errorMessage = llformat("Problem with file %s:\n\n%s\n", + getFileName().c_str(), LLImage::getLastError().c_str()); + errorLabel = "ProblemWithFile"; + error = true; + } + } + else if (exten == "wav") + { + assetType = LLAssetType::AT_SOUND; // tag it as audio + S32 encodeResult = 0; + + LL_INFOS() << "Attempting to encode wav as an ogg file" << LL_ENDL; + + encodeResult = encode_vorbis_file(getFileName(), filename); + + if (LLVORBISENC_NOERR != encodeResult) + { + switch (encodeResult) + { + case LLVORBISENC_DEST_OPEN_ERR: + errorMessage = llformat("Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str()); + errorLabel = "CannotOpenTemporarySoundFile"; + break; + + default: + errorMessage = llformat("Unknown vorbis encode failure on: %s\n", getFileName().c_str()); + errorLabel = "UnknownVorbisEncodeFailure"; + break; + } + error = true; + } + } + else if (exten == "bvh") + { + errorMessage = llformat("We do not currently support bulk upload of animation files\n"); + errorLabel = "DoNotSupportBulkAnimationUpload"; + error = true; + } + else if (exten == "anim") + { + assetType = LLAssetType::AT_ANIMATION; + filename = getFileName(); + } + else + { + // Unknown extension + errorMessage = llformat(LLTrans::getString("UnknownFileExtension").c_str(), exten.c_str()); + errorLabel = "ErrorMessage"; + error = TRUE;; + } + + if (error) + { + LLSD errorResult(LLSD::emptyMap()); + + errorResult["error"] = LLSD::Binary(true); + errorResult["message"] = errorMessage; + errorResult["label"] = errorLabel; + return errorResult; + } + + setAssetType(assetType); + + // copy this file into the vfs for upload + S32 file_size; + LLAPRFile infile; + infile.open(filename, LL_APR_RB, NULL, &file_size); + if (infile.getFileHandle()) + { + LLVFile file(gVFS, getAssetId(), assetType, LLVFile::WRITE); + + file.setMaxSize(file_size); + + const S32 buf_size = 65536; + U8 copy_buf[buf_size]; + while ((file_size = infile.read(copy_buf, buf_size))) + { + file.write(copy_buf, file_size); + } + } + else + { + errorMessage = llformat("Unable to access output file: %s", filename.c_str()); + LLSD errorResult(LLSD::emptyMap()); + + errorResult["error"] = LLSD::Binary(true); + errorResult["message"] = errorMessage; + return errorResult; + } + + return LLSD(); + +} //========================================================================= /*static*/ -- cgit v1.2.3 From 247eb0c9c3418c10be8f2a0e3c8116758efa702f Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 7 Jul 2015 19:41:27 +0100 Subject: Backout selfles merge 738255dbbfd679d9e615baab3398e5e345bbb3c5 --- indra/newview/llviewerassetupload.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index cd4e7c33ef..e2394e20d5 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -46,7 +46,7 @@ //========================================================================= /*static*/ -void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, +void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo) { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); @@ -68,7 +68,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti LLSD body = uploadInfo->generatePostBody(); - result = httpAdapter->postAndYield(httpRequest, url, body); + result = httpAdapter->postAndYield(self, httpRequest, url, body); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -82,7 +82,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti std::string uploader = result["uploader"].asString(); - result = httpAdapter->postFileAndYield(httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); + result = httpAdapter->postFileAndYield(self, httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); -- cgit v1.2.3 From 1138c57f9a8553903199e727912d7f1b092697e4 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 10:01:27 -0700 Subject: Convert LLCore::HttpHeaders to use shared_ptr<> rather than an intrusive_ptr<> for refrence counting. --- indra/newview/llviewerassetupload.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index bfcdbfc109..efaf95444d 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -393,6 +393,9 @@ LLSD NewFileResourceUploadInfo::exportTempFile() } +//========================================================================= + + //========================================================================= /*static*/ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, @@ -552,3 +555,4 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res } } + -- cgit v1.2.3 From efa9a0f99c17b2b937120bcad6e3d45944122ed9 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 10 Jul 2015 19:30:10 -0400 Subject: Backed out changeset bab1000e1b2d: restore 'selfless' changes --- indra/newview/llviewerassetupload.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index e2394e20d5..cd4e7c33ef 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -46,7 +46,7 @@ //========================================================================= /*static*/ -void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, +void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo) { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); @@ -68,7 +68,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore LLSD body = uploadInfo->generatePostBody(); - result = httpAdapter->postAndYield(self, httpRequest, url, body); + result = httpAdapter->postAndYield(httpRequest, url, body); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -82,7 +82,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore std::string uploader = result["uploader"].asString(); - result = httpAdapter->postFileAndYield(self, httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); + result = httpAdapter->postFileAndYield(httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); -- cgit v1.2.3 From 91f636f23a6db27c4ca4c5df2325a7053ca3044e Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 10 Jul 2015 16:45:07 -0700 Subject: MAINT-5356: Conversion of Notecards and Gesture to use new coroutine uploading. Minor reorganization of Upload Info classes. --- indra/newview/llviewerassetupload.cpp | 170 ++++++++++++++++++++++++++++++++-- 1 file changed, 160 insertions(+), 10 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index efaf95444d..04014a6ecb 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -46,6 +46,56 @@ #include "llappviewer.h" #include "llviewerstats.h" #include "llvfile.h" +#include "llgesturemgr.h" +#include "llpreviewnotecard.h" +#include "llpreviewgesture.h" + +void dialog_refresh_all(); + +NewResourceUploadInfo::NewResourceUploadInfo(LLTransactionID transactId, + LLAssetType::EType assetType, std::string name, std::string description, + S32 compressionInfo, LLFolderType::EType destinationType, + LLInventoryType::EType inventoryType, U32 nextOWnerPerms, + U32 groupPerms, U32 everyonePerms, S32 expectedCost) : + mTransactionId(transactId), + mAssetType(assetType), + mName(name), + mDescription(description), + mCompressionInfo(compressionInfo), + mDestinationFolderType(destinationType), + mInventoryType(inventoryType), + mNextOwnerPerms(nextOWnerPerms), + mGroupPerms(groupPerms), + mEveryonePerms(everyonePerms), + mExpectedUploadCost(expectedCost), + mFolderId(LLUUID::null), + mItemId(LLUUID::null), + mAssetId(LLAssetID::null) +{ } + + +NewResourceUploadInfo::NewResourceUploadInfo(std::string name, + std::string description, S32 compressionInfo, + LLFolderType::EType destinationType, LLInventoryType::EType inventoryType, + U32 nextOWnerPerms, U32 groupPerms, U32 everyonePerms, S32 expectedCost): + mName(name), + mDescription(description), + mCompressionInfo(compressionInfo), + mDestinationFolderType(destinationType), + mInventoryType(inventoryType), + mNextOwnerPerms(nextOWnerPerms), + mGroupPerms(groupPerms), + mEveryonePerms(everyonePerms), + mExpectedUploadCost(expectedCost), + mTransactionId(), + mAssetType(LLAssetType::AT_NONE), + mFolderId(LLUUID::null), + mItemId(LLUUID::null), + mAssetId(LLAssetID::null) +{ + mTransactionId.generate(); +} + LLSD NewResourceUploadInfo::prepareUpload() { @@ -251,16 +301,14 @@ NewFileResourceUploadInfo::NewFileResourceUploadInfo( nextOWnerPerms, groupPerms, everyonePerms, expectedCost), mFileName(fileName) { - LLTransactionID tid; - tid.generate(); - setTransactionId(tid); } LLSD NewFileResourceUploadInfo::prepareUpload() { - generateNewAssetId(); + if (getAssetId().isNull()) + generateNewAssetId(); LLSD result = exportTempFile(); if (result.has("error")) @@ -394,7 +442,103 @@ LLSD NewFileResourceUploadInfo::exportTempFile() } //========================================================================= +LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType::EType assetType, std::string buffer, invnUploadFinish_f finish) : + NewResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, + 0, 0, 0, 0), + mTaskUpload(false), + mTaskId(LLUUID::null), + mContents(buffer), + mInvnFinishFn(finish), + mTaskFinishFn(NULL) +{ + setItemId(itemId); + setAssetType(assetType); + +} + +LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish) : + NewResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, + 0, 0, 0, 0), + mTaskUpload(true), + mTaskId(taskId), + mContents(buffer), + mInvnFinishFn(NULL), + mTaskFinishFn(finish) +{ + setItemId(itemId); + setAssetType(assetType); +} + + +LLSD LLBufferedAssetUploadInfo::prepareUpload() +{ + if (getAssetId().isNull()) + generateNewAssetId(); + + LLVFile file(gVFS, getAssetId(), getAssetType(), LLVFile::APPEND); + + S32 size = mContents.length() + 1; + file.setMaxSize(size); + file.write((U8*)mContents.c_str(), size); + + return LLSD().with("success", LLSD::Boolean(true)); +} + +LLSD LLBufferedAssetUploadInfo::generatePostBody() +{ + LLSD body; + + if (!getTaskId().isNull()) + { + body["task_id"] = getTaskId(); + } + body["item_id"] = getItemId(); + + return body; +} + +LLUUID LLBufferedAssetUploadInfo::finishUpload(LLSD &result) +{ + LLUUID newAssetId = result["new_asset"].asUUID(); + LLUUID itemId = getItemId(); + + if (mTaskUpload) + { + LLUUID taskId = getTaskId(); + + dialog_refresh_all(); + + if (mTaskFinishFn) + { + mTaskFinishFn(itemId, taskId, newAssetId, result); + } + } + else + { + LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(itemId); + if(!item) + { + LL_WARNS() << "Inventory item for " << getDisplayName() << " is no longer in agent inventory." << LL_ENDL; + return newAssetId; + } + // Update viewer inventory item + LLPointer newItem = new LLViewerInventoryItem(item); + newItem->setAssetUUID(newAssetId); + + gInventory.updateItem(newItem); + + LL_INFOS() << "Inventory item " << item->getName() << " saved into " << newAssetId.asString() << LL_ENDL; + + if (mInvnFinishFn) + { + mInvnFinishFn(itemId, newAssetId, newItem->getUUID(), result); + } + gInventory.notifyObservers(); + } + + return newAssetId; +} //========================================================================= /*static*/ @@ -414,9 +558,12 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore //self.yield(); - std::string uploadMessage = "Uploading...\n\n"; - uploadMessage.append(uploadInfo->getDisplayName()); - LLUploadDialog::modalUploadDialog(uploadMessage); + if (uploadInfo->showUploadDialog()) + { + std::string uploadMessage = "Uploading...\n\n"; + uploadMessage.append(uploadInfo->getDisplayName()); + LLUploadDialog::modalUploadDialog(uploadMessage); + } LLSD body = uploadInfo->generatePostBody(); @@ -428,7 +575,8 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore if ((!status) || (result.has("error"))) { HandleUploadError(status, result, uploadInfo); - LLUploadDialog::modalUploadFinished(); + if (uploadInfo->showUploadDialog()) + LLUploadDialog::modalUploadFinished(); return; } @@ -441,7 +589,8 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore if (!status) { HandleUploadError(status, result, uploadInfo); - LLUploadDialog::modalUploadFinished(); + if (uploadInfo->showUploadDialog()) + LLUploadDialog::modalUploadFinished(); return; } @@ -494,7 +643,8 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCore } // remove the "Uploading..." message - LLUploadDialog::modalUploadFinished(); + if (uploadInfo->showUploadDialog()) + LLUploadDialog::modalUploadFinished(); // Let the Snapshot floater know we have finished uploading a snapshot to inventory. LLFloater* floater_snapshot = LLFloaterReg::findInstance("snapshot"); -- cgit v1.2.3 From 0ba39810a90c5feaa741e5b1283c55e126bcaf66 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 13 Jul 2015 12:42:23 -0700 Subject: Rename the file in VFS with the new asset AID (prevents crash on gesture change and fixes notecard update) --- indra/newview/llviewerassetupload.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index f1a253a421..910e1dc6c5 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -449,7 +449,8 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType: mTaskId(LLUUID::null), mContents(buffer), mInvnFinishFn(finish), - mTaskFinishFn(NULL) + mTaskFinishFn(NULL), + mStoredToVFS(false) { setItemId(itemId); setAssetType(assetType); @@ -463,7 +464,8 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemI mTaskId(taskId), mContents(buffer), mInvnFinishFn(NULL), - mTaskFinishFn(finish) + mTaskFinishFn(finish), + mStoredToVFS(false) { setItemId(itemId); setAssetType(assetType); @@ -481,6 +483,9 @@ LLSD LLBufferedAssetUploadInfo::prepareUpload() file.setMaxSize(size); file.write((U8*)mContents.c_str(), size); + mStoredToVFS = true; + + return LLSD().with("success", LLSD::Boolean(true)); } @@ -502,6 +507,12 @@ LLUUID LLBufferedAssetUploadInfo::finishUpload(LLSD &result) LLUUID newAssetId = result["new_asset"].asUUID(); LLUUID itemId = getItemId(); + if (mStoredToVFS) + { + LLAssetType::EType assetType(getAssetType()); + gVFS->renameFile(getAssetId(), assetType, newAssetId, assetType); + } + if (mTaskUpload) { LLUUID taskId = getTaskId(); @@ -542,8 +553,8 @@ LLUUID LLBufferedAssetUploadInfo::finishUpload(LLSD &result) //========================================================================= /*static*/ -void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, - std::string url, NewResourceUploadInfo::ptr_t uploadInfo) +void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, + const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo) { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); -- cgit v1.2.3 From 1a6a6c786dcb4164c51734e51a4c86c722835e56 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 15 Jul 2015 14:35:53 -0700 Subject: LSL Script upload from inventory. --- indra/newview/llviewerassetupload.cpp | 74 ++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 18 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 910e1dc6c5..426e89b9d5 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -49,10 +49,11 @@ #include "llgesturemgr.h" #include "llpreviewnotecard.h" #include "llpreviewgesture.h" +#include "llcoproceduremanager.h" void dialog_refresh_all(); -NewResourceUploadInfo::NewResourceUploadInfo(LLTransactionID transactId, +LLResourceUploadInfo::LLResourceUploadInfo(LLTransactionID transactId, LLAssetType::EType assetType, std::string name, std::string description, S32 compressionInfo, LLFolderType::EType destinationType, LLInventoryType::EType inventoryType, U32 nextOWnerPerms, @@ -74,7 +75,7 @@ NewResourceUploadInfo::NewResourceUploadInfo(LLTransactionID transactId, { } -NewResourceUploadInfo::NewResourceUploadInfo(std::string name, +LLResourceUploadInfo::LLResourceUploadInfo(std::string name, std::string description, S32 compressionInfo, LLFolderType::EType destinationType, LLInventoryType::EType inventoryType, U32 nextOWnerPerms, U32 groupPerms, U32 everyonePerms, S32 expectedCost): @@ -97,7 +98,7 @@ NewResourceUploadInfo::NewResourceUploadInfo(std::string name, } -LLSD NewResourceUploadInfo::prepareUpload() +LLSD LLResourceUploadInfo::prepareUpload() { if (mAssetId.isNull()) generateNewAssetId(); @@ -108,17 +109,17 @@ LLSD NewResourceUploadInfo::prepareUpload() return LLSD().with("success", LLSD::Boolean(true)); } -std::string NewResourceUploadInfo::getAssetTypeString() const +std::string LLResourceUploadInfo::getAssetTypeString() const { return LLAssetType::lookup(mAssetType); } -std::string NewResourceUploadInfo::getInventoryTypeString() const +std::string LLResourceUploadInfo::getInventoryTypeString() const { return LLInventoryType::lookup(mInventoryType); } -LLSD NewResourceUploadInfo::generatePostBody() +LLSD LLResourceUploadInfo::generatePostBody() { LLSD body; @@ -135,7 +136,7 @@ LLSD NewResourceUploadInfo::generatePostBody() } -void NewResourceUploadInfo::logPreparedUpload() +void LLResourceUploadInfo::logPreparedUpload() { LL_INFOS() << "*** Uploading: " << std::endl << "Type: " << LLAssetType::lookup(mAssetType) << std::endl << @@ -147,7 +148,7 @@ void NewResourceUploadInfo::logPreparedUpload() "Asset Type: " << LLAssetType::lookup(mAssetType) << LL_ENDL; } -LLUUID NewResourceUploadInfo::finishUpload(LLSD &result) +LLUUID LLResourceUploadInfo::finishUpload(LLSD &result) { if (getFolderId().isNull()) { @@ -225,7 +226,7 @@ LLUUID NewResourceUploadInfo::finishUpload(LLSD &result) } -LLAssetID NewResourceUploadInfo::generateNewAssetId() +LLAssetID LLResourceUploadInfo::generateNewAssetId() { if (gDisconnected) { @@ -239,7 +240,7 @@ LLAssetID NewResourceUploadInfo::generateNewAssetId() return mAssetId; } -void NewResourceUploadInfo::incrementUploadStats() const +void LLResourceUploadInfo::incrementUploadStats() const { if (LLAssetType::AT_SOUND == mAssetType) { @@ -255,7 +256,7 @@ void NewResourceUploadInfo::incrementUploadStats() const } } -void NewResourceUploadInfo::assignDefaults() +void LLResourceUploadInfo::assignDefaults() { if (LLInventoryType::IT_NONE == mInventoryType) { @@ -279,7 +280,7 @@ void NewResourceUploadInfo::assignDefaults() } -std::string NewResourceUploadInfo::getDisplayName() const +std::string LLResourceUploadInfo::getDisplayName() const { return (mName.empty()) ? mAssetId.asString() : mName; }; @@ -296,7 +297,7 @@ NewFileResourceUploadInfo::NewFileResourceUploadInfo( U32 groupPerms, U32 everyonePerms, S32 expectedCost) : - NewResourceUploadInfo(name, description, compressionInfo, + LLResourceUploadInfo(name, description, compressionInfo, destinationType, inventoryType, nextOWnerPerms, groupPerms, everyonePerms, expectedCost), mFileName(fileName) @@ -314,7 +315,7 @@ LLSD NewFileResourceUploadInfo::prepareUpload() if (result.has("error")) return result; - return NewResourceUploadInfo::prepareUpload(); + return LLResourceUploadInfo::prepareUpload(); } LLSD NewFileResourceUploadInfo::exportTempFile() @@ -443,7 +444,7 @@ LLSD NewFileResourceUploadInfo::exportTempFile() //========================================================================= LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType::EType assetType, std::string buffer, invnUploadFinish_f finish) : - NewResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, + LLResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, 0, 0, 0, 0), mTaskUpload(false), mTaskId(LLUUID::null), @@ -458,7 +459,7 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType: } LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish) : - NewResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, + LLResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, 0, 0, 0, 0), mTaskUpload(true), mTaskId(taskId), @@ -551,10 +552,47 @@ LLUUID LLBufferedAssetUploadInfo::finishUpload(LLSD &result) return newAssetId; } +//========================================================================= + +LLScriptAssetUpload::LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish): + LLBufferedAssetUploadInfo(itemId, LLAssetType::AT_LSL_TEXT, buffer, finish) +{ +} + +// LLScriptAssetUpload::LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish): +// LLBufferedAssetUploadInfo() +// { +// } + +LLSD LLScriptAssetUpload::generatePostBody() +{ + LLSD body; + + if (getTaskId().isNull()) + { + body["item_id"] = getItemId(); + body["target"] = "lsl2"; + } + + return body; +} + +//========================================================================= +/*static*/ +LLUUID LLViewerAssetUpload::EnqueueInventoryUpload(const std::string &url, const LLResourceUploadInfo::ptr_t &uploadInfo) +{ + std::string procName("LLViewerAssetUpload::AssetInventoryUploadCoproc("); + + LLUUID queueId = LLCoprocedureManager::getInstance()->enqueueCoprocedure(procName + LLAssetType::lookup(uploadInfo->getAssetType()) + ")", + boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo)); + + return queueId; +} + //========================================================================= /*static*/ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, - const LLUUID &id, std::string url, NewResourceUploadInfo::ptr_t uploadInfo) + const LLUUID &id, std::string url, LLResourceUploadInfo::ptr_t uploadInfo) { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); @@ -667,7 +705,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti //========================================================================= /*static*/ -void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &result, NewResourceUploadInfo::ptr_t &uploadInfo) +void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &result, LLResourceUploadInfo::ptr_t &uploadInfo) { std::string reason; std::string label("CannotUploadReason"); -- cgit v1.2.3 From d22812a8c8cf96992bcf8d159be76a7bd962de63 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 17 Jul 2015 14:32:14 -0700 Subject: LSL Compile and upload from task object. Fix auto open when finished on all uploads... --- indra/newview/llviewerassetupload.cpp | 53 ++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 19 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 426e89b9d5..b29a9a6114 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -559,10 +559,14 @@ LLScriptAssetUpload::LLScriptAssetUpload(LLUUID itemId, std::string buffer, invn { } -// LLScriptAssetUpload::LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish): -// LLBufferedAssetUploadInfo() -// { -// } +LLScriptAssetUpload::LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, TargetType_t targetType, + bool isRunning, LLUUID exerienceId, std::string buffer, taskUploadFinish_f finish): + LLBufferedAssetUploadInfo(taskId, itemId, LLAssetType::AT_LSL_TEXT, buffer, finish), + mExerienceId(exerienceId), + mTargetType(targetType), + mIsRunning(isRunning) +{ +} LLSD LLScriptAssetUpload::generatePostBody() { @@ -573,6 +577,14 @@ LLSD LLScriptAssetUpload::generatePostBody() body["item_id"] = getItemId(); body["target"] = "lsl2"; } + else + { + body["task_id"] = getTaskId(); + body["item_id"] = getItemId(); + body["is_script_running"] = getIsRunning(); + body["target"] = (getTargetType() == MONO) ? "mono" : "lsl2"; + body["experience"] = getExerienceId(); + } return body; } @@ -670,25 +682,28 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti LLUUID serverInventoryItem = uploadInfo->finishUpload(result); - if (serverInventoryItem.notNull()) + if (uploadInfo->showInventoryPanel()) { - success = true; - - // Show the preview panel for textures and sounds to let - // user know that the image (or snapshot) arrived intact. - LLInventoryPanel* panel = LLInventoryPanel::getActiveInventoryPanel(); - if (panel) + if (serverInventoryItem.notNull()) { - LLFocusableElement* focus = gFocusMgr.getKeyboardFocus(); - panel->setSelection(serverInventoryItem, TAKE_FOCUS_NO); + success = true; - // restore keyboard focus - gFocusMgr.setKeyboardFocus(focus); + // Show the preview panel for textures and sounds to let + // user know that the image (or snapshot) arrived intact. + LLInventoryPanel* panel = LLInventoryPanel::getActiveInventoryPanel(); + if (panel) + { + LLFocusableElement* focus = gFocusMgr.getKeyboardFocus(); + panel->setSelection(serverInventoryItem, TAKE_FOCUS_NO); + + // restore keyboard focus + gFocusMgr.setKeyboardFocus(focus); + } + } + else + { + LL_WARNS() << "Can't find a folder to put it in" << LL_ENDL; } - } - else - { - LL_WARNS() << "Can't find a folder to put it in" << LL_ENDL; } // remove the "Uploading..." message -- cgit v1.2.3 From 37d17eaebd05325f0ddb3334cbabf7a8710d5843 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 20 Jul 2015 15:57:10 -0700 Subject: Remove old "compile queue" and replace with the coroutine based upload queue. --- indra/newview/llviewerassetupload.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index b29a9a6114..9982d68f52 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -486,7 +486,6 @@ LLSD LLBufferedAssetUploadInfo::prepareUpload() mStoredToVFS = true; - return LLSD().with("success", LLSD::Boolean(true)); } @@ -555,7 +554,10 @@ LLUUID LLBufferedAssetUploadInfo::finishUpload(LLSD &result) //========================================================================= LLScriptAssetUpload::LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish): - LLBufferedAssetUploadInfo(itemId, LLAssetType::AT_LSL_TEXT, buffer, finish) + LLBufferedAssetUploadInfo(itemId, LLAssetType::AT_LSL_TEXT, buffer, finish), + mExerienceId(), + mTargetType(LSL2), + mIsRunning(false) { } @@ -568,6 +570,7 @@ LLScriptAssetUpload::LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, TargetTyp { } + LLSD LLScriptAssetUpload::generatePostBody() { LLSD body; -- cgit v1.2.3 From f2850548abf8c103d6b11051a168d4f01ca154f4 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 20 Jul 2015 17:00:06 -0700 Subject: Forgot to remove an unused varable and renamed NewFileResourceUploadInfo to LLNewFileResourceUploadInfo --- indra/newview/llviewerassetupload.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 9982d68f52..51374922e8 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -286,7 +286,7 @@ std::string LLResourceUploadInfo::getDisplayName() const }; //========================================================================= -NewFileResourceUploadInfo::NewFileResourceUploadInfo( +LLNewFileResourceUploadInfo::LLNewFileResourceUploadInfo( std::string fileName, std::string name, std::string description, @@ -306,7 +306,7 @@ NewFileResourceUploadInfo::NewFileResourceUploadInfo( -LLSD NewFileResourceUploadInfo::prepareUpload() +LLSD LLNewFileResourceUploadInfo::prepareUpload() { if (getAssetId().isNull()) generateNewAssetId(); @@ -318,7 +318,7 @@ LLSD NewFileResourceUploadInfo::prepareUpload() return LLResourceUploadInfo::prepareUpload(); } -LLSD NewFileResourceUploadInfo::exportTempFile() +LLSD LLNewFileResourceUploadInfo::exportTempFile() { std::string filename = gDirUtilp->getTempFilename(); -- cgit v1.2.3 From 22bd85441b488dd9576bbdeffe9936650f010d78 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 22 Jul 2015 09:33:21 -0700 Subject: Clean up for postcard post. --- indra/newview/llviewerassetupload.cpp | 62 ++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 11 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 51374922e8..b00f99cf5c 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -458,6 +458,40 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType: } +LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLPointer image, invnUploadFinish_f finish) : + LLResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, + 0, 0, 0, 0), + mTaskUpload(false), + mTaskId(LLUUID::null), + mContents(), + mInvnFinishFn(finish), + mTaskFinishFn(NULL), + mStoredToVFS(false) +{ + setItemId(itemId); + + EImageCodec codec = static_cast(image->getCodec()); + + switch (codec) + { + case IMG_CODEC_JPEG: + setAssetType(LLAssetType::AT_IMAGE_JPEG); + LL_INFOS() << "Upload Asset type set to JPEG." << LL_ENDL; + break; + case IMG_CODEC_TGA: + setAssetType(LLAssetType::AT_IMAGE_TGA); + LL_INFOS() << "Upload Asset type set to TGA." << LL_ENDL; + break; + default: + LL_WARNS() << "Unknown codec to asset type transition. Codec=" << (int)codec << "." << LL_ENDL; + break; + } + + size_t imageSize = image->getDataSize(); + mContents.reserve(imageSize); + mContents.assign((char *)image->getData(), imageSize); +} + LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish) : LLResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, 0, 0, 0, 0), @@ -526,24 +560,30 @@ LLUUID LLBufferedAssetUploadInfo::finishUpload(LLSD &result) } else { - LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(itemId); - if(!item) + LLUUID newItemId(LLUUID::null); + + if (itemId.notNull()) { - LL_WARNS() << "Inventory item for " << getDisplayName() << " is no longer in agent inventory." << LL_ENDL; - return newAssetId; - } + LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(itemId); + if (!item) + { + LL_WARNS() << "Inventory item for " << getDisplayName() << " is no longer in agent inventory." << LL_ENDL; + return newAssetId; + } - // Update viewer inventory item - LLPointer newItem = new LLViewerInventoryItem(item); - newItem->setAssetUUID(newAssetId); + // Update viewer inventory item + LLPointer newItem = new LLViewerInventoryItem(item); + newItem->setAssetUUID(newAssetId); - gInventory.updateItem(newItem); + gInventory.updateItem(newItem); - LL_INFOS() << "Inventory item " << item->getName() << " saved into " << newAssetId.asString() << LL_ENDL; + newItemId = newItem->getUUID(); + LL_INFOS() << "Inventory item " << item->getName() << " saved into " << newAssetId.asString() << LL_ENDL; + } if (mInvnFinishFn) { - mInvnFinishFn(itemId, newAssetId, newItem->getUUID(), result); + mInvnFinishFn(itemId, newAssetId, newItemId, result); } gInventory.notifyObservers(); } -- cgit v1.2.3 From 62e83193c55e505d83a9be33cbc30353b6b887d2 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 22 Jul 2015 14:56:49 -0700 Subject: MAINT-5357: Added yield between prepare and post in upload. Removed some commented out code I had missed earlier Moved costing to virtual function in uploadinfo. --- indra/newview/llviewerassetupload.cpp | 73 ++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 31 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index b00f99cf5c..83d3449b96 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -148,6 +148,22 @@ void LLResourceUploadInfo::logPreparedUpload() "Asset Type: " << LLAssetType::lookup(mAssetType) << LL_ENDL; } +S32 LLResourceUploadInfo::getEconomyUploadCost() +{ + // Update L$ and ownership credit information + // since it probably changed on the server + if (getAssetType() == LLAssetType::AT_TEXTURE || + getAssetType() == LLAssetType::AT_SOUND || + getAssetType() == LLAssetType::AT_ANIMATION || + getAssetType() == LLAssetType::AT_MESH) + { + return LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); + } + + return 0; +} + + LLUUID LLResourceUploadInfo::finishUpload(LLSD &result) { if (getFolderId().isNull()) @@ -660,7 +676,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti return; } - //self.yield(); + llcoro::yield(); if (uploadInfo->showUploadDialog()) { @@ -686,43 +702,38 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti std::string uploader = result["uploader"].asString(); - result = httpAdapter->postFileAndYield(httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); - httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status) + bool success = false; + if (!uploader.empty() && uploadInfo->getAssetId().notNull()) { - HandleUploadError(status, result, uploadInfo); - if (uploadInfo->showUploadDialog()) - LLUploadDialog::modalUploadFinished(); - return; - } + result = httpAdapter->postFileAndYield(httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); + httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - S32 uploadPrice = 0; + if (!status) + { + HandleUploadError(status, result, uploadInfo); + if (uploadInfo->showUploadDialog()) + LLUploadDialog::modalUploadFinished(); + return; + } - // Update L$ and ownership credit information - // since it probably changed on the server - if (uploadInfo->getAssetType() == LLAssetType::AT_TEXTURE || - uploadInfo->getAssetType() == LLAssetType::AT_SOUND || - uploadInfo->getAssetType() == LLAssetType::AT_ANIMATION || - uploadInfo->getAssetType() == LLAssetType::AT_MESH) - { - uploadPrice = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); - } + S32 uploadPrice = uploadInfo->getEconomyUploadCost(); - bool success = false; + if (uploadPrice > 0) + { + // this upload costed us L$, update our balance + // and display something saying that it cost L$ + LLStatusBar::sendMoneyBalanceRequest(); - if (uploadPrice > 0) + LLSD args; + args["AMOUNT"] = llformat("%d", uploadPrice); + LLNotificationsUtil::add("UploadPayment", args); + } + } + else { - // this upload costed us L$, update our balance - // and display something saying that it cost L$ - LLStatusBar::sendMoneyBalanceRequest(); - - LLSD args; - args["AMOUNT"] = llformat("%d", uploadPrice); - LLNotificationsUtil::add("UploadPayment", args); + LL_WARNS() << "No upload url provided. Nothing uploaded, responding with previous result." << LL_ENDL; } - LLUUID serverInventoryItem = uploadInfo->finishUpload(result); if (uploadInfo->showInventoryPanel()) -- cgit v1.2.3 From a035d78e25551a77a7a1513c3cee8b9dca117540 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 23 Jul 2015 11:28:21 -0700 Subject: AR Reports now use coroutines. --- indra/newview/llviewerassetupload.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 83d3449b96..4ef398d314 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -97,6 +97,23 @@ LLResourceUploadInfo::LLResourceUploadInfo(std::string name, mTransactionId.generate(); } +LLResourceUploadInfo::LLResourceUploadInfo(LLAssetID assetId, LLAssetType::EType assetType, std::string name) : + mAssetId(assetId), + mAssetType(assetType), + mName(name), + mDescription(), + mCompressionInfo(0), + mDestinationFolderType(LLFolderType::FT_NONE), + mInventoryType(LLInventoryType::IT_NONE), + mNextOwnerPerms(0), + mGroupPerms(0), + mEveryonePerms(0), + mExpectedUploadCost(0), + mTransactionId(), + mFolderId(LLUUID::null), + mItemId(LLUUID::null) +{ +} LLSD LLResourceUploadInfo::prepareUpload() { @@ -320,8 +337,6 @@ LLNewFileResourceUploadInfo::LLNewFileResourceUploadInfo( { } - - LLSD LLNewFileResourceUploadInfo::prepareUpload() { if (getAssetId().isNull()) @@ -471,7 +486,6 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType: { setItemId(itemId); setAssetType(assetType); - } LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLPointer image, invnUploadFinish_f finish) : @@ -522,7 +536,6 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemI setAssetType(assetType); } - LLSD LLBufferedAssetUploadInfo::prepareUpload() { if (getAssetId().isNull()) @@ -626,7 +639,6 @@ LLScriptAssetUpload::LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, TargetTyp { } - LLSD LLScriptAssetUpload::generatePostBody() { LLSD body; -- cgit v1.2.3 From b57b0d97bb2fb880084cbcca1b915f8e67b442a5 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 28 Jul 2015 15:29:51 -0700 Subject: Named pools of coroutines. --- indra/newview/llviewerassetupload.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 4ef398d314..6c6d3a4f33 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -666,7 +666,8 @@ LLUUID LLViewerAssetUpload::EnqueueInventoryUpload(const std::string &url, const { std::string procName("LLViewerAssetUpload::AssetInventoryUploadCoproc("); - LLUUID queueId = LLCoprocedureManager::getInstance()->enqueueCoprocedure(procName + LLAssetType::lookup(uploadInfo->getAssetType()) + ")", + LLUUID queueId = LLCoprocedureManager::getInstance()->enqueueCoprocedure("Upload", + procName + LLAssetType::lookup(uploadInfo->getAssetType()) + ")", boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo)); return queueId; -- cgit v1.2.3 From 75c6549fde060e974c90636685962ee373f94202 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 18 Sep 2015 11:39:22 -0700 Subject: Set consistent terminology for yield/wait -> suspend for coroutines. --- indra/newview/llviewerassetupload.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 6c6d3a4f33..e8f9809ee7 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -689,7 +689,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti return; } - llcoro::yield(); + llcoro::suspend(); if (uploadInfo->showUploadDialog()) { @@ -700,7 +700,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti LLSD body = uploadInfo->generatePostBody(); - result = httpAdapter->postAndYield(httpRequest, url, body); + result = httpAdapter->postAndSuspend(httpRequest, url, body); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -718,7 +718,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti bool success = false; if (!uploader.empty() && uploadInfo->getAssetId().notNull()) { - result = httpAdapter->postFileAndYield(httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); + result = httpAdapter->postFileAndSuspend(httpRequest, uploader, uploadInfo->getAssetId(), uploadInfo->getAssetType()); httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); -- cgit v1.2.3 From cf835a80cd2bb5d02cc03034009919e0d9eb73b6 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 18 Sep 2015 16:36:49 -0700 Subject: Pref instance() over getInstance() --- indra/newview/llviewerassetupload.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index e8f9809ee7..ea3d81c2f6 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -174,7 +174,7 @@ S32 LLResourceUploadInfo::getEconomyUploadCost() getAssetType() == LLAssetType::AT_ANIMATION || getAssetType() == LLAssetType::AT_MESH) { - return LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); + return LLGlobalEconomy::Singleton::instance().getPriceUpload(); } return 0; @@ -666,7 +666,7 @@ LLUUID LLViewerAssetUpload::EnqueueInventoryUpload(const std::string &url, const { std::string procName("LLViewerAssetUpload::AssetInventoryUploadCoproc("); - LLUUID queueId = LLCoprocedureManager::getInstance()->enqueueCoprocedure("Upload", + LLUUID queueId = LLCoprocedureManager::instance().enqueueCoprocedure("Upload", procName + LLAssetType::lookup(uploadInfo->getAssetType()) + ")", boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo)); -- cgit v1.2.3 From ed7963bad14abd628fa60d0d5baf357f1858c48c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 9 Oct 2015 14:46:01 -0700 Subject: SL-230: Azumarill viewer was incorrectly swallowing upload errors returned from the server. Correctly report errors and use upload cost provided by server. --- indra/newview/llviewerassetupload.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/llviewerassetupload.cpp') diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index ea3d81c2f6..f0dafec240 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -722,7 +722,9 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - if (!status) + std::string ulstate = result["state"].asString(); + + if ((!status) || (ulstate != "complete")) { HandleUploadError(status, result, uploadInfo); if (uploadInfo->showUploadDialog()) @@ -730,7 +732,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti return; } - S32 uploadPrice = uploadInfo->getEconomyUploadCost(); + S32 uploadPrice = result["upload_price"].asInteger();//uploadInfo->getEconomyUploadCost(); if (uploadPrice > 0) { -- cgit v1.2.3