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/llviewermenufile.cpp | 386 ++++++++++++++++--------------------- 1 file changed, 167 insertions(+), 219 deletions(-) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index f8e50ba463..7bcf241d5e 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -62,6 +62,8 @@ #include "lluploaddialog.h" #include "lltrans.h" #include "llfloaterbuycurrency.h" +#include "llcoproceduremanager.h" +#include "llviewerassetupload.h" // linden libraries #include "llassetuploadresponders.h" @@ -621,6 +623,7 @@ void handle_compress_image(void*) } } + LLUUID upload_new_resource( const std::string& src_filename, std::string name, @@ -704,123 +707,6 @@ LLUUID upload_new_resource( return LLUUID(); } } - else if(exten == "tmp") - { - // This is a generic .lin resource file - asset_type = LLAssetType::AT_OBJECT; - LLFILE* in = LLFile::fopen(src_filename, "rb"); /* Flawfinder: ignore */ - if (in) - { - // read in the file header - char buf[16384]; /* Flawfinder: ignore */ - size_t readbytes; - S32 version; - if (fscanf(in, "LindenResource\nversion %d\n", &version)) - { - if (2 == version) - { - // *NOTE: This buffer size is hard coded into scanf() below. - char label[MAX_STRING]; /* Flawfinder: ignore */ - char value[MAX_STRING]; /* Flawfinder: ignore */ - S32 tokens_read; - while (fgets(buf, 1024, in)) - { - label[0] = '\0'; - value[0] = '\0'; - tokens_read = sscanf( /* Flawfinder: ignore */ - buf, - "%254s %254s\n", - label, value); - - LL_INFOS() << "got: " << label << " = " << value - << LL_ENDL; - - if (EOF == tokens_read) - { - fclose(in); - error_message = llformat("corrupt resource file: %s", src_filename.c_str()); - args["FILE"] = src_filename; - upload_error(error_message, "CorruptResourceFile", filename, args); - return LLUUID(); - } - - if (2 == tokens_read) - { - if (! strcmp("type", label)) - { - asset_type = (LLAssetType::EType)(atoi(value)); - } - } - else - { - if (! strcmp("_DATA_", label)) - { - // below is the data section - break; - } - } - // other values are currently discarded - } - - } - else - { - fclose(in); - error_message = llformat("unknown linden resource file version in file: %s", src_filename.c_str()); - args["FILE"] = src_filename; - upload_error(error_message, "UnknownResourceFileVersion", filename, args); - return LLUUID(); - } - } - else - { - // this is an original binary formatted .lin file - // start over at the beginning of the file - fseek(in, 0, SEEK_SET); - - const S32 MAX_ASSET_DESCRIPTION_LENGTH = 256; - const S32 MAX_ASSET_NAME_LENGTH = 64; - S32 header_size = 34 + MAX_ASSET_DESCRIPTION_LENGTH + MAX_ASSET_NAME_LENGTH; - S16 type_num; - - // read in and throw out most of the header except for the type - if (fread(buf, header_size, 1, in) != 1) - { - LL_WARNS() << "Short read" << LL_ENDL; - } - memcpy(&type_num, buf + 16, sizeof(S16)); /* Flawfinder: ignore */ - asset_type = (LLAssetType::EType)type_num; - } - - // copy the file's data segment into another file for uploading - LLFILE* out = LLFile::fopen(filename, "wb"); /* Flawfinder: ignore */ - if (out) - { - while((readbytes = fread(buf, 1, 16384, in))) /* Flawfinder: ignore */ - { - if (fwrite(buf, 1, readbytes, out) != readbytes) - { - LL_WARNS() << "Short write" << LL_ENDL; - } - } - fclose(out); - } - else - { - fclose(in); - error_message = llformat( "Unable to create output file: %s", filename.c_str()); - args["FILE"] = filename; - upload_error(error_message, "UnableToCreateOutputFile", filename, args); - return LLUUID(); - } - - fclose(in); - } - else - { - LL_INFOS() << "Couldn't open .lin file " << src_filename << LL_ENDL; - } - } else if (exten == "bvh") { error_message = llformat("We do not currently support bulk upload of animation files\n"); @@ -876,6 +762,17 @@ LLUUID upload_new_resource( { t_disp_name = src_filename; } + +#if 1 + NewResourceUploadInfo::ptr_t uploadInfo(new NewResourceUploadInfo( + name, desc, compression_info, + destination_folder_type, inv_type, + next_owner_perms, group_perms, everyone_perms, + display_name, expected_upload_cost)); + + upload_new_resource(tid, asset_type, uploadInfo, + callback, userdata); +#else upload_new_resource( tid, asset_type, @@ -891,6 +788,7 @@ LLUUID upload_new_resource( callback, expected_upload_cost, userdata); +#endif } else { @@ -1035,6 +933,7 @@ void upload_done_callback( } } +#if 0 static LLAssetID upload_new_resource_prep( const LLTransactionID& tid, LLAssetType::EType asset_type, @@ -1056,7 +955,9 @@ static LLAssetID upload_new_resource_prep( return uuid; } +#endif +#if 0 LLSD generate_new_resource_upload_capability_body( LLAssetType::EType asset_type, const std::string& name, @@ -1084,140 +985,81 @@ LLSD generate_new_resource_upload_capability_body( return body; } +#endif void upload_new_resource( - const LLTransactionID &tid, - LLAssetType::EType asset_type, - std::string name, - std::string desc, - S32 compression_info, - LLFolderType::EType destination_folder_type, - LLInventoryType::EType inv_type, - U32 next_owner_perms, - U32 group_perms, - U32 everyone_perms, - const std::string& display_name, - LLAssetStorage::LLStoreAssetCallback callback, - S32 expected_upload_cost, - void *userdata) + const LLTransactionID &tid, + LLAssetType::EType assetType, + NewResourceUploadInfo::ptr_t &uploadInfo, + LLAssetStorage::LLStoreAssetCallback callback, + void *userdata) { if(gDisconnected) { return ; } - - LLAssetID uuid = - upload_new_resource_prep( - tid, - asset_type, - inv_type, - name, - display_name, - desc); - - if( LLAssetType::AT_SOUND == asset_type ) - { - add(LLStatViewer::UPLOAD_SOUND, 1); - } - else - if( LLAssetType::AT_TEXTURE == asset_type ) - { - add(LLStatViewer::UPLOAD_TEXTURE, 1); - } - else - if( LLAssetType::AT_ANIMATION == asset_type) - { - add(LLStatViewer::ANIMATION_UPLOADS, 1); - } - if(LLInventoryType::IT_NONE == inv_type) - { - inv_type = LLInventoryType::defaultForAssetType(asset_type); - } - LLStringUtil::stripNonprintable(name); - LLStringUtil::stripNonprintable(desc); - if(name.empty()) - { - name = "(No Name)"; - } - if(desc.empty()) - { - desc = "(No Description)"; - } - - // At this point, we're ready for the upload. - std::string upload_message = "Uploading...\n\n"; - upload_message.append(display_name); - LLUploadDialog::modalUploadDialog(upload_message); + uploadInfo->setAssetType(assetType); + uploadInfo->setTransactionId(tid); - LL_INFOS() << "*** Uploading: " << LL_ENDL; - LL_INFOS() << "Type: " << LLAssetType::lookup(asset_type) << LL_ENDL; - LL_INFOS() << "UUID: " << uuid << LL_ENDL; - LL_INFOS() << "Name: " << name << LL_ENDL; - LL_INFOS() << "Desc: " << desc << LL_ENDL; - LL_INFOS() << "Expected Upload Cost: " << expected_upload_cost << LL_ENDL; - LL_DEBUGS() << "Folder: " << gInventory.findCategoryUUIDForType((destination_folder_type == LLFolderType::FT_NONE) ? LLFolderType::assetTypeToFolderType(asset_type) : destination_folder_type) << LL_ENDL; - LL_DEBUGS() << "Asset Type: " << LLAssetType::lookup(asset_type) << LL_ENDL; - std::string url = gAgent.getRegion()->getCapability( - "NewFileAgentInventory"); + std::string url = gAgent.getRegion()->getCapability("NewFileAgentInventory"); if ( !url.empty() ) { - LL_INFOS() << "New Agent Inventory via capability" << LL_ENDL; - - LLSD body; - body = generate_new_resource_upload_capability_body( - asset_type, - name, - desc, - destination_folder_type, - inv_type, - next_owner_perms, - group_perms, - everyone_perms); - - LLHTTPClient::post( - url, - body, - new LLNewAgentInventoryResponder( - body, - uuid, - asset_type)); + LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, _3, url, uploadInfo); + + LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); +// LL_INFOS() << "New Agent Inventory via capability" << LL_ENDL; +// uploadInfo->prepareUpload(); +// uploadInfo->logPreparedUpload(); +// +// LLSD body = uploadInfo->generatePostBody(); +// +// LLHTTPClient::post( +// url, +// body, +// new LLNewAgentInventoryResponder( +// body, +// uploadInfo->getAssetId(), +// assetType)); } else { + uploadInfo->prepareUpload(); + uploadInfo->logPreparedUpload(); + LL_INFOS() << "NewAgentInventory capability not found, new agent inventory via asset system." << LL_ENDL; // check for adequate funds // TODO: do this check on the sim - if (LLAssetType::AT_SOUND == asset_type || - LLAssetType::AT_TEXTURE == asset_type || - LLAssetType::AT_ANIMATION == asset_type) + if (LLAssetType::AT_SOUND == assetType || + LLAssetType::AT_TEXTURE == assetType || + LLAssetType::AT_ANIMATION == assetType) { S32 balance = gStatusBar->getBalance(); - if (balance < expected_upload_cost) + if (balance < uploadInfo->getExpectedUploadCost()) { // insufficient funds, bail on this upload LLStringUtil::format_map_t args; - args["NAME"] = name; - args["AMOUNT"] = llformat("%d", expected_upload_cost); - LLBuyCurrencyHTML::openCurrencyFloater( LLTrans::getString("UploadingCosts", args), expected_upload_cost ); + args["NAME"] = uploadInfo->getName(); + args["AMOUNT"] = llformat("%d", uploadInfo->getExpectedUploadCost()); + LLBuyCurrencyHTML::openCurrencyFloater(LLTrans::getString("UploadingCosts", args), uploadInfo->getExpectedUploadCost()); return; } } LLResourceData* data = new LLResourceData; data->mAssetInfo.mTransactionID = tid; - data->mAssetInfo.mUuid = uuid; - data->mAssetInfo.mType = asset_type; + data->mAssetInfo.mUuid = uploadInfo->getAssetId(); + data->mAssetInfo.mType = assetType; data->mAssetInfo.mCreatorID = gAgentID; - data->mInventoryType = inv_type; - data->mNextOwnerPerm = next_owner_perms; - data->mExpectedUploadCost = expected_upload_cost; + data->mInventoryType = uploadInfo->getInventoryType(); + data->mNextOwnerPerm = uploadInfo->getNextOwnerPerms(); + data->mExpectedUploadCost = uploadInfo->getExpectedUploadCost(); data->mUserData = userdata; - data->mAssetInfo.setName(name); - data->mAssetInfo.setDescription(desc); - data->mPreferredLocation = destination_folder_type; + data->mAssetInfo.setName(uploadInfo->getName()); + data->mAssetInfo.setDescription(uploadInfo->getDescription()); + data->mPreferredLocation = uploadInfo->getDestinationFolderType(); LLAssetStorage::LLStoreAssetCallback asset_callback = &upload_done_callback; if (callback) @@ -1233,6 +1075,7 @@ void upload_new_resource( } } +#if 0 LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid) { if ( gDisconnected ) @@ -1292,6 +1135,7 @@ void assign_defaults_and_show_upload_message( upload_message.append(display_name); LLUploadDialog::modalUploadDialog(upload_message); } +#endif void init_menu_file() @@ -1315,3 +1159,107 @@ void init_menu_file() // "File.SaveTexture" moved to llpanelmaininventory so that it can be properly handled. } + +LLAssetID NewResourceUploadInfo::prepareUpload() +{ + LLAssetID uuid = generateNewAssetId(); + + incrementUploadStats(); + assignDefaults(); + + return uuid; +} + +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; +} + +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); + +} + -- 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/llviewermenufile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 7bcf241d5e..c9c670aaff 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -1007,7 +1007,7 @@ void upload_new_resource( if ( !url.empty() ) { - LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, _3, url, uploadInfo); + LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo); LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); // LL_INFOS() << "New Agent Inventory via capability" << LL_ENDL; -- 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/llviewermenufile.cpp | 267 ++++++++++++++----------------------- 1 file changed, 98 insertions(+), 169 deletions(-) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 7bcf241d5e..4772dd144b 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -85,8 +85,9 @@ class LLFileEnableUpload : public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = gStatusBar && LLGlobalEconomy::Singleton::getInstance() && (gStatusBar->getBalance() >= LLGlobalEconomy::Singleton::getInstance()->getPriceUpload()); - return new_value; + return true; +// bool new_value = gStatusBar && LLGlobalEconomy::Singleton::getInstance() && (gStatusBar->getBalance() >= LLGlobalEconomy::Singleton::getInstance()->getPriceUpload()); +// return new_value; } }; @@ -757,38 +758,15 @@ LLUUID upload_new_resource( if (!error) { - std::string t_disp_name = display_name; - if (t_disp_name.empty()) - { - t_disp_name = src_filename; - } - -#if 1 NewResourceUploadInfo::ptr_t uploadInfo(new NewResourceUploadInfo( + tid, asset_type, name, desc, compression_info, destination_folder_type, inv_type, next_owner_perms, group_perms, everyone_perms, - display_name, expected_upload_cost)); + expected_upload_cost)); - upload_new_resource(tid, asset_type, uploadInfo, + upload_new_resource(uploadInfo, callback, userdata); -#else - upload_new_resource( - tid, - asset_type, - name, - desc, - compression_info, // tid - destination_folder_type, - inv_type, - next_owner_perms, - group_perms, - everyone_perms, - display_name, - callback, - expected_upload_cost, - userdata); -#endif } else { @@ -933,63 +911,7 @@ void upload_done_callback( } } -#if 0 -static LLAssetID upload_new_resource_prep( - const LLTransactionID& tid, - LLAssetType::EType asset_type, - LLInventoryType::EType& inventory_type, - std::string& name, - const std::string& display_name, - std::string& description) -{ - LLAssetID uuid = generate_asset_id_for_new_upload(tid); - - increase_new_upload_stats(asset_type); - - assign_defaults_and_show_upload_message( - asset_type, - inventory_type, - name, - display_name, - description); - - return uuid; -} -#endif - -#if 0 -LLSD generate_new_resource_upload_capability_body( - LLAssetType::EType asset_type, - const std::string& name, - const std::string& desc, - LLFolderType::EType destination_folder_type, - LLInventoryType::EType inv_type, - U32 next_owner_perms, - U32 group_perms, - U32 everyone_perms) -{ - LLSD body; - - body["folder_id"] = gInventory.findCategoryUUIDForType( - (destination_folder_type == LLFolderType::FT_NONE) ? - (LLFolderType::EType) asset_type : - destination_folder_type); - - body["asset_type"] = LLAssetType::lookup(asset_type); - body["inventory_type"] = LLInventoryType::lookup(inv_type); - body["name"] = name; - body["description"] = desc; - body["next_owner_mask"] = LLSD::Integer(next_owner_perms); - body["group_mask"] = LLSD::Integer(group_perms); - body["everyone_mask"] = LLSD::Integer(everyone_perms); - - return body; -} -#endif - void upload_new_resource( - const LLTransactionID &tid, - LLAssetType::EType assetType, NewResourceUploadInfo::ptr_t &uploadInfo, LLAssetStorage::LLStoreAssetCallback callback, void *userdata) @@ -999,8 +921,8 @@ void upload_new_resource( return ; } - uploadInfo->setAssetType(assetType); - uploadInfo->setTransactionId(tid); +// uploadInfo->setAssetType(assetType); +// uploadInfo->setTransactionId(tid); std::string url = gAgent.getRegion()->getCapability("NewFileAgentInventory"); @@ -1010,19 +932,6 @@ void upload_new_resource( LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, _3, url, uploadInfo); LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); -// LL_INFOS() << "New Agent Inventory via capability" << LL_ENDL; -// uploadInfo->prepareUpload(); -// uploadInfo->logPreparedUpload(); -// -// LLSD body = uploadInfo->generatePostBody(); -// -// LLHTTPClient::post( -// url, -// body, -// new LLNewAgentInventoryResponder( -// body, -// uploadInfo->getAssetId(), -// assetType)); } else { @@ -1032,9 +941,9 @@ void upload_new_resource( LL_INFOS() << "NewAgentInventory capability not found, new agent inventory via asset system." << LL_ENDL; // check for adequate funds // TODO: do this check on the sim - if (LLAssetType::AT_SOUND == assetType || - LLAssetType::AT_TEXTURE == assetType || - LLAssetType::AT_ANIMATION == assetType) + if (LLAssetType::AT_SOUND == uploadInfo->getAssetType() || + LLAssetType::AT_TEXTURE == uploadInfo->getAssetType() || + LLAssetType::AT_ANIMATION == uploadInfo->getAssetType()) { S32 balance = gStatusBar->getBalance(); if (balance < uploadInfo->getExpectedUploadCost()) @@ -1049,9 +958,9 @@ void upload_new_resource( } LLResourceData* data = new LLResourceData; - data->mAssetInfo.mTransactionID = tid; + data->mAssetInfo.mTransactionID = uploadInfo->getTransactionId(); data->mAssetInfo.mUuid = uploadInfo->getAssetId(); - data->mAssetInfo.mType = assetType; + data->mAssetInfo.mType = uploadInfo->getAssetType(); data->mAssetInfo.mCreatorID = gAgentID; data->mInventoryType = uploadInfo->getInventoryType(); data->mNextOwnerPerm = uploadInfo->getNextOwnerPerms(); @@ -1075,68 +984,6 @@ void upload_new_resource( } } -#if 0 -LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid) -{ - if ( gDisconnected ) - { - LLAssetID rv; - - rv.setNull(); - return rv; - } - - LLAssetID uuid = tid.makeAssetID(gAgent.getSecureSessionID()); - - return uuid; -} - -void increase_new_upload_stats(LLAssetType::EType asset_type) -{ - if ( LLAssetType::AT_SOUND == asset_type ) - { - add(LLStatViewer::UPLOAD_SOUND, 1); - } - else if ( LLAssetType::AT_TEXTURE == asset_type ) - { - add(LLStatViewer::UPLOAD_TEXTURE, 1); - } - else if ( LLAssetType::AT_ANIMATION == asset_type ) - { - add(LLStatViewer::ANIMATION_UPLOADS, 1); - } -} - -void assign_defaults_and_show_upload_message( - LLAssetType::EType asset_type, - LLInventoryType::EType& inventory_type, - std::string& name, - const std::string& display_name, - std::string& description) -{ - if ( LLInventoryType::IT_NONE == inventory_type ) - { - inventory_type = LLInventoryType::defaultForAssetType(asset_type); - } - LLStringUtil::stripNonprintable(name); - LLStringUtil::stripNonprintable(description); - - if ( name.empty() ) - { - name = "(No Name)"; - } - if ( description.empty() ) - { - description = "(No Description)"; - } - - // At this point, we're ready for the upload. - std::string upload_message = "Uploading...\n\n"; - upload_message.append(display_name); - LLUploadDialog::modalUploadDialog(upload_message); -} -#endif - void init_menu_file() { @@ -1160,14 +1007,14 @@ void init_menu_file() // "File.SaveTexture" moved to llpanelmaininventory so that it can be properly handled. } -LLAssetID NewResourceUploadInfo::prepareUpload() +LLSD NewResourceUploadInfo::prepareUpload() { - LLAssetID uuid = generateNewAssetId(); + generateNewAssetId(); incrementUploadStats(); assignDefaults(); - return uuid; + return LLSD().with("success", LLSD::Boolean(true)); } std::string NewResourceUploadInfo::getAssetTypeString() const @@ -1209,6 +1056,84 @@ void NewResourceUploadInfo::logPreparedUpload() "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) @@ -1263,3 +1188,7 @@ void NewResourceUploadInfo::assignDefaults() } +std::string NewResourceUploadInfo::getDisplayName() const +{ + return (mName.empty()) ? mAssetId.asString() : mName; +}; -- cgit v1.2.3 From f00cd0ab9fde7377e859942a66fc47649d854a1c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Jul 2015 14:39:12 -0700 Subject: Crash on second add to coproc queue. --- indra/newview/llviewermenufile.cpp | 203 ++++++++++++++++++++++++++++++++++++- 1 file changed, 202 insertions(+), 1 deletion(-) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index e9eb0e807a..8a95c2a6dd 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -425,6 +425,34 @@ class LLFileUploadBulk : public view_listener_t LLFilePicker& picker = LLFilePicker::instance(); if (picker.getMultipleOpenFiles()) { + std::string filename = picker.getFirstFile(); + S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); + + while (!filename.empty()) + { + std::string name = gDirUtilp->getBaseFileName(filename, true); + + std::string asset_name = name; + LLStringUtil::replaceNonstandardASCII( asset_name, '?' ); + LLStringUtil::replaceChar(asset_name, '|', '?'); + LLStringUtil::stripNonprintable(asset_name); + LLStringUtil::trim(asset_name); + + NewResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( + 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); + + filename = picker.getNextFile(); + } +#if 0 const std::string& filename = picker.getFirstFile(); std::string name = gDirUtilp->getBaseFileName(filename, true); @@ -456,6 +484,7 @@ class LLFileUploadBulk : public view_listener_t // *NOTE: Ew, we don't iterate over the file list here, // we handle the next files in upload_done_callback() +#endif } else { @@ -640,6 +669,18 @@ LLUUID upload_new_resource( S32 expected_upload_cost, void *userdata) { + + NewResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( + src_filename, + name, desc, compression_info, + destination_folder_type, inv_type, + next_owner_perms, group_perms, everyone_perms, + expected_upload_cost)); + upload_new_resource(uploadInfo, callback, userdata); + + return LLUUID::null; + +#if 0 // Generate the temporary UUID. std::string filename = gDirUtilp->getTempFilename(); LLTransactionID tid; @@ -782,6 +823,7 @@ LLUUID upload_new_resource( } return uuid; +#endif } void upload_done_callback( @@ -1009,7 +1051,8 @@ void init_menu_file() LLSD NewResourceUploadInfo::prepareUpload() { - generateNewAssetId(); + if (mAssetId.isNull()) + generateNewAssetId(); incrementUploadStats(); assignDefaults(); @@ -1192,3 +1235,161 @@ 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; + 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(); + +} -- cgit v1.2.3 From d28c7dd7f6a0c2ab2b95169b9d140c5cf4c4c72b Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Jul 2015 15:02:40 -0700 Subject: Forgot to set a Transaction ID --- indra/newview/llviewermenufile.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 8a95c2a6dd..3160b4b3a6 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -1254,6 +1254,7 @@ NewFileResourceUploadInfo::NewFileResourceUploadInfo( mFileName(fileName) { LLTransactionID tid; + tid.generate(); setTransactionId(tid); } -- cgit v1.2.3 From 6ccd8bb6120be90eccb4e4b482132ed4fc3695af Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 2 Jul 2015 16:54:19 -0700 Subject: Temp disable llavatarnamecache integration test for linux --- indra/newview/llviewermenufile.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 3160b4b3a6..20fbfaf71a 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -413,7 +413,6 @@ class LLFileUploadBulk : public view_listener_t } // TODO: - // Iterate over all files // Check extensions for uploadability, cost // Check user balance for entire cost // Charge user entire cost -- 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/llviewermenufile.cpp | 524 ------------------------------------- 1 file changed, 524 deletions(-) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 20fbfaf71a..9c4045fa1e 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -451,39 +451,6 @@ class LLFileUploadBulk : public view_listener_t filename = picker.getNextFile(); } -#if 0 - const std::string& filename = picker.getFirstFile(); - std::string name = gDirUtilp->getBaseFileName(filename, true); - - std::string asset_name = name; - LLStringUtil::replaceNonstandardASCII( asset_name, '?' ); - LLStringUtil::replaceChar(asset_name, '|', '?'); - LLStringUtil::stripNonprintable(asset_name); - LLStringUtil::trim(asset_name); - - std::string display_name = LLStringUtil::null; - LLAssetStorage::LLStoreAssetCallback callback = NULL; - S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); - void *userdata = NULL; - - upload_new_resource( - filename, - asset_name, - asset_name, - 0, - LLFolderType::FT_NONE, - LLInventoryType::IT_NONE, - LLFloaterPerms::getNextOwnerPerms("Uploads"), - LLFloaterPerms::getGroupPerms("Uploads"), - LLFloaterPerms::getEveryonePerms("Uploads"), - display_name, - callback, - expected_upload_cost, - userdata); - - // *NOTE: Ew, we don't iterate over the file list here, - // we handle the next files in upload_done_callback() -#endif } else { @@ -678,151 +645,6 @@ LLUUID upload_new_resource( upload_new_resource(uploadInfo, callback, userdata); return LLUUID::null; - -#if 0 - // Generate the temporary UUID. - std::string filename = gDirUtilp->getTempFilename(); - LLTransactionID tid; - LLAssetID uuid; - - LLSD args; - - std::string exten = gDirUtilp->getExtension(src_filename); - U32 codec = LLImageBase::getCodecFromExtension(exten); - LLAssetType::EType asset_type = LLAssetType::AT_NONE; - std::string error_message; - - BOOL error = FALSE; - - if (exten.empty()) - { - std::string short_name = gDirUtilp->getBaseFileName(filename); - - // No extension - error_message = llformat( - "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension", - short_name.c_str()); - args["FILE"] = short_name; - upload_error(error_message, "NoFileExtension", filename, args); - return LLUUID(); - } - else if (codec != IMG_CODEC_INVALID) - { - // It's an image file, the upload procedure is the same for all - asset_type = LLAssetType::AT_TEXTURE; - if (!LLViewerTextureList::createUploadFile(src_filename, filename, codec )) - { - error_message = llformat( "Problem with file %s:\n\n%s\n", - src_filename.c_str(), LLImage::getLastError().c_str()); - args["FILE"] = src_filename; - args["ERROR"] = LLImage::getLastError(); - upload_error(error_message, "ProblemWithFile", filename, args); - return LLUUID(); - } - } - else if(exten == "wav") - { - asset_type = LLAssetType::AT_SOUND; // tag it as audio - S32 encode_result = 0; - - LL_INFOS() << "Attempting to encode wav as an ogg file" << LL_ENDL; - - encode_result = encode_vorbis_file(src_filename, filename); - - if (LLVORBISENC_NOERR != encode_result) - { - switch(encode_result) - { - case LLVORBISENC_DEST_OPEN_ERR: - error_message = llformat( "Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str()); - args["FILE"] = filename; - upload_error(error_message, "CannotOpenTemporarySoundFile", filename, args); - break; - - default: - error_message = llformat("Unknown vorbis encode failure on: %s\n", src_filename.c_str()); - args["FILE"] = src_filename; - upload_error(error_message, "UnknownVorbisEncodeFailure", filename, args); - break; - } - return LLUUID(); - } - } - else if (exten == "bvh") - { - error_message = llformat("We do not currently support bulk upload of animation files\n"); - upload_error(error_message, "DoNotSupportBulkAnimationUpload", filename, args); - return LLUUID(); - } - else if (exten == "anim") - { - asset_type = LLAssetType::AT_ANIMATION; - filename = src_filename; - } - else - { - // Unknown extension - error_message = llformat(LLTrans::getString("UnknownFileExtension").c_str(), exten.c_str()); - error = TRUE;; - } - - // gen a new transaction ID for this asset - tid.generate(); - - if (!error) - { - uuid = tid.makeAssetID(gAgent.getSecureSessionID()); - // 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, uuid, asset_type, 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 - { - error_message = llformat( "Unable to access output file: %s", filename.c_str()); - error = TRUE; - } - } - - if (!error) - { - NewResourceUploadInfo::ptr_t uploadInfo(new NewResourceUploadInfo( - tid, asset_type, - name, desc, compression_info, - destination_folder_type, inv_type, - next_owner_perms, group_perms, everyone_perms, - expected_upload_cost)); - - upload_new_resource(uploadInfo, - callback, userdata); - } - else - { - LL_WARNS() << error_message << LL_ENDL; - LLSD args; - args["ERROR_MESSAGE"] = error_message; - LLNotificationsUtil::add("ErrorMessage", args); - if(LLFile::remove(filename) == -1) - { - LL_DEBUGS() << "unable to remove temp file" << LL_ENDL; - } - LLFilePicker::instance().reset(); - } - - return uuid; -#endif } void upload_done_callback( @@ -1047,349 +869,3 @@ void init_menu_file() // "File.SaveTexture" moved to llpanelmaininventory so that it can be properly handled. } - -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(); - -} -- 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/llviewermenufile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index e9eb0e807a..4772dd144b 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -929,7 +929,7 @@ void upload_new_resource( if ( !url.empty() ) { - LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo); + LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, _3, url, uploadInfo); LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); } -- 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/llviewermenufile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 4772dd144b..e9eb0e807a 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -929,7 +929,7 @@ void upload_new_resource( if ( !url.empty() ) { - LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, _3, url, uploadInfo); + LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo); LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); } -- 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/llviewermenufile.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 9c4045fa1e..163ae4f4ec 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -62,7 +62,6 @@ #include "lluploaddialog.h" #include "lltrans.h" #include "llfloaterbuycurrency.h" -#include "llcoproceduremanager.h" #include "llviewerassetupload.h" // linden libraries @@ -437,7 +436,7 @@ class LLFileUploadBulk : public view_listener_t LLStringUtil::stripNonprintable(asset_name); LLStringUtil::trim(asset_name); - NewResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( + LLResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( filename, asset_name, asset_name, 0, @@ -636,7 +635,7 @@ LLUUID upload_new_resource( void *userdata) { - NewResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( + LLResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( src_filename, name, desc, compression_info, destination_folder_type, inv_type, @@ -775,7 +774,7 @@ void upload_done_callback( } void upload_new_resource( - NewResourceUploadInfo::ptr_t &uploadInfo, + LLResourceUploadInfo::ptr_t &uploadInfo, LLAssetStorage::LLStoreAssetCallback callback, void *userdata) { @@ -792,9 +791,7 @@ void upload_new_resource( if ( !url.empty() ) { - LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLViewerAssetUpload::AssetInventoryUploadCoproc, _1, _2, url, uploadInfo); - - LLCoprocedureManager::getInstance()->enqueueCoprocedure("LLViewerAssetUpload::AssetInventoryUploadCoproc", proc); + LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); } else { -- 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/llviewermenufile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 163ae4f4ec..904fa7fcbe 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -436,7 +436,7 @@ class LLFileUploadBulk : public view_listener_t LLStringUtil::stripNonprintable(asset_name); LLStringUtil::trim(asset_name); - LLResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( + LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo( filename, asset_name, asset_name, 0, @@ -635,7 +635,7 @@ LLUUID upload_new_resource( void *userdata) { - LLResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo( + LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo( src_filename, name, desc, compression_info, destination_folder_type, inv_type, -- cgit v1.2.3 From 7882396811fdf8b297f6d0c92d8e1e37859fde9d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 23 Jul 2015 13:06:24 -0700 Subject: Remove unused code and llassetuploadresponders files. --- indra/newview/llviewermenufile.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 904fa7fcbe..782a27a846 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -65,7 +65,6 @@ #include "llviewerassetupload.h" // linden libraries -#include "llassetuploadresponders.h" #include "lleconomy.h" #include "llhttpclient.h" #include "llnotificationsutil.h" -- cgit v1.2.3 From 97236a42ca08979897d5c7b0826312345754cd67 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 14 Sep 2015 11:15:23 -0700 Subject: MAINT-5507: Remove HTTPClient and related cruft. --- indra/newview/llviewermenufile.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 782a27a846..4f24dfafac 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -66,7 +66,6 @@ // linden libraries #include "lleconomy.h" -#include "llhttpclient.h" #include "llnotificationsutil.h" #include "llsdserialize.h" #include "llsdutil.h" -- cgit v1.2.3