kmime_parsers.h
00001 /* 00002 kmime_parsers.h 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 program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 You should have received a copy of the GNU General Public License 00013 along with this program; if not, write to the Free Software Foundation, 00014 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US 00015 */ 00016 #ifndef __KMIME_PARSERS__ 00017 #define __KMIME_PARSERS__ 00018 00019 #include <tqvaluelist.h> 00020 #include <tqcstring.h> 00021 #include <tqstrlist.h> 00022 00023 namespace KMime { 00024 00025 namespace Parser { 00026 00031 class MultiPart { 00032 00033 public: 00034 MultiPart(const TQCString &src, const TQCString &boundary); 00035 ~MultiPart() {}; 00036 00037 bool parse(); 00038 TQValueList<TQCString> parts() { return p_arts; } 00039 TQCString preamble() { return p_reamble; } 00040 TQCString epilouge() { return e_pilouge; } 00041 00042 protected: 00043 TQCString s_rc, b_oundary, p_reamble, e_pilouge; 00044 TQValueList<TQCString> p_arts; 00045 }; 00046 00047 00052 class NonMimeParser { 00053 00054 public: 00055 NonMimeParser(const TQCString &src); 00056 virtual ~NonMimeParser() {}; 00057 virtual bool parse() = 0; 00058 bool isPartial() { return (p_artNr>-1 && t_otalNr>-1 && t_otalNr!=1); } 00059 int partialNumber() { return p_artNr; } 00060 int partialCount() { return t_otalNr; } 00061 bool hasTextPart() { return (t_ext.length()>1); } 00062 TQCString textPart() { return t_ext; } 00063 TQStrList binaryParts() { return b_ins; } 00064 TQStrList filenames() { return f_ilenames; } 00065 TQStrList mimeTypes() { return m_imeTypes; } 00066 00067 protected: 00068 static TQCString guessMimeType(const TQCString& fileName); 00069 00070 TQCString s_rc, t_ext; 00071 TQStrList b_ins, f_ilenames, m_imeTypes; 00072 int p_artNr, t_otalNr; 00073 }; 00074 00075 00080 class UUEncoded : public NonMimeParser { 00081 00082 public: 00083 UUEncoded(const TQCString &src, const TQCString &subject); 00084 00085 virtual bool parse(); 00086 00087 protected: 00088 TQCString s_ubject; 00089 }; 00090 00091 00092 00097 class YENCEncoded : public NonMimeParser { 00098 00099 public: 00100 YENCEncoded(const TQCString &src); 00101 00102 virtual bool parse(); 00103 TQValueList<TQByteArray> binaryParts() { return b_ins; } 00104 00105 protected: 00106 TQValueList<TQByteArray> b_ins; 00107 static bool yencMeta( TQCString& src, const TQCString& name, int* value); 00108 }; 00109 00110 00111 } // namespace Parser 00112 00113 } // namespace KMime 00114 00115 #endif // __KMIME_PARSERS__