KIO
httpfilter.h
Go to the documentation of this file.00001 /* 00002 This file is part of the KDE libraries 00003 Copyright (c) 2002 Waldo Bastian <bastian@kde.org> 00004 Copyright 2009 David Faure <faure@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public 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 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef _HTTPFILTER_H_ 00022 #define _HTTPFILTER_H_ 00023 00024 #include <config.h> 00025 00026 class KGzipFilter; 00027 #include <QBuffer> 00028 00029 #include <QObject> 00030 #include <kcodecs.h> 00031 00032 class HTTPFilterBase : public QObject 00033 { 00034 Q_OBJECT 00035 public: 00036 HTTPFilterBase(); 00037 ~HTTPFilterBase(); 00038 00039 void chain(HTTPFilterBase *previous); 00040 00041 public Q_SLOTS: 00042 virtual void slotInput(const QByteArray &d) = 0; 00043 00044 Q_SIGNALS: 00045 void output(const QByteArray &d); 00046 void error(const QString &); 00047 00048 protected: 00049 HTTPFilterBase *last; 00050 }; 00051 00052 class HTTPFilterChain : public HTTPFilterBase 00053 { 00054 Q_OBJECT 00055 public: 00056 HTTPFilterChain(); 00057 00058 void addFilter(HTTPFilterBase *filter); 00059 00060 public Q_SLOTS: 00061 void slotInput(const QByteArray &d); 00062 00063 private: 00064 HTTPFilterBase *first; 00065 }; 00066 00067 class HTTPFilterMD5 : public HTTPFilterBase 00068 { 00069 Q_OBJECT 00070 public: 00071 HTTPFilterMD5(); 00072 00073 QString md5(); 00074 00075 public Q_SLOTS: 00076 void slotInput(const QByteArray &d); 00077 00078 private: 00079 KMD5 context; 00080 }; 00081 00082 00083 class HTTPFilterGZip : public HTTPFilterBase 00084 { 00085 Q_OBJECT 00086 public: 00087 HTTPFilterGZip(bool deflate = false /* for subclass HTTPFilterDeflate */ ); 00088 ~HTTPFilterGZip(); 00089 00090 public Q_SLOTS: 00091 void slotInput(const QByteArray &d); 00092 00093 private: 00094 bool m_deflateMode; 00095 bool m_firstData; 00096 bool m_finished; 00097 KGzipFilter* m_gzipFilter; 00098 }; 00099 00100 class HTTPFilterDeflate : public HTTPFilterGZip 00101 { 00102 Q_OBJECT 00103 public: 00104 HTTPFilterDeflate(); 00105 }; 00106 00107 #endif