• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.8.5 API Reference
  • KDE Home
  • 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() : std::exception( other ), 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:
00062     explicit ImapStreamParser( QIODevice *socket, bool serverModeEnabled = false );
00063 
00067     ~ImapStreamParser();
00068 
00074     QString readUtf8String();
00075 
00080     QByteArray readString();
00081 
00087     QList<QByteArray> readParenthesizedList();
00088 
00089 
00095     qint64 readNumber( bool * ok = 0 );
00096 
00101     bool hasString();
00102 
00109     bool hasLiteral();
00110 
00130     QByteArray readLiteralPart();
00131 
00136     bool atLiteralEnd() const;
00137 
00142     bool hasList();
00143 
00148     bool atListEnd();
00149 
00154     bool hasResponseCode();
00155 
00160     bool atResponseCodeEnd();
00161 
00166     bool atCommandEnd();
00167 
00172     QByteArray readUntilCommandEnd();
00173 
00178     QByteArray readRemainingData();
00179 
00180     int availableDataSize() const;
00181 
00182     void setData( const QByteArray &data );
00183 
00184 
00185   private:
00186     void stripLeadingSpaces();
00187     QByteArray parseQuotedString();
00188 
00195     bool waitForMoreData( bool wait);
00196 
00200     void sendContinuationResponse( qint64 size );
00201 
00205     void trimBuffer();
00206 
00207     QIODevice *m_socket;
00208     bool m_isServerModeEnabled;
00209     QByteArray m_data;
00210     int m_position;
00211     qint64 m_literalSize;
00212 };
00213 
00214 }
00215 
00216 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:24:24 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIMAP Library

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

kdepimlibs-4.8.5 API Reference

Skip menu "kdepimlibs-4.8.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal