Initialize();\r
}\r
\r
-void IdentityExportXML::AddIdentity(const std::string &name, const std::string &publickey, const std::string &privatekey, const bool singleuse, const bool publishtrustlist, const bool publishboardlist)\r
+void IdentityExportXML::AddIdentity(const std::string &name, const std::string &publickey, const std::string &privatekey, const bool singleuse, const bool publishtrustlist, const bool publishboardlist, const bool publishfreesite)\r
{\r
- m_identities.push_back(identity(name,publickey,privatekey,singleuse,publishtrustlist,publishboardlist));\r
+ m_identities.push_back(identity(name,publickey,privatekey,singleuse,publishtrustlist,publishboardlist,publishfreesite));\r
}\r
\r
const std::string IdentityExportXML::GetName(const long index)\r
}\r
}\r
\r
+const bool IdentityExportXML::GetPublishFreesite(const long index)\r
+{\r
+ if(index>=0 && index<GetCount())\r
+ {\r
+ return m_identities[index].m_publishfreesite;\r
+ }\r
+ else\r
+ {\r
+ return false;\r
+ }\r
+}\r
+\r
const bool IdentityExportXML::GetPublishTrustList(const long index)\r
{\r
if(index>=0 && index<GetCount())\r
\r
std::string IdentityExportXML::GetXML()\r
{\r
- TiXmlDocument td;\r
- TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8","");\r
- TiXmlElement *tid;\r
- TiXmlPrinter tp;\r
+ Poco::AutoPtr<Poco::XML::Document> doc=new Poco::XML::Document;\r
+ Poco::AutoPtr<Poco::XML::Element> root=doc->createElement("IdentityExport");\r
+ Poco::AutoPtr<Poco::XML::Element> el=NULL;\r
\r
- td.LinkEndChild(tdec);\r
- tid=new TiXmlElement("IdentityExport");\r
- td.LinkEndChild(tid);\r
+ doc->appendChild(root);\r
\r
for(std::vector<identity>::iterator i=m_identities.begin(); i!=m_identities.end(); i++)\r
{\r
- TiXmlElement *tr=new TiXmlElement("Identity");\r
- tid->LinkEndChild(tr);\r
- tr->LinkEndChild(XMLCreateCDATAElement("Name",(*i).m_name));\r
- tr->LinkEndChild(XMLCreateTextElement("PublicKey",(*i).m_publickey));\r
- tr->LinkEndChild(XMLCreateTextElement("PrivateKey",(*i).m_privatekey));\r
- tr->LinkEndChild(XMLCreateBooleanElement("SingleUse",(*i).m_singleuse));\r
- tr->LinkEndChild(XMLCreateBooleanElement("PublishTrustList",(*i).m_publishtrustlist));\r
- tr->LinkEndChild(XMLCreateBooleanElement("PublishBoardList",(*i).m_publishboardlist));\r
+ el=doc->createElement("Identity");\r
+ root->appendChild(el);\r
+\r
+ el->appendChild(XMLCreateCDATAElement(doc,"Name",(*i).m_name));\r
+ el->appendChild(XMLCreateTextElement(doc,"PublicKey",(*i).m_publickey));\r
+ el->appendChild(XMLCreateTextElement(doc,"PrivateKey",(*i).m_privatekey));\r
+ el->appendChild(XMLCreateBooleanElement(doc,"SingleUse",(*i).m_singleuse));\r
+ el->appendChild(XMLCreateBooleanElement(doc,"PublishTrustList",(*i).m_publishtrustlist));\r
+ el->appendChild(XMLCreateBooleanElement(doc,"PublishBoardList",(*i).m_publishboardlist));\r
+ el->appendChild(XMLCreateBooleanElement(doc,"PublishFreesite",(*i).m_publishfreesite));\r
}\r
\r
- td.Accept(&tp);\r
- return std::string(tp.CStr());\r
+ return GenerateXML(doc);\r
}\r
\r
void IdentityExportXML::Initialize()\r
\r
const bool IdentityExportXML::ParseXML(const std::string &xml)\r
{\r
- TiXmlDocument td;\r
- td.Parse(xml.c_str());\r
+ bool parsed=false;\r
+ Poco::XML::DOMParser dp;\r
\r
- if(!td.Error())\r
- {\r
- std::string name;\r
- std::string publickey;\r
- std::string privatekey;\r
- bool singleuse=false;\r
- bool publishtrustlist=false;\r
- bool publishboardlist=false;\r
- TiXmlText *txt;\r
- TiXmlHandle hnd(&td);\r
- TiXmlNode *node;\r
+ Initialize();\r
\r
- Initialize();\r
+ try\r
+ {\r
+ Poco::AutoPtr<Poco::XML::Document> doc=dp.parseString(FixCDATA(xml));\r
+ Poco::XML::Element *root=XMLGetFirstChild(doc,"IdentityExport");\r
+ Poco::XML::Element *node=XMLGetFirstChild(root,"Identity");\r
\r
- node=hnd.FirstChild("IdentityExport").FirstChild("Identity").ToElement();\r
while(node)\r
{\r
- name="";\r
- publickey="";\r
- privatekey="";\r
- singleuse=false;\r
- publishtrustlist=false;\r
- publishboardlist=false;\r
-\r
- TiXmlHandle hnd2(node);\r
- txt=hnd2.FirstChild("Name").FirstChild().ToText();\r
- if(txt)\r
+ std::string name="";\r
+ std::string publickey="";\r
+ std::string privatekey="";\r
+ bool singleuse=false;\r
+ bool publishtrustlist=false;\r
+ bool publishboardlist=false;\r
+ bool publishfreesite=false; \r
+\r
+ Poco::XML::Element *text=XMLGetFirstChild(node,"Name");\r
+ if(text)\r
{\r
- name=txt->ValueStr();\r
+ if(text->firstChild())\r
+ {\r
+ std::string asdf=text->innerText();\r
+ asdf=text->firstChild()->innerText();\r
+ name=text->firstChild()->getNodeValue();\r
+ }\r
}\r
- txt=hnd2.FirstChild("PublicKey").FirstChild().ToText();\r
- if(txt)\r
+ text=XMLGetFirstChild(node,"PublicKey");\r
+ if(text)\r
{\r
- publickey=txt->ValueStr();\r
+ if(text->firstChild())\r
+ {\r
+ publickey=text->firstChild()->getNodeValue();\r
+ }\r
}\r
- txt=hnd2.FirstChild("PrivateKey").FirstChild().ToText();\r
- if(txt)\r
+ text=XMLGetFirstChild(node,"PrivateKey");\r
+ if(text)\r
{\r
- privatekey=txt->ValueStr();\r
+ if(text->firstChild())\r
+ {\r
+ privatekey=text->firstChild()->getNodeValue();\r
+ }\r
}\r
\r
- singleuse=XMLGetBooleanElement(node->ToElement(),"SingleUse");\r
- publishtrustlist=XMLGetBooleanElement(node->ToElement(),"PublishTrustList");\r
- publishboardlist=XMLGetBooleanElement(node->ToElement(),"PublishBoardList");\r
+ singleuse=XMLGetBooleanElement(node,"SingleUse");\r
+ publishtrustlist=XMLGetBooleanElement(node,"PublishTrustList");\r
+ publishboardlist=XMLGetBooleanElement(node,"PublishBoardList");\r
+ publishfreesite=XMLGetBooleanElement(node,"PublishFreesite");\r
\r
if(name!="" && publickey!="" && privatekey!="")\r
{\r
- m_identities.push_back(identity(name,publickey,privatekey,singleuse,publishtrustlist,publishboardlist));\r
+ m_identities.push_back(identity(name,publickey,privatekey,singleuse,publishtrustlist,publishboardlist,publishfreesite));\r
}\r
- \r
- node=node->NextSibling("Identity");\r
+\r
+ node=XMLGetNextSibling(node,"Identity");\r
}\r
- return true;\r
\r
+ parsed=true;\r
}\r
- else\r
+ catch(...)\r
{\r
- return false;\r
}\r
-}
\ No newline at end of file
+\r
+ return parsed;\r
+}\r