kioslave/imap4
imap4.h
00001 #ifndef _IMAP4_H 00002 #define _IMAP4_H 00003 /********************************************************************** 00004 * 00005 * imap4.h - IMAP4rev1 KIOSlave 00006 * Copyright (C) 2001-2002 Michael Haeckel <haeckel@kde.org> 00007 * Copyright (C) 1999 John Corey <jcorey@fruity.ath.cx> 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00022 * 00023 * Send comments and bug fixes to jcorey@fruity.ath.cx 00024 * 00025 *********************************************************************/ 00026 00027 #include "imap4-config.h" 00028 #include "imapparser.h" 00029 #include "mimeio.h" 00030 00031 #include <kio/tcpslavebase.h> 00032 #include <QBuffer> 00033 #include <QDateTime> 00034 #include <QByteArray> 00035 00036 #define IMAP_BUFFER 8192 00037 00039 enum IMAP_TYPE 00040 { 00041 ITYPE_UNKNOWN, /*< unknown type */ 00042 ITYPE_DIR, /*< Object is a directory. i.e. does not contain message, just mailboxes */ 00043 ITYPE_BOX, /*< Object is a mailbox. i.e. contains mails */ 00044 ITYPE_DIR_AND_BOX, /*< Object contains both mails and mailboxes */ 00045 ITYPE_MSG, /*< Object is a mail */ 00046 ITYPE_ATTACH /*< Object is an attachment */ 00047 }; 00048 00050 class IMAP4Protocol:public 00051 KIO::TCPSlaveBase, 00052 public 00053 imapParser, 00054 public 00055 mimeIO 00056 { 00057 00058 public: 00059 00060 // reimplement the TCPSlave 00061 IMAP4Protocol (const QByteArray & pool, const QByteArray & app, bool isSSL); 00062 virtual ~IMAP4Protocol (); 00063 00064 virtual void openConnection(); 00065 virtual void closeConnection(); 00066 00067 virtual void setHost (const QString & _host, quint16 _port, const QString & _user, 00068 const QString & _pass); 00075 virtual void get (const KUrl & _url); 00079 virtual void stat (const KUrl & _url); 00080 virtual void slave_status (); 00084 virtual void del (const KUrl & _url, bool isFile); 00089 virtual void special (const QByteArray & data); 00093 virtual void listDir (const KUrl & _url); 00094 virtual void setSubURL (const KUrl & _url); 00095 virtual void dispatch (int command, const QByteArray & data); 00099 virtual void mkdir (const KUrl & url, int permissions); 00100 virtual void put (const KUrl & url, int permissions, KIO::JobFlags flags); 00101 virtual void rename (const KUrl & src, const KUrl & dest, KIO::JobFlags flags); 00102 virtual void copy (const KUrl & src, const KUrl & dest, int permissions, 00103 KIO::JobFlags flags); 00104 00108 virtual void parseRelay (const QByteArray & buffer); 00109 00113 virtual void parseRelay (ulong); 00114 00117 virtual bool parseRead (QByteArray &buffer, long len, long relay=0); 00118 00121 virtual bool parseReadLine (QByteArray & buffer, long relay = 0); 00122 00125 virtual void parseWriteLine (const QString &); 00126 00128 virtual int outputLine (const QByteArray & _str, int len = -1); 00129 00131 virtual void flushOutput(const QString &contentEncoding = QString()); 00132 00133 protected: 00134 00135 // select or examine the box if needed 00136 bool assureBox (const QString & aBox, bool readonly); 00137 00138 ssize_t myRead(void *data, ssize_t len); 00139 00147 enum IMAP_TYPE 00148 parseURL (const KUrl & _url, QString & _box, QString & _section, 00149 QString & _type, QString & _uid, QString & _validity, 00150 QString & _hierarchyDelimiter, QString & _info, 00151 bool cache = false); 00152 QString getMimeType (enum IMAP_TYPE); 00153 00154 bool makeLogin (); 00155 00156 void outputLineStr (const QString & _str) 00157 { 00158 outputLine (_str.toLatin1 (), _str.length()); 00159 } 00160 void doListEntry (const KUrl & _url, int stretch, imapCache * cache = NULL, 00161 bool withFlags = false, bool withSubject = false); 00162 00168 void doListEntry (const KUrl & url, const QString & myBox, 00169 const imapList & item, bool appendPath = true); 00170 00172 void specialACLCommand( int command, QDataStream& stream ); 00173 00175 void specialAnnotateMoreCommand( int command, QDataStream& stream ); 00176 void specialQuotaCommand( int command, QDataStream& stream ); 00177 00179 void specialSearchCommand( QDataStream& ); 00180 00182 void specialCustomCommand( QDataStream& ); 00183 00184 private: 00185 00186 // This method behaves like the above method but takes an already encoded url, 00187 // so you don't have to call KUrl::url() for every mail. 00188 void doListEntry (const QString & encodedUrl, int stretch, imapCache * cache = NULL, 00189 bool withFlags = false, bool withSubject = false); 00190 00191 QString myHost, myUser, myPass, myAuth, myTLS; 00192 int myPort; 00193 bool mySSL; 00194 00195 bool relayEnabled, cacheOutput, decodeContent; 00196 QByteArray outputCache; 00197 QBuffer outputBuffer; 00198 int outputBufferIndex; 00199 KIO::filesize_t mProcessedSize; 00200 00201 char readBuffer[IMAP_BUFFER]; 00202 ssize_t readBufferLen; 00203 int readSize; 00204 QDateTime mTimeOfLastNoop; 00205 }; 00206 00207 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Apr 30 2012 21:48:35 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Apr 30 2012 21:48:35 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.