File indexing completed on 2024-05-05 05:44:48
0001 /*************************************************************************** 0002 * Copyright (C) 2006-2009 by Rajko Albrecht * 0003 * ral@alwins-world.de * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0019 ***************************************************************************/ 0020 #ifndef KIOBYTESTREAM_H 0021 #define KIOBYTESTREAM_H 0022 0023 #include "svnqt/svnstream.h" 0024 0025 #include <QElapsedTimer> 0026 #include <QMimeType> 0027 #include <kio/global.h> 0028 0029 class StreamWrittenCb 0030 { 0031 public: 0032 StreamWrittenCb() = default; 0033 virtual ~StreamWrittenCb() = default; 0034 virtual void streamWritten(const KIO::filesize_t current) = 0; 0035 virtual void streamPushData(const QByteArray &streamData) = 0; 0036 virtual void streamSendMime(const QMimeType &mt) = 0; 0037 }; 0038 0039 /** 0040 @author Rajko Albrecht 0041 */ 0042 class KioByteStream : public svn::stream::SvnStream 0043 { 0044 public: 0045 KioByteStream(StreamWrittenCb *, const QString &filename); 0046 0047 ~KioByteStream() override; 0048 0049 bool isOk() const override; 0050 long write(const char *data, const unsigned long max) override; 0051 0052 KIO::filesize_t written() 0053 { 0054 return m_Written; 0055 } 0056 0057 protected: 0058 StreamWrittenCb *m_Cb; 0059 KIO::filesize_t m_Written; 0060 bool m_mimeSend; 0061 QString m_Filename; 0062 QByteArray array; 0063 QElapsedTimer m_MessageTick; 0064 }; 0065 0066 #endif