X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmessage.cpp;h=d7aaf3fc12bf26896b5cccedb999fa6a08ed00ad;hb=44f964d9b2b2d55a5b5672e9297717bd25fa8ee2;hp=d2693f58fa3a54229e9aeceb90b6202013d9cc00;hpb=e773b0ecb8a35c67cde5b2e82bbebb05224f34d0;p=fms.git diff --git a/src/message.cpp b/src/message.cpp index d2693f5..d7aaf3f 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -325,6 +325,7 @@ void Message::Initialize() m_fromname=""; m_boards.clear(); m_inreplyto.clear(); + m_fileattachments.clear(); m_changemessagetrustonreply=0; Option::Instance()->Get("ChangeMessageTrustOnReply",tempval); StringFunctions::Convert(tempval,m_changemessagetrustonreply); @@ -694,6 +695,29 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage) #endif m_body+=bodypart; } + // add a binary file attachment + else if(((*i)->GetName()!="" || (*i)->GetFilename()!="") && (*i)->GetLength()>0 && (*i)->GetContent()) + { + std::string filename=""; + std::string contenttype=""; + std::vector data((*i)->GetContent(),(*i)->GetContent()+(*i)->GetContentLength()); + if((*i)->GetContentType()) + { + contenttype=(*i)->GetContentType(); + // find first ; tab cr or lf and erase it and everything after it + std::string::size_type endpos=contenttype.find_first_of(";\t\r\n "); + if(endpos!=std::string::npos) + { + contenttype.erase(endpos); + } + } + filename=(*i)->GetFilename(); + if(filename=="") + { + filename=(*i)->GetName(); + } + m_fileattachments.push_back(fileattachment(filename,contenttype,data)); + } } return true; @@ -735,6 +759,19 @@ const bool Message::StartFreenetInsert() st.Bind(2,xml.GetXML()); st.Step(); + // insert file attachments into database + st=m_db->Prepare("INSERT INTO tblFileInserts(MessageUUID,FileName,Size,MimeType,Data) VALUES(?,?,?,?,?);"); + for(std::vector::iterator i=m_fileattachments.begin(); i!=m_fileattachments.end(); i++) + { + st.Bind(0,m_messageuuid); + st.Bind(1,(*i).m_filename); + st.Bind(2,(long)(*i).m_data.size()); + st.Bind(3,(*i).m_mimetype); + st.Bind(4,&((*i).m_data[0]),(*i).m_data.size()); + st.Step(); + st.Reset(); + } + HandleChangeTrust(); return true;