// static void LLPreviewNotecard::onClickDelete(void* user_data) { LLPreviewNotecard* preview = (LLPreviewNotecard*)user_data; if(preview) { preview->deleteNotecard(); } }
// static void LLPreviewNotecard::onClickSave(void* user_data) { //llinfos << "LLPreviewNotecard::onBtnSave()" << llendl; LLPreviewNotecard* preview = (LLPreviewNotecard*)user_data; if(preview) { preview->saveIfNeeded(); } }
// override void fire(const LLUUID& inv_item) { if(!mTextEditor) { // The parent text editor may have vanished by now. // In that case just quit. return; } LLInventoryItem* item = gInventory.getItem(inv_item); if(!item) { LL_WARNS() << "Item add reported, but not found in inventory!: " << inv_item << LL_ENDL; } else { // [RLVa:KB] - Checked: 2009-11-11 (RLVa-1.1.0a) | Modified: RLVa-1.1.0a if (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWNOTE)) { RlvUtil::notifyBlockedViewXXX(LLAssetType::AT_NOTECARD); return; } // [/RLVa:KB] // See if we can bring an existing preview to the front if(!LLPreview::show(item->getUUID(), true)) { if (gSavedSettings.getBOOL("ShowNewInventory")) // Singu Note: ShowNewInventory is true, not false, when they want a preview { // There isn't one, so make a new preview S32 left, top; gFloaterView->getNewFloaterPosition(&left, &top); LLRect rect = gSavedSettings.getRect("NotecardEditorRect"); rect.translate(left - rect.mLeft, top - rect.mTop); LLPreviewNotecard* preview; preview = new LLPreviewNotecard("preview notecard", rect, std::string("Embedded Note: ") + item->getName(), item->getUUID(), LLUUID::null, item->getAssetUUID(), true, (LLViewerInventoryItem*)item); preview->setSourceID(LLUUID::null); preview->setFocus(TRUE); // Force to be entirely onscreen. gFloaterView->adjustToFitScreen(preview, FALSE); } } } }
// static bool LLViewerTextEditor::onNotecardDialog(const LLSD& notification, const LLSD& response ) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if( option == 0 ) { LLPreviewNotecard* preview = LLFloaterReg::findTypedInstance<LLPreviewNotecard>("preview_notecard", notification["payload"]["notecard_id"]);; if (preview) { preview->saveItem(); } } return false; }
// override void fire(const LLUUID& inv_item) { if(!mTextEditor) { // The parent text editor may have vanished by now. // In that case just quit. return; } LLInventoryItem* item = gInventory.getItem(inv_item); if(!item) { llwarns << "Item add reported, but not found in inventory!: " << inv_item << llendl; } else { // See if we can bring an existing preview to the front if(!LLPreview::show(item->getUUID(), true)) { if(!gSavedSettings.getBOOL("ShowNewInventory")) { // There isn't one, so make a new preview S32 left, top; gFloaterView->getNewFloaterPosition(&left, &top); LLRect rect = gSavedSettings.getRect("NotecardEditorRect"); rect.translate(left - rect.mLeft, top - rect.mTop); LLPreviewNotecard* preview; preview = new LLPreviewNotecard("preview notecard", rect, std::string("Embedded Note: ") + item->getName(), item->getUUID(), LLUUID::null, item->getAssetUUID(), true, (LLViewerInventoryItem*)item); preview->setSourceID(LLUUID::null); preview->setFocus(TRUE); // Force to be entirely onscreen. gFloaterView->adjustToFitScreen(preview, FALSE); } } } }
void LLMultiPreview::tabOpen(LLFloater* opened_floater, bool from_click) { // Floater could be something else than LLPreview, eg LLFloaterProfile. LLPreview* opened_preview = dynamic_cast<LLPreview*>(opened_floater); if (opened_preview && opened_preview->getAssetStatus() == LLPreview::PREVIEW_ASSET_UNLOADED) { opened_preview->loadAsset(); } // <FS:Ansariel> Update preview dimensions for multi texture preview upon tab change LLPreviewTexture* texture_preview = dynamic_cast<LLPreviewTexture*>(opened_floater); if (texture_preview) { texture_preview->setUpdateDimensions(TRUE); } // </FS:Ansariel> // [SL:KB] - Patch: UI-FloaterSearchReplace | Checked: 2010-11-05 (Catznip-2.3.0a) | Added: Catznip-2.3.0a LLFloaterSearchReplace* pSearchFloater = LLFloaterReg::getTypedInstance<LLFloaterSearchReplace>("search_replace"); if ( (pSearchFloater) && (pSearchFloater->getDependee() == this) ) { LLPreviewNotecard* pPreviewNotecard = NULL; LLPreviewLSL* pPreviewScript = NULL; LLLiveLSLEditor* pPreviewScriptLive = NULL; if ((pPreviewNotecard = dynamic_cast<LLPreviewNotecard*>(opened_preview)) != NULL) { LLFloaterSearchReplace::show(pPreviewNotecard->getEditor()); } else if ((pPreviewScript = dynamic_cast<LLPreviewLSL*>(opened_preview)) != NULL) { LLFloaterSearchReplace::show(pPreviewScript->getEditor()); } else if ((pPreviewScriptLive = dynamic_cast<LLLiveLSLEditor*>(opened_preview)) != NULL) { LLFloaterSearchReplace::show(pPreviewScriptLive->getEditor()); } else { pSearchFloater->setVisible(FALSE); } } // [/SL:KB] }
// <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(); } } } } } }
// static void LLPreviewNotecard::handleSaveChangesDialog(S32 option, void* userdata) { LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; switch(option) { case 0: // "Yes" self->mCloseAfterSave = TRUE; LLPreviewNotecard::onClickSave((void*)self); break; case 1: // "No" self->mForceClose = TRUE; self->close(); break; case 2: // "Cancel" default: // If we were quitting, we didn't really mean it. LLAppViewer::instance()->abortQuit(); break; } }
//virtual void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content) { llinfos << "LLUpdateTaskInventoryResponder::result from capabilities" << llendl; LLUUID item_id = mPostData["item_id"]; LLUUID task_id = mPostData["task_id"]; dialog_refresh_all(); switch(mAssetType) { case LLAssetType::AT_NOTECARD: { // Update the UI with the new asset. LLPreviewNotecard* nc; nc = (LLPreviewNotecard*)LLPreview::find(item_id); if(nc) { // *HACK: we have to delete the asset in the VFS so // that the viewer will redownload it. This is only // really necessary if the asset had to be modified by // the uploader, so this can be optimized away in some // cases. A better design is to have a new uuid if the // script actually changed the asset. if(nc->hasEmbeddedInventory()) { gVFS->removeFile( content["new_asset"].asUUID(), LLAssetType::AT_NOTECARD); } nc->setAssetId(content["new_asset"].asUUID()); nc->refreshFromInventory(); } } break; case LLAssetType::AT_LSL_TEXT: { if(mQueueId.notNull()) { LLFloaterCompileQueue* queue = (LLFloaterCompileQueue*) LLFloaterScriptQueue::findInstance(mQueueId); if(NULL != queue) { queue->removeItemByItemID(item_id); } } else { LLLiveLSLEditor* preview = LLLiveLSLEditor::find(item_id, task_id); if (preview) { // Bytecode save completed if (content["compiled"]) { preview->callbackLSLCompileSucceeded( task_id, item_id, mPostData["is_script_running"]); } else { preview->callbackLSLCompileFailed(content["errors"]); } } } } break; default: break; } }
//virtual void LLUpdateAgentInventoryResponder::uploadComplete(const LLSD& content) { llinfos << "LLUpdateAgentInventoryResponder::result from capabilities" << llendl; LLUUID item_id = mPostData["item_id"]; LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(item_id); if(!item) { llwarns << "Inventory item for " << mVFileID << " is no longer in agent inventory." << llendl; return; } // Update viewer inventory item LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); new_item->setAssetUUID(content["new_asset"].asUUID()); gInventory.updateItem(new_item); gInventory.notifyObservers(); llinfos << "Inventory item " << item->getName() << " saved into " << content["new_asset"].asString() << llendl; LLInventoryType::EType inventory_type = new_item->getInventoryType(); switch(inventory_type) { case LLInventoryType::IT_NOTECARD: { // Update the UI with the new asset. LLPreviewNotecard* nc; nc = (LLPreviewNotecard*)LLPreview::find(new_item->getUUID()); if(nc) { // *HACK: we have to delete the asset in the VFS so // that the viewer will redownload it. This is only // really necessary if the asset had to be modified by // the uploader, so this can be optimized away in some // cases. A better design is to have a new uuid if the // script actually changed the asset. if(nc->hasEmbeddedInventory()) { gVFS->removeFile( content["new_asset"].asUUID(), LLAssetType::AT_NOTECARD); } nc->refreshFromInventory(); } } break; case LLInventoryType::IT_LSL: { // Find our window and close it if requested. LLPreviewLSL* preview = (LLPreviewLSL*)LLPreview::find(item_id); if (preview) { // Bytecode save completed if (content["compiled"]) { preview->callbackLSLCompileSucceeded(); } else { preview->callbackLSLCompileFailed(content["errors"]); } } } break; case LLInventoryType::IT_GESTURE: { // If this gesture is active, then we need to update the in-memory // active map with the new pointer. if (gGestureManager.isGestureActive(item_id)) { LLUUID asset_id = new_item->getAssetUUID(); gGestureManager.replaceGesture(item_id, asset_id); gInventory.notifyObservers(); } //gesture will have a new asset_id LLPreviewGesture* previewp = (LLPreviewGesture*)LLPreview::find(item_id); if(previewp) { previewp->onUpdateSucceeded(); } } break; case LLInventoryType::IT_WEARABLE: default: break; } }
// static void LLPreviewNotecard::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed) { LLSaveNotecardInfo* info = static_cast<LLSaveNotecardInfo*>(user_data); if (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()) { if (LLViewerTextEditor* editor = info->mSelf->findChild<LLViewerTextEditor>("Notecard 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; 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 = 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; if (LLViewerTextEditor* previewEditor = preview->findChild<LLViewerTextEditor>("Notecard Editor")) { if ((file_length > 19) && !strncmp(buffer, "Linden text version", 19)) { if (!previewEditor->importBuffer(buffer, file_length+1)) { 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 { 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; }
// 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; }