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()); } }
void MessageManager::save(SimpleXML& aXml) { aXml.addTag("ChatFilterItems"); aXml.stepIn(); { RLock l(Ignorecs); for (const auto& i : ChatFilterItems) { aXml.addTag("ChatFilterItem"); aXml.addChildAttrib("Nick", i.getNickPattern()); aXml.addChildAttrib("NickMethod", i.getNickMethod()); aXml.addChildAttrib("Text", i.getTextPattern()); aXml.addChildAttrib("TextMethod", i.getTextMethod()); aXml.addChildAttrib("MC", i.matchMainchat); aXml.addChildAttrib("PM", i.matchPM); aXml.addChildAttrib("Enabled", i.getEnabled()); } } aXml.stepOut(); if (dirty) saveUsers(); }
void HighlightManager::save(SimpleXML& aXml){ aXml.addTag("Highlights"); aXml.stepIn(); for(const auto& hl: colorSettings) { aXml.addTag("Highlight"); aXml.addChildAttrib("Context", hl.getContext()); aXml.addChildAttrib("Match", Text::fromT(hl.getMatch())); aXml.addChildAttrib("Bold", hl.getBold()); aXml.addChildAttrib("Italic", hl.getItalic()); aXml.addChildAttrib("Underline", hl.getUnderline()); aXml.addChildAttrib("Strikeout", hl.getStrikeout()); aXml.addChildAttrib("CaseSensitive", hl.getCaseSensitive()); aXml.addChildAttrib("WholeLine", hl.getWholeLine()); aXml.addChildAttrib("WholeWord", hl.getWholeWord()); aXml.addChildAttrib("Popup", hl.getPopup()); aXml.addChildAttrib("Tab", hl.getTab()); aXml.addChildAttrib("PlaySound", hl.getPlaySound()); //aXml.addChildAttrib("LastLog", hl.getLog()); aXml.addChildAttrib("FlashWindow", hl.getFlashWindow() ); aXml.addChildAttrib("MatchType", hl.getMatchType()); aXml.addChildAttrib("HasFgColor", hl.getHasFgColor()); aXml.addChildAttrib("HasBgColor", hl.getHasBgColor()); aXml.addChildAttrib("FgColor", Util::toString(hl.getFgColor())); aXml.addChildAttrib("BgColor", Util::toString(hl.getBgColor())); aXml.addChildAttrib("SoundFile", hl.getSoundFile()); aXml.addChildAttrib("MatchColumn", hl.getMatchColumn()); }//end for aXml.stepOut(); }
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; }
void HighlightManager::save(SimpleXML& aXml) { aXml.addTag("Highlights"); aXml.stepIn(); ColorIter iter = colorSettings.begin(); for(; iter != colorSettings.end(); ++iter) { aXml.addTag("Highlight"); aXml.addChildAttrib("Match", Text::wideToUtf8((*iter).getMatch())); aXml.addChildAttrib("Bold", (*iter).getBold()); aXml.addChildAttrib("Italic", (*iter).getItalic()); aXml.addChildAttrib("Underline", (*iter).getUnderline()); aXml.addChildAttrib("Strikeout", (*iter).getStrikeout()); aXml.addChildAttrib("IncludeNickList", (*iter).getIncludeNickList()); aXml.addChildAttrib("CaseSensitive", (*iter).getCaseSensitive()); aXml.addChildAttrib("WholeLine", (*iter).getWholeLine()); aXml.addChildAttrib("WholeWord", (*iter).getWholeWord()); aXml.addChildAttrib("Popup", (*iter).getPopup()); aXml.addChildAttrib("Tab", (*iter).getTab()); aXml.addChildAttrib("PlaySound", (*iter).getPlaySound()); aXml.addChildAttrib("LastLog", (*iter).getLog()); aXml.addChildAttrib("FlashWindow", (*iter).getFlashWindow() ); aXml.addChildAttrib("MatchType", (*iter).getMatchType()); aXml.addChildAttrib("HasFgColor", (*iter).getHasFgColor()); aXml.addChildAttrib("HasBgColor", (*iter).getHasBgColor()); aXml.addChildAttrib("FgColor", Util::toString((*iter).getFgColor())); aXml.addChildAttrib("BgColor", Util::toString((*iter).getBgColor())); aXml.addChildAttrib("SoundFile", Text::wideToUtf8((*iter).getSoundFile())); }//end for aXml.stepOut(); }
/////////////////////////////////////////////////////////////////////////////// // // 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 AutoSearch::saveToXml(SimpleXML& xml) { xml.addTag("Autosearch"); xml.addChildAttrib("Enabled", getEnabled()); xml.addChildAttrib("SearchString", getSearchString()); xml.addChildAttrib("FileType", getFileType()); xml.addChildAttrib("Action", getAction()); xml.addChildAttrib("Remove", getRemove()); xml.addChildAttrib("Target", getTarget()); xml.addChildAttrib("TargetType", getTargetType()); xml.addChildAttrib("MatcherType", getMethod()), xml.addChildAttrib("MatcherString", getMatcherString()), xml.addChildAttrib("UserMatch", getNickPattern()); xml.addChildAttrib("ExpireTime", getExpireTime()); xml.addChildAttrib("CheckAlreadyQueued", getCheckAlreadyQueued()); xml.addChildAttrib("CheckAlreadyShared", getCheckAlreadyShared()); xml.addChildAttrib("SearchDays", searchDays.to_string()); xml.addChildAttrib("StartTime", startTime.toString()); xml.addChildAttrib("EndTime", endTime.toString()); xml.addChildAttrib("LastSearchTime", Util::toString(getLastSearch())); xml.addChildAttrib("MatchFullPath", getMatchFullPath()); xml.addChildAttrib("ExcludedWords", getExcludedString()); xml.addChildAttrib("SearchInterval", Util::toString(getSearchInterval())); xml.addChildAttrib("ItemType", Util::toString(getAsType())); xml.addChildAttrib("Token", Util::toString(getToken())); xml.addChildAttrib("TimeAdded", Util::toString(getTimeAdded())); xml.addChildAttrib("Group", getGroup()); xml.addChildAttrib("UserMatcherExclude", getUserMatcherExclude()); xml.stepIn(); xml.addTag("Params"); xml.addChildAttrib("Enabled", getUseParams()); xml.addChildAttrib("CurNumber", getCurNumber()); xml.addChildAttrib("MaxNumber", getMaxNumber()); xml.addChildAttrib("MinNumberLen", getNumberLen()); xml.addChildAttrib("LastIncFinish", getLastIncFinish()); if (!getFinishedPaths().empty()) { xml.addTag("FinishedPaths"); xml.stepIn(); for (auto& p : getFinishedPaths()) { xml.addTag("Path", p.first); xml.addChildAttrib("FinishTime", p.second); } xml.stepOut(); } if (!getBundles().empty()) { xml.addTag("Bundles"); xml.stepIn(); for (const auto& b : getBundles()) { xml.addTag("Bundle", Util::toString(b->getToken())); } xml.stepOut(); } xml.stepOut(); }
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&) { // ... } }