X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Fmessage.cpp;h=8582146a765cdc782b2a51d99049c6d788a2ba4f;hp=eea0633477f6d423d609e0ff33f7aa4bd1fa12ee;hb=bae54a5dae027ad0a6b0126ec9eeecd3bd2739eb;hpb=b4f4686250878cdf4fcb2986a2ea6546cba867d1 diff --git a/src/message.cpp b/src/message.cpp index eea0633..8582146 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -7,6 +7,10 @@ #include +#ifdef DO_CHARSET_CONVERSION + #include "../include/charsetconverter.h" +#endif + #ifdef XMEM #include #endif @@ -611,6 +615,19 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage) m_subject=mime.GetFieldValue("Subject"); // remove any path folding m_subject=StringFunctions::Replace(m_subject,"\r\n",""); +#if DO_CHARSET_CONVERSION + if(mime.GetFieldCharset("Subject")) + { + std::string charset=mime.GetFieldCharset("Subject"); + CharsetConverter ccv; + if(charset!="" && charset!="UTF-8" && ccv.SetConversion(charset,"UTF-8")) + { + std::string output=""; + ccv.Convert(m_subject,output); + m_subject=output; + } + } +#endif } else { @@ -658,7 +675,21 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage) { if((*i)->IsText() && (*i)->GetContent()) { - m_body+=(char *)(*i)->GetContent(); + std::string bodypart=(char *)(*i)->GetContent(); +#ifdef DO_CHARSET_CONVERSION + std::string charset=(*i)->GetCharset(); + if(charset!="" && charset!="UTF-8") + { + CharsetConverter ccv; + if(ccv.SetConversion(charset,"UTF-8")) + { + std::string output=""; + ccv.Convert(bodypart,output); + bodypart=output; + } + } +#endif + m_body+=bodypart; } } @@ -689,35 +720,6 @@ const bool Message::StartFreenetInsert() xml.AddInReplyTo((*j).first,(*j).second); } - - // find identity to insert with - /* - SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID FROM tblLocalIdentity WHERE Name=?;"); - st.Bind(0,m_fromname); - st.Step(); - - // couldn't find identity with this name - insert a new identity - if(!st.RowReturned()) - { - if(m_addnewpostfromidentities==true) - { - DateTime now; - now.SetToGMTime(); - st=m_db->Prepare("INSERT INTO tblLocalIdentity(Name) VALUES(?);"); - st.Bind(0,m_fromname); - st.Step(true); - localidentityid=st.GetLastInsertRowID(); - } - else - { - return false; - } - } - else - { - st.ResultInt(0,localidentityid); - } - */ localidentityid=FindLocalIdentityID(m_fromname); if(localidentityid==-1) {