Fix upload snapshot to inventory callback mechanism.
This commit is contained in:
@@ -317,8 +317,10 @@ void LLAssetUploadResponder::uploadComplete(const LLSD& content)
|
||||
LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(
|
||||
const LLSD& post_data,
|
||||
const LLUUID& vfile_id,
|
||||
LLAssetType::EType asset_type)
|
||||
: LLAssetUploadResponder(post_data, vfile_id, asset_type)
|
||||
LLAssetType::EType asset_type,
|
||||
void (*callback)(bool, void*),
|
||||
void* user_data)
|
||||
: LLAssetUploadResponder(post_data, vfile_id, asset_type), mCallBack(callback), mUserData(user_data)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -326,13 +328,17 @@ LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(
|
||||
const LLSD& post_data,
|
||||
const std::string& file_name,
|
||||
LLAssetType::EType asset_type)
|
||||
: LLAssetUploadResponder(post_data, file_name, asset_type)
|
||||
: LLAssetUploadResponder(post_data, file_name, asset_type), mCallBack(NULL), mUserData(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
// virtual
|
||||
void LLNewAgentInventoryResponder::error(U32 statusNum, const std::string& reason)
|
||||
{
|
||||
if (mCallBack)
|
||||
{
|
||||
(*mCallBack)(false, mUserData);
|
||||
}
|
||||
LLAssetUploadResponder::error(statusNum, reason);
|
||||
//LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, LLUUID(), FALSE);
|
||||
}
|
||||
@@ -340,6 +346,10 @@ void LLNewAgentInventoryResponder::error(U32 statusNum, const std::string& reaso
|
||||
//virtual
|
||||
void LLNewAgentInventoryResponder::uploadFailure(const LLSD& content)
|
||||
{
|
||||
if (mCallBack)
|
||||
{
|
||||
(*mCallBack)(false, mUserData);
|
||||
}
|
||||
LLAssetUploadResponder::uploadFailure(content);
|
||||
//LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], FALSE);
|
||||
}
|
||||
@@ -349,6 +359,11 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
|
||||
{
|
||||
lldebugs << "LLNewAgentInventoryResponder::result from capabilities" << llendl;
|
||||
|
||||
if (mCallBack)
|
||||
{
|
||||
(*mCallBack)(true, mUserData);
|
||||
}
|
||||
|
||||
//std::ostringstream llsdxml;
|
||||
//LLSDSerialize::toXML(content, llsdxml);
|
||||
//llinfos << "upload complete content:\n " << llsdxml.str() << llendl;
|
||||
|
||||
@@ -78,11 +78,15 @@ protected:
|
||||
|
||||
class LLNewAgentInventoryResponder : public LLAssetUploadResponder
|
||||
{
|
||||
void (*mCallBack)(bool, void*);
|
||||
void* mUserData;
|
||||
public:
|
||||
LLNewAgentInventoryResponder(
|
||||
const LLSD& post_data,
|
||||
const LLUUID& vfile_id,
|
||||
LLAssetType::EType asset_type);
|
||||
LLAssetType::EType asset_type,
|
||||
void (*callback)(bool, void*) = NULL,
|
||||
void* user_data = NULL);
|
||||
LLNewAgentInventoryResponder(
|
||||
const LLSD& post_data,
|
||||
const std::string& file_name,
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
#include "llviewerwindow.h"
|
||||
#include "llwindow.h"
|
||||
#include "llviewermenufile.h" // upload_new_resource()
|
||||
#include "llresourcedata.h"
|
||||
#include "llfloaterpostcard.h"
|
||||
#include "llfloaterfeed.h"
|
||||
#include "llcheckboxctrl.h"
|
||||
@@ -183,6 +184,7 @@ public:
|
||||
LLFloaterPostcard* savePostcard();
|
||||
void saveTexture();
|
||||
static void saveTextureDone(LLUUID const& asset_id, void* user_data, S32 status, LLExtStat ext_status);
|
||||
static void saveTextureDone2(bool success, void* user_data);
|
||||
void saveLocal();
|
||||
void saveStart(int index);
|
||||
void saveDone(ESnapshotType type, bool success, int index);
|
||||
@@ -1383,9 +1385,10 @@ LLFloaterPostcard* LLSnapshotLivePreview::savePostcard()
|
||||
|
||||
class saveTextureUserData {
|
||||
public:
|
||||
saveTextureUserData(LLSnapshotLivePreview* self, int index) : mSelf(self), mSnapshotIndex(index) { }
|
||||
saveTextureUserData(LLSnapshotLivePreview* self, int index, bool temporary) : mSelf(self), mSnapshotIndex(index), mTemporary(temporary) { }
|
||||
LLSnapshotLivePreview* mSelf;
|
||||
int mSnapshotIndex;
|
||||
bool mTemporary;
|
||||
};
|
||||
|
||||
void LLSnapshotLivePreview::saveTexture()
|
||||
@@ -1412,7 +1415,8 @@ void LLSnapshotLivePreview::saveTexture()
|
||||
LLAgentUI::buildFullname(who_took_it);
|
||||
LLAssetStorage::LLStoreAssetCallback callback = &LLSnapshotLivePreview::saveTextureDone;
|
||||
S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
|
||||
upload_new_resource(tid, // tid
|
||||
saveTextureUserData* user_data = new saveTextureUserData(this, sSnapshotIndex, gSavedSettings.getBOOL("TemporaryUpload"));
|
||||
if (!upload_new_resource(tid, // tid
|
||||
LLAssetType::AT_TEXTURE,
|
||||
"Snapshot : " + pos_string,
|
||||
"Taken by " + who_took_it + " at " + pos_string,
|
||||
@@ -1423,7 +1427,12 @@ void LLSnapshotLivePreview::saveTexture()
|
||||
LLFloaterPerms::getGroupPerms(), // that is more permissive than other uploads
|
||||
LLFloaterPerms::getEveryonePerms(),
|
||||
"Snapshot : " + pos_string,
|
||||
callback, expected_upload_cost, new saveTextureUserData(this, sSnapshotIndex));
|
||||
callback, expected_upload_cost, user_data, &LLSnapshotLivePreview::saveTextureDone2))
|
||||
{
|
||||
// Something went wrong.
|
||||
delete user_data;
|
||||
saveDone(SNAPSHOT_TEXTURE, false, sSnapshotIndex);
|
||||
}
|
||||
|
||||
gViewerWindow->playSnapshotAnimAndSound();
|
||||
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_SNAPSHOT_COUNT );
|
||||
@@ -1509,16 +1518,36 @@ void LLSnapshotLivePreview::saveDone(ESnapshotType type, bool success, int index
|
||||
}
|
||||
}
|
||||
|
||||
// This callback is only used for the *legacy* LLViewerAssetStorage::storeAssetData
|
||||
// (when the cap NewFileAgentInventory is not available) and temporaries.
|
||||
// See upload_new_resource.
|
||||
//static
|
||||
void LLSnapshotLivePreview::saveTextureDone(LLUUID const& asset_id, void* user_data, S32 status, LLExtStat ext_status)
|
||||
{
|
||||
bool success = status != LL_ERR_NOERR;
|
||||
LLResourceData* resource_data = (LLResourceData*)user_data;
|
||||
|
||||
bool success = status == LL_ERR_NOERR;
|
||||
if (!success)
|
||||
{
|
||||
LLSD args;
|
||||
args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
|
||||
LLNotificationsUtil::add("UploadSnapshotFail", args);
|
||||
}
|
||||
saveTextureUserData* data = (saveTextureUserData*)resource_data->mUserData;
|
||||
bool temporary = data->mTemporary;
|
||||
data->mSelf->saveDone(SNAPSHOT_TEXTURE, success, data->mSnapshotIndex);
|
||||
delete data;
|
||||
|
||||
// Call the default call back.
|
||||
LLAssetStorage::LLStoreAssetCallback asset_callback = temporary ? &temp_upload_callback : &upload_done_callback;
|
||||
(*asset_callback)(asset_id, user_data, status, ext_status);
|
||||
}
|
||||
|
||||
// This callback used when the capability NewFileAgentInventory is available and it wasn't a temporary.
|
||||
// See upload_new_resource.
|
||||
//static
|
||||
void LLSnapshotLivePreview::saveTextureDone2(bool success, void* user_data)
|
||||
{
|
||||
saveTextureUserData* data = (saveTextureUserData*)user_data;
|
||||
data->mSelf->saveDone(SNAPSHOT_TEXTURE, success, data->mSnapshotIndex);
|
||||
delete data;
|
||||
|
||||
@@ -1155,7 +1155,7 @@ LLSD generate_new_resource_upload_capability_body(LLAssetType::EType asset_type,
|
||||
return body;
|
||||
}
|
||||
|
||||
void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_type,
|
||||
bool upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_type,
|
||||
std::string name,
|
||||
std::string desc, S32 compression_info,
|
||||
LLFolderType::EType destination_folder_type,
|
||||
@@ -1166,11 +1166,12 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
|
||||
const std::string& display_name,
|
||||
LLAssetStorage::LLStoreAssetCallback callback,
|
||||
S32 expected_upload_cost,
|
||||
void *userdata)
|
||||
void *userdata,
|
||||
void (*callback2)(bool, void*))
|
||||
{
|
||||
if(gDisconnected)
|
||||
{
|
||||
return ;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1207,7 +1208,7 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
|
||||
body["expected_upload_cost"] = LLSD::Integer(expected_upload_cost);
|
||||
|
||||
LLHTTPClient::post(url, body,
|
||||
new LLNewAgentInventoryResponder(body, uuid, asset_type));
|
||||
new LLNewAgentInventoryResponder(body, uuid, asset_type, callback2, userdata));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1230,7 +1231,7 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
|
||||
args["[CURRENCY]"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol();
|
||||
args["[AMOUNT]"] = llformat("%d", expected_upload_cost);
|
||||
LLFloaterBuyCurrency::buyCurrency( LLTrans::getString("UploadingCosts", args), expected_upload_cost );
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1260,6 +1261,9 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
|
||||
TRUE,
|
||||
temporary);
|
||||
}
|
||||
|
||||
// Return true when a call to a callback function will follow.
|
||||
return true;
|
||||
}
|
||||
|
||||
LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid)
|
||||
|
||||
@@ -66,7 +66,8 @@ void upload_new_resource(const std::string& src_filename,
|
||||
S32 expected_upload_cost,
|
||||
void *userdata);
|
||||
|
||||
void upload_new_resource(const LLTransactionID &tid,
|
||||
// Return false if no upload attempt was done (and the callback will not be called).
|
||||
bool upload_new_resource(const LLTransactionID &tid,
|
||||
LLAssetType::EType type,
|
||||
std::string name,
|
||||
std::string desc,
|
||||
@@ -79,7 +80,13 @@ void upload_new_resource(const LLTransactionID &tid,
|
||||
const std::string& display_name,
|
||||
LLAssetStorage::LLStoreAssetCallback callback,
|
||||
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).
|
||||
// user_data must be a LLResourceData allocated with new (or NULL).
|
||||
void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status);
|
||||
void temp_upload_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status);
|
||||
|
||||
LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user