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);
	}

}
void FireSettingsManager::load(string const& aFileName)
{
	try {
		SimpleXML xml;
		
		xml.fromXML(File(aFileName, File::READ, File::OPEN).read());
		
		xml.resetCurrentChild();
		
		xml.stepIn();
		
		if(xml.findChild("FireSettings"))
		{
			xml.stepIn();

			int i;
			
			for(i=STR_FIRST; i<STR_LAST; i++)
			{
				const string& attr = settingTags[i];
				dcassert(attr.find("SENTRY") == string::npos);
				
				if(xml.findChild(attr))
					set(StrSetting(i), xml.getChildData());
				xml.resetCurrentChild();
			}
			for(i=INT_FIRST; i<INT_LAST; i++)
			{
				const string& attr = settingTags[i];
				dcassert(attr.find("SENTRY") == string::npos);
				
				if(xml.findChild(attr))
					set(IntSetting(i), Util::toInt(xml.getChildData()));
				xml.resetCurrentChild();
			}
			for(i=INT64_FIRST; i<INT64_LAST; i++)
			{
				const string& attr = settingTags[i];
				dcassert(attr.find("SENTRY") == string::npos);
				
				if(xml.findChild(attr))
					set(Int64Setting(i), Util::toInt64(xml.getChildData()));
				xml.resetCurrentChild();
			}
			
			xml.stepOut();
		}
	
		fire(FireSettingsManagerListener::Load(), xml);
//		fire(FireSettingsManagerListener::Load(), &xml);
		xml.stepOut();

	} catch(const Exception&) {
	}
}
Esempio n. 4
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 RawManager::loadActionRaws(SimpleXML& aXml) {
	aXml.resetCurrentChild();
	while(aXml.findChild("Action")) {
		Action* a = NULL;
		try {
			a = addAction(aXml.getIntChildAttrib("ID"), aXml.getChildAttrib("Name"), aXml.getBoolChildAttrib("Enabled"));
		} catch(const Exception&) {
			continue;
		}

		aXml.stepIn();
		while(aXml.findChild("Raw")) {
			try {
				Raw r;
				r.setEnabled(aXml.getBoolChildAttrib("Enabled"));
				r.setId(aXml.getIntChildAttrib("ID"));
				r.setName(aXml.getChildAttrib("Name"));
				r.setRaw(aXml.getChildAttrib("Raw"));
				r.setTime(aXml.getIntChildAttrib("Time"));
				r.setLua(aXml.getBoolChildAttrib("UseLua"));
				addRaw(a, r);
			} catch(const Exception&) {
				// ...
			}
		}
		aXml.stepOut();
	}
}
Esempio n. 6
0
	void WebUserManager::on(WebServerManagerListener::LoadSettings, SimpleXML& xml_) noexcept {
		if (xml_.findChild("WebUsers")) {
			xml_.stepIn();
			while (xml_.findChild("WebUser")) {
				const auto& username = xml_.getChildAttrib("Username");
				const auto& password = xml_.getChildAttrib("Password");

				if (username.empty() || password.empty()) {
					continue;
				}

				const auto& permissions = xml_.getChildAttrib("Permissions");

				// Set as admin mainly for compatibility with old accounts if no permissions were found
				auto user = std::make_shared<WebUser>(username, password, permissions.empty());

				user->setLastLogin(xml_.getIntChildAttrib("LastLogin"));
				if (!permissions.empty()) {
					user->setPermissions(permissions);
				}

				users.emplace(username, user);

			}
			xml_.stepOut();
		}

		xml_.resetCurrentChild();
	}
Esempio n. 7
0
	/*
	 * Loads existing nodes from disk
	 */
	void KBucket::loadNodes(SimpleXML& xml)
	{
		xml.resetCurrentChild();
		if(xml.findChild("Nodes"))
		{
			xml.stepIn();
			while(xml.findChild("Node"))
			{
				CID cid			= CID(xml.getChildAttrib("CID"));
				string i4		= xml.getChildAttrib("I4");
				uint16_t u4		= static_cast<uint16_t>(xml.getIntChildAttrib("U4"));

				if(Utils::isGoodIPPort(i4, u4))
				{
					UDPKey udpKey;
					string key		= xml.getChildAttrib("key");
					string keyIp	= xml.getChildAttrib("keyIP");

					if(!key.empty() && !keyIp.empty())
					{
						udpKey.key = CID(key);
						udpKey.ip = keyIp;
					}

					//addUser(cid, i4, u4);
					BootstrapManager::getInstance()->addBootstrapNode(i4, u4, cid, udpKey);
				}
			}
			xml.stepOut();
		}
	}
