diff options
Diffstat (limited to 'indra/newview/llviewerassetupload.cpp')
-rw-r--r-- | indra/newview/llviewerassetupload.cpp | 212 |
1 files changed, 117 insertions, 95 deletions
diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index e2e321af0d..7ef2c8d697 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -81,9 +81,9 @@ LLResourceUploadInfo::LLResourceUploadInfo(LLTransactionID transactId, { } -LLResourceUploadInfo::LLResourceUploadInfo(std::string name, - std::string description, S32 compressionInfo, - LLFolderType::EType destinationType, LLInventoryType::EType inventoryType, +LLResourceUploadInfo::LLResourceUploadInfo(std::string name, + std::string description, S32 compressionInfo, + LLFolderType::EType destinationType, LLInventoryType::EType inventoryType, U32 nextOWnerPerms, U32 groupPerms, U32 everyonePerms, S32 expectedCost, bool showInventory) : mName(name), mDescription(description), @@ -100,7 +100,7 @@ LLResourceUploadInfo::LLResourceUploadInfo(std::string name, mFolderId(LLUUID::null), mItemId(LLUUID::null), mAssetId(LLAssetID::null) -{ +{ mTransactionId.generate(); } @@ -156,9 +156,9 @@ LLSD LLResourceUploadInfo::generatePostBody() body["next_owner_mask"] = LLSD::Integer(mNextOwnerPerms); body["group_mask"] = LLSD::Integer(mGroupPerms); body["everyone_mask"] = LLSD::Integer(mEveryonePerms); + body["expected_upload_cost"] = mExpectedUploadCost; return body; - } void LLResourceUploadInfo::logPreparedUpload() @@ -226,7 +226,7 @@ LLUUID LLResourceUploadInfo::finishUpload(LLSD &result) LL_INFOS() << "inventory_item_flags " << flagsInventoryItem << LL_ENDL; } } - S32 creationDate = time_corrected(); + S32 creationDate = (S32)time_corrected(); LLUUID serverInventoryItem = result["new_inventory_item"].asUUID(); LLUUID serverAssetId = result["new_asset"].asUUID(); @@ -299,10 +299,18 @@ void LLResourceUploadInfo::assignDefaults() mDescription = "(No Description)"; } + if (mAssetType == LLAssetType::AT_GLTF || + mAssetType == LLAssetType::AT_GLTF_BIN) + { + mFolderId = LLUUID::null; + } + else + { mFolderId = gInventory.findUserDefinedCategoryUUIDForType( (mDestinationFolderType == LLFolderType::FT_NONE) ? (LLFolderType::EType)mAssetType : mDestinationFolderType); } +} std::string LLResourceUploadInfo::getDisplayName() const { @@ -311,39 +319,39 @@ std::string LLResourceUploadInfo::getDisplayName() const bool LLResourceUploadInfo::findAssetTypeOfExtension(const std::string& exten, LLAssetType::EType& asset_type) { - U32 codec; - return findAssetTypeAndCodecOfExtension(exten, asset_type, codec, false); + U32 codec; + return findAssetTypeAndCodecOfExtension(exten, asset_type, codec, false); } // static bool LLResourceUploadInfo::findAssetTypeAndCodecOfExtension(const std::string& exten, LLAssetType::EType& asset_type, U32& codec, bool bulk_upload) { - bool succ = false; - std::string exten_lc(exten); - LLStringUtil::toLower(exten_lc); - codec = LLImageBase::getCodecFromExtension(exten_lc); - if (codec != IMG_CODEC_INVALID) - { - asset_type = LLAssetType::AT_TEXTURE; - succ = true; - } - else if (exten_lc == "wav") - { - asset_type = LLAssetType::AT_SOUND; - succ = true; - } - else if (exten_lc == "anim") - { - asset_type = LLAssetType::AT_ANIMATION; - succ = true; - } - else if (!bulk_upload && (exten_lc == "bvh")) - { - asset_type = LLAssetType::AT_ANIMATION; - succ = true; - } - - return succ; + bool succ = false; + std::string exten_lc(exten); + LLStringUtil::toLower(exten_lc); + codec = LLImageBase::getCodecFromExtension(exten_lc); + if (codec != IMG_CODEC_INVALID) + { + asset_type = LLAssetType::AT_TEXTURE; + succ = true; + } + else if (exten_lc == "wav") + { + asset_type = LLAssetType::AT_SOUND; + succ = true; + } + else if (exten_lc == "anim") + { + asset_type = LLAssetType::AT_ANIMATION; + succ = true; + } + else if (!bulk_upload && (exten_lc == "bvh")) + { + asset_type = LLAssetType::AT_ANIMATION; + succ = true; + } + + return succ; } //========================================================================= @@ -362,7 +370,8 @@ LLNewFileResourceUploadInfo::LLNewFileResourceUploadInfo( LLResourceUploadInfo(name, description, compressionInfo, destinationType, inventoryType, nextOWnerPerms, groupPerms, everyonePerms, expectedCost, show_inventory), - mFileName(fileName) + mFileName(fileName), + mMaxImageSize(LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT) { } @@ -385,8 +394,8 @@ LLSD LLNewFileResourceUploadInfo::exportTempFile() std::string exten = gDirUtilp->getExtension(getFileName()); LLAssetType::EType assetType = LLAssetType::AT_NONE; - U32 codec = IMG_CODEC_INVALID; - bool found_type = findAssetTypeAndCodecOfExtension(exten, assetType, codec); + U32 codec = IMG_CODEC_INVALID; + bool found_type = findAssetTypeAndCodecOfExtension(exten, assetType, codec); std::string errorMessage; std::string errorLabel; @@ -409,15 +418,15 @@ LLSD LLNewFileResourceUploadInfo::exportTempFile() // Unknown extension errorMessage = llformat(LLTrans::getString("UnknownFileExtension").c_str(), exten.c_str()); errorLabel = "ErrorMessage"; - error = TRUE;; + error = true;; } else if (assetType == LLAssetType::AT_TEXTURE) { // It's an image file, the upload procedure is the same for all - if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec)) + if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec, mMaxImageSize)) { errorMessage = llformat("Problem with file %s:\n\n%s\n", - getFileName().c_str(), LLImage::getLastError().c_str()); + getFileName().c_str(), LLImage::getLastThreadError().c_str()); errorLabel = "ProblemWithFile"; error = true; } @@ -455,60 +464,65 @@ LLSD LLNewFileResourceUploadInfo::exportTempFile() } else if (exten == "anim") { - // Default unless everything succeeds - errorLabel = "ProblemWithFile"; - error = true; + // Default unless everything succeeds + errorLabel = "ProblemWithFile"; + error = true; // read from getFileName() - LLAPRFile infile; - infile.open(getFileName(),LL_APR_RB); - if (!infile.getFileHandle()) - { - LL_WARNS() << "Couldn't open file for reading: " << getFileName() << LL_ENDL; - errorMessage = llformat("Failed to open animation file %s\n", getFileName().c_str()); - } - else - { - S32 size = LLAPRFile::size(getFileName()); - U8* buffer = new U8[size]; - S32 size_read = infile.read(buffer,size); - if (size_read != size) - { - errorMessage = llformat("Failed to read animation file %s: wanted %d bytes, got %d\n", getFileName().c_str(), size, size_read); - } - else - { - LLDataPackerBinaryBuffer dp(buffer, size); - LLKeyframeMotion *motionp = new LLKeyframeMotion(getAssetId()); - motionp->setCharacter(gAgentAvatarp); - if (motionp->deserialize(dp, getAssetId(), false)) - { - // write to temp file - bool succ = motionp->dumpToFile(filename); - if (succ) - { - assetType = LLAssetType::AT_ANIMATION; - errorLabel = ""; - error = false; - } - else - { - errorMessage = "Failed saving temporary animation file"; - } - } - else - { - errorMessage = "Failed reading animation file"; - } - } - } + LLAPRFile infile; + infile.open(getFileName(),LL_APR_RB); + if (!infile.getFileHandle()) + { + LL_WARNS() << "Couldn't open file for reading: " << getFileName() << LL_ENDL; + errorMessage = llformat("Failed to open animation file %s\n", getFileName().c_str()); + } + else + { + S32 size = LLAPRFile::size(getFileName()); + U8* buffer = new(std::nothrow) U8[size]; + if (!buffer) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Bad memory allocation for buffer, size: " << size << LL_ENDL; + } + S32 size_read = infile.read(buffer,size); + if (size_read != size) + { + errorMessage = llformat("Failed to read animation file %s: wanted %d bytes, got %d\n", getFileName().c_str(), size, size_read); + } + else + { + LLDataPackerBinaryBuffer dp(buffer, size); + LLKeyframeMotion *motionp = new LLKeyframeMotion(getAssetId()); + motionp->setCharacter(gAgentAvatarp); + if (motionp->deserialize(dp, getAssetId(), false)) + { + // write to temp file + bool succ = motionp->dumpToFile(filename); + if (succ) + { + assetType = LLAssetType::AT_ANIMATION; + errorLabel = ""; + error = false; + } + else + { + errorMessage = "Failed saving temporary animation file"; + } + } + else + { + errorMessage = "Failed reading animation file"; + } + } + } } else { // Unknown extension errorMessage = llformat(LLTrans::getString("UnknownFileExtension").c_str(), exten.c_str()); errorLabel = "ErrorMessage"; - error = TRUE;; + error = true;; } if (error) @@ -596,10 +610,10 @@ LLSD LLNewBufferedResourceUploadInfo::exportTempFile() { std::string filename = gDirUtilp->getTempFilename(); - // copy buffer to the cache for upload + // copy buffer to the cache for upload LLFileSystem file(getAssetId(), getAssetType(), LLFileSystem::APPEND); - file.write((U8*) mBuffer.c_str(), mBuffer.size()); - + file.write((U8*) mBuffer.c_str(), static_cast<S32>(mBuffer.size())); + return LLSD(); } @@ -654,6 +668,8 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLPointer<LL { setItemId(itemId); + LLImageDataSharedLock lock(image); + EImageCodec codec = static_cast<EImageCodec>(image->getCodec()); switch (codec) @@ -698,7 +714,7 @@ LLSD LLBufferedAssetUploadInfo::prepareUpload() LLFileSystem file(getAssetId(), getAssetType(), LLFileSystem::APPEND); - S32 size = mContents.length() + 1; + S32 size = static_cast<S32>(mContents.length()) + 1; file.write((U8*)mContents.c_str(), size); mStoredToCache = true; @@ -828,8 +844,8 @@ LLSD LLScriptAssetUpload::generatePostBody() LLUUID LLViewerAssetUpload::EnqueueInventoryUpload(const std::string &url, const LLResourceUploadInfo::ptr_t &uploadInfo) { std::string procName("LLViewerAssetUpload::AssetInventoryUploadCoproc("); - - LLUUID queueId = LLCoprocedureManager::instance().enqueueCoprocedure("Upload", + + LLUUID queueId = LLCoprocedureManager::instance().enqueueCoprocedure("Upload", procName + LLAssetType::lookup(uploadInfo->getAssetType()) + ")", boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo)); @@ -838,7 +854,7 @@ LLUUID LLViewerAssetUpload::EnqueueInventoryUpload(const std::string &url, const //========================================================================= /*static*/ -void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, +void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, std::string url, LLResourceUploadInfo::ptr_t uploadInfo) { LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); @@ -930,7 +946,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti // Show the preview panel for textures and sounds to let // user know that the image (or snapshot) arrived intact. - LLInventoryPanel* panel = LLInventoryPanel::getActiveInventoryPanel(FALSE); + LLInventoryPanel* panel = LLInventoryPanel::getActiveInventoryPanel(false); LLInventoryPanel::openInventoryPanelAndSetSelection(true, serverInventoryItem, false, false, !panel); // restore keyboard focus @@ -968,6 +984,7 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res label = result["label"].asString(); } + LLFloaterSnapshot* floater_snapshot = LLFloaterSnapshot::findInstance(); if (result.has("message")) { reason = result["message"].asString(); @@ -978,6 +995,12 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res { case 404: reason = LLTrans::getString("AssetUploadServerUnreacheble"); + if (floater_snapshot + && floater_snapshot->isWaitingState() + && uploadInfo->getAssetType() == LLAssetType::AT_IMAGE_JPEG) + { + label = "CannotUploadSnapshotEmailTooBig"; + } break; case 499: reason = LLTrans::getString("AssetUploadServerDifficulties"); @@ -1014,7 +1037,6 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res // Todo: move these floater specific actions into proper callbacks // Let the Snapshot floater know we have failed uploading. - LLFloaterSnapshot* floater_snapshot = LLFloaterSnapshot::findInstance(); if (floater_snapshot && floater_snapshot->isWaitingState()) { if (uploadInfo->getAssetType() == LLAssetType::AT_IMAGE_JPEG) |