summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Kittenbrink (Brad Linden) <brad@lindenlab.com>2022-04-28 17:30:51 -0700
committerBrad Kittenbrink <brad@lindenlab.com>2022-05-06 08:26:19 -0700
commitc9be81a74753600b8a06f369966674b50ef9781a (patch)
tree99913b2182a99a9f951f220117ccf65f919873af
parent5ac6f139655815b81a3a4ffce71f0650da771f6f (diff)
SL-17198 material asset uploading now suuceeeds.
-rw-r--r--indra/newview/llpanelface.cpp77
-rw-r--r--indra/newview/skins/default/xui/en/notifications.xml6
2 files changed, 53 insertions, 30 deletions
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 6b3ca43402..024e886b2d 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -2559,57 +2559,74 @@ void LLPanelFace::onAlignTexture(void* userdata)
}
#include "llagent.h"
-#include "llfilesystem.h"
-#include "llfloaterperms.h"
#include "llviewerassetupload.h"
#include "llviewermenufile.h"
#include "llsd.h"
-#pragma warning (disable: 4189)
+#include "llsdutil.h"
+#include "llsdserialize.h"
+#include "llinventorymodel.h"
+
void LLPanelFace::onSaveMaterial(void* userdata)
{
// DRTVWR-559, Q&D material picker - save to inventory goes here
LL_DEBUGS("Material") << "saving material to inventory" << LL_ENDL;
- LLPanelFace* self = (LLPanelFace*)userdata;
+ //LLPanelFace* self = static_cast<LLPanelFace*>(userdata);
std::string name = "New Material";
- LLSD* mat_llsd = new LLSD("Surely you jest...");
- // TBD populate mat_llsd with material data
- self->onCloseTexturePicker(*mat_llsd); // certainly wrong, but something like this?
+ LLSD material_data = llsd::map(
+ "version", "1",
+ "material", LLSD::emptyMap()
+ );
// gen a new uuid for this asset
LLTransactionID tid;
tid.generate();
LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
- LLFileSystem fmt_file(new_asset_id, LLAssetType::AT_MATERIAL, LLFileSystem::WRITE);
- fmt_file.write(mat_llsd->asBinary().data(), mat_llsd->size());
+ std::stringstream output;
+ LLSDSerialize::toNotation(material_data, output);
- S32 expected_upload_cost = 0;// LLAgentBenefitsMgr::current().getTextureUploadCost();
+ //S32 expected_upload_cost = 0;// LLAgentBenefitsMgr::current().getTextureUploadCost();
std::string res_name = name;
std::string res_desc = "Saved Material";
- LLFolderType::EType folder_type = LLFolderType::FT_MATERIAL;
- LLInventoryType::EType inv_type = LLInventoryType::IT_MATERIAL;
-
- auto upload_info = new LLResourceUploadInfo(
- tid,
- LLAssetType::AT_MATERIAL,
- res_name,
- res_desc,
- 0,
- folder_type,
- inv_type,
- PERM_ALL,
- LLFloaterPerms::getGroupPerms("Uploads"),
- LLFloaterPerms::getEveryonePerms("Uploads"),
- expected_upload_cost,
- false);
-
- LLResourceUploadInfo::ptr_t p_upload_info(upload_info);
-
- upload_new_resource(p_upload_info);
+ //LLFolderType::EType folder_type = LLFolderType::FT_MATERIAL;
+ //LLInventoryType::EType inv_type = LLInventoryType::IT_MATERIAL;
+ U32 next_owner_perm = LLPermissions::DEFAULT.getMaskNextOwner();
+
+ LLUUID parent = gInventory.findCategoryUUIDForType(LLFolderType::FT_MATERIAL);
+ const U8 subtype = NO_INV_SUBTYPE; // TODO maybe use AT_SETTINGS and LLSettingsType::ST_MATERIAL ?
+
+ create_inventory_item(gAgent.getID(), gAgent.getSessionID(), parent, tid, res_name, res_desc,
+ LLAssetType::AT_MATERIAL, LLInventoryType::IT_MATERIAL, subtype, next_owner_perm,
+ new LLBoostFuncInventoryCallback([output=output.str()](LLUUID const & inv_item_id){
+ // from reference in LLSettingsVOBase::createInventoryItem()/updateInventoryItem()
+ LLResourceUploadInfo::ptr_t uploadInfo =
+ std::make_shared<LLBufferedAssetUploadInfo>(
+ inv_item_id,
+ LLAssetType::AT_SETTINGS, // TODO switch to AT_MATERIAL
+ output,
+ [](LLUUID item_id, LLUUID new_asset_id, LLUUID new_item_id, LLSD response) {
+ LL_INFOS("Material") << "inventory item uploaded. item: " << item_id << " asset: " << new_asset_id << " new_item_id: " << new_item_id << " response: " << response << LL_ENDL;
+ LLSD params = llsd::map("ASSET_ID", new_asset_id);
+ LLNotificationsUtil::add("MaterialCreated", params);
+ });
+
+ const LLViewerRegion* region = gAgent.getRegion();
+ if (region)
+ {
+ std::string agent_url(region->getCapability("UpdateSettingsAgentInventory"));
+ if (agent_url.empty())
+ {
+ LL_ERRS() << "missing required agent inventory cap url" << LL_ENDL;
+ }
+ LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo);
+ }
+ })
+ );
+
}
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index 4f1755a99b..a85131cc75 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -11831,4 +11831,10 @@ Unpacking: [UNPACK_TIME]s [USIZE]KB
</form>
</notification>
+<notification
+ icon="notifytip.tga"
+ name="MaterialCreated"
+ type="notifytip">
+Material successfully created. Asset ID: [ASSET_ID]
+</notification>
</notifications>