void temp_upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status) // StoreAssetData callback (fixed) { LLResourceData* data = (LLResourceData*)user_data; if(result >= 0) { LLAssetType::EType dest_loc = (data->mPreferredLocation == LLAssetType::AT_NONE) ? data->mAssetInfo.mType : data->mPreferredLocation; LLUUID folder_id(gInventory.findCategoryUUIDForType(dest_loc)); LLUUID item_id; item_id.generate(); LLPermissions perm; perm.init(gAgentID, gAgentID, gAgentID, gAgentID); perm.setMaskBase(PERM_ALL); perm.setMaskOwner(PERM_ALL); perm.setMaskEveryone(PERM_ALL); perm.setMaskGroup(PERM_ALL); LLPointer<LLViewerInventoryItem> item = new LLViewerInventoryItem(item_id, folder_id, perm, data->mAssetInfo.mTransactionID.makeAssetID(gAgent.getSecureSessionID()), data->mAssetInfo.mType, data->mInventoryType, data->mAssetInfo.getName(), "", LLSaleInfo::DEFAULT, LLInventoryItem::II_FLAGS_NONE, time_corrected()); item->updateServer(TRUE); gInventory.updateItem(item); gInventory.notifyObservers(); }else // if(result >= 0) { LLSD args; args["FILE"] = LLInventoryType::lookupHumanReadable(data->mInventoryType); args["REASON"] = std::string(LLAssetStorage::getErrorString(result)); LLNotifications::instance().add("CannotUploadReason", args); } LLUploadDialog::modalUploadFinished(); delete data; }
void LLViewerInventoryCategory::createBasicHair() { LLUUID item_id = LLUUID("30d1d71b-38a6-4956-b27e-3bbcc17da0e2"); //lolhack, it's my UUID? //Make some hair just in case, using the library item so we're not hacking. LLUUID folder_id(gInventory.findCategoryUUIDForType(LLAssetType::AT_BODYPART)); LLPermissions* perms = new LLPermissions(); perms->set(LLPermissions::DEFAULT); perms->setOwnerAndGroup(LLUUID::null, LLUUID::null, LLUUID::null, false); perms->setMaskBase(0); perms->setMaskEveryone(0); perms->setMaskGroup(0); perms->setMaskNext(0); perms->setMaskOwner(0); LLViewerInventoryItem* item = new LLViewerInventoryItem( item_id, folder_id, *perms, LLUUID("f0581d0d-d7c4-2573-b2ce-7a5d6ded3851"), LLAssetType::AT_BODYPART, LLInventoryType::IT_WEARABLE, "RuthHairFix", "", LLSaleInfo::DEFAULT, 0, 0); //Update some stuff I guess LLInventoryModel::update_map_t update; ++update[item->getParentUUID()]; gInventory.accountForUpdate(update); gInventory.updateItem(item); gInventory.notifyObservers(); wear_inventory_item_on_avatar(item); }
void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status) // StoreAssetData callback (fixed) { LLResourceData* data = (LLResourceData*)user_data; S32 expected_upload_cost = data ? data->mExpectedUploadCost : 0; //LLAssetType::EType pref_loc = data->mPreferredLocation; BOOL is_balance_sufficient = TRUE; if(result >= 0) { LLAssetType::EType dest_loc = (data->mPreferredLocation == LLAssetType::AT_NONE) ? data->mAssetInfo.mType : data->mPreferredLocation; if (LLAssetType::AT_SOUND == data->mAssetInfo.mType || LLAssetType::AT_TEXTURE == data->mAssetInfo.mType || LLAssetType::AT_ANIMATION == data->mAssetInfo.mType) { // Charge the user for the upload. LLViewerRegion* region = gAgent.getRegion(); if(!(can_afford_transaction(expected_upload_cost))) { LLFloaterBuyCurrency::buyCurrency( llformat("Uploading %s costs", data->mAssetInfo.getName().c_str()), // *TODO: Translate expected_upload_cost); is_balance_sufficient = FALSE; } else if(region) { // Charge user for upload gStatusBar->debitBalance(expected_upload_cost); LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_MoneyTransferRequest); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_MoneyData); msg->addUUIDFast(_PREHASH_SourceID, gAgent.getID()); msg->addUUIDFast(_PREHASH_DestID, LLUUID::null); msg->addU8("Flags", 0); // we tell the sim how much we were expecting to pay so it // can respond to any discrepancy msg->addS32Fast(_PREHASH_Amount, expected_upload_cost); msg->addU8Fast(_PREHASH_AggregatePermNextOwner, (U8)LLAggregatePermissions::AP_EMPTY); msg->addU8Fast(_PREHASH_AggregatePermInventory, (U8)LLAggregatePermissions::AP_EMPTY); msg->addS32Fast(_PREHASH_TransactionType, TRANS_UPLOAD_CHARGE); msg->addStringFast(_PREHASH_Description, NULL); msg->sendReliable(region->getHost()); } } if(is_balance_sufficient) { // Actually add the upload to inventory llinfos << "Adding " << uuid << " to inventory." << llendl; LLUUID folder_id(gInventory.findCategoryUUIDForType(dest_loc)); if(folder_id.notNull()) { U32 next_owner_perms = data->mNextOwnerPerm; if(PERM_NONE == next_owner_perms) { next_owner_perms = PERM_MOVE | PERM_TRANSFER; } create_inventory_item(gAgent.getID(), gAgent.getSessionID(), folder_id, data->mAssetInfo.mTransactionID, data->mAssetInfo.getName(), data->mAssetInfo.getDescription(), data->mAssetInfo.mType, data->mInventoryType, NOT_WEARABLE, next_owner_perms, LLPointer<LLInventoryCallback>(NULL)); } else { llwarns << "Can't find a folder to put it in" << llendl; } } } else // if(result >= 0) { LLSD args; args["FILE"] = LLInventoryType::lookupHumanReadable(data->mInventoryType); args["REASON"] = std::string(LLAssetStorage::getErrorString(result)); LLNotifications::instance().add("CannotUploadReason", args); } LLUploadDialog::modalUploadFinished(); delete data; // *NOTE: This is a pretty big hack. What this does is check the // file picker if there are any more pending uploads. If so, // upload that file. const std::string& next_file = LLFilePicker::instance().getNextFile(); if(is_balance_sufficient && !next_file.empty()) { std::string asset_name = gDirUtilp->getBaseFileName(next_file, true); 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; void *userdata = NULL; upload_new_resource(next_file, asset_name, asset_name, // file 0, LLAssetType::AT_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); } }
void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result) // StoreAssetData callback (fixed) { LLResourceData* data = (LLResourceData*)user_data; //LLAssetType::EType pref_loc = data->mPreferredLocation; BOOL is_balance_sufficient = TRUE; if(result >= 0) { LLAssetType::EType dest_loc = (data->mPreferredLocation == LLAssetType::AT_NONE) ? data->mAssetInfo.mType : data->mPreferredLocation; if (LLAssetType::AT_SOUND == data->mAssetInfo.mType || LLAssetType::AT_TEXTURE == data->mAssetInfo.mType || LLAssetType::AT_ANIMATION == data->mAssetInfo.mType) { // Charge the user for the upload. LLViewerRegion* region = gAgent.getRegion(); S32 upload_cost = gGlobalEconomy->getPriceUpload(); if(!(can_afford_transaction(upload_cost))) { LLFloaterBuyCurrency::buyCurrency( llformat("Uploading %s costs", data->mAssetInfo.getName().c_str()), upload_cost); is_balance_sufficient = FALSE; } else if(region) { // Charge user for upload gStatusBar->debitBalance(upload_cost); LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_MoneyTransferRequest); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_MoneyData); msg->addUUIDFast(_PREHASH_SourceID, gAgent.getID()); msg->addUUIDFast(_PREHASH_DestID, LLUUID::null); msg->addU8("Flags", 0); msg->addS32Fast(_PREHASH_Amount, upload_cost); msg->addU8Fast(_PREHASH_AggregatePermNextOwner, (U8)LLAggregatePermissions::AP_EMPTY); msg->addU8Fast(_PREHASH_AggregatePermInventory, (U8)LLAggregatePermissions::AP_EMPTY); msg->addS32Fast(_PREHASH_TransactionType, TRANS_UPLOAD_CHARGE); msg->addStringFast(_PREHASH_Description, NULL); msg->sendReliable(region->getHost()); } } if(is_balance_sufficient) { // Actually add the upload to inventory llinfos << "Adding " << uuid << " to inventory." << llendl; LLUUID folder_id(gInventory.findCategoryUUIDForType(dest_loc)); if(folder_id.notNull()) { U32 next_owner_perm = data->mNextOwnerPerm; if(PERM_NONE == next_owner_perm) { next_owner_perm = PERM_MOVE | PERM_TRANSFER; } create_inventory_item(gAgent.getID(), gAgent.getSessionID(), folder_id, data->mAssetInfo.mTransactionID, data->mAssetInfo.getName(), data->mAssetInfo.getDescription(), data->mAssetInfo.mType, data->mInventoryType, NOT_WEARABLE, next_owner_perm, LLPointer<LLInventoryCallback>(NULL)); } else { llwarns << "Can't find a folder to put it in" << llendl; } } } else // if(result >= 0) { LLStringBase<char>::format_map_t args; args["[FILE]"] = LLInventoryType::lookupHumanReadable(data->mInventoryType); args["[REASON]"] = LLString(LLAssetStorage::getErrorString(result)); gViewerWindow->alertXml("CannotUploadReason", args); } LLUploadDialog::modalUploadFinished(); delete data; // *NOTE: This is a pretty big hack. What this does is check the // file picker if there are any more pending uploads. If so, // upload that file. const char* next_file = LLFilePicker::instance().getNextFile(); if(is_balance_sufficient && next_file) { const char* name = LLFilePicker::instance().getDirname(); LLString asset_name = name; LLString::replaceNonstandardASCII( asset_name, '?' ); LLString::replaceChar(asset_name, '|', '?'); LLString::stripNonprintable(asset_name); LLString::trim(asset_name); char* asset_name_str = (char*)asset_name.c_str(); char* end_p = strrchr(asset_name_str, '.'); // strip extension if exists if( !end_p ) { end_p = asset_name_str + strlen( asset_name_str ); /* Flawfinder: ignore */ } S32 len = llmin( (S32) (DB_INV_ITEM_NAME_STR_LEN), (S32) (end_p - asset_name_str) ); asset_name = asset_name.substr( 0, len ); upload_new_resource(next_file, asset_name, asset_name, // file 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE); } }