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

KIMAP Library

  • sources
  • kde-4.12
  • kdepimlibs
  • 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  explicit ImapParserException( const char *what ) throw() : mWhat( what ) {}
40  explicit ImapParserException( const QByteArray &what ) throw() : mWhat( what ) {}
41  explicit 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 
94  qint64 readNumber( bool * ok = 0 );
95 
100  bool hasString();
101 
108  bool hasLiteral();
109 
129  QByteArray readLiteralPart();
130 
135  bool atLiteralEnd() const;
136 
141  bool hasList();
142 
147  bool atListEnd();
148 
153  bool hasResponseCode();
154 
159  bool atResponseCodeEnd();
160 
165  bool atCommandEnd();
166 
171  QByteArray readUntilCommandEnd();
172 
177  QByteArray readRemainingData();
178 
179  int availableDataSize() const;
180 
181  void setData( const QByteArray &data );
182 
183  private:
184  void stripLeadingSpaces();
185  QByteArray parseQuotedString();
186 
193  bool waitForMoreData( bool wait);
194 
198  void sendContinuationResponse( qint64 size );
199 
203  void trimBuffer();
204 
205  QIODevice *m_socket;
206  bool m_isServerModeEnabled;
207  QByteArray m_data;
208  int m_position;
209  qint64 m_literalSize;
210 };
211 
212 }
213 
214 #endif
KIMAP::ImapStreamParser
Parser for IMAP messages that operates on a local socket stream.
Definition: imapstreamparser.h:53
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:08 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



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