version 0.2.2
[fms.git] / src / freenet / trustlistxml.cpp
index d732105..6b0329a 100644 (file)
@@ -12,9 +12,9 @@ TrustListXML::TrustListXML()
        Initialize();\r
 }\r
 \r
-void TrustListXML::AddTrust(const std::string &identity, const long messagetrust, const long trustlisttrust)\r
+void TrustListXML::AddTrust(const std::string &identity, const long messagetrust, const long trustlisttrust, const std::string &messagetrustcomment, const std::string &trustlisttrustcomment)\r
 {\r
-       m_trust.push_back(trust(identity,messagetrust,trustlisttrust));\r
+       m_trust.push_back(trust(identity,messagetrust,trustlisttrust,messagetrustcomment,trustlisttrustcomment));\r
 }\r
 \r
 std::string TrustListXML::GetIdentity(const long index)\r
@@ -41,6 +41,18 @@ long TrustListXML::GetMessageTrust(const long index)
        }       \r
 }\r
 \r
+std::string TrustListXML::GetMessageTrustComment(const long index)\r
+{\r
+       if(index>=0 && index<m_trust.size())\r
+       {\r
+               return m_trust[index].m_messagetrustcomment;\r
+       }\r
+       else\r
+       {\r
+               return "";\r
+       }       \r
+}\r
+\r
 long TrustListXML::GetTrustListTrust(const long index)\r
 {\r
        if(index>=0 && index<m_trust.size())\r
@@ -53,6 +65,18 @@ long TrustListXML::GetTrustListTrust(const long index)
        }\r
 }\r
 \r
+std::string TrustListXML::GetTrustListTrustComment(const long index)\r
+{\r
+       if(index>=0 && index<m_trust.size())\r
+       {\r
+               return m_trust[index].m_trustlisttrustcomment;\r
+       }\r
+       else\r
+       {\r
+               return "";\r
+       }\r
+}\r
+\r
 std::string TrustListXML::GetXML()\r
 {\r
        TiXmlDocument td;\r
@@ -81,6 +105,14 @@ std::string TrustListXML::GetXML()
                {\r
                        tr->LinkEndChild(XMLCreateTextElement("TrustListTrustLevel",trustlisttrust));\r
                }\r
+               if((*i).m_messagetrustcomment!="")\r
+               {\r
+                       tr->LinkEndChild(XMLCreateCDATAElement("MessageTrustComment",(*i).m_messagetrustcomment));\r
+               }\r
+               if((*i).m_trustlisttrustcomment!="")\r
+               {\r
+                       tr->LinkEndChild(XMLCreateCDATAElement("TrustListTrustComment",(*i).m_trustlisttrustcomment));\r
+               }\r
        }\r
 \r
        td.Accept(&tp);\r
@@ -102,6 +134,8 @@ const bool TrustListXML::ParseXML(const std::string &xml)
                std::string identity;\r
                std::string messagetruststr;\r
                std::string trustlisttruststr;\r
+               std::string messagetrustcomment="";\r
+               std::string trustlisttrustcomment="";\r
                long messagetrust;\r
                long trustlisttrust;\r
                TiXmlText *txt;\r
@@ -142,6 +176,16 @@ const bool TrustListXML::ParseXML(const std::string &xml)
                                        StringFunctions::Convert(trustlisttruststr,trustlisttrust);\r
                                }\r
                        }\r
+                       txt=hnd2.FirstChild("MessageTrustComment").FirstChild().ToText();\r
+                       if(txt)\r
+                       {\r
+                               messagetrustcomment=txt->ValueStr();\r
+                       }\r
+                       txt=hnd2.FirstChild("TrustListTrustComment").FirstChild().ToText();\r
+                       if(txt)\r
+                       {\r
+                               trustlisttrustcomment=txt->ValueStr();\r
+                       }\r
 \r
                        if(identity!="" && messagetrust>=-1 && messagetrust<=100 && trustlisttrust>=-1 && trustlisttrust<=100)\r
                        {\r
@@ -149,7 +193,7 @@ const bool TrustListXML::ParseXML(const std::string &xml)
                                if(std::find(m_foundkeys.begin(),m_foundkeys.end(),identity)==m_foundkeys.end())\r
                                {\r
                                        m_foundkeys.push_back(identity);\r
-                                       m_trust.push_back(trust(identity,messagetrust,trustlisttrust));\r
+                                       m_trust.push_back(trust(identity,messagetrust,trustlisttrust,messagetrustcomment,trustlisttrustcomment));\r
                                }\r
                        }\r
                        else\r