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

KIMAP Library

imapstreamparser.h

00001 /*
00002     Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
00003     Copyright (c) 2009 Andras Mantia <amantia@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or modify it
00006     under the terms of the GNU Library General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or (at your
00008     option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful, but WITHOUT
00011     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013     License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to the
00017     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018     02110-1301, USA.
00019 */
00020 
00021 #ifndef KIMAP_IMAPSTREAMPARSER_P_H
00022 #define KIMAP_IMAPSTREAMPARSER_P_H
00023 
00024 #include "kimap_export.h"
00025 
00026 #include <exception>
00027 
00028 #include <QtCore/QByteArray>
00029 #include <QtCore/QList>
00030 #include <QtCore/QString>
00031 
00032 class QIODevice;
00033 
00034 namespace KIMAP {
00035 
00036 class ImapParserException : public std::exception
00037 {
00038   public:
00039     ImapParserException( const char *what ) throw() : mWhat( what ) {}
00040     ImapParserException( const QByteArray &what ) throw() : mWhat( what ) {}
00041     ImapParserException( const QString &what ) throw() : mWhat( what.toUtf8() ) {}
00042     ImapParserException( const ImapParserException &other ) throw() : mWhat( other.what() ) {}
00043     virtual ~ImapParserException() throw() {}
00044     const char *what() const throw() { return mWhat.constData(); }
00045     virtual const char *type() const throw() { return "ImapParserException"; }
00046   private:
00047     QByteArray mWhat;
00048 };
00049 
00053 class KIMAP_EXPORT ImapStreamParser
00054 {
00055   public:
00060     ImapStreamParser( QIODevice* socket);
00061 
00065     ~ImapStreamParser();
00066 
00072     QString readUtf8String();
00073 
00078     QByteArray readString();
00079 
00085     QList<QByteArray> readParenthesizedList();
00086 
00087 
00093     qint64 readNumber( bool * ok = 0 );
00094 
00099     bool hasString();
00100 
00107     bool hasLiteral();
00108 
00128     QByteArray readLiteralPart();
00129 
00134     bool atLiteralEnd() const;
00135 
00140     bool hasList();
00141 
00146     bool atListEnd();
00147 
00152     bool hasResponseCode();
00153 
00158     bool atResponseCodeEnd();
00159 
00164     bool atCommandEnd();
00165 
00170     QByteArray readUntilCommandEnd();
00171 
00176     QByteArray readRemainingData();
00177 
00178     int availableDataSize() const;
00179 
00180     void setData( const QByteArray &data );
00181 
00182 
00183   private:
00184     void stripLeadingSpaces();
00185     QByteArray parseQuotedString();
00186 
00193     bool waitForMoreData( bool wait);
00194 
00198     void sendContinuationResponse();
00199 
00200     QIODevice *m_socket;
00201     QByteArray m_data;
00202     int m_position;
00203     qint64 m_literalSize;
00204     qint64 m_continuationSize;
00205 };
00206 
00207 }
00208 
00209 #endif

KIMAP Library

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • 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