From 7480e069349e2b3a7581267d13f52c63e459af64 Mon Sep 17 00:00:00 2001
From: Leyla Farazha <leyla@lindenlab.com>
Date: Wed, 24 Mar 2010 16:39:59 -0700
Subject: Hooked up Save As Profile Pic reviewed by Richard CC# 167

---
 indra/newview/llassetuploadresponders.cpp |  26 +++++--
 indra/newview/llassetuploadresponders.h   |  12 ++-
 indra/newview/llfloateranimpreview.cpp    |   9 +--
 indra/newview/llfloaternamedesc.cpp       |   6 +-
 indra/newview/llfloatersnapshot.cpp       | 102 +++++++++++++++++++++----
 indra/newview/llfloatersnapshot.h         |   2 +
 indra/newview/llviewermenufile.cpp        | 121 ++++++++----------------------
 indra/newview/llviewermenufile.h          |  14 +---
 8 files changed, 161 insertions(+), 131 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index 80cf8f1d61..1d92c396b4 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -199,13 +199,19 @@ 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,
+														   boost::function<void(const LLUUID& uuid)> callback)
+: LLAssetUploadResponder(post_data, vfile_id, asset_type),
+  mCallback(callback)
 {
 }
 
-LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data, const std::string& file_name, LLAssetType::EType asset_type)
-: LLAssetUploadResponder(post_data, file_name, asset_type)
+LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data, 
+														   const std::string& file_name, 
+														   LLAssetType::EType asset_type, 
+														   boost::function<void(const LLUUID& uuid)> callback)
+: LLAssetUploadResponder(post_data, file_name, asset_type),
+  mCallback(callback)
 {
 }
 
@@ -283,6 +289,12 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
 										creation_date_now);
 		gInventory.updateItem(item);
 		gInventory.notifyObservers();
+		
+		if (mCallback)
+		{
+			// call the callback with the new Asset UUID
+			mCallback(item->getAssetUUID());
+		}
 
 		// Show the preview panel for textures and sounds to let
 		// user know that the image (or snapshot) arrived intact.
@@ -330,13 +342,11 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
 		U32 group_perms      = mPostData.has("group_mask")      ? mPostData.get("group_mask"     ).asInteger() : PERM_NONE;
 		U32 next_owner_perms = mPostData.has("next_owner_mask") ? mPostData.get("next_owner_mask").asInteger() : PERM_NONE;
 		std::string display_name = LLStringUtil::null;
-		LLAssetStorage::LLStoreAssetCallback callback = NULL;
-		void *userdata = NULL;
 		upload_new_resource(next_file, asset_name, asset_name,
-				    0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
+				    LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
 				    next_owner_perms, group_perms,
 				    everyone_perms, display_name,
-				    callback, expected_upload_cost, userdata);
+				    NULL, expected_upload_cost);
 	}
 }
 
diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h
index e656351305..ade9c96758 100644
--- a/indra/newview/llassetuploadresponders.h
+++ b/indra/newview/llassetuploadresponders.h
@@ -33,6 +33,7 @@
 #ifndef LL_LLASSETUPLOADRESPONDER_H
 #define LL_LLASSETUPLOADRESPONDER_H
 
+#include "llassetstorage.h"
 #include "llhttpclient.h"
 
 // Abstract class for supporting asset upload
@@ -66,10 +67,15 @@ class LLNewAgentInventoryResponder : public LLAssetUploadResponder
 public:
 	LLNewAgentInventoryResponder(const LLSD& post_data,
 								const LLUUID& vfile_id,
-								LLAssetType::EType asset_type);
-	LLNewAgentInventoryResponder(const LLSD& post_data, const std::string& file_name,
-											   LLAssetType::EType asset_type);
+								LLAssetType::EType asset_type,
+								boost::function<void(const LLUUID& uuid)> callback = NULL);
+	LLNewAgentInventoryResponder(const LLSD& post_data, 
+								const std::string& file_name,
+								 LLAssetType::EType asset_type,
+								boost::function<void(const LLUUID& uuid)> callback = NULL);
 	virtual void uploadComplete(const LLSD& content);
