void IpManager::onIPUpdate(string buf, bool isFailed) {
	if(!isFailed) {
		if(!buf.empty()) {
			try {
				SimpleXML xml;
				xml.fromXML(buf);
				if(xml.findChild("html")) {
					xml.stepIn();
					if(xml.findChild("body")) {
						string x = xml.getChildData().substr(20);
						if(Util::isPrivateIp(x)) {
							SettingsManager::getInstance()->set(SettingsManager::INCOMING_CONNECTIONS, SettingsManager::INCOMING_FIREWALL_PASSIVE);
						}
						SettingsManager::getInstance()->set(SettingsManager::EXTERNAL_IP, x);				
					} else {
						SettingsManager::getInstance()->set(SettingsManager::EXTERNAL_IP, Util::getLocalIp());
					}
				}
			} catch(const SimpleXMLException&) {
				//...
			}
		}
	} else {
		if(!SETTING(NO_IP_OVERRIDE)) {
			if(Util::isPrivateIp(Util::getLocalIp())) {
				SettingsManager::getInstance()->set(SettingsManager::INCOMING_CONNECTIONS, SettingsManager::INCOMING_FIREWALL_PASSIVE);
			}
			SettingsManager::getInstance()->set(SettingsManager::EXTERNAL_IP, Util::getLocalIp());
		}
	}

}
Esempio n. 2
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. 3
0
RSSFeed::RssFormat RSSFeed::DetectRSSFormat(void* data, RSSParser parser)
{
	if (parser == XML_PARSER)
	{
		XMLParser::XMLNode* rootNode = reinterpret_cast<XMLParser::XMLNode*>(data);
		if (rootNode != nullptr)
		{
			// Start Detection
			XMLParser::XMLNode rssNode = rootNode->getChildNode("rss");
			if (!rssNode.isEmpty())
			{
				return RSS_2_0;
			}
			XMLParser::XMLNode atomNode = rootNode->getChildNode("feed");
			if (!atomNode.isEmpty())
			{
				return RSS_ATOM;
			}
		}
	}
	else if (parser == XML_SIMPLE)
	{
		SimpleXML* xml = reinterpret_cast<SimpleXML*>(data);
		if (xml != nullptr)
		{
			if (xml->findChild("rss")) return RSS_2_0;
			if (xml->findChild("feed")) return RSS_ATOM;
		}
	}
	return RSS_2_0;
}
Esempio n. 4
0
	bool WebServerManager::load() noexcept {
		try {
			SimpleXML xml;
			SettingsManager::loadSettingFile(xml, CONFIG_DIR, CONFIG_NAME, true);
			if (xml.findChild("WebServer")) {
				xml.stepIn();

				if (xml.findChild("Config")) {
					xml.stepIn();
					loadServer(xml, "Server", plainServerConfig);
					loadServer(xml, "TLSServer", tlsServerConfig);

					if (xml.findChild("Threads")) {
						xml.stepIn();
						serverThreads = min(Util::toInt(xml.getData()), 2);
						xml.stepOut();
					}

					xml.stepOut();
				}

				fire(WebServerManagerListener::LoadSettings(), xml);

				xml.stepOut();
			}
		} catch (const Exception& e) {
			LogManager::getInstance()->message(STRING_F(LOAD_FAILED_X, CONFIG_NAME % e.getError()), LogMessage::SEV_ERROR);
		}

		return hasValidConfig();
	}
Esempio n. 5
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. 6
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();
		}
	}
Esempio n. 7
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);
    }
}
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();
    }
}
Esempio n. 9
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. 10
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. 11
0
void ResourceManager::loadLanguage(const string& aFile) {
	try {
		File f(aFile, File::READ, File::OPEN);
		SimpleXML xml;
		xml.fromXML(f.read());

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

		if(xml.findChild("Language")) {
			rtl = xml.getBoolChildAttrib("RightToLeft");

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

				while(xml.findChild("String")) {
					unordered_map<string, int>::const_iterator j = h.find(xml.getChildAttrib("Name"));

					if(j != h.end()) {
						strings[j->second] = xml.getChildData();
					}
				}
				createWide();
			}
		}
	} catch(const Exception&) {
		// ...
	}
}
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. 13
0
void IgnoreManager::load(SimpleXML& aXml) {
	if(aXml.findChild("IgnoreList")) {
		aXml.stepIn();
		while(aXml.findChild("User")) {	
			ignoredUsers.insert(Text::toT(aXml.getChildAttrib("Nick")));
		}
		aXml.stepOut();
	}
}
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 FireResourceManager::loadLanguage(const string& aFile) {
	try {
		File f(aFile, File::READ, File::OPEN);
		SimpleXML xml;
		xml.fromXML(f.read());

		HASH_MAP<string, int> h;
//FireDC++ start
		HASH_MAP<string, int> e;
		
//FireDC++ end
		for(int i = 0; i < LAST; ++i) {
			h[names[i]] = i;
		}
//FireDC++ start
		for(int i = 0; i < LASTTWO; ++i) {
			e[namesTwo[i]] = i;
		}
//FireDC++ end
		if(xml.findChild("Language")) {
			rtl = xml.getBoolChildAttrib("RightToLeft");

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

				while(xml.findChild("String")) {
					HASH_MAP<string, int>::iterator j = h.find(xml.getChildAttrib("Name"));

					if(j != h.end()) {
						strings[j->second] = xml.getChildData();
					}
				}
				createWide();
			}
//FireDC++ start
			xml.stepOut();
			if(xml.findChild("StringsTwo")) {
				xml.stepIn();

				while(xml.findChild("StringTwo")) {
					HASH_MAP<string, int>::iterator j = e.find(xml.getChildAttrib("Name"));

					if(j != e.end()) {
						stringsTwo[j->second] = xml.getChildData();
					}
				}
				createWideTwo();
			}
//FireDC++ end
		}
	} catch(const Exception&) {
		// ...
	}
}
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. 17
0
bool CAGEmotionSetup::LoadEmotion(const string& p_file_name) {
  const string l_fileName = Util::getDataPath() + "EmoPacks\\" + p_file_name + ".xml";
  if ((p_file_name == "Disabled") || !Util::fileExists(l_fileName)) {
    return true;
  }
  try {
    SimpleXML xml;
    xml.fromXML(File(l_fileName, File::READ, File::OPEN).read());
    if (xml.findChild("Emoticons")) {
      xml.stepIn();
      while (xml.findChild("Emoticon")) {
        string strEmotionText = xml.getChildAttrib("PasteText");
        if (strEmotionText.empty()) {
          strEmotionText = xml.getChildAttrib("Expression");
        }
        while (strEmotionText[0] == ' ') // ltrim
          strEmotionText.erase(0, 1);
        if (!strEmotionText.empty()) { 
          // dcdebug("CAGEmotionSetup::Create: emotion:[%s]\n", Text::fromT(strEmotionText).c_str());
          if (m_FilterEmotiion.count(strEmotionText)) {
            //	dcdebug("CAGEmotionSetup::Create: dup emotion:[%s]\n", strEmotionText.c_str());
            continue;
          }
          m_FilterEmotiion.insert(strEmotionText); 
          string strEmotionBmpPath = xml.getChildAttrib("Bitmap");
          if (strEmotionBmpPath.size() > 0) {
            if (strEmotionBmpPath[0] == '.') {
              // Relativni cesta - dame od aplikace
              strEmotionBmpPath = Util::getDataPath() + "EmoPacks\\" + strEmotionBmpPath;
            }
            else strEmotionBmpPath = "EmoPacks\\" + strEmotionBmpPath;
          }
          CAGEmotion* pEmotion = new CAGEmotion();
          //[!]PPA for lock bmp
          //File* l__f = new File (Util::getDataPath() + strEmotionBmpPath, File::READ, File::OPEN);
          if (!pEmotion->Create(Text::toT(strEmotionText), strEmotionBmpPath)) {
            delete pEmotion;
            continue;
          }
          m_CountSelEmotions++;
          EmotionsList.push_back(pEmotion);
        } 
      }
      xml.stepOut();
    }
  } 
  catch(const Exception& e) {
    dcdebug("CAGEmotionSetup::Create: %s\n", e.getError().c_str());
    return false;
  }
  return true;
}
Esempio n. 18
0
void MessageManager::load(SimpleXML& aXml) {

    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. 19
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 RawManager::on(SettingsManagerListener::Load, SimpleXML& xml) throw() {
	if(xml.findChild("ADLSPoints")) {
		xml.stepIn();
		while(xml.findChild("PointsSetting")) {
			int _points = xml.getIntChildAttrib("Points");
			if(_points <= 0)
				continue;

			Lock l(cs);
			IntMap::iterator i = points.find(_points);
			if(i != points.end())
				continue;
			int _action = xml.getIntChildAttrib("Action");
			points.insert(make_pair(_points, _action));
		}
		xml.stepOut();
	}
}
Esempio n. 21
0
void ClientManager::loadUsers() {
	try {
		SimpleXML xml;
		xml.fromXML(File(getUsersFile(), File::READ, File::OPEN).read());

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

			{
				Lock l(cs);
				while(xml.findChild("User")) {
					nicks[CID(xml.getChildAttrib("CID"))] = std::make_pair(xml.getChildAttrib("Nick"), false);
				}
			}

			xml.stepOut();
		}
	} catch(const Exception&) { }
}
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. 23
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();
	}
}
Esempio n. 24
0
void EmoticonsManager::Load() {

	setUseEmoticons(false);

	if((SETTING(EMOTICONS_FILE) == "Disabled") || !Util::fileExists(Util::getPath(Util::PATH_EMOPACKS) + SETTING(EMOTICONS_FILE) + ".xml" )) {
		return;
	}

	try {
		SimpleXML xml;
		xml.fromXML(File(Util::getPath(Util::PATH_EMOPACKS) + SETTING(EMOTICONS_FILE) + ".xml", File::READ, File::OPEN).read());
		
		if(xml.findChild("Emoticons")) {
			xml.stepIn();

			while(xml.findChild("Emoticon")) {
				tstring strEmotionText = Text::toT(xml.getChildAttrib("PasteText"));
				if (strEmotionText.empty()) {
					strEmotionText = Text::toT(xml.getChildAttrib("Expression"));
				}
				
				string strEmotionBmpPath = xml.getChildAttrib("Bitmap");
				if (!strEmotionBmpPath.empty()) {
					if (strEmotionBmpPath[0] == '.') {
						// change relative path
						strEmotionBmpPath = Util::getPath(Util::PATH_EMOPACKS) + strEmotionBmpPath;
					} else {
						strEmotionBmpPath = "EmoPacks\\" + strEmotionBmpPath;
					}
				}

				emoticons.push_back(new Emoticon(strEmotionText, strEmotionBmpPath));
			}
			xml.stepOut();
		}
	} catch(const Exception& e) {
		dcdebug("EmoticonsManager::Create: %s\n", e.getError().c_str());
		return;
	}
	
	setUseEmoticons(true);
}
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();
		}
	}
}
void IpManager::WatchLoad() {
	try {
		SimpleXML xml;
		xml.fromXML(File(Util::getPath(Util::PATH_USER_CONFIG) + "IPWatch.xml", File::READ, File::OPEN).read());
		if(xml.findChild("IPWatch")) {
			xml.stepIn();
			loadWatch(xml);
			xml.stepOut();
		}
	} catch(const Exception& e) {
		dcdebug("IpManager::WatchLoad: %s\n", e.getError().c_str());
	}	
}
Esempio n. 27
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. 28
0
void ClientProfileManager::loadClientProfiles() {
	try {
		SimpleXML xml;
		xml.fromXML(File(Util::getConfigPath() + "Profiles.xml", File::READ, File::OPEN).read());
		
		if(xml.findChild("Profiles")) {
			xml.stepIn();
			loadClientProfiles(&xml);
			xml.stepOut();
		}
	} catch(const Exception& e) {
		dcdebug("FavoriteManager::loadClientProfiles: %s\n", e.getError().c_str());
	}
}
Esempio n. 29
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();
	}
}
void RawManager::loadActionRaws() {
	try {
		SimpleXML xml;
		xml.fromXML(File(Util::getPath(Util::PATH_USER_CONFIG) + "Raws.xml", File::READ, File::OPEN).read());
		
		if(xml.findChild("ActionRaws")) {
			xml.stepIn();
			loadActionRaws(xml);
			xml.stepOut();
		}
	} catch(const Exception& e) {
		dcdebug("RawManager::loadActionRaws: %s\n", e.getError().c_str());
	}
}