summaryrefslogtreecommitdiffstats
path: root/libkmime/kmime_newsarticle.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /libkmime/kmime_newsarticle.cpp
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkmime/kmime_newsarticle.cpp')
-rw-r--r--libkmime/kmime_newsarticle.cpp160
1 files changed, 160 insertions, 0 deletions
diff --git a/libkmime/kmime_newsarticle.cpp b/libkmime/kmime_newsarticle.cpp
new file mode 100644
index 000000000..a60b07df8
--- /dev/null
+++ b/libkmime/kmime_newsarticle.cpp
@@ -0,0 +1,160 @@
+/*
+ kmime_newsarticle.cpp
+
+ KMime, the KDE internet mail/usenet news message library.
+ Copyright (c) 2001 the KMime authors.
+ See file AUTHORS for details
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
+*/
+#include "kmime_newsarticle.h"
+
+using namespace KMime;
+
+namespace KMime {
+
+void NewsArticle::parse()
+{
+ Message::parse();
+
+ QCString raw;
+
+ if( !(raw=rawHeader(l_ines.type())).isEmpty() )
+ l_ines.from7BitString(raw);
+}
+
+void NewsArticle::assemble()
+{
+ Headers::Base *h;
+ QCString newHead="";
+
+ //Message-ID
+ if( (h=messageID(false))!=0 )
+ newHead+=h->as7BitString()+"\n";
+
+ //Control
+ if( (h=control(false))!=0 )
+ newHead+=h->as7BitString()+"\n";
+
+ //Supersedes
+ if( (h=supersedes(false))!=0 )
+ newHead+=h->as7BitString()+"\n";
+
+ //From
+ h=from(); // "From" is mandatory
+ newHead+=h->as7BitString()+"\n";
+
+ //Subject
+ h=subject(); // "Subject" is mandatory
+ newHead+=h->as7BitString()+"\n";
+
+ //To
+ if( (h=to(false))!=0 )
+ newHead+=h->as7BitString()+"\n";
+
+ //Newsgroups
+ if( (h=newsgroups(false))!=0 )
+ newHead+=h->as7BitString()+"\n";
+
+ //Followup-To
+ if( (h=followUpTo(false))!=0 )
+ newHead+=h->as7BitString()+"\n";
+
+ //Reply-To
+ if( (h=replyTo(false))!=0 )
+ newHead+=h->as7BitString()+"\n";
+
+ //Mail-Copies-To
+ if( (h=mailCopiesTo(false))!=0 )
+ newHead+=h->as7BitString()+"\n";
+
+ //Date
+ h=date(); // "Date" is mandatory
+ newHead+=h->as7BitString()+"\n";
+
+ //References
+ if( (h=references(false))!=0 )
+ newHead+=h->as7BitString()+"\n";
+
+ //Lines
+ h=lines(); // "Lines" is mandatory
+ newHead+=h->as7BitString()+"\n";
+
+ //Organization
+ if( (h=organization(false))!=0 )
+ newHead+=h->as7BitString()+"\n";
+
+ //User-Agent
+ if( (h=userAgent(false))!=0 )
+ newHead+=h->as7BitString()+"\n";
+
+ //Mime-Version
+ newHead+="MIME-Version: 1.0\n";
+
+ //Content-Type
+ newHead+=contentType()->as7BitString()+"\n";
+
+ //Content-Transfer-Encoding
+ newHead+=contentTransferEncoding()->as7BitString()+"\n";
+
+ //X-Headers
+ int pos=h_ead.find("\nX-");
+ if(pos>-1) //we already have some x-headers => "recycle" them
+ newHead+=h_ead.mid(pos+1, h_ead.length()-pos);
+ else if(h_eaders && !h_eaders->isEmpty()) {
+ for(h=h_eaders->first(); h; h=h_eaders->next()) {
+ if( h->isXHeader() && (strncasecmp(h->type(), "X-KNode", 7)!=0) )
+ newHead+=h->as7BitString()+"\n";
+ }
+ }
+
+ h_ead=newHead;
+}
+
+void NewsArticle::clear()
+{
+ l_ines.clear();
+ Message::clear();
+}
+
+Headers::Base * NewsArticle::getHeaderByType(const char * type)
+{
+ if(strcasecmp("Lines", type)==0) {
+ if(l_ines.isEmpty()) return 0;
+ else return &l_ines;
+ } else
+ return Message::getHeaderByType(type);
+}
+
+void NewsArticle::setHeader(Headers::Base *h)
+{
+ bool del=true;
+ if(h->is("Lines"))
+ l_ines.setNumberOfLines( (static_cast<Headers::Lines*>(h))->numberOfLines() );
+ else {
+ del=false;
+ Message::setHeader(h);
+ }
+
+ if(del) delete h;
+}
+
+
+bool NewsArticle::removeHeader(const char *type)
+{
+ if(strcasecmp("Lines", type)==0)
+ l_ines.clear();
+ else
+ return Message::removeHeader(type);
+
+ return true;
+}
+
+
+} // namespace KMime