summaryrefslogtreecommitdiff
path: root/indra/newview/llpreviewgesture.cpp
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2016-04-04 15:53:09 -0400
committerOz Linden <oz@lindenlab.com>2016-04-04 15:53:09 -0400
commit9be58e915a6c69de280ccabd3019e9ac40beed26 (patch)
treead6f8f1f754a865afb761d0f17744cc7e1ef8b74 /indra/newview/llpreviewgesture.cpp
parentab46c9226bd9048fa218f54bc8668594401529e7 (diff)
parent18928ea6c6f2830a0d45ec412c915eceff1b76b0 (diff)
merge with 4.0.3-release
Diffstat (limited to 'indra/newview/llpreviewgesture.cpp')
-rw-r--r--indra/newview/llpreviewgesture.cpp252
1 files changed, 142 insertions, 110 deletions
diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp
index c378738b05..ff9a70d05c 100644
--- a/indra/newview/llpreviewgesture.cpp
+++ b/indra/newview/llpreviewgesture.cpp
@@ -31,7 +31,6 @@
#include "llanimstatelabels.h"
#include "llanimationstates.h"
#include "llappviewer.h" // gVFS
-#include "llassetuploadresponders.h"
#include "llcheckboxctrl.h"
#include "llcombobox.h"
#include "lldatapacker.h"
@@ -52,6 +51,7 @@
#include "llviewerobjectlist.h"
#include "llviewerregion.h"
#include "llviewerstats.h"
+#include "llviewerassetupload.h"
std::string NONE_LABEL;
std::string SHIFT_LABEL;
@@ -1015,6 +1015,27 @@ struct LLSaveInfo
};
+void LLPreviewGesture::finishInventoryUpload(LLUUID itemId, LLUUID newAssetId)
+{
+ // If this gesture is active, then we need to update the in-memory
+ // active map with the new pointer.
+ if (LLGestureMgr::instance().isGestureActive(itemId))
+ {
+ //*TODO: This is crashing for some reason. Fix it.
+ // Active gesture edited from menu.
+ LLGestureMgr::instance().replaceGesture(itemId, newAssetId);
+ gInventory.notifyObservers();
+ }
+
+ //gesture will have a new asset_id
+ LLPreviewGesture* previewp = LLFloaterReg::findTypedInstance<LLPreviewGesture>("preview_gesture", LLSD(itemId));
+ if (previewp)
+ {
+ previewp->onUpdateSucceeded();
+ }
+}
+
+
void LLPreviewGesture::saveIfNeeded()
{
if (!gAssetStorage)
@@ -1028,116 +1049,127 @@ void LLPreviewGesture::saveIfNeeded()
return;
}
- // Copy the UI into a gesture
- LLMultiGesture* gesture = createGesture();
-
- // Serialize the gesture
- S32 max_size = gesture->getMaxSerialSize();
- char* buffer = new char[max_size];
-
- LLDataPackerAsciiBuffer dp(buffer, max_size);
-
- BOOL ok = gesture->serialize(dp);
-
- if (dp.getCurrentSize() > 1000)
- {
- LLNotificationsUtil::add("GestureSaveFailedTooManySteps");
-
- delete gesture;
- gesture = NULL;
- }
- else if (!ok)
- {
- LLNotificationsUtil::add("GestureSaveFailedTryAgain");
- delete gesture;
- gesture = NULL;
- }
- else
- {
- LLPreview::onCommit();
-
- // Every save gets a new UUID. Yup.
- LLTransactionID tid;
- LLAssetID asset_id;
- tid.generate();
- asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
-
- LLVFile file(gVFS, asset_id, LLAssetType::AT_GESTURE, LLVFile::APPEND);
-
- S32 size = dp.getCurrentSize();
- file.setMaxSize(size);
- file.write((U8*)buffer, size);
-
- BOOL delayedUpload = FALSE;
-
- // Upload that asset to the database
- LLViewerInventoryItem* item = (LLViewerInventoryItem*) getItem();
- if (item)
- {
- std::string agent_url = gAgent.getRegion()->getCapability("UpdateGestureAgentInventory");
- std::string task_url = gAgent.getRegion()->getCapability("UpdateGestureTaskInventory");
- if (mObjectUUID.isNull() && !agent_url.empty())
- {
- //need to disable the preview floater so item
- //isn't re-saved before new asset arrives
- //fake out refresh.
- item->setComplete(FALSE);
- refresh();
- item->setComplete(TRUE);
-
- // Saving into agent inventory
- LLSD body;
- body["item_id"] = mItemUUID;
- LLHTTPClient::post(agent_url, body,
- new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_GESTURE));
- delayedUpload = TRUE;
- }
- else if (!mObjectUUID.isNull() && !task_url.empty())
- {
- // Saving into task inventory
- LLSD body;
- body["task_id"] = mObjectUUID;
- body["item_id"] = mItemUUID;
- LLHTTPClient::post(task_url, body,
- new LLUpdateTaskInventoryResponder(body, asset_id, LLAssetType::AT_GESTURE));
- }
- else if (gAssetStorage)
- {
- LLLineEditor* descEditor = getChild<LLLineEditor>("desc");
- LLSaveInfo* info = new LLSaveInfo(mItemUUID, mObjectUUID, descEditor->getText(), tid);
- gAssetStorage->storeAssetData(tid, LLAssetType::AT_GESTURE, onSaveComplete, info, FALSE);
- }
- }
-
- // If this gesture is active, then we need to update the in-memory
- // active map with the new pointer.
- if (!delayedUpload && LLGestureMgr::instance().isGestureActive(mItemUUID))
- {
- // gesture manager now owns the pointer
- LLGestureMgr::instance().replaceGesture(mItemUUID, gesture, asset_id);
-
- // replaceGesture may deactivate other gestures so let the
- // inventory know.
- gInventory.notifyObservers();
- }
- else
- {
- // we're done with this gesture
- delete gesture;
- gesture = NULL;
- }
-
- mDirty = FALSE;
- // refresh will be called when callback
- // if triggered when delayedUpload
- if(!delayedUpload)
- {
- refresh();
- }
- }
+ // Copy the UI into a gesture
+ LLMultiGesture* gesture = createGesture();
+
+ // Serialize the gesture
+ S32 maxSize = gesture->getMaxSerialSize();
+ char* buffer = new char[maxSize];
+
+ LLDataPackerAsciiBuffer dp(buffer, maxSize);
+
+ bool ok = gesture->serialize(dp);
+
+ if (dp.getCurrentSize() > 1000)
+ {
+ LLNotificationsUtil::add("GestureSaveFailedTooManySteps");
+
+ delete gesture;
+ gesture = NULL;
+ return;
+ }
+ else if (!ok)
+ {
+ LLNotificationsUtil::add("GestureSaveFailedTryAgain");
+ delete gesture;
+ gesture = NULL;
+ return;
+ }
+
+ LLAssetID assetId;
+ LLPreview::onCommit();
+ bool delayedUpload(false);
+
+ LLViewerInventoryItem* item = (LLViewerInventoryItem*) getItem();
+ if (item)
+ {
+ const LLViewerRegion* region = gAgent.getRegion();
+ if (!region)
+ {
+ LL_WARNS() << "Not connected to a region, cannot save notecard." << LL_ENDL;
+ return;
+ }
+ std::string agent_url = region->getCapability("UpdateGestureAgentInventory");
+ std::string task_url = region->getCapability("UpdateGestureTaskInventory");
+
+ if (!agent_url.empty() && !task_url.empty())
+ {
+ std::string url;
+ LLResourceUploadInfo::ptr_t uploadInfo;
+
+ if (mObjectUUID.isNull() && !agent_url.empty())
+ {
+ //need to disable the preview floater so item
+ //isn't re-saved before new asset arrives
+ //fake out refresh.
+ item->setComplete(false);
+ refresh();
+ item->setComplete(true);
+
+ uploadInfo = LLResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mItemUUID, LLAssetType::AT_GESTURE, buffer,
+ boost::bind(&LLPreviewGesture::finishInventoryUpload, _1, _2)));
+ url = agent_url;
+ }
+ else if (!mObjectUUID.isNull() && !task_url.empty())
+ {
+ uploadInfo = LLResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mObjectUUID, mItemUUID, LLAssetType::AT_GESTURE, buffer, NULL));
+ url = task_url;
+ }
+
+ if (!url.empty() && uploadInfo)
+ {
+ delayedUpload = true;
+
+ LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo);
+ }
+
+ }
+ else if (gAssetStorage)
+ {
+ // Every save gets a new UUID. Yup.
+ LLTransactionID tid;
+ tid.generate();
+ assetId = tid.makeAssetID(gAgent.getSecureSessionID());
+
+ LLVFile file(gVFS, assetId, LLAssetType::AT_GESTURE, LLVFile::APPEND);
+
+ S32 size = dp.getCurrentSize();
+ file.setMaxSize(size);
+ file.write((U8*)buffer, size);
+
+ LLLineEditor* descEditor = getChild<LLLineEditor>("desc");
+ LLSaveInfo* info = new LLSaveInfo(mItemUUID, mObjectUUID, descEditor->getText(), tid);
+ gAssetStorage->storeAssetData(tid, LLAssetType::AT_GESTURE, onSaveComplete, info, FALSE);
+ }
+
+ }
+
+ // If this gesture is active, then we need to update the in-memory
+ // active map with the new pointer.
+ if (!delayedUpload && LLGestureMgr::instance().isGestureActive(mItemUUID))
+ {
+ // gesture manager now owns the pointer
+ LLGestureMgr::instance().replaceGesture(mItemUUID, gesture, assetId);
+
+ // replaceGesture may deactivate other gestures so let the
+ // inventory know.
+ gInventory.notifyObservers();
+ }
+ else
+ {
+ // we're done with this gesture
+ delete gesture;
+ gesture = NULL;
+ }
+
+ mDirty = false;
+ // refresh will be called when callback
+ // if triggered when delayedUpload
+ if(!delayedUpload)
+ {
+ refresh();
+ }
- delete [] buffer;
- buffer = NULL;
}