• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

KMIME Library

kmime_message.cpp

00001 /*
00002     kmime_message.cpp
00003 
00004     KMime, the KDE Internet mail/usenet news message library.
00005     Copyright (c) 2001 the KMime authors.
00006     See file AUTHORS for details
00007 
00008     This library is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU Library General Public
00010     License as published by the Free Software Foundation; either
00011     version 2 of the License, or (at your option) any later version.
00012 
00013     This library is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016     Library General Public License for more details.
00017 
00018     You should have received a copy of the GNU Library General Public License
00019     along with this library; see the file COPYING.LIB.  If not, write to
00020     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021     Boston, MA 02110-1301, USA.
00022 */
00023 
00024 #include "kmime_message.h"
00025 #include "kmime_message_p.h"
00026 #include "kmime_util_p.h"
00027 
00028 using namespace KMime;
00029 
00030 namespace KMime {
00031 
00032 Message::Message()
00033   : Content( new MessagePrivate( this ) )
00034 {
00035 }
00036 
00037 Message::Message(MessagePrivate * d)
00038   : Content( d )
00039 {
00040 }
00041 
00042 Message::~Message()
00043 {
00044 }
00045 
00046 void Message::parse()
00047 {
00048   // KDE5: remove this virtual reimplementation.
00049   Content::parse();
00050 }
00051 
00052 QByteArray Message::assembleHeaders()
00053 {
00054   // Create the mandatory fields (RFC5322) if they do not exist already.
00055   date( true );
00056   from( true );
00057 
00058   // Make sure the mandatory MIME-Version field (RFC2045) is present and valid.
00059   Headers::MIMEVersion *mimeVersion = header<Headers::MIMEVersion>( true );
00060   mimeVersion->from7BitString( "1.0" );
00061 
00062   // Assemble all header fields.
00063   return Content::assembleHeaders();
00064 }
00065 
00066 void Message::clear()
00067 {
00068   // KDE5: remove this virtual reimplementation.
00069   Content::clear();
00070 }
00071 
00072 Headers::Base *Message::getHeaderByType( const char *type )
00073 {
00074   // KDE5: remove this virtual reimplementation.
00075   return headerByType( type );
00076 }
00077 
00078 Headers::Base *Message::headerByType( const char *type )
00079 {
00080   // KDE5: remove this virtual reimplementation.
00081   return Content::headerByType( type );
00082 }
00083 
00084 void Message::setHeader( Headers::Base *h )
00085 {
00086   // KDE5: remove this virtual reimplementation.
00087   Content::setHeader( h );
00088 }
00089 
00090 bool Message::removeHeader( const char *type )
00091 {
00092   // KDE5: remove this virtual reimplementation.
00093   return Content::removeHeader( type );
00094 }
00095 
00096 bool Message::isTopLevel() const
00097 {
00098   return true;
00099 }
00100 
00101 Content *Message::mainBodyPart( const QByteArray &type )
00102 {
00103   KMime::Content *c = this;
00104   while ( c ) {
00105     // not a multipart message
00106     if ( !c->contentType()->isMultipart() ) {
00107       if ( c->contentType()->mimeType() == type || type.isEmpty() ) {
00108         return c;
00109       }
00110       return 0;
00111     }
00112 
00113     // empty multipart
00114     if ( c->contents().count() == 0 ) {
00115       return 0;
00116     }
00117 
00118     // multipart/alternative
00119     if ( c->contentType()->subType() == "alternative" ) {
00120       if ( type.isEmpty() ) {
00121         return c->contents().first();
00122       }
00123       foreach ( Content *c1, c->contents() ) {
00124         if ( c1->contentType()->mimeType() == type ) {
00125           return c1;
00126         }
00127       }
00128       return 0;
00129     }
00130 
00131     c = c->contents().first();
00132   }
00133 
00134   return 0;
00135 }
00136 
00137 QString Message::mimeType()
00138 {
00139   return QLatin1String( "message/rfc822" );
00140 }
00141 
00142 
00143 // @cond PRIVATE
00144 #define kmime_mk_header_accessor( type, method ) \
00145 Headers::type *Message::method( bool create ) { \
00146   return header<Headers::type>( create ); \
00147 }
00148 
00149 kmime_mk_header_accessor( MessageID, messageID )
00150 kmime_mk_header_accessor( Subject, subject )
00151 kmime_mk_header_accessor( Date, date )
00152 kmime_mk_header_accessor( Organization, organization )
00153 kmime_mk_header_accessor( From, from )
00154 kmime_mk_header_accessor( ReplyTo, replyTo )
00155 kmime_mk_header_accessor( To, to )
00156 kmime_mk_header_accessor( Cc, cc )
00157 kmime_mk_header_accessor( Bcc, bcc )
00158 kmime_mk_header_accessor( References, references )
00159 kmime_mk_header_accessor( UserAgent, userAgent )
00160 kmime_mk_header_accessor( InReplyTo, inReplyTo )
00161 kmime_mk_header_accessor( Sender, sender )
00162 
00163 #undef kmime_mk_header_accessor
00164 // @endcond
00165 
00166 }
00167 

KMIME Library

Skip menu "KMIME Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal