void LLPreviewNotecard::draw() { //childSetFocus("Save", FALSE); LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("Notecard Editor"); BOOL script_changed = !editor->isPristine(); childSetEnabled("Save", script_changed && getEnabled()); LLPreview::draw(); }
void LLPreviewNotecard::setEnabled( BOOL enabled ) { LLViewerTextEditor* editor = findChild<LLViewerTextEditor>("Notecard Editor"); if (editor) editor->setEnabled(enabled); if (LLUICtrl* ctrl = findChild<LLUICtrl>("lock")) ctrl->setVisible(!enabled); if (LLUICtrl* ctrl = findChild<LLUICtrl>("desc")) ctrl->setEnabled(enabled); if (LLUICtrl* ctrl = findChild<LLUICtrl>("Save")) ctrl->setEnabled(enabled && editor && !editor->isPristine()); }
void LLFloaterLuaConsole::onClickSend(void *data) { LLFloaterLuaConsole *self = (LLFloaterLuaConsole *)data; LLLineEditor *editor = self->getChild<LLLineEditor>("Lua Editor", TRUE); if(editor->getLength()) { LLColor4 text_color = gSavedSettings.getColor4("llOwnerSayChatColor"); LLViewerTextEditor *out = self->getChild<LLViewerTextEditor>("Lua Output Editor"); out->appendColoredText("] "+editor->getText(), false, true, text_color); //echo command, like a proper console. FLLua::callCommand(editor->getText()); editor->updateHistory(); editor->clear(); } }
// virtual BOOL LLPreviewNotecard::canClose() { LLViewerTextEditor* editor = findChild<LLViewerTextEditor>("Notecard Editor"); if (mForceClose || (editor && editor->isPristine())) { return TRUE; } else { // Bring up view-modal dialog: Save changes? Yes, No, Cancel LLNotificationsUtil::add("SaveChanges", LLSD(), LLSD(), boost::bind(&LLPreviewNotecard::handleSaveChangesDialog,this, _1, _2)); return FALSE; } }
// virtual BOOL LLPreviewNotecard::canClose() { LLViewerTextEditor* editor = LLViewerUICtrlFactory::getViewerTextEditorByName(this, "Notecard Editor"); if(mForceClose || editor->isPristine()) { return TRUE; } else { // Bring up view-modal dialog: Save changes? Yes, No, Cancel gViewerWindow->alertXml("SaveChanges", &LLPreviewNotecard::handleSaveChangesDialog, this); return FALSE; } }
void LLFloaterLuaConsole::addOutput(std::string output, bool error) { LLFloaterLuaConsole *self = sInstance; if(!self) //open but hidden { self=getInstance(); self->setVisible(FALSE); } LLColor4 text_color; if(error) text_color = gSavedSettings.getColor4("ScriptErrorColor"); else text_color = gSavedSettings.getColor4("ObjectChatColor"); LLViewerTextEditor *editor = self->getChild<LLViewerTextEditor>("Lua Output Editor"); editor->setParseHTML(TRUE); editor->setParseHighlights(TRUE); editor->appendColoredText(output, false, true, text_color); }
// <edit> // static void LLPreviewNotecard::onClickGetItems(void* user_data) { LLPreviewNotecard* preview = (LLPreviewNotecard*)user_data; if(preview) { LLViewerTextEditor* editor = preview->getChild<LLViewerTextEditor>("Notecard Editor"); if(editor) { std::vector<LLPointer<LLInventoryItem>> items = editor->getEmbeddedItems(); if(items.size()) { const BOOL use_caps = FALSE; std::vector<LLPointer<LLInventoryItem>>::iterator iter = items.begin(); std::vector<LLPointer<LLInventoryItem>>::iterator end = items.end(); for( ; iter != end; ++iter) { LLInventoryItem* item = static_cast<LLInventoryItem*>(*iter); if(use_caps) { copy_inventory_from_notecard(preview->getObjectID(), preview->getNotecardItemID(), item, 0); } else { // Only one item per message actually works gMessageSystem->newMessageFast(_PREHASH_CopyInventoryFromNotecard); gMessageSystem->nextBlockFast(_PREHASH_AgentData); gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); gMessageSystem->nextBlockFast(_PREHASH_NotecardData); gMessageSystem->addUUIDFast(_PREHASH_NotecardItemID, preview->getNotecardItemID()); gMessageSystem->addUUIDFast(_PREHASH_ObjectID, preview->getObjectID()); gMessageSystem->nextBlockFast(_PREHASH_InventoryData); gMessageSystem->addUUIDFast(_PREHASH_ItemID, item->getUUID()); gMessageSystem->addUUIDFast(_PREHASH_FolderID, gInventory.findCategoryUUIDForType(item->getType())); gAgent.sendReliableMessage(); } } } } } }
void LLPreviewNotecard::saveAs_continued(AIFilePicker* filepicker) { if (!filepicker->hasFilename()) return; LLViewerTextEditor* editor = findChild<LLViewerTextEditor>("Notecard Editor"); std::string buffer; if (editor && !editor->exportBuffer(buffer)) { // FIXME: Notify the user! return; } S32 size = buffer.length(); std::string filename = filepicker->getFilename(); std::ofstream export_file(filename.c_str(), std::ofstream::binary); export_file.write(buffer.c_str(), size); export_file.close(); }
void lggAutoCorrectFloater::onNotecardLoadComplete(LLVFS *vfs,const LLUUID& asset_uuid,LLAssetType::EType type,void* user_data, S32 status, LLExtStat ext_status) { if(status == LL_ERR_NOERR) { S32 size = vfs->getSize(asset_uuid, type); U8* buffer = new U8[size]; vfs->getData(asset_uuid, type, buffer, 0, size); if(type == LLAssetType::AT_NOTECARD) { LLViewerTextEditor* edit = new LLViewerTextEditor("",LLRect(0,0,0,0),S32_MAX,""); if(edit->importBuffer((char*)buffer, (S32)size)) { llinfos << "decode success" << llendl; std::string card = edit->getText(); edit->die(); LLSD info; std::istringstream ins; // Declare an input string stream. ins.str(card); // Specify string to read. LLSDSerialize::fromXML(info,ins); LGGAutoCorrect::getInstance()->addCorrectionList(info); llinfos << "read success" << llendl; sInstance->updateEnabledStuff(); } else { llinfos << "decode error" << llendl; } } } else { llinfos << "read error" << llendl; } }
void LLFloaterBuyLandUI::updateFloaterCovenantText(const std::string &string, const LLUUID& asset_id) { LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("covenant_editor"); editor->setText(string); LLCheckBoxCtrl* check = getChild<LLCheckBoxCtrl>("agree_covenant"); LLTextBox* box = getChild<LLTextBox>("covenant_text"); if (asset_id.isNull()) { check->set(true); check->setEnabled(false); refreshUI(); // remove the line stating that you must agree box->setVisible(FALSE); } else { check->setEnabled(true); // remove the line stating that you must agree box->setVisible(TRUE); } }
BOOL LLPreviewNotecard::postBuild() { LLViewerTextEditor *ed = getChild<LLViewerTextEditor>("Notecard Editor"); ed->setNotecardInfo(mItemUUID, mObjectID, getKey()); ed->makePristine(); childSetAction("Save", onClickSave, this); getChildView("lock")->setVisible( FALSE); childSetAction("Delete", onClickDelete, this); getChildView("Delete")->setEnabled(false); const LLInventoryItem* item = getItem(); childSetCommitCallback("desc", LLPreview::onText, this); if (item) { getChild<LLUICtrl>("desc")->setValue(item->getDescription()); getChildView("Delete")->setEnabled(true); } getChild<LLLineEditor>("desc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe); return LLPreview::postBuild(); }
void LLEmbeddedItems::removeUnusedChars() { std::set<llwchar> used = mEmbeddedUsedChars; const LLWString& wtext = mEditor->getWText(); for (S32 i=0; i<(S32)wtext.size(); i++) { llwchar wc = wtext[i]; if( wc >= LLTextEditor::FIRST_EMBEDDED_CHAR && wc <= LLTextEditor::LAST_EMBEDDED_CHAR ) { used.erase(wc); } } // Remove chars not actually used for (std::set<llwchar>::iterator iter = used.begin(); iter != used.end(); ++iter) { removeEmbeddedItem(*iter); } }
void onOpen() { LLViewerTextEditor* pEditor = dynamic_cast<LLViewerTextEditor*>(&mEditor); if (pEditor) pEditor->openEmbeddedItem(mItem, pEditor->getWText()[pEditor->getCursorPos()]); }
void LLFloaterLuaConsole::onInputEditorGainFocus( LLFocusableElement* caller, void* userdata ) { LLFloaterLuaConsole *self = (LLFloaterLuaConsole *)userdata; LLViewerTextEditor *editor = self->getChild<LLViewerTextEditor>("Lua Output Editor"); editor->setCursorAndScrollToEnd(); }
void onCopyToInventory() { LLViewerTextEditor* pEditor = dynamic_cast<LLViewerTextEditor*>(&mEditor); if (pEditor) pEditor->showCopyToInvDialog(mItem, pEditor->getWText()[pEditor->getCursorPos()]); }
// static void LLPreviewNotecard::onLoadComplete(LLVFS *vfs, const LLUUID& asset_uuid, LLAssetType::EType type, void* user_data, S32 status, LLExtStat ext_status) { llinfos << "LLPreviewNotecard::onLoadComplete()" << llendl; LLUUID* item_id = (LLUUID*)user_data; LLPreviewNotecard* preview = LLPreviewNotecard::getInstance(*item_id); if( preview ) { if(0 == status) { LLVFile file(vfs, asset_uuid, type, LLVFile::READ); S32 file_length = file.getSize(); char* buffer = new char[file_length+1]; file.read((U8*)buffer, file_length); /*Flawfinder: ignore*/ // put a EOS at the end buffer[file_length] = 0; LLViewerTextEditor* previewEditor = LLViewerUICtrlFactory::getViewerTextEditorByName(preview, "Notecard Editor"); if( (file_length > 19) && !strncmp( buffer, "Linden text version", 19 ) ) { if( !previewEditor->importBuffer( buffer ) ) { llwarns << "Problem importing notecard" << llendl; } } else { // Version 0 (just text, doesn't include version number) previewEditor->setText(LLStringExplicit(buffer)); } previewEditor->makePristine(); const LLInventoryItem* item = preview->getItem(); BOOL modifiable = item && gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE); preview->setEnabled(modifiable); delete[] buffer; preview->mAssetStatus = PREVIEW_ASSET_LOADED; } else { if( gViewerStats ) { gViewerStats->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); } if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { LLNotifyBox::showXml("NotecardMissing"); } else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) { LLNotifyBox::showXml("NotecardNoPermissions"); } else { LLNotifyBox::showXml("UnableToLoadNotecard"); } llwarns << "Problem loading notecard: " << status << llendl; preview->mAssetStatus = PREVIEW_ASSET_ERROR; } } delete item_id; }
// Default constructor LLPreviewNotecard::LLPreviewNotecard(const std::string& name, const LLRect& rect, const std::string& title, const LLUUID& item_id, const LLUUID& object_id, const LLUUID& asset_id, BOOL show_keep_discard, LLPointer<LLViewerInventoryItem> inv_item) : LLPreview(name, rect, title, item_id, object_id, TRUE, PREVIEW_MIN_WIDTH, PREVIEW_MIN_HEIGHT, inv_item), mAssetID( asset_id ), mNotecardItemID(item_id), mObjectID(object_id) { LLRect curRect = rect; if (show_keep_discard) { LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_notecard_keep_discard.xml"); childSetAction("Keep",onKeepBtn,this); childSetAction("Discard",onDiscardBtn,this); } else { LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_notecard.xml"); // <edit> childSetAction("Get Items", onClickGetItems, this); // </edit> if( mAssetID.isNull() ) { const LLInventoryItem* item = getItem(); if( item ) { mAssetID = item->getAssetUUID(); } } } if (hasChild("Save", true)) childSetAction("Save",onClickSave,this); // only assert shape if not hosted in a multifloater if (!getHost()) { reshape(curRect.getWidth(), curRect.getHeight(), TRUE); setRect(curRect); } if (LLUICtrl* ctrl = findChild<LLUICtrl>("lock")) ctrl->setVisible(false); if (hasChild("desc", true)) { childSetCommitCallback("desc", LLPreview::onText, this); if (const LLInventoryItem* item = getItem()) childSetText("desc", item->getDescription()); childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe); } setTitle(title); LLViewerTextEditor* editor = findChild<LLViewerTextEditor>("Notecard Editor"); if (editor) { editor->setWordWrap(TRUE); editor->setSourceID(item_id); editor->setHandleEditKeysDirectly(TRUE); } initMenu(); gAgentCamera.changeCameraToDefault(); }
void LLPreviewNotecard::loadAsset() { LLViewerTextEditor* editor = findChild<LLViewerTextEditor>("Notecard Editor"); if (!editor) return; // request the asset. if (const LLInventoryItem* item = getItem()) { if (gAgent.allowOperation(PERM_COPY, item->getPermissions(), GP_OBJECT_MANIPULATE) || gAgent.isGodlike()) { mAssetID = item->getAssetUUID(); if(mAssetID.isNull()) { editor->setText(LLStringUtil::null); editor->makePristine(); editor->setEnabled(TRUE); mAssetStatus = PREVIEW_ASSET_LOADED; } else { LLUUID* new_uuid = new LLUUID(mItemUUID); LLHost source_sim = LLHost::invalid; if (mObjectUUID.notNull()) { LLViewerObject *objectp = gObjectList.findObject(mObjectUUID); if (objectp && objectp->getRegion()) { source_sim = objectp->getRegion()->getHost(); } else { // The object that we're trying to look at disappeared, bail. llwarns << "Can't find object " << mObjectUUID << " associated with notecard." << llendl; mAssetID.setNull(); editor->setText(getString("no_object")); editor->makePristine(); editor->setEnabled(FALSE); mAssetStatus = PREVIEW_ASSET_LOADED; delete new_uuid; return; } } gAssetStorage->getInvItemAsset(source_sim, gAgent.getID(), gAgent.getSessionID(), item->getPermissions().getOwner(), mObjectUUID, item->getUUID(), item->getAssetUUID(), item->getType(), &onLoadComplete, (void*)new_uuid, TRUE); mAssetStatus = PREVIEW_ASSET_LOADING; } } else { mAssetID.setNull(); editor->setText(getString("not_allowed")); editor->makePristine(); editor->setEnabled(FALSE); mAssetStatus = PREVIEW_ASSET_LOADED; } if(!gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE)) { editor->setEnabled(FALSE); // <edit> You can always save in task inventory if(!mObjectUUID.isNull()) editor->setEnabled(TRUE); // </edit> if (LLUICtrl* ctrl = findChild<LLUICtrl>("lock")) ctrl->setVisible(true); } } else { editor->setText(LLStringUtil::null); editor->makePristine(); editor->setEnabled(TRUE); mAssetStatus = PREVIEW_ASSET_LOADED; } }
bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem) { if(!gAssetStorage) { llwarns << "Not connected to an asset storage system." << llendl; return false; } LLViewerTextEditor* editor = findChild<LLViewerTextEditor>("Notecard Editor"); if (editor && !editor->isPristine()) { // We need to update the asset information LLTransactionID tid; LLAssetID asset_id; tid.generate(); asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); LLVFile file(gVFS, asset_id, LLAssetType::AT_NOTECARD, LLVFile::APPEND); std::string buffer; if (!editor->exportBuffer(buffer)) { return false; } editor->makePristine(); S32 size = buffer.length() + 1; file.setMaxSize(size); file.write((U8*)buffer.c_str(), size); const LLInventoryItem* item = getItem(); // save it out to database if (item) { std::string agent_url = gAgent.getRegion()->getCapability("UpdateNotecardAgentInventory"); std::string task_url = gAgent.getRegion()->getCapability("UpdateNotecardTaskInventory"); if (mObjectUUID.isNull() && !agent_url.empty()) { // Saving into agent inventory mAssetStatus = PREVIEW_ASSET_LOADING; setEnabled(FALSE); LLSD body; body["item_id"] = mItemUUID; llinfos << "Saving notecard " << mItemUUID << " into agent inventory via " << agent_url << llendl; LLHTTPClient::post(agent_url, body, new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD)); } else if (!mObjectUUID.isNull() && !task_url.empty()) { // Saving into task inventory mAssetStatus = PREVIEW_ASSET_LOADING; setEnabled(FALSE); LLSD body; body["task_id"] = mObjectUUID; body["item_id"] = mItemUUID; llinfos << "Saving notecard " << mItemUUID << " into task " << mObjectUUID << " via " << task_url << llendl; LLHTTPClient::post(task_url, body, new LLUpdateTaskInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD)); } else if (gAssetStorage) { LLSaveNotecardInfo* info = new LLSaveNotecardInfo(this, mItemUUID, mObjectUUID, tid, copyitem); gAssetStorage->storeAssetData(tid, LLAssetType::AT_NOTECARD, &onSaveComplete, (void*)info, FALSE); } } } return true; }
// static void LLPreviewNotecard::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed) { LLSaveNotecardInfo* info = (LLSaveNotecardInfo*)user_data; if(info && (0 == status)) { if(info->mObjectUUID.isNull()) { LLViewerInventoryItem* item; item = (LLViewerInventoryItem*)gInventory.getItem(info->mItemUUID); if(item) { LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); new_item->setAssetUUID(asset_uuid); new_item->setTransactionID(info->mTransactionID); new_item->updateServer(FALSE); gInventory.updateItem(new_item); gInventory.notifyObservers(); } else { llwarns << "Inventory item for script " << info->mItemUUID << " is no longer in agent inventory." << llendl; } } else { LLViewerObject* object = gObjectList.findObject(info->mObjectUUID); LLViewerInventoryItem* item = NULL; if(object) { item = (LLViewerInventoryItem*)object->getInventoryObject(info->mItemUUID); } if(object && item) { item->setAssetUUID(asset_uuid); item->setTransactionID(info->mTransactionID); object->updateInventory(item, TASK_INVENTORY_ITEM_KEY, false); dialog_refresh_all(); } else { gViewerWindow->alertXml("SaveNotecardFailObjectNotFound"); } } // Perform item copy to inventory if (info->mCopyItem.notNull()) { LLViewerTextEditor* editor = LLViewerUICtrlFactory::getViewerTextEditorByName(info->mSelf, "Notecard Editor"); if (editor) { editor->copyInventory(info->mCopyItem); } } // Find our window and close it if requested. LLPreviewNotecard* previewp = (LLPreviewNotecard*)LLPreview::find(info->mItemUUID); if (previewp && previewp->mCloseAfterSave) { previewp->close(); } } else { llwarns << "Problem saving notecard: " << status << llendl; LLStringBase<char>::format_map_t args; args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); gViewerWindow->alertXml("SaveNotecardFailReason",args); } char uuid_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ asset_uuid.toString(uuid_string); char filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ snprintf(filename, LL_MAX_PATH, "%s.tmp", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str()); /* Flawfinder: ignore */ LLFile::remove(filename); delete info; }
void LLFloaterAO::onNotecardLoadComplete(LLVFS *vfs,const LLUUID& asset_uuid,LLAssetType::EType type,void* user_data, S32 status, LLExtStat ext_status) { if(status == LL_ERR_NOERR) { S32 size = vfs->getSize(asset_uuid, type); U8* buffer = new U8[size]; vfs->getData(asset_uuid, type, buffer, 0, size); if(type == LLAssetType::AT_NOTECARD) { LLViewerTextEditor* edit = new LLViewerTextEditor("",LLRect(0,0,0,0),S32_MAX,""); if(edit->importBuffer((char*)buffer, (S32)size)) { llinfos << "ao nc decode success" << llendl; std::string card = edit->getText(); edit->die(); LUA_CALL("OnAONotecardRead") << card << LUA_END; mAOAllAnims.clear(); mAOStands.clear(); //mAODefaultAnims.clear(); struct_stands standsloader; struct_all_anims all_anims_loader; typedef boost::tokenizer<boost::char_separator<char> > tokenizer; boost::char_separator<char> sep("\n"); tokenizer tokline(card, sep); for (tokenizer::iterator line = tokline.begin(); line != tokline.end(); ++line) { std::string strline(*line); boost::regex type("^(\\s*)(\\[ )(.*)( \\])"); boost::smatch what; if (boost::regex_search(strline, what, type)) { boost::char_separator<char> sep("|,"); std::string stranimnames(boost::regex_replace(strline, type, "")); tokenizer tokanimnames(stranimnames, sep); for (tokenizer::iterator anim = tokanimnames.begin(); anim != tokanimnames.end(); ++anim) { std::string strtoken(what[0]); std::string stranim(*anim); int state = GetStateFromToken(strtoken.c_str()); LLUUID animid(getAssetIDByName(stranim)); if (!(animid.notNull())) { cmdline_printchat(llformat("Warning: animation '%s' could not be found (Section: %s).",stranim.c_str(),strtoken.c_str())); } else { all_anims_loader.ao_id = animid; all_anims_loader.anim_name = stranim.c_str(); all_anims_loader.state = state; mAOAllAnims.push_back(all_anims_loader); if (state == STATE_AGENT_STAND) { standsloader.ao_id = animid; standsloader.anim_name = stranim.c_str(); mAOStands.push_back(standsloader); continue; } for (std::vector<struct_default_anims>::iterator iter = mAODefaultAnims.begin(); iter != mAODefaultAnims.end(); ++iter) { if (state == iter->state) iter->ao_id = animid; } } } } } llinfos << "ao nc read sucess" << llendl; loadComboBoxes(); run(); } else { llinfos << "ao nc decode error" << llendl; } } } else { llinfos << "ao nc read error" << llendl; } }
void LLPreviewNotecard::loadAsset() { // request the asset. const LLInventoryItem* item = getItem(); LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("Notecard Editor"); if (!editor) return; if(item) { if (gAgent.allowOperation(PERM_COPY, item->getPermissions(), GP_OBJECT_MANIPULATE) || gAgent.isGodlike()) { mAssetID = item->getAssetUUID(); if(mAssetID.isNull()) { editor->setText(LLStringUtil::null); editor->makePristine(); editor->setEnabled(TRUE); mAssetStatus = PREVIEW_ASSET_LOADED; } else { LLHost source_sim = LLHost::invalid; if (mObjectUUID.notNull()) { LLViewerObject *objectp = gObjectList.findObject(mObjectUUID); if (objectp && objectp->getRegion()) { source_sim = objectp->getRegion()->getHost(); } else { // The object that we're trying to look at disappeared, bail. llwarns << "Can't find object " << mObjectUUID << " associated with notecard." << llendl; mAssetID.setNull(); editor->setText(getString("no_object")); editor->makePristine(); editor->setEnabled(FALSE); mAssetStatus = PREVIEW_ASSET_LOADED; return; } } gAssetStorage->getInvItemAsset(source_sim, gAgent.getID(), gAgent.getSessionID(), item->getPermissions().getOwner(), mObjectUUID, item->getUUID(), item->getAssetUUID(), item->getType(), &onLoadComplete, (void*)new LLUUID(mItemUUID), TRUE); mAssetStatus = PREVIEW_ASSET_LOADING; } } else { mAssetID.setNull(); editor->setText(getString("not_allowed")); editor->makePristine(); editor->setEnabled(FALSE); mAssetStatus = PREVIEW_ASSET_LOADED; } if(!gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE)) { editor->setEnabled(FALSE); getChildView("lock")->setVisible( TRUE); } } else { editor->setText(LLStringUtil::null); editor->makePristine(); editor->setEnabled(TRUE); // Don't set asset status here; we may not have set the item id yet // (e.g. when this gets called initially) //mAssetStatus = PREVIEW_ASSET_LOADED; } }
// static void LLPreviewNotecard::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed) { LLSaveNotecardInfo* info = (LLSaveNotecardInfo*)user_data; if(info && (0 == status)) { if(info->mObjectUUID.isNull()) { LLViewerInventoryItem* item; item = (LLViewerInventoryItem*)gInventory.getItem(info->mItemUUID); if(item) { LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); new_item->setAssetUUID(asset_uuid); new_item->setTransactionID(info->mTransactionID); new_item->updateServer(FALSE); gInventory.updateItem(new_item); gInventory.notifyObservers(); } else { llwarns << "Inventory item for script " << info->mItemUUID << " is no longer in agent inventory." << llendl; } } else { LLViewerObject* object = gObjectList.findObject(info->mObjectUUID); LLViewerInventoryItem* item = NULL; if(object) { item = (LLViewerInventoryItem*)object->getInventoryObject(info->mItemUUID); } if(object && item) { item->setAssetUUID(asset_uuid); item->setTransactionID(info->mTransactionID); object->updateInventory(item, TASK_INVENTORY_ITEM_KEY, false); dialog_refresh_all(); } else { LLNotificationsUtil::add("SaveNotecardFailObjectNotFound"); } } // Perform item copy to inventory if (info->mCopyItem.notNull()) { LLViewerTextEditor* editor = info->mSelf->getChild<LLViewerTextEditor>("Notecard Editor"); if (editor) { editor->copyInventory(info->mCopyItem); } } // Find our window and close it if requested. LLPreviewNotecard* previewp = LLFloaterReg::findTypedInstance<LLPreviewNotecard>("preview_notecard", info->mItemUUID); if (previewp && previewp->mCloseAfterSave) { previewp->closeFloater(); } } else { llwarns << "Problem saving notecard: " << status << llendl; LLSD args; args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); LLNotificationsUtil::add("SaveNotecardFailReason", args); } std::string uuid_string; asset_uuid.toString(uuid_string); std::string filename; filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string) + ".tmp"; LLFile::remove(filename); delete info; }
// static void LLPreviewNotecard::onLoadComplete(LLVFS *vfs, const LLUUID& asset_uuid, LLAssetType::EType type, void* user_data, S32 status, LLExtStat ext_status) { llinfos << "LLPreviewNotecard::onLoadComplete()" << llendl; LLUUID* item_id = (LLUUID*)user_data; LLPreviewNotecard* preview = LLFloaterReg::findTypedInstance<LLPreviewNotecard>("preview_notecard", LLSD(*item_id)); if( preview ) { if(0 == status) { LLVFile file(vfs, asset_uuid, type, LLVFile::READ); S32 file_length = file.getSize(); std::vector<char> buffer(file_length+1); file.read((U8*)&buffer[0], file_length); // put a EOS at the end buffer[file_length] = 0; LLViewerTextEditor* previewEditor = preview->getChild<LLViewerTextEditor>("Notecard Editor"); if( (file_length > 19) && !strncmp( &buffer[0], "Linden text version", 19 ) ) { if( !previewEditor->importBuffer( &buffer[0], file_length+1 ) ) { llwarns << "Problem importing notecard" << llendl; } } else { // Version 0 (just text, doesn't include version number) previewEditor->setText(LLStringExplicit(&buffer[0])); } previewEditor->makePristine(); const LLInventoryItem* item = preview->getItem(); BOOL modifiable = item && gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE); preview->setEnabled(modifiable); preview->mAssetStatus = PREVIEW_ASSET_LOADED; } else { LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { LLNotificationsUtil::add("NotecardMissing"); } else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) { LLNotificationsUtil::add("NotecardNoPermissions"); } else { LLNotificationsUtil::add("UnableToLoadNotecard"); } llwarns << "Problem loading notecard: " << status << llendl; preview->mAssetStatus = PREVIEW_ASSET_ERROR; } } delete item_id; }