summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rwxr-xr-xindra/newview/llassetuploadresponders.cpp2
-rwxr-xr-xindra/newview/llassetuploadresponders.h3
-rw-r--r--indra/newview/llcoproceduremanager.cpp2
-rwxr-xr-xindra/newview/lleventpoll.cpp2
-rwxr-xr-xindra/newview/llhttpretrypolicy.cpp4
-rwxr-xr-xindra/newview/llhttpretrypolicy.h2
-rwxr-xr-xindra/newview/llinventorymodel.cpp23
-rwxr-xr-xindra/newview/llinventorymodel.h4
-rwxr-xr-xindra/newview/llmaterialmgr.cpp2
-rwxr-xr-xindra/newview/llmeshrepository.cpp45
-rwxr-xr-xindra/newview/llmeshrepository.h10
-rwxr-xr-xindra/newview/lltexturefetch.cpp55
-rwxr-xr-xindra/newview/lltexturefetch.h12
-rw-r--r--indra/newview/llviewerassetupload.cpp355
-rw-r--r--indra/newview/llviewerassetupload.h155
-rwxr-xr-xindra/newview/llviewermenufile.cpp524
-rwxr-xr-xindra/newview/llviewermenufile.h146
-rwxr-xr-xindra/newview/llxmlrpctransaction.cpp2
-rwxr-xr-xindra/newview/tests/llhttpretrypolicy_test.cpp6
19 files changed, 569 insertions, 785 deletions
diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index e492b8cf5d..fe01288e23 100755
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -352,6 +352,7 @@ void LLAssetUploadResponder::uploadComplete(const LLSD& content)
{
}
+#if 0
LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(
const LLSD& post_data,
const LLUUID& vfile_id,
@@ -473,6 +474,7 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
//LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], TRUE);
}
+#endif
LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(
const LLSD& post_data,
diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h
index 18968bb1af..6828678f09 100755
--- a/indra/newview/llassetuploadresponders.h
+++ b/indra/newview/llassetuploadresponders.h
@@ -60,6 +60,7 @@ protected:
std::string mFileName;
};
+#if 0
// TODO*: Remove this once deprecated
class LLNewAgentInventoryResponder : public LLAssetUploadResponder
{
@@ -78,7 +79,7 @@ public:
protected:
virtual void httpFailure();
};
-
+#endif
#if 0
// A base class which goes through and performs some default
// actions for variable price uploads. If more specific actions
diff --git a/indra/newview/llcoproceduremanager.cpp b/indra/newview/llcoproceduremanager.cpp
index d3168985f8..1a4a906f35 100644
--- a/indra/newview/llcoproceduremanager.cpp
+++ b/indra/newview/llcoproceduremanager.cpp
@@ -138,7 +138,7 @@ void LLCoprocedureManager::coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineA
while (!mShutdown)
{
- llcoro::waitForEventOn(mWakeupTrigger);
+ waitForEventOn(mWakeupTrigger);
if (mShutdown)
break;
diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp
index 0aad1d5ba9..54da226209 100755
--- a/indra/newview/lleventpoll.cpp
+++ b/indra/newview/lleventpoll.cpp
@@ -197,7 +197,7 @@ namespace Details
" seconds, error count is now " << errorCount << LL_ENDL;
timeout.eventAfter(waitToRetry, LLSD());
- llcoro::waitForEventOn(timeout);
+ waitForEventOn(timeout);
if (mDone)
break;
diff --git a/indra/newview/llhttpretrypolicy.cpp b/indra/newview/llhttpretrypolicy.cpp
index 530eb685fa..e2e151eb63 100755
--- a/indra/newview/llhttpretrypolicy.cpp
+++ b/indra/newview/llhttpretrypolicy.cpp
@@ -56,7 +56,7 @@ bool LLAdaptiveRetryPolicy::getRetryAfter(const LLSD& headers, F32& retry_header
&& getSecondsUntilRetryAfter(headers[HTTP_IN_HEADER_RETRY_AFTER].asStringRef(), retry_header_time));
}
-bool LLAdaptiveRetryPolicy::getRetryAfter(const LLCore::HttpHeaders *headers, F32& retry_header_time)
+bool LLAdaptiveRetryPolicy::getRetryAfter(const LLCore::HttpHeaders::ptr_t &headers, F32& retry_header_time)
{
if (headers)
{
@@ -85,7 +85,7 @@ void LLAdaptiveRetryPolicy::onFailure(S32 status, const LLSD& headers)
void LLAdaptiveRetryPolicy::onFailure(const LLCore::HttpResponse *response)
{
F32 retry_header_time;
- const LLCore::HttpHeaders *headers = response->getHeaders();
+ const LLCore::HttpHeaders::ptr_t headers = response->getHeaders();
bool has_retry_header_time = getRetryAfter(headers,retry_header_time);
onFailureCommon(response->getStatus().getType(), has_retry_header_time, retry_header_time);
}
diff --git a/indra/newview/llhttpretrypolicy.h b/indra/newview/llhttpretrypolicy.h
index cf79e0b401..c0cc263546 100755
--- a/indra/newview/llhttpretrypolicy.h
+++ b/indra/newview/llhttpretrypolicy.h
@@ -79,7 +79,7 @@ public:
protected:
void init();
bool getRetryAfter(const LLSD& headers, F32& retry_header_time);
- bool getRetryAfter(const LLCore::HttpHeaders *headers, F32& retry_header_time);
+ bool getRetryAfter(const LLCore::HttpHeaders::ptr_t &headers, F32& retry_header_time);
void onFailureCommon(S32 status, bool has_retry_header_time, F32 retry_header_time);
private:
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index 25450f2317..47d3e88b3a 100755
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -148,8 +148,8 @@ LLInventoryModel::LLInventoryModel()
mObservers(),
mHttpRequestFG(NULL),
mHttpRequestBG(NULL),
- mHttpOptions(NULL),
- mHttpHeaders(NULL),
+ mHttpOptions(),
+ mHttpHeaders(),
mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID),
mHttpPriorityFG(0),
mHttpPriorityBG(0),
@@ -178,16 +178,9 @@ void LLInventoryModel::cleanupInventory()
mObservers.clear();
// Run down HTTP transport
- if (mHttpHeaders)
- {
- mHttpHeaders->release();
- mHttpHeaders = NULL;
- }
- if (mHttpOptions)
- {
- mHttpOptions->release();
- mHttpOptions = NULL;
- }
+ mHttpHeaders.reset();
+ mHttpOptions.reset();
+
delete mHttpRequestFG;
mHttpRequestFG = NULL;
delete mHttpRequestBG;
@@ -613,7 +606,7 @@ void LLInventoryModel::createNewCategoryCoro(std::string url, LLSD postData, inv
LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("createNewCategoryCoro", httpPolicy));
LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
- LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);
+ LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
httpOpts->setWantHeaders(true);
@@ -2418,11 +2411,11 @@ void LLInventoryModel::initHttpRequest()
mHttpRequestFG = new LLCore::HttpRequest;
mHttpRequestBG = new LLCore::HttpRequest;
- mHttpOptions = new LLCore::HttpOptions;
+ mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);
mHttpOptions->setTransferTimeout(300);
mHttpOptions->setUseRetryAfter(true);
// mHttpOptions->setTrace(2); // Do tracing of requests
- mHttpHeaders = new LLCore::HttpHeaders;
+ mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders);
mHttpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML);
mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_LLSD_XML);
mHttpPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_INVENTORY);
diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h
index 1f1c686ef1..e8977bc7d7 100755
--- a/indra/newview/llinventorymodel.h
+++ b/indra/newview/llinventorymodel.h
@@ -571,8 +571,8 @@ private:
// Usual plumbing for LLCore:: HTTP operations.
LLCore::HttpRequest * mHttpRequestFG;
LLCore::HttpRequest * mHttpRequestBG;
- LLCore::HttpOptions * mHttpOptions;
- LLCore::HttpHeaders * mHttpHeaders;
+ LLCore::HttpOptions::ptr_t mHttpOptions;
+ LLCore::HttpHeaders::ptr_t mHttpHeaders;
LLCore::HttpRequest::policy_t mHttpPolicyClass;
LLCore::HttpRequest::priority_t mHttpPriorityFG;
LLCore::HttpRequest::priority_t mHttpPriorityBG;
diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp
index aef5bcf0dd..1045def72e 100755
--- a/indra/newview/llmaterialmgr.cpp
+++ b/indra/newview/llmaterialmgr.cpp
@@ -712,7 +712,7 @@ void LLMaterialMgr::processGetAllQueue()
);
LLCore::HttpHandle handle = mHttpRequest->requestGet(mHttpPolicy, mHttpPriority, capURL,
- mHttpOptions.get(), mHttpHeaders.get(), handler);
+ mHttpOptions, mHttpHeaders, handler);
if (handle == LLCORE_HTTP_HANDLE_INVALID)
{
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index 648056484e..d6aaf18cb7 100755
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -738,9 +738,9 @@ void log_upload_error(LLCore::HttpStatus status, const LLSD& content,
LLMeshRepoThread::LLMeshRepoThread()
: LLThread("mesh repo"),
mHttpRequest(NULL),
- mHttpOptions(NULL),
- mHttpLargeOptions(NULL),
- mHttpHeaders(NULL),
+ mHttpOptions(),
+ mHttpLargeOptions(),
+ mHttpHeaders(),
mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID),
mHttpLegacyPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID),
mHttpLargePolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID),
@@ -753,13 +753,13 @@ LLMeshRepoThread::LLMeshRepoThread()
mHeaderMutex = new LLMutex(NULL);
mSignal = new LLCondition(NULL);
mHttpRequest = new LLCore::HttpRequest;
- mHttpOptions = new LLCore::HttpOptions;
+ mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);
mHttpOptions->setTransferTimeout(SMALL_MESH_XFER_TIMEOUT);
mHttpOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter"));
- mHttpLargeOptions = new LLCore::HttpOptions;
+ mHttpLargeOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);
mHttpLargeOptions->setTransferTimeout(LARGE_MESH_XFER_TIMEOUT);
mHttpLargeOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter"));
- mHttpHeaders = new LLCore::HttpHeaders;
+ mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders);
mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_VND_LL_MESH);
mHttpPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_MESH2);
mHttpLegacyPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_MESH1);
@@ -781,22 +781,9 @@ LLMeshRepoThread::~LLMeshRepoThread()
delete *iter;
}
mHttpRequestSet.clear();
- if (mHttpHeaders)
- {
- mHttpHeaders->release();
- mHttpHeaders = NULL;
- }
- if (mHttpOptions)
- {
- mHttpOptions->release();
- mHttpOptions = NULL;
- }
- if (mHttpLargeOptions)
- {
- mHttpLargeOptions->release();
- mHttpLargeOptions = NULL;
- }
- delete mHttpRequest;
+ mHttpHeaders.reset();
+
+ delete mHttpRequest;
mHttpRequest = NULL;
delete mMutex;
mMutex = NULL;
@@ -1882,11 +1869,11 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data,
mMeshUploadTimeOut = gSavedSettings.getS32("MeshUploadTimeOut") ;
mHttpRequest = new LLCore::HttpRequest;
- mHttpOptions = new LLCore::HttpOptions;
+ mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);
mHttpOptions->setTransferTimeout(mMeshUploadTimeOut);
mHttpOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter"));
mHttpOptions->setRetries(UPLOAD_RETRY_LIMIT);
- mHttpHeaders = new LLCore::HttpHeaders;
+ mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders);
mHttpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML);
mHttpPolicyClass = LLAppViewer::instance()->getAppCoreHttp().getPolicy(LLAppCoreHttp::AP_UPLOADS);
mHttpPriority = 0;
@@ -1894,16 +1881,6 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data,
LLMeshUploadThread::~LLMeshUploadThread()
{
- if (mHttpHeaders)
- {
- mHttpHeaders->release();
- mHttpHeaders = NULL;
- }
- if (mHttpOptions)
- {
- mHttpOptions->release();
- mHttpOptions = NULL;
- }
delete mHttpRequest;
mHttpRequest = NULL;
}
diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h
index 39280bea3a..55157cc040 100755
--- a/indra/newview/llmeshrepository.h
+++ b/indra/newview/llmeshrepository.h
@@ -322,9 +322,9 @@ public:
// llcorehttp library interface objects.
LLCore::HttpStatus mHttpStatus;
LLCore::HttpRequest * mHttpRequest;
- LLCore::HttpOptions * mHttpOptions;
- LLCore::HttpOptions * mHttpLargeOptions;
- LLCore::HttpHeaders * mHttpHeaders;
+ LLCore::HttpOptions::ptr_t mHttpOptions;
+ LLCore::HttpOptions::ptr_t mHttpLargeOptions;
+ LLCore::HttpHeaders::ptr_t mHttpHeaders;
LLCore::HttpRequest::policy_t mHttpPolicyClass;
LLCore::HttpRequest::policy_t mHttpLegacyPolicyClass;
LLCore::HttpRequest::policy_t mHttpLargePolicyClass;
@@ -493,8 +493,8 @@ private:
// llcorehttp library interface objects.
LLCore::HttpStatus mHttpStatus;
LLCore::HttpRequest * mHttpRequest;
- LLCore::HttpOptions * mHttpOptions;
- LLCore::HttpHeaders * mHttpHeaders;
+ LLCore::HttpOptions::ptr_t mHttpOptions;
+ LLCore::HttpHeaders::ptr_t mHttpHeaders;
LLCore::HttpRequest::policy_t mHttpPolicyClass;
LLCore::HttpRequest::priority_t mHttpPriority;
};
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index f4b1ff7313..e61eeb2f4e 100755
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -1557,7 +1557,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
// Will call callbackHttpGet when curl request completes
// Only server bake images use the returned headers currently, for getting retry-after field.
- LLCore::HttpOptions *options = (mFTType == FTT_SERVER_BAKE) ? mFetcher->mHttpOptionsWithHeaders: mFetcher->mHttpOptions;
+ LLCore::HttpOptions::ptr_t options = (mFTType == FTT_SERVER_BAKE) ? mFetcher->mHttpOptionsWithHeaders: mFetcher->mHttpOptions;
if (disable_range_req)
{
// 'Range:' requests may be disabled in which case all HTTP
@@ -2509,11 +2509,11 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image
mTotalHTTPRequests(0),
mQAMode(qa_mode),
mHttpRequest(NULL),
- mHttpOptions(NULL),
- mHttpOptionsWithHeaders(NULL),
- mHttpHeaders(NULL),
+ mHttpOptions(),
+ mHttpOptionsWithHeaders(),
+ mHttpHeaders(),
mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID),
- mHttpMetricsHeaders(NULL),
+ mHttpMetricsHeaders(),
mHttpMetricsPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID),
mTotalCacheReadCount(0U),
mTotalCacheWriteCount(0U),
@@ -2528,13 +2528,13 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image
LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp());
mHttpRequest = new LLCore::HttpRequest;
- mHttpOptions = new LLCore::HttpOptions;
- mHttpOptionsWithHeaders = new LLCore::HttpOptions;
+ mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);
+ mHttpOptionsWithHeaders = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);
mHttpOptionsWithHeaders->setWantHeaders(true);
- mHttpHeaders = new LLCore::HttpHeaders;
+ mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders);
mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_IMAGE_X_J2C);
mHttpPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_TEXTURE);
- mHttpMetricsHeaders = new LLCore::HttpHeaders;
+ mHttpMetricsHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders);
mHttpMetricsHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML);
mHttpMetricsPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_REPORTING);
mHttpHighWater = HTTP_NONPIPE_REQUESTS_HIGH_WATER;
@@ -2568,30 +2568,6 @@ LLTextureFetch::~LLTextureFetch()
delete req;
}
- if (mHttpOptions)
- {
- mHttpOptions->release();
- mHttpOptions = NULL;
- }
-
- if (mHttpOptionsWithHeaders)
- {
- mHttpOptionsWithHeaders->release();
- mHttpOptionsWithHeaders = NULL;
- }
-
- if (mHttpHeaders)
- {
- mHttpHeaders->release();
- mHttpHeaders = NULL;
- }
-
- if (mHttpMetricsHeaders)
- {
- mHttpMetricsHeaders->release();
- mHttpMetricsHeaders = NULL;
- }
-
mHttpWaitResource.clear();
delete mHttpRequest;
@@ -4043,7 +4019,7 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
report_priority,
mCapsURL,
sd,
- NULL,
+ LLCore::HttpOptions::ptr_t(),
fetcher->getMetricsHeaders(),
handler);
LLTextureFetch::svMetricsDataBreak = false;
@@ -4162,7 +4138,7 @@ LLTextureFetchDebugger::LLTextureFetchDebugger(LLTextureFetch* fetcher, LLTextur
mFetcher(fetcher),
mTextureCache(cache),
mImageDecodeThread(imagedecodethread),
- mHttpHeaders(NULL),
+ mHttpHeaders(),
mHttpPolicyClass(fetcher->getPolicyClass()),
mNbCurlCompleted(0),
mTempIndex(0),
@@ -4176,11 +4152,6 @@ LLTextureFetchDebugger::~LLTextureFetchDebugger()
mFetchingHistory.clear();
mStopDebug = TRUE;
tryToStopDebug();
- if (mHttpHeaders)
- {
- mHttpHeaders->release();
- mHttpHeaders = NULL;
- }
}
void LLTextureFetchDebugger::init()
@@ -4225,7 +4196,7 @@ void LLTextureFetchDebugger::init()
if (! mHttpHeaders)
{
- mHttpHeaders = new LLCore::HttpHeaders;
+ mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders);
mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_IMAGE_X_J2C);
}
}
@@ -4625,7 +4596,7 @@ S32 LLTextureFetchDebugger::fillCurlQueue()
texture_url,
0,
requestedSize,
- NULL,
+ LLCore::HttpOptions::ptr_t(),
mHttpHeaders,
this);
if (LLCORE_HTTP_HANDLE_INVALID != handle)
diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h
index 27779a31e0..e569175e8f 100755
--- a/indra/newview/lltexturefetch.h
+++ b/indra/newview/lltexturefetch.h
@@ -177,7 +177,7 @@ public:
// to do that to hold a reference for any length of time.
//
// Threads: T*
- LLCore::HttpHeaders * getMetricsHeaders() const { return mHttpMetricsHeaders; }
+ LLCore::HttpHeaders::ptr_t getMetricsHeaders() const { return mHttpMetricsHeaders; }
// Threads: T*
LLCore::HttpRequest::policy_t getMetricsPolicyClass() const { return mHttpMetricsPolicyClass; }
@@ -354,11 +354,11 @@ private:
// to make our HTTP requests. These replace the various
// LLCurl interfaces used in the past.
LLCore::HttpRequest * mHttpRequest; // Ttf
- LLCore::HttpOptions * mHttpOptions; // Ttf
- LLCore::HttpOptions * mHttpOptionsWithHeaders; // Ttf
- LLCore::HttpHeaders * mHttpHeaders; // Ttf
+ LLCore::HttpOptions::ptr_t mHttpOptions; // Ttf
+ LLCore::HttpOptions::ptr_t mHttpOptionsWithHeaders; // Ttf
+ LLCore::HttpHeaders::ptr_t mHttpHeaders; // Ttf
LLCore::HttpRequest::policy_t mHttpPolicyClass; // T*
- LLCore::HttpHeaders * mHttpMetricsHeaders; // Ttf
+ LLCore::HttpHeaders::ptr_t mHttpMetricsHeaders; // Ttf
LLCore::HttpRequest::policy_t mHttpMetricsPolicyClass; // T*
S32 mHttpHighWater; // Ttf
S32 mHttpLowWater; // Ttf
@@ -510,7 +510,7 @@ private:
LLTextureFetch* mFetcher;
LLTextureCache* mTextureCache;
LLImageDecodeThread* mImageDecodeThread;
- LLCore::HttpHeaders* mHttpHeaders;
+ LLCore::HttpHeaders::ptr_t mHttpHeaders;
LLCore::HttpRequest::policy_t mHttpPolicyClass;
S32 mNumFetchedTextures;
diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp
index 717b14bb72..51001a51d2 100644
--- a/indra/newview/llviewerassetupload.cpp
+++ b/indra/newview/llviewerassetupload.cpp
@@ -28,7 +28,6 @@
#include "llviewerprecompiledheaders.h"
#include "linden_common.h"
-#include "llviewerassetupload.h"
#include "llviewertexturelist.h"
#include "llimage.h"
#include "lltrans.h"
@@ -43,6 +42,359 @@
#include "llstatusbar.h"
#include "llinventorypanel.h"
#include "llsdutil.h"
+#include "llviewerassetupload.h"
+#include "llappviewer.h"
+#include "llviewerstats.h"
+#include "llvfile.h"
+
+LLSD NewResourceUploadInfo::prepareUpload()
+{
+ if (mAssetId.isNull())
+ generateNewAssetId();
+
+ incrementUploadStats();
+ assignDefaults();
+
+ return LLSD().with("success", LLSD::Boolean(true));
+}
+
+std::string NewResourceUploadInfo::getAssetTypeString() const
+{
+ return LLAssetType::lookup(mAssetType);
+}
+
+std::string NewResourceUploadInfo::getInventoryTypeString() const
+{
+ return LLInventoryType::lookup(mInventoryType);
+}
+
+LLSD NewResourceUploadInfo::generatePostBody()
+{
+ LLSD body;
+
+ body["folder_id"] = mFolderId;
+ body["asset_type"] = getAssetTypeString();
+ body["inventory_type"] = getInventoryTypeString();
+ body["name"] = mName;
+ body["description"] = mDescription;
+ body["next_owner_mask"] = LLSD::Integer(mNextOwnerPerms);
+ body["group_mask"] = LLSD::Integer(mGroupPerms);
+ body["everyone_mask"] = LLSD::Integer(mEveryonePerms);
+
+ return body;
+
+}
+
+void NewResourceUploadInfo::logPreparedUpload()
+{
+ LL_INFOS() << "*** Uploading: " << std::endl <<
+ "Type: " << LLAssetType::lookup(mAssetType) << std::endl <<
+ "UUID: " << mAssetId.asString() << std::endl <<
+ "Name: " << mName << std::endl <<
+ "Desc: " << mDescription << std::endl <<
+ "Expected Upload Cost: " << mExpectedUploadCost << std::endl <<
+ "Folder: " << mFolderId << std::endl <<
+ "Asset Type: " << LLAssetType::lookup(mAssetType) << LL_ENDL;
+}
+
+LLUUID NewResourceUploadInfo::finishUpload(LLSD &result)
+{
+ if (getFolderId().isNull())
+ {
+ return LLUUID::null;
+ }
+
+ U32 permsEveryone = PERM_NONE;
+ U32 permsGroup = PERM_NONE;
+ U32 permsNextOwner = PERM_ALL;
+
+ if (result.has("new_next_owner_mask"))
+ {
+ // The server provided creation perms so use them.
+ // Do not assume we got the perms we asked for in
+ // since the server may not have granted them all.
+ permsEveryone = result["new_everyone_mask"].asInteger();
+ permsGroup = result["new_group_mask"].asInteger();
+ permsNextOwner = result["new_next_owner_mask"].asInteger();
+ }
+ else
+ {
+ // The server doesn't provide creation perms
+ // so use old assumption-based perms.
+ if (getAssetTypeString() != "snapshot")
+ {
+ permsNextOwner = PERM_MOVE | PERM_TRANSFER;
+ }
+ }
+
+ LLPermissions new_perms;
+ new_perms.init(
+ gAgent.getID(),
+ gAgent.getID(),
+ LLUUID::null,
+ LLUUID::null);
+
+ new_perms.initMasks(
+ PERM_ALL,
+ PERM_ALL,
+ permsEveryone,
+ permsGroup,
+ permsNextOwner);
+
+ U32 flagsInventoryItem = 0;
+ if (result.has("inventory_flags"))
+ {
+ flagsInventoryItem = static_cast<U32>(result["inventory_flags"].asInteger());
+ if (flagsInventoryItem != 0)
+ {
+ LL_INFOS() << "inventory_item_flags " << flagsInventoryItem << LL_ENDL;
+ }
+ }
+ S32 creationDate = time_corrected();
+
+ LLUUID serverInventoryItem = result["new_inventory_item"].asUUID();
+ LLUUID serverAssetId = result["new_asset"].asUUID();
+
+ LLPointer<LLViewerInventoryItem> item = new LLViewerInventoryItem(
+ serverInventoryItem,
+ getFolderId(),
+ new_perms,
+ serverAssetId,
+ getAssetType(),
+ getInventoryType(),
+ getName(),
+ getDescription(),
+ LLSaleInfo::DEFAULT,
+ flagsInventoryItem,
+ creationDate);
+
+ gInventory.updateItem(item);
+ gInventory.notifyObservers();
+
+ return serverInventoryItem;
+}
+
+
+LLAssetID NewResourceUploadInfo::generateNewAssetId()
+{
+ if (gDisconnected)
+ {
+ LLAssetID rv;
+
+ rv.setNull();
+ return rv;
+ }
+ mAssetId = mTransactionId.makeAssetID(gAgent.getSecureSessionID());
+
+ return mAssetId;
+}
+
+void NewResourceUploadInfo::incrementUploadStats() const
+{
+ if (LLAssetType::AT_SOUND == mAssetType)
+ {
+ add(LLStatViewer::UPLOAD_SOUND, 1);
+ }
+ else if (LLAssetType::AT_TEXTURE == mAssetType)
+ {
+ add(LLStatViewer::UPLOAD_TEXTURE, 1);
+ }
+ else if (LLAssetType::AT_ANIMATION == mAssetType)
+ {
+ add(LLStatViewer::ANIMATION_UPLOADS, 1);
+ }
+}
+
+void NewResourceUploadInfo::assignDefaults()
+{
+ if (LLInventoryType::IT_NONE == mInventoryType)
+ {
+ mInventoryType = LLInventoryType::defaultForAssetType(mAssetType);
+ }
+ LLStringUtil::stripNonprintable(mName);
+ LLStringUtil::stripNonprintable(mDescription);
+
+ if (mName.empty())
+ {
+ mName = "(No Name)";
+ }
+ if (mDescription.empty())
+ {
+ mDescription = "(No Description)";
+ }
+
+ mFolderId = gInventory.findCategoryUUIDForType(
+ (mDestinationFolderType == LLFolderType::FT_NONE) ?
+ (LLFolderType::EType)mAssetType : mDestinationFolderType);
+
+}
+
+std::string NewResourceUploadInfo::getDisplayName() const
+{
+ return (mName.empty()) ? mAssetId.asString() : mName;
+};
+
+//=========================================================================
+NewFileResourceUploadInfo::NewFileResourceUploadInfo(
+ std::string fileName,
+ std::string name,
+ std::string description,
+ S32 compressionInfo,
+ LLFolderType::EType destinationType,
+ LLInventoryType::EType inventoryType,
+ U32 nextOWnerPerms,
+ U32 groupPerms,
+ U32 everyonePerms,
+ S32 expectedCost) :
+ NewResourceUploadInfo(name, description, compressionInfo,
+ destinationType, inventoryType,
+ nextOWnerPerms, groupPerms, everyonePerms, expectedCost),
+ mFileName(fileName)
+{
+ LLTransactionID tid;
+ tid.generate();
+ setTransactionId(tid);
+}
+
+
+
+LLSD NewFileResourceUploadInfo::prepareUpload()
+{
+ generateNewAssetId();
+
+ LLSD result = exportTempFile();
+ if (result.has("error"))
+ return result;
+
+ return NewResourceUploadInfo::prepareUpload();
+}
+
+LLSD NewFileResourceUploadInfo::exportTempFile()
+{
+ std::string filename = gDirUtilp->getTempFilename();
+
+ std::string exten = gDirUtilp->getExtension(getFileName());
+ U32 codec = LLImageBase::getCodecFromExtension(exten);
+
+ LLAssetType::EType assetType = LLAssetType::AT_NONE;
+ std::string errorMessage;
+ std::string errorLabel;
+
+ bool error = false;
+
+ if (exten.empty())
+ {
+ std::string shortName = gDirUtilp->getBaseFileName(filename);
+
+ // No extension
+ errorMessage = llformat(
+ "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension",
+ shortName.c_str());
+ errorLabel = "NoFileExtension";
+ error = true;
+ }
+ else if (codec != IMG_CODEC_INVALID)
+ {
+ // It's an image file, the upload procedure is the same for all
+ assetType = LLAssetType::AT_TEXTURE;
+ if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec))
+ {
+ errorMessage = llformat("Problem with file %s:\n\n%s\n",
+ getFileName().c_str(), LLImage::getLastError().c_str());
+ errorLabel = "ProblemWithFile";
+ error = true;
+ }
+ }
+ else if (exten == "wav")
+ {
+ assetType = LLAssetType::AT_SOUND; // tag it as audio
+ S32 encodeResult = 0;
+
+ LL_INFOS() << "Attempting to encode wav as an ogg file" << LL_ENDL;
+
+ encodeResult = encode_vorbis_file(getFileName(), filename);
+
+ if (LLVORBISENC_NOERR != encodeResult)
+ {
+ switch (encodeResult)
+ {
+ case LLVORBISENC_DEST_OPEN_ERR:
+ errorMessage = llformat("Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str());
+ errorLabel = "CannotOpenTemporarySoundFile";
+ break;
+
+ default:
+ errorMessage = llformat("Unknown vorbis encode failure on: %s\n", getFileName().c_str());
+ errorLabel = "UnknownVorbisEncodeFailure";
+ break;
+ }
+ error = true;
+ }
+ }
+ else if (exten == "bvh")
+ {
+ errorMessage = llformat("We do not currently support bulk upload of animation files\n");
+ errorLabel = "DoNotSupportBulkAnimationUpload";
+ error = true;
+ }
+ else if (exten == "anim")
+ {
+ assetType = LLAssetType::AT_ANIMATION;
+ filename = getFileName();
+ }
+ else
+ {
+ // Unknown extension
+ errorMessage = llformat(LLTrans::getString("UnknownFileExtension").c_str(), exten.c_str());
+ errorLabel = "ErrorMessage";
+ error = TRUE;;
+ }
+
+ if (error)
+ {
+ LLSD errorResult(LLSD::emptyMap());
+
+ errorResult["error"] = LLSD::Binary(true);
+ errorResult["message"] = errorMessage;
+ errorResult["label"] = errorLabel;
+ return errorResult;
+ }
+
+ setAssetType(assetType);
+
+ // copy this file into the vfs for upload
+ S32 file_size;
+ LLAPRFile infile;
+ infile.open(filename, LL_APR_RB, NULL, &file_size);
+ if (infile.getFileHandle())
+ {
+ LLVFile file(gVFS, getAssetId(), assetType, LLVFile::WRITE);
+
+ file.setMaxSize(file_size);
+
+ const S32 buf_size = 65536;
+ U8 copy_buf[buf_size];
+ while ((file_size = infile.read(copy_buf, buf_size)))
+ {
+ file.write(copy_buf, file_size);
+ }
+ }
+ else
+ {
+ errorMessage = llformat("Unable to access output file: %s", filename.c_str());
+ LLSD errorResult(LLSD::emptyMap());
+
+ errorResult["error"] = LLSD::Binary(true);
+ errorResult["message"] = errorMessage;
+ return errorResult;
+ }
+
+ return LLSD();
+
+}
+
+//=========================================================================
+
//=========================================================================
/*static*/
@@ -203,3 +555,4 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res
}
}
+
diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h
index 38167fc0c7..119a5bc3e8 100644
--- a/indra/newview/llviewerassetupload.h
+++ b/indra/newview/llviewerassetupload.h
@@ -35,7 +35,160 @@
#include "llcoros.h"
#include "llcorehttputil.h"
-#include "llviewermenufile.h"
+class NewResourceUploadInfo
+{
+public:
+ typedef boost::shared_ptr<NewResourceUploadInfo> ptr_t;
+
+ NewResourceUploadInfo(
+ LLTransactionID transactId,
+ LLAssetType::EType assetType,
+ std::string name,
+ std::string description,
+ S32 compressionInfo,
+ LLFolderType::EType destinationType,
+ LLInventoryType::EType inventoryType,
+ U32 nextOWnerPerms,
+ U32 groupPerms,
+ U32 everyonePerms,
+ S32 expectedCost) :
+ mTransactionId(transactId),
+ mAssetType(assetType),
+ mName(name),
+ mDescription(description),
+ mCompressionInfo(compressionInfo),
+ mDestinationFolderType(destinationType),
+ mInventoryType(inventoryType),
+ mNextOwnerPerms(nextOWnerPerms),
+ mGroupPerms(groupPerms),
+ mEveryonePerms(everyonePerms),
+ mExpectedUploadCost(expectedCost),
+ mFolderId(LLUUID::null),
+ mItemId(LLUUID::null),
+ mAssetId(LLAssetID::null)
+ { }
+
+ virtual ~NewResourceUploadInfo()
+ { }
+
+ virtual LLSD prepareUpload();
+ virtual LLSD generatePostBody();
+ virtual void logPreparedUpload();
+ virtual LLUUID finishUpload(LLSD &result);
+
+ LLTransactionID getTransactionId() const { return mTransactionId; }
+ LLAssetType::EType getAssetType() const { return mAssetType; }
+ std::string getAssetTypeString() const;
+ std::string getName() const { return mName; };
+ std::string getDescription() const { return mDescription; };
+ S32 getCompressionInfo() const { return mCompressionInfo; };
+ LLFolderType::EType getDestinationFolderType() const { return mDestinationFolderType; };
+ LLInventoryType::EType getInventoryType() const { return mInventoryType; };
+ std::string getInventoryTypeString() const;
+ U32 getNextOwnerPerms() const { return mNextOwnerPerms; };
+ U32 getGroupPerms() const { return mGroupPerms; };
+ U32 getEveryonePerms() const { return mEveryonePerms; };
+ S32 getExpectedUploadCost() const { return mExpectedUploadCost; };
+
+ virtual std::string getDisplayName() const;
+
+ LLUUID getFolderId() const { return mFolderId; }
+ LLUUID getItemId() const { return mItemId; }
+ LLAssetID getAssetId() const { return mAssetId; }
+
+protected:
+ NewResourceUploadInfo(
+ std::string name,
+ std::string description,
+ S32 compressionInfo,
+ LLFolderType::EType destinationType,
+ LLInventoryType::EType inventoryType,
+ U32 nextOWnerPerms,
+ U32 groupPerms,
+ U32 everyonePerms,
+ S32 expectedCost) :
+ mName(name),
+ mDescription(description),
+ mCompressionInfo(compressionInfo),
+ mDestinationFolderType(destinationType),
+ mInventoryType(inventoryType),
+ mNextOwnerPerms(nextOWnerPerms),
+ mGroupPerms(groupPerms),
+ mEveryonePerms(everyonePerms),
+ mExpectedUploadCost(expectedCost),
+ mTransactionId(),
+ mAssetType(LLAssetType::AT_NONE),
+ mFolderId(LLUUID::null),
+ mItemId(LLUUID::null),
+ mAssetId(LLAssetID::null)
+ { }
+
+ void setTransactionId(LLTransactionID tid) { mTransactionId = tid; }
+ void setAssetType(LLAssetType::EType assetType) { mAssetType = assetType; }
+
+ LLAssetID generateNewAssetId();
+ void incrementUploadStats() const;
+ virtual void assignDefaults();
+
+private:
+ LLTransactionID mTransactionId;
+ LLAssetType::EType mAssetType;
+ std::string mName;
+ std::string mDescription;
+ S32 mCompressionInfo;
+ LLFolderType::EType mDestinationFolderType;
+ LLInventoryType::EType mInventoryType;
+ U32 mNextOwnerPerms;
+ U32 mGroupPerms;
+ U32 mEveryonePerms;
+ S32 mExpectedUploadCost;
+
+ LLUUID mFolderId;
+ LLUUID mItemId;
+ LLAssetID mAssetId;
+};
+
+class NewFileResourceUploadInfo : public NewResourceUploadInfo
+{
+public:
+ NewFileResourceUploadInfo(
+ std::string fileName,
+ std::string name,
+ std::string description,
+ S32 compressionInfo,
+ LLFolderType::EType destinationType,
+ LLInventoryType::EType inventoryType,
+ U32 nextOWnerPerms,
+ U32 groupPerms,
+ U32 everyonePerms,
+ S32 expectedCost);
+
+ virtual LLSD prepareUpload();
+
+ std::string getFileName() const { return mFileName; };
+
+protected:
+
+ virtual LLSD exportTempFile();
+
+private:
+ std::string mFileName;
+
+};
+
+#if 0
+class NotecardResourceUploadInfo : public NewResourceUploadInfo
+{
+public:
+ NotecardResourceUploadInfo(
+ );
+
+
+protected:
+
+private:
+};
+#endif
class LLViewerAssetUpload
{
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 20fbfaf71a..9c4045fa1e 100755
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -451,39 +451,6 @@ class LLFileUploadBulk : public view_listener_t
filename = picker.getNextFile();
}
-#if 0
- const std::string& filename = picker.getFirstFile();
- std::string name = gDirUtilp->getBaseFileName(filename, true);
-
- std::string asset_name = name;
- LLStringUtil::replaceNonstandardASCII( asset_name, '?' );
- LLStringUtil::replaceChar(asset_name, '|', '?');
- LLStringUtil::stripNonprintable(asset_name);
- LLStringUtil::trim(asset_name);
-
- std::string display_name = LLStringUtil::null;
- LLAssetStorage::LLStoreAssetCallback callback = NULL;
- S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
- void *userdata = NULL;
-
- upload_new_resource(
- filename,
- asset_name,
- asset_name,
- 0,
- LLFolderType::FT_NONE,
- LLInventoryType::IT_NONE,
- LLFloaterPerms::getNextOwnerPerms("Uploads"),
- LLFloaterPerms::getGroupPerms("Uploads"),
- LLFloaterPerms::getEveryonePerms("Uploads"),
- display_name,
- callback,
- expected_upload_cost,
- userdata);
-
- // *NOTE: Ew, we don't iterate over the file list here,
- // we handle the next files in upload_done_callback()
-#endif
}
else
{
@@ -678,151 +645,6 @@ LLUUID upload_new_resource(
upload_new_resource(uploadInfo, callback, userdata);
return LLUUID::null;
-
-#if 0
- // Generate the temporary UUID.
- std::string filename = gDirUtilp->getTempFilename();
- LLTransactionID tid;
- LLAssetID uuid;
-
- LLSD args;
-
- std::string exten = gDirUtilp->getExtension(src_filename);
- U32 codec = LLImageBase::getCodecFromExtension(exten);
- LLAssetType::EType asset_type = LLAssetType::AT_NONE;
- std::string error_message;
-
- BOOL error = FALSE;
-
- if (exten.empty())
- {
- std::string short_name = gDirUtilp->getBaseFileName(filename);
-
- // No extension
- error_message = llformat(
- "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension",
- short_name.c_str());
- args["FILE"] = short_name;
- upload_error(error_message, "NoFileExtension", filename, args);
- return LLUUID();
- }
- else if (codec != IMG_CODEC_INVALID)
- {
- // It's an image file, the upload procedure is the same for all
- asset_type = LLAssetType::AT_TEXTURE;
- if (!LLViewerTextureList::createUploadFile(src_filename, filename, codec ))
- {
- error_message = llformat( "Problem with file %s:\n\n%s\n",
- src_filename.c_str(), LLImage::getLastError().c_str());
- args["FILE"] = src_filename;
- args["ERROR"] = LLImage::getLastError();
- upload_error(error_message, "ProblemWithFile", filename, args);
- return LLUUID();
- }
- }
- else if(exten == "wav")
- {
- asset_type = LLAssetType::AT_SOUND; // tag it as audio
- S32 encode_result = 0;
-
- LL_INFOS() << "Attempting to encode wav as an ogg file" << LL_ENDL;
-
- encode_result = encode_vorbis_file(src_filename, filename);
-
- if (LLVORBISENC_NOERR != encode_result)
- {
- switch(encode_result)
- {
- case LLVORBISENC_DEST_OPEN_ERR:
- error_message = llformat( "Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str());
- args["FILE"] = filename;
- upload_error(error_message, "CannotOpenTemporarySoundFile", filename, args);
- break;
-
- default:
- error_message = llformat("Unknown vorbis encode failure on: %s\n", src_filename.c_str());
- args["FILE"] = src_filename;
- upload_error(error_message, "UnknownVorbisEncodeFailure", filename, args);
- break;
- }
- return LLUUID();
- }
- }
- else if (exten == "bvh")
- {
- error_message = llformat("We do not currently support bulk upload of animation files\n");
- upload_error(error_message, "DoNotSupportBulkAnimationUpload", filename, args);
- return LLUUID();
- }
- else if (exten == "anim")
- {
- asset_type = LLAssetType::AT_ANIMATION;
- filename = src_filename;
- }
- else
- {
- // Unknown extension
- error_message = llformat(LLTrans::getString("UnknownFileExtension").c_str(), exten.c_str());
- error = TRUE;;
- }
-
- // gen a new transaction ID for this asset
- tid.generate();
-
- if (!error)
- {
- uuid = tid.makeAssetID(gAgent.getSecureSessionID());
- // copy this file into the vfs for upload
- S32 file_size;
- LLAPRFile infile ;
- infile.open(filename, LL_APR_RB, NULL, &file_size);
- if (infile.getFileHandle())
- {
- LLVFile file(gVFS, uuid, asset_type, LLVFile::WRITE);
-
- file.setMaxSize(file_size);
-
- const S32 buf_size = 65536;
- U8 copy_buf[buf_size];
- while ((file_size = infile.read(copy_buf, buf_size)))
- {
- file.write(copy_buf, file_size);
- }
- }
- else
- {
- error_message = llformat( "Unable to access output file: %s", filename.c_str());
- error = TRUE;
- }
- }
-
- if (!error)
- {
- NewResourceUploadInfo::ptr_t uploadInfo(new NewResourceUploadInfo(
- tid, asset_type,
- name, desc, compression_info,
- destination_folder_type, inv_type,
- next_owner_perms, group_perms, everyone_perms,
- expected_upload_cost));
-
- upload_new_resource(uploadInfo,
- callback, userdata);
- }
- else
- {
- LL_WARNS() << error_message << LL_ENDL;
- LLSD args;
- args["ERROR_MESSAGE"] = error_message;
- LLNotificationsUtil::add("ErrorMessage", args);
- if(LLFile::remove(filename) == -1)
- {
- LL_DEBUGS() << "unable to remove temp file" << LL_ENDL;
- }
- LLFilePicker::instance().reset();
- }
-
- return uuid;
-#endif
}
void upload_done_callback(
@@ -1047,349 +869,3 @@ void init_menu_file()
// "File.SaveTexture" moved to llpanelmaininventory so that it can be properly handled.
}
-
-LLSD NewResourceUploadInfo::prepareUpload()
-{
- if (mAssetId.isNull())
- generateNewAssetId();
-
- incrementUploadStats();
- assignDefaults();
-
- return LLSD().with("success", LLSD::Boolean(true));
-}
-
-std::string NewResourceUploadInfo::getAssetTypeString() const
-{
- return LLAssetType::lookup(mAssetType);
-}
-
-std::string NewResourceUploadInfo::getInventoryTypeString() const
-{
- return LLInventoryType::lookup(mInventoryType);
-}
-
-LLSD NewResourceUploadInfo::generatePostBody()
-{
- LLSD body;
-
- body["folder_id"] = mFolderId;
- body["asset_type"] = getAssetTypeString();
- body["inventory_type"] = getInventoryTypeString();
- body["name"] = mName;
- body["description"] = mDescription;
- body["next_owner_mask"] = LLSD::Integer(mNextOwnerPerms);
- body["group_mask"] = LLSD::Integer(mGroupPerms);
- body["everyone_mask"] = LLSD::Integer(mEveryonePerms);
-
- return body;
-
-}
-
-void NewResourceUploadInfo::logPreparedUpload()
-{
- LL_INFOS() << "*** Uploading: " << std::endl <<
- "Type: " << LLAssetType::lookup(mAssetType) << std::endl <<
- "UUID: " << mAssetId.asString() << std::endl <<
- "Name: " << mName << std::endl <<
- "Desc: " << mDescription << std::endl <<
- "Expected Upload Cost: " << mExpectedUploadCost << std::endl <<
- "Folder: " << mFolderId << std::endl <<
- "Asset Type: " << LLAssetType::lookup(mAssetType) << LL_ENDL;
-}
-
-LLUUID NewResourceUploadInfo::finishUpload(LLSD &result)
-{
- if (getFolderId().isNull())
- {
- return LLUUID::null;
- }
-
- U32 permsEveryone = PERM_NONE;
- U32 permsGroup = PERM_NONE;
- U32 permsNextOwner = PERM_ALL;
-
- if (result.has("new_next_owner_mask"))
- {
- // The server provided creation perms so use them.
- // Do not assume we got the perms we asked for in
- // since the server may not have granted them all.
- permsEveryone = result["new_everyone_mask"].asInteger();
- permsGroup = result["new_group_mask"].asInteger();
- permsNextOwner = result["new_next_owner_mask"].asInteger();
- }
- else
- {
- // The server doesn't provide creation perms
- // so use old assumption-based perms.
- if (getAssetTypeString() != "snapshot")
- {
- permsNextOwner = PERM_MOVE | PERM_TRANSFER;
- }
- }
-
- LLPermissions new_perms;
- new_perms.init(
- gAgent.getID(),
- gAgent.getID(),
- LLUUID::null,
- LLUUID::null);
-
- new_perms.initMasks(
- PERM_ALL,
- PERM_ALL,
- permsEveryone,
- permsGroup,
- permsNextOwner);
-
- U32 flagsInventoryItem = 0;
- if (result.has("inventory_flags"))
- {
- flagsInventoryItem = static_cast<U32>(result["inventory_flags"].asInteger());
- if (flagsInventoryItem != 0)
- {
- LL_INFOS() << "inventory_item_flags " << flagsInventoryItem << LL_ENDL;
- }
- }
- S32 creationDate = time_corrected();
-
- LLUUID serverInventoryItem = result["new_inventory_item"].asUUID();
- LLUUID serverAssetId = result["new_asset"].asUUID();
-
- LLPointer<LLViewerInventoryItem> item = new LLViewerInventoryItem(
- serverInventoryItem,
- getFolderId(),
- new_perms,
- serverAssetId,
- getAssetType(),
- getInventoryType(),
- getName(),
- getDescription(),
- LLSaleInfo::DEFAULT,
- flagsInventoryItem,
- creationDate);
-
- gInventory.updateItem(item);
- gInventory.notifyObservers();
-
- return serverInventoryItem;
-}
-
-
-LLAssetID NewResourceUploadInfo::generateNewAssetId()
-{
- if (gDisconnected)
- {
- LLAssetID rv;
-
- rv.setNull();
- return rv;
- }
- mAssetId = mTransactionId.makeAssetID(gAgent.getSecureSessionID());
-
- return mAssetId;
-}
-
-void NewResourceUploadInfo::incrementUploadStats() const
-{
- if (LLAssetType::AT_SOUND == mAssetType)
- {
- add(LLStatViewer::UPLOAD_SOUND, 1);
- }
- else if (LLAssetType::AT_TEXTURE == mAssetType)
- {
- add(LLStatViewer::UPLOAD_TEXTURE, 1);
- }
- else if (LLAssetType::AT_ANIMATION == mAssetType)
- {
- add(LLStatViewer::ANIMATION_UPLOADS, 1);
- }
-}
-
-void NewResourceUploadInfo::assignDefaults()
-{
- if (LLInventoryType::IT_NONE == mInventoryType)
- {
- mInventoryType = LLInventoryType::defaultForAssetType(mAssetType);
- }
- LLStringUtil::stripNonprintable(mName);
- LLStringUtil::stripNonprintable(mDescription);
-
- if (mName.empty())
- {
- mName = "(No Name)";
- }
- if (mDescription.empty())
- {
- mDescription = "(No Description)";
- }
-
- mFolderId = gInventory.findCategoryUUIDForType(
- (mDestinationFolderType == LLFolderType::FT_NONE) ?
- (LLFolderType::EType)mAssetType : mDestinationFolderType);
-
-}
-
-std::string NewResourceUploadInfo::getDisplayName() const
-{
- return (mName.empty()) ? mAssetId.asString() : mName;
-};
-
-
-NewFileResourceUploadInfo::NewFileResourceUploadInfo(
- std::string fileName,
- std::string name,
- std::string description,
- S32 compressionInfo,
- LLFolderType::EType destinationType,
- LLInventoryType::EType inventoryType,
- U32 nextOWnerPerms,
- U32 groupPerms,
- U32 everyonePerms,
- S32 expectedCost):
- NewResourceUploadInfo(name, description, compressionInfo,
- destinationType, inventoryType,
- nextOWnerPerms, groupPerms, everyonePerms, expectedCost),
- mFileName(fileName)
-{
- LLTransactionID tid;
- tid.generate();
- setTransactionId(tid);
-}
-
-
-
-LLSD NewFileResourceUploadInfo::prepareUpload()
-{
- generateNewAssetId();
-
- LLSD result = exportTempFile();
- if (result.has("error"))
- return result;
-
- return NewResourceUploadInfo::prepareUpload();
-}
-
-LLSD NewFileResourceUploadInfo::exportTempFile()
-{
- std::string filename = gDirUtilp->getTempFilename();
-
- std::string exten = gDirUtilp->getExtension(getFileName());
- U32 codec = LLImageBase::getCodecFromExtension(exten);
-
- LLAssetType::EType assetType = LLAssetType::AT_NONE;
- std::string errorMessage;
- std::string errorLabel;
-
- bool error = false;
-
- if (exten.empty())
- {
- std::string shortName = gDirUtilp->getBaseFileName(filename);
-
- // No extension
- errorMessage = llformat(
- "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension",
- shortName.c_str());
- errorLabel = "NoFileExtension";
- error = true;
- }
- else if (codec != IMG_CODEC_INVALID)
- {
- // It's an image file, the upload procedure is the same for all
- assetType = LLAssetType::AT_TEXTURE;
- if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec))
- {
- errorMessage = llformat("Problem with file %s:\n\n%s\n",
- getFileName().c_str(), LLImage::getLastError().c_str());
- errorLabel = "ProblemWithFile";
- error = true;
- }
- }
- else if (exten == "wav")
- {
- assetType = LLAssetType::AT_SOUND; // tag it as audio
- S32 encodeResult = 0;
-
- LL_INFOS() << "Attempting to encode wav as an ogg file" << LL_ENDL;
-
- encodeResult = encode_vorbis_file(getFileName(), filename);
-
- if (LLVORBISENC_NOERR != encodeResult)
- {
- switch (encodeResult)
- {
- case LLVORBISENC_DEST_OPEN_ERR:
- errorMessage = llformat("Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str());
- errorLabel = "CannotOpenTemporarySoundFile";
- break;
-
- default:
- errorMessage = llformat("Unknown vorbis encode failure on: %s\n", getFileName().c_str());
- errorLabel = "UnknownVorbisEncodeFailure";
- break;
- }
- error = true;
- }
- }
- else if (exten == "bvh")
- {
- errorMessage = llformat("We do not currently support bulk upload of animation files\n");
- errorLabel = "DoNotSupportBulkAnimationUpload";
- error = true;
- }
- else if (exten == "anim")
- {
- assetType = LLAssetType::AT_ANIMATION;
- filename = getFileName();
- }
- else
- {
- // Unknown extension
- errorMessage = llformat(LLTrans::getString("UnknownFileExtension").c_str(), exten.c_str());
- errorLabel = "ErrorMessage";
- error = TRUE;;
- }
-
- if (error)
- {
- LLSD errorResult(LLSD::emptyMap());
-
- errorResult["error"] = LLSD::Binary(true);
- errorResult["message"] = errorMessage;
- errorResult["label"] = errorLabel;
- return errorResult;
- }
-
- setAssetType(assetType);
-
- // copy this file into the vfs for upload
- S32 file_size;
- LLAPRFile infile;
- infile.open(filename, LL_APR_RB, NULL, &file_size);
- if (infile.getFileHandle())
- {
- LLVFile file(gVFS, getAssetId(), assetType, LLVFile::WRITE);
-
- file.setMaxSize(file_size);
-
- const S32 buf_size = 65536;
- U8 copy_buf[buf_size];
- while ((file_size = infile.read(copy_buf, buf_size)))
- {
- file.write(copy_buf, file_size);
- }
- }
- else
- {
- errorMessage = llformat("Unable to access output file: %s", filename.c_str());
- LLSD errorResult(LLSD::emptyMap());
-
- errorResult["error"] = LLSD::Binary(true);
- errorResult["message"] = errorMessage;
- return errorResult;
- }
-
- return LLSD();
-
-}
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index 7ee5043777..616eaed373 100755
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -34,155 +34,13 @@
#include "llthread.h"
#include <queue>
+#include "llviewerassetupload.h"
+
class LLTransactionID;
void init_menu_file();
-class NewResourceUploadInfo
-{
-public:
- typedef boost::shared_ptr<NewResourceUploadInfo> ptr_t;
-
- NewResourceUploadInfo(
- LLTransactionID transactId,
- LLAssetType::EType assetType,
- std::string name,
- std::string description,
- S32 compressionInfo,
- LLFolderType::EType destinationType,
- LLInventoryType::EType inventoryType,
- U32 nextOWnerPerms,
- U32 groupPerms,
- U32 everyonePerms,
- S32 expectedCost) :
- mTransactionId(transactId),
- mAssetType(assetType),
- mName(name),
- mDescription(description),
- mCompressionInfo(compressionInfo),
- mDestinationFolderType(destinationType),
- mInventoryType(inventoryType),
- mNextOwnerPerms(nextOWnerPerms),
- mGroupPerms(groupPerms),
- mEveryonePerms(everyonePerms),
- mExpectedUploadCost(expectedCost),
- mFolderId(LLUUID::null),
- mItemId(LLUUID::null),
- mAssetId(LLAssetID::null)
- { }
-
- virtual ~NewResourceUploadInfo()
- { }
-
- virtual LLSD prepareUpload();
- virtual LLSD generatePostBody();
- virtual void logPreparedUpload();
- virtual LLUUID finishUpload(LLSD &result);
-
- //void setAssetType(LLAssetType::EType assetType) { mAssetType = assetType; }
- //void setTransactionId(LLTransactionID transactionId) { mTransactionId = transactionId; }
-
- LLTransactionID getTransactionId() const { return mTransactionId; }
- LLAssetType::EType getAssetType() const { return mAssetType; }
- std::string getAssetTypeString() const;
- std::string getName() const { return mName; };
- std::string getDescription() const { return mDescription; };
- S32 getCompressionInfo() const { return mCompressionInfo; };
- LLFolderType::EType getDestinationFolderType() const { return mDestinationFolderType; };
- LLInventoryType::EType getInventoryType() const { return mInventoryType; };
- std::string getInventoryTypeString() const;
- U32 getNextOwnerPerms() const { return mNextOwnerPerms; };
- U32 getGroupPerms() const { return mGroupPerms; };
- U32 getEveryonePerms() const { return mEveryonePerms; };
- S32 getExpectedUploadCost() const { return mExpectedUploadCost; };
-
- virtual std::string getDisplayName() const;
-
- LLUUID getFolderId() const { return mFolderId; }
- LLUUID getItemId() const { return mItemId; }
- LLAssetID getAssetId() const { return mAssetId; }
-
-protected:
- NewResourceUploadInfo(
- std::string name,
- std::string description,
- S32 compressionInfo,
- LLFolderType::EType destinationType,
- LLInventoryType::EType inventoryType,
- U32 nextOWnerPerms,
- U32 groupPerms,
- U32 everyonePerms,
- S32 expectedCost) :
- mName(name),
- mDescription(description),
- mCompressionInfo(compressionInfo),
- mDestinationFolderType(destinationType),
- mInventoryType(inventoryType),
- mNextOwnerPerms(nextOWnerPerms),
- mGroupPerms(groupPerms),
- mEveryonePerms(everyonePerms),
- mExpectedUploadCost(expectedCost),
- mTransactionId(),
- mAssetType(LLAssetType::AT_NONE),
- mFolderId(LLUUID::null),
- mItemId(LLUUID::null),
- mAssetId(LLAssetID::null)
- { }
-
- void setTransactionId(LLTransactionID tid) { mTransactionId = tid; }
- void setAssetType(LLAssetType::EType assetType) { mAssetType = assetType; }
-
- LLAssetID generateNewAssetId();
- void incrementUploadStats() const;
- virtual void assignDefaults();
-
-private:
- LLTransactionID mTransactionId;
- LLAssetType::EType mAssetType;
- std::string mName;
- std::string mDescription;
- S32 mCompressionInfo;
- LLFolderType::EType mDestinationFolderType;
- LLInventoryType::EType mInventoryType;
- U32 mNextOwnerPerms;
- U32 mGroupPerms;
- U32 mEveryonePerms;
- S32 mExpectedUploadCost;
-
- LLUUID mFolderId;
- LLUUID mItemId;
- LLAssetID mAssetId;
-};
-
-class NewFileResourceUploadInfo : public NewResourceUploadInfo
-{
-public:
- NewFileResourceUploadInfo(
- std::string fileName,
- std::string name,
- std::string description,
- S32 compressionInfo,
- LLFolderType::EType destinationType,
- LLInventoryType::EType inventoryType,
- U32 nextOWnerPerms,
- U32 groupPerms,
- U32 everyonePerms,
- S32 expectedCost);
-
- virtual LLSD prepareUpload();
-
- std::string getFileName() const { return mFileName; };
-
-protected:
-
- virtual LLSD exportTempFile();
-
-private:
- std::string mFileName;
-
-};
-
LLUUID upload_new_resource(
const std::string& src_filename,
diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp
index 066970614a..5828aee7fc 100755
--- a/indra/newview/llxmlrpctransaction.cpp
+++ b/indra/newview/llxmlrpctransaction.cpp
@@ -390,7 +390,7 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip)
mHandler = LLXMLRPCTransaction::Handler::ptr_t(new Handler( mHttpRequest, this ));
mPostH = mHttpRequest->requestPost(LLCore::HttpRequest::DEFAULT_POLICY_ID, 0,
- mURI, body.get(), httpOpts.get(), httpHeaders.get(), mHandler.get());
+ mURI, body.get(), httpOpts, httpHeaders, mHandler.get());
}
diff --git a/indra/newview/tests/llhttpretrypolicy_test.cpp b/indra/newview/tests/llhttpretrypolicy_test.cpp
index 25e6de46d9..8bd6cc2690 100755
--- a/indra/newview/tests/llhttpretrypolicy_test.cpp
+++ b/indra/newview/tests/llhttpretrypolicy_test.cpp
@@ -285,10 +285,10 @@ void RetryPolicyTestObject::test<7>()
ensure_approximately_equals_range("header 2", seconds_to_wait, 7.0F, 2.0F);
LLCore::HttpResponse *response;
- LLCore::HttpHeaders *headers;
+ LLCore::HttpHeaders::ptr_t headers;
response = new LLCore::HttpResponse();
- headers = new LLCore::HttpHeaders();
+ headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders());
response->setStatus(503);
response->setHeaders(headers);
headers->append(HTTP_IN_HEADER_RETRY_AFTER, std::string("600"));
@@ -299,7 +299,7 @@ void RetryPolicyTestObject::test<7>()
response->release();
response = new LLCore::HttpResponse();
- headers = new LLCore::HttpHeaders();
+ headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders());
response->setStatus(503);
response->setHeaders(headers);
time(&nowseconds);