void permission_object_t::test<6>() { LLPermissions perm; LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8"); perm.init(creator,owner,lastOwner,group); ensure_equals("getSafeOwner:failed ", owner,perm.getSafeOwner()); ///NULL Owner perm.init(creator,LLUUID::null,lastOwner,group); ensure_equals("getSafeOwner:failed ", group, perm.getSafeOwner()); }
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; }
LLWearable* LLWearableList::createNewWearable( LLWearableType::EType type ) { lldebugs << "LLWearableList::createNewWearable()" << llendl; LLWearable *wearable = generateNewWearable(); wearable->setType( type ); std::string name = LLWearableType::getTypeDefaultNewName(wearable->getType()); wearable->setName( name ); LLPermissions perm; perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); perm.initMasks(PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, PERM_MOVE | PERM_TRANSFER); wearable->setPermissions(perm); // Description and sale info have default values. wearable->setParamsToDefaults(); wearable->setTexturesToDefaults(); //mark all values (params & images) as saved wearable->saveValues(); // Send to the dataserver wearable->saveNewAsset(); return wearable; }
LLPermissions ll_permissions_from_sd(const LLSD& sd_perm) { LLPermissions rv; rv.init( sd_perm[PERM_CREATOR_ID_LABEL].asUUID(), sd_perm[PERM_OWNER_ID_LABEL].asUUID(), sd_perm[PERM_LAST_OWNER_ID_LABEL].asUUID(), sd_perm[PERM_GROUP_ID_LABEL].asUUID()); // We do a cast to U32 here since LLSD does not attempt to // represent unsigned ints. PermissionMask mask; mask = (U32)(sd_perm[PERM_BASE_MASK_LABEL].asInteger()); rv.setMaskBase(mask); mask = (U32)(sd_perm[PERM_OWNER_MASK_LABEL].asInteger()); rv.setMaskOwner(mask); mask = (U32)(sd_perm[PERM_EVERYONE_MASK_LABEL].asInteger()); rv.setMaskEveryone(mask); mask = (U32)(sd_perm[PERM_GROUP_MASK_LABEL].asInteger()); rv.setMaskGroup(mask); mask = (U32)(sd_perm[PERM_NEXT_OWNER_MASK_LABEL].asInteger()); rv.setMaskNext(mask); rv.fix(); return rv; }
// static void LLPanelContents::onClickNewScript(void *userdata) { const BOOL children_ok = TRUE; LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject(children_ok); if(object) { // [RLVa:KB] - Checked: 2010-03-31 (RLVa-1.2.0c) | Modified: RLVa-1.0.5a if (rlv_handler_t::isEnabled()) // Fallback code [see LLPanelContents::getState()] { if (gRlvAttachmentLocks.isLockedAttachment(object->getRootEdit())) { return; // Disallow creating new scripts in a locked attachment } else if ( (gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SITTP)) ) { if ( (isAgentAvatarValid()) && (gAgentAvatarp->isSitting()) && (gAgentAvatarp->getRoot() == object->getRootEdit()) ) return; // .. or in a linkset the avie is sitting on under @unsit=n/@sittp=n } } // [/RLVa:KB] LLPermissions perm; perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); // Parameters are base, owner, everyone, group, next perm.initMasks( PERM_ALL, PERM_ALL, LLFloaterPerms::getEveryonePerms("Scripts"), LLFloaterPerms::getGroupPerms("Scripts"), PERM_MOVE | LLFloaterPerms::getNextOwnerPerms("Scripts")); std::string desc; LLViewerAssetType::generateDescriptionFor(LLAssetType::AT_LSL_TEXT, desc); LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem( LLUUID::null, LLUUID::null, perm, LLUUID::null, LLAssetType::AT_LSL_TEXT, LLInventoryType::IT_LSL, "New Script", desc, LLSaleInfo::DEFAULT, LLInventoryItemFlags::II_FLAGS_NONE, time_corrected()); object->saveScript(new_item, TRUE, true); std::string name = new_item->getName(); // *NOTE: In order to resolve SL-22177, we needed to create // the script first, and then you have to click it in // inventory to edit it. // *TODO: The script creation should round-trip back to the // viewer so the viewer can auto-open the script and start // editing ASAP. } }
// static void LLPanelContents::onClickNewScript(void *userdata) { const BOOL children_ok = TRUE; LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject(children_ok); if(object) { LLPermissions perm; perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); perm.initMasks( PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, PERM_MOVE | PERM_TRANSFER); std::string desc; LLAssetType::generateDescriptionFor(LLAssetType::AT_LSL_TEXT, desc); LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem( LLUUID::null, LLUUID::null, perm, LLUUID::null, LLAssetType::AT_LSL_TEXT, LLInventoryType::IT_LSL, std::string("New Script"), desc, LLSaleInfo::DEFAULT, LLViewerInventoryItem::II_FLAGS_NONE, time_corrected()); object->saveScript(new_item, TRUE, true); // *NOTE: In order to resolve SL-22177, we needed to create // the script first, and then you have to click it in // inventory to edit it. // *TODO: The script creation should round-trip back to the // viewer so the viewer can auto-open the script and start // editing ASAP. #if 0 S32 left, top; gFloaterView->getNewFloaterPosition(&left, &top); LLRect rect = gSavedSettings.getRect("PreviewScriptRect"); rect.translate( left - rect.mLeft, top - rect.mTop ); LLLiveLSLEditor* editor; editor = new LLLiveLSLEditor("script ed", rect, "Script: New Script", object->mID, LLUUID::null); editor->open(); /*Flawfinder: ignore*/ // keep onscreen gFloaterView->adjustToFitScreen(editor, FALSE); #endif } }
void permission_object_t::test<7>() { LLPermissions perm1; LLUUID uuid; BOOL is_group_owned = FALSE; ensure("1:getOwnership:failed ", (FALSE == perm1.getOwnership(uuid,is_group_owned))); LLPermissions perm; LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8"); perm.init(creator,owner,lastOwner,group); perm.getOwnership(uuid,is_group_owned); ensure("2:getOwnership:failed ", ((uuid == owner) && (FALSE == is_group_owned))); perm.init(creator,LLUUID::null,lastOwner,group); perm.getOwnership(uuid,is_group_owned); ensure("3:getOwnership:failed ", ((uuid == group) && (TRUE == is_group_owned))); }
// <edit> //static void LLFloaterTexturePicker::onBtnCpToInv(void* userdata) { LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; LLUUID mUUID = self->mImageAssetID; LLAssetType::EType asset_type = LLAssetType::AT_TEXTURE; LLInventoryType::EType inv_type = LLInventoryType::IT_TEXTURE; const LLUUID folder_id = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(asset_type)); if(folder_id.notNull()) { std::string name; std::string desc; name.assign("temp."); desc.assign(mUUID.asString()); name.append(mUUID.asString()); LLUUID item_id; item_id.generate(); LLPermissions perm; perm.init(gAgentID, gAgentID, LLUUID::null, LLUUID::null); U32 next_owner_perm = PERM_MOVE | PERM_TRANSFER; perm.initMasks(PERM_ALL, PERM_ALL, PERM_NONE,PERM_NONE, next_owner_perm); S32 creation_date_now = time_corrected(); LLPointer<LLViewerInventoryItem> item = new LLViewerInventoryItem(item_id, folder_id, perm, mUUID, asset_type, inv_type, name, desc, LLSaleInfo::DEFAULT, LLInventoryItemFlags::II_FLAGS_NONE, creation_date_now); item->updateServer(TRUE); gInventory.updateItem(item); gInventory.notifyObservers(); LLInventoryPanel *active_panel = LLInventoryPanel::getActiveInventoryPanel(); if (active_panel) { active_panel->openSelected(); LLFocusableElement* focus = gFocusMgr.getKeyboardFocus(); gFocusMgr.setKeyboardFocus(focus); } } else { llwarns << "Can't find a folder to put it in" << llendl; } }
void permission_object_t::test<17>() { LLPermissions perm; LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); LLUUID owner; LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8"); LLUUID agent; ensure("1:allowMoveBy():failed ", perm.allowTransferTo(agent)); perm.init(creator,owner,lastOwner,group); ensure("2:allowMoveBy():failed ", perm.allowTransferTo(agent)); }
void permission_object_t::test<2>() { LLPermissions permissions; LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8"); permissions.init(creator, owner, lastOwner, group); ensure_equals("init/getCreator():failed to return the creator ", creator, permissions.getCreator()); ensure_equals("init/getOwner():failed to return the owner ", owner, permissions.getOwner()); ensure_equals("init/getLastOwner():failed to return the group ", lastOwner, permissions.getLastOwner()); ensure_equals("init/getGroup():failed to return the group ", group, permissions.getGroup()); }
void permission_object_t::test<13>() { LLPermissions perm; LLUUID agent; LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8"); U32 bits = 10; ensure("allowOperationBy():failed ", (TRUE == perm.allowOperationBy(bits,agent,group))); LLUUID agent1("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); perm.init(creator,owner,lastOwner,group); ensure("allowOperationBy():failed ", (TRUE == perm.allowOperationBy(bits,agent1,group))); }
void permission_object_t::test<16>() { LLPermissions perm; LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); LLUUID owner; LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8"); perm.init(creator,owner,lastOwner,group); LLUUID agent; ensure("1:allowMoveBy():failed ", (TRUE == perm.allowMoveBy(agent))); ensure("2:allowMoveBy():failed ", (TRUE == perm.allowMoveBy(agent,group))); U32 val1 = 0x7FFFFFFF; S32 sVal = 1 << 19; sVal = val1 & sVal; LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8"); ensure("3:allowMoveBy():failed ", (sVal == perm.allowMoveBy(agent1))); ensure("4:allowMoveBy():failed ", (sVal == perm.allowMoveBy(agent1,group))); }
// static void LLPanelContents::onClickNewScript(void *userdata) { const BOOL children_ok = TRUE; LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject(children_ok); if(object) { LLPermissions perm; perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); perm.initMasks( PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, PERM_MOVE | PERM_TRANSFER); std::string desc; LLViewerAssetType::generateDescriptionFor(LLAssetType::AT_LSL_TEXT, desc); LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem( LLUUID::null, LLUUID::null, perm, LLUUID::null, LLAssetType::AT_LSL_TEXT, LLInventoryType::IT_LSL, LLTrans::getString("PanelContentsNewScript"), desc, LLSaleInfo::DEFAULT, LLViewerInventoryItem::II_FLAGS_NONE, time_corrected()); object->saveScript(new_item, TRUE, true); // *NOTE: In order to resolve SL-22177, we needed to create // the script first, and then you have to click it in // inventory to edit it. // *TODO: The script creation should round-trip back to the // viewer so the viewer can auto-open the script and start // editing ASAP. #if 0 LLFloaterReg::showInstance("preview_scriptedit", LLSD(inv_item->getUUID()), TAKE_FOCUS_YES); #endif } }
LLPointer<LLInventoryItem> create_random_inventory_item() { LLUUID item_id; item_id.generate(); LLUUID parent_id; parent_id.generate(); LLPermissions perm; LLUUID creator_id; creator_id.generate(); LLUUID owner_id; owner_id.generate(); LLUUID last_owner_id; last_owner_id.generate(); LLUUID group_id; group_id.generate(); perm.init(creator_id, owner_id, last_owner_id, group_id); perm.initMasks(PERM_ALL, PERM_ALL, PERM_COPY, PERM_COPY, PERM_MODIFY | PERM_COPY); LLUUID asset_id; asset_id.generate(); S32 price = rand(); LLSaleInfo sale_info(LLSaleInfo::FS_COPY, price); U32 flags = rand(); S32 creation = time(NULL); LLPointer<LLInventoryItem> item = new LLInventoryItem( item_id, parent_id, perm, asset_id, LLAssetType::AT_OBJECT, LLInventoryType::IT_ATTACHMENT, "Sample Object", "Used for Testing", sale_info, flags, creation); return item; }
// Allow calling cards to be dropped onto text fields. Append the name and // a carriage return. // virtual BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string& tooltip_msg) { BOOL handled = FALSE; LLToolDragAndDrop::ESource source = LLToolDragAndDrop::getInstance()->getSource(); if (LLToolDragAndDrop::SOURCE_NOTECARD == source) { // We currently do not handle dragging items from one notecard to another // since items in a notecard must be in Inventory to be verified. See DEV-2891. return FALSE; } if (mTakesNonScrollClicks) { if (getEnabled() && acceptsTextInput()) { switch( cargo_type ) { // <edit> // This does not even appear to be used maybe // Throwing it out so I can embed calling cards /* case DAD_CALLINGCARD: if(acceptsCallingCardNames()) { if (drop) { LLInventoryItem *item = (LLInventoryItem *)cargo_data; std::string name = item->getName(); appendText(name, true, true); } *accept = ACCEPT_YES_COPY_SINGLE; } else { *accept = ACCEPT_NO; } break; */ case DAD_CALLINGCARD: // </edit> case DAD_TEXTURE: case DAD_SOUND: case DAD_LANDMARK: case DAD_SCRIPT: case DAD_CLOTHING: case DAD_OBJECT: case DAD_NOTECARD: case DAD_BODYPART: case DAD_ANIMATION: case DAD_GESTURE: { LLInventoryItem *item = (LLInventoryItem *)cargo_data; // <edit> if((item->getPermissions().getMaskOwner() & PERM_ITEM_UNRESTRICTED) != PERM_ITEM_UNRESTRICTED) { if(gSavedSettings.getBOOL("ForceNotecardDragCargoPermissive")) { item = new LLInventoryItem((LLInventoryItem *)cargo_data); LLPermissions old = item->getPermissions(); LLPermissions perm; perm.init(old.getCreator(), old.getOwner(), old.getLastOwner(), old.getGroup()); perm.setMaskBase(PERM_ITEM_UNRESTRICTED); perm.setMaskEveryone(PERM_ITEM_UNRESTRICTED); perm.setMaskGroup(PERM_ITEM_UNRESTRICTED); perm.setMaskNext(PERM_ITEM_UNRESTRICTED); perm.setMaskOwner(PERM_ITEM_UNRESTRICTED); item->setPermissions(perm); } } // </edit> if( item && allowsEmbeddedItems() ) { U32 mask_next = item->getPermissions().getMaskNextOwner(); // <edit> //if((mask_next & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) if(((mask_next & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) || gSavedSettings.getBOOL("ForceNotecardDragCargoAcceptance")) { if( drop ) { deselect(); S32 old_cursor = mCursorPos; setCursorAtLocalPos( x, y, TRUE ); S32 insert_pos = mCursorPos; setCursorPos(old_cursor); BOOL inserted = insertEmbeddedItem( insert_pos, item ); if( inserted && (old_cursor > mCursorPos) ) { setCursorPos(mCursorPos + 1); } updateLineStartList(); } *accept = ACCEPT_YES_COPY_MULTI; } else { *accept = ACCEPT_NO; if (tooltip_msg.empty()) { tooltip_msg.assign("Only items with unrestricted\n" "'next owner' permissions \n" "can be attached to notecards."); } } } else { *accept = ACCEPT_NO; } break; } default: *accept = ACCEPT_NO; break; } } else { // Not enabled *accept = ACCEPT_NO; } handled = TRUE; LL_DEBUGS("UserInput") << "dragAndDrop handled by LLViewerTextEditor " << getName() << LL_ENDL; } return handled; }
virtual void uploadComplete(const LLSD& content) { llinfos << "Adding " << content["new_inventory_item"].asUUID() << " " << content["new_asset"].asUUID() << " to inventory." << llendl; //LLPointer<LLInventoryCallback> cb = new LLImportTransferCallback(mData); if(mPostData["folder_id"].asUUID().notNull()) { LLPermissions perm; U32 everyone_perms = PERM_NONE; U32 group_perms = PERM_NONE; U32 next_owner_perms = PERM_ALL; perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); if(content.has("new_next_owner_mask")) { // This is a new sim that provides creation perms so use them. // Do not assume we got the perms we asked for in mPostData // since the sim may not have granted them all. everyone_perms = content["new_everyone_mask"].asInteger(); group_perms = content["new_group_mask"].asInteger(); next_owner_perms = content["new_next_owner_mask"].asInteger(); } else { // This old sim doesn't provide creation perms so use old assumption-based perms. if(mPostData["inventory_type"].asString() != "snapshot") { next_owner_perms = PERM_MOVE | PERM_TRANSFER; } } perm.initMasks(PERM_ALL, PERM_ALL, everyone_perms, group_perms, next_owner_perms); S32 creation_date_now = time_corrected(); LLPointer<LLViewerInventoryItem> item = new LLViewerInventoryItem(content["new_inventory_item"].asUUID(), mPostData["folder_id"].asUUID(), perm, content["new_asset"].asUUID(), mData->type, mData->inv_type, mPostData["name"].asString(), mPostData["description"].asString(), LLSaleInfo::DEFAULT, LLInventoryItemFlags::II_FLAGS_NONE, creation_date_now); gInventory.updateItem(item); gInventory.notifyObservers(); LLXmlImport::sTextureReplace[mData->oldassetid] = content["new_asset"].asUUID(); } LLXmlImport::sUploadedAssets++; if(!LLXmlImport::sImportInProgress) return; LLFloaterImportProgress::update(); if(LLXmlImport::sUploadedAssets < LLXmlImport::sTotalAssets) { LLImportAssetData* data = LLXmlImport::sXmlImportOptions->mAssets[LLXmlImport::sUploadedAssets]; data->folderid = mData->folderid; std::string url = gAgent.getRegion()->getCapability("NewFileAgentInventory"); if(!url.empty()) { LLPointer<LLImageJ2C> integrity_test = new LLImageJ2C; if( !integrity_test->loadAndValidate( data->filename ) ) { llinfos << "Image: " << data->filename << " is corrupt." << llendl; } S32 file_size; LLAPRFile infile ; infile.open(data->filename, LL_APR_RB, LLAPRFile::short_lived, &file_size); if (infile.getFileHandle()) { LLVFile file(gVFS, data->assetid, data->type, 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); } LLSD body; body["folder_id"] = data->folderid; body["asset_type"] = LLAssetType::lookup(data->type); body["inventory_type"] = LLInventoryType::lookup(data->inv_type); body["name"] = data->name; body["description"] = data->description; body["next_owner_mask"] = LLSD::Integer(U32_MAX); body["group_mask"] = LLSD::Integer(U32_MAX); body["everyone_mask"] = LLSD::Integer(U32_MAX); body["expected_upload_cost"] = LLSD::Integer(LLGlobalEconomy::Singleton::getInstance()->getPriceUpload()); LLHTTPClient::post(url, body, new LLImportInventoryResponder(body, data->assetid, data->type,data)); } } else llinfos << "NewFileAgentInventory does not exist!!!!" << llendl; } else LLXmlImport::finish_init(); }
// static void LLPanelContents::onClickNewScript(void *userdata) { const BOOL children_ok = TRUE; LLViewerObject* object = gSelectMgr->getSelection()->getFirstRootObject(children_ok); if(object) { //MK if (RRenabled) { // can't edit objects that someone is sitting on, // when prevented from sit-tping if (gAgent.mRRInterface.contains ("sittp") || gAgent.mRRInterface.mContainsUnsit) { if (object->isSeat()) { return; } } if (!gAgent.mRRInterface.isAllowed (object->getRootEdit()->getID(), "detach")) { return; } LLVOAvatar *avatarp = gAgent.getAvatarObject(); LLUUID inv_item_id = LLUUID::null; LLInventoryItem* inv_item = gAgent.mRRInterface.getItem(object->getRootEdit()->getID()); if (inv_item) inv_item_id = inv_item->getUUID(); if (avatarp && gAgent.mRRInterface.contains("detach:"+avatarp->getAttachedPointName(inv_item_id))) { return; } } //mk LLPermissions perm; perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); perm.initMasks( PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, PERM_MOVE | PERM_TRANSFER); LLString desc; LLAssetType::generateDescriptionFor(LLAssetType::AT_LSL_TEXT, desc); LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem( LLUUID::null, LLUUID::null, perm, LLUUID::null, LLAssetType::AT_LSL_TEXT, LLInventoryType::IT_LSL, LLString("New Script"), desc, LLSaleInfo::DEFAULT, LLViewerInventoryItem::II_FLAGS_NONE, time_corrected()); object->saveScript(new_item, TRUE, true); // *NOTE: In order to resolve SL-22177, we needed to create // the script first, and then you have to click it in // inventory to edit it. // *TODO: The script creation should round-trip back to the // viewer so the viewer can auto-open the script and start // editing ASAP. #if 0 S32 left, top; gFloaterView->getNewFloaterPosition(&left, &top); LLRect rect = gSavedSettings.getRect("PreviewScriptRect"); rect.translate( left - rect.mLeft, top - rect.mTop ); LLLiveLSLEditor* editor; editor = new LLLiveLSLEditor("script ed", rect, "Script: New Script", object->mID, LLUUID::null); editor->open(); /*Flawfinder: ignore*/ // keep onscreen gFloaterView->adjustToFitScreen(editor, FALSE); #endif } }
//virtual void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) { lldebugs << "LLNewAgentInventoryResponder::result from capabilities" << llendl; LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString()); LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString()); // Update L$ and ownership credit information // since it probably changed on the server if (asset_type == LLAssetType::AT_TEXTURE || asset_type == LLAssetType::AT_SOUND || asset_type == LLAssetType::AT_ANIMATION) { gMessageSystem->newMessageFast(_PREHASH_MoneyBalanceRequest); gMessageSystem->nextBlockFast(_PREHASH_AgentData); gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); gMessageSystem->nextBlockFast(_PREHASH_MoneyData); gMessageSystem->addUUIDFast(_PREHASH_TransactionID, LLUUID::null ); gAgent.sendReliableMessage(); LLStringUtil::format_map_t args; args["[AMOUNT]"] = llformat("%d",LLGlobalEconomy::Singleton::getInstance()->getPriceUpload()); LLNotifyBox::showXml("UploadPayment", args); } // Actually add the upload to viewer inventory llinfos << "Adding " << content["new_inventory_item"].asUUID() << " " << content["new_asset"].asUUID() << " to inventory." << llendl; if(mPostData["folder_id"].asUUID().notNull()) { LLPermissions perm; U32 next_owner_perm; perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); if (mPostData["inventory_type"].asString() == "snapshot") { next_owner_perm = PERM_ALL; } else { next_owner_perm = PERM_MOVE | PERM_TRANSFER; } perm.initMasks(PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, next_owner_perm); S32 creation_date_now = time_corrected(); LLPointer<LLViewerInventoryItem> item = new LLViewerInventoryItem(content["new_inventory_item"].asUUID(), mPostData["folder_id"].asUUID(), perm, content["new_asset"].asUUID(), asset_type, inventory_type, mPostData["name"].asString(), mPostData["description"].asString(), LLSaleInfo::DEFAULT, LLInventoryItem::II_FLAGS_NONE, creation_date_now); gInventory.updateItem(item); gInventory.notifyObservers(); // Show the preview panel for textures and sounds to let // user know that the image (or snapshot) arrived intact. LLInventoryView* view = LLInventoryView::getActiveInventory(); if(view) { LLUICtrl* focus_ctrl = gFocusMgr.getKeyboardFocus(); view->getPanel()->setSelection(content["new_inventory_item"].asUUID(), TAKE_FOCUS_NO); if((LLAssetType::AT_TEXTURE == asset_type) || (LLAssetType::AT_SOUND == asset_type)) { view->getPanel()->openSelected(); } //LLInventoryView::dumpSelectionInformation((void*)view); // restore keyboard focus gFocusMgr.setKeyboardFocus(focus_ctrl); } } else { llwarns << "Can't find a folder to put it in" << llendl; } // remove the "Uploading..." message LLUploadDialog::modalUploadFinished(); // *FIX: 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. std::string next_file = LLFilePicker::instance().getNextFile(); if(!next_file.empty()) { std::string name = gDirUtilp->getBaseFileName(next_file, true); std::string asset_name = name; LLStringUtil::replaceNonstandardASCII( asset_name, '?' ); LLStringUtil::replaceChar(asset_name, '|', '?'); LLStringUtil::stripNonprintable(asset_name); LLStringUtil::trim(asset_name); upload_new_resource(next_file, asset_name, asset_name, 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE); } }
// static void LLFloaterNewLocalInventory::onClickOK(void* user_data) { LLFloaterNewLocalInventory* floater = (LLFloaterNewLocalInventory*)user_data; LLUUID item_id; item_id.generate(); std::string name = floater->getChild<LLLineEditor>("name_line")->getText(); std::string desc = floater->getChild<LLLineEditor>("desc_line")->getText(); LLUUID asset_id = LLUUID(floater->getChild<LLLineEditor>("asset_id_line")->getText()); LLUUID creator_id = LLUUID(floater->getChild<LLLineEditor>("creator_id_line")->getText()); LLUUID owner_id = LLUUID(floater->getChild<LLLineEditor>("owner_id_line")->getText()); LLAssetType::EType type = LLAssetType::lookup(floater->getChild<LLComboBox>("type_combo")->getValue().asString()); LLInventoryType::EType inv_type = LLInventoryType::IT_NONE; switch(type) { case LLAssetType::AT_TEXTURE: case LLAssetType::AT_TEXTURE_TGA: case LLAssetType::AT_IMAGE_TGA: case LLAssetType::AT_IMAGE_JPEG: inv_type = LLInventoryType::IT_TEXTURE; break; case LLAssetType::AT_SOUND: case LLAssetType::AT_SOUND_WAV: inv_type = LLInventoryType::IT_SOUND; break; case LLAssetType::AT_CALLINGCARD: inv_type = LLInventoryType::IT_CALLINGCARD; break; case LLAssetType::AT_LANDMARK: inv_type = LLInventoryType::IT_LANDMARK; break; case LLAssetType::AT_SCRIPT: inv_type = LLInventoryType::IT_LSL; break; case LLAssetType::AT_CLOTHING: inv_type = LLInventoryType::IT_WEARABLE; break; case LLAssetType::AT_OBJECT: inv_type = LLInventoryType::IT_OBJECT; break; case LLAssetType::AT_NOTECARD: inv_type = LLInventoryType::IT_NOTECARD; break; case LLAssetType::AT_CATEGORY: inv_type = LLInventoryType::IT_CATEGORY; break; //No longer asset types. /*case LLFolderType::FT_ROOT_CATEGORY: case LLFolderType::FT_TRASH: case LLFolderType::FT_SNAPSHOT_CATEGORY: case LLFolderType::FT_LOST_AND_FOUND: inv_type = LLInventoryType::IT_ROOT_CATEGORY; break;*/ case LLAssetType::AT_LSL_TEXT: case LLAssetType::AT_LSL_BYTECODE: inv_type = LLInventoryType::IT_LSL; break; case LLAssetType::AT_BODYPART: inv_type = LLInventoryType::IT_WEARABLE; break; case LLAssetType::AT_ANIMATION: inv_type = LLInventoryType::IT_ANIMATION; break; case LLAssetType::AT_GESTURE: inv_type = LLInventoryType::IT_GESTURE; break; //case LLAssetType::AT_SIMSTATE: default: //inv_type = LLInventoryType::IT_CALLINGCARD; break; } if(inv_type == LLInventoryType::IT_NONE) return; LLPermissions* perms = new LLPermissions(); perms->init(creator_id, owner_id, LLUUID::null, LLUUID::null); LLViewerInventoryItem* item = new LLViewerInventoryItem( item_id, gSystemFolderRoot, *perms, asset_id, type, inv_type, name, desc, LLSaleInfo::DEFAULT, 0, 0); LLLocalInventory::addItem(item); if(floater->childGetValue("chk_open")) { LLLocalInventory::open(item_id); } LLFloaterNewLocalInventory::sLastCreatorId = creator_id; floater->close(); }
void LLInventoryItem::unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size) { // Early exit on an empty binary bucket. if (bin_bucket_size <= 1) return; if (NULL == bin_bucket) { LL_ERRS() << "unpackBinaryBucket failed. bin_bucket is NULL." << LL_ENDL; return; } // Convert the bin_bucket into a string. std::vector<char> item_buffer(bin_bucket_size+1); memcpy(&item_buffer[0], bin_bucket, bin_bucket_size); /* Flawfinder: ignore */ item_buffer[bin_bucket_size] = '\0'; std::string str(&item_buffer[0]); LL_DEBUGS() << "item buffer: " << str << LL_ENDL; // Tokenize the string. typedef boost::tokenizer<boost::char_separator<char> > tokenizer; boost::char_separator<char> sep("|", "", boost::keep_empty_tokens); tokenizer tokens(str, sep); tokenizer::iterator iter = tokens.begin(); // Extract all values. LLUUID item_id; item_id.generate(); setUUID(item_id); LLAssetType::EType type; type = static_cast<LLAssetType::EType>(std::stoi((*(iter++)))); setType( type ); LLInventoryType::EType inv_type; inv_type = static_cast<LLInventoryType::EType>(std::stoi((*(iter++)))); setInventoryType( inv_type ); std::string name((*(iter++)).c_str()); rename( name ); LLUUID creator_id((*(iter++)).c_str()); LLUUID owner_id((*(iter++)).c_str()); LLUUID last_owner_id((*(iter++)).c_str()); LLUUID group_id((*(iter++)).c_str()); PermissionMask mask_base = strtoul((*(iter++)).c_str(), NULL, 16); PermissionMask mask_owner = strtoul((*(iter++)).c_str(), NULL, 16); PermissionMask mask_group = strtoul((*(iter++)).c_str(), NULL, 16); PermissionMask mask_every = strtoul((*(iter++)).c_str(), NULL, 16); PermissionMask mask_next = strtoul((*(iter++)).c_str(), NULL, 16); LLPermissions perm; perm.init(creator_id, owner_id, last_owner_id, group_id); perm.initMasks(mask_base, mask_owner, mask_group, mask_every, mask_next); setPermissions(perm); //LL_DEBUGS() << "perm: " << perm << LL_ENDL; LLUUID asset_id((*(iter++)).c_str()); setAssetUUID(asset_id); std::string desc((*(iter++)).c_str()); setDescription(desc); LLSaleInfo::EForSale sale_type; sale_type = static_cast<LLSaleInfo::EForSale>(std::stoi((*(iter++)))); S32 price = std::stoi(*(iter++)); LLSaleInfo sale_info(sale_type, price); setSaleInfo(sale_info); U32 flags = strtoul((*(iter++)).c_str(), NULL, 16); setFlags(flags); time_t now = time(NULL); setCreationDate(now); }
//virtual virtual void uploadComplete(const LLSD& content) { lldebugs << "LLNewAgentInventoryResponder::result from capabilities" << llendl; LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString()); LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString()); // Update L$ and ownership credit information // since it probably changed on the server if (asset_type == LLAssetType::AT_TEXTURE || asset_type == LLAssetType::AT_SOUND || asset_type == LLAssetType::AT_ANIMATION) { gMessageSystem->newMessageFast(_PREHASH_MoneyBalanceRequest); gMessageSystem->nextBlockFast(_PREHASH_AgentData); gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); gMessageSystem->nextBlockFast(_PREHASH_MoneyData); gMessageSystem->addUUIDFast(_PREHASH_TransactionID, LLUUID::null ); gAgent.sendReliableMessage(); // LLStringUtil::format_map_t args; // args["[AMOUNT]"] = llformat("%d",LLGlobalEconomy::Singleton::getInstance()->getPriceUpload()); // LLNotifyBox::showXml("UploadPayment", args); } // Actually add the upload to viewer inventory llinfos << "Adding " << content["new_inventory_item"].asUUID() << " " << content["new_asset"].asUUID() << " to inventory." << llendl; if(mPostData["folder_id"].asUUID().notNull()) { LLPermissions perm; U32 next_owner_perm; perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); if (mPostData["inventory_type"].asString() == "snapshot") { next_owner_perm = PERM_ALL; } else { next_owner_perm = PERM_MOVE | PERM_TRANSFER; } perm.initMasks(PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, next_owner_perm); S32 creation_date_now = time_corrected(); LLPointer<LLViewerInventoryItem> item = new LLViewerInventoryItem(content["new_inventory_item"].asUUID(), mPostData["folder_id"].asUUID(), perm, content["new_asset"].asUUID(), asset_type, inventory_type, mPostData["name"].asString(), mPostData["description"].asString(), LLSaleInfo::DEFAULT, LLInventoryItem::II_FLAGS_NONE, creation_date_now); gInventory.updateItem(item); gInventory.notifyObservers(); } else { llwarns << "Can't find a folder to put it in" << llendl; } // remove the "Uploading..." message LLUploadDialog::modalUploadFinished(); primbackup::getInstance()->update_map(content["new_asset"].asUUID()); primbackup::getInstance()->upload_next_asset(); }
//virtual virtual void uploadComplete(const LLSD& content) { LLObjectBackup* self = LLObjectBackup::findInstance(); if (!self) { LL_WARNS() << "Import aborted, LLObjectBackup instance gone !" << LL_ENDL; // remove the "Uploading..." message LLUploadDialog::modalUploadFinished(); return; } LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString()); LLInventoryType::EType inv_type = LLInventoryType::lookup(mPostData["inventory_type"].asString()); // Update L$ and ownership credit information // since it probably changed on the server if (asset_type == LLAssetType::AT_TEXTURE || asset_type == LLAssetType::AT_SOUND || asset_type == LLAssetType::AT_ANIMATION) { LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_MoneyBalanceRequest); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgentID); msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID); msg->nextBlockFast(_PREHASH_MoneyData); msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); gAgent.sendReliableMessage(); } // Actually add the upload to viewer inventory LL_INFOS() << "Adding " << content["new_inventory_item"].asUUID() << " " << content["new_asset"].asUUID() << " to inventory." << LL_ENDL; if (mPostData["folder_id"].asUUID().notNull()) { LLPermissions perm; U32 next_owner_perm; perm.init(gAgentID, gAgentID, LLUUID::null, LLUUID::null); if (mPostData["inventory_type"].asString() == "snapshot") { next_owner_perm = PERM_ALL; } else { next_owner_perm = PERM_MOVE | PERM_TRANSFER; } perm.initMasks(PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, next_owner_perm); S32 creation_date_now = time_corrected(); LLPointer<LLViewerInventoryItem> item; item = new LLViewerInventoryItem(content["new_inventory_item"].asUUID(), mPostData["folder_id"].asUUID(), perm, content["new_asset"].asUUID(), asset_type, inv_type, mPostData["name"].asString(), mPostData["description"].asString(), LLSaleInfo::DEFAULT, LLInventoryItemFlags::II_FLAGS_NONE, creation_date_now); gInventory.updateItem(item); gInventory.notifyObservers(); } else { LL_WARNS() << "Can't find a folder to put it into" << LL_ENDL; } // remove the "Uploading..." message LLUploadDialog::modalUploadFinished(); self->updateMap(content["new_asset"].asUUID()); self->uploadNextAsset(); }
void LLInventoryItem::unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size) { // Early exit on an empty binary bucket. if (bin_bucket_size <= 1) return; // Convert the bin_bucket into a string. char* item_buffer = new char[bin_bucket_size+1]; if ((item_buffer != NULL) && (bin_bucket != NULL)) { memcpy(item_buffer, bin_bucket, bin_bucket_size); /* Flawfinder: ignore */ } else { llerrs << "unpackBinaryBucket failed. item_buffer or bin_bucket is Null." << llendl; delete[] item_buffer; return; } item_buffer[bin_bucket_size] = '\0'; std::string str(item_buffer); lldebugs << "item buffer: " << item_buffer << llendl; delete[] item_buffer; // Tokenize the string. typedef boost::tokenizer<boost::char_separator<char> > tokenizer; boost::char_separator<char> sep("|", "", boost::keep_empty_tokens); tokenizer tokens(str, sep); tokenizer::iterator iter = tokens.begin(); // Extract all values. LLUUID item_id; item_id.generate(); setUUID(item_id); LLAssetType::EType type; type = (LLAssetType::EType)(atoi((*(iter++)).c_str())); setType( type ); LLInventoryType::EType inv_type; inv_type = (LLInventoryType::EType)(atoi((*(iter++)).c_str())); setInventoryType( inv_type ); std::string name((*(iter++)).c_str()); rename( name ); LLUUID creator_id((*(iter++)).c_str()); LLUUID owner_id((*(iter++)).c_str()); LLUUID last_owner_id((*(iter++)).c_str()); LLUUID group_id((*(iter++)).c_str()); PermissionMask mask_base = strtoul((*(iter++)).c_str(), NULL, 16); PermissionMask mask_owner = strtoul((*(iter++)).c_str(), NULL, 16); PermissionMask mask_group = strtoul((*(iter++)).c_str(), NULL, 16); PermissionMask mask_every = strtoul((*(iter++)).c_str(), NULL, 16); PermissionMask mask_next = strtoul((*(iter++)).c_str(), NULL, 16); LLPermissions perm; perm.init(creator_id, owner_id, last_owner_id, group_id); perm.initMasks(mask_base, mask_owner, mask_group, mask_every, mask_next); setPermissions(perm); //lldebugs << "perm: " << perm << llendl; LLUUID asset_id((*(iter++)).c_str()); setAssetUUID(asset_id); std::string desc((*(iter++)).c_str()); setDescription(desc); LLSaleInfo::EForSale sale_type; sale_type = (LLSaleInfo::EForSale)(atoi((*(iter++)).c_str())); S32 price = atoi((*(iter++)).c_str()); LLSaleInfo sale_info(sale_type, price); setSaleInfo(sale_info); U32 flags = strtoul((*(iter++)).c_str(), NULL, 16); setFlags(flags); time_t now = time(NULL); setCreationDate(now); }
// static void LLPanelContents::onClickNewScript(void *userdata) { const BOOL children_ok = TRUE; LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject(children_ok); if(object) { // [RLVa:KB] - Checked: 2010-03-31 (RLVa-1.2.0c) | Modified: RLVa-1.0.5a if (rlv_handler_t::isEnabled()) // Fallback code [see LLPanelContents::getState()] { if (gRlvAttachmentLocks.isLockedAttachment(object->getRootEdit())) { return; // Disallow creating new scripts in a locked attachment } else if ( (gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SITTP)) ) { LLVOAvatar* pAvatar = gAgent.getAvatarObject(); if ( (pAvatar) && (pAvatar->mIsSitting) && (pAvatar->getRoot() == object->getRootEdit()) ) return; // .. or in a linkset the avie is sitting on under @unsit=n/@sittp=n } } // [/RLVa:KB] LLPermissions perm; perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); perm.initMasks( PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, PERM_MOVE | PERM_TRANSFER); std::string desc; LLViewerAssetType::generateDescriptionFor(LLAssetType::AT_LSL_TEXT, desc); LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem( LLUUID::null, LLUUID::null, perm, LLUUID::null, LLAssetType::AT_LSL_TEXT, LLInventoryType::IT_LSL, std::string("New Script"), desc, LLSaleInfo::DEFAULT, LLViewerInventoryItem::II_FLAGS_NONE, time_corrected()); object->saveScript(new_item, TRUE, true); // *NOTE: In order to resolve SL-22177, we needed to create // the script first, and then you have to click it in // inventory to edit it. // *TODO: The script creation should round-trip back to the // viewer so the viewer can auto-open the script and start // editing ASAP. #if 0 S32 left, top; gFloaterView->getNewFloaterPosition(&left, &top); LLRect rect = gSavedSettings.getRect("PreviewScriptRect"); rect.translate( left - rect.mLeft, top - rect.mTop ); LLLiveLSLEditor* editor; editor = new LLLiveLSLEditor("script ed", rect, "Script: New Script", object->mID, LLUUID::null); editor->open(); /*Flawfinder: ignore*/ // keep onscreen gFloaterView->adjustToFitScreen(editor, FALSE); #endif } }