Preparing to add mesh upload.

This commit is contained in:
Siana Gearz
2011-12-02 09:30:12 +01:00
parent aeb766ee37
commit 697dd7e929
22 changed files with 7700 additions and 453 deletions

View File

@@ -32,11 +32,34 @@
#include "llviewerprecompiledheaders.h"
// system libraries
#include <boost/tokenizer.hpp>
#include "llviewermenufile.h"
// linden libraries
#include "lleconomy.h"
#include "llhttpclient.h"
#include "llimage.h"
#include "llmemberlistener.h"
#include "llnotificationsutil.h"
#include "llsdserialize.h"
#include "llsdutil.h"
#include "llstring.h"
#include "lltransactiontypes.h"
#include "lluictrlfactory.h"
#include "lluuid.h"
#include "llvorbisencode.h"
#include "message.h"
// project includes
#include "llagent.h"
#include "llagentcamera.h"
#include "llappviewer.h"
#include "llassetuploadresponders.h"
#ifdef MESH_UPLOAD
#include "llfloatermodelpreview.h"
#endif
#include "llimagejpeg.h"
#include "llimagepng.h"
@@ -62,7 +85,6 @@
#include "llviewerregion.h"
#include "llviewerstats.h"
#include "llviewerwindow.h"
#include "llappviewer.h"
#include "lluploaddialog.h"
// <edit>
#include "llselectmgr.h"
@@ -72,23 +94,9 @@
#include "lllocalinventory.h"
// </edit>
#include "importtracker.h"
// linden libraries
#include "llassetuploadresponders.h"
#include "lleconomy.h"
#include "llhttpclient.h"
#include "llnotificationsutil.h"
#include "llmemberlistener.h"
#include "llsdserialize.h"
#include "llstring.h"
#include "lltransactiontypes.h"
#include "lluuid.h"
#include "llvorbisencode.h"
// system libraries
#include <boost/tokenizer.hpp>
//#include "importtracker.h"
std::deque<std::string> gUploadQueue;
typedef LLMemberListener<LLView> view_listener_t;
@@ -97,7 +105,8 @@ class LLFileEnableSaveAs : public view_listener_t
{
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
bool new_value = gFloaterView->getFrontmost() && gFloaterView->getFrontmost()->canSaveAs();
bool new_value = gFloaterView->getFrontmost() &&
gFloaterView->getFrontmost()->canSaveAs();
gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
return true;
}
@@ -107,7 +116,8 @@ class LLFileEnableUpload : public view_listener_t
{
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
bool new_value = gStatusBar && LLGlobalEconomy::Singleton::getInstance() && (gStatusBar->getBalance() >= LLGlobalEconomy::Singleton::getInstance()->getPriceUpload());
bool new_value = gStatusBar && LLGlobalEconomy::Singleton::getInstance() &&
gStatusBar->getBalance() >= LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
return true;
}
@@ -207,7 +217,7 @@ bool AIFileUpload::is_valid(std::string const& filename, ELoadFilter type)
// No extension
LLSD args;
args["FILE"] = short_name;
LLNotificationsUtil::add("NoFileExtension", args);
LLNotifications::instance().add("NoFileExtension", args);
return false;
}
else
@@ -250,7 +260,7 @@ bool AIFileUpload::is_valid(std::string const& filename, ELoadFilter type)
LLSD args;
args["EXTENSION"] = ext;
args["VALIDS"] = valid_extensions;
LLNotificationsUtil::add("InvalidFileExtension", args);
LLNotifications::instance().add("InvalidFileExtension", args);
return false;
}
}//end else (non-null extension)
@@ -355,7 +365,7 @@ class LLFileUploadBulk : public view_listener_t
if(expected_upload_cost)
msg.append(llformat("\nWARNING: Each upload costs L$%d if it's not temporary.",expected_upload_cost));
args["MESSAGE"] = msg;
LLNotificationsUtil::add("GenericAlertYesNoCancel", args, LLSD(), onConfirmBulkUploadTemp);
LLNotifications::instance().add("GenericAlertYesNoCancel", args, LLSD(), onConfirmBulkUploadTemp);
return true;
}
@@ -640,6 +650,7 @@ void upload_new_resource(const std::string& src_filename, std::string name,
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;
@@ -657,12 +668,11 @@ void upload_new_resource(const std::string& src_filename, std::string name,
upload_error(error_message, "NofileExtension", filename, args);
return;
}
else if( exten == "bmp")
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,
IMG_CODEC_BMP ))
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());
@@ -672,51 +682,6 @@ void upload_new_resource(const std::string& src_filename, std::string name,
return;
}
}
else if( exten == "tga")
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerTextureList::createUploadFile(src_filename,
filename,
IMG_CODEC_TGA ))
{
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;
}
}
else if( exten == "jpg" || exten == "jpeg")
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerTextureList::createUploadFile(src_filename,
filename,
IMG_CODEC_JPEG ))
{
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;
}
}
else if( exten == "png")
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerTextureList::createUploadFile(src_filename,
filename,
IMG_CODEC_PNG ))
{
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;
}
}
else if(exten == "wav")
{
asset_type = LLAssetType::AT_SOUND; // tag it as audio
@@ -1122,6 +1087,52 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt
data = NULL;
}
static LLAssetID upload_new_resource_prep(const LLTransactionID& tid,
LLAssetType::EType asset_type,
LLInventoryType::EType& inventory_type,
std::string& name,
const std::string& display_name,
std::string& description)
{
LLAssetID uuid = generate_asset_id_for_new_upload(tid);
increase_new_upload_stats(asset_type);
assign_defaults_and_show_upload_message(asset_type,
inventory_type,
name,
display_name,
description);
return uuid;
}
LLSD generate_new_resource_upload_capability_body(LLAssetType::EType asset_type,
const std::string& name,
const std::string& desc,
LLFolderType::EType destination_folder_type,
LLInventoryType::EType inv_type,
U32 next_owner_perms,
U32 group_perms,
U32 everyone_perms)
{
LLSD body;
body["folder_id"] = gInventory.findCategoryUUIDForType(destination_folder_type == LLFolderType::FT_NONE ?
LLFolderType::assetTypeToFolderType(asset_type) :
destination_folder_type);
body["asset_type"] = LLAssetType::lookup(asset_type);
body["inventory_type"] = LLInventoryType::lookup(inv_type);
body["name"] = name;
body["description"] = desc;
body["next_owner_mask"] = LLSD::Integer(next_owner_perms);
body["group_mask"] = LLSD::Integer(group_perms);
body["everyone_mask"] = LLSD::Integer(everyone_perms);
return body;
}
void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_type,
std::string name,
std::string desc, S32 compression_info,
@@ -1140,51 +1151,20 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
return ;
}
LLAssetID uuid = tid.makeAssetID(gAgent.getSecureSessionID());
if( LLAssetType::AT_SOUND == asset_type )
{
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_SOUND_COUNT );
}
else
if( LLAssetType::AT_TEXTURE == asset_type )
{
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_TEXTURE_COUNT );
}
else
if( LLAssetType::AT_ANIMATION == asset_type)
{
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_ANIM_COUNT );
}
if(LLInventoryType::IT_NONE == inv_type)
{
inv_type = LLInventoryType::defaultForAssetType(asset_type);
}
LLStringUtil::stripNonprintable(name);
LLStringUtil::stripNonprintable(desc);
if(name.empty())
{
name = "(No Name)";
}
if(desc.empty())
{
desc = "(No Description)";
}
// At this point, we're ready for the upload.
std::string upload_message = "Uploading...\n\n";
upload_message.append(display_name);
LLUploadDialog::modalUploadDialog(upload_message);
LLAssetID uuid = upload_new_resource_prep(tid, asset_type, inv_type,
name, display_name, desc);
llinfos << "*** Uploading: "
<< "\nType: " << LLAssetType::lookup(asset_type)
<< "\nUUID: " << uuid
<< "\nName: " << name
<< "\nDesc: " << desc
<< "\nFolder: "
<< gInventory.findCategoryUUIDForType(destination_folder_type == LLFolderType::FT_NONE ?
LLFolderType::assetTypeToFolderType(asset_type) :
destination_folder_type)
<< "\nExpected Upload Cost: " << expected_upload_cost << llendl;
llinfos << "*** Uploading: " << llendl;
llinfos << "Type: " << LLAssetType::lookup(asset_type) << llendl;
llinfos << "UUID: " << uuid << llendl;
llinfos << "Name: " << name << llendl;
llinfos << "Desc: " << desc << llendl;
llinfos << "Expected Upload Cost: " << expected_upload_cost << llendl;
lldebugs << "Folder: " << gInventory.findCategoryUUIDForType((destination_folder_type == LLFolderType::FT_NONE) ? LLFolderType::assetTypeToFolderType(asset_type) : destination_folder_type) << llendl;
lldebugs << "Asset Type: " << LLAssetType::lookup(asset_type) << llendl;
std::string url = gAgent.getRegion()->getCapability("NewFileAgentInventory");
// <edit>
BOOL temporary = gSavedSettings.getBOOL("TemporaryUpload");
@@ -1204,11 +1184,8 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
body["everyone_mask"] = LLSD::Integer(everyone_perms);
body["expected_upload_cost"] = LLSD::Integer(expected_upload_cost);
//std::ostringstream llsdxml;
//LLSDSerialize::toPrettyXML(body, llsdxml);
//llinfos << "posting body to capability: " << llsdxml.str() << llendl;
LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, uuid, asset_type));
LLHTTPClient::post(url, body,
new LLNewAgentInventoryResponder(body, uuid, asset_type));
}
else
{
@@ -1259,6 +1236,64 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
}
}
LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid)
{
LLAssetID uuid;
if (gDisconnected)
{
uuid.setNull();
}
else
{
uuid = tid.makeAssetID(gAgent.getSecureSessionID());
}
return uuid;
}
void increase_new_upload_stats(LLAssetType::EType asset_type)
{
if (LLAssetType::AT_SOUND == asset_type)
{
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_SOUND_COUNT);
}
else if (LLAssetType::AT_TEXTURE == asset_type)
{
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_TEXTURE_COUNT);
}
else if (LLAssetType::AT_ANIMATION == asset_type)
{
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_ANIM_COUNT);
}
}
void assign_defaults_and_show_upload_message(LLAssetType::EType asset_type,
LLInventoryType::EType& inventory_type,
std::string& name,
const std::string& display_name,
std::string& description)
{
if (LLInventoryType::IT_NONE == inventory_type)
{
inventory_type = LLInventoryType::defaultForAssetType(asset_type);
}
LLStringUtil::stripNonprintable(name);
LLStringUtil::stripNonprintable(description);
if (name.empty())
{
name = "(No Name)";
}
if (description.empty())
{
description = "(No Description)";
}
// At this point, we're ready for the upload.
std::string upload_message = "Uploading...\n\n";
upload_message.append(display_name);
LLUploadDialog::modalUploadDialog(upload_message);
}
void init_menu_file()
{