+
+	boost::function<void(const LLUUID& uuid)> mCallback;
 };
 
 class LLBakedUploadData;
diff --git a/indra/newview/llfloateranimpreview.cpp b/indra/newview/llfloateranimpreview.cpp
index 5ec58c8dd6..feb18fe393 100644
--- a/indra/newview/llfloateranimpreview.cpp
+++ b/indra/newview/llfloateranimpreview.cpp
@@ -1001,19 +1001,18 @@ void LLFloaterAnimPreview::onBtnOK(void* userdata)
 			{
 				std::string name = floaterp->childGetValue("name_form").asString();
 				std::string desc = floaterp->childGetValue("description_form").asString();
-				LLAssetStorage::LLStoreAssetCallback callback = NULL;
 				S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
-				void *userdata = NULL;
 				upload_new_resource(floaterp->mTransactionID, // tid
 						    LLAssetType::AT_ANIMATION,
 						    name,
 						    desc,
-						    0,
 						    LLFolderType::FT_NONE,
 						    LLInventoryType::IT_ANIMATION,
-						    LLFloaterPerms::getNextOwnerPerms(), LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(),
+						    LLFloaterPerms::getNextOwnerPerms(), 
+							LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(),
 						    name,
-						    callback, expected_upload_cost, userdata);
+						    NULL, 
+							expected_upload_cost);
 			}
 			else
 			{
diff --git a/indra/newview/llfloaternamedesc.cpp b/indra/newview/llfloaternamedesc.cpp
index 159ce41b79..5c343ecb22 100644
--- a/indra/newview/llfloaternamedesc.cpp
+++ b/indra/newview/llfloaternamedesc.cpp
@@ -169,16 +169,14 @@ void LLFloaterNameDesc::onBtnOK( )
 {
 	childDisable("ok_btn"); // don't allow inadvertent extra uploads
 	
-	LLAssetStorage::LLStoreAssetCallback callback = NULL;
 	S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); // kinda hack - assumes that unsubclassed LLFloaterNameDesc is only used for uploading chargeable assets, which it is right now (it's only used unsubclassed for the sound upload dialog, and THAT should be a subclass).
-	void *nruserdata = NULL;
 	std::string display_name = LLStringUtil::null;
 	upload_new_resource(mFilenameAndPath, // file
 			    childGetValue("name_form").asString(), 
 			    childGetValue("description_form").asString(), 
-			    0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
+			    LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
 			    LLFloaterPerms::getNextOwnerPerms(), LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(),
-			    display_name, callback, expected_upload_cost, nruserdata);
+			    display_name, NULL, expected_upload_cost);
 	closeFloater(false);
 }
 
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index 2df297fc42..9ce6230d5c 100644
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -39,6 +39,7 @@
 // Viewer includes
 #include "llagent.h"
 #include "llagentui.h"
+#include "llavatarpropertiesprocessor.h"
 #include "llbottomtray.h"
 #include "llbutton.h"
 #include "llcallbacklist.h"
@@ -166,7 +167,7 @@ public:
 	void setSnapshotBufferType(LLViewerWindow::ESnapshotType type) { mSnapshotBufferType = type; }
 	void updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail = FALSE, F32 delay = 0.f);
 	LLFloaterPostcard* savePostcard();
-	void saveTexture();
+	void saveTexture(bool set_as_profile_pic = false);
 	BOOL saveLocal();
 	void saveWeb(std::string url);
 
@@ -974,13 +975,21 @@ LLFloaterPostcard* LLSnapshotLivePreview::savePostcard()
 	return floater;
 }
 
