Esempio n. 1
0
void IpGuard::save()
{
	Lock l(cs);
	
	SimpleXML xml;
	xml.addTag("IpRanges");
	xml.stepIn();
	for (RangeIter i = ranges.begin(); i != ranges.end(); ++i)
	{
		xml.addTag("Range");
		xml.addChildAttrib("Start", Util::toString(i->start.iIP));
		xml.addChildAttrib("End", Util::toString(i->end.iIP));
		xml.addChildAttrib("Comment", i->name);
	}
	xml.stepOut();
	
	try
	{
		string fname = Util::getPath(Util::PATH_USER_CONFIG) + "IPGuard.xml";
		
		File f(fname + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE);
		f.write(SimpleXML::utf8Header);
		f.write(xml.toXML());
		f.close();
		File::deleteFile(fname);
		File::renameFile(fname + ".tmp", fname);
	}
	catch (const Exception& e)
	{
		dcdebug("IpGuard::save: %s\n", e.getError().c_str());
	}
}
Esempio n. 2
0
void ClientManager::saveUsers() const {
	try {
		SimpleXML xml;
		xml.addTag("Users");
		xml.stepIn();

		{
			Lock l(cs);
			for(auto& i: nicks) {
				if(i.second.second) {
					xml.addTag("User");
					xml.addChildAttrib("CID", i.first.toBase32());
					xml.addChildAttrib("Nick", i.second.first);
				}
			}
		}

		xml.stepOut();

		const string fName = getUsersFile();
		File out(fName + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE);
		BufferedOutputStream<false> f(&out);
		f.write(SimpleXML::utf8Header);
		xml.toXML(&f);
		f.flush();
		out.close();
		File::deleteFile(fName);
		File::renameFile(fName + ".tmp", fName);
	} catch(const Exception&) { }
}
Esempio n. 3
0
void ClientProfileManager::saveClientProfiles() {
	try {
		SimpleXML xml;
		xml.addTag("Profiles");
		xml.stepIn();

		xml.addTag("ClientProfilesV2");
		xml.stepIn();
		for(ClientProfile::List::const_iterator l = clientProfiles.begin(); l != clientProfiles.end(); ++l) {
			xml.addTag("ClientProfile");
			xml.stepIn();
			xml.addTag("Name", l->getName());
			xml.addTag("Version", l->getVersion());
			xml.addTag("Tag", l->getTag());
			xml.addTag("ExtendedTag", l->getExtendedTag());
			xml.addTag("Lock", l->getLock());
			xml.addTag("Pk", l->getPk());
			xml.addTag("Supports", l->getSupports());
			xml.addTag("TestSUR", l->getTestSUR());
			xml.addTag("UserConCom", l->getUserConCom());
			xml.addTag("Status", l->getStatus());
			xml.addTag("CheatingDescription", l->getCheatingDescription());
			xml.addTag("RawToSend", Util::toString(l->getRawToSend()));
			//xml.addTag("TagVersion", Util::toString(l->getTagVersion()));
			xml.addTag("UseExtraVersion", Util::toString(l->getUseExtraVersion()));
			xml.addTag("CheckMismatch", Util::toString(l->getCheckMismatch()));
			xml.addTag("Connection", l->getConnection());
			xml.addTag("Comment", l->getComment());
			xml.addTag("Recheck", l->getRecheck());
			xml.addTag("SkipExtended", l->getSkipExtended());
			xml.stepOut();
		}
		xml.stepOut();

		xml.addTag("Params");
		xml.stepIn();
		for(StringMap::iterator m = params.begin(); m != params.end(); ++m) {
			xml.addTag("Param");
			xml.addChildAttrib("Name", m->first);
			xml.addChildAttrib("RegExp", m->second);
		}
		xml.stepOut();

		xml.stepOut();

		string fname = Util::getConfigPath() + "Profiles.xml";

		File f(fname + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE);
		f.write(SimpleXML::utf8Header);
		f.write(xml.toXML());
		f.close();
		File::deleteFile(fname);
		File::renameFile(fname + ".tmp", fname);

	} catch(const Exception& e) {
		dcdebug("FavoriteManager::saveClientProfiles: %s\n", e.getError().c_str());
	}
}
Esempio n. 4
0
void SettingsManager::save(string const& aFileName) {

	SimpleXML xml;
	xml.addTag("DCPlusPlus");
	xml.stepIn();
	xml.addTag("Settings");
	xml.stepIn();

	int i;
	string type("type"), curType("string");
	
	for(i=STR_FIRST; i<STR_LAST; i++)
	{
		if (i == INCOMING_CONNECTIONS) continue;
		if(i == CONFIG_VERSION) {
			xml.addTag(settingTags[i], m_version);
			xml.addChildAttrib(type, curType);
		} else if(isSet[i]) {
			xml.addTag(settingTags[i], get(StrSetting(i), false));
			xml.addChildAttrib(type, curType);
		}
	}

	curType = "int";
	for(i=INT_FIRST; i<INT_LAST; i++)
	{
		if(isSet[i]) {
			xml.addTag(settingTags[i], get(IntSetting(i), false));
			xml.addChildAttrib(type, curType);
		}
	}
	curType = "int64";
	for(i=INT64_FIRST; i<INT64_LAST; i++)
	{
		if(isSet[i])
		{
			xml.addTag(settingTags[i], get(Int64Setting(i), false));
			xml.addChildAttrib(type, curType);
		}
	}
	xml.stepOut();
	
	fire(SettingsManagerListener::Save(), xml);

	try {
		File out(aFileName + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE);
		BufferedOutputStream<false> f(&out);
		f.write(SimpleXML::utf8Header);
		xml.toXML(&f);
		f.flush();
		out.close();
		File::deleteFile(aFileName);
		File::renameFile(aFileName + ".tmp", aFileName);
	} catch(const FileException&) {
		// ...
	}
}
Esempio n. 5
0
void ADLSearchManager::save() const
{
	// Prepare xml string for saving
	try
	{
		SimpleXML xml;
		
		xml.addTag("ADLSearch");
		xml.stepIn();
		
		// Predicted several groups of searches to be differentiated
		// in multiple categories. Not implemented yet.
		xml.addTag("SearchGroup");
		xml.stepIn();
		
		// Save all searches
		for (auto i = collection.cbegin(); i != collection.cend(); ++i)
		{
			const ADLSearch& search = *i;
			if (search.searchString.empty())
			{
				continue;
			}
			xml.addTag("Search");
			xml.stepIn();
			
			xml.addTag("SearchString", search.searchString);
			xml.addTag("SourceType", search.SourceTypeToString(search.sourceType));
			xml.addTag("DestDirectory", search.destDir);
			xml.addTag("IsActive", search.isActive);
			xml.addTag("IsForbidden", search.isForbidden);
			xml.addTag("Raw", search.raw);
			xml.addTag("MaxSize", search.maxFileSize);
			xml.addTag("MinSize", search.minFileSize);
			xml.addTag("SizeType", search.SizeTypeToString(search.typeFileSize));
			xml.addTag("IsAutoQueue", search.isAutoQueue);
			xml.stepOut();
		}
		
		xml.stepOut();
		
		xml.stepOut();
		
		// Save string to file
		try
		{
			File fout(getConfigFile(), File::WRITE, File::CREATE | File::TRUNCATE);
			fout.write(SimpleXML::utf8Header);
			fout.write(xml.toXML());
			fout.close();
		}
		catch (const FileException&) {   }
	}
	catch (const SimpleXMLException&) { }
}
void IpManager::WatchSave() {
	Lock l(cs);
	try {
		SimpleXML xml;

		xml.addTag("IPWatch");
		xml.stepIn();
		{
			xml.addTag("IPWatch");
			xml.stepIn();
			{
				for(IPWatch::Iter i = ipwatch.begin(); i != ipwatch.end(); ++i) {
					xml.addTag("IPWatch");
					xml.addChildAttrib("Mode", (*i)->getMode());
					xml.addChildAttrib("Pattern", (*i)->getPattern());
					xml.addChildAttrib("Task", (*i)->getTask());
					xml.addChildAttrib("Action", (*i)->getAction());
					xml.addChildAttrib("DisplayCheat", (*i)->getDisplayCheat());
					xml.addChildAttrib("Cheat", (*i)->getCheat());
					xml.addChildAttrib("MatchType", (*i)->getMatchType());
					xml.addChildAttrib("ISP", (*i)->getIsp());
				}
			}
			xml.stepOut();
			xml.addTag("RevisionInfo");
			xml.stepIn();
			{
				xml.addTag("Version", getIpWatchVersion());
			}
			xml.stepOut();
		}
		xml.stepOut();

		string fname = Util::getPath(Util::PATH_USER_CONFIG) + "IPWatch.xml";
		File f(fname + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE);
		f.write(SimpleXML::utf8Header);
		f.write(xml.toXML());
		f.close();
		File::deleteFile(fname);
		File::renameFile(fname + ".tmp", fname);
	} catch(const Exception& e) {
		dcdebug("IpManager::WatchSave: %s\n", e.getError().c_str());
	}
}
void RawManager::saveActionRaws() {
	try {
		SimpleXML xml;
		xml.addTag("ActionRaws");
		xml.stepIn();

		for(Action::ActionList::const_iterator i = actions.begin(); i != actions.end(); ++i) {
			xml.addTag("Action");
			xml.addChildAttrib("ID", Util::toString((*i)->getId()));
			xml.addChildAttrib("Name", (*i)->getName());
			xml.addChildAttrib("Enabled", Util::toString((*i)->getEnabled()));
			xml.stepIn();
			for(Action::RawsList::const_iterator j = (*i)->raw.begin(); j != (*i)->raw.end(); ++j) {
				xml.addTag("Raw");
				xml.addChildAttrib("ID", Util::toString(j->getId()));
				xml.addChildAttrib("Name", j->getName());
				xml.addChildAttrib("Raw", j->getRaw());
				xml.addChildAttrib("Time", Util::toString(j->getTime()));
				xml.addChildAttrib("Enabled", Util::toString(j->getEnabled()));
				xml.addChildAttrib("UseLua", Util::toString(j->getLua()));
			}
			xml.stepOut();
		}
		xml.stepOut();

		string fname = Util::getPath(Util::PATH_USER_CONFIG) + "Raws.xml";

		File f(fname + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE);
		f.write(SimpleXML::utf8Header);
		f.write(xml.toXML());
		f.close();
		File::deleteFile(fname);
		File::renameFile(fname + ".tmp", fname);

	} catch(const Exception& e) {
		dcdebug("RawManager::saveActionRaws: %s\n", e.getError().c_str());
	}
}
Esempio n. 8
0
int __cdecl main(int argc, char* argv[])
{
	if(argc < 3) {
		return 0;
	}
	
	try {
		string tmp;
		File src(argv[1], File::READ, File::OPEN, false);
		File tgt(argv[2], File::WRITE, File::CREATE | File::TRUNCATE, false);
		File example(argv[3], File::WRITE, File::CREATE | File::TRUNCATE, false);
		string x = src.read();
		x = Text::acpToUtf8(x);
		string::size_type k;
		
		while((k = x.find('\r')) != string::npos) {
			x.erase(k, 1);
		}

		StringList l = StringTokenizer<string>(x, '\n').getTokens();

		StringIter i;
		string varStr;
		string varName;
		string start;

		SimpleXML ex;

		for(i = l.begin(); i != l.end(); ) {
			if( (k = i->find("// @Strings: ")) != string::npos) {
				varStr = i->substr(k + 13);
				i = l.erase(i);
			} else if( (k = i->find("// @Names: ")) != string::npos) {
				varName = i->substr(k + 11);
				i = l.erase(i);
			} else if(i->find("// @DontAdd") != string::npos) {
				i = l.erase(i);
			} else if( (k = i->find("// @Prolog: ")) != string::npos) {
				start += i->substr(k + 12) + "\r\n";
				i = l.erase(i);
			} else if(i->size() < 5) {
				i = l.erase(i);
			} else {
				++i;
			}
		}

		if(varStr.empty() || varName.empty()) {
			printf("No @Strings or @Names\n");
			return 0;
		}
		
		varStr += " = {\r\n";
		varName += " = {\r\n";
/*		
		ex.addTag("Language");
		ex.addChildAttrib("Name", string("Example Language"));
		ex.addChildAttrib("Author", string("FlylinkDC++ Development Team"));
		//ex.addChildAttrib("Version", string(A_VERSIONSTRING));
		ex.addChildAttrib("Revision", string("1"));
		ex.stepIn();
*/
		ex.addTag("resources");
		ex.stepIn();
		string name;
		string def;
		string xmldef;
		string s;
		for(i = l.begin(); i != l.end(); i++) {

			name.clear();
			s = *i;

			bool u = true;
			for(k = s.find_first_not_of(" \t"); s[k] != ','; k++) {
				if(s[k] == '_') {
					u = true;
				} else if(u) {
					name+=s[k];
					u = false;
				} else {
					name+=(char)tolower(s[k]);
				}
			}

			k = s.find("// ");
			def = s.substr(k + 3);
			xmldef = def.substr(1, def.size() - 2);
/*			while( (k = xmldef.find("\\t")) != string::npos) {
				xmldef.replace(k, 2, "\t");
			}
			while( (k = xmldef.find("\\r")) != string::npos) {
				xmldef.replace(k, 2, "\r");
			}
			while( (k = xmldef.find("\\n")) != string::npos) {
				xmldef.replace(k, 2, "\n");
			}

			while( (k = xmldef.find("\\\\")) != string::npos) {
				xmldef.replace(k, 2, "\\");
			}
			*/
			ex.addTag("string", xmldef);
			ex.addChildAttrib("name", name);

			varStr += def + ", \r\n";
			varName += '\"' + name + "\", \r\n";

		}

		varStr.erase(varStr.size()-2, 2);
		varName.erase(varName.size()-2, 2);

		varStr += "\r\n};\r\n";
		varName += "\r\n};\r\n";

		tgt.write(start);
		tgt.write(varStr);
		tgt.write(varName);

		example.write(SimpleXML::utf8Header);
		example.write(ex.toXML());
	} catch(const Exception& e) {
		printf("%s\n", e.getError().c_str());
	}

	return 0;
}
LRESULT PropPageTextStyles::onExport(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	tstring x = _T("");	
	if(WinUtil::browseFile(x, m_hWnd, true, x, types, defExt) == IDOK) {
		SimpleXML xml;
		xml.addTag("DCPlusPlus");
		xml.stepIn();
		xml.addTag("Settings");
		xml.stepIn();

		string type("type"), curType("string");
		exportData("Font", TEXT_FONT);

		curType = "int";
		exportData("BackgroundColor", BACKGROUND_COLOR);
		exportData("TextColor", TEXT_COLOR);
		exportData("DownloadBarColor", DOWNLOAD_BAR_COLOR);
		exportData("UploadBarColor", UPLOAD_BAR_COLOR);
		exportData("TextGeneralBackColor", TEXT_GENERAL_BACK_COLOR);
		exportData("TextGeneralForeColor", TEXT_GENERAL_FORE_COLOR);
		exportData("TextGeneralBold", TEXT_GENERAL_BOLD);
		exportData("TextGeneralItalic", TEXT_GENERAL_ITALIC);
		exportData("TextMyOwnBackColor", TEXT_MYOWN_BACK_COLOR);
		exportData("TextMyOwnForeColor", TEXT_MYOWN_FORE_COLOR);
		exportData("TextMyOwnBold", TEXT_MYOWN_BOLD);
		exportData("TextMyOwnItalic", TEXT_MYOWN_ITALIC);
		exportData("TextPrivateBackColor", TEXT_PRIVATE_BACK_COLOR);
		exportData("TextPrivateForeColor", TEXT_PRIVATE_FORE_COLOR);
		exportData("TextPrivateBold", TEXT_PRIVATE_BOLD);
		exportData("TextPrivateItalic", TEXT_PRIVATE_ITALIC);
		exportData("TextSystemBackColor", TEXT_SYSTEM_BACK_COLOR);
		exportData("TextSystemForeColor", TEXT_SYSTEM_FORE_COLOR);
		exportData("TextSystemBold", TEXT_SYSTEM_BOLD);
		exportData("TextSystemItalic", TEXT_SYSTEM_ITALIC);
		exportData("TextServerBackColor", TEXT_SERVER_BACK_COLOR);
		exportData("TextServerForeColor", TEXT_SERVER_FORE_COLOR);
		exportData("TextServerBold", TEXT_SERVER_BOLD);
		exportData("TextServerItalic", TEXT_SERVER_ITALIC);
		exportData("TextTimestampBackColor", TEXT_TIMESTAMP_BACK_COLOR);
		exportData("TextTimestampForeColor", TEXT_TIMESTAMP_FORE_COLOR);
		exportData("TextTimestampBold", TEXT_TIMESTAMP_BOLD);
		exportData("TextTimestampItalic", TEXT_TIMESTAMP_ITALIC);
		exportData("TextMyNickBackColor", TEXT_MYNICK_BACK_COLOR);
		exportData("TextMyNickForeColor", TEXT_MYNICK_FORE_COLOR);
		exportData("TextMyNickBold", TEXT_MYNICK_BOLD);
		exportData("TextMyNickItalic", TEXT_MYNICK_ITALIC);
		exportData("TextFavBackColor", TEXT_FAV_BACK_COLOR);
		exportData("TextFavForeColor", TEXT_FAV_FORE_COLOR);
		exportData("TextFavBold", TEXT_FAV_BOLD);
		exportData("TextFavItalic", TEXT_FAV_ITALIC);
		exportData("TextURLBackColor", TEXT_URL_BACK_COLOR);
		exportData("TextURLForeColor", TEXT_URL_FORE_COLOR);
		exportData("TextURLBold", TEXT_URL_BOLD);
		exportData("TextURLItalic", TEXT_URL_ITALIC);
		exportData("ProgressTextDown", PROGRESS_TEXT_COLOR_DOWN);
		exportData("ProgressTextUp", PROGRESS_TEXT_COLOR_UP);
		exportData("ErrorColor", ERROR_COLOR);
		exportData("ProgressOverrideColors", PROGRESS_OVERRIDE_COLORS);
		exportData("MenubarTwoColors", MENUBAR_TWO_COLORS);
		exportData("MenubarLeftColor", MENUBAR_LEFT_COLOR);
		exportData("MenubarRightColor", MENUBAR_RIGHT_COLOR);
		exportData("MenubarBumped", MENUBAR_BUMPED);
		exportData("Progress3DDepth", PROGRESS_3DDEPTH);
		exportData("ProgressOverrideColors2", PROGRESS_OVERRIDE_COLORS2);
		exportData("TextOPBackColor", TEXT_OP_BACK_COLOR);
		exportData("TextOPForeColor", TEXT_OP_FORE_COLOR);
		exportData("TextOPBold", TEXT_OP_BOLD);
		exportData("TextOPItalic", TEXT_OP_ITALIC);
		exportData("TextNormBackColor", TEXT_NORM_BACK_COLOR);
		exportData("TextNormForeColor", TEXT_NORM_FORE_COLOR);
		exportData("TextNormBold", TEXT_NORM_BOLD);
		exportData("TextNormItalic", TEXT_NORM_ITALIC);
		exportData("SearchAlternateColour", SEARCH_ALTERNATE_COLOUR);
		exportData("ProgressBackColor", PROGRESS_BACK_COLOR);
		exportData("ProgressCompressColor", PROGRESS_COMPRESS_COLOR);
		exportData("ProgressSegmentColor", PROGRESS_SEGMENT_COLOR);
		exportData("ColorDone", COLOR_DONE);
		exportData("ColorDownloaded", COLOR_DOWNLOADED);
		exportData("ColorRunning", COLOR_RUNNING);
		exportData("ReservedSlotColor", RESERVED_SLOT_COLOR);
		exportData("IgnoredColor", IGNORED_COLOR);
		exportData("FavoriteColor", FAVORITE_COLOR);
		exportData("NormalColour", NORMAL_COLOUR);
		exportData("PasiveColor", PASIVE_COLOR);
		exportData("OpColor", OP_COLOR);
		exportData("ProgressbaroDCStyle", PROGRESSBAR_ODC_STYLE);
		exportData("UnderlineLinks", UNDERLINE_LINKS);
		exportData("UnderlineDupes", UNDERLINE_DUPES);
		exportData("TextDupeBackColor", TEXT_DUPE_BACK_COLOR);
		exportData("TextDupeColor", DUPE_COLOR);
		exportData("TextDupeBold", TEXT_DUPE_BOLD);
		exportData("TextDupeItalic", TEXT_DUPE_ITALIC);
		exportData("TextQueueBackColor", TEXT_QUEUE_BACK_COLOR);
		exportData("QueueColor", QUEUE_COLOR);
		exportData("TextQueueBold", TEXT_QUEUE_BOLD);
		exportData("TextQueueItalic", TEXT_QUEUE_ITALIC);
		exportData("UnderlineQueue", UNDERLINE_QUEUE);
		//tabs
		exportData("tabactivebg", TAB_ACTIVE_BG);
		exportData("TabActiveText", TAB_ACTIVE_TEXT);
		exportData("TabActiveBorder", TAB_ACTIVE_BORDER);
		exportData("TabInactiveBg", TAB_INACTIVE_BG);
		exportData("TabInactiveBgDisconnected", TAB_INACTIVE_BG_DISCONNECTED);
		exportData("TabInactiveText", TAB_INACTIVE_TEXT);
		exportData("TabInactiveBorder", TAB_INACTIVE_BORDER);
		exportData("TabInactiveBgNotify", TAB_INACTIVE_BG_NOTIFY);
		exportData("TabDirtyBlend", TAB_DIRTY_BLEND);
		exportData("BlendTabs", BLEND_TABS);
		exportData("TabSize", TAB_SIZE);
	
		xml.stepOut();
		
		if(!HighlightManager::getInstance()->emptyList())
			HighlightManager::getInstance()->save(xml);
		/*
		Don't export icon stuff, user might have absolute path for toolbars. Icon packs can be included by editing the .dctheme example.
		curType = "string";
		string empty = "";
		xml.addTag("Icons");
		xml.stepIn();
		exportData("IconPath", ICON_PATH);
		xml.addTag("ToolbarImage", empty);
		xml.addChildAttrib(curType, curType);
		xml.addTag("ToolbarHot", empty);
		xml.addChildAttrib(type, curType);
		xml.stepOut();
		*/

		try {
			File ff(Text::fromT(x) , File::WRITE, File::CREATE | File::TRUNCATE);
			BufferedOutputStream<false> f(&ff);
			f.write(SimpleXML::utf8Header);
			xml.toXML(&f);
			f.flush();
			ff.close();
		} catch(const FileException&) {
			// ...
		}
	}
	return 0;
}
Esempio n. 10
0
///////////////////////////////////////////////////////////////////////////////
//
//	Save current searches to disk
//
///////////////////////////////////////////////////////////////////////////////
void ADLSearchManager::Save()
{
	// Prepare xml string for saving
	try {
		SimpleXML xml;

		xml.addTag("ADLSearch");
		xml.stepIn();

		// Predicted several groups of searches to be differentiated
		// in multiple categories. Not implemented yet.
		xml.addTag("SearchGroup");
		xml.stepIn();

		// Save all	searches
		for(SearchCollection::iterator i = collection.begin(); i != collection.end(); ++i) {
			ADLSearch& search = *i;
			if(search.searchString.size() == 0) {
				continue;
			}
			string type = "type";
			xml.addTag("Search");
			xml.stepIn();

			xml.addTag("SearchString", search.searchString);
			xml.addChildAttrib(type, string("string"));

			xml.addTag("SourceType", search.SourceTypeToString(search.sourceType));
			xml.addChildAttrib(type, string("string"));

			xml.addTag("DestDirectory", search.destDir);
			xml.addChildAttrib(type, string("string"));

			xml.addTag("IsActive", search.isActive);
			xml.addChildAttrib(type, string("int"));

			xml.addTag("MaxSize", search.maxFileSize);
			xml.addChildAttrib(type, string("int64"));

			xml.addTag("MinSize", search.minFileSize);
			xml.addChildAttrib(type, string("int64"));

			xml.addTag("SizeType", search.SizeTypeToString(search.typeFileSize));
			xml.addChildAttrib(type, string("string"));

			xml.addTag("IsAutoQueue", search.isAutoQueue);
			xml.addChildAttrib(type, string("int"));

			xml.stepOut();
		}

		xml.stepOut();

		xml.stepOut();

		// Save string to file
		try {
			File fout(getConfigFile(), File::WRITE, File::CREATE | File::TRUNCATE);
			fout.write(SimpleXML::utf8Header);
			fout.write(xml.toXML());
			fout.close();
		} catch(const FileException&) {
			return;
		}
	} catch(const SimpleXMLException&) {
		return;
	}
}
void SettingsManager::save(string const& aFileName) {

    SimpleXML xml;
    xml.addTag("DCPlusPlus");
    xml.stepIn();
    xml.addTag("Settings");
    xml.stepIn();

    int i;
    string type("type"), curType("string");

    for(i=STR_FIRST; i<STR_LAST; i++)
    {
        if(i == CONFIG_VERSION) {
            xml.addTag(settingTags[i], VERSIONSTRING);
            xml.addChildAttrib(type, curType);
        } else if(isSet[i]) {
            xml.addTag(settingTags[i], get(StrSetting(i), false));
            xml.addChildAttrib(type, curType);
        }
    }

    curType = "int";
    for(i=INT_FIRST; i<INT_LAST; i++)
    {
        if(isSet[i]) {
            xml.addTag(settingTags[i], get(IntSetting(i), false));
            xml.addChildAttrib(type, curType);
        }
    }
    for(i=FLOAT_FIRST; i<FLOAT_LAST; i++)
    {
        if(isSet[i]) {
            xml.addTag(settingTags[i], static_cast<int>(get(FloatSetting(i), false) * 1000.));
            xml.addChildAttrib(type, curType);
        }
    }
    curType = "int64";
    for(i=INT64_FIRST; i<INT64_LAST; i++)
    {
        if(isSet[i])
        {
            xml.addTag(settingTags[i], get(Int64Setting(i), false));
            xml.addChildAttrib(type, curType);
        }
    }
    xml.stepOut();

    xml.addTag("SearchTypes");
    xml.stepIn();
    for(SearchTypesIterC i = searchTypes.begin(); i != searchTypes.end(); ++i) {
        xml.addTag("SearchType", Util::toString(";", i->second));
        xml.addChildAttrib("Id", i->first);
    }
    xml.stepOut();

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

    try {
        File out(aFileName + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE);
        BufferedOutputStream<false> f(&out);
        f.write(SimpleXML::utf8Header);
        xml.toXML(&f);
        f.flush();
        out.close();
        File::deleteFile(aFileName);
        File::renameFile(aFileName + ".tmp", aFileName);
    } catch(const FileException&) {
        // ...
    }
}
Esempio n. 12
0
LRESULT PropPageTextStyles::onExport(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	tstring x = _T("");	
	if(WinUtil::browseFile(x, m_hWnd, true, x, types, defExt) == IDOK) {
	SimpleXML xml;
	xml.addTag("DCPlusPlus");
	xml.stepIn();
	xml.addTag("Settings");
	xml.stepIn();

	string type("type"), curType("string");
	exportData("Font", TEXT_FONT);

	curType = "int";
	exportData("BackgroundColor", BACKGROUND_COLOR);
	exportData("TextColor", TEXT_COLOR);
	exportData("DownloadBarColor", DOWNLOAD_BAR_COLOR);
	exportData("UploadBarColor", UPLOAD_BAR_COLOR);
	exportData("TextGeneralBackColor", TEXT_GENERAL_BACK_COLOR);
	exportData("TextGeneralForeColor", TEXT_GENERAL_FORE_COLOR);
	exportData("TextGeneralBold", TEXT_GENERAL_BOLD);
	exportData("TextGeneralItalic", TEXT_GENERAL_ITALIC);
	exportData("TextMyOwnBackColor", TEXT_MYOWN_BACK_COLOR);
	exportData("TextMyOwnForeColor", TEXT_MYOWN_FORE_COLOR);
	exportData("TextMyOwnBold", TEXT_MYOWN_BOLD);
	exportData("TextMyOwnItalic", TEXT_MYOWN_ITALIC);
	exportData("TextPrivateBackColor", TEXT_PRIVATE_BACK_COLOR);
	exportData("TextPrivateForeColor", TEXT_PRIVATE_FORE_COLOR);
	exportData("TextPrivateBold", TEXT_PRIVATE_BOLD);
	exportData("TextPrivateItalic", TEXT_PRIVATE_ITALIC);
	exportData("TextSystemBackColor", TEXT_SYSTEM_BACK_COLOR);
	exportData("TextSystemForeColor", TEXT_SYSTEM_FORE_COLOR);
	exportData("TextSystemBold", TEXT_SYSTEM_BOLD);
	exportData("TextSystemItalic", TEXT_SYSTEM_ITALIC);
	exportData("TextServerBackColor", TEXT_SERVER_BACK_COLOR);
	exportData("TextServerForeColor", TEXT_SERVER_FORE_COLOR);
	exportData("TextServerBold", TEXT_SERVER_BOLD);
	exportData("TextServerItalic", TEXT_SERVER_ITALIC);
	exportData("TextTimestampBackColor", TEXT_TIMESTAMP_BACK_COLOR);
	exportData("TextTimestampForeColor", TEXT_TIMESTAMP_FORE_COLOR);
	exportData("TextTimestampBold", TEXT_TIMESTAMP_BOLD);
	exportData("TextTimestampItalic", TEXT_TIMESTAMP_ITALIC);
	exportData("TextMyNickBackColor", TEXT_MYNICK_BACK_COLOR);
	exportData("TextMyNickForeColor", TEXT_MYNICK_FORE_COLOR);
	exportData("TextMyNickBold", TEXT_MYNICK_BOLD);
	exportData("TextMyNickItalic", TEXT_MYNICK_ITALIC);
	exportData("TextFavBackColor", TEXT_FAV_BACK_COLOR);
	exportData("TextFavForeColor", TEXT_FAV_FORE_COLOR);
	exportData("TextFavBold", TEXT_FAV_BOLD);
	exportData("TextFavItalic", TEXT_FAV_ITALIC);
	exportData("TextURLBackColor", TEXT_URL_BACK_COLOR);
	exportData("TextURLForeColor", TEXT_URL_FORE_COLOR);
	exportData("TextURLBold", TEXT_URL_BOLD);
	exportData("TextURLItalic", TEXT_URL_ITALIC);
	exportData("BoldAuthorsMess", BOLD_AUTHOR_MESS);
	exportData("ProgressTextDown", PROGRESS_TEXT_COLOR_DOWN);
	exportData("ProgressTextUp", PROGRESS_TEXT_COLOR_UP);
	exportData("ErrorColor", ERROR_COLOR);
	exportData("ProgressOverrideColors", PROGRESS_OVERRIDE_COLORS);
	exportData("MenubarTwoColors", MENUBAR_TWO_COLORS);
	exportData("MenubarLeftColor", MENUBAR_LEFT_COLOR);
	exportData("MenubarRightColor", MENUBAR_RIGHT_COLOR);
	exportData("MenubarBumped", MENUBAR_BUMPED);
	exportData("Progress3DDepth", PROGRESS_3DDEPTH);
	exportData("ProgressOverrideColors2", PROGRESS_OVERRIDE_COLORS2);
	exportData("TextOPBackColor", TEXT_OP_BACK_COLOR);
	exportData("TextOPForeColor", TEXT_OP_FORE_COLOR);
	exportData("TextOPBold", TEXT_OP_BOLD);
	exportData("TextOPItalic", TEXT_OP_ITALIC);
	exportData("SearchAlternateColour", SEARCH_ALTERNATE_COLOUR);
	exportData("ProgressBackColor", PROGRESS_BACK_COLOR);
	exportData("ProgressCompressColor", PROGRESS_COMPRESS_COLOR);
	exportData("ProgressSegmentColor", PROGRESS_SEGMENT_COLOR);
	exportData("ColorDone", COLOR_DONE);
	exportData("ColorDownloaded", COLOR_DOWNLOADED);
	exportData("ColorRunning", COLOR_RUNNING);
	exportData("IgnoredColor", IGNORED_COLOR);
	exportData("FavoriteColor", FAVORITE_COLOR);
	exportData("NormalColour", NORMAL_COLOUR);
	exportData("PasiveColor", PASIVE_COLOR);
	exportData("OpColor", OP_COLOR);
	exportData("ProgressbaroDCStyle", PROGRESSBAR_ODC_STYLE);
	
	try {
		File ff(Text::fromT(x) , File::WRITE, File::CREATE | File::TRUNCATE);
		BufferedOutputStream<false> f(&ff);
		f.write(SimpleXML::utf8Header);
		xml.toXML(&f);
		f.flush();
		ff.close();
	} catch(const FileException&) {
		// ...
	}

	}
	return 0;
}