Esempio n. 8
0
void MessageManager::loadUsers() {
    try {
        SimpleXML xml;
        SettingsManager::loadSettingFile(xml, CONFIG_DIR, CONFIG_NAME);
        auto cm = ClientManager::getInstance();
        if (xml.findChild("Ignored")) {
            xml.stepIn();
            xml.resetCurrentChild();
            if (xml.findChild("Users")) {
                xml.stepIn();
                while (xml.findChild("User")) {
                    UserPtr user = cm->getUser(CID(xml.getChildAttrib("CID")));
                    {
                        WLock(cm->getCS());
                        cm->addOfflineUser(user, xml.getChildAttrib("Nick"), xml.getChildAttrib("Hub"), (uint32_t)xml.getIntChildAttrib("LastSeen"));
                    }
                    WLock l(Ignorecs);
                    ignoredUsers.emplace(user);
                    user->setFlag(User::IGNORED);
                }
                xml.stepOut();
            }
            xml.stepOut();
        }
    }
    catch (const Exception& e) {
        LogManager::getInstance()->message(STRING_F(LOAD_FAILED_X, CONFIG_NAME % e.getError()), LogManager::LOG_ERROR);
    }
}
Esempio n. 9
0
void RSSManager::load(SimpleXML& aXml)
{
	{
		CFlyLock(g_csFeed);
		aXml.resetCurrentChild();
		if (aXml.findChild("Rss"))
		{
			aXml.stepIn();
			while (aXml.findChild("Feed"))
			{
				const string& realURL = aXml.getChildData();
				if (realURL.empty())
				{
					continue;
				}
				const string& sourceName = aXml.getChildAttrib("Name");
				const string& codeingType = aXml.getChildAttrib("Codeing");
				
				const size_t iCodeingType = Util::toInt(codeingType);
				
				// add only unique RSS feeds
				addNewFeed(realURL, sourceName, getCodeing(iCodeingType));
			}
			aXml.stepOut();
		}
	}
	updateFeeds();
}
Esempio n. 10
0
void ShareManager::load(SimpleXML& aXml) {
	Lock l(cs);

	aXml.resetCurrentChild();
	if(aXml.findChild("Share")) {
		aXml.stepIn();
		while(aXml.findChild("Directory")) {
			string realPath = aXml.getChildData();
			if(realPath.empty()) {
				continue;
			}
			// make sure realPath ends with a PATH_SEPARATOR
			if(realPath[realPath.size() - 1] != PATH_SEPARATOR) {
				realPath += PATH_SEPARATOR;
			}

			const string& virtualName = aXml.getChildAttrib("Virtual");
			string vName = validateVirtual(virtualName.empty() ? Util::getLastDir(realPath) : virtualName);
			shares[move(realPath)] = vName;
			if(directories.find(vName) == directories.end()) {
				directories[vName] = Directory::create(vName);
			}
		}
		aXml.stepOut();
	}
}
Esempio n. 11
0
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::toT( 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(aXml.getIntChildAttrib("BgColor"));
				cs.setFgColor(aXml.getIntChildAttrib("FgColor"));
				cs.setSoundFile(aXml.getChildAttrib("SoundFile"));
				cs.setMatchColumn(aXml.getIntChildAttrib("MatchColumn"));

				cs.setRegexp();
				colorSettings.push_back(cs);
			}catch(...) { }
		}
		aXml.stepOut();
	} else {
		aXml.resetCurrentChild();
	}
}
void IpManager::loadWatch(SimpleXML& aXml){
	aXml.resetCurrentChild();
	if(aXml.findChild("IPWatch")) {
		aXml.stepIn();
		while(aXml.findChild("IPWatch")) {					
			addWatch(aXml.getIntChildAttrib("Mode"), aXml.getChildAttrib("Pattern"), aXml.getIntChildAttrib("Task"), aXml.getIntChildAttrib("Action"),
				aXml.getBoolChildAttrib("DisplayCheat"), aXml.getChildAttrib("Cheat"), aXml.getIntChildAttrib("MatchType"), aXml.getChildAttrib("ISP"));			
		}
		aXml.stepOut();
		aXml.resetCurrentChild();
		if(aXml.findChild("RevisionInfo")) {
			aXml.stepIn();
			if(aXml.findChild("Version")) {
				setIpWatchVersion(aXml.getChildData());
				aXml.resetCurrentChild();
			}
			aXml.stepOut();
		}
	}
}
Esempio n. 13
0
void MessageManager::load(SimpleXML& aXml) {
	aXml.resetCurrentChild();
	if (aXml.findChild("ChatFilterItems")) {
		aXml.stepIn();
		while (aXml.findChild("ChatFilterItem")) {
			WLock l(Ignorecs);
			ChatFilterItems.push_back(ChatFilterItem(aXml.getChildAttrib("Nick"), aXml.getChildAttrib("Text"),
				(StringMatch::Method)aXml.getIntChildAttrib("NickMethod"), (StringMatch::Method)aXml.getIntChildAttrib("TextMethod"),
				aXml.getBoolChildAttrib("MC"), aXml.getBoolChildAttrib("PM"), aXml.getBoolChildAttrib("Enabled")));
		}
		aXml.stepOut();
	}
	loadUsers();
}
Esempio n. 14
0
void DetectNetworkSetupThread::on(Complete, HttpConnection*, const string&) throw() {
	debug_log(AUTODETECT, "parsing response {%s}", m_buffer.c_str());
	try {
		SimpleXML xml;
		xml.fromXML(m_buffer);
		if (xml.findChild("response")) {
			debug_log(AUTODETECT, "found <response>");
			xml.stepIn();
			if (xml.findChild("mode")) {
				string mode = xml.getChildData();
				info_log(AUTODETECT, "mode={%s}", mode.c_str());
				xml.resetCurrentChild();
				string address;
				if (xml.findChild("address")) {
					string address = xml.getChildData();
					info_log(AUTODETECT, "address={%s}", address.c_str());
					if (!address.empty()) {
						SettingsManager::getInstance()->set(SettingsManager::EXTERNAL_IP, address);
					}
				}
				else {
					warn_log(AUTODETECT, "<address> not found");
				}
				debug_log(AUTODETECT, "local address={%s}", connection.m_localIp.c_str());
				if (Util::stricmp(mode, "active") == 0) {
					SettingsManager::getInstance()->set(SettingsManager::INCOMING_CONNECTIONS, SettingsManager::INCOMING_FIREWALL_NAT);
					debug_log(AUTODETECT, "setting ACTIVE mode");
				}
				else if (Util::stricmp(mode, "passive") == 0) {
					SettingsManager::getInstance()->set(SettingsManager::INCOMING_CONNECTIONS, SettingsManager::INCOMING_FIREWALL_PASSIVE);
				}
				else {
					throw Exception("Wrong mode '" + mode + "'");
				}
			}
			else {
				warn_log(AUTODETECT, "<mode> not found");
			}
		}
		else {
			warn_log(AUTODETECT, "<response> not found");
		}
	} 
	catch (const Exception &e) {
		error_log(AUTODETECT, "Error parsing response: %s", e.getError().c_str());
	}
	finalize();
}
void ResourceManager::loadLanguage(const string& aFile) {
	try {
		File f(aFile, File::READ, File::OPEN, File::BUFFER_SEQUENTIAL, false);
		SimpleXML xml;
		xml.fromXML(f.read());

		unordered_map<string, int> h;
		
		for(int i = 0; i < LAST; ++i) {
			h[names[i]] = i;
		}

		string childName = "String";
		string attribName = "Name";
		if (xml.findChild("Language")) {
			rtl = xml.getBoolChildAttrib("RightToLeft");

			xml.stepIn();
			if (xml.findChild("Strings")) {
				xml.stepIn();
			}
		} else {
			xml.resetCurrentChild();
			if (xml.findChild("resources")) {
				xml.stepIn();
				childName = "string";
				attribName = "name";
			} else {
				throw Exception("Invalid format");
			}
		}

		while (xml.findChild(childName)) {
			const auto j = h.find(xml.getChildAttrib(attribName));
			if(j != h.end()) {
				strings[j->second] = xml.getChildData();
			}
		}
		createWide();
	} catch(const Exception& e) {
		LogManager::getInstance()->message("Failed to load the language file " + aFile + ": " + e.getError(), LogManager::LOG_ERROR);
	}
}
Esempio n. 16
0
bool IpGuard::load()
{
	if (noSave)
	{
		Lock l(cs);
		noSave = false;
		
		try
		{
			SimpleXML xml;
			xml.fromXML(File(Util::getPath(Util::PATH_USER_CONFIG) + "IPGuard.xml", File::READ, File::OPEN).read());
			if (xml.findChild("IpRanges"))
			{
				xml.stepIn();
				while (xml.findChild("Range"))
				{
					uint32_t start = Util::toUInt32(xml.getChildAttrib("Start"));
					uint32_t end = Util::toUInt32(xml.getChildAttrib("End"));
					ranges.push_front(range(++lastRange, xml.getChildAttrib("Comment"), ip(std::min(start, end)), ip(std::max(start, end))));
				}
				xml.resetCurrentChild();
				xml.stepOut();
			}
		}
		catch (const Exception& e)
		{
			dcdebug("IpGuard::load: %s\n", e.getError().c_str());
		}
		
		// Optimize ranges
		ranges.sort();
		ranges.unique(merger);
		
		return true;
	}
	
	return false;
}
Esempio n. 17
0
void WebShortcuts::load(SimpleXML& xml) {
	xml.resetCurrentChild();

	if(xml.findChild("WebShortcuts")){
		xml.stepIn();

		clear();

		while(xml.findChild("WebShortcut")){
			auto tmp = new WebShortcut();

			tmp->name  = xml.getChildAttrib("Name");
			tmp->key   = xml.getChildAttrib("Key");
			tmp->url   = xml.getChildAttrib("URL");

			tmp->clean = xml.getBoolChildAttrib("Clean");

			list.push_back(tmp);
		}
		
		xml.stepOut();
	}
}
Esempio n. 18
0
bool
RSSFeed::UpdateFeedOldParser(const string& data)
{
	clearNewsList();
	SimpleXML xml;
	try
	{
		xml.fromXML(data);
		xml.resetCurrentChild();
		const RssFormat rssFormat = DetectRSSFormat(&xml, XML_SIMPLE);
		switch (rssFormat)
		{
			case RSS_2_0:
				return ProcessRSS(&xml, XML_SIMPLE, true);
			case RSS_ATOM:
				return ProcessAtom(&xml, XML_SIMPLE, true);
		}
		
	}
	catch (SimpleXMLException& /*ex*/)
	{
	}
	return false;
}
Esempio n. 19
0
LRESULT PropPageTextStyles::onImport(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	tstring x = _T("");	
	if(WinUtil::browseFile(x, m_hWnd, false, x, types, defExt) == IDOK) {
		SimpleXML xml;
		xml.fromXML(File(Text::fromT(x), File::READ, File::OPEN).read());
		xml.resetCurrentChild();
		xml.stepIn();
		if(xml.findChild(("Settings"))) {
			xml.stepIn();

			importData("Font", TEXT_FONT);
			importData("BackgroundColor", BACKGROUND_COLOR);
			importData("TextColor", TEXT_COLOR);
			importData("DownloadBarColor", DOWNLOAD_BAR_COLOR);
			importData("UploadBarColor", UPLOAD_BAR_COLOR);
			importData("TextGeneralBackColor", TEXT_GENERAL_BACK_COLOR);
			importData("TextGeneralForeColor", TEXT_GENERAL_FORE_COLOR);
			importData("TextGeneralBold", TEXT_GENERAL_BOLD);
			importData("TextGeneralItalic", TEXT_GENERAL_ITALIC);
			importData("TextMyOwnBackColor", TEXT_MYOWN_BACK_COLOR);
			importData("TextMyOwnForeColor", TEXT_MYOWN_FORE_COLOR);
			importData("TextMyOwnBold", TEXT_MYOWN_BOLD);
			importData("TextMyOwnItalic", TEXT_MYOWN_ITALIC);
			importData("TextPrivateBackColor", TEXT_PRIVATE_BACK_COLOR);
			importData("TextPrivateForeColor", TEXT_PRIVATE_FORE_COLOR);
			importData("TextPrivateBold", TEXT_PRIVATE_BOLD);
			importData("TextPrivateItalic", TEXT_PRIVATE_ITALIC);
			importData("TextSystemBackColor", TEXT_SYSTEM_BACK_COLOR);
			importData("TextSystemForeColor", TEXT_SYSTEM_FORE_COLOR);
			importData("TextSystemBold", TEXT_SYSTEM_BOLD);
			importData("TextSystemItalic", TEXT_SYSTEM_ITALIC);
			importData("TextServerBackColor", TEXT_SERVER_BACK_COLOR);
			importData("TextServerForeColor", TEXT_SERVER_FORE_COLOR);
			importData("TextServerBold", TEXT_SERVER_BOLD);
			importData("TextServerItalic", TEXT_SERVER_ITALIC);
			importData("TextTimestampBackColor", TEXT_TIMESTAMP_BACK_COLOR);
			importData("TextTimestampForeColor", TEXT_TIMESTAMP_FORE_COLOR);
			importData("TextTimestampBold", TEXT_TIMESTAMP_BOLD);
			importData("TextTimestampItalic", TEXT_TIMESTAMP_ITALIC);
			importData("TextMyNickBackColor", TEXT_MYNICK_BACK_COLOR);
			importData("TextMyNickForeColor", TEXT_MYNICK_FORE_COLOR);
			importData("TextMyNickBold", TEXT_MYNICK_BOLD);
			importData("TextMyNickItalic", TEXT_MYNICK_ITALIC);
			importData("TextFavBackColor", TEXT_FAV_BACK_COLOR);
			importData("TextFavForeColor", TEXT_FAV_FORE_COLOR);
			importData("TextFavBold", TEXT_FAV_BOLD);
			importData("TextFavItalic", TEXT_FAV_ITALIC);
			importData("TextURLBackColor", TEXT_URL_BACK_COLOR);
			importData("TextURLForeColor", TEXT_URL_FORE_COLOR);
			importData("TextURLBold", TEXT_URL_BOLD);
			importData("TextURLItalic", TEXT_URL_ITALIC);
			importData("BoldAuthorsMess", BOLD_AUTHOR_MESS);
			importData("ProgressTextDown", PROGRESS_TEXT_COLOR_DOWN);
			importData("ProgressTextUp", PROGRESS_TEXT_COLOR_UP);
			importData("ErrorColor", ERROR_COLOR);
			importData("ProgressOverrideColors", PROGRESS_OVERRIDE_COLORS);
			importData("MenubarTwoColors", MENUBAR_TWO_COLORS);
			importData("MenubarLeftColor", MENUBAR_LEFT_COLOR);
			importData("MenubarRightColor", MENUBAR_RIGHT_COLOR);
			importData("MenubarBumped", MENUBAR_BUMPED);
			importData("Progress3DDepth", PROGRESS_3DDEPTH);
			importData("ProgressOverrideColors2", PROGRESS_OVERRIDE_COLORS2);
			importData("TextOPBackColor", TEXT_OP_BACK_COLOR);
			importData("TextOPForeColor", TEXT_OP_FORE_COLOR);
			importData("TextOPBold", TEXT_OP_BOLD);
			importData("TextOPItalic", TEXT_OP_ITALIC);
			importData("SearchAlternateColour", SEARCH_ALTERNATE_COLOUR);
			importData("ProgressBackColor", PROGRESS_BACK_COLOR);
			importData("ProgressCompressColor", PROGRESS_COMPRESS_COLOR);
			importData("ProgressSegmentColor", PROGRESS_SEGMENT_COLOR);
			importData("ColorDone", COLOR_DONE);
			importData("ColorDownloaded", COLOR_DOWNLOADED);
			importData("ColorRunning", COLOR_RUNNING);
			importData("IgnoredColor", IGNORED_COLOR);
			importData("FavoriteColor", FAVORITE_COLOR);
			importData("NormalColour", NORMAL_COLOUR);
			importData("PasiveColor", PASIVE_COLOR);
			importData("OpColor", OP_COLOR);
			importData("ProgressbaroDCStyle", PROGRESSBAR_ODC_STYLE);
			importData("ProgressbaroDCStyle", PROGRESSBAR_ODC_STYLE);
		}
		xml.resetCurrentChild();
		xml.stepOut();
	}

	SendMessage(WM_DESTROY,0,0);
	//SettingsManager::getInstance()->save();
	PropertiesDlg::needUpdate = true;
	SendMessage(WM_INITDIALOG,0,0);

//	RefreshPreview();
	return 0;
}
Esempio n. 20
0
void SettingsManager::load(string const& aFileName)
{
	try {
		SimpleXML xml;

		xml.fromXML(File(aFileName, File::READ, File::OPEN).read());

		xml.resetCurrentChild();

		xml.stepIn();

		if(xml.findChild("Settings"))
		{
			xml.stepIn();

			int i;

			for(i=STR_FIRST; i<STR_LAST; i++)
			{
				const string& attr = settingTags[i];
				dcassert(attr.find("SENTRY") == string::npos);

				if(xml.findChild(attr))
					set(StrSetting(i), xml.getChildData());
				xml.resetCurrentChild();
			}
			for(i=INT_FIRST; i<INT_LAST; i++)
			{
				const string& attr = settingTags[i];
				dcassert(attr.find("SENTRY") == string::npos);

				if(xml.findChild(attr))
					set(IntSetting(i), Util::toInt(xml.getChildData()));
				xml.resetCurrentChild();
			}
			for(i=INT64_FIRST; i<INT64_LAST; i++)
			{
				const string& attr = settingTags[i];
				dcassert(attr.find("SENTRY") == string::npos);

				if(xml.findChild(attr))
					set(Int64Setting(i), Util::toInt64(xml.getChildData()));
				xml.resetCurrentChild();
			}

			xml.stepOut();
		}

		if(SETTING(PRIVATE_ID).length() != 39 || CID(SETTING(PRIVATE_ID)).isZero()) {
			set(PRIVATE_ID, CID::generate().toBase32());
		}
		
		double v = Util::toDouble(SETTING(CONFIG_VERSION));
		// if(v < 0.x) { // Fix old settings here }

		if(v <= 0.674) {

			// Formats changed, might as well remove these...
			set(LOG_FORMAT_POST_DOWNLOAD, Util::emptyString);
			set(LOG_FORMAT_POST_UPLOAD, Util::emptyString);
			set(LOG_FORMAT_MAIN_CHAT, Util::emptyString);
			set(LOG_FORMAT_PRIVATE_CHAT, Util::emptyString);
			set(LOG_FORMAT_STATUS, Util::emptyString);
			set(LOG_FORMAT_SYSTEM, Util::emptyString);
			set(LOG_FILE_MAIN_CHAT, Util::emptyString);
			set(LOG_FILE_STATUS, Util::emptyString);
			set(LOG_FILE_PRIVATE_CHAT, Util::emptyString);
			set(LOG_FILE_UPLOAD, Util::emptyString);
			set(LOG_FILE_DOWNLOAD, Util::emptyString);
			set(LOG_FILE_SYSTEM, Util::emptyString);
		}

		if(SETTING(SET_MINISLOT_SIZE) < 64)
			set(SET_MINISLOT_SIZE, 64);
		if(SETTING(AUTODROP_INTERVAL) < 1)
			set(AUTODROP_INTERVAL, 1);
		if(SETTING(AUTODROP_ELAPSED) < 1)
			set(AUTODROP_ELAPSED, 1);
		if(SETTING(AUTO_SEARCH_LIMIT) > 5)
			set(AUTO_SEARCH_LIMIT, 5);
		else if(SETTING(AUTO_SEARCH_LIMIT) < 1)
			set(AUTO_SEARCH_LIMIT, 1);

#ifdef _DEBUG
		set(PRIVATE_ID, CID::generate().toBase32());
#endif
		setDefault(UDP_PORT, SETTING(TCP_PORT));

		File::ensureDirectory(SETTING(TLS_TRUSTED_CERTIFICATES_PATH));

		fire(SettingsManagerListener::Load(), xml);

		xml.stepOut();

	} catch(const Exception&) {
		if(CID(SETTING(PRIVATE_ID)).isZero())
			set(PRIVATE_ID, CID::generate().toBase32());
	}
}
Esempio n. 21
0
void WulforSettings::loadOldConfig(){
    //Load default values into maps
    {
        strmap.insert(WS_CHAT_LOCAL_COLOR,      "#078010");
        strmap.insert(WS_CHAT_OP_COLOR,         "#000000");
        strmap.insert(WS_CHAT_BOT_COLOR,        "#838383");
        strmap.insert(WS_CHAT_FIND_COLOR,       "#FFFF00");
        strmap.insert(WS_CHAT_PRIV_LOCAL_COLOR, "#078010");
        strmap.insert(WS_CHAT_PRIV_USER_COLOR,  "#ac0000");
        strmap.insert(WS_CHAT_SAY_NICK,         "#2344e7");
        strmap.insert(WS_CHAT_CORE_COLOR,       "#ff0000");
        strmap.insert(WS_CHAT_STAT_COLOR,       "#ac0000");
        strmap.insert(WS_CHAT_USER_COLOR,       "#ac0000");
        strmap.insert(WS_CHAT_FAVUSER_COLOR,    "#00ff7f");
        strmap.insert(WS_CHAT_TIME_COLOR,       qApp->palette().text().color().name());
        strmap.insert(WS_CHAT_MSG_COLOR,        qApp->palette().text().color().name());
        strmap.insert(WS_CHAT_USERLIST_STATE,   "");
        strmap.insert(WS_CHAT_CMD_ALIASES,      "");
        strmap.insert(WS_CHAT_FONT,             "");
        strmap.insert(WS_CHAT_ULIST_FONT,       "");
        strmap.insert(WS_CHAT_PM_FONT,          "");
        strmap.insert(WS_CHAT_SEPARATOR,        ":");
        strmap.insert(WS_CHAT_TIMESTAMP,        "hh:mm:ss");
        strmap.insert(WS_QCONNECT_HISTORY,      "");
        strmap.insert(WS_DEFAULT_LOCALE,        "UTF-8");
        strmap.insert(WS_DOWNLOAD_DIR_HISTORY,  "");
        strmap.insert(WS_DQUEUE_STATE,          "");
        strmap.insert(WS_SEARCH_STATE,          "");
        strmap.insert(WS_SEARCH_HISTORY,        "");
        strmap.insert(WS_TRANSLATION_FILE,      "");
        strmap.insert(WS_TRANSFERS_STATE,       "");
        strmap.insert(WS_SHARE_LPANE_STATE,     "");
        strmap.insert(WS_SHARE_RPANE_STATE,     "");
        strmap.insert(WS_MAINWINDOW_STATE,      "");
        strmap.insert(WS_MAINWINDOW_TOOLBAR_ACTS,"");
        strmap.insert(WS_FTRANSFERS_FILES_STATE,"");
        strmap.insert(WS_FTRANSFERS_USERS_STATE,"");
        strmap.insert(WS_FAV_HUBS_STATE,        "");
        strmap.insert(WS_ADLS_STATE,            "");
        strmap.insert(WS_APP_THEME,             "");
        strmap.insert(WS_APP_FONT,              "");
        strmap.insert(WS_APP_ICONTHEME,         "default");
        strmap.insert(WS_APP_USERTHEME,         "default");
        strmap.insert(WS_APP_SHARED_FILES_COLOR,"#1f8f1f");
        strmap.insert(WS_NOTIFY_SOUNDS,         "");
        strmap.insert(WS_NOTIFY_SND_CMD,        "");
        strmap.insert(WS_FAVUSERS_STATE,        "");
        strmap.insert(WS_SHAREHEADER_STATE,     "");
        strmap.insert(WS_DOWNLOADTO_ALIASES,    "");
        strmap.insert(WS_DOWNLOADTO_PATHS,      "");
        strmap.insert(WS_APP_EMOTICON_THEME,    "default");
        strmap.insert(WS_APP_ASPELL_LANG,       "");
        strmap.insert(WS_APP_ENABLED_SCRIPTS,   "");
        strmap.insert(WS_PUBLICHUBS_STATE,      "");
        strmap.insert(WS_SETTINGS_GUI_FONTS_STATE, "");

        intmap.insert(WB_APP_AUTOAWAY_BY_TIMER, static_cast<int>(false));
        intmap.insert(WB_CHAT_SHOW_TIMESTAMP,   static_cast<int>(true));
        intmap.insert(WB_SHOW_FREE_SPACE,       static_cast<int>(true));
        intmap.insert(WB_LAST_STATUS,           static_cast<int>(true));
        intmap.insert(WB_USERS_STATISTICS,      static_cast<int>(true));
        intmap.insert(WB_CHAT_SHOW_JOINS,       static_cast<int>(false));
        intmap.insert(WB_CHAT_REDIRECT_BOT_PMS, static_cast<int>(true));
        intmap.insert(WB_CHAT_KEEPFOCUS,        static_cast<int>(true));
        intmap.insert(WB_CHAT_SHOW_JOINS_FAV,   static_cast<int>(true));
        intmap.insert(WB_CHAT_HIGHLIGHT_FAVS,   static_cast<int>(true));
        intmap.insert(WB_CHAT_ROTATING_MSGS,    static_cast<int>(true));
        intmap.insert(WB_CHAT_USE_SMILE_PANEL,  static_cast<int>(false));
        intmap.insert(WB_CHAT_HIDE_SMILE_PANEL, static_cast<bool>(true));
        intmap.insert(WB_MAINWINDOW_MAXIMIZED,  static_cast<int>(true));
        intmap.insert(WB_MAINWINDOW_HIDE,       static_cast<int>(false));
        intmap.insert(WB_MAINWINDOW_REMEMBER,   static_cast<int>(false));
        intmap.insert(WB_MAINWINDOW_USE_M_TABBAR, static_cast<int>(true));
        intmap.insert(WB_MAINWINDOW_USE_SIDEBAR, static_cast<int>(true));
        intmap.insert(WB_SEARCHFILTER_NOFREE,   static_cast<int>(false));
        intmap.insert(WB_SEARCH_DONTHIDEPANEL,  static_cast<int>(false));
        intmap.insert(WB_ANTISPAM_ENABLED,      static_cast<int>(false));
        intmap.insert(WB_ANTISPAM_AS_FILTER,    static_cast<int>(false));
        intmap.insert(WB_ANTISPAM_FILTER_OPS,   static_cast<int>(false));
        intmap.insert(WB_IPFILTER_ENABLED,      static_cast<int>(false));
        intmap.insert(WB_TRAY_ENABLED,          static_cast<int>(true));
        intmap.insert(WB_EXIT_CONFIRM,          static_cast<int>(false));
        intmap.insert(WB_SHOW_IP_IN_CHAT,       static_cast<int>(false));
        intmap.insert(WB_SHOW_HIDDEN_USERS,     static_cast<int>(false));
        intmap.insert(WB_SHOW_JOINS,            static_cast<int>(false));
        intmap.insert(WB_NOTIFY_ENABLED,        static_cast<int>(true));
        intmap.insert(WB_NOTIFY_SND_ENABLED,    static_cast<int>(false));
        intmap.insert(WB_NOTIFY_SND_EXTERNAL,   static_cast<int>(false));
        intmap.insert(WB_NOTIFY_CH_ICON_ALWAYS, static_cast<int>(false));
        intmap.insert(WB_NOTIFY_SHOW_ON_ACTIVE, static_cast<int>(false));
        intmap.insert(WB_NOTIFY_SHOW_ON_VISIBLE, static_cast<int>(false));
        intmap.insert(WB_FAVUSERS_AUTOGRANT,    static_cast<int>(true));
        intmap.insert(WB_APP_ENABLE_EMOTICON,   static_cast<int>(true));
        intmap.insert(WB_APP_FORCE_EMOTICONS,   static_cast<int>(false));
        intmap.insert(WB_APP_ENABLE_ASPELL,     static_cast<int>(true));
        intmap.insert(WB_APP_REMOVE_NOT_EX_DIRS,static_cast<int>(false));
        intmap.insert(WB_APP_AUTO_AWAY,         static_cast<int>(false));
        intmap.insert(WB_APP_TBAR_SHOW_CL_BTNS, static_cast<int>(true));
        intmap.insert(WB_WIDGETS_PANEL_VISIBLE, static_cast<int>(true));
        intmap.insert(WB_TOOLS_PANEL_VISIBLE,   static_cast<int>(true));
        intmap.insert(WB_SEARCH_PANEL_VISIBLE,  static_cast<int>(false));
        intmap.insert(WB_MAIN_MENU_VISIBLE,     static_cast<int>(true));
        intmap.insert(WB_USE_CTRL_ENTER,        static_cast<int>(false));
        intmap.insert(WB_SIMPLE_SHARE_MODE,     static_cast<int>(false));
        intmap.insert(WI_APP_UNIT_BASE,         1024);
        intmap.insert(WI_APP_AUTOAWAY_INTERVAL, 60);
        intmap.insert(WI_APP_SHARED_FILES_ALPHA, 127);
        intmap.insert(WI_CHAT_MAXPARAGRAPHS,    1000);
        intmap.insert(WI_DEF_MAGNET_ACTION,     0);
        intmap.insert(WI_CHAT_WIDTH,            -1);
        intmap.insert(WI_CHAT_USERLIST_WIDTH,   -1);
        intmap.insert(WI_CHAT_SORT_COLUMN,      0);
        intmap.insert(WI_CHAT_SORT_ORDER,       0);
        intmap.insert(WI_CHAT_DBLCLICK_ACT,     0);//nick in chat
        intmap.insert(WI_CHAT_MDLCLICK_ACT,     1);//browse files
        intmap.insert(WI_CHAT_FIND_COLOR_ALPHA, 127);
        intmap.insert(WI_CHAT_STATUS_HISTORY_SZ,5);
        intmap.insert(WI_CHAT_STATUS_MSG_MAX_LEN, 128);
        intmap.insert(WI_STATUSBAR_HISTORY_SZ,  5);
        intmap.insert(WI_MAINWINDOW_HEIGHT,     -1);
        intmap.insert(WI_MAINWINDOW_WIDTH,      -1);
        intmap.insert(WI_MAINWINDOW_X,          -1);
        intmap.insert(WI_MAINWINDOW_Y,          -1);
        intmap.insert(WI_SEARCH_SORT_COLUMN,    1);
        intmap.insert(WI_SEARCH_SORT_ORDER,     0);
        intmap.insert(WI_SEARCH_SHARED_ACTION,  0);
        intmap.insert(WI_SEARCH_LAST_TYPE,      0);
        intmap.insert(WI_TRANSFER_HEIGHT,       -1);
        intmap.insert(WI_SHARE_RPANE_WIDTH,     -1);
        intmap.insert(WI_SHARE_WIDTH,           -1);
        intmap.insert(WI_NOTIFY_EVENTMAP,       0x0B);// 0b00001011, (transfer done = off)
        intmap.insert(WI_NOTIFY_MODULE,         1);//default
        intmap.insert(WI_NOTIFY_SNDMAP,         0x0F);// 0b00001111, all events
        intmap.insert(WI_OUT_IN_HIST,           50);//number of output messages in history
    }

    if (!QFile::exists(configFileOld))
        return;

    try{
        SimpleXML xml;
        xml.fromXML(File(configFileOld.toStdString(), File::READ, File::OPEN).read());
        xml.resetCurrentChild();
        xml.stepIn();

        if (xml.findChild("Settings")){

            xml.stepIn();

            auto it = strmap.begin();

            for (; it != strmap.end(); ++it){
                if (xml.findChild(it.key().toStdString()))
                        strmap.insert(it.key(), QString::fromStdString(xml.getChildData()));

                xml.resetCurrentChild();
            }

            auto iit = intmap.begin();

            for (; iit != intmap.end(); ++iit){
                if (xml.findChild(iit.key().toStdString()))
                    intmap.insert(iit.key(), Util::toInt(xml.getChildData()));

                xml.resetCurrentChild();
            }
        }
    }
    catch (Exception &ex){}
}
Esempio n. 22
0
void UpdateManager::completeVersionDownload(bool manualCheck) {
	auto& conn = conns[CONN_VERSION];
	if(!conn) { return; }
	ScopedFunctor([&conn] { conn.reset(); });

	if (conn->buf.empty()) {
		failVersionDownload(STRING_F(DOWNLOAD_VERSION_FAILED, conn->status), manualCheck);
		return; 
	}

	bool verified = !versionSig.empty() && UpdateManager::verifyVersionData(conn->buf, versionSig);
	if(!verified) {
		failVersionDownload(STRING(VERSION_VERIFY_FAILED), manualCheck);
	}

	try {
		SimpleXML xml;
		xml.fromXML(conn->buf);
		xml.stepIn();


		//Check for updated HTTP links
		if(xml.findChild("Links")) {
			xml.stepIn();
			if(xml.findChild("Homepage")) {
				links.homepage = xml.getChildData();
			}
			xml.resetCurrentChild();
			if(xml.findChild("Downloads")) {
				links.downloads = xml.getChildData();
			}
			xml.resetCurrentChild();
			if(xml.findChild("GeoIPv6")) {
				links.geoip6 = xml.getChildData();
			}
			xml.resetCurrentChild();
			if(xml.findChild("GeoIPv4")) {
				links.geoip4 = xml.getChildData();
			}
			xml.resetCurrentChild();
			if(xml.findChild("Customize")) {
				links.customize = xml.getChildData();
			}
			xml.resetCurrentChild();
			if(xml.findChild("Forum")) {
				links.discuss = xml.getChildData();
			}
			xml.resetCurrentChild();
			if(xml.findChild("Languages")) {
				links.language = xml.getChildData();
			}
			xml.resetCurrentChild();
			if(xml.findChild("Guides")) {
				links.guides = xml.getChildData();
			}
			xml.resetCurrentChild();
			if(xml.findChild("IPCheck")) {
				links.ipcheck4 = xml.getChildData();
			}
			xml.resetCurrentChild();
			if(xml.findChild("IPCheck6")) {
				links.ipcheck6 = xml.getChildData();
			}
			xml.stepOut();
		}
		xml.resetCurrentChild();

		updater->onVersionDownloaded(xml, verified, manualCheck);
	} catch (const Exception& e) {
		failVersionDownload(STRING_F(VERSION_PARSING_FAILED, e.getError()), manualCheck);
	}

	checkAdditionalUpdates(manualCheck);
}
void PropPageTextStyles::LoadTheme(const string& path) {
		
	SimpleXML xml;
	try {
		xml.fromXML(File(path, File::READ, File::OPEN, false).read());
	} catch(...) {
		return;
	}
	xml.resetCurrentChild();
	xml.stepIn();
	if(xml.findChild(("Settings"))) {
		xml.stepIn();

		importData("Font", TEXT_FONT);
		importData("BackgroundColor", BACKGROUND_COLOR);
		importData("TextColor", TEXT_COLOR);
		importData("DownloadBarColor", DOWNLOAD_BAR_COLOR);
		importData("UploadBarColor", UPLOAD_BAR_COLOR);
		importData("TextGeneralBackColor", TEXT_GENERAL_BACK_COLOR);
		importData("TextGeneralForeColor", TEXT_GENERAL_FORE_COLOR);
		importData("TextGeneralBold", TEXT_GENERAL_BOLD);
		importData("TextGeneralItalic", TEXT_GENERAL_ITALIC);
		importData("TextMyOwnBackColor", TEXT_MYOWN_BACK_COLOR);
		importData("TextMyOwnForeColor", TEXT_MYOWN_FORE_COLOR);
		importData("TextMyOwnBold", TEXT_MYOWN_BOLD);
		importData("TextMyOwnItalic", TEXT_MYOWN_ITALIC);
		importData("TextPrivateBackColor", TEXT_PRIVATE_BACK_COLOR);
		importData("TextPrivateForeColor", TEXT_PRIVATE_FORE_COLOR);
		importData("TextPrivateBold", TEXT_PRIVATE_BOLD);
		importData("TextPrivateItalic", TEXT_PRIVATE_ITALIC);
		importData("TextSystemBackColor", TEXT_SYSTEM_BACK_COLOR);
		importData("TextSystemForeColor", TEXT_SYSTEM_FORE_COLOR);
		importData("TextSystemBold", TEXT_SYSTEM_BOLD);
		importData("TextSystemItalic", TEXT_SYSTEM_ITALIC);
		importData("TextServerBackColor", TEXT_SERVER_BACK_COLOR);
		importData("TextServerForeColor", TEXT_SERVER_FORE_COLOR);
		importData("TextServerBold", TEXT_SERVER_BOLD);
		importData("TextServerItalic", TEXT_SERVER_ITALIC);
		importData("TextTimestampBackColor", TEXT_TIMESTAMP_BACK_COLOR);
		importData("TextTimestampForeColor", TEXT_TIMESTAMP_FORE_COLOR);
		importData("TextTimestampBold", TEXT_TIMESTAMP_BOLD);
		importData("TextTimestampItalic", TEXT_TIMESTAMP_ITALIC);
		importData("TextMyNickBackColor", TEXT_MYNICK_BACK_COLOR);
		importData("TextMyNickForeColor", TEXT_MYNICK_FORE_COLOR);
		importData("TextMyNickBold", TEXT_MYNICK_BOLD);
		importData("TextMyNickItalic", TEXT_MYNICK_ITALIC);
		importData("TextFavBackColor", TEXT_FAV_BACK_COLOR);
		importData("TextFavForeColor", TEXT_FAV_FORE_COLOR);
		importData("TextFavBold", TEXT_FAV_BOLD);
		importData("TextFavItalic", TEXT_FAV_ITALIC);
		importData("TextURLBackColor", TEXT_URL_BACK_COLOR);
		importData("TextURLForeColor", TEXT_URL_FORE_COLOR);
		importData("TextURLBold", TEXT_URL_BOLD);
		importData("TextURLItalic", TEXT_URL_ITALIC);
		importData("TextDupeBackColor", TEXT_DUPE_BACK_COLOR);
		importData("TextDupeColor", DUPE_COLOR);
		importData("TextDupeBold", TEXT_DUPE_BOLD);
		importData("TextDupeItalic", TEXT_DUPE_ITALIC);
		importData("ProgressTextDown", PROGRESS_TEXT_COLOR_DOWN);
		importData("ProgressTextUp", PROGRESS_TEXT_COLOR_UP);
		importData("ErrorColor", ERROR_COLOR);
		importData("ProgressOverrideColors", PROGRESS_OVERRIDE_COLORS);
		importData("MenubarTwoColors", MENUBAR_TWO_COLORS);
		importData("MenubarLeftColor", MENUBAR_LEFT_COLOR);
		importData("MenubarRightColor", MENUBAR_RIGHT_COLOR);
		importData("MenubarBumped", MENUBAR_BUMPED);
		importData("Progress3DDepth", PROGRESS_3DDEPTH);
		importData("ProgressOverrideColors2", PROGRESS_OVERRIDE_COLORS2);
		importData("TextOPBackColor", TEXT_OP_BACK_COLOR);
		importData("TextOPForeColor", TEXT_OP_FORE_COLOR);
		importData("TextOPBold", TEXT_OP_BOLD);
		importData("TextOPItalic", TEXT_OP_ITALIC);
		importData("TextNormBackColor", TEXT_NORM_BACK_COLOR);
		importData("TextNormForeColor", TEXT_NORM_FORE_COLOR);
		importData("TextNormBold", TEXT_NORM_BOLD);
		importData("TextNormItalic", TEXT_NORM_ITALIC);
		importData("SearchAlternateColour", SEARCH_ALTERNATE_COLOUR);
		importData("ProgressBackColor", PROGRESS_BACK_COLOR);
		importData("ProgressCompressColor", PROGRESS_COMPRESS_COLOR);
		importData("ProgressSegmentColor", PROGRESS_SEGMENT_COLOR);
		importData("ColorDone", COLOR_DONE);
		importData("ColorDownloaded", COLOR_DOWNLOADED);
		importData("ColorRunning", COLOR_RUNNING);
		importData("ReservedSlotColor", RESERVED_SLOT_COLOR);
		importData("IgnoredColor", IGNORED_COLOR);
		importData("FavoriteColor", FAVORITE_COLOR);
		importData("NormalColour", NORMAL_COLOUR);
		importData("PasiveColor", PASIVE_COLOR);
		importData("OpColor", OP_COLOR);
		importData("ProgressbaroDCStyle", PROGRESSBAR_ODC_STYLE);
		importData("UnderlineLinks", UNDERLINE_LINKS);
		importData("UnderlineDupes", UNDERLINE_DUPES);
		importData("TextQueueBackColor", TEXT_QUEUE_BACK_COLOR);
		importData("QueueColor", QUEUE_COLOR);
		importData("TextQueueBold", TEXT_QUEUE_BOLD);
		importData("TextQueueItalic", TEXT_QUEUE_ITALIC);
		importData("UnderlineQueue", UNDERLINE_QUEUE);

		//tabs
		importData("tabactivebg", TAB_ACTIVE_BG);
		importData("TabActiveText", TAB_ACTIVE_TEXT);
		importData("TabActiveBorder", TAB_ACTIVE_BORDER);
		importData("TabInactiveBg", TAB_INACTIVE_BG);
		importData("TabInactiveBgDisconnected", TAB_INACTIVE_BG_DISCONNECTED);
		importData("TabInactiveText", TAB_INACTIVE_TEXT);
		importData("TabInactiveBorder", TAB_INACTIVE_BORDER);
		importData("TabInactiveBgNotify", TAB_INACTIVE_BG_NOTIFY);
		importData("TabDirtyBlend", TAB_DIRTY_BLEND);
		importData("BlendTabs", BLEND_TABS);
		importData("TabSize", TAB_SIZE);

	}
	xml.stepOut();

	if(xml.findChild("Icons")) {
		if(MessageBox(CTSTRING(ICONS_IN_THEME), _T("AirDC++") _T(" ") _T(VERSIONSTRING), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES) {
			xml.stepIn();
			importData("IconPath", ICON_PATH);
			//toolbars not exported to avoid absolute local paths in toolbar settings.
			importData("ToolbarImage", TOOLBARIMAGE);
			importData("ToolbarHot", TOOLBARHOTIMAGE);
			xml.resetCurrentChild();
			xml.stepOut();
		}
	}
	xml.resetCurrentChild();
	if(xml.findChild("Highlights")) {
		if(MessageBox(CTSTRING(HIGHLIGHTS_IN_THEME), _T("AirDC++") _T(" ") _T(VERSIONSTRING), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES) {
			HighlightManager::getInstance()->clearList();
			HighlightManager::getInstance()->load(xml);
		}
	}
	xml.resetCurrentChild();
			
	//SendMessage(WM_DESTROY,0,0);
	//SettingsManager::getInstance()->save();
	//SendMessage(WM_INITDIALOG,0,0);
	SettingsManager::getInstance()->reloadPages();
	
	fontdirty = true;

}
Esempio n. 24
0
	void WebServerManager::loadServer(SimpleXML& aXml, const string& aTagName, ServerConfig& config_) noexcept {
		if (aXml.findChild(aTagName)) {
			config_.setPort(aXml.getIntChildAttrib("Port"));
			aXml.resetCurrentChild();
		}
	}
Esempio n. 25
0
void SettingsManager::load(string const& aFileName, bool main)
{
	try {
		SimpleXML xml;
		xml.fromXML(File(aFileName, File::READ, File::OPEN).read());
		xml.resetCurrentChild();
		xml.stepIn();
		if(xml.findChild("Settings")) {
			xml.stepIn();
			for(int i=STR_FIRST; i<STR_LAST; i++) {
				const string& attr = settingTags[i];
				dcassert(attr.find(SENTRY) == string::npos);
				
				if(xml.findChild(attr))
					set(StrSetting(i), xml.getChildData());
				xml.resetCurrentChild();
			}
			for(int i=INT_FIRST+1; i<INT_LAST; i++) {
				const string& attr = settingTags[i];
				dcassert(attr.find(SENTRY) == string::npos);
				
				if(xml.findChild(attr))
					set(IntSetting(i), Util::toInt(xml.getChildData()));
				xml.resetCurrentChild();
			}
			for(int i=INT64_FIRST; i<INT64_LAST; i++) {
				const string& attr = settingTags[i];
				dcassert(attr.find(SENTRY) == string::npos);
				
				if(xml.findChild(attr))
					set(Int64Setting(i), Util::toInt64(xml.getChildData()));
				xml.resetCurrentChild();
			}			
			xml.stepOut();
		}

		if (main) {
			double v = Util::toDouble(SETTING(CONFIG_VERSION));
			// if(v < 0.x) { // Fix old settings here }

			if(v <= 0.674 || SETTING(PRIVATE_ID).length() != 39 || CID(SETTING(PRIVATE_ID)).isZero()) {
				set(PRIVATE_ID, CID::generate().toBase32());

				// Formats changed, might as well remove these...
				set(LOG_FORMAT_POST_DOWNLOAD, Util::emptyString);
				set(LOG_FORMAT_POST_UPLOAD, Util::emptyString);
				set(LOG_FORMAT_MAIN_CHAT, Util::emptyString);
				set(LOG_FORMAT_PRIVATE_CHAT, Util::emptyString);
				set(LOG_FORMAT_STATUS, Util::emptyString);
				set(LOG_FORMAT_SYSTEM, Util::emptyString);
				set(LOG_FILE_MAIN_CHAT, Util::emptyString);
				set(LOG_FILE_STATUS, Util::emptyString);
				set(LOG_FILE_PRIVATE_CHAT, Util::emptyString);
				set(LOG_FILE_UPLOAD, Util::emptyString);
				set(LOG_FILE_DOWNLOAD, Util::emptyString);
				set(LOG_FILE_SYSTEM, Util::emptyString);
			}

			if(v <= 16) {
				set(HUBLIST_SERVERS, Util::emptyString);
			}
#ifdef _DEBUG
			set(PRIVATE_ID, CID::generate().toBase32());
#endif
			setDefault(UDP_PORT, SETTING(TCP_PORT));

#ifdef PPA_INCLUDE_SSL
			File::ensureDirectory(SETTING(TLS_TRUSTED_CERTIFICATES_PATH));
#endif

			fire(SettingsManagerListener::Load(), xml);
		}

		xml.stepOut();

	} catch(const Exception&) {
		if (main) {
			if(CID(SETTING(PRIVATE_ID)).isZero())
				set(PRIVATE_ID, CID::generate().toBase32());
		}
	}

	if (main) {
		if(SETTING(TCP_PORT) == 0) {
			set(TCP_PORT, (int)Util::rand(1025, 8000));
		}
		if(SETTING(UDP_PORT) == 0) {
			set(UDP_PORT, (int)Util::rand(1025, 8000));
		}
		if(SETTING(TLS_PORT) == 0) {
			set(TLS_PORT, (int)Util::rand(1025, 32000));
		}
	}

}
Esempio n. 26
0
bool
RSSFeed::ProcessRSS(void* data, RSSParser parser, bool isUtf8)
{
	time_t maxLastDate = 0;
	if (parser == XML_PARSER)
	{
		XMLParser::XMLNode* rootNode = reinterpret_cast<XMLParser::XMLNode*>(data);
		if (rootNode != nullptr)
		{
			XMLParser::XMLNode rssNode = rootNode->getChildNode("rss");
			if (!rssNode.isEmpty())
			{
				XMLParser::XMLNode channelNode = rssNode.getChildNode("channel");
				if (!channelNode.isEmpty())
				{
					// Search items
					int i = 0;
					XMLParser::XMLNode itemNode = channelNode.getChildNode("item", &i);
					while (!itemNode.isEmpty())
					{
						string title;
						string url;
						string desc;
						time_t pubDate = 0;
						string author;
						string category;
						XMLParser::XMLNode titleNode = itemNode.getChildNode("title");
						if (!titleNode.isEmpty())
						{
							if (titleNode.nText())
								title = titleNode.getText();
							else if (titleNode.nClear())
								title = titleNode.getClear().lpszValue;
							if (isUtf8) title = Text::fromUtf8(title);
						}
						XMLParser::XMLNode linkNode = itemNode.getChildNode("link");
						if (!linkNode.isEmpty())
						{
							if (linkNode.nText())
								url = linkNode.getText();
							else if (linkNode.nClear())
								url = linkNode.getClear().lpszValue;
							// [!] SSA Can be problems
							if (isUtf8) url = Text::utf8ToAcp(Text::fromUtf8(url));
						}
						XMLParser::XMLNode descNode = itemNode.getChildNode("description");
						if (!descNode.isEmpty())
						{
							if (descNode.nText())
								desc = descNode.getText();
							else if (descNode.nClear())
								desc = descNode.getClear().lpszValue;
							if (isUtf8) desc = Text::fromUtf8(desc);
						}
						XMLParser::XMLNode pubDateNode = itemNode.getChildNode("pubDate");
						if (!pubDateNode.isEmpty())
						{
							string pDate;
							if (pubDateNode.nText())
								pDate = pubDateNode.getText();
							else if (pubDateNode.nClear())
								pDate = pubDateNode.getClear().lpszValue;
								
							pubDate = convertPubDate(pDate);
						}
						XMLParser::XMLNode authorNode =  itemNode.getChildNode("author");
						if (!authorNode.isEmpty())
						{
							if (authorNode.nText())
								author =  authorNode.getText();
							else if (authorNode.nClear())
								author = authorNode.getClear().lpszValue;
							if (isUtf8) author = Text::fromUtf8(author);
						}
						XMLParser::XMLNode categoryNode =  itemNode.getChildNode("category");
						if (!categoryNode.isEmpty())
						{
							if (categoryNode.nText())
								category = categoryNode.getText();
							else if (categoryNode.nClear())
								category = categoryNode.getClear().lpszValue;
							if (isUtf8) category = Text::fromUtf8(category);
						}
						
						if (pubDate == 0 || lastNewsDate < pubDate)
						{
							if (pubDate > maxLastDate)
								maxLastDate = pubDate;
								
							RSSItem* item = new RSSItem(Util::ConvertFromHTML(title), url, Util::ConvertFromHTML(desc), pubDate, author, category, source);
							CFlyFastLock(csNews);
							m_newsList.push_back(item);
						}
						
						itemNode = channelNode.getChildNode("item", &i);
					}
					if (maxLastDate > lastNewsDate)
						lastNewsDate = maxLastDate;
						
					CFlyFastLock(csNews);
					return !m_newsList.empty();
				}
			}
		}
	}
	else if (parser == XML_SIMPLE)
	{
		SimpleXML* xml = reinterpret_cast<SimpleXML*>(data);
		if (xml != nullptr)
		{
			xml->resetCurrentChild();
			
			if (xml->findChild("rss"))
			{
				xml->stepIn();
				if (xml->findChild("channel"))
				{
					xml->stepIn();
					while (xml->findChild("item"))
					{
						xml->stepIn();
						string title;
						string url;
						string desc;
						time_t pubDate = 0;
						string author;
						string category;
						if (xml->findChild("title"))
							removeCDATA(xml->getChildData(), title);
						xml->resetCurrentChild();
						if (xml->findChild("link"))
							removeCDATA(xml->getChildData(), url);
						xml->resetCurrentChild();
						if (xml->findChild("description"))
							removeCDATA(xml->getChildData(), desc);
						xml->resetCurrentChild();
						if (xml->findChild("pubDate"))
						{
							string pDate;
							removeCDATA(xml->getChildData(), pDate);
							pubDate = convertPubDate(pDate);
						}
						xml->resetCurrentChild();
						
						if (xml->findChild("author"))
							removeCDATA(xml->getChildData(), author);
						xml->resetCurrentChild();
						if (xml->findChild("category"))
							removeCDATA(xml->getChildData(), category);
						xml->resetCurrentChild();
						
						if (pubDate == 0 || lastNewsDate < pubDate)
						{
							if (pubDate > maxLastDate)
								maxLastDate = pubDate;
								
							RSSItem* item = new RSSItem(Util::ConvertFromHTML(title), url, desc, pubDate, author, category, source);
							CFlyFastLock(csNews);
							m_newsList.push_back(item);
						}
						xml->stepOut();
					}
				}
			}
			if (maxLastDate > lastNewsDate)
				lastNewsDate = maxLastDate;
				
			CFlyFastLock(csNews);
			return !m_newsList.empty();
		}
	}
	return false;
}