-void LLSnapshotLivePreview::saveTexture()
+// Callback for asset upload
+void profile_pic_upload_callback(const LLUUID& uuid)
+{
+	LLFloaterSnapshot* floater =  LLFloaterReg::getTypedInstance<LLFloaterSnapshot>("snapshot");
+	floater->setAsProfilePic(uuid);
+}
+
+
+void LLSnapshotLivePreview::saveTexture(bool set_as_profile_pic)
 {
 	// gen a new uuid for this asset
 	LLTransactionID tid;
 	tid.generate();
 	LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
-		
+
 	LLPointer<LLImageJ2C> formatted = new LLImageJ2C;
 	LLPointer<LLImageRaw> scaled = new LLImageRaw(mPreviewImage->getData(),
 												  mPreviewImage->getWidth(),
@@ -991,26 +1000,30 @@ void LLSnapshotLivePreview::saveTexture()
 			
 	if (formatted->encode(scaled, 0.0f))
 	{
+		boost::function<void(const LLUUID& uuid)> callback = NULL;
+
+		if (set_as_profile_pic)
+		{
+			callback = profile_pic_upload_callback;
+		}
+
 		LLVFile::writeFile(formatted->getData(), formatted->getDataSize(), gVFS, new_asset_id, LLAssetType::AT_TEXTURE);
 		std::string pos_string;
 		LLAgentUI::buildLocationString(pos_string, LLAgentUI::LOCATION_FORMAT_FULL);
 		std::string who_took_it;
 		LLAgentUI::buildFullname(who_took_it);
-		LLAssetStorage::LLStoreAssetCallback callback = NULL;
 		S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
-		void *userdata = NULL;
 		upload_new_resource(tid,	// tid
 				    LLAssetType::AT_TEXTURE,
 				    "Snapshot : " + pos_string,
 				    "Taken by " + who_took_it + " at " + pos_string,
-				    0,
 				    LLFolderType::FT_SNAPSHOT_CATEGORY,
 				    LLInventoryType::IT_SNAPSHOT,
 				    PERM_ALL,  // Note: Snapshots to inventory is a special case of content upload
 				    PERM_NONE, // that ignores the user's premissions preferences and continues to
 				    PERM_NONE, // always use these fairly permissive hard-coded initial perms. - MG
 				    "Snapshot : " + pos_string,
-				    callback, expected_upload_cost, userdata);
+				    callback, expected_upload_cost);
 		gViewerWindow->playSnapshotAnimAndSound();
 	}
 	else
@@ -1151,6 +1164,7 @@ public:
 	static void onCommitSnapshotFormat(LLUICtrl* ctrl, void* data);
 	static void onCommitCustomResolution(LLUICtrl *ctrl, void* data);
 	static void onCommitSnapshot(LLFloaterSnapshot* view, LLSnapshotLivePreview::ESnapshotType type);
+	static void onCommitProfilePic(LLFloaterSnapshot* view);
 	static void onToggleAdvanced(LLUICtrl *ctrl, void* data);
 	static void resetSnapshotSizeOnUI(LLFloaterSnapshot *view, S32 width, S32 height) ;
 	static BOOL checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value);
@@ -1661,6 +1675,60 @@ void LLFloaterSnapshot::Impl::onToggleAdvanced(LLUICtrl* ctrl, void* data)
 	}
 }
 
