Sync LLAssetUploadResponders with upstream

Move LLSendTexLayerResponder into llviewertexlayer.cpp to reduce diff noise
This commit is contained in:
Inusaito Sayori
2014-09-11 18:13:11 -04:00
parent 6863eb6651
commit e5e665b9ee
7 changed files with 142 additions and 171 deletions

View File

@@ -905,7 +905,6 @@ AIHTTPTimeoutPolicy const* AIHTTPTimeoutPolicy::getTimeoutPolicyByName(std::stri
#define P2(n, b) AIHTTPTimeoutPolicy n##_timeout(#n, b) #define P2(n, b) AIHTTPTimeoutPolicy n##_timeout(#n, b)
// Policy name Policy // Policy name Policy
P(assetUploadResponder);
P(assetReportHandler); P(assetReportHandler);
P(avatarPickerResponder); P(avatarPickerResponder);
P(authHandler); P(authHandler);
@@ -952,7 +951,6 @@ P2(meshPhysicsShapeResponder, connect_30s);
P2(meshSkinInfoResponder, connect_30s); P2(meshSkinInfoResponder, connect_30s);
P(mimeDiscoveryResponder); P(mimeDiscoveryResponder);
P(moderationResponder); P(moderationResponder);
P(newAgentInventoryVariablePriceResponder);
P(objectCostResponder); P(objectCostResponder);
P(physicsFlagsResponder); P(physicsFlagsResponder);
P(productInfoRequestResponder); P(productInfoRequestResponder);

View File

@@ -37,6 +37,7 @@
#include "llagent.h" #include "llagent.h"
#include "llcompilequeue.h" #include "llcompilequeue.h"
#include "llfloaterbuycurrency.h" #include "llfloaterbuycurrency.h"
#include "statemachine/aifilepicker.h"
#include "llinventorydefines.h" #include "llinventorydefines.h"
#include "llinventoryobserver.h" #include "llinventoryobserver.h"
#include "llinventorypanel.h" #include "llinventorypanel.h"
@@ -66,8 +67,6 @@
#include "llsdutil.h" #include "llsdutil.h"
#include "llvfs.h" #include "llvfs.h"
#include "statemachine/aifilepicker.h"
// When uploading multiple files, don't display any of them when uploading more than this number. // When uploading multiple files, don't display any of them when uploading more than this number.
static const S32 FILE_COUNT_DISPLAY_THRESHOLD = 5; static const S32 FILE_COUNT_DISPLAY_THRESHOLD = 5;
@@ -190,9 +189,10 @@ void on_new_single_inventory_upload_complete(
LLAssetUploadResponder::LLAssetUploadResponder(const LLSD &post_data, LLAssetUploadResponder::LLAssetUploadResponder(const LLSD &post_data,
const LLUUID& vfile_id, const LLUUID& vfile_id,
LLAssetType::EType asset_type) LLAssetType::EType asset_type)
: mPostData(post_data), :
mVFileID(vfile_id), mPostData(post_data),
mAssetType(asset_type) mVFileID(vfile_id),
mAssetType(asset_type)
{ {
if (!gVFS->getExists(vfile_id, asset_type)) if (!gVFS->getExists(vfile_id, asset_type))
{ {
@@ -207,9 +207,10 @@ LLAssetUploadResponder::LLAssetUploadResponder(
const LLSD &post_data, const LLSD &post_data,
const std::string& file_name, const std::string& file_name,
LLAssetType::EType asset_type) LLAssetType::EType asset_type)
: mPostData(post_data), :
mFileName(file_name), mPostData(post_data),
mAssetType(asset_type) mFileName(file_name),
mAssetType(asset_type)
{ {
} }
@@ -223,7 +224,7 @@ LLAssetUploadResponder::~LLAssetUploadResponder()
} }
// virtual // virtual
void LLAssetUploadResponder::httpFailure(void) void LLAssetUploadResponder::httpFailure()
{ {
llinfos << "LLAssetUploadResponder::error " << mStatus llinfos << "LLAssetUploadResponder::error " << mStatus
<< " reason: " << mReason << llendl; << " reason: " << mReason << llendl;
@@ -248,15 +249,21 @@ void LLAssetUploadResponder::httpFailure(void)
} }
//virtual //virtual
void LLAssetUploadResponder::httpSuccess(void) void LLAssetUploadResponder::httpSuccess()
{ {
const LLSD& content = getContent();
if (!content.isMap())
{
failureResult(HTTP_INTERNAL_ERROR_OTHER, "Malformed response contents", content);
return;
}
lldebugs << "LLAssetUploadResponder::result from capabilities" << llendl; lldebugs << "LLAssetUploadResponder::result from capabilities" << llendl;
std::string state = mContent["state"]; const std::string& state = content["state"].asString();
if (state == "upload") if (state == "upload")
{ {
uploadUpload(mContent); uploadUpload(content);
} }
else if (state == "complete") else if (state == "complete")
{ {
@@ -264,20 +271,20 @@ void LLAssetUploadResponder::httpSuccess(void)
if (mFileName.empty()) if (mFileName.empty())
{ {
// rename the file in the VFS to the actual asset id // rename the file in the VFS to the actual asset id
// llinfos << "Changing uploaded asset UUID to " << mContent["new_asset"].asUUID() << llendl; // LL_INFOS() << "Changing uploaded asset UUID to " << content["new_asset"].asUUID() << LL_ENDL;
gVFS->renameFile(mVFileID, mAssetType, mContent["new_asset"].asUUID(), mAssetType); gVFS->renameFile(mVFileID, mAssetType, content["new_asset"].asUUID(), mAssetType);
} }
uploadComplete(mContent); uploadComplete(content);
} }
else else
{ {
uploadFailure(mContent); uploadFailure(content);
} }
} }
void LLAssetUploadResponder::uploadUpload(const LLSD& content) void LLAssetUploadResponder::uploadUpload(const LLSD& content)
{ {
std::string uploader = content["uploader"]; const std::string& uploader = content["uploader"].asString();
if (mFileName.empty()) if (mFileName.empty())
{ {
LLHTTPClient::postFile(uploader, mVFileID, mAssetType, this); LLHTTPClient::postFile(uploader, mVFileID, mAssetType, this);
@@ -293,7 +300,7 @@ void LLAssetUploadResponder::uploadFailure(const LLSD& content)
// remove the "Uploading..." message // remove the "Uploading..." message
LLUploadDialog::modalUploadFinished(); LLUploadDialog::modalUploadFinished();
std::string reason = content["state"]; const std::string& reason = content["state"].asString();
// deal with L$ errors // deal with L$ errors
if (reason == "insufficient funds") if (reason == "insufficient funds")
{ {
@@ -316,10 +323,8 @@ void LLAssetUploadResponder::uploadComplete(const LLSD& content)
LLNewAgentInventoryResponder::LLNewAgentInventoryResponder( LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(
const LLSD& post_data, const LLSD& post_data,
const LLUUID& vfile_id, const LLUUID& vfile_id,
LLAssetType::EType asset_type, LLAssetType::EType asset_type)
void (*callback)(bool, void*), : LLAssetUploadResponder(post_data, vfile_id, asset_type)
void* user_data)
: LLAssetUploadResponder(post_data, vfile_id, asset_type), mCallBack(callback), mUserData(user_data)
{ {
} }
@@ -327,17 +332,13 @@ LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(
const LLSD& post_data, const LLSD& post_data,
const std::string& file_name, const std::string& file_name,
LLAssetType::EType asset_type) LLAssetType::EType asset_type)
: LLAssetUploadResponder(post_data, file_name, asset_type), mCallBack(NULL), mUserData(NULL) : LLAssetUploadResponder(post_data, file_name, asset_type)
{ {
} }
// virtual // virtual
void LLNewAgentInventoryResponder::httpFailure(void) void LLNewAgentInventoryResponder::httpFailure()
{ {
if (mCallBack)
{
(*mCallBack)(false, mUserData);
}
LLAssetUploadResponder::httpFailure(); LLAssetUploadResponder::httpFailure();
//LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, LLUUID(), FALSE); //LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, LLUUID(), FALSE);
} }
@@ -346,10 +347,6 @@ void LLNewAgentInventoryResponder::httpFailure(void)
//virtual //virtual
void LLNewAgentInventoryResponder::uploadFailure(const LLSD& content) void LLNewAgentInventoryResponder::uploadFailure(const LLSD& content)
{ {
if (mCallBack)
{
(*mCallBack)(false, mUserData);
}
LLAssetUploadResponder::uploadFailure(content); LLAssetUploadResponder::uploadFailure(content);
//LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], FALSE); //LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], FALSE);
@@ -360,14 +357,9 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
{ {
lldebugs << "LLNewAgentInventoryResponder::result from capabilities" << llendl; lldebugs << "LLNewAgentInventoryResponder::result from capabilities" << llendl;
if (mCallBack)
{
(*mCallBack)(true, mUserData);
}
//std::ostringstream llsdxml; //std::ostringstream llsdxml;
//LLSDSerialize::toXML(content, llsdxml); //LLSDSerialize::toXML(content, llsdxml);
//llinfos << "upload complete content:\n " << llsdxml.str() << llendl; //LL_INFOS() << "upload complete content:\n " << llsdxml.str() << LL_ENDL;
LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString()); LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString());
LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString()); LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString());
@@ -456,57 +448,6 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
*/ */
} }
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)
{
}
LLSendTexLayerResponder::~LLSendTexLayerResponder()
{
// mBakedUploadData is normally deleted by calls to LLViewerTexLayerSetBuffer::onTextureUploadComplete() below
if (mBakedUploadData)
{ // ...but delete it in the case where uploadComplete() is never called
delete mBakedUploadData;
mBakedUploadData = NULL;
}
}
// 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
LLViewerTexLayerSetBuffer::onTextureUploadComplete(new_id, (void*) mBakedUploadData, 0, LL_EXSTAT_NONE);
mBakedUploadData = NULL; // deleted in onTextureUploadComplete()
}
else
{ // Invoke the original callback with an error result
LLViewerTexLayerSetBuffer::onTextureUploadComplete(new_id, (void*) mBakedUploadData, -1, LL_EXSTAT_NONE);
mBakedUploadData = NULL; // deleted in onTextureUploadComplete()
}
}
void LLSendTexLayerResponder::httpFailure(void)
{
llinfos << "status: " << mStatus << " reason: " << mReason << llendl;
// Invoke the original callback with an error result
LLViewerTexLayerSetBuffer::onTextureUploadComplete(LLUUID(), (void*) mBakedUploadData, -1, LL_EXSTAT_NONE);
mBakedUploadData = NULL; // deleted in onTextureUploadComplete()
}
LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder( LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(
const LLSD& post_data, const LLSD& post_data,
const LLUUID& vfile_id, const LLUUID& vfile_id,
@@ -533,7 +474,7 @@ void LLUpdateAgentInventoryResponder::uploadComplete(const LLSD& content)
if(!item) if(!item)
{ {
llwarns << "Inventory item for " << mVFileID llwarns << "Inventory item for " << mVFileID
<< " is no longer in agent inventory." << llendl; << " is no longer in agent inventory." << LL_ENDL;
return; return;
} }
@@ -544,7 +485,7 @@ void LLUpdateAgentInventoryResponder::uploadComplete(const LLSD& content)
gInventory.notifyObservers(); gInventory.notifyObservers();
llinfos << "Inventory item " << item->getName() << " saved into " llinfos << "Inventory item " << item->getName() << " saved into "
<< content["new_asset"].asString() << llendl; << content["new_asset"].asString() << LL_ENDL;
LLInventoryType::EType inventory_type = new_item->getInventoryType(); LLInventoryType::EType inventory_type = new_item->getInventoryType();
switch(inventory_type) switch(inventory_type)
@@ -605,6 +546,7 @@ void LLUpdateAgentInventoryResponder::uploadComplete(const LLSD& content)
{ {
previewp->onUpdateSucceeded(); previewp->onUpdateSucceeded();
} }
break; break;
} }
case LLInventoryType::IT_WEARABLE: case LLInventoryType::IT_WEARABLE:
@@ -650,8 +592,7 @@ void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content)
case LLAssetType::AT_NOTECARD: case LLAssetType::AT_NOTECARD:
{ {
// Update the UI with the new asset. // Update the UI with the new asset.
LLPreviewNotecard* nc; LLPreviewNotecard* nc = (LLPreviewNotecard*)LLPreview::find(item_id);
nc = (LLPreviewNotecard*)LLPreview::find(item_id);
if (nc) if (nc)
{ {
// *HACK: we have to delete the asset in the VFS so // *HACK: we have to delete the asset in the VFS so
@@ -674,8 +615,7 @@ void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content)
{ {
if (mQueueId.notNull()) if (mQueueId.notNull())
{ {
LLFloaterCompileQueue* queue = LLFloaterCompileQueue* queue = (LLFloaterCompileQueue*) LLFloaterScriptQueue::findInstance(mQueueId);
(LLFloaterCompileQueue*) LLFloaterScriptQueue::findInstance(mQueueId);
if (NULL != queue) if (NULL != queue)
{ {
queue->removeItemByItemID(item_id); queue->removeItemByItemID(item_id);
@@ -724,7 +664,7 @@ public:
{ {
llwarns llwarns
<< "LLAssetUploadResponder called with nonexistant " << "LLAssetUploadResponder called with nonexistant "
<< "vfile_id " << vfile_id << llendl; << "vfile_id " << vfile_id << LL_ENDL;
mVFileID.setNull(); mVFileID.setNull();
mAssetType = LLAssetType::AT_NONE; mAssetType = LLAssetType::AT_NONE;
} }
@@ -1020,17 +960,15 @@ LLNewAgentInventoryVariablePriceResponder::~LLNewAgentInventoryVariablePriceResp
delete mImpl; delete mImpl;
} }
void LLNewAgentInventoryVariablePriceResponder::httpFailure(void) void LLNewAgentInventoryVariablePriceResponder::httpFailure()
{ {
lldebugs const LLSD& content = getContent();
<< "LLNewAgentInventoryVariablePrice::error " << mStatus LL_WARNS("Upload") << dumpResponse() << LL_ENDL;
<< " reason: " << mReason << llendl;
if ( mContent.has("error") )
{
static const std::string _ERROR = "error"; static const std::string _ERROR = "error";
if ( content.has(_ERROR) )
mImpl->onTransportError(mContent[_ERROR]); {
mImpl->onTransportError(content[_ERROR]);
} }
else else
{ {
@@ -1038,8 +976,14 @@ void LLNewAgentInventoryVariablePriceResponder::httpFailure(void)
} }
} }
void LLNewAgentInventoryVariablePriceResponder::httpSuccess(void) void LLNewAgentInventoryVariablePriceResponder::httpSuccess()
{ {
const LLSD& content = getContent();
if (!content.isMap())
{
failureResult(HTTP_INTERNAL_ERROR_OTHER, "Malformed response contents", content);
return;
}
// Parse out application level errors and the appropriate // Parse out application level errors and the appropriate
// responses for them // responses for them
static const std::string _ERROR = "error"; static const std::string _ERROR = "error";
@@ -1053,13 +997,14 @@ void LLNewAgentInventoryVariablePriceResponder::httpSuccess(void)
static const std::string _RSVP = "rsvp"; static const std::string _RSVP = "rsvp";
// Check for application level errors // Check for application level errors
if (mContent.has(_ERROR)) if ( content.has(_ERROR) )
{ {
onApplicationLevelError(mContent[_ERROR]); LL_WARNS("Upload") << dumpResponse() << LL_ENDL;
onApplicationLevelError(content[_ERROR]);
return; return;
} }
std::string state = mContent[_STATE]; std::string state = content[_STATE];
LLAssetType::EType asset_type = mImpl->getAssetType(); LLAssetType::EType asset_type = mImpl->getAssetType();
if (_COMPLETE == state) if (_COMPLETE == state)
@@ -1068,11 +1013,11 @@ void LLNewAgentInventoryVariablePriceResponder::httpSuccess(void)
if (mImpl->getFilename().empty()) if (mImpl->getFilename().empty())
{ {
// rename the file in the VFS to the actual asset id // rename the file in the VFS to the actual asset id
// llinfos << "Changing uploaded asset UUID to " << mContent["new_asset"].asUUID() << llendl; // LL_INFOS() << "Changing uploaded asset UUID to " << content["new_asset"].asUUID() << LL_ENDL;
gVFS->renameFile( gVFS->renameFile(
mImpl->getVFileID(), mImpl->getVFileID(),
asset_type, asset_type,
mContent["new_asset"].asUUID(), content["new_asset"].asUUID(),
asset_type); asset_type);
} }
@@ -1083,8 +1028,8 @@ void LLNewAgentInventoryVariablePriceResponder::httpSuccess(void)
mImpl->getFolderID(), mImpl->getFolderID(),
mImpl->getItemName(), mImpl->getItemName(),
mImpl->getItemDescription(), mImpl->getItemDescription(),
mContent, content,
mContent[_UPLOAD_PRICE].asInteger()); content[_UPLOAD_PRICE].asInteger());
// TODO* Add bulk (serial) uploading or add // TODO* Add bulk (serial) uploading or add
// a super class of this that does so // a super class of this that does so
@@ -1092,12 +1037,13 @@ void LLNewAgentInventoryVariablePriceResponder::httpSuccess(void)
else if ( _CONFIRM_UPLOAD == state ) else if ( _CONFIRM_UPLOAD == state )
{ {
showConfirmationDialog( showConfirmationDialog(
mContent[_UPLOAD_PRICE].asInteger(), content[_UPLOAD_PRICE].asInteger(),
mContent[_RESOURCE_COST].asInteger(), content[_RESOURCE_COST].asInteger(),
mContent[_RSVP].asString()); content[_RSVP].asString());
} }
else else
{ {
LL_WARNS("Upload") << dumpResponse() << LL_ENDL;
onApplicationLevelError(""); onApplicationLevelError("");
} }
} }
@@ -1170,3 +1116,4 @@ void LLNewAgentInventoryVariablePriceResponder::showConfirmationDialog(
} }
} }

View File

@@ -36,10 +36,6 @@
#include "llhttpclient.h" #include "llhttpclient.h"
#include "llinventory.h" #include "llinventory.h"
class AIHTTPTimeoutPolicy;
extern AIHTTPTimeoutPolicy assetUploadResponder_timeout;
extern AIHTTPTimeoutPolicy newAgentInventoryVariablePriceResponder_timeout;
void on_new_single_inventory_upload_complete(LLAssetType::EType asset_type, void on_new_single_inventory_upload_complete(LLAssetType::EType asset_type,
LLInventoryType::EType inventory_type, LLInventoryType::EType inventory_type,
const std::string inventory_type_string, const std::string inventory_type_string,
@@ -53,6 +49,8 @@ void on_new_single_inventory_upload_complete(LLAssetType::EType asset_type,
// via capabilities // via capabilities
class LLAssetUploadResponder : public LLHTTPClient::ResponderWithResult class LLAssetUploadResponder : public LLHTTPClient::ResponderWithResult
{ {
protected:
LOG_CLASS(LLAssetUploadResponder);
public: public:
LLAssetUploadResponder(const LLSD& post_data, LLAssetUploadResponder(const LLSD& post_data,
const LLUUID& vfile_id, const LLUUID& vfile_id,
@@ -61,10 +59,12 @@ public:
const std::string& file_name, const std::string& file_name,
LLAssetType::EType asset_type); LLAssetType::EType asset_type);
~LLAssetUploadResponder(); ~LLAssetUploadResponder();
/*virtual*/ void httpFailure(void);
/*virtual*/ void httpSuccess(void);
/*virtual*/ AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return assetUploadResponder_timeout; }
protected:
virtual void httpFailure();
virtual void httpSuccess();
public:
virtual void uploadUpload(const LLSD& content); virtual void uploadUpload(const LLSD& content);
virtual void uploadComplete(const LLSD& content); virtual void uploadComplete(const LLSD& content);
virtual void uploadFailure(const LLSD& content); virtual void uploadFailure(const LLSD& content);
@@ -76,25 +76,24 @@ protected:
std::string mFileName; std::string mFileName;
}; };
// TODO*: Remove this once deprecated
class LLNewAgentInventoryResponder : public LLAssetUploadResponder class LLNewAgentInventoryResponder : public LLAssetUploadResponder
{ {
void (*mCallBack)(bool, void*); LOG_CLASS(LLNewAgentInventoryResponder);
void* mUserData;
public: public:
LLNewAgentInventoryResponder( LLNewAgentInventoryResponder(
const LLSD& post_data, const LLSD& post_data,
const LLUUID& vfile_id, const LLUUID& vfile_id,
LLAssetType::EType asset_type, LLAssetType::EType asset_type);
void (*callback)(bool, void*) = NULL,
void* user_data = NULL);
LLNewAgentInventoryResponder( LLNewAgentInventoryResponder(
const LLSD& post_data, const LLSD& post_data,
const std::string& file_name, const std::string& file_name,
LLAssetType::EType asset_type); LLAssetType::EType asset_type);
/*virtual*/ void httpFailure(void);
virtual void uploadComplete(const LLSD& content); virtual void uploadComplete(const LLSD& content);
virtual void uploadFailure(const LLSD& content); virtual void uploadFailure(const LLSD& content);
/*virtual*/ char const* getName(void) const { return "LLNewAgentInventoryResponder"; } /*virtual*/ char const* getName() const { return "LLNewAgentInventoryResponder"; }
protected:
virtual void httpFailure();
}; };
// A base class which goes through and performs some default // A base class which goes through and performs some default
@@ -104,6 +103,7 @@ public:
class LLNewAgentInventoryVariablePriceResponder : class LLNewAgentInventoryVariablePriceResponder :
public LLHTTPClient::ResponderWithResult public LLHTTPClient::ResponderWithResult
{ {
LOG_CLASS(LLNewAgentInventoryVariablePriceResponder);
public: public:
LLNewAgentInventoryVariablePriceResponder( LLNewAgentInventoryVariablePriceResponder(
const LLUUID& vfile_id, const LLUUID& vfile_id,
@@ -116,10 +116,11 @@ public:
const LLSD& inventory_info); const LLSD& inventory_info);
virtual ~LLNewAgentInventoryVariablePriceResponder(); virtual ~LLNewAgentInventoryVariablePriceResponder();
/*virtual*/ void httpFailure(void); private:
/*virtual*/ void httpSuccess(void); /* virtual */ void httpFailure();
/*virtual*/ AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return newAgentInventoryVariablePriceResponder_timeout; } /* virtual */ void httpSuccess();
public:
virtual void onApplicationLevelError( virtual void onApplicationLevelError(
const LLSD& error); const LLSD& error);
virtual void showConfirmationDialog( virtual void showConfirmationDialog(
@@ -132,25 +133,6 @@ private:
Impl* mImpl; Impl* mImpl;
}; };
struct LLBakedUploadData;
class LLSendTexLayerResponder : public LLAssetUploadResponder
{
LOG_CLASS(LLSendTexLayerResponder);
public:
LLSendTexLayerResponder(const LLSD& post_data,
const LLUUID& vfile_id,
LLAssetType::EType asset_type,
LLBakedUploadData * baked_upload_data);
~LLSendTexLayerResponder();
/*virtual*/ void uploadComplete(const LLSD& content);
/*virtual*/ void httpFailure(void);
/*virtual*/ char const* getName(void) const { return "LLSendTexLayerResponder"; }
LLBakedUploadData * mBakedUploadData;
};
class LLUpdateAgentInventoryResponder : public LLAssetUploadResponder class LLUpdateAgentInventoryResponder : public LLAssetUploadResponder
{ {
public: public:
@@ -161,7 +143,7 @@ public:
const std::string& file_name, const std::string& file_name,
LLAssetType::EType asset_type); LLAssetType::EType asset_type);
virtual void uploadComplete(const LLSD& content); virtual void uploadComplete(const LLSD& content);
/*virtual*/ char const* getName(void) const { return "LLUpdateAgentInventoryResponder"; } /*virtual*/ char const* getName() const { return "LLUpdateAgentInventoryResponder"; }
}; };
class LLUpdateTaskInventoryResponder : public LLAssetUploadResponder class LLUpdateTaskInventoryResponder : public LLAssetUploadResponder
@@ -179,7 +161,7 @@ public:
LLAssetType::EType asset_type); LLAssetType::EType asset_type);
virtual void uploadComplete(const LLSD& content); virtual void uploadComplete(const LLSD& content);
/*virtual*/ char const* getName(void) const { return "LLUpdateTaskInventoryResponder"; } /*virtual*/ char const* getName() const { return "LLUpdateTaskInventoryResponder"; }
private: private:
LLUUID mQueueId; LLUUID mQueueId;

View File

@@ -1426,7 +1426,7 @@ void LLSnapshotLivePreview::saveTexture()
LLAssetStorage::LLStoreAssetCallback callback = &LLSnapshotLivePreview::saveTextureDone; LLAssetStorage::LLStoreAssetCallback callback = &LLSnapshotLivePreview::saveTextureDone;
S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
saveTextureUserData* user_data = new saveTextureUserData(this, sSnapshotIndex, gSavedSettings.getBOOL("TemporaryUpload")); saveTextureUserData* user_data = new saveTextureUserData(this, sSnapshotIndex, gSavedSettings.getBOOL("TemporaryUpload"));
if (!upload_new_resource(tid, // tid if (upload_new_resource(tid, // tid
LLAssetType::AT_TEXTURE, LLAssetType::AT_TEXTURE,
"Snapshot : " + pos_string, "Snapshot : " + pos_string,
"Taken by " + who_took_it + " at " + pos_string, "Taken by " + who_took_it + " at " + pos_string,
@@ -1437,7 +1437,11 @@ void LLSnapshotLivePreview::saveTexture()
LLFloaterPerms::getGroupPerms("Uploads"), // that is more permissive than other uploads LLFloaterPerms::getGroupPerms("Uploads"), // that is more permissive than other uploads
LLFloaterPerms::getEveryonePerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"),
"Snapshot : " + pos_string, "Snapshot : " + pos_string,
callback, expected_upload_cost, user_data, &LLSnapshotLivePreview::saveTextureDone2)) callback, expected_upload_cost, user_data))
{
saveTextureDone2(true, user_data);
}
else
{ {
// Something went wrong. // Something went wrong.
delete user_data; delete user_data;

View File

@@ -1177,8 +1177,7 @@ bool upload_new_resource(
const std::string& display_name, const std::string& display_name,
LLAssetStorage::LLStoreAssetCallback callback, LLAssetStorage::LLStoreAssetCallback callback,
S32 expected_upload_cost, S32 expected_upload_cost,
void *userdata, void *userdata)
void (*callback2)(bool, void*))
{ {
if(gDisconnected) if(gDisconnected)
{ {
@@ -1230,9 +1229,7 @@ bool upload_new_resource(
new LLNewAgentInventoryResponder( new LLNewAgentInventoryResponder(
body, body,
uuid, uuid,
asset_type, asset_type));
callback2,
userdata));
} }
else else
{ {
@@ -1294,17 +1291,16 @@ bool upload_new_resource(
LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid) LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid)
{ {
LLAssetID uuid;
if (gDisconnected) if (gDisconnected)
{ {
uuid.setNull(); LLAssetID rv;
}
else rv.setNull();
{ return rv;
uuid = tid.makeAssetID(gAgent.getSecureSessionID());
} }
LLAssetID uuid = tid.makeAssetID(gAgent.getSecureSessionID());
return uuid; return uuid;
} }

View File

@@ -78,8 +78,7 @@ bool upload_new_resource(const LLTransactionID &tid,
const std::string& display_name, const std::string& display_name,
LLAssetStorage::LLStoreAssetCallback callback, LLAssetStorage::LLStoreAssetCallback callback,
S32 expected_upload_cost, S32 expected_upload_cost,
void *userdata, void *userdata);
void (*callback2)(bool, void*) = NULL);
// The default callback functions, called when 'callback' == NULL (for normal and temporary uploads). // The default callback functions, called when 'callback' == NULL (for normal and temporary uploads).
// user_data must be a LLResourceData allocated with new (or NULL). // user_data must be a LLResourceData allocated with new (or NULL).

View File

@@ -361,6 +361,51 @@ BOOL LLViewerTexLayerSetBuffer::requestUpdateImmediate()
return result; return result;
} }
class LLSendTexLayerResponder : public LLAssetUploadResponder
{
LOG_CLASS(LLSendTexLayerResponder);
public:
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)
{}
~LLSendTexLayerResponder()
{
// mBakedUploadData is normally deleted by calls to LLViewerTexLayerSetBuffer::onTextureUploadComplete() below
if (mBakedUploadData)
{ // ...but delete it in the case where uploadComplete() is never called
delete mBakedUploadData;
mBakedUploadData = NULL;
}
}
// Baked texture upload completed
/*virtual*/ void uploadComplete(const LLSD& content)
{
const std::string& result = content["state"];
const LLUUID& new_id = content["new_asset"];
llinfos << "result: " << result << " new_id: " << new_id << llendl;
LLViewerTexLayerSetBuffer::onTextureUploadComplete(new_id, (void*) mBakedUploadData, (result == "complete" && mBakedUploadData) ? 0 : -1, LL_EXSTAT_NONE);
mBakedUploadData = NULL; // deleted in onTextureUploadComplete()
}
/*virtual*/ void httpFailure()
{
llinfos << dumpResponse() << llendl;
// Invoke the original callback with an error result
LLViewerTexLayerSetBuffer::onTextureUploadComplete(LLUUID::null, (void*) mBakedUploadData, -1, LL_EXSTAT_NONE);
mBakedUploadData = NULL; // deleted in onTextureUploadComplete()
}
/*virtual*/ char const* getName() const { return "LLSendTexLayerResponder"; }
private:
LLBakedUploadData* mBakedUploadData;
};
// Create the baked texture, send it out to the server, then wait for it to come // Create the baked texture, send it out to the server, then wait for it to come
// back so we can switch to using it. // back so we can switch to using it.
void LLViewerTexLayerSetBuffer::doUpload() void LLViewerTexLayerSetBuffer::doUpload()