summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerassetupload.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewerassetupload.cpp')
-rw-r--r--indra/newview/llviewerassetupload.cpp147
1 files changed, 107 insertions, 40 deletions
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<LLPreviewLSL>("preview_script",
+ uploadInfo->getItemId());
+ if (preview)
+ {
+ LLSD errors;
+ errors.append(LLTrans::getString("UploadFailed") + reason);
+ preview->callbackLSLCompileFailed(errors);
+ }
+ }
+
+}