+// This object represents a pending request for avatar properties information
+class LLAvatarDataRequest : public LLAvatarPropertiesObserver
+{
+public:
+	LLAvatarDataRequest(const LLUUID& avatar_id, const LLUUID& image_id, LLFloaterSnapshot* floater)
+	:	mAvatarID(avatar_id),
+		mImageID(image_id),
+		mSnapshotFloater(floater)
+
+	{
+	}
+	
+	~LLAvatarDataRequest()
+	{
+		// remove ourselves as an observer
+		LLAvatarPropertiesProcessor::getInstance()->
+		removeObserver(mAvatarID, this);
+	}
+	
+	void processProperties(void* data, EAvatarProcessorType type)
+	{
+		// route the data to the inspector
+		if (data
+			&& type == APT_PROPERTIES)
+		{
+
+			LLAvatarData* avatar_data = static_cast<LLAvatarData*>(data);
+
+			LLAvatarData new_data(*avatar_data);
+			new_data.image_id = mImageID;
+
+			LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesUpdate(&new_data);
+
+			delete this;
+		}
+	}
+	
+	// Store avatar ID so we can un-register the observer on destruction
+	LLUUID mAvatarID;
+	LLUUID mImageID;
+	LLFloaterSnapshot* mSnapshotFloater;
+};
+
+void LLFloaterSnapshot::Impl::onCommitProfilePic(LLFloaterSnapshot* view)
+{
+	//first save to harddrive
+	LLSnapshotLivePreview* previewp = getPreviewView(view);
+	
+	if(previewp)
+	{
+		previewp->saveTexture(true);
+	}
+}
+
 void LLFloaterSnapshot::Impl::onCommitSnapshot(LLFloaterSnapshot* view, LLSnapshotLivePreview::ESnapshotType type)
 {
 	LLSnapshotLivePreview* previewp = getPreviewView(view);
@@ -1717,8 +1785,6 @@ void LLFloaterSnapshot::Impl::onCommitSnapshotFormat(LLUICtrl* ctrl, void* data)
 	}
 }
 
-
-
 // Sets the named size combo to "custom" mode.
 // static
 void LLFloaterSnapshot::Impl::comboSetCustom(LLFloaterSnapshot* floater, const std::string& comboname)
@@ -1732,8 +1798,6 @@ void LLFloaterSnapshot::Impl::comboSetCustom(LLFloaterSnapshot* floater, const s
 	checkAspectRatio(floater, -1); // -1 means custom
 }
 
-
-
 //static
 BOOL LLFloaterSnapshot::Impl::checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value)
 {
@@ -1925,7 +1989,8 @@ BOOL LLFloaterSnapshot::postBuild()
 	getChild<LLButton>("share_to_email")->setCommitCallback(boost::bind(&Impl::onCommitSnapshot, this, LLSnapshotLivePreview::SNAPSHOT_POSTCARD));
 	getChild<LLButton>("save_to_inventory")->setCommitCallback(boost::bind(&Impl::onCommitSnapshot, this, LLSnapshotLivePreview::SNAPSHOT_TEXTURE));
 	getChild<LLButton>("save_to_computer")->setCommitCallback(boost::bind(&Impl::onCommitSnapshot, this, LLSnapshotLivePreview::SNAPSHOT_LOCAL));
-	
+	getChild<LLButton>("set_profile_pic")->setCommitCallback(boost::bind(&Impl::onCommitProfilePic, this));
+
 	childSetCommitCallback("show_advanced", Impl::onToggleAdvanced, this);
 	childSetCommitCallback("hide_advanced", Impl::onToggleAdvanced, this);
 
@@ -2082,7 +2147,6 @@ void LLFloaterSnapshot::update()
 	}
 }
 
-
 bool LLFloaterSnapshot::updateButtons(ESnapshotMode mode)
 {
 	childSetVisible("share", mode == SNAPSHOT_MAIN);
@@ -2099,6 +2163,18 @@ bool LLFloaterSnapshot::updateButtons(ESnapshotMode mode)
 
 	return true;
 }
+
+void LLFloaterSnapshot::setAsProfilePic(const LLUUID& image_id)
+{
+	LLAvatarDataRequest* avatar_data_request = new LLAvatarDataRequest(gAgent.getID(), image_id, this);
+	
+	LLAvatarPropertiesProcessor* processor = 
+		LLAvatarPropertiesProcessor::getInstance();
+	
+	processor->addObserver(gAgent.getID(), avatar_data_request);
+	processor->sendAvatarPropertiesRequest(gAgent.getID());
+}
+
 ///----------------------------------------------------------------------------
 /// Class LLSnapshotFloaterView
 ///----------------------------------------------------------------------------
diff --git a/indra/newview/llfloatersnapshot.h b/indra/newview/llfloatersnapshot.h
index d876fc4781..931d355748 100644
--- a/indra/newview/llfloatersnapshot.h
+++ b/indra/newview/llfloatersnapshot.h
@@ -64,6 +64,8 @@ public:
 	
 	static void update();
 	
+	void setAsProfilePic(const LLUUID& image_id);
+	
 	bool updateButtons(ESnapshotMode mode);
 	
 	static S32  getUIWinHeightLong()  {return sUIWinHeightLong ;}
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 00762894cd..0d855c17a9 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -317,13 +317,11 @@ class LLFileUploadBulk : public view_listener_t
 			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,
+			upload_new_resource(filename, asset_name, asset_name, LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
 				LLFloaterPerms::getNextOwnerPerms(), LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(),
 					    display_name,
-					    callback, expected_upload_cost, userdata);
+					    NULL, expected_upload_cost);
 
 			// *NOTE: Ew, we don't iterate over the file list here,
 			// we handle the next files in upload_done_callback()
@@ -480,16 +478,15 @@ void handle_compress_image(void*)
 }
 
 void upload_new_resource(const std::string& src_filename, std::string name,
-			 std::string desc, S32 compression_info,
+			 std::string desc,
 			 LLFolderType::EType destination_folder_type,
 			 LLInventoryType::EType inv_type,
 			 U32 next_owner_perms,
 			 U32 group_perms,
 			 U32 everyone_perms,
 			 const std::string& display_name,
-			 LLAssetStorage::LLStoreAssetCallback callback,
-			 S32 expected_upload_cost,
-			 void *userdata)
+			 boost::function<void(const LLUUID& uuid)> callback,
+			 S32 expected_upload_cost)
 {	
 	// Generate the temporary UUID.
 	std::string filename = gDirUtilp->getTempFilename();
@@ -771,9 +768,9 @@ void upload_new_resource(const std::string& src_filename, std::string name,
 		{
 			t_disp_name = src_filename;
 		}
-		upload_new_resource(tid, asset_type, name, desc, compression_info, // tid
+		upload_new_resource(tid, asset_type, name, desc,
 				    destination_folder_type, inv_type, next_owner_perms, group_perms, everyone_perms,
-				    display_name, callback, expected_upload_cost, userdata);
+				    display_name, callback, expected_upload_cost);
 	}
 	else
 	{
@@ -892,30 +889,28 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt
 		LLStringUtil::trim(asset_name);
 
 		std::string display_name = LLStringUtil::null;
-		LLAssetStorage::LLStoreAssetCallback callback = NULL;
-		void *userdata = NULL;
 		upload_new_resource(next_file, asset_name, asset_name,	// file
-				    0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
+				    LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
 				    PERM_NONE, PERM_NONE, PERM_NONE,
 				    display_name,
-				    callback,
-				    expected_upload_cost, // assuming next in a group of uploads is of roughly the same type, i.e. same upload cost
-				    userdata);
+				    NULL,
+				    expected_upload_cost); // assuming next in a group of uploads is of roughly the same type, i.e. same upload cost
+				
 	}
 }
 
-void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_type,
+void upload_new_resource(const LLTransactionID &tid, 
+			 LLAssetType::EType asset_type,
 			 std::string name,
-			 std::string desc, S32 compression_info,
+			 std::string desc, 
 			 LLFolderType::EType destination_folder_type,
 			 LLInventoryType::EType inv_type,
 			 U32 next_owner_perms,
 			 U32 group_perms,
 			 U32 everyone_perms,
 			 const std::string& display_name,
-			 LLAssetStorage::LLStoreAssetCallback callback,
-			 S32 expected_upload_cost,
-			 void *userdata)
+			 boost::function<void(const LLUUID& uuid)> callback,
+			 S32 expected_upload_cost)
 {
 	if(gDisconnected)
 	{
@@ -959,76 +954,26 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
 	upload_message.append(display_name);
 	LLUploadDialog::modalUploadDialog(upload_message);
 
-	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");
-	if (!url.empty())
-	{
-		llinfos << "New Agent Inventory via capability" << llendl;
-		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);
-		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));
+	
+	if (url.empty()) {
+		llwarns << "Could not get NewFileAgentInventory capability" << llendl;
+		return;
 	}
-	else
-	{
-		llinfos << "NewAgentInventory capability not found, new agent inventory via asset system." << llendl;
-		// check for adequate funds
-		// TODO: do this check on the sim
-		if (LLAssetType::AT_SOUND == asset_type ||
-			LLAssetType::AT_TEXTURE == asset_type ||
-			LLAssetType::AT_ANIMATION == asset_type)
-		{
-			S32 balance = gStatusBar->getBalance();
-			if (balance < expected_upload_cost)
-			{
-				// insufficient funds, bail on this upload
-				LLFloaterBuyCurrency::buyCurrency(LLTrans::getString("uploading_costs"), expected_upload_cost);
-				return;
-			}
-		}
 
-		LLResourceData* data = new LLResourceData;
-		data->mAssetInfo.mTransactionID = tid;
-		data->mAssetInfo.mUuid = uuid;
-		data->mAssetInfo.mType = asset_type;
-		data->mAssetInfo.mCreatorID = gAgentID;
-		data->mInventoryType = inv_type;
-		data->mNextOwnerPerm = next_owner_perms;
-		data->mExpectedUploadCost = expected_upload_cost;
-		data->mUserData = userdata;
-		data->mAssetInfo.setName(name);
-		data->mAssetInfo.setDescription(desc);
-		data->mPreferredLocation = destination_folder_type;
-
-		LLAssetStorage::LLStoreAssetCallback asset_callback = &upload_done_callback;
-		if (callback)
-		{
-			asset_callback = callback;
-		}
-		gAssetStorage->storeAssetData(data->mAssetInfo.mTransactionID, data->mAssetInfo.mType,
-										asset_callback,
-										(void*)data,
-										FALSE);
-	}
+	llinfos << "New Agent Inventory via capability" << llendl;
+	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);
+	body["expected_upload_cost"] = LLSD::Integer(expected_upload_cost);
+
+	LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, uuid, asset_type, callback));
 }
 
 void init_menu_file()
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index 1e6d13f1c6..33f8243ac0 100644
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -34,41 +34,35 @@
 #define LLVIEWERMENUFILE_H
 
 #include "llfoldertype.h"
-#include "llassetstorage.h"
 #include "llinventorytype.h"
 
 class LLTransactionID;
 
-
 void init_menu_file();
 
 void upload_new_resource(const std::string& src_filename, 
 			 std::string name,
 			 std::string desc, 
-			 S32 compression_info,
 			 LLFolderType::EType destination_folder_type,
 			 LLInventoryType::EType inv_type,
 			 U32 next_owner_perms,
 			 U32 group_perms,
 			 U32 everyone_perms,
 			 const std::string& display_name,
-			 LLAssetStorage::LLStoreAssetCallback callback,
-			 S32 expected_upload_cost,
-			 void *userdata);
+			 boost::function<void(const LLUUID& uuid)> callback,
+			 S32 expected_upload_cost);
 
 void upload_new_resource(const LLTransactionID &tid, 
 			 LLAssetType::EType type,
 			 std::string name,
 			 std::string desc, 
-			 S32 compression_info,
 			 LLFolderType::EType destination_folder_type,
 			 LLInventoryType::EType inv_type,
 			 U32 next_owner_perms,
 			 U32 group_perms,
 			 U32 everyone_perms,
 			 const std::string& display_name,
-			 LLAssetStorage::LLStoreAssetCallback callback,
-			 S32 expected_upload_cost,
-			 void *userdata);
+			 boost::function<void(const LLUUID& uuid)> callback,
+			 S32 expected_upload_cost);
 
 #endif
-- 
cgit v1.2.3