• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 API Reference
  • KDE Home
  • Contact Us
 

KIMAP Library

  • kimap
imapstreamparser.h
1 /*
2  Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
3  Copyright (c) 2009 Andras Mantia <amantia@kde.org>
4 
5  This library is free software; you can redistribute it and/or modify it
6  under the terms of the GNU Library General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or (at your
8  option) any later version.
9 
10  This library is distributed in the hope that it will be useful, but WITHOUT
11  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13  License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to the
17  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  02110-1301, USA.
19 */
20 
21 #ifndef KIMAP_IMAPSTREAMPARSER_P_H
22 #define KIMAP_IMAPSTREAMPARSER_P_H
23 
24 #include "kimap_export.h"
25 
26 #include <exception>
27 
28 #include <QtCore/QByteArray>
29 #include <QtCore/QList>
30 #include <QtCore/QString>
31 
32 class QIODevice;
33 
34 namespace KIMAP {
35 
36 class ImapParserException : public std::exception
37 {
38  public:
39  ImapParserException( const char *what ) throw() : mWhat( what ) {}
40  ImapParserException( const QByteArray &what ) throw() : mWhat( what ) {}
41  ImapParserException( const QString &what ) throw() : mWhat( what.toUtf8() ) {}
42  ImapParserException( const ImapParserException &other ) throw() : std::exception( other ), mWhat( other.what() ) {}
43  virtual ~ImapParserException() throw() {}
44  const char *what() const throw() { return mWhat.constData(); }
45  virtual const char *type() const throw() { return "ImapParserException"; }
46  private:
47  QByteArray mWhat;
48 };
49 
53 class KIMAP_EXPORT ImapStreamParser
54 {
55  public:
62  explicit ImapStreamParser( QIODevice *socket, bool serverModeEnabled = false );
63 
67  ~ImapStreamParser();
68 
74  QString readUtf8String();
75 
80  QByteArray readString();
81 
87  QList<QByteArray> readParenthesizedList();
88 
89 
95  qint64 readNumber( bool * ok = 0 );
96 
101  bool hasString();
102 
109  bool hasLiteral();
110 
130  QByteArray readLiteralPart();
131 
136  bool atLiteralEnd() const;
137 
142  bool hasList();
143 
148  bool atListEnd();
149 
154  bool hasResponseCode();
155 
160  bool atResponseCodeEnd();
161 
166  bool atCommandEnd();
167 
172  QByteArray readUntilCommandEnd();
173 
178  QByteArray readRemainingData();
179 
180  int availableDataSize() const;
181 
182  void setData( const QByteArray &data );
183 
184 
185  private:
186  void stripLeadingSpaces();
187  QByteArray parseQuotedString();
188 
195  bool waitForMoreData( bool wait);
196 
200  void sendContinuationResponse( qint64 size );
201 
205  void trimBuffer();
206 
207  QIODevice *m_socket;
208  bool m_isServerModeEnabled;
209  QByteArray m_data;
210  int m_position;
211  qint64 m_literalSize;
212 };
213 
214 }
215 
216 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:25:17 by doxygen 1.8.3.1 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.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • 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