1 #include "../../include/freenet/identityxml.h"
\r
7 IdentityXML::IdentityXML()
\r
12 std::string IdentityXML::GetXML()
\r
14 Poco::AutoPtr<Poco::XML::Document> doc=new Poco::XML::Document;
\r
15 Poco::AutoPtr<Poco::XML::Element> root=doc->createElement("Identity");
\r
17 doc->appendChild(root);
\r
19 root->appendChild(XMLCreateCDATAElement(doc,"Name",m_name));
\r
21 root->appendChild(XMLCreateBooleanElement(doc,"SingleUse",m_singleuse));
\r
23 root->appendChild(XMLCreateBooleanElement(doc,"PublishTrustList",m_publishtrustlist));
\r
25 root->appendChild(XMLCreateBooleanElement(doc,"PublishBoardList",m_publishboardlist));
\r
27 // freesite edition will be -1 if identity isn't publishing a freesite
\r
28 if(m_freesiteedition>=0)
\r
30 root->appendChild(XMLCreateTextElement(doc,"FreesiteEdition",m_freesiteedition));
\r
33 return GenerateXML(doc);
\r
36 void IdentityXML::Initialize()
\r
39 m_publishtrustlist=false;
\r
40 m_publishboardlist=false;
\r
42 m_freesiteedition=-1;
\r
45 const bool IdentityXML::ParseXML(const std::string &xml)
\r
49 Poco::XML::DOMParser dp;
\r
55 Poco::AutoPtr<Poco::XML::Document> doc=dp.parseString(FixCDATA(xml));
\r
56 Poco::XML::Element *root=XMLGetFirstChild(doc,"Identity");
\r
57 Poco::XML::Element *txt=NULL;
\r
59 txt=XMLGetFirstChild(root,"Name");
\r
62 if(txt->firstChild())
\r
64 m_name=txt->firstChild()->getNodeValue();
\r
65 if(m_name.size()>40)
\r
72 m_singleuse=XMLGetBooleanElement(root,"SingleUse");
\r
73 m_publishtrustlist=XMLGetBooleanElement(root,"PublishTrustList");
\r
74 m_publishboardlist=XMLGetBooleanElement(root,"PublishBoardList");
\r
76 txt=XMLGetFirstChild(root,"FreesiteEdition");
\r
79 if(txt->firstChild())
\r
81 std::string editionstr=txt->firstChild()->getNodeValue();
\r
82 StringFunctions::Convert(editionstr,m_freesiteedition);
\r