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;
	}
}
示例#2
0
// 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;
}
示例#3
0
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;
	}
}
示例#4
0
// 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;
}