diff options
Diffstat (limited to 'indra/newview/llassetuploadresponders.cpp')
-rw-r--r-- | indra/newview/llassetuploadresponders.cpp | 543 |
1 files changed, 310 insertions, 233 deletions
diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp index 76cfe92c4c..f12bc16d4b 100644 --- a/indra/newview/llassetuploadresponders.cpp +++ b/indra/newview/llassetuploadresponders.cpp @@ -2,30 +2,25 @@ * @file llassetuploadresponders.cpp * @brief Processes responses received for asset upload requests. * - * $LicenseInfo:firstyear=2007&license=viewergpl$ - * - * Copyright (c) 2007, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlife.com/developers/opensource/gplv2 + * Copyright (C) 2010, 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. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at http://secondlife.com/developers/opensource/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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 * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -33,25 +28,42 @@ #include "llassetuploadresponders.h" +// viewer includes #include "llagent.h" -#include "llfloaterbuycurrency.h" -#include "lleconomy.h" +#include "llcompilequeue.h" +#include "llbuycurrencyhtml.h" #include "llfilepicker.h" -#include "llfocusmgr.h" -#include "llnotify.h" -#include "llinventorymodel.h" -#include "llinventoryview.h" +#include "llinventorydefines.h" +#include "llinventoryobserver.h" +#include "llinventorypanel.h" #include "llpermissionsflags.h" #include "llpreviewnotecard.h" #include "llpreviewscript.h" #include "llpreviewgesture.h" #include "llgesturemgr.h" -#include "llscrolllistctrl.h" +#include "llstatusbar.h" // sendMoneyBalanceRequest() +#include "llsdserialize.h" #include "lluploaddialog.h" #include "llviewerobject.h" +#include "llviewercontrol.h" #include "llviewerobjectlist.h" #include "llviewermenufile.h" #include "llviewerwindow.h" +#include "lltexlayer.h" +#include "lltrans.h" + +// library includes +#include "lldir.h" +#include "lleconomy.h" +#include "llfloaterreg.h" +#include "llfocusmgr.h" +#include "llnotificationsutil.h" +#include "llscrolllistctrl.h" +#include "llsdserialize.h" +#include "llvfs.h" + +// When uploading multiple files, don't display any of them when uploading more than this number. +static const S32 FILE_COUNT_DISPLAY_THRESHOLD = 5; void dialog_refresh_all(); @@ -73,10 +85,12 @@ LLAssetUploadResponder::LLAssetUploadResponder(const LLSD &post_data, } LLAssetUploadResponder::LLAssetUploadResponder(const LLSD &post_data, - const std::string& file_name) + const std::string& file_name, + LLAssetType::EType asset_type) : LLHTTPClient::Responder(), mPostData(post_data), - mFileName(file_name) + mFileName(file_name), + mAssetType(asset_type) { } @@ -85,7 +99,7 @@ LLAssetUploadResponder::~LLAssetUploadResponder() if (!mFileName.empty()) { // Delete temp file - LLFile::remove(mFileName.c_str()); + LLFile::remove(mFileName); } } @@ -94,21 +108,21 @@ void LLAssetUploadResponder::error(U32 statusNum, const std::string& reason) { llinfos << "LLAssetUploadResponder::error " << statusNum << " reason: " << reason << llendl; - LLStringBase<char>::format_map_t args; + LLSD args; switch(statusNum) { case 400: - args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName); - args["[REASON]"] = "Error in upload request. Please visit " + args["FILE"] = (mFileName.empty() ? mVFileID.asString() : mFileName); + args["REASON"] = "Error in upload request. Please visit " "http://secondlife.com/support for help fixing this problem."; - gViewerWindow->alertXml("CannotUploadReason", args); + LLNotificationsUtil::add("CannotUploadReason", args); break; case 500: default: - args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName); - args["[REASON]"] = "The server is experiencing unexpected " + args["FILE"] = (mFileName.empty() ? mVFileID.asString() : mFileName); + args["REASON"] = "The server is experiencing unexpected " "difficulties."; - gViewerWindow->alertXml("CannotUploadReason", args); + LLNotificationsUtil::add("CannotUploadReason", args); break; } LLUploadDialog::modalUploadFinished(); @@ -130,6 +144,7 @@ void LLAssetUploadResponder::result(const LLSD& content) if (mFileName.empty()) { // rename the file in the VFS to the actual asset id + // llinfos << "Changing uploaded asset UUID to " << content["new_asset"].asUUID() << llendl; gVFS->renameFile(mVFileID, mAssetType, content["new_asset"].asUUID(), mAssetType); } uploadComplete(content); @@ -155,18 +170,24 @@ void LLAssetUploadResponder::uploadUpload(const LLSD& content) void LLAssetUploadResponder::uploadFailure(const LLSD& content) { + // remove the "Uploading..." message + LLUploadDialog::modalUploadFinished(); + std::string reason = content["state"]; // deal with L$ errors if (reason == "insufficient funds") { - LLFloaterBuyCurrency::buyCurrency("Uploading costs", gGlobalEconomy->getPriceUpload()); + S32 price = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); + LLStringUtil::format_map_t args; + args["AMOUNT"] = llformat("%d", price); + LLBuyCurrencyHTML::openCurrencyFloater( LLTrans::getString("uploading_costs", args), price ); } else { - LLStringBase<char>::format_map_t args; - args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName); - args["[REASON]"] = content["message"].asString(); - gViewerWindow->alertXml("CannotUploadReason", args); + LLSD args; + args["FILE"] = (mFileName.empty() ? mVFileID.asString() : mFileName); + args["REASON"] = content["message"].asString(); + LLNotificationsUtil::add("CannotUploadReason", args); } } @@ -181,8 +202,8 @@ LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data { } -LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data, const std::string& file_name) -: LLAssetUploadResponder(post_data, file_name) +LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data, const std::string& file_name, LLAssetType::EType asset_type) +: LLAssetUploadResponder(post_data, file_name, asset_type) { } @@ -190,9 +211,14 @@ LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) { lldebugs << "LLNewAgentInventoryResponder::result from capabilities" << llendl; + + //std::ostringstream llsdxml; + //LLSDSerialize::toXML(content, llsdxml); + //llinfos << "upload complete content:\n " << llsdxml.str() << llendl; - LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString().c_str()); - LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString().c_str()); + LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString()); + LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString()); + S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); // Update L$ and ownership credit information // since it probably changed on the server @@ -200,17 +226,11 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) asset_type == LLAssetType::AT_SOUND || asset_type == LLAssetType::AT_ANIMATION) { - gMessageSystem->newMessageFast(_PREHASH_MoneyBalanceRequest); - gMessageSystem->nextBlockFast(_PREHASH_AgentData); - gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - gMessageSystem->nextBlockFast(_PREHASH_MoneyData); - gMessageSystem->addUUIDFast(_PREHASH_TransactionID, LLUUID::null ); - gAgent.sendReliableMessage(); - - LLString::format_map_t args; - args["[AMOUNT]"] = llformat("%d",gGlobalEconomy->getPriceUpload()); - LLNotifyBox::showXml("UploadPayment", args); + LLStatusBar::sendMoneyBalanceRequest(); + + LLSD args; + args["AMOUNT"] = llformat("%d", expected_upload_cost); + LLNotificationsUtil::add("UploadPayment", args); } // Actually add the upload to viewer inventory @@ -218,50 +238,65 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) << content["new_asset"].asUUID() << " to inventory." << llendl; if(mPostData["folder_id"].asUUID().notNull()) { - LLPermissions perm; - U32 next_owner_perm; - perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); - if (mPostData["inventory_type"].asString() == "snapshot") + //std::ostringstream out; + //LLSDXMLFormatter *formatter = new LLSDXMLFormatter; + //formatter->format(mPostData, out, LLSDFormatter::OPTIONS_PRETTY); + //llinfos << "Post Data: " << out.str() << llendl; + + U32 everyone_perms = PERM_NONE; + U32 group_perms = PERM_NONE; + U32 next_owner_perms = PERM_ALL; + if(content.has("new_next_owner_mask")) { - next_owner_perm = PERM_ALL; + // This is a new sim that provides creation perms so use them. + // Do not assume we got the perms we asked for in mPostData + // since the sim may not have granted them all. + everyone_perms = content["new_everyone_mask"].asInteger(); + group_perms = content["new_group_mask"].asInteger(); + next_owner_perms = content["new_next_owner_mask"].asInteger(); } - else + else { - next_owner_perm = PERM_MOVE | PERM_TRANSFER; + // This old sim doesn't provide creation perms so use old assumption-based perms. + if(mPostData["inventory_type"].asString() != "snapshot") + { + next_owner_perms = PERM_MOVE | PERM_TRANSFER; + } } - perm.initMasks(PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, next_owner_perm); + LLPermissions new_perms; + new_perms.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); + new_perms.initMasks(PERM_ALL, PERM_ALL, everyone_perms, group_perms, next_owner_perms); S32 creation_date_now = time_corrected(); LLPointer<LLViewerInventoryItem> item = new LLViewerInventoryItem(content["new_inventory_item"].asUUID(), mPostData["folder_id"].asUUID(), - perm, + new_perms, content["new_asset"].asUUID(), asset_type, inventory_type, mPostData["name"].asString(), mPostData["description"].asString(), LLSaleInfo::DEFAULT, - LLInventoryItem::II_FLAGS_NONE, + LLInventoryItemFlags::II_FLAGS_NONE, creation_date_now); gInventory.updateItem(item); gInventory.notifyObservers(); // Show the preview panel for textures and sounds to let // user know that the image (or snapshot) arrived intact. - LLInventoryView* view = LLInventoryView::getActiveInventory(); - if(view) + LLInventoryPanel *active_panel = LLInventoryPanel::getActiveInventoryPanel(); + if (active_panel) { - LLUICtrl* focus_ctrl = gFocusMgr.getKeyboardFocus(); - - view->getPanel()->setSelection(content["new_inventory_item"].asUUID(), TAKE_FOCUS_NO); - if((LLAssetType::AT_TEXTURE == asset_type) - || (LLAssetType::AT_SOUND == asset_type)) + active_panel->setSelection(content["new_inventory_item"].asUUID(), TAKE_FOCUS_NO); + if((LLAssetType::AT_TEXTURE == asset_type || LLAssetType::AT_SOUND == asset_type) + && LLFilePicker::instance().getFileCount() <= FILE_COUNT_DISPLAY_THRESHOLD) { - view->getPanel()->openSelected(); + active_panel->openSelected(); } - //LLInventoryView::dumpSelectionInformation((void*)view); + //LLFloaterInventory::dumpSelectionInformation((void*)view); // restore keyboard focus - gFocusMgr.setKeyboardFocus(focus_ctrl); + LLFocusableElement* focus = gFocusMgr.getKeyboardFocus(); + gFocusMgr.setKeyboardFocus(focus); } } else @@ -275,33 +310,84 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) // *FIX: This is a pretty big hack. What this does is check the // file picker if there are any more pending uploads. If so, // upload that file. - const char* next_file = LLFilePicker::instance().getNextFile(); - if(next_file) + std::string next_file = LLFilePicker::instance().getNextFile(); + if(!next_file.empty()) { - const char* name = LLFilePicker::instance().getDirname(); + std::string name = gDirUtilp->getBaseFileName(next_file, true); + + std::string asset_name = name; + LLStringUtil::replaceNonstandardASCII( asset_name, '?' ); + LLStringUtil::replaceChar(asset_name, '|', '?'); + LLStringUtil::stripNonprintable(asset_name); + LLStringUtil::trim(asset_name); + + // Continuing the horrible hack above, we need to extract the originally requested permissions data, if any, + // and use them for each next file to be uploaded. Note the requested perms are not the same as the + // granted ones found in the given "content" structure but can still be found in mPostData. -MG + U32 everyone_perms = mPostData.has("everyone_mask") ? mPostData.get("everyone_mask" ).asInteger() : PERM_NONE; + U32 group_perms = mPostData.has("group_mask") ? mPostData.get("group_mask" ).asInteger() : PERM_NONE; + U32 next_owner_perms = mPostData.has("next_owner_mask") ? mPostData.get("next_owner_mask").asInteger() : PERM_NONE; + std::string display_name = LLStringUtil::null; + LLAssetStorage::LLStoreAssetCallback callback = NULL; + void *userdata = NULL; + upload_new_resource(next_file, asset_name, asset_name, + 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE, + next_owner_perms, group_perms, + everyone_perms, display_name, + callback, expected_upload_cost, userdata); + } +} - LLString asset_name = name; - LLString::replaceNonstandardASCII( asset_name, '?' ); - LLString::replaceChar(asset_name, '|', '?'); - LLString::stripNonprintable(asset_name); - LLString::trim(asset_name); +LLSendTexLayerResponder::LLSendTexLayerResponder(const LLSD& post_data, + const LLUUID& vfile_id, + LLAssetType::EType asset_type, + LLBakedUploadData * baked_upload_data) : + LLAssetUploadResponder(post_data, vfile_id, asset_type), + mBakedUploadData(baked_upload_data) +{ +} - char* asset_name_str = (char*)asset_name.c_str(); - char* end_p = strrchr(asset_name_str, '.'); // strip extension if exists - if( !end_p ) - { - end_p = asset_name_str + strlen( asset_name_str ); /*Flawfinder: ignore*/ - } - - S32 len = llmin( (S32) (DB_INV_ITEM_NAME_STR_LEN), (S32) (end_p - asset_name_str) ); +LLSendTexLayerResponder::~LLSendTexLayerResponder() +{ + // mBakedUploadData is normally deleted by calls to LLTexLayerSetBuffer::onTextureUploadComplete() below + if (mBakedUploadData) + { // ...but delete it in the case where uploadComplete() is never called + delete mBakedUploadData; + mBakedUploadData = NULL; + } +} - asset_name = asset_name.substr( 0, len ); - upload_new_resource(next_file, asset_name, asset_name, - 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE); +// Baked texture upload completed +void LLSendTexLayerResponder::uploadComplete(const LLSD& content) +{ + LLUUID item_id = mPostData["item_id"]; + + std::string result = content["state"]; + LLUUID new_id = content["new_asset"]; + + llinfos << "result: " << result << "new_id:" << new_id << llendl; + if (result == "complete" + && mBakedUploadData != NULL) + { // Invoke + LLTexLayerSetBuffer::onTextureUploadComplete(new_id, (void*) mBakedUploadData, 0, LL_EXSTAT_NONE); + mBakedUploadData = NULL; // deleted in onTextureUploadComplete() + } + else + { // Invoke the original callback with an error result + LLTexLayerSetBuffer::onTextureUploadComplete(new_id, (void*) mBakedUploadData, -1, LL_EXSTAT_NONE); + mBakedUploadData = NULL; // deleted in onTextureUploadComplete() } } +void LLSendTexLayerResponder::error(U32 statusNum, const std::string& reason) +{ + llinfos << "status: " << statusNum << " reason: " << reason << llendl; + + // Invoke the original callback with an error result + LLTexLayerSetBuffer::onTextureUploadComplete(LLUUID(), (void*) mBakedUploadData, -1, LL_EXSTAT_NONE); + mBakedUploadData = NULL; // deleted in onTextureUploadComplete() +} LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(const LLSD& post_data, const LLUUID& vfile_id, @@ -311,8 +397,9 @@ LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(const LLSD& pos } LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(const LLSD& post_data, - const std::string& file_name) -: LLAssetUploadResponder(post_data, file_name) + const std::string& file_name, + LLAssetType::EType asset_type) +: LLAssetUploadResponder(post_data, file_name, asset_type) { } @@ -342,72 +429,68 @@ void LLUpdateAgentInventoryResponder::uploadComplete(const LLSD& content) LLInventoryType::EType inventory_type = new_item->getInventoryType(); switch(inventory_type) { - case LLInventoryType::IT_NOTECARD: - { - - // Update the UI with the new asset. - LLPreviewNotecard* nc; - nc = (LLPreviewNotecard*)LLPreview::find(new_item->getUUID()); - if(nc) - { - // *HACK: we have to delete the asset in the VFS so - // that the viewer will redownload it. This is only - // really necessary if the asset had to be modified by - // the uploader, so this can be optimized away in some - // cases. A better design is to have a new uuid if the - // script actually changed the asset. - if(nc->hasEmbeddedInventory()) - { - gVFS->removeFile( - content["new_asset"].asUUID(), - LLAssetType::AT_NOTECARD); - } - nc->refreshFromInventory(); - } - } - break; - case LLInventoryType::IT_LSL: - { - // Find our window and close it if requested. - LLPreviewLSL* preview = (LLPreviewLSL*)LLPreview::find(item_id); - if (preview) - { - // Bytecode save completed - if (content["compiled"]) - { - preview->callbackLSLCompileSucceeded(); - } - else - { - preview->callbackLSLCompileFailed(content["errors"]); - } - } - } - break; - - case LLInventoryType::IT_GESTURE: - { - // If this gesture is active, then we need to update the in-memory - // active map with the new pointer. - if (gGestureManager.isGestureActive(item_id)) - { - LLUUID asset_id = new_item->getAssetUUID(); - gGestureManager.replaceGesture(item_id, asset_id); - gInventory.notifyObservers(); - } - - //gesture will have a new asset_id - LLPreviewGesture* previewp = (LLPreviewGesture*)LLPreview::find(item_id); - if(previewp) - { - previewp->onUpdateSucceeded(); - } + case LLInventoryType::IT_NOTECARD: + { + // Update the UI with the new asset. + LLPreviewNotecard* nc = LLFloaterReg::findTypedInstance<LLPreviewNotecard>("preview_notecard", LLSD(item_id)); + if(nc) + { + // *HACK: we have to delete the asset in the VFS so + // that the viewer will redownload it. This is only + // really necessary if the asset had to be modified by + // the uploader, so this can be optimized away in some + // cases. A better design is to have a new uuid if the + // script actually changed the asset. + if(nc->hasEmbeddedInventory()) + { + gVFS->removeFile(content["new_asset"].asUUID(), LLAssetType::AT_NOTECARD); + } + nc->refreshFromInventory(new_item->getUUID()); + } + break; + } + case LLInventoryType::IT_LSL: + { + // Find our window and close it if requested. + LLPreviewLSL* preview = LLFloaterReg::findTypedInstance<LLPreviewLSL>("preview_script", LLSD(item_id)); + if (preview) + { + // Bytecode save completed + if (content["compiled"]) + { + preview->callbackLSLCompileSucceeded(); + } + else + { + preview->callbackLSLCompileFailed(content["errors"]); + } + } + break; + } + + case LLInventoryType::IT_GESTURE: + { + // If this gesture is active, then we need to update the in-memory + // active map with the new pointer. + if (LLGestureMgr::instance().isGestureActive(item_id)) + { + LLUUID asset_id = new_item->getAssetUUID(); + LLGestureMgr::instance().replaceGesture(item_id, asset_id); + gInventory.notifyObservers(); + } + + //gesture will have a new asset_id + LLPreviewGesture* previewp = LLFloaterReg::findTypedInstance<LLPreviewGesture>("preview_gesture", LLSD(item_id)); + if(previewp) + { + previewp->onUpdateSucceeded(); + } - } - break; - case LLInventoryType::IT_WEARABLE: - default: - break; + break; + } + case LLInventoryType::IT_WEARABLE: + default: + break; } } @@ -420,8 +503,17 @@ LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_ } LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data, - const std::string& file_name) -: LLAssetUploadResponder(post_data, file_name) + const std::string& file_name, + LLAssetType::EType asset_type) +: LLAssetUploadResponder(post_data, file_name, asset_type) +{ +} + +LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data, + const std::string& file_name, + const LLUUID& queue_id, + LLAssetType::EType asset_type) +: LLAssetUploadResponder(post_data, file_name, asset_type), mQueueId(queue_id) { } @@ -432,76 +524,61 @@ void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content) LLUUID item_id = mPostData["item_id"]; LLUUID task_id = mPostData["task_id"]; - LLViewerObject* object = gObjectList.findObject(task_id); - if (!object) - { - llwarns << "LLUpdateTaskInventoryResponder::uploadComplete task " << task_id - << " no longer exist." << llendl; - return; - } - LLViewerInventoryItem* item = (LLViewerInventoryItem*)object->getInventoryObject(item_id); - if (!item) - { - llwarns << "LLUpdateTaskInventoryResponder::uploadComplete item " - << item_id << " is no longer in task " << task_id - << "'s inventory." << llendl; - return; - } - LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); - // Update Viewer inventory - object->updateViewerInventoryAsset(new_item, content["new_asset"]); dialog_refresh_all(); - LLInventoryType::EType inventory_type = new_item->getInventoryType(); - switch(inventory_type) + switch(mAssetType) { - case LLInventoryType::IT_NOTECARD: - { - - // Update the UI with the new asset. - LLPreviewNotecard* nc; - nc = (LLPreviewNotecard*)LLPreview::find(new_item->getUUID()); - if(nc) - { - // *HACK: we have to delete the asset in the VFS so - // that the viewer will redownload it. This is only - // really necessary if the asset had to be modified by - // the uploader, so this can be optimized away in some - // cases. A better design is to have a new uuid if the - // script actually changed the asset. - if(nc->hasEmbeddedInventory()) - { - gVFS->removeFile( - content["new_asset"].asUUID(), - LLAssetType::AT_NOTECARD); - } - - nc->refreshFromInventory(); - } - } - break; - case LLInventoryType::IT_LSL: - { - LLLiveLSLEditor* preview = LLLiveLSLEditor::find(item_id, task_id); - if (preview) - { - // Bytecode save completed - if (content["compiled"]) - { - preview->callbackLSLCompileSucceeded( - task_id, - item_id, - mPostData["is_script_running"]); - } - else - { - preview->callbackLSLCompileFailed(content["errors"]); - } - } - } - break; - case LLInventoryType::IT_WEARABLE: - default: - break; + case LLAssetType::AT_NOTECARD: + { + // Update the UI with the new asset. + LLPreviewNotecard* nc = LLFloaterReg::findTypedInstance<LLPreviewNotecard>("preview_notecard", LLSD(item_id)); + if(nc) + { + // *HACK: we have to delete the asset in the VFS so + // that the viewer will redownload it. This is only + // really necessary if the asset had to be modified by + // the uploader, so this can be optimized away in some + // cases. A better design is to have a new uuid if the + // script actually changed the asset. + if(nc->hasEmbeddedInventory()) + { + gVFS->removeFile(content["new_asset"].asUUID(), + LLAssetType::AT_NOTECARD); + } + nc->setAssetId(content["new_asset"].asUUID()); + nc->refreshFromInventory(); + } + break; + } + case LLAssetType::AT_LSL_TEXT: + { + if(mQueueId.notNull()) + { + LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance<LLFloaterCompileQueue>("compile_queue", mQueueId); + if(NULL != queue) + { + queue->removeItemByItemID(item_id); + } + } + else + { + LLLiveLSLEditor* preview = LLFloaterReg::findTypedInstance<LLLiveLSLEditor>("preview_scriptedit", LLSD(item_id)); + if (preview) + { + // Bytecode save completed + if (content["compiled"]) + { + preview->callbackLSLCompileSucceeded(task_id, item_id, mPostData["is_script_running"]); + } + else + { + preview->callbackLSLCompileFailed(content["errors"]); + } + } + } + break; + } + default: + break; } } |