1 #include "../../include/http/identityexportxml.h"
\r
7 IdentityExportXML::IdentityExportXML()
\r
12 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
14 m_identities.push_back(identity(name,publickey,privatekey,singleuse,publishtrustlist,publishboardlist,publishfreesite));
\r
17 const std::string IdentityExportXML::GetName(const long index)
\r
19 if(index>=0 && index<GetCount())
\r
21 return m_identities[index].m_name;
\r
29 const std::string IdentityExportXML::GetPrivateKey(const long index)
\r
31 if(index>=0 && index<GetCount())
\r
33 return m_identities[index].m_privatekey;
\r
41 const std::string IdentityExportXML::GetPublicKey(const long index)
\r
43 if(index>=0 && index<GetCount())
\r
45 return m_identities[index].m_publickey;
\r
53 const bool IdentityExportXML::GetPublishBoardList(const long index)
\r
55 if(index>=0 && index<GetCount())
\r
57 return m_identities[index].m_publishboardlist;
\r
65 const bool IdentityExportXML::GetPublishFreesite(const long index)
\r
67 if(index>=0 && index<GetCount())
\r
69 return m_identities[index].m_publishfreesite;
\r
77 const bool IdentityExportXML::GetPublishTrustList(const long index)
\r
79 if(index>=0 && index<GetCount())
\r
81 return m_identities[index].m_publishtrustlist;
\r
89 const bool IdentityExportXML::GetSingleUse(const long index)
\r
91 if(index>=0 && index<GetCount())
\r
93 return m_identities[index].m_singleuse;
\r
101 std::string IdentityExportXML::GetXML()
\r
104 TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8","");
\r
108 td.LinkEndChild(tdec);
\r
109 tid=new TiXmlElement("IdentityExport");
\r
110 td.LinkEndChild(tid);
\r
112 for(std::vector<identity>::iterator i=m_identities.begin(); i!=m_identities.end(); i++)
\r
114 TiXmlElement *tr=new TiXmlElement("Identity");
\r
115 tid->LinkEndChild(tr);
\r
116 tr->LinkEndChild(XMLCreateCDATAElement("Name",(*i).m_name));
\r
117 tr->LinkEndChild(XMLCreateTextElement("PublicKey",(*i).m_publickey));
\r
118 tr->LinkEndChild(XMLCreateTextElement("PrivateKey",(*i).m_privatekey));
\r
119 tr->LinkEndChild(XMLCreateBooleanElement("SingleUse",(*i).m_singleuse));
\r
120 tr->LinkEndChild(XMLCreateBooleanElement("PublishTrustList",(*i).m_publishtrustlist));
\r
121 tr->LinkEndChild(XMLCreateBooleanElement("PublishBoardList",(*i).m_publishboardlist));
\r
122 tr->LinkEndChild(XMLCreateBooleanElement("PublishFreesite",(*i).m_publishfreesite));
\r
126 return std::string(tp.CStr());
\r
129 void IdentityExportXML::Initialize()
\r
131 m_identities.clear();
\r
134 const bool IdentityExportXML::ParseXML(const std::string &xml)
\r
137 td.Parse(xml.c_str());
\r
142 std::string publickey;
\r
143 std::string privatekey;
\r
144 bool singleuse=false;
\r
145 bool publishtrustlist=false;
\r
146 bool publishboardlist=false;
\r
147 bool publishfreesite=false;
\r
149 TiXmlHandle hnd(&td);
\r
154 node=hnd.FirstChild("IdentityExport").FirstChild("Identity").ToElement();
\r
161 publishtrustlist=false;
\r
162 publishboardlist=false;
\r
163 publishfreesite=false;
\r
165 TiXmlHandle hnd2(node);
\r
166 txt=hnd2.FirstChild("Name").FirstChild().ToText();
\r
169 name=txt->ValueStr();
\r
171 txt=hnd2.FirstChild("PublicKey").FirstChild().ToText();
\r
174 publickey=txt->ValueStr();
\r
176 txt=hnd2.FirstChild("PrivateKey").FirstChild().ToText();
\r
179 privatekey=txt->ValueStr();
\r
182 singleuse=XMLGetBooleanElement(node->ToElement(),"SingleUse");
\r
183 publishtrustlist=XMLGetBooleanElement(node->ToElement(),"PublishTrustList");
\r
184 publishboardlist=XMLGetBooleanElement(node->ToElement(),"PublishBoardList");
\r
185 publishfreesite=XMLGetBooleanElement(node->ToElement(),"PublishFreesite");
\r
187 if(name!="" && publickey!="" && privatekey!="")
\r
189 m_identities.push_back(identity(name,publickey,privatekey,singleuse,publishtrustlist,publishboardlist,publishfreesite));
\r
192 node=node->NextSibling("Identity");
\r