X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Ffreenet%2Fmessagexml.cpp;h=9652c766b3d34a9b5d4116b226f3b9d48f6b0ac6;hp=ec5946e72facab20b3e1ef19965dc425501be3f0;hb=63376b2a82c3f6cdf2df56b1f134bd7df0aaab3a;hpb=e773b0ecb8a35c67cde5b2e82bbebb05224f34d0 diff --git a/src/freenet/messagexml.cpp b/src/freenet/messagexml.cpp index ec5946e..9652c76 100644 --- a/src/freenet/messagexml.cpp +++ b/src/freenet/messagexml.cpp @@ -51,6 +51,20 @@ std::string MessageXML::GetXML() } } + // add attachemnt node if we have attachments + if(m_fileattachments.size()>0) + { + TiXmlElement *attachments=new TiXmlElement("Attachments"); + tid->LinkEndChild(attachments); + for(std::vector::iterator j=m_fileattachments.begin(); j!=m_fileattachments.end(); j++) + { + TiXmlElement *f=new TiXmlElement("File"); + attachments->LinkEndChild(f); + f->LinkEndChild(XMLCreateCDATAElement("Key",(*j).m_key)); + f->LinkEndChild(XMLCreateTextElement("Size",(*j).m_size)); + } + } + td.Accept(&tp); return std::string(tp.CStr()); } @@ -64,6 +78,7 @@ void MessageXML::Initialize() m_replyboard=""; m_inreplyto.clear(); m_body=""; + m_fileattachments.clear(); } const bool MessageXML::ParseXML(const std::string &xml) @@ -158,6 +173,36 @@ const bool MessageXML::ParseXML(const std::string &xml) node2=node2->NextSibling("Message"); } + node2=hnd.FirstChild("Message").FirstChild("Attachments").FirstChild("File").ToNode(); + while(node2) + { + std::string key=""; + std::string sizestr="-1"; + int size=-1; + + TiXmlHandle hnd2(node2); + + txt=hnd2.FirstChild("Key").FirstChild().ToText(); + if(txt) + { + key=txt->ValueStr(); + } + + txt=hnd2.FirstChild("Size").FirstChild().ToText(); + if(txt) + { + sizestr=txt->ValueStr(); + StringFunctions::Convert(sizestr,size); + } + + if(key!="" && size>0) + { + m_fileattachments.push_back(fileattachment(key,size)); + } + + node2=node2->NextSibling("File"); + } + return true; } else