Ejemplo n.º 1
0
	/*
	 * Loads existing indexes from disk
	 */
	void IndexManager::loadIndexes(SimpleXML& xml)
	{
		xml.resetCurrentChild();
		if(xml.findChild("Files"))
		{
			xml.stepIn();
			while(xml.findChild("File"))
			{
				const TTHValue tth = TTHValue(xml.getChildAttrib("TTH"));
				SourceList sources;

				xml.stepIn();
				while(xml.findChild("Source"))
				{
					Source source;
					source.setCID(CID(xml.getChildAttrib("CID")));
					source.setIp(xml.getChildAttrib("I4"));
					source.setUdpPort(static_cast<uint16_t>(xml.getIntChildAttrib("U4")));
					source.setSize(xml.getLongLongChildAttrib("SI"));
					source.setExpires(xml.getLongLongChildAttrib("EX"));
					source.setPartial(false);

					sources.push_back(source);
				}

				tthList.insert(std::make_pair(tth, sources));
				xml.stepOut();
			}
			xml.stepOut();
		}
	}
void HighlightManager::load(SimpleXML& aXml) {
    aXml.resetCurrentChild();

    if(aXml.findChild("Highlights")) {
        aXml.stepIn();
        while(aXml.findChild("Highlight")) {
            ColorSettings cs;
            cs.setMatch( Text::utf8ToWide( aXml.getChildAttrib("Match") ) );
            cs.setBold(	aXml.getBoolChildAttrib("Bold") );
            cs.setItalic( aXml.getBoolChildAttrib("Italic") );
            cs.setUnderline( aXml.getBoolChildAttrib("Underline") );
            cs.setStrikeout( aXml.getBoolChildAttrib("Strikeout") );
            cs.setIncludeNickList( aXml.getBoolChildAttrib("IncludeNickList") );
            cs.setCaseSensitive( aXml.getBoolChildAttrib("CaseSensitive") );
            cs.setWholeLine( aXml.getBoolChildAttrib("WholeLine") );
            cs.setWholeWord( aXml.getBoolChildAttrib("WholeWord") );
            cs.setPopup( aXml.getBoolChildAttrib("Popup") );
            cs.setTab( aXml.getBoolChildAttrib("Tab") );
            cs.setPlaySound( aXml.getBoolChildAttrib("PlaySound") );
            cs.setLog( aXml.getBoolChildAttrib("LastLog") );
            cs.setFlashWindow( aXml.getBoolChildAttrib("FlashWindow") );
            cs.setMatchType( aXml.getIntChildAttrib("MatchType") );
            cs.setHasFgColor( aXml.getBoolChildAttrib("HasFgColor") );
            cs.setHasBgColor( aXml.getBoolChildAttrib("HasBgColor") );
            cs.setBgColor( (int)aXml.getLongLongChildAttrib("BgColor") );
            cs.setFgColor( (int)aXml.getLongLongChildAttrib("FgColor") );
            cs.setSoundFile( Text::utf8ToWide( aXml.getChildAttrib("SoundFile") ) );

            colorSettings.push_back(cs);
        }
        aXml.stepOut();
    } else {
        aXml.resetCurrentChild();
    }
}
void HighlightManager::load(SimpleXML& aXml){
	aXml.resetCurrentChild();

	if(aXml.findChild("Highlights")) {
		aXml.stepIn();
		while(aXml.findChild("Highlight")) {
			try{
				ColorSettings cs;
				cs.setContext(aXml.getIntChildAttrib("Context"));
				cs.setMatch( Text::utf8ToWide( aXml.getChildAttrib("Match") ) );
				cs.setBold(	aXml.getBoolChildAttrib("Bold") );
				cs.setItalic( aXml.getBoolChildAttrib("Italic") );
				cs.setUnderline( aXml.getBoolChildAttrib("Underline") );
				cs.setStrikeout( aXml.getBoolChildAttrib("Strikeout") );
				//Convert old setting to correct context
				if(aXml.getBoolChildAttrib("IncludeNickList") == true)
					cs.setContext(CONTEXT_NICKLIST);
				cs.setCaseSensitive( aXml.getBoolChildAttrib("CaseSensitive") );
				cs.setWholeLine( aXml.getBoolChildAttrib("WholeLine") );
				cs.setWholeWord( aXml.getBoolChildAttrib("WholeWord") );
				cs.setPopup( aXml.getBoolChildAttrib("Popup") );
				cs.setTab( aXml.getBoolChildAttrib("Tab") );
				cs.setPlaySound( aXml.getBoolChildAttrib("PlaySound") );
				//cs.setLog( aXml.getBoolChildAttrib("LastLog") );
				cs.setFlashWindow( aXml.getBoolChildAttrib("FlashWindow") );
				cs.setMatchType( aXml.getIntChildAttrib("MatchType") );
				cs.setHasFgColor( aXml.getBoolChildAttrib("HasFgColor") );
				cs.setHasBgColor( aXml.getBoolChildAttrib("HasBgColor") );
				cs.setBgColor( (int)aXml.getLongLongChildAttrib("BgColor") );
				cs.setFgColor( (int)aXml.getLongLongChildAttrib("FgColor") );
				cs.setSoundFile( Text::utf8ToWide( aXml.getChildAttrib("SoundFile") ) );
				cs.setMatchColumn(aXml.getIntChildAttrib("MatchColumn"));

				cs.setRegexp();
				colorSettings.push_back(cs);
			}catch(...) { }
		}
		aXml.stepOut();
	} else {
		aXml.resetCurrentChild();
	}
	//convert the old setting to highlights
	if(!SETTING(HIGHLIGHT_LIST).empty()) {
		ColorSettings cs;
		cs.setContext(CONTEXT_FILELIST);
		cs.setMatch(Text::toT(SETTING(HIGHLIGHT_LIST)));
		cs.setHasFgColor(true);
		cs.setFgColor( SETTING(LIST_HL_COLOR) );
		cs.setHasBgColor(true);
		cs.setBgColor( SETTING(LIST_HL_BG_COLOR) );
		SettingsManager::getInstance()->set(SettingsManager::HIGHLIGHT_LIST, "");
		SettingsManager::getInstance()->set(SettingsManager::USE_HIGHLIGHT, true);
		colorSettings.push_back(cs);
	}

}