X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffreenet%2Fidentityxml.cpp;h=a44057368ff3a4728ee4dc7a42e7dca56ddcdaa8;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hp=4b0fa237dbd58adc16dbe5310c51be11005e2bb3;hpb=9b22dd53fe62e312c1647310b7ec43aa127090af;p=fms.git diff --git a/src/freenet/identityxml.cpp b/src/freenet/identityxml.cpp index 4b0fa23..a440573 100644 --- a/src/freenet/identityxml.cpp +++ b/src/freenet/identityxml.cpp @@ -11,32 +11,41 @@ IdentityXML::IdentityXML() std::string IdentityXML::GetXML() { - TiXmlDocument td; - TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8",""); - TiXmlElement *tid; - TiXmlPrinter tp; + Poco::AutoPtr doc=new Poco::XML::Document; + //TiXmlDocument td; + //TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8",""); + Poco::XML::Element *root=doc->createElement("Identity"); + //TiXmlElement *tid; + //TiXmlPrinter tp; - td.LinkEndChild(tdec); - tid=new TiXmlElement("Identity"); - td.LinkEndChild(tid); + doc->appendChild(root); + //td.LinkEndChild(tdec); + //tid=new TiXmlElement("Identity"); + //td.LinkEndChild(tid); - tid->LinkEndChild(XMLCreateCDATAElement("Name",m_name)); + root->appendChild(XMLCreateCDATAElement(doc,"Name",m_name)); + //tid->LinkEndChild(XMLCreateCDATAElement("Name",m_name)); - tid->LinkEndChild(XMLCreateBooleanElement("SingleUse",m_singleuse)); + root->appendChild(XMLCreateBooleanElement(doc,"SingleUse",m_singleuse)); + //tid->LinkEndChild(XMLCreateBooleanElement("SingleUse",m_singleuse)); - tid->LinkEndChild(XMLCreateBooleanElement("PublishTrustList",m_publishtrustlist)); + root->appendChild(XMLCreateBooleanElement(doc,"PublishTrustList",m_publishtrustlist)); + //tid->LinkEndChild(XMLCreateBooleanElement("PublishTrustList",m_publishtrustlist)); - tid->LinkEndChild(XMLCreateBooleanElement("PublishBoardList",m_publishboardlist)); + root->appendChild(XMLCreateBooleanElement(doc,"PublishBoardList",m_publishboardlist)); + //tid->LinkEndChild(XMLCreateBooleanElement("PublishBoardList",m_publishboardlist)); // freesite edition will be -1 if identity isn't publishing a freesite if(m_freesiteedition>=0) { - tid->LinkEndChild(XMLCreateTextElement("FreesiteEdition",m_freesiteedition)); + root->appendChild(XMLCreateTextElement(doc,"FreesiteEdition",m_freesiteedition)); + //tid->LinkEndChild(XMLCreateTextElement("FreesiteEdition",m_freesiteedition)); } - td.Accept(&tp); - return std::string(tp.CStr()); + //td.Accept(&tp); + //return std::string(tp.CStr()); + return GenerateXML(doc); } void IdentityXML::Initialize() @@ -50,6 +59,55 @@ void IdentityXML::Initialize() const bool IdentityXML::ParseXML(const std::string &xml) { + + bool parsed=false; + Poco::XML::DOMParser dp; + + Initialize(); + + try + { + Poco::AutoPtr doc=dp.parseString(FixCDATA(xml)); + Poco::XML::Element *root=XMLGetFirstChild(doc,"Identity"); + Poco::XML::Element *txt=NULL; + + txt=XMLGetFirstChild(root,"Name"); + if(txt) + { + if(txt->firstChild()) + { + m_name=txt->firstChild()->getNodeValue(); + if(m_name.size()>40) + { + m_name.erase(40); + } + } + } + + m_singleuse=XMLGetBooleanElement(root,"SingleUse"); + m_publishtrustlist=XMLGetBooleanElement(root,"PublishTrustList"); + m_publishboardlist=XMLGetBooleanElement(root,"PublishBoardList"); + + txt=XMLGetFirstChild(root,"FreesiteEdition"); + if(txt) + { + if(txt->firstChild()) + { + std::string editionstr=txt->firstChild()->getNodeValue(); + StringFunctions::Convert(editionstr,m_freesiteedition); + } + } + + parsed=true; + + } + catch(...) + { + } + + return parsed; + + /* TiXmlDocument td; td.Parse(xml.c_str()); @@ -91,5 +149,5 @@ const bool IdentityXML::ParseXML(const std::string &xml) { return false; } - +*/ }