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; }
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); }
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); }
void LLPanelPermissions::setAllSaleInfo() { llinfos << "LLPanelPermissions::setAllSaleInfo()" << llendl; LLSaleInfo::EForSale sale_type = LLSaleInfo::FS_NOT; LLStringUtil::format_map_t argsCurrency; argsCurrency["[CURRENCY]"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); LLCheckBoxCtrl *checkPurchase = getChild<LLCheckBoxCtrl>("checkbox for sale"); // Set the sale type if the object(s) are for sale. if(checkPurchase && checkPurchase->get()) { LLRadioGroup* RadioSaleType = getChild<LLRadioGroup>("sale type"); if(RadioSaleType) { switch(RadioSaleType->getSelectedIndex()) { case 0: sale_type = LLSaleInfo::FS_ORIGINAL; break; case 1: sale_type = LLSaleInfo::FS_COPY; break; case 2: sale_type = LLSaleInfo::FS_CONTENTS; break; default: sale_type = LLSaleInfo::FS_COPY; break; } } } S32 price = -1; LLLineEditor *editPrice = getChild<LLLineEditor>("Edit Cost"); if (editPrice) { // Don't extract the price if it's labeled as MIXED or is empty. const std::string& editPriceString = editPrice->getText(); if (editPriceString != getString("Cost Mixed", argsCurrency) && !editPriceString.empty()) { price = atoi(editPriceString.c_str()); } else { price = DEFAULT_PRICE; } } // If somehow an invalid price, turn the sale off. if (price < 0) sale_type = LLSaleInfo::FS_NOT; // Force the sale price of not-for-sale items to DEFAULT_PRICE. if (sale_type == LLSaleInfo::FS_NOT) { price = DEFAULT_PRICE; } // Pack up the sale info and send the update. LLSaleInfo sale_info(sale_type, price); LLSelectMgr::getInstance()->selectionSetObjectSaleInfo(sale_info); // If turned off for-sale, make sure click-action buy is turned // off as well if (sale_type == LLSaleInfo::FS_NOT) { U8 click_action = 0; LLSelectMgr::getInstance()->selectionGetClickAction(&click_action); if (click_action == CLICK_ACTION_BUY) { LLSelectMgr::getInstance()->selectionSetClickAction(CLICK_ACTION_TOUCH); } } }
void LLFloaterProperties::updateSaleInfo() { LLViewerInventoryItem* item = (LLViewerInventoryItem*)findItem(); if(!item) return; LLSaleInfo sale_info(item->getSaleInfo()); if(!gAgent.allowOperation(PERM_TRANSFER, item->getPermissions(), GP_OBJECT_SET_SALE)) { getChild<LLUICtrl>("CheckPurchase")->setValue(LLSD((BOOL)FALSE)); } if((BOOL)getChild<LLUICtrl>("CheckPurchase")->getValue()) { // turn on sale info LLSaleInfo::EForSale sale_type = LLSaleInfo::FS_COPY; LLRadioGroup* RadioSaleType = getChild<LLRadioGroup>("RadioSaleType"); if(RadioSaleType) { switch (RadioSaleType->getSelectedIndex()) { case 0: sale_type = LLSaleInfo::FS_ORIGINAL; break; case 1: sale_type = LLSaleInfo::FS_COPY; break; case 2: sale_type = LLSaleInfo::FS_CONTENTS; break; default: sale_type = LLSaleInfo::FS_COPY; break; } } if (sale_type == LLSaleInfo::FS_COPY && !gAgent.allowOperation(PERM_COPY, item->getPermissions(), GP_OBJECT_SET_SALE)) { sale_type = LLSaleInfo::FS_ORIGINAL; } S32 price = -1; price = getChild<LLUICtrl>("Edit Cost")->getValue().asInteger();; // Invalid data - turn off the sale if (price < 0) { sale_type = LLSaleInfo::FS_NOT; price = 0; } sale_info.setSaleType(sale_type); sale_info.setSalePrice(price); } else { sale_info.setSaleType(LLSaleInfo::FS_NOT); } if(sale_info != item->getSaleInfo() && item->isFinished()) { LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); // Force an update on the sale price at rez if (item->getType() == LLAssetType::AT_OBJECT) { U32 flags = new_item->getFlags(); flags |= LLInventoryItemFlags::II_FLAGS_OBJECT_SLAM_SALE; new_item->setFlags(flags); } new_item->setSaleInfo(sale_info); if(mObjectID.isNull()) { // This is in the agent's inventory. new_item->updateServer(FALSE); gInventory.updateItem(new_item); gInventory.notifyObservers(); } else { // This is in an object's contents. LLViewerObject* object = gObjectList.findObject(mObjectID); if(object) { object->updateInventory( new_item, TASK_INVENTORY_ITEM_KEY, false); } } } else { // need to make sure we don't just follow the click refresh(); } }