コード例 #1
0
void lggHunSpell_Wrapper::setNewDictionary(std::string newDict)
{

	llinfos << "Setting new base dictionary long name is-> " << newDict.c_str() << llendl;

	currentBaseDic = newDict;
	
	//expecting a full name comming in
	newDict = fullName2DictName(newDict);

	if (myHunspell)
	{
		delete myHunspell;
	}

	std::string dicaffpath = getCorrectPath(newDict+".aff");
	std::string dicdicpath = getCorrectPath(newDict+".dic");
	
	llinfos << "Setting new base dictionary -> " << dicaffpath.c_str() << llendl;

	myHunspell = new Hunspell(dicaffpath.c_str(), dicdicpath.c_str());
	llinfos << "Adding custom dictionary " << llendl;
	createCustomDic();
	addDictionary("custom");
	std::vector<std::string> toInstall = getInstalledDicts();
	for (int i = 0; i < (int)toInstall.size(); i++)
	{
		addDictionary(toInstall[i]);
	}
}
コード例 #2
0
void lggHunSpell_Wrapper::addButton(std::string selection)
{
	if(selection=="")return;
	addDictionary(selection);
	std::vector<std::string> alreadyInstalled = CSV2VEC(gSavedSettings.getString("EmeraldSpellInstalled"));
	alreadyInstalled.push_back(fullName2DictName(selection));	
	gSavedSettings.setString("EmeraldSpellInstalled",VEC2CSV(alreadyInstalled));
}
コード例 #3
0
void lggHunSpell_Wrapper::addDictionary(std::string additionalDictionary)
{
	if(!myHunspell)return;
	if(additionalDictionary=="")return;
	//expecting a full name here
	std::string dicpath=getCorrectPath(fullName2DictName(additionalDictionary)+".dic");
	if(gDirUtilp->fileExists(dicpath))
	{
		llinfos << "Adding additional dictionary -> " << dicpath.c_str() << llendl;
		myHunspell->add_dic(dicpath.c_str());
	}
}
コード例 #4
0
void lggHunSpell_Wrapper::removeButton(std::string selection)
{
	if(selection=="")return;
	std::vector<std::string> newInstalledDics;
	std::vector<std::string> currentlyInstalled = getInstalledDicts();
	for(int i =0;i<(int)currentlyInstalled.size();i++)
	{
		if(0!=LLStringUtil::compareInsensitive(selection,currentlyInstalled[i]))
			newInstalledDics.push_back(fullName2DictName(currentlyInstalled[i]));
	}
	gSavedSettings.setString("EmeraldSpellInstalled",VEC2CSV(newInstalledDics));
	processSettings();
}
コード例 #5
0
void lggHunSpell_Wrapper::addDictionary(std::string additionalDictionary)
{
	if(!myHunspell)return;
	if(additionalDictionary=="")return;
	//expecting a full name here
	std::string dicpath(
		gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries",
		std::string(fullName2DictName(additionalDictionary)+".dic")
		).c_str());
	if(gDirUtilp->fileExists(dicpath))
	{
		llinfos << "Adding additional dictionary -> " << dicpath.c_str() << llendl;
		myHunspell->add_dic(dicpath.c_str());
	}
}
コード例 #6
0
void lggHunSpell_Wrapper::getMoreButton(void* data)
{
	std::vector<std::string> shortNames;
	std::vector<std::string> longNames;
	LLSD response = LLHTTPClient::blockingGet(gSavedSettings.getString("SpellDownloadURL")+"dic_list.xml");
	if (response.has("body"))
	{
		const LLSD &dict_list = response["body"];
		if (dict_list.has("isComplete"))
		{
			LLSD dics = dict_list["data"];
			for (int i = 0; i < dics.size(); i++)
			{
				std::string dicFullName = dictName2FullName(dics[i].asString());
				longNames.push_back(dicFullName);
				shortNames.push_back(fullName2DictName(dicFullName));
			}
			LggDicDownload::show(true,shortNames,longNames, data);	
		}
	}
}
コード例 #7
0
void lggHunSpell_Wrapper::getMoreButton(void * data)
{
	//LLWeb::loadURL("http://www.cypherpunks.ca/otr/");
	std::vector<std::string> shortNames;
	std::vector<std::string> longNames;
	LLSD response = LLHTTPClient::blockingGet("http://www.modularsystems.sl/app/dics/dic_list.xml");
	if(response.has("body"))
	{
		const LLSD &dict_list = response["body"];
		if(dict_list.has("isComplete"))
		{
			LLSD dics = dict_list["data"];
			for(int i = 0; i < dics.size(); i++)
			{
				std::string dicFullName = dictName2FullName(dics[i].asString());
				longNames.push_back(dicFullName);
				shortNames.push_back(fullName2DictName(dicFullName));
			}
			LggDicDownload::show(true,shortNames,longNames, data);	
		}
	}
}
コード例 #8
0
void lggHunSpell_Wrapper::setNewDictionary(std::string newDict)
{

	llinfos << "Setting new base dictionary long name is-> " << newDict.c_str() << llendl;

	currentBaseDic=newDict;
	
	//expecting a full name comming in
	newDict = fullName2DictName(newDict);

	if(myHunspell)delete myHunspell;

	std::string dicaffpath(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries", std::string(newDict+".aff")).c_str());
	std::string dicdicpath(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries", std::string(newDict+".dic")).c_str());
	
	//check to make sure this dictionary exists, if not, make it use one we know does
	if(!gDirUtilp->fileExists(dicaffpath))
	{
		gSavedSettings.setString("EmeraldSpellBase","English (United States of America)");
		LLSD args;
		args["MESSAGE"] = "Your current dictionary could not be found, please re-download it.  Setting dictionary to English...";
		LLNotifications::instance().add("GenericAlert", args);
		setNewDictionary("English (United States of America)");
		return;
	}
	llinfos << "Setting new base dictionary -> " << dicaffpath.c_str() << llendl;

	myHunspell = new Hunspell(dicaffpath.c_str(),dicdicpath.c_str());
	llinfos << "Adding custom dictionary " << llendl;

	addDictionary("emerald_custom");
	std::vector<std::string> toInstall = getInstalledDicts();
	for(int i =0;i<(int)toInstall.size();i++)
		addDictionary(toInstall[i]);


}