Skip to content
Snippets Groups Projects
Commit b34163be authored by Rider Linden's avatar Rider Linden
Browse files

Merge

parents 247eb0c9 d8c02a28
No related branches found
No related tags found
No related merge requests found
...@@ -64,12 +64,14 @@ ...@@ -64,12 +64,14 @@
// Boost.Coroutine #include is the *first* #include of the platform header. // Boost.Coroutine #include is the *first* #include of the platform header.
// That means that client code must generally #include Boost.Coroutine headers // That means that client code must generally #include Boost.Coroutine headers
// before anything else. // before anything else.
#define BOOST_RESULT_OF_USE_TR1 1
#include <boost/dcoroutine/coroutine.hpp> #include <boost/dcoroutine/coroutine.hpp>
// Normally, lleventcoro.h obviates future.hpp. We only include this because // Normally, lleventcoro.h obviates future.hpp. We only include this because
// we implement a "by hand" test of future functionality. // we implement a "by hand" test of future functionality.
#include <boost/dcoroutine/future.hpp> #include <boost/dcoroutine/future.hpp>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/range.hpp> #include <boost/range.hpp>
#include <boost/utility.hpp>
#include "linden_common.h" #include "linden_common.h"
......
...@@ -261,7 +261,7 @@ if (LL_TESTS) ...@@ -261,7 +261,7 @@ if (LL_TESTS)
${GOOGLEMOCK_LIBRARIES} ${GOOGLEMOCK_LIBRARIES}
) )
LL_ADD_INTEGRATION_TEST(llavatarnamecache "" "${test_libs}") #LL_ADD_INTEGRATION_TEST(llavatarnamecache "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llhost "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llhost "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llpartdata "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llpartdata "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llxfer_file "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llxfer_file "" "${test_libs}")
......
...@@ -164,6 +164,19 @@ void LLFloaterNameDesc::onBtnOK( ) ...@@ -164,6 +164,19 @@ void LLFloaterNameDesc::onBtnOK( )
void *nruserdata = NULL; void *nruserdata = NULL;
std::string display_name = LLStringUtil::null; std::string display_name = LLStringUtil::null;
NewResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo(
mFilenameAndPath,
getChild<LLUICtrl>("name_form")->getValue().asString(),
getChild<LLUICtrl>("description_form")->getValue().asString(), 0,
LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
LLFloaterPerms::getNextOwnerPerms("Uploads"),
LLFloaterPerms::getGroupPerms("Uploads"),
LLFloaterPerms::getEveryonePerms("Uploads"),
expected_upload_cost));
upload_new_resource(uploadInfo, callback, nruserdata);
#if 0
upload_new_resource(mFilenameAndPath, // file upload_new_resource(mFilenameAndPath, // file
getChild<LLUICtrl>("name_form")->getValue().asString(), getChild<LLUICtrl>("name_form")->getValue().asString(),
getChild<LLUICtrl>("description_form")->getValue().asString(), getChild<LLUICtrl>("description_form")->getValue().asString(),
...@@ -172,6 +185,8 @@ void LLFloaterNameDesc::onBtnOK( ) ...@@ -172,6 +185,8 @@ void LLFloaterNameDesc::onBtnOK( )
LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"),
LLFloaterPerms::getEveryonePerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"),
display_name, callback, expected_upload_cost, nruserdata); display_name, callback, expected_upload_cost, nruserdata);
#endif
closeFloater(false); closeFloater(false);
} }
......
...@@ -163,12 +163,12 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res ...@@ -163,12 +163,12 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res
if (result.has("label")) if (result.has("label"))
{ {
label = result["label"]; label = result["label"].asString();
} }
if (result.has("message")) if (result.has("message"))
{ {
reason = result["message"]; reason = result["message"].asString();
} }
else else
{ {
......
...@@ -413,7 +413,6 @@ class LLFileUploadBulk : public view_listener_t ...@@ -413,7 +413,6 @@ class LLFileUploadBulk : public view_listener_t
} }
// TODO: // TODO:
// Iterate over all files
// Check extensions for uploadability, cost // Check extensions for uploadability, cost
// Check user balance for entire cost // Check user balance for entire cost
// Charge user entire cost // Charge user entire cost
...@@ -425,6 +424,34 @@ class LLFileUploadBulk : public view_listener_t ...@@ -425,6 +424,34 @@ class LLFileUploadBulk : public view_listener_t
LLFilePicker& picker = LLFilePicker::instance(); LLFilePicker& picker = LLFilePicker::instance();
if (picker.getMultipleOpenFiles()) if (picker.getMultipleOpenFiles())
{ {
std::string filename = picker.getFirstFile();
S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
while (!filename.empty())
{
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);
NewResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo(
filename,
asset_name,
asset_name, 0,
LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
LLFloaterPerms::getNextOwnerPerms("Uploads"),
LLFloaterPerms::getGroupPerms("Uploads"),
LLFloaterPerms::getEveryonePerms("Uploads"),
expected_upload_cost));
upload_new_resource(uploadInfo, NULL, NULL);
filename = picker.getNextFile();
}
#if 0
const std::string& filename = picker.getFirstFile(); const std::string& filename = picker.getFirstFile();
std::string name = gDirUtilp->getBaseFileName(filename, true); std::string name = gDirUtilp->getBaseFileName(filename, true);
...@@ -456,6 +483,7 @@ class LLFileUploadBulk : public view_listener_t ...@@ -456,6 +483,7 @@ class LLFileUploadBulk : public view_listener_t
// *NOTE: Ew, we don't iterate over the file list here, // *NOTE: Ew, we don't iterate over the file list here,
// we handle the next files in upload_done_callback() // we handle the next files in upload_done_callback()
#endif
} }
else else
{ {
...@@ -640,6 +668,18 @@ LLUUID upload_new_resource( ...@@ -640,6 +668,18 @@ LLUUID upload_new_resource(
S32 expected_upload_cost, S32 expected_upload_cost,
void *userdata) void *userdata)
{ {
NewResourceUploadInfo::ptr_t uploadInfo(new NewFileResourceUploadInfo(
src_filename,
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);
return LLUUID::null;
#if 0
// Generate the temporary UUID. // Generate the temporary UUID.
std::string filename = gDirUtilp->getTempFilename(); std::string filename = gDirUtilp->getTempFilename();
LLTransactionID tid; LLTransactionID tid;
...@@ -782,6 +822,7 @@ LLUUID upload_new_resource( ...@@ -782,6 +822,7 @@ LLUUID upload_new_resource(
} }
return uuid; return uuid;
#endif
} }
void upload_done_callback( void upload_done_callback(
...@@ -1009,6 +1050,7 @@ void init_menu_file() ...@@ -1009,6 +1050,7 @@ void init_menu_file()
LLSD NewResourceUploadInfo::prepareUpload() LLSD NewResourceUploadInfo::prepareUpload()
{ {
if (mAssetId.isNull())
generateNewAssetId(); generateNewAssetId();
incrementUploadStats(); incrementUploadStats();
...@@ -1192,3 +1234,162 @@ std::string NewResourceUploadInfo::getDisplayName() const ...@@ -1192,3 +1234,162 @@ std::string NewResourceUploadInfo::getDisplayName() const
{ {
return (mName.empty()) ? mAssetId.asString() : mName; 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();
}
...@@ -97,13 +97,42 @@ class NewResourceUploadInfo ...@@ -97,13 +97,42 @@ class NewResourceUploadInfo
U32 getEveryonePerms() const { return mEveryonePerms; }; U32 getEveryonePerms() const { return mEveryonePerms; };
S32 getExpectedUploadCost() const { return mExpectedUploadCost; }; S32 getExpectedUploadCost() const { return mExpectedUploadCost; };
std::string getDisplayName() const; virtual std::string getDisplayName() const;
LLUUID getFolderId() const { return mFolderId; } LLUUID getFolderId() const { return mFolderId; }
LLUUID getItemId() const { return mItemId; } LLUUID getItemId() const { return mItemId; }
LLAssetID getAssetId() const { return mAssetId; } LLAssetID getAssetId() const { return mAssetId; }
protected: 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(); LLAssetID generateNewAssetId();
void incrementUploadStats() const; void incrementUploadStats() const;
virtual void assignDefaults(); virtual void assignDefaults();
...@@ -126,6 +155,34 @@ class NewResourceUploadInfo ...@@ -126,6 +155,34 @@ class NewResourceUploadInfo
LLAssetID mAssetId; 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( LLUUID upload_new_resource(
const std::string& src_filename, const std::string& src_filename,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment