X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fmessagexml.cpp;h=9652c766b3d34a9b5d4116b226f3b9d48f6b0ac6;hb=63376b2a82c3f6cdf2df56b1f134bd7df0aaab3a;hp=994ebd4fd718e9335c5eb0405e57ba4b642fc3f5;hpb=befd91205eff729a182f66de15374a577a8718f7;p=fms.git diff --git a/src/freenet/messagexml.cpp b/src/freenet/messagexml.cpp index 994ebd4..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) @@ -103,6 +118,11 @@ const bool MessageXML::ParseXML(const std::string &xml) if(txt) { m_replyboard=txt->ValueStr(); + StringFunctions::LowerCase(m_replyboard,m_replyboard); + if(m_replyboard.size()>40) + { + m_replyboard.erase(40); + } } txt=hnd.FirstChild("Message").FirstChild("Body").FirstChild().ToText(); if(txt) @@ -117,6 +137,10 @@ const bool MessageXML::ParseXML(const std::string &xml) { std::string boardname=node2->FirstChild()->ValueStr(); StringFunctions::LowerCase(boardname,boardname); + if(boardname.size()>40) + { + boardname.erase(40); + } m_boards.push_back(boardname); } node2=node2->NextSibling("Board"); @@ -149,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