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

kioslave/imap4

mimeheader.h

00001 /***************************************************************************
00002                           mimeheader.h  -  description
00003                              -------------------
00004     begin                : Fri Oct 20 2000
00005     copyright            : (C) 2000 by Sven Carstens
00006     email                : s.carstens@gmx.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef MIMEHEADER_H
00019 #define MIMEHEADER_H
00020 
00021 #include <QList>
00022 #include <QHash>
00023 #include <QByteArray>
00024 
00025 #include "mimehdrline.h"
00026 #include "mimeio.h"
00027 
00028 #include <kimap/rfccodecs.h>
00029 using namespace KIMAP;
00030 
00035 class mimeHeader
00036 {
00037 public:
00038   mimeHeader ();
00039   virtual ~ mimeHeader ();
00040 
00041   virtual void addHdrLine (mimeHdrLine *);
00042   virtual void outputHeader (mimeIO &);
00043   virtual void outputPart (mimeIO &);
00044 
00045 
00046   QByteArray outputParameter (QHash < QString, QString > &);
00047 
00048 //  int parsePart (mimeIO &, const QString&);
00049 //  int parseBody (mimeIO &, QByteArray &, const QString&, bool mbox = false);
00050 
00051   // parse a header. returns true if it had a leading 'From ' line
00052   bool parseHeader (mimeIO &);
00053 
00054   QString getDispositionParm (const QByteArray&);
00055   void setDispositionParm (const QByteArray&, const QString&);
00056   QHashIterator < QString, QString > getDispositionIterator ();
00057 
00058   QString getTypeParm (const QByteArray&);
00059   void setTypeParm (const QByteArray&, const QString&);
00060   QHashIterator < QString, QString > getTypeIterator ();
00061 
00062   // recursively serialize all important contents to the QDataStream
00063   void serialize(QDataStream& stream);
00064 
00065   const QByteArray& getType ()
00066   {
00067     return _contentType;
00068   }
00069   void setType (const QByteArray& _str)
00070   {
00071     _contentType = _str;
00072   }
00073 
00074   const QByteArray& getDescription ()
00075   {
00076     return _contentDescription;
00077   }
00078   void setDescription( const QByteArray& _str )
00079   {
00080     _contentDescription = _str;
00081   }
00082 
00083   const QByteArray& getDisposition ()
00084   {
00085     return _contentDisposition;
00086   }
00087   void setDisposition( const QByteArray& _str )
00088   {
00089     _contentDisposition = _str;
00090   }
00091 
00092   const QByteArray& getEncoding ()
00093   {
00094     return _contentEncoding;
00095   }
00096   void setEncoding (const QByteArray &_str )
00097   {
00098     _contentEncoding = _str;
00099   }
00100 
00101   const QByteArray& getMD5 ()
00102   {
00103     return _contentMD5;
00104   }
00105   void setMD5 (const QByteArray & _str)
00106   {
00107     _contentMD5 = _str;
00108   }
00109 
00110   const QByteArray& getID ()
00111   {
00112     return _contentID;
00113   }
00114   void setID (const QByteArray & _str)
00115   {
00116     _contentID = _str;
00117   }
00118 
00119   unsigned long getLength ()
00120   {
00121     return contentLength;
00122   }
00123   void setLength (unsigned long _len)
00124   {
00125     contentLength = _len;
00126   }
00127 
00128   const QString & getPartSpecifier ()
00129   {
00130     return partSpecifier;
00131   }
00132   void setPartSpecifier (const QString & _str)
00133   {
00134     partSpecifier = _str;
00135   }
00136 
00137   QListIterator < mimeHdrLine *> getOriginalIterator ();
00138   QListIterator < mimeHdrLine *> getAdditionalIterator ();
00139   void setContent (const QByteArray &aContent)
00140   {
00141     mimeContent = aContent;
00142   }
00143   QByteArray getContent ()
00144   {
00145     return mimeContent;
00146   }
00147 
00148   QByteArray getBody ()
00149   {
00150     return preMultipartBody + postMultipartBody;
00151   }
00152   QByteArray getPreBody ()
00153   {
00154     return preMultipartBody;
00155   }
00156   void setPreBody (QByteArray & inBody)
00157   {
00158     preMultipartBody = inBody;
00159   }
00160 
00161   QByteArray getPostBody ()
00162   {
00163     return postMultipartBody;
00164   }
00165   void setPostBody (QByteArray & inBody)
00166   {
00167     postMultipartBody = inBody;
00168     contentLength = inBody.length ();
00169   }
00170 
00171   mimeHeader *getNestedMessage ()
00172   {
00173     return nestedMessage;
00174   }
00175   void setNestedMessage (mimeHeader * inPart, bool destroy = true)
00176   {
00177     if (nestedMessage && destroy)
00178       delete nestedMessage;
00179     nestedMessage = inPart;
00180   }
00181 
00182 //  mimeHeader *getNestedPart() { return nestedPart; };
00183   void addNestedPart (mimeHeader * inPart)
00184   {
00185     nestedParts.append (inPart);
00186   }
00187   QListIterator < mimeHeader *> getNestedIterator ()
00188   {
00189     return QListIterator < mimeHeader *> (nestedParts);
00190   }
00191 
00192   // clears all parts and deletes them from memory
00193   void clearNestedParts ()
00194   {
00195     nestedParts.clear ();
00196   }
00197 
00198   // clear all parameters to content-type
00199   void clearTypeParameters ()
00200   {
00201     typeList.clear ();
00202   }
00203 
00204   // clear all parameters to content-disposition
00205   void clearDispositionParameters ()
00206   {
00207     dispositionList.clear ();
00208   }
00209 
00210   // return the specified body part or NULL
00211   mimeHeader *bodyPart (const QString &);
00212 
00213 #ifdef KMAIL_COMPATIBLE
00214   ulong msgSize ()
00215   {
00216     return contentLength;
00217   }
00218   uint numBodyParts ()
00219   {
00220     return nestedParts.count ();
00221   }
00222   mimeHeader *bodyPart (int which, mimeHeader ** ret = NULL)
00223   {
00224     if (ret)
00225       (*ret) = nestedParts.at (which);
00226     return nestedParts.at (which);
00227   }
00228   void write (const QString &)
00229   {
00230   }
00231   QString typeStr ()
00232   {
00233     return QString (contentType.left (contentType.find ('/')));
00234   }
00235   void setTypeStr (const QString & _str)
00236   {
00237     contentType = QByteArray (_str.toLatin1 ()) + "/" + subtypeStr ().toLatin1 ();
00238   }
00239   QString subtypeStr ()
00240   {
00241     return QString (contentType.
00242                     right (contentType.length () - contentType.find ('/') -
00243                            1));
00244   }
00245   void setSubtypeStr (const QString & _str)
00246   {
00247     contentType = QByteArray (typeStr ().toLatin1 ()) + "/" + _str.toLatin1 ();
00248   }
00249   QString cteStr ()
00250   {
00251     return QString (getEncoding ());
00252   }
00253   void setCteStr (const QString & _str)
00254   {
00255     setEncoding (_str.toLatin1 ());
00256   }
00257   QString contentDisposition ()
00258   {
00259     return QString (_contentDisposition);
00260   }
00261   QString body ()
00262   {
00263     return QString (postMultipartBody);
00264   }
00265   QString charset ()
00266   {
00267     return getTypeParm ("charset");
00268   }
00269   QString bodyDecoded ();
00270   void setBodyEncoded (const QByteArray &);
00271   void setBodyEncodedBinary (const QByteArray &);
00272   QByteArray bodyDecodedBinary ();
00273   QString name ()
00274   {
00275     return QString (getTypeParm ("name"));
00276   }
00277   void setName (const QString & _str)
00278   {
00279     setTypeParm ("name", _str);
00280   }
00281   QString fileName ()
00282   {
00283     return QString (getDispositionParm ("filename"));
00284   }
00285   QString contentDescription ()
00286   {
00287     return QString (RfcCodecs::decodeRFC2047String (_contentDescription));
00288   }
00289   void setContentDescription (const QString & _str)
00290   {
00291     _contentDescription = RfcCodecs::encodeRFC2047String (_str).toLatin1 ();
00292   }
00293   QString msgIdMD5 ()
00294   {
00295     return QString (contentMD5);
00296   }
00297   QString iconName ();
00298   QString magicSetType (bool aAutoDecode = true);
00299   QString headerAsString ();
00300   ulong size ()
00301   {
00302     return 0;
00303   }
00304   void fromString (const QByteArray &)
00305   {;
00306   }
00307   void setContentDisposition (const QString & _str)
00308   {
00309     setDisposition (_str.toLatin1 ());
00310   }
00311 #endif
00312 
00313 protected:
00314   static void addParameter (const QByteArray&, QHash < QString, QString > &);
00315   static QString getParameter (const QByteArray&, QHash < QString, QString > &);
00316   static void setParameter (const QByteArray&, const QString&, QHash < QString, QString > &);
00317 
00318   QList < mimeHdrLine *> originalHdrLines;
00319 
00320 private:
00321   QList < mimeHdrLine *> additionalHdrLines;
00322   QHash < QString, QString > typeList;
00323   QHash < QString, QString > dispositionList;
00324   QByteArray _contentType;
00325   QByteArray _contentDisposition;
00326   QByteArray _contentEncoding;
00327   QByteArray _contentDescription;
00328   QByteArray _contentID;
00329   QByteArray _contentMD5;
00330   unsigned int contentLength;
00331   QByteArray mimeContent;
00332   QByteArray preMultipartBody;
00333   QByteArray postMultipartBody;
00334   mimeHeader *nestedMessage;
00335   QList < mimeHeader *> nestedParts;
00336   QString partSpecifier;
00337 
00338 };
00339 
00340 #endif

kioslave/imap4

Skip menu "kioslave/imap4"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • 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